diff options
Diffstat (limited to 'packages/merchant-backoffice-ui/src/components')
-rw-r--r-- | packages/merchant-backoffice-ui/src/components/form/InputSelector.tsx | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/packages/merchant-backoffice-ui/src/components/form/InputSelector.tsx b/packages/merchant-backoffice-ui/src/components/form/InputSelector.tsx index 7a419ebb9..021977dfe 100644 --- a/packages/merchant-backoffice-ui/src/components/form/InputSelector.tsx +++ b/packages/merchant-backoffice-ui/src/components/form/InputSelector.tsx @@ -25,6 +25,7 @@ interface Props<T> extends InputProps<T> { readonly?: boolean; expand?: boolean; values: string[]; + convert?: (v: string) => any; toStr?: (v?: any) => string; fromStr?: (s: string) => any; } @@ -41,6 +42,7 @@ export function InputSelector<T>({ label, help, values, + convert, toStr = defaultToString, }: Props<keyof T>): VNode { const { error, value, onChange } = useField<T>(name); @@ -66,7 +68,10 @@ export function InputSelector<T>({ disabled={readonly} readonly={readonly} onChange={(e) => { - onChange(e.currentTarget.value as any); + const v = convert + ? convert(e.currentTarget.value) + : e.currentTarget.value; + onChange(v); }} > {placeholder && <option>{placeholder}</option>} |