@verifiedinc-public/shared-ui-elements 12.5.2 → 12.7.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.
@@ -1,2 +1,10 @@
1
1
  import { PropsWithChildren } from 'react';
2
- export declare function Tip({ children }: PropsWithChildren): React.JSX.Element;
2
+ interface TipProps extends PropsWithChildren {
3
+ /**
4
+ * Widens the popover past MUI Tooltip's ~300px default for content that must not wrap,
5
+ * like a code snippet with a long line. Omit to keep the default.
6
+ */
7
+ maxWidth?: number | string;
8
+ }
9
+ export declare function Tip({ children, maxWidth }: TipProps): React.JSX.Element;
10
+ export {};
@@ -1 +1 @@
1
- "use strict";import{Tooltip as t,IconButton as e}from"@mui/material";import{Code as n}from"@mui/icons-material";import{jsx as o}from"react/jsx-runtime";function a({children:r}){return o(t,{title:r,arrow:!0,enterTouchDelay:0,children:o(e,{size:"small",onClick:i=>{i.stopPropagation()},children:o(n,{})})})}export{a as Tip};
1
+ "use strict";import{Tooltip as n,IconButton as e}from"@mui/material";import{Code as s}from"@mui/icons-material";import{jsx as o}from"react/jsx-runtime";function a({children:i,maxWidth:t}){return o(n,{title:i,arrow:!0,enterTouchDelay:0,componentsProps:t===void 0?void 0:{tooltip:{sx:{maxWidth:t}}},children:o(e,{size:"small",onClick:r=>{r.stopPropagation()},children:o(s,{})})})}export{a as Tip};
@@ -5,19 +5,36 @@ 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
+ * How many chips to show while the input is not focused; the rest collapse into `+N`.
28
+ * Focusing the input always reveals the full selection. Pass -1 to never collapse.
29
+ */
30
+ limitTags?: number;
31
+ }
32
+ type SelectInputProps = SelectInputSingleProps | SelectInputMultipleProps;
18
33
  /**
19
34
  * This component manages the input of type Select.
35
+ * Pass `multiple` to select many options; `value`, `defaultOption`, and
36
+ * `onChange` then work with `Option[]` instead of `Option | null`.
20
37
  * @constructor
21
38
  */
22
- export declare function SelectInput({ options, defaultOption, value: controlledValue, onChange, onClear, disableClearable, ...props }: SelectInputProps): React.JSX.Element;
39
+ export declare function SelectInput(props: SelectInputProps): React.JSX.Element;
23
40
  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 C,Checkbox as O}from"@mui/material";import{useState as g}from"react";import{jsx as t,jsxs as T}from"react/jsx-runtime";function V(o){return o.multiple?t(E,{...o}):t(k,{...o})}function k({options:o,defaultOption:n,value:i,onChange:a,onClear:u,disableClearable:b,...c}){const[h,P]=g(n??null),p=i!==void 0,s=p?i:h,d=e=>{p||P(e),a&&a(e)},f=()=>{d(null),u&&u()},r={inputProps:{tabIndex:0},fullWidth:!0,...c.InputProps};return t(m,{disablePortal:!0,autoHighlight:!0,defaultValue:n,options:o,disableClearable:b,isOptionEqualToValue:(e,l)=>e?.id===l?.id,value:s,onChange:(e,l)=>{if(!l){f();return}d(l)},renderInput:e=>t(C,{...e,...r,inputProps:{...e.inputProps,...r.inputProps}})})}function E({options:o,defaultOption:n,value:i,onChange:a,onClear:u,disableClearable:b,limitTags:c=2,...h}){const[P,p]=g(n??[]),s=i!==void 0,d=s?i:P,f=e=>{s||p(e),a&&a(e)},r={inputProps:{tabIndex:0},fullWidth:!0,...h.InputProps};return t(m,{multiple:!0,disableCloseOnSelect:!0,limitTags:c,disablePortal:!0,autoHighlight:!0,defaultValue:n,options:o,disableClearable:b,isOptionEqualToValue:(e,l)=>e?.id===l?.id,value:d,onChange:(e,l)=>{f(l),l.length===0&&u&&u()},renderOption:(e,l,{selected:v})=>{const{key:x,...I}=e;return T("li",{...I,children:[t(O,{checked:v,sx:{mr:1}}),l.label]},x)},renderInput:e=>t(C,{...e,...r,inputProps:{...e.inputProps,...r.inputProps}})})}export{V 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.7.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,