From 5e31adb143e46d099c2b4a962b9b9a0ff3dd2260 Mon Sep 17 00:00:00 2001 From: lopesc Date: Fri, 22 Nov 2019 18:21:23 +0000 Subject: [PATCH] FIX (types): update type definitions for methods closes #53 thanks to @lopesc * FIX (types): update type definitions for methods * Update types.d.ts * FIX (types): update event type * FIX (types): add null as option for event params --- types.d.ts | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/types.d.ts b/types.d.ts index f571eff0..c7eb4830 100644 --- a/types.d.ts +++ b/types.d.ts @@ -1,32 +1,32 @@ -import React from 'react'; +import { React, SyntheticEvent, KeyboardEvent } from 'react'; export interface IState { dropdown: boolean; values: object; search: string; selectBounds: object; - cursor: object; + cursor: number; } export interface IMethods { - removeItem: () => void; - dropDown: () => void; + removeItem: (event: SyntheticEvent | null, item: IItemRenderer['item'], close: boolean) => void; + dropDown: (action: string, event: SyntheticEvent | null) => void; addItem: (item: IItemRenderer['item']) => void; - setSearch: () => void; - getInputSize: () => void; + setSearch: (event: SyntheticEvent) => void; + getInputSize: () => number; toggleSelectAll: () => void; clearAll: () => void; selectAll: () => void; searchResults: () => void; - getSelectRef: () => void; - isSelected: () => void; - getSelectBounds: () => void; - areAllSelected: () => void; - handleKeyDown: () => void; + getSelectRef: () => React.RefObject; + isSelected: (item: IItemRenderer['item']) => boolean; + getSelectBounds: () => ClientRect; + areAllSelected: () => boolean; + handleKeyDown: (event: KeyboardEvent) => void; activeCursorItem: () => void; - createNew: () => void; - sortBy: () => void; - safeString: () => void; + createNew: (item: IItemRenderer['item']) => void; + sortBy: () => ISelectProps['options']; + safeString: (input: string) => string; } export interface IRenderer { @@ -36,7 +36,7 @@ export interface IRenderer { } export interface IKeyDown { - event: Event; + event: KeyboardEvent; props?: ISelectProps; state?: IState; methods?: IMethods;