@s_mart/form 6.1.1 → 6.2.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.
- package/dist/index.d.mts +124 -9
- package/dist/index.mjs +19 -19
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -110,18 +110,30 @@ type TextFieldProps = TextFieldProps$1 & ControllerTextField & {
|
|
|
110
110
|
|
|
111
111
|
declare const _default$6: react.MemoExoticComponent<({ name, rules, defaultValue, shouldUnregister, label, required, mask, variant, info, parse, inputMode, format, onInputChange, disableIconError, ...rest }: TextFieldProps) => react_jsx_runtime.JSX.Element>;
|
|
112
112
|
|
|
113
|
-
|
|
113
|
+
/**
|
|
114
|
+
* @deprecated usar SelectV2
|
|
115
|
+
*/
|
|
116
|
+
declare const Select: react.MemoExoticComponent<({ name, rules, defaultValue, shouldUnregister, label, required, options, placeholder, clearable, disableOnChangeForm, multiple, info, footer, onChange: onChangeProp, disableIconError, variant, ...rest }: SelectProps) => react_jsx_runtime.JSX.Element>;
|
|
114
117
|
|
|
115
|
-
type ControllerSelect = Omit<ControllerProps, 'render' | 'control'>;
|
|
118
|
+
type ControllerSelect$1 = Omit<ControllerProps, 'render' | 'control'>;
|
|
119
|
+
/**
|
|
120
|
+
* @deprecated
|
|
121
|
+
*/
|
|
116
122
|
type SelectOption = {
|
|
117
123
|
label: string;
|
|
118
124
|
value: string | number | readonly string[] | undefined;
|
|
119
125
|
afterLabel?: string | React.ReactNode;
|
|
120
126
|
};
|
|
127
|
+
/**
|
|
128
|
+
* @deprecated
|
|
129
|
+
*/
|
|
121
130
|
type FooterProps = {
|
|
122
131
|
closeSelect: () => void;
|
|
123
132
|
};
|
|
124
|
-
|
|
133
|
+
/**
|
|
134
|
+
* @deprecated
|
|
135
|
+
*/
|
|
136
|
+
type SelectProps = Omit<SelectProps$1, 'onChange'> & ControllerSelect$1 & {
|
|
125
137
|
/**
|
|
126
138
|
* As opções que serão renderizadas no select
|
|
127
139
|
*
|
|
@@ -180,12 +192,18 @@ type SelectProps = Omit<SelectProps$1, 'onChange'> & ControllerSelect & {
|
|
|
180
192
|
};
|
|
181
193
|
|
|
182
194
|
type ControllerSearchable = Omit<ControllerProps, 'render' | 'control'>;
|
|
195
|
+
/**
|
|
196
|
+
* @deprecated usar SearchableV2
|
|
197
|
+
*/
|
|
183
198
|
type SearchableOption = {
|
|
184
199
|
key?: string | number;
|
|
185
200
|
label: string;
|
|
186
201
|
value: string | number | readonly string[] | undefined;
|
|
187
202
|
afterLabel?: string | React.ReactNode;
|
|
188
203
|
} | string;
|
|
204
|
+
/**
|
|
205
|
+
* @deprecated usar SearchableV2
|
|
206
|
+
*/
|
|
189
207
|
type SearchableProps = Omit<AutocompleteProps$1<SearchableOption, true, true, true>, 'renderInput' | 'size' | 'onInputChange' | 'onChange'> & ControllerSearchable & {
|
|
190
208
|
/**
|
|
191
209
|
* Opções do autocomplete
|
|
@@ -243,7 +261,10 @@ type SearchableProps = Omit<AutocompleteProps$1<SearchableOption, true, true, tr
|
|
|
243
261
|
placeholder?: string;
|
|
244
262
|
};
|
|
245
263
|
|
|
246
|
-
|
|
264
|
+
/**
|
|
265
|
+
* @deprecated usar SearchableV2
|
|
266
|
+
*/
|
|
267
|
+
declare const Searchable: react.MemoExoticComponent<({ name, rules, defaultValue, shouldUnregister, label, required, options, textFieldProps, noOptionsText, footer, multiple, info, placeholder, onChange: onChangeProp, onInputChange, disableIconError, ...rest }: SearchableProps) => react_jsx_runtime.JSX.Element>;
|
|
247
268
|
|
|
248
269
|
type ControllerCreatable = Omit<ControllerProps, 'render' | 'control'>;
|
|
249
270
|
type CreatableOption = {
|
|
@@ -344,7 +365,7 @@ type CreatableProps = Omit<AutocompleteProps$1<CreatableOption, true, true, true
|
|
|
344
365
|
placeholder?: string;
|
|
345
366
|
};
|
|
346
367
|
|
|
347
|
-
declare const _default$
|
|
368
|
+
declare const _default$5: react.MemoExoticComponent<({ name, rules, defaultValue, shouldUnregister, label, required, options, editable, footer, onEditOption, onCreateOption, textFieldProps, hideAddButton, multiple, info, onChange: onChangeProp, onInputChange, placeholder, disableIconError, ...rest }: CreatableProps) => react_jsx_runtime.JSX.Element>;
|
|
348
369
|
|
|
349
370
|
type ControllerCheckbox = Omit<ControllerProps, 'render' | 'control'>;
|
|
350
371
|
type CheckboxProps = CheckboxProps$1 & ControllerCheckbox & {
|
|
@@ -519,7 +540,7 @@ type DatePickerProps = Omit<UseControllerProps, 'control'> & Pick<TextFieldProps
|
|
|
519
540
|
disableIconError?: boolean;
|
|
520
541
|
};
|
|
521
542
|
|
|
522
|
-
declare const _default$
|
|
543
|
+
declare const _default$4: react.MemoExoticComponent<({ rules, name, defaultValue, shouldUnregister, datePickerProps, label, required, placeholder, disabled, disableIconError, ...rest }: DatePickerProps) => react_jsx_runtime.JSX.Element>;
|
|
523
544
|
|
|
524
545
|
type TimePickerProps = Omit<UseControllerProps, 'control'> & Pick<TextFieldProps$1, 'label' | 'error' | 'helperText' | 'size' | 'fullWidth' | 'variant' | 'autoFocus' | 'placeholder'> & {
|
|
525
546
|
timePickerProps?: Partial<TimePickerProps$1<any>>;
|
|
@@ -545,7 +566,7 @@ type TimePickerProps = Omit<UseControllerProps, 'control'> & Pick<TextFieldProps
|
|
|
545
566
|
disableIconError?: boolean;
|
|
546
567
|
};
|
|
547
568
|
|
|
548
|
-
declare const _default$
|
|
569
|
+
declare const _default$3: react.MemoExoticComponent<({ rules, defaultValue, shouldUnregister, name, required, label, timePickerProps, placeholder, disabled, disableIconError, ...rest }: TimePickerProps) => react_jsx_runtime.JSX.Element>;
|
|
549
570
|
|
|
550
571
|
type AutoCompleteOption = {
|
|
551
572
|
key?: string | number;
|
|
@@ -589,7 +610,7 @@ type AutocompleteProps<T = any> = Omit<UseControllerProps, 'control'> & Omit<Aut
|
|
|
589
610
|
placeholder?: string;
|
|
590
611
|
};
|
|
591
612
|
|
|
592
|
-
declare const _default: react.MemoExoticComponent<({ name, defaultValue, rules, shouldUnregister, label, required, noOptionsText, placeholder, onInputChange, onChange, disableIconError, ...rest }: AutocompleteProps) => react_jsx_runtime.JSX.Element>;
|
|
613
|
+
declare const _default$2: react.MemoExoticComponent<({ name, defaultValue, rules, shouldUnregister, label, required, noOptionsText, placeholder, onInputChange, onChange, disableIconError, ...rest }: AutocompleteProps) => react_jsx_runtime.JSX.Element>;
|
|
593
614
|
|
|
594
615
|
type FieldLabelProps = {
|
|
595
616
|
label: React.ReactNode;
|
|
@@ -599,4 +620,98 @@ type FieldLabelProps = {
|
|
|
599
620
|
|
|
600
621
|
declare const FieldLabel: ({ label, required, regular }: FieldLabelProps) => react_jsx_runtime.JSX.Element;
|
|
601
622
|
|
|
602
|
-
|
|
623
|
+
type SearchableV2Props<T extends FieldValues = any> = Omit<AutocompleteProps$1<T, true, true, true>, 'renderInput' | 'size' | 'onInputChange' | 'onChange' | 'getOptionLabel' | 'getOptionKey' | 'defaultValue'> & Omit<ControllerProps, 'render' | 'control'> & {
|
|
624
|
+
options: T[];
|
|
625
|
+
textFieldProps?: TextFieldProps$1;
|
|
626
|
+
label?: React.ReactNode;
|
|
627
|
+
required?: boolean;
|
|
628
|
+
/**
|
|
629
|
+
* Texto que será exibido quando não houver opções para serem exibidas
|
|
630
|
+
* @default 'Nenhuma opção encontrada'
|
|
631
|
+
*/
|
|
632
|
+
noOptionsText?: string;
|
|
633
|
+
/**
|
|
634
|
+
* Componente que renderiza no footer do searchable (opcional)
|
|
635
|
+
* @example
|
|
636
|
+
* footer: (
|
|
637
|
+
* <Button onClick={handleClick}>Mostrar mais...</Button>
|
|
638
|
+
* )
|
|
639
|
+
*/
|
|
640
|
+
footer?: React.ReactNode;
|
|
641
|
+
/**
|
|
642
|
+
* É o conteúdo passado para a tooltip que renderizará ao lado da label do campo,
|
|
643
|
+
* montada à tela como um ícone de informação.
|
|
644
|
+
*/
|
|
645
|
+
info?: React.ReactNode;
|
|
646
|
+
defaultValue?: T | T[];
|
|
647
|
+
placeholder?: string;
|
|
648
|
+
onInputChange?: (value: string) => void;
|
|
649
|
+
onChange?: (value: T | T[]) => void;
|
|
650
|
+
/**
|
|
651
|
+
* Define a key unica da option
|
|
652
|
+
*/
|
|
653
|
+
getOptionKey: (option: T) => string | number;
|
|
654
|
+
/**
|
|
655
|
+
* Define a label da option
|
|
656
|
+
*/
|
|
657
|
+
getOptionLabel: (option: T) => string;
|
|
658
|
+
/**
|
|
659
|
+
* Componente renderizado embaixo da option da listagem
|
|
660
|
+
*/
|
|
661
|
+
getOptionAfterLabel?: (option: T) => string | React.ReactNode;
|
|
662
|
+
};
|
|
663
|
+
|
|
664
|
+
declare const _default$1: <T extends FieldValues>({ name, rules, defaultValue, shouldUnregister, label, required, options, textFieldProps, noOptionsText, footer, multiple, info, placeholder, onChange: onChangeProp, onInputChange, getOptionAfterLabel, getOptionLabel, getOptionKey, ...rest }: SearchableV2Props<T>) => react_jsx_runtime.JSX.Element;
|
|
665
|
+
|
|
666
|
+
type ControllerSelect = Omit<ControllerProps, 'render' | 'control'>;
|
|
667
|
+
type FooterPropsV2 = {
|
|
668
|
+
closeSelect: () => void;
|
|
669
|
+
};
|
|
670
|
+
type SelectV2Props<T extends FieldValues> = Omit<SelectProps$1, 'onChange' | 'multiple' | 'defaultValue'> & ControllerSelect & {
|
|
671
|
+
/**
|
|
672
|
+
* As opções que serão renderizadas no select
|
|
673
|
+
*/
|
|
674
|
+
options: T[];
|
|
675
|
+
onChange?: (value: T | null) => void;
|
|
676
|
+
/**
|
|
677
|
+
* Função que renderiza o footer do select (opcional) - recebe como parâmetro a função closeSelect que fecha o select
|
|
678
|
+
* @param {FooterProps} props
|
|
679
|
+
*
|
|
680
|
+
* @example
|
|
681
|
+
* footer: ({ closeSelect }) => (
|
|
682
|
+
* <Button onClick={closeSelect}>Fechar</Button>
|
|
683
|
+
* )
|
|
684
|
+
*
|
|
685
|
+
*/
|
|
686
|
+
footer?: (props: FooterPropsV2) => React.ReactNode;
|
|
687
|
+
/**
|
|
688
|
+
* É o conteúdo passado para a tooltip que renderizará ao lado da label do campo,
|
|
689
|
+
* montada à tela como um ícone de informação.
|
|
690
|
+
*/
|
|
691
|
+
info?: React.ReactNode;
|
|
692
|
+
/**
|
|
693
|
+
* Habilita ícone no endAdornment para limpar o valor do campo.
|
|
694
|
+
* @default false
|
|
695
|
+
*
|
|
696
|
+
* @example
|
|
697
|
+
* <Select clearable />
|
|
698
|
+
*/
|
|
699
|
+
clearable?: boolean;
|
|
700
|
+
defaultValue?: T;
|
|
701
|
+
/**
|
|
702
|
+
* Define a key unica da option
|
|
703
|
+
*/
|
|
704
|
+
getOptionKey: (option: T) => string | number;
|
|
705
|
+
/**
|
|
706
|
+
* Define a label da option
|
|
707
|
+
*/
|
|
708
|
+
getOptionLabel: (option: T) => string;
|
|
709
|
+
/**
|
|
710
|
+
* Componente renderizado embaixo da option da listagem
|
|
711
|
+
*/
|
|
712
|
+
getOptionAfterLabel?: (option: T) => string | React.ReactNode;
|
|
713
|
+
};
|
|
714
|
+
|
|
715
|
+
declare const _default: <T extends FieldValues>({ name, rules, defaultValue, shouldUnregister, label, required, options, placeholder, clearable, info, footer, onChange: onChangeProp, variant, getOptionKey, getOptionLabel, getOptionAfterLabel, ...rest }: SelectV2Props<T>) => react_jsx_runtime.JSX.Element;
|
|
716
|
+
|
|
717
|
+
export { _default$2 as Autocomplete, type AutocompleteProps, Checkbox, type CheckboxProps, _default$5 as Creatable, type CreatableOption, type CreatableProps, _default$4 as DatePicker, type DatePickerProps, FieldLabel, type FieldLabelProps, type FooterProps, type FooterPropsV2, Form, FormProvider, type IFormProps, type IFormProviderProps, type IUseFormProps, RadioButton, RadioGroup, type RadioGroupProps, type RadioProps, Searchable, type SearchableOption, type SearchableProps, _default$1 as SearchableV2, type SearchableV2Props, Select, type SelectOption, type SelectProps, _default as SelectV2, type SelectV2Props, Slider, type SliderProps, Switch, type SwitchProps, _default$6 as TextField, type TextFieldProps, _default$3 as TimePicker, type TimePickerProps, useForm };
|
package/dist/index.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import{FormProvider as
|
|
1
|
+
import{FormProvider as Ne}from"react-hook-form";import{jsx as Fe}from"react/jsx-runtime";function He({children:e,style:t,onSubmit:n,...i}){return Fe(Ne,{...i,children:Fe("form",{onSubmit:l=>{l.preventDefault(),l.stopPropagation(),n(l)},style:t,children:e})})}var pe=He;import{useEffect as We}from"react";import{useForm as Ye}from"react-hook-form";import{zodResolver as Ke}from"@hookform/resolvers/zod";var Je=({disableDefaultValuesUpdate:e,onSubmit:t,...n})=>{let i=Ye({...n,resolver:n.schema&&Ke(n.schema)});return We(()=>{e||i.reset(n.defaultValues)},[n.defaultValues,i.reset]),{...i,onSubmit:i.handleSubmit(l=>t(l,i))}},me=Je;import{jsx as Ze}from"react/jsx-runtime";function Xe({children:e,style:t,...n}){let i=me(n);return Ze(pe,{...i,style:t,children:typeof e=="function"?e(i):e})}var Qe=Xe;import{memo as ao,useState as so}from"react";import{Controller as po,useFormContext as mo}from"react-hook-form";import{Grid as ue,InputAdornment as uo,TextField as fo}from"@mui/material";import{lineEye as co,lineEyeSlash as yo,lineInfoCircle as xo}from"@s_mart/solid-icons";import*as he from"@s_mart/masks";import{Typography as Pe}from"@mui/material";import{toRem as eo}from"@s_mart/utils";import{jsx as be,jsxs as ro}from"react/jsx-runtime";var oo=({label:e,required:t,regular:n})=>ro("span",{style:{display:"flex",alignItems:"center",gap:eo(2)},children:[be(Pe,{variant:"caption",fontWeight:n?400:700,style:{display:"flex",alignItems:"center"},children:e}),t&&be(Pe,{variant:"caption",fontWeight:900,color:"error",children:"*"})]}),C=oo;import{useFormContext as to}from"react-hook-form";import{Indicator as io}from"@s_mart/core";var w=(e,t)=>t.replace(/[[\]]/g,"").split(".").reduce((i,l)=>i?.[l],e);import{jsx as no}from"react/jsx-runtime";var lo=({name:e,disableIcon:t})=>{let n=to(),i=w(n?.formState?.errors,e);return i?no(io,{severity:"error",icon:t?!1:void 0,children:i?.message}):null},S=lo;import{LIcon as ge,Tooltip as Fo}from"@s_mart/core";import{jsx as $,jsxs as ve}from"react/jsx-runtime";var Po=({name:e,rules:t,defaultValue:n,shouldUnregister:i,label:l,required:g,mask:F,variant:v="outlined",info:I,parse:u,inputMode:y,format:a,onInputChange:b,disableIconError:f,...x})=>{let P=mo();if(!P)throw new Error("Para usar o <TextField /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let[s,h]=so(!1),d=r=>{let o=r;return a&&(o=a(r)),F?he?.[F]?.format(o):o},m=r=>{let o=r;return u&&(o=u(r)),F?he?.[F]?.parse(o):o},G=r=>{if(!r||F!=="porcentagem"&&F!=="porcentagem0")return;r?.stopPropagation();let o=(r?.target).value;if(o){let p=String(o);if(p.length>0){let c=p.indexOf("%");c>-1&&(r.currentTarget.selectionEnd=c)}}},M=w(P.formState.errors,e);return $(po,{control:P.control,name:e,rules:t,defaultValue:n,shouldUnregister:i,render:({field:{value:r,onChange:o,ref:p}})=>ve(ue,{display:"flex",flexDirection:"column",children:[ve("div",{style:{display:"flex"},children:[l&&$(ue,{item:!0,children:$(C,{label:l,required:g})}),I&&$(ue,{item:!0,children:$(Fo,{title:I,placement:"top",children:$("div",{style:{width:"fit-content"},children:$(ge,{icon:xo,color:"#757575"})})})})]}),$(fo,{variant:v,defaultValue:n,value:d(r||(r!=0?"":r)),onChange:c=>{let E=m(c?.target?.value);o(E),b?.(E,P.getValues())},error:!!M,...x,type:x.type==="password"?s?"text":"password":x.type,autoComplete:x.autoComplete||"off",inputProps:{inputMode:y,...x.inputProps},InputProps:{onKeyDown:G,inputRef:p,endAdornment:x.type==="password"&&$(uo,{position:"start",onClick:()=>h(!s),style:{cursor:"pointer"},children:$(ge,{icon:s?co:yo,size:"24px",removeMargin:!0})}),...x.InputProps}},e),$(S,{name:e,disableIcon:f})]})})},bo=ao(Po);import{memo as ho,useState as go}from"react";import{Controller as vo,useFormContext as Co}from"react-hook-form";import{Divider as To,IconButton as Io,LIcon as Ce,Tooltip as So}from"@s_mart/core";import{lineTimes as ko}from"@s_mart/regular-icons";import{lineInfoCircle as wo}from"@s_mart/solid-icons";import{colorPalette as Vo}from"@s_mart/tokens";import{Grid as j,Select as Go,MenuItem as Eo,useTheme as Lo}from"@mui/material";import{Fragment as Bo,jsx as B,jsxs as X}from"react/jsx-runtime";var Te=ho(({name:e,rules:t,defaultValue:n,shouldUnregister:i,label:l,required:g,options:F,placeholder:v,clearable:I,disableOnChangeForm:u=!1,multiple:y,info:a,footer:b,onChange:f,disableIconError:x,variant:P="outlined",...s})=>{let h=Co(),{palette:d}=Lo(),[m,G]=go(!1);if(!h)throw new Error("Para usar o <Select /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let M=w(h.formState.errors,e);return B(vo,{control:h.control,name:e,rules:t,defaultValue:n,shouldUnregister:i,render:({field:{value:r,onChange:o,ref:p}})=>X(j,{display:"flex",flexDirection:"column",children:[X("div",{style:{display:"flex"},children:[l&&B(j,{item:!0,children:B(C,{label:l,required:g})}),a&&B(j,{item:!0,children:B(So,{title:a,placement:"top",children:B("div",{style:{width:"fit-content"},children:B(Ce,{icon:wo,color:"#757575"})})})})]}),X(Go,{open:m,onOpen:()=>G(!0),onClose:()=>G(!1),displayEmpty:!!v,variant:P,autoComplete:"off",value:r?r||"":y?[]:"",renderValue:c=>{if(c.label)return c.label;if(v)return B("p",{style:{color:d.grey[400]},children:v})},multiple:y,onChange:c=>{!u&&o(c.target.value),f&&f(c.target.value,h.getValues())},error:!!M,size:s.size||"medium",inputRef:p,...s,endAdornment:X(Bo,{children:[s.endAdornment,!!(I&&r)&&B(Io,{variant:"text",color:"neutral",size:"small",sx:{borderRadius:"50%",position:"absolute",right:"2rem"},style:{padding:0},"aria-label":"Clear",title:"Clear",onClick:()=>{!u&&o(null),f&&f(null,h.getValues())},children:B(Ce,{icon:ko,color:Vo.neutral[100],size:"25px",removeMargin:!0})})]}),children:[F?.map((c,E)=>B(Eo,{value:c,children:X(j,{container:!0,direction:"column",children:[B(j,{item:!0,children:c.label}),c.afterLabel&&B(j,{item:!0,children:c.afterLabel})]})},E)),b&&[B(j,{px:2,py:1,children:B(To,{})},"footer-divider"),B("div",{children:b({closeSelect:()=>G(!1)})},"footer-content")]]},e),B(S,{name:e,disableIcon:x})]})})});Te.displayName="Select";var Ro=Te;import{forwardRef as Do,memo as Ao}from"react";import{Controller as Mo,useFormContext as $o}from"react-hook-form";import{Grid as U,Autocomplete as qo,TextField as zo}from"@mui/material";import{Divider as Ie,LIcon as _o,Tooltip as Uo}from"@s_mart/core";import{lineInfoCircle as Oo}from"@s_mart/solid-icons";import{colorPalette as jo}from"@s_mart/tokens";import{Fragment as re,jsx as R,jsxs as N}from"react/jsx-runtime";import{createElement as Se}from"react";var ke=Ao(({name:e,rules:t,defaultValue:n,shouldUnregister:i,label:l,required:g,options:F,textFieldProps:v,noOptionsText:I,footer:u,multiple:y,info:a,placeholder:b,onChange:f,onInputChange:x,disableIconError:P,...s})=>{let h=$o();if(!h)throw new Error("Para usar o <Searchable /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let d=w(h.formState.errors,e);return R(Mo,{control:h.control,name:e,rules:t,defaultValue:n,shouldUnregister:i,render:({field:{onChange:m,value:G,ref:M}})=>N(U,{display:"flex",flexDirection:"column",children:[N("div",{style:{display:"flex"},children:[l&&R(U,{item:!0,children:R(C,{label:l,required:g})}),a&&R(U,{item:!0,children:R(Uo,{title:a,placement:"top",children:R("div",{style:{width:"fit-content"},children:R(_o,{icon:Oo,color:"#757575"})})})})]}),R(qo,{onChange:(r,o)=>{m(o),f?.(o,h.getValues())},onInputChange:(r,o,p)=>{p==="input"&&setTimeout(()=>{x?.(o,h.getValues())},0)},slotProps:{...s.slotProps||{},paper:{...(s.slotProps||{}).paper||{},sx:{border:`1px solid ${jo.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)",...(s.slotProps||{}).paper?.sx||{}}}},value:G||(y?[]:null),options:F,multiple:y,readOnly:s.disabled,noOptionsText:N(re,{children:[I||"Nenhum resultado encontrado",u?N(re,{children:[R(U,{py:1,children:R(Ie,{})}),u]}):null]}),isOptionEqualToValue:(r,o)=>typeof r=="string"&&typeof o=="string"?r===o:typeof r=="object"&&typeof o=="object"?typeof r.value=="object"&&typeof o.value=="object"&&r.key!==void 0&&o.key!==void 0?r.key===o.key:r.value===o.value:!1,renderOption:(r,o)=>typeof o=="object"?Se("li",{...r,key:o.key||o.value},N(U,{container:!0,direction:"column",children:[R(U,{item:!0,children:o.label}),o.afterLabel&&R(U,{item:!0,children:o.afterLabel})]})):Se("li",{...r,key:o},o),ListboxComponent:Do(function(o,p){return N(re,{children:[R("ul",{...o,ref:p}),!!u&&R("div",{...o,children:N(re,{children:[R(U,{px:2,py:1,children:R(Ie,{})}),u]})},"searchable-footer")]})}),...s,renderInput:r=>R(zo,{error:!!d,placeholder:b,...r,...v,inputRef:M})},e),R(S,{name:e,disableIcon:P})]})})});ke.displayName="Searchable";var No=ke;import{forwardRef as Yo,memo as Ko}from"react";import{Controller as Jo,useFormContext as Xo}from"react-hook-form";import{isObject as Qo,isEmpty as Zo}from"lodash-es";import{Grid as H,Autocomplete as er,TextField as or}from"@mui/material";import{LIcon as ie,Tooltip as rr,Button as tr,Divider as ir}from"@s_mart/core";import{colorPalette as lr}from"@s_mart/tokens";import{linePlus as Ee,linePen as nr,lineInfoCircle as ar}from"@s_mart/solid-icons";import{toRem as Le}from"@s_mart/utils";import{toRem as te}from"@s_mart/utils";import Ho from"@emotion/styled";import{css as we}from"@emotion/react";var Ve=we`
|
|
2
2
|
display: flex;
|
|
3
3
|
align-items: center;
|
|
4
4
|
justify-content: center;
|
|
5
|
-
`,
|
|
5
|
+
`,Wo=e=>we`
|
|
6
6
|
.creatable,
|
|
7
7
|
.editable {
|
|
8
|
-
${
|
|
8
|
+
${Ve}
|
|
9
9
|
|
|
10
10
|
.divider {
|
|
11
11
|
width: 1px;
|
|
12
|
-
height: ${
|
|
12
|
+
height: ${te(20)};
|
|
13
13
|
background-color: ${e.palette.grey[400]};
|
|
14
14
|
}
|
|
15
15
|
|
|
@@ -20,9 +20,9 @@ import{FormProvider as Ve}from"react-hook-form";import{jsx as de}from"react/jsx-
|
|
|
20
20
|
color: ${e.palette.grey[600]};
|
|
21
21
|
border-radius: 50%;
|
|
22
22
|
|
|
23
|
-
margin: 0 ${
|
|
24
|
-
width: ${
|
|
25
|
-
height: ${
|
|
23
|
+
margin: 0 ${te(6)};
|
|
24
|
+
width: ${te(28)};
|
|
25
|
+
height: ${te(28)};
|
|
26
26
|
|
|
27
27
|
&:hover {
|
|
28
28
|
cursor: pointer;
|
|
@@ -31,14 +31,14 @@ import{FormProvider as Ve}from"react-hook-form";import{jsx as de}from"react/jsx-
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
`,
|
|
34
|
+
`,Ge=Ho.div`
|
|
35
35
|
display: flex;
|
|
36
36
|
|
|
37
37
|
div.endAdornments {
|
|
38
38
|
position: absolute;
|
|
39
39
|
right: 0;
|
|
40
40
|
|
|
41
|
-
${
|
|
41
|
+
${Ve}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
.MuiAutocomplete-endAdornment {
|
|
@@ -50,23 +50,23 @@ import{FormProvider as Ve}from"react-hook-form";import{jsx as de}from"react/jsx-
|
|
|
50
50
|
transform: translate(0, 0);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
${({hideAddButton:e,theme:
|
|
54
|
-
`;import{Fragment as
|
|
53
|
+
${({hideAddButton:e,theme:t})=>!e&&Wo(t)}
|
|
54
|
+
`;import{Fragment as fe,jsx as k,jsxs as q}from"react/jsx-runtime";import{createElement as Re}from"react";var sr=({name:e,rules:t,defaultValue:n,shouldUnregister:i,label:l,required:g,options:F,editable:v,footer:I,onEditOption:u,onCreateOption:y,textFieldProps:a,hideAddButton:b,multiple:f,info:x,onChange:P,onInputChange:s,placeholder:h,disableIconError:d,...m})=>{let G=Xo();if(!G)throw new Error("Para usar o <Creatable /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let M=w(G.formState.errors,e),r=b||m.disabled,o=V=>{let O=0;return a?.InputProps||(O+=2.5),r||(O+=2.56,p(V)&&(O+=2.56)),!m.disableClearable&&!m.disabled&&(O+=1.3),O+"rem"},p=V=>m.disabled?!1:v&&Qo(V)&&!Zo(V);console.warn=()=>{};let c=V=>{y?y(V):console.error("onCreateOption n\xE3o foi definido")},E=V=>{u?u(V):console.error("onEditOption n\xE3o foi definido")};return k(Jo,{control:G.control,name:e,rules:t,defaultValue:n,shouldUnregister:i,render:({field:{value:V,onChange:O,ref:je}})=>{let xe=V?.label||V?.value||V;return q(H,{display:"flex",flexDirection:"column",children:[q("div",{style:{display:"flex"},children:[l&&k(H,{item:!0,children:k(C,{label:l,required:g})}),x&&k(H,{item:!0,children:k(rr,{title:x,placement:"top",children:k("div",{style:{width:"fit-content"},children:k(ie,{icon:ar,color:"#757575"})})})})]}),k(Ge,{hideAddButton:r,children:k(er,{fullWidth:!0,onChange:(L,T)=>{O(T),P?.(T,G.getValues())},onInputChange:(L,T,de)=>{de==="input"&&setTimeout(()=>{s?.(T,G.getValues())},0)},slotProps:{...m.slotProps||{},paper:{...(m.slotProps||{}).paper||{},sx:{border:`1px solid ${lr.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)",...(m.slotProps||{}).paper?.sx||{}}}},options:F,value:V||(f?[]:null),multiple:f,readOnly:m.disabled,noOptionsText:r?void 0:q(tr,{sx:{justifyContent:"flex-start",padding:`${Le(6)} ${Le(-16)}`,margin:0},fullWidth:!0,onClick:()=>c(V),variant:"text",startIcon:k(ie,{icon:Ee}),children:["Adicionar ",xe&&`"${xe}"`]}),isOptionEqualToValue:(L,T)=>T?typeof L=="string"&&typeof T=="string"?L===T:typeof L=="object"&&typeof T=="object"?typeof L.value=="object"&&typeof T.value=="object"&&L.key!==void 0&&T.key!==void 0?L.key===T.key:L.value===T.value:typeof L=="object"&&typeof T=="string":!1,renderOption:(L,T)=>typeof T=="object"?Re("li",{...L,key:T.key||T.value},q(H,{container:!0,direction:"column",children:[k(H,{item:!0,children:T.label}),T.afterLabel&&k(H,{item:!0,children:T.afterLabel})]})):Re("li",{...L,key:T},T),ListboxComponent:Yo(function(T,de){return q(fe,{children:[k("ul",{...T,ref:de}),!!I&&k("div",{...T,children:q(fe,{children:[k(H,{px:2,py:1,children:k(ir,{})}),I]})},"creatable-footer")]})}),...m,sx:{"& div.MuiInputBase-root":{paddingRight:`${o(V)} !important`},...m.sx},renderInput:L=>k(or,{placeholder:h,...L,error:!!M,InputProps:{...L.InputProps,inputRef:je,endAdornment:q("div",{className:"endAdornments",children:[L.InputProps.endAdornment,!r&&q(fe,{children:[p(V)?q("div",{className:"editable",children:[k("div",{className:"divider"}),k("div",{className:"button",onClick:()=>E(V),children:k(ie,{icon:nr,size:"24px",removeMargin:!0})})]}):null,q("div",{className:"creatable",children:[k("div",{className:"divider"}),k("div",{className:"button",onClick:()=>c(V),children:k(ie,{icon:Ee,size:"24px",removeMargin:!0})})]})]})]})},...a})},e)}),k(S,{name:e,disableIcon:d})]})}})},dr=Ko(sr);import{Controller as pr,useFormContext as mr}from"react-hook-form";import{Grid as ur,Checkbox as fr,FormControlLabel as cr}from"@mui/material";import{jsx as Q,jsxs as Fr}from"react/jsx-runtime";var yr=({name:e,rules:t,defaultValue:n,shouldUnregister:i,label:l,labelPlacement:g,required:F,disableIconError:v,onChange:I,...u})=>{let y=mr();if(!y)throw new Error("Para usar o <Checkbox /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return Q(pr,{control:y.control,name:e,rules:t,defaultValue:n,shouldUnregister:i,render:({field:{value:a,onChange:b}})=>Fr(ur,{display:"flex",flexDirection:"column",children:[Q(cr,{control:Q(fr,{checked:!!a,value:a??"",defaultValue:a,onChange:(f,x)=>{b(f,x),I?.(f,x)},...u},e),label:Q(C,{label:l,required:F,regular:!0}),labelPlacement:g||"end"}),Q(S,{name:e,disableIcon:v})]})})},xr=yr;import{Controller as Pr,useFormContext as br}from"react-hook-form";import{Grid as hr,Switch as gr,FormControlLabel as vr}from"@mui/material";import{jsx as Z,jsxs as Ir}from"react/jsx-runtime";var Cr=({name:e,rules:t,defaultValue:n,shouldUnregister:i,label:l,labelPlacement:g,disableIconError:F,onChange:v,...I})=>{let u=br();if(!u)throw new Error("Para usar o <Switch /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return Z(Pr,{control:u.control,name:e,rules:t,defaultValue:n,shouldUnregister:i,render:({field:{value:y,onChange:a}})=>Ir(hr,{display:"flex",flexDirection:"column",children:[Z(vr,{control:Z(gr,{value:y??"",checked:y??!1,defaultValue:y,onChange:(b,f)=>{a(b,f),v?.(b,f)},...I},e),label:Z(C,{label:l}),labelPlacement:g||"end"}),Z(S,{name:e,disableIcon:F})]})})},Tr=Cr;import{Grid as Sr,Radio as kr,FormControlLabel as wr}from"@mui/material";import{jsx as le}from"react/jsx-runtime";var Vr=({label:e,labelPlacement:t,...n})=>le(Sr,{display:"flex",flexDirection:"column",children:le(wr,{control:le(kr,{...n}),label:le(C,{label:e}),labelPlacement:t||"end"})}),Gr=Vr;import{Controller as Er,useFormContext as Lr}from"react-hook-form";import{Grid as Rr,RadioGroup as Br}from"@mui/material";import{jsx as ne,jsxs as Mr}from"react/jsx-runtime";var Dr=({name:e,rules:t,defaultValue:n,shouldUnregister:i,label:l,required:g,children:F,orientation:v="row",disableIconError:I,...u})=>{let y=Lr();if(!y)throw new Error("Para usar o <RadioGroup /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return ne(Er,{control:y.control,name:e,rules:t,defaultValue:n,shouldUnregister:i,render:({field:{value:a,onChange:b}})=>Mr(Rr,{display:"flex",flexDirection:"column",children:[l&&ne(C,{label:l,required:g}),ne(Br,{value:a||"",name:e,...u,onChange:f=>{u?.onChange?.(f,f.target?.value),b(f)},style:{display:"flex",flexDirection:v},children:F},e),ne(S,{name:e,disableIcon:I})]})})},Ar=Dr;import{Controller as $r,useFormContext as qr}from"react-hook-form";import{Slider as zr}from"@mui/material";import{jsx as Be}from"react/jsx-runtime";var _r=({name:e,rules:t,defaultValue:n,shouldUnregister:i,...l})=>{let g=qr();if(!g)throw new Error("Para usar o <Slider /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return Be($r,{control:g.control,name:e,rules:t,defaultValue:n,shouldUnregister:i,render:({field:{value:F,onChange:v}})=>Be(zr,{value:F||l?.min||0,onChange:v,valueLabelDisplay:"auto",...l},e)})},Ur=_r;import{memo as Wr}from"react";import{Controller as Yr,useFormContext as Kr}from"react-hook-form";import{Grid as Jr}from"@s_mart/core";import{composeValidators as Xr,date as Ae}from"@s_mart/rules";import{TextField as Qr}from"@mui/material";import{DatePicker as Zr}from"@mui/x-date-pickers/DatePicker";import{AdapterDayjs as et}from"@mui/x-date-pickers/AdapterDayjs";import{LocalizationProvider as ot}from"@mui/x-date-pickers/LocalizationProvider";import{ptBR as rt}from"@mui/x-date-pickers/locales/ptBR";import tt from"dayjs/locale/pt-br";import Or from"@emotion/styled";import{IconButton as jr}from"@mui/material";import{toRem as z}from"@s_mart/utils";var Nr=e=>{switch(e){case"small":return z(16);default:case"medium":return z(20);case"large":return z(24)}},Hr=e=>{switch(e){case"small":return`${z(2)} ${z(8)}`;default:case"medium":return`${z(6)} ${z(8)}`;case"large":return`${z(10)}`}},De=Or(jr)`
|
|
55
55
|
margin: 0px;
|
|
56
56
|
|
|
57
|
-
padding: ${({size:e})=>
|
|
58
|
-
border-radius: 0 ${
|
|
57
|
+
padding: ${({size:e})=>Hr(e)};
|
|
58
|
+
border-radius: 0 ${z(4)} ${z(4)} 0;
|
|
59
59
|
|
|
60
60
|
svg {
|
|
61
|
-
width: ${({size:e})=>
|
|
61
|
+
width: ${({size:e})=>Nr(e)} !important;
|
|
62
62
|
}
|
|
63
|
-
`;import{jsx as
|
|
63
|
+
`;import{jsx as ee,jsxs as at}from"react/jsx-runtime";import{createElement as nt}from"react";var it=({rules:e,name:t,defaultValue:n,shouldUnregister:i,datePickerProps:l,label:g,required:F,placeholder:v,disabled:I,disableIconError:u,...y})=>{let a=Kr();if(!a)throw new Error("Para usar o <DataPicker /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let b=w(a.formState.errors,t),f=l?.format||"DD/MM/YYYY",x=e?Xr([Ae(f),e]):Ae(f);return ee(ot,{dateAdapter:et,adapterLocale:tt,localeText:rt.components.MuiLocalizationProvider.defaultProps.localeText,children:ee(Yr,{control:a.control,name:t,rules:x,defaultValue:n,shouldUnregister:i,render:({field:{value:P,onChange:s,ref:h}})=>at(Jr,{display:"flex",flexDirection:"column",children:[g&&ee(C,{label:g,required:F}),nt(Zr,{...l,key:t,value:P??null,format:f,onChange:(d,m)=>{s(d,m),l?.onChange?.(d,m)},disabled:I,slots:{textField:Qr,openPickerButton:d=>ee(De,{...d,size:y.size})},slotProps:{textField:d=>({variant:"outlined",...d,error:!!b,...y,inputProps:{...d.inputProps,placeholder:v||d.inputProps?.placeholder},InputProps:{...d.InputProps,inputRef(m){h(m),typeof d.inputRef=="function"&&d.inputRef(m)}}})}}),ee(S,{name:t,disableIcon:u})]})})})},lt=Wr(it);import{memo as ut}from"react";import{Controller as ft,useFormContext as ct}from"react-hook-form";import{Grid as yt}from"@s_mart/core";import{composeValidators as xt,time as $e}from"@s_mart/rules";import{TextField as Ft}from"@mui/material";import{TimePicker as Pt}from"@mui/x-date-pickers/TimePicker";import{AdapterDayjs as bt}from"@mui/x-date-pickers/AdapterDayjs";import{LocalizationProvider as ht}from"@mui/x-date-pickers/LocalizationProvider";import{ptBR as gt}from"@mui/x-date-pickers/locales/ptBR";import vt from"dayjs/locale/pt-br";import st from"@emotion/styled";import{IconButton as dt}from"@mui/material";import{toRem as _}from"@s_mart/utils";var pt=e=>{switch(e){case"small":return _(16);default:case"medium":return _(20);case"large":return _(24)}},mt=e=>{switch(e){case"small":return`${_(2)} ${_(8)}`;default:case"medium":return`${_(6)} ${_(8)}`;case"large":return`${_(10)}`}},Me=st(dt)`
|
|
64
64
|
margin: 0px;
|
|
65
65
|
|
|
66
|
-
padding: ${({size:e})=>
|
|
67
|
-
border-radius: 0 ${
|
|
66
|
+
padding: ${({size:e})=>mt(e)};
|
|
67
|
+
border-radius: 0 ${_(4)} ${_(4)} 0;
|
|
68
68
|
|
|
69
69
|
svg {
|
|
70
|
-
width: ${({size:e})=>
|
|
70
|
+
width: ${({size:e})=>pt(e)} !important;
|
|
71
71
|
}
|
|
72
|
-
`;import{jsx as
|
|
72
|
+
`;import{jsx as K,jsxs as It}from"react/jsx-runtime";var Ct=({rules:e,defaultValue:t,shouldUnregister:n,name:i,required:l,label:g,timePickerProps:F,placeholder:v,disabled:I,disableIconError:u,...y})=>{let a=ct();if(!a)throw new Error("Para usar o <TimePicker /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let b=w(a.formState.errors,i),f=F?.format||"HH:mm",x=e?xt([$e(f),e]):$e(f);return K(ht,{dateAdapter:bt,adapterLocale:vt,localeText:gt.components.MuiLocalizationProvider.defaultProps.localeText,children:K(ft,{control:a.control,name:i,rules:x,defaultValue:t,shouldUnregister:n,render:({field:{value:P,onChange:s,ref:h}})=>It(yt,{display:"flex",flexDirection:"column",children:[g&&K(C,{label:g,required:l}),K(Pt,{ampm:!1,format:f,value:P??null,disabled:I,...F,onChange:(d,m)=>{s(d,m),F?.onChange?.(d,m)},slots:{textField:Ft,openPickerButton:d=>K(Me,{...d,size:y.size})},slotProps:{textField:d=>({variant:"outlined",...d,error:!!b,...y,inputProps:{...d.inputProps,placeholder:v||d.inputProps?.placeholder},InputProps:{...d.InputProps,inputRef(m){h(m),typeof d.inputRef=="function"&&d.inputRef(m)}}})}},i),K(S,{name:i,disableIcon:u})]})})})},Tt=ut(Ct);import{memo as St}from"react";import{Controller as kt,useFormContext as wt}from"react-hook-form";import{Autocomplete as Vt,TextField as Gt}from"@mui/material";import{Grid as ae}from"@s_mart/core";import{colorPalette as Et}from"@s_mart/tokens";import{jsx as W,jsxs as qe}from"react/jsx-runtime";import{createElement as Bt}from"react";var Lt=({name:e,defaultValue:t,rules:n,shouldUnregister:i,label:l,required:g,noOptionsText:F,placeholder:v,onInputChange:I,onChange:u,disableIconError:y,...a})=>{let b=wt();if(!b)throw new Error("Para usar o <Autocomplete /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let f=w(b.formState.errors,e);return console.warn=()=>{},W(kt,{name:e,control:b.control,defaultValue:t,rules:n,shouldUnregister:i,render:({field:x})=>qe(ae,{display:"flex",flexDirection:"column",children:[l&&W(C,{label:l,required:g}),W(Vt,{onChange:(P,s)=>{x.onChange(s),u?.(s,b.getValues())},onInputChange:(P,s,h)=>{h==="input"&&(x.onChange(s),setTimeout(()=>{I?.(s,b.getValues())},0))},slotProps:{...a.slotProps||{},paper:{...(a.slotProps||{}).paper||{},sx:{border:`1px solid ${Et.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)",...(a.slotProps||{}).paper?.sx||{}}}},isOptionEqualToValue:(P,s)=>P.value===s.value,renderOption:(P,s)=>Bt("li",{...P,key:s.key||s.value,onClick:h=>{P.onClick?.(h),x.onChange(s)}},qe(ae,{container:!0,direction:"column",children:[W(ae,{item:!0,children:s.label}),s.afterLabel&&W(ae,{item:!0,children:s.afterLabel})]})),value:x.value||null,readOnly:a.disabled,noOptionsText:F||"Nenhuma op\xE7\xE3o encontrada",...a,renderInput:P=>W(Gt,{placeholder:v,...P,...a.textFieldProps,error:!!f,InputProps:{...P.InputProps,...a.textFieldProps?.InputProps,inputRef:x.ref,inputProps:{...P.inputProps,...a.textFieldProps?.InputProps?.inputProps}}})},e),W(S,{name:e,disableIcon:y})]})})},Rt=St(Lt);import{Controller as zt,useFormContext as _t}from"react-hook-form";import{Tooltip as Dt}from"@mui/material";import{LIcon as At}from"@s_mart/core";import{lineInfoCircle as Mt}from"@s_mart/solid-icons";import{jsx as ce}from"react/jsx-runtime";var $t=({title:e})=>ce(Dt,{title:e,placement:"top",children:ce("div",{style:{width:"fit-content"},children:ce(At,{icon:Mt,color:"#757575"})})}),oe=$t;import{Autocomplete as Ut,Divider as ze,TextField as Ot}from"@mui/material";import{isEqual as jt}from"lodash-es";import{forwardRef as Nt}from"react";import{colorPalette as Ht}from"@s_mart/tokens";import{memo as qt}from"react";var se=qt;import{Fragment as ye,jsx as A,jsxs as Y}from"react/jsx-runtime";import{createElement as Kt}from"react";var Wt=({name:e,rules:t,defaultValue:n,shouldUnregister:i,label:l,required:g,options:F,textFieldProps:v,noOptionsText:I,footer:u,multiple:y,info:a,placeholder:b,onChange:f,onInputChange:x,getOptionAfterLabel:P,getOptionLabel:s,getOptionKey:h,...d})=>{let m=_t();if(!m)throw new Error("Para usar o <SearchableV2 /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let G=w(m.formState.errors,e);return A(zt,{control:m.control,name:e,rules:t,defaultValue:n,shouldUnregister:i,render:({field:{onChange:M,value:r,ref:o}})=>Y("div",{style:{display:"flex",flexDirection:"column"},children:[Y("div",{style:{display:"flex"},children:[l&&A(C,{label:l,required:g}),a&&A(oe,{title:a})]}),A(Ut,{onChange:(p,c)=>{M(c),f?.(c)},onInputChange:(p,c,E)=>{E==="input"&&x?.(c)},value:r||(y?[]:null),options:F,multiple:y,readOnly:d.disabled,slotProps:{...d.slotProps||{},paper:{...(d.slotProps||{}).paper||{},sx:{border:`1px solid ${Ht.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)",...(d.slotProps||{}).paper?.sx||{}}}},noOptionsText:Y(ye,{children:[I||"Nenhuma op\xE7\xE3o encontrada",u?Y(ye,{children:[A("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:A(ze,{})}),u]}):null]}),isOptionEqualToValue:(p,c)=>jt(p,c),getOptionLabel:p=>s(p),getOptionKey:p=>h(p),renderOption:typeof P=="function"?(p,c)=>{let E=P(c);return Kt("li",{...p,key:c.key},Y("div",{style:{display:"flex",flexDirection:"column"},children:[A("span",{children:s(c)}),typeof E=="string"?A("span",{children:E}):E]}))}:void 0,ListboxComponent:Nt(function(c,E){return Y(ye,{children:[A("ul",{...c,ref:E}),!!u&&Y("div",{...c,children:[A("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:A(ze,{})}),u]},"searchable-footer")]})}),...d,renderInput:p=>A(Ot,{error:!!G,placeholder:b,...p,...v,inputRef:o})},e),A(S,{name:e})]})})},Yt=se(Wt);import{useState as Jt}from"react";import{Controller as Xt,useFormContext as Qt}from"react-hook-form";import{IconButton as Zt,LIcon as ei}from"@s_mart/core";import{lineTimes as oi}from"@s_mart/regular-icons";import{colorPalette as _e}from"@s_mart/tokens";import{Select as ri,MenuItem as Ue,Divider as ti}from"@mui/material";import{Fragment as Oe,jsx as D,jsxs as J}from"react/jsx-runtime";var ii=({name:e,rules:t,defaultValue:n,shouldUnregister:i,label:l,required:g,options:F,placeholder:v,clearable:I,info:u,footer:y,onChange:a,variant:b="outlined",getOptionKey:f,getOptionLabel:x,getOptionAfterLabel:P,...s})=>{let h=Qt(),[d,m]=Jt(!1);if(!h)throw new Error("Para usar o <SelectV2 /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let G=w(h.formState.errors,e);return D(Xt,{control:h.control,name:e,rules:t,defaultValue:n,shouldUnregister:i,render:({field:{value:M,onChange:r,ref:o}})=>J("div",{style:{display:"flex",flexDirection:"column"},children:[J("div",{style:{display:"flex"},children:[l&&D(C,{label:l,required:g}),u&&D(oe,{title:u})]}),J(ri,{open:d,onOpen:()=>m(!0),onClose:()=>m(!1),displayEmpty:!!v,variant:b,autoComplete:"off",value:M||"",renderValue:p=>p?.length===0?D("p",{style:{color:_e.neutral[100]},children:v}):x(p),onChange:p=>{r(p.target.value),a?.(p.target.value)},error:!!G,size:s.size||"medium",inputRef:o,...s,endAdornment:J(Oe,{children:[s.endAdornment,!!(I&&M)&&D(Zt,{variant:"text",color:"neutral",size:"small",sx:{borderRadius:"50%",position:"absolute",right:"2rem"},style:{padding:0},"aria-label":"Limpar",title:"Limpar",onClick:()=>{r(null),a?.(null)},children:D(ei,{icon:oi,color:_e.neutral[100],size:"25px",removeMargin:!0})})]}),children:[F.map(p=>{let c=f(p);if(typeof P=="function"){let E=P(p);return D(Ue,{value:p,children:J("div",{style:{display:"flex",flexDirection:"column"},children:[x(p),typeof E=="string"?D("span",{children:E}):E]})},c)}return D(Ue,{value:p,children:D("div",{children:x(p)})},c)}),y!==void 0&&J(Oe,{children:[D("div",{style:{padding:"8px 16px"},children:D(ti,{})},"footer-divider"),D("div",{children:y({closeSelect:()=>m(!1)})},"footer-content")]})]},e),D(S,{name:e})]})})},li=se(ii);export{Rt as Autocomplete,xr as Checkbox,dr as Creatable,lt as DatePicker,C as FieldLabel,Qe as Form,pe as FormProvider,Gr as RadioButton,Ar as RadioGroup,No as Searchable,Yt as SearchableV2,Ro as Select,li as SelectV2,Ur as Slider,Tr as Switch,bo as TextField,Tt as TimePicker,me as useForm};
|