@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 SelectInputProps {
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({ options, defaultOption, value: controlledValue, onChange, onClear, disableClearable, ...props }: SelectInputProps): React.JSX.Element;
34
+ export declare function SelectInput(props: SelectInputProps): React.JSX.Element;
23
35
  export {};
@@ -1 +1 @@
1
- "use strict";import{Autocomplete as c,TextField as g}from"@mui/material";import{useState as v}from"react";import{jsx as r}from"react/jsx-runtime";function x({options:s,defaultOption:l,value:e,onChange:a,onClear:n,disableClearable:d,...f}){const[m,P]=v(l??null),u=e!==void 0,b=u?e:m,i=o=>{u||P(o),a&&a(o)},h=()=>{i(null),n&&n()},p={inputProps:{tabIndex:0},fullWidth:!0,...f.InputProps};return r(c,{disablePortal:!0,autoHighlight:!0,defaultValue:l,options:s,disableClearable:d,isOptionEqualToValue:(o,t)=>o?.id===t?.id,value:b,onChange:(o,t)=>{if(!t){h();return}i(t)},renderInput:o=>r(g,{...o,...p,inputProps:{...o.inputProps,...p.inputProps}})})}export{x as SelectInput};
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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verifiedinc-public/shared-ui-elements",
3
- "version": "12.5.2",
3
+ "version": "12.6.0",
4
4
  "description": "A set of UI components, utilities that is shareable with the core apps.",
5
5
  "private": false,
6
6
  "sideEffects": false,