@verifiedinc-public/shared-ui-elements 12.5.2 → 12.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5,19 +5,31 @@ interface Option {
|
|
|
5
5
|
label: string;
|
|
6
6
|
id: string;
|
|
7
7
|
}
|
|
8
|
-
interface
|
|
8
|
+
interface SelectInputBaseProps {
|
|
9
9
|
name?: string;
|
|
10
|
-
onChange?: (value: Option | null) => void;
|
|
11
10
|
onClear?: () => void;
|
|
12
11
|
options: Option[];
|
|
13
|
-
value?: Option | null;
|
|
14
|
-
defaultOption?: Option;
|
|
15
12
|
InputProps?: TextFieldProps;
|
|
16
13
|
disableClearable?: boolean;
|
|
17
14
|
}
|
|
15
|
+
interface SelectInputSingleProps extends SelectInputBaseProps {
|
|
16
|
+
multiple?: false;
|
|
17
|
+
onChange?: (value: Option | null) => void;
|
|
18
|
+
value?: Option | null;
|
|
19
|
+
defaultOption?: Option;
|
|
20
|
+
}
|
|
21
|
+
interface SelectInputMultipleProps extends SelectInputBaseProps {
|
|
22
|
+
multiple: true;
|
|
23
|
+
onChange?: (value: Option[]) => void;
|
|
24
|
+
value?: Option[];
|
|
25
|
+
defaultOption?: Option[];
|
|
26
|
+
}
|
|
27
|
+
type SelectInputProps = SelectInputSingleProps | SelectInputMultipleProps;
|
|
18
28
|
/**
|
|
19
29
|
* This component manages the input of type Select.
|
|
30
|
+
* Pass `multiple` to select many options; `value`, `defaultOption`, and
|
|
31
|
+
* `onChange` then work with `Option[]` instead of `Option | null`.
|
|
20
32
|
* @constructor
|
|
21
33
|
*/
|
|
22
|
-
export declare function SelectInput(
|
|
34
|
+
export declare function SelectInput(props: SelectInputProps): React.JSX.Element;
|
|
23
35
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{Autocomplete as
|
|
1
|
+
"use strict";import{Autocomplete as m,TextField as v}from"@mui/material";import{useState as C}from"react";import{jsx as t}from"react/jsx-runtime";function I(e){return e.multiple?t(x,{...e}):t(c,{...e})}function c({options:e,defaultOption:n,value:i,onChange:a,onClear:u,disableClearable:f,...P}){const[b,h]=C(n??null),p=i!==void 0,g=p?i:b,s=l=>{p||h(l),a&&a(l)},d=()=>{s(null),u&&u()},o={inputProps:{tabIndex:0},fullWidth:!0,...P.InputProps};return t(m,{disablePortal:!0,autoHighlight:!0,defaultValue:n,options:e,disableClearable:f,isOptionEqualToValue:(l,r)=>l?.id===r?.id,value:g,onChange:(l,r)=>{if(!r){d();return}s(r)},renderInput:l=>t(v,{...l,...o,inputProps:{...l.inputProps,...o.inputProps}})})}function x({options:e,defaultOption:n,value:i,onChange:a,onClear:u,disableClearable:f,...P}){const[b,h]=C(n??[]),p=i!==void 0,g=p?i:b,s=o=>{p||h(o),a&&a(o)},d={inputProps:{tabIndex:0},fullWidth:!0,...P.InputProps};return t(m,{multiple:!0,disablePortal:!0,autoHighlight:!0,defaultValue:n,options:e,disableClearable:f,isOptionEqualToValue:(o,l)=>o?.id===l?.id,value:g,onChange:(o,l)=>{s(l),l.length===0&&u&&u()},renderInput:o=>t(v,{...o,...d,inputProps:{...o.inputProps,...d.inputProps}})})}export{I as SelectInput};
|