Skip to content

Commit

Permalink
fix(ts): Add type property for change callbacks in useCombobox and …
Browse files Browse the repository at this point in the history
…useSelect

The documentation clearly states that there is a `type` property passed in here. This has already been fixed for `useMultipleSelect`, so I’m leaving that alone and copying the approach.
  • Loading branch information
kimroen committed Jun 6, 2020
1 parent 45985a8 commit c7b1062
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,10 @@ export interface UseSelectProps<Item> {
state: UseSelectState<Item>,
actionAndChanges: UseSelectStateChangeOptions<Item>,
) => UseSelectState<Item>
onSelectedItemChange?: (changes: Partial<UseSelectState<Item>>) => void
onIsOpenChange?: (changes: Partial<UseSelectState<Item>>) => void
onHighlightedIndexChange?: (changes: Partial<UseSelectState<Item>>) => void
onStateChange?: (changes: Partial<UseSelectState<Item>>) => void
onSelectedItemChange?: (changes: UseSelectStateChange<Item>) => void
onIsOpenChange?: (changes: UseSelectStateChange<Item>) => void
onHighlightedIndexChange?: (changes: UseSelectStateChange<Item>) => void
onStateChange?: (changes: UseSelectStateChange<Item>) => void
environment?: Environment
}

Expand All @@ -305,6 +305,11 @@ export interface UseSelectStateChangeOptions<Item> {
props: UseSelectProps<Item>
}

export interface UseSelectStateChange<Item>
extends Partial<UseSelectState<Item>> {
type: UseSelectStateChangeTypes
}

export interface UseSelectGetMenuPropsOptions
extends GetPropsWithRefKey,
GetMenuPropsOptions {}
Expand Down Expand Up @@ -398,7 +403,7 @@ export enum UseComboboxStateChangeTypes {
FunctionSelectItem = '__function_select_item__',
FunctionSetInputValue = '__function_set_input_value__',
FunctionReset = '__function_reset__',
ControlledPropUpdatedSelectedItem = '__controlled_prop_updated_selected_item__'
ControlledPropUpdatedSelectedItem = '__controlled_prop_updated_selected_item__',
}

export interface UseComboboxProps<Item> {
Expand Down Expand Up @@ -430,11 +435,11 @@ export interface UseComboboxProps<Item> {
state: UseComboboxState<Item>,
actionAndChanges: UseComboboxStateChangeOptions<Item>,
) => UseComboboxState<Item>
onSelectedItemChange?: (changes: Partial<UseComboboxState<Item>>) => void
onIsOpenChange?: (changes: Partial<UseComboboxState<Item>>) => void
onHighlightedIndexChange?: (changes: Partial<UseComboboxState<Item>>) => void
onStateChange?: (changes: Partial<UseComboboxState<Item>>) => void
onInputValueChange?: (changes: Partial<UseComboboxState<Item>>) => void
onSelectedItemChange?: (changes: UseComboboxStateChange<Item>) => void
onIsOpenChange?: (changes: UseComboboxStateChange<Item>) => void
onHighlightedIndexChange?: (changes: UseComboboxStateChange<Item>) => void
onStateChange?: (changes: UseComboboxStateChange<Item>) => void
onInputValueChange?: (changes: UseComboboxStateChange<Item>) => void
environment?: Environment
}

Expand All @@ -444,6 +449,11 @@ export interface UseComboboxStateChangeOptions<Item> {
props: UseComboboxProps<Item>
}

export interface UseComboboxStateChange<Item>
extends Partial<UseComboboxState<Item>> {
type: UseComboboxStateChangeTypes
}

export interface UseComboboxGetMenuPropsOptions
extends GetPropsWithRefKey,
GetMenuPropsOptions {}
Expand Down Expand Up @@ -588,7 +598,8 @@ export interface A11yRemovalMessage<Item> {
}

export interface UseMultipleSelectionGetSelectedItemPropsOptions<Item>
extends React.HTMLProps<HTMLElement>, GetPropsWithRefKey {
extends React.HTMLProps<HTMLElement>,
GetPropsWithRefKey {
index?: number
selectedItem: Item
}
Expand Down

0 comments on commit c7b1062

Please sign in to comment.