Skip to content

Commit

Permalink
fix: SelectOnChange value type
Browse files Browse the repository at this point in the history
  • Loading branch information
bmartel committed Jan 20, 2024
1 parent 5e3aed2 commit a9e87fa
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/use-select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export enum ChangeActions {
}

export type SelectOnChange = (
value: string | number | Array<string | number>,
value: Option|Option[],
change?: {
action: ChangeActions
value: any
Expand Down Expand Up @@ -1222,7 +1222,7 @@ export function useMultiSelect(
(next, change) => {
switch (change?.action) {
case ChangeActions.SingleCreate:
setNextValue(next as string, change)
setNextValue(next, change)
setOptions((o) => {
const opt = getOption(next as any)
return o.some((_o) => getOption(_o).value === opt.value)
Expand All @@ -1232,13 +1232,13 @@ export function useMultiSelect(
break
case ChangeActions.SingleClear:
case ChangeActions.SingleRemove:
setNextValue(next as string, change)
setNextValue(next, change)
break
case ChangeActions.SingleSelect:
setNextValue(next as string, change)
setNextValue(next, change)
break
case ChangeActions.MultiCreate:
const nextValue = next as string[]
const nextValue = next as Option[]
const created = next[nextValue.length - 1]
setNextValue(nextValue, change)
setOptions((o) => {
Expand All @@ -1250,11 +1250,11 @@ export function useMultiSelect(
break
case ChangeActions.MultiClear:
case ChangeActions.MultiRemove:
setNextValue(next as string[], change)
setNextValue(next, change)
break
case ChangeActions.MultiSelect:
default:
setNextValue(next as string[], change)
setNextValue(next, change)
}
},
[setValue, setOptions, getOption]
Expand Down

0 comments on commit a9e87fa

Please sign in to comment.