@s_mart/form 6.1.1 → 6.2.1

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 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
- declare const _default$5: 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>;
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
- type SelectProps = Omit<SelectProps$1, 'onChange'> & ControllerSelect & {
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
- declare const _default$4: 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>;
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$3: 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>;
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$2: react.MemoExoticComponent<({ rules, name, defaultValue, shouldUnregister, datePickerProps, label, required, placeholder, disabled, disableIconError, ...rest }: DatePickerProps) => react_jsx_runtime.JSX.Element>;
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$1: react.MemoExoticComponent<({ rules, defaultValue, shouldUnregister, name, required, label, timePickerProps, placeholder, disabled, disableIconError, ...rest }: TimePickerProps) => react_jsx_runtime.JSX.Element>;
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,99 @@ type FieldLabelProps = {
599
620
 
600
621
  declare const FieldLabel: ({ label, required, regular }: FieldLabelProps) => react_jsx_runtime.JSX.Element;
601
622
 
602
- export { _default as Autocomplete, type AutocompleteProps, Checkbox, type CheckboxProps, _default$3 as Creatable, type CreatableOption, type CreatableProps, _default$2 as DatePicker, type DatePickerProps, FieldLabel, type FieldLabelProps, type FooterProps, Form, FormProvider, type IFormProps, type IFormProviderProps, type IUseFormProps, RadioButton, RadioGroup, type RadioGroupProps, type RadioProps, _default$4 as Searchable, type SearchableOption, type SearchableProps, _default$5 as Select, type SelectOption, type SelectProps, Slider, type SliderProps, Switch, type SwitchProps, _default$6 as TextField, type TextFieldProps, _default$1 as TimePicker, type TimePickerProps, useForm };
623
+ type SearchableV2Props<T extends FieldValues | string | number> = 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 string | number | 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 | string | number> = Omit<SelectProps$1, 'onChange' | 'multiple' | 'defaultValue' | 'variant'> & ControllerSelect & {
671
+ variant?: 'filled' | 'outlined' | 'standard';
672
+ /**
673
+ * As opções que serão renderizadas no select
674
+ */
675
+ options: T[];
676
+ onChange?: (value: T | null) => void;
677
+ /**
678
+ * Função que renderiza o footer do select (opcional) - recebe como parâmetro a função closeSelect que fecha o select
679
+ * @param {FooterProps} props
680
+ *
681
+ * @example
682
+ * footer: ({ closeSelect }) => (
683
+ * <Button onClick={closeSelect}>Fechar</Button>
684
+ * )
685
+ *
686
+ */
687
+ footer?: (props: FooterPropsV2) => React.ReactNode;
688
+ /**
689
+ * É o conteúdo passado para a tooltip que renderizará ao lado da label do campo,
690
+ * montada à tela como um ícone de informação.
691
+ */
692
+ info?: React.ReactNode;
693
+ /**
694
+ * Habilita ícone no endAdornment para limpar o valor do campo.
695
+ * @default false
696
+ *
697
+ * @example
698
+ * <Select clearable />
699
+ */
700
+ clearable?: boolean;
701
+ defaultValue?: T;
702
+ /**
703
+ * Define a key unica da option
704
+ */
705
+ getOptionKey: (option: T) => string | number;
706
+ /**
707
+ * Define a label da option
708
+ */
709
+ getOptionLabel: (option: T) => string;
710
+ /**
711
+ * Componente renderizado embaixo da option da listagem
712
+ */
713
+ getOptionAfterLabel?: (option: T) => string | React.ReactNode;
714
+ };
715
+
716
+ declare const _default: <T extends string | number | 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;
717
+
718
+ 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 Ve}from"react-hook-form";import{jsx as de}from"react/jsx-runtime";function Re({children:e,style:r,onSubmit:i,...t}){return de(Ve,{...t,children:de("form",{onSubmit:n=>{n.preventDefault(),n.stopPropagation(),i(n)},style:r,children:e})})}var ie=Re;import{useEffect as Ee}from"react";import{useForm as Be}from"react-hook-form";import{zodResolver as Ae}from"@hookform/resolvers/zod";var De=({disableDefaultValuesUpdate:e,onSubmit:r,...i})=>{let t=Be({...i,resolver:i.schema&&Ae(i.schema)});return Ee(()=>{e||t.reset(i.defaultValues)},[i.defaultValues,t.reset]),{...t,onSubmit:t.handleSubmit(n=>r(n,t))}},le=De;import{jsx as ze}from"react/jsx-runtime";function $e({children:e,style:r,...i}){let t=le(i);return ze(ie,{...t,style:r,children:typeof e=="function"?e(t):e})}var Me=$e;import{memo as He,useState as We}from"react";import{Controller as Ye,useFormContext as Je}from"react-hook-form";import{Grid as ne,InputAdornment as Ke,TextField as Xe}from"@mui/material";import{lineEye as Qe,lineEyeSlash as Ze,lineInfoCircle as eo}from"@s_mart/solid-icons";import*as ue from"@s_mart/masks";import{Typography as me}from"@mui/material";import{toRem as qe}from"@s_mart/utils";import{jsx as pe,jsxs as Oe}from"react/jsx-runtime";var _e=({label:e,required:r,regular:i})=>Oe("span",{style:{display:"flex",alignItems:"center",gap:qe(2)},children:[pe(me,{variant:"caption",fontWeight:i?400:700,style:{display:"flex",alignItems:"center"},children:e}),r&&pe(me,{variant:"caption",fontWeight:900,color:"error",children:"*"})]}),v=_e;import{useFormContext as Ue}from"react-hook-form";import{Indicator as je}from"@s_mart/core";var V=(e,r)=>r.replace(/[[\]]/g,"").split(".").reduce((t,n)=>t?.[n],e);import{jsx as Ne}from"react/jsx-runtime";var T=({name:e,disableIcon:r})=>{let i=Ue(),t=V(i?.formState?.errors,e);return t?Ne(je,{severity:"error",icon:r?!1:void 0,children:t?.message}):null};import{LIcon as fe,Tooltip as oo}from"@s_mart/core";import{jsx as B,jsxs as ce}from"react/jsx-runtime";var ro=({name:e,rules:r,defaultValue:i,shouldUnregister:t,label:n,required:b,mask:p,variant:g="outlined",info:I,parse:c,inputMode:u,format:a,onInputChange:F,disableIconError:d,...x})=>{let P=Je();if(!P)throw new Error("Para usar o <TextField /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let[s,C]=We(!1),m=l=>{let o=l;return a&&(o=a(l)),p?ue?.[p]?.format(o):o},f=l=>{let o=l;return c&&(o=c(l)),p?ue?.[p]?.parse(o):o},R=l=>{if(!l||p!=="porcentagem"&&p!=="porcentagem0")return;l?.stopPropagation();let o=(l?.target).value;if(o){let E=String(o);if(E.length>0){let w=E.indexOf("%");w>-1&&(l.currentTarget.selectionEnd=w)}}},z=V(P.formState.errors,e);return B(Ye,{control:P.control,name:e,rules:r,defaultValue:i,shouldUnregister:t,render:({field:{value:l,onChange:o,ref:E}})=>ce(ne,{display:"flex",flexDirection:"column",children:[ce("div",{style:{display:"flex"},children:[n&&B(ne,{item:!0,children:B(v,{label:n,required:b})}),I&&B(ne,{item:!0,children:B(oo,{title:I,placement:"top",children:B("div",{style:{width:"fit-content"},children:B(fe,{icon:eo,color:"#757575"})})})})]}),B(Xe,{variant:g,defaultValue:i,value:m(l||(l!=0?"":l)),onChange:w=>{let N=f(w?.target?.value);o(N),F?.(N,P.getValues())},error:!!z,...x,type:x.type==="password"?s?"text":"password":x.type,autoComplete:x.autoComplete||"off",inputProps:{inputMode:u,...x.inputProps},InputProps:{onKeyDown:R,inputRef:E,endAdornment:x.type==="password"&&B(Ke,{position:"start",onClick:()=>C(!s),style:{cursor:"pointer"},children:B(fe,{icon:s?Qe:Ze,size:"24px",removeMargin:!0})}),...x.InputProps}},e),B(T,{name:e,disableIcon:d})]})})},to=He(ro);import{memo as io,useState as lo}from"react";import{Controller as no,useFormContext as ao}from"react-hook-form";import{Divider as so,IconButton as mo,LIcon as xe,Tooltip as po}from"@s_mart/core";import{lineTimes as uo}from"@s_mart/regular-icons";import{lineInfoCircle as fo}from"@s_mart/solid-icons";import{colorPalette as co}from"@s_mart/tokens";import{Grid as _,Select as xo,MenuItem as yo,useTheme as Fo}from"@mui/material";import{Fragment as ho,jsx as L,jsxs as W}from"react/jsx-runtime";var Po=({name:e,rules:r,defaultValue:i,shouldUnregister:t,label:n,required:b,options:p,placeholder:g,clearable:I,disableOnChangeForm:c=!1,multiple:u,info:a,footer:F,onChange:d,disableIconError:x,variant:P="outlined",...s})=>{let C=ao(),{palette:m}=Fo(),[f,R]=lo(!1);if(!C)throw new Error("Para usar o <Select /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let z=V(C.formState.errors,e);return console.warn=()=>{},L(no,{control:C.control,name:e,rules:r,defaultValue:i,shouldUnregister:t,render:({field:{value:l,onChange:o,ref:E}})=>W(_,{display:"flex",flexDirection:"column",children:[W("div",{style:{display:"flex"},children:[n&&L(_,{item:!0,children:L(v,{label:n,required:b})}),a&&L(_,{item:!0,children:L(po,{title:a,placement:"top",children:L("div",{style:{width:"fit-content"},children:L(xe,{icon:fo,color:"#757575"})})})})]}),W(xo,{open:f,onOpen:()=>R(!0),onClose:()=>R(!1),displayEmpty:!!g,variant:P,autoComplete:"off",value:l?l||"":u?[]:"",renderValue:w=>{if(w.label)return w.label;if(g)return L("p",{style:{color:m.grey[400]},children:g})},multiple:u,onChange:w=>{!c&&o(w.target.value),d&&d(w.target.value,C.getValues())},error:!!z,size:s.size||"medium",inputRef:E,...s,endAdornment:W(ho,{children:[s.endAdornment,!!(I&&l)&&L(mo,{variant:"text",color:"neutral",size:"small",sx:{borderRadius:"50%",position:"absolute",right:"2rem"},style:{padding:0},"aria-label":"Clear",title:"Clear",onClick:()=>{!c&&o(null),d&&d(null,C.getValues())},children:L(xe,{icon:uo,color:co.neutral[100],size:"25px",removeMargin:!0})})]}),children:[p?.map((w,N)=>L(yo,{value:w,children:W(_,{container:!0,direction:"column",children:[L(_,{item:!0,children:w.label}),w.afterLabel&&L(_,{item:!0,children:w.afterLabel})]})},N)),F&&[L(_,{px:2,py:1,children:L(so,{})},"footer-divider"),L("div",{children:F({closeSelect:()=>R(!1)})},"footer-content")]]},e),L(T,{name:e,disableIcon:x})]})})},bo=io(Po);import{forwardRef as go,memo as Co}from"react";import{Controller as vo,useFormContext as Io}from"react-hook-form";import{Grid as M,Autocomplete as To,TextField as ko}from"@mui/material";import{Divider as ye,LIcon as wo,Tooltip as So}from"@s_mart/core";import{lineInfoCircle as Go}from"@s_mart/solid-icons";import{colorPalette as Lo}from"@s_mart/tokens";import{Fragment as X,jsx as G,jsxs as O}from"react/jsx-runtime";import{createElement as Fe}from"react";var Vo=({name:e,rules:r,defaultValue:i,shouldUnregister:t,label:n,required:b,options:p,textFieldProps:g,noOptionsText:I,footer:c,multiple:u,info:a,placeholder:F,onChange:d,onInputChange:x,disableIconError:P,...s})=>{let C=Io();if(!C)throw new Error("Para usar o <Searchable /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let m=V(C.formState.errors,e);return console.warn=()=>{},G(vo,{control:C.control,name:e,rules:r,defaultValue:i,shouldUnregister:t,render:({field:{onChange:f,value:R,ref:z}})=>O(M,{display:"flex",flexDirection:"column",children:[O("div",{style:{display:"flex"},children:[n&&G(M,{item:!0,children:G(v,{label:n,required:b})}),a&&G(M,{item:!0,children:G(So,{title:a,placement:"top",children:G("div",{style:{width:"fit-content"},children:G(wo,{icon:Go,color:"#757575"})})})})]}),G(To,{onChange:(l,o)=>{f(o),d?.(o,C.getValues())},onInputChange:(l,o,E)=>{E==="input"&&setTimeout(()=>{x?.(o,C.getValues())},0)},slotProps:{...s.slotProps||{},paper:{...(s.slotProps||{}).paper||{},sx:{border:`1px solid ${Lo.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)",...(s.slotProps||{}).paper?.sx||{}}}},value:R||(u?[]:null),options:p,multiple:u,readOnly:s.disabled,noOptionsText:O(X,{children:[I||"Nenhum resultado encontrado",c?O(X,{children:[G(M,{py:1,children:G(ye,{})}),c]}):null]}),isOptionEqualToValue:(l,o)=>typeof l=="string"&&typeof o=="string"?l===o:typeof l=="object"&&typeof o=="object"?typeof l.value=="object"&&typeof o.value=="object"&&l.key!==void 0&&o.key!==void 0?l.key===o.key:l.value===o.value:!1,renderOption:(l,o)=>typeof o=="object"?Fe("li",{...l,key:o.key||o.value},O(M,{container:!0,direction:"column",children:[G(M,{item:!0,children:o.label}),o.afterLabel&&G(M,{item:!0,children:o.afterLabel})]})):Fe("li",{...l,key:o},o),ListboxComponent:go(function(o,E){return O(X,{children:[G("ul",{...o,ref:E}),!!c&&G("div",{...o,children:O(X,{children:[G(M,{px:2,py:1,children:G(ye,{})}),c]})},"searchable-footer")]})}),...s,renderInput:l=>G(ko,{error:!!m,placeholder:F,...l,...g,inputRef:z})},e),G(T,{name:e,disableIcon:P})]})})},Ro=Co(Vo);import{forwardRef as Ao,memo as Do}from"react";import{Controller as $o,useFormContext as Mo}from"react-hook-form";import{isObject as zo,isEmpty as qo}from"lodash-es";import{Grid as U,Autocomplete as _o,TextField as Oo}from"@mui/material";import{LIcon as Z,Tooltip as Uo,Button as jo,Divider as No}from"@s_mart/core";import{colorPalette as Ho}from"@s_mart/tokens";import{linePlus as ge,linePen as Wo,lineInfoCircle as Yo}from"@s_mart/solid-icons";import{toRem as Ce}from"@s_mart/utils";import{toRem as Q}from"@s_mart/utils";import Eo from"@emotion/styled";import{css as Pe}from"@emotion/react";var be=Pe`
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 me=He;import{useEffect as We}from"react";import{useForm as Ye}from"react-hook-form";import{zodResolver as Je}from"@hookform/resolvers/zod";var Ke=({disableDefaultValuesUpdate:e,onSubmit:t,...n})=>{let i=Ye({...n,resolver:n.schema&&Je(n.schema)});return We(()=>{e||i.reset(n.defaultValues)},[n.defaultValues,i.reset]),{...i,onSubmit:i.handleSubmit(l=>t(l,i))}},pe=Ke;import{jsx as Ze}from"react/jsx-runtime";function Xe({children:e,style:t,...n}){let i=pe(n);return Ze(me,{...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 mo,useFormContext as po}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 V=(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=V(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:h,disableIconError:f,...x})=>{let P=po();if(!P)throw new Error("Para usar o <TextField /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let[s,b]=so(!1),d=r=>{let o=r;return a&&(o=a(r)),F?he?.[F]?.format(o):o},p=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 m=String(o);if(m.length>0){let c=m.indexOf("%");c>-1&&(r.currentTarget.selectionEnd=c)}}},M=V(P.formState.errors,e);return $(mo,{control:P.control,name:e,rules:t,defaultValue:n,shouldUnregister:i,render:({field:{value:r,onChange:o,ref:m}})=>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=p(c?.target?.value);o(E),h?.(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:m,endAdornment:x.type==="password"&&$(uo,{position:"start",onClick:()=>b(!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:h,onChange:f,disableIconError:x,variant:P="outlined",...s})=>{let b=Co(),{palette:d}=Lo(),[p,G]=go(!1);if(!b)throw new Error("Para usar o <Select /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let M=V(b.formState.errors,e);return B(vo,{control:b.control,name:e,rules:t,defaultValue:n,shouldUnregister:i,render:({field:{value:r,onChange:o,ref:m}})=>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:p,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,b.getValues())},error:!!M,size:s.size||"medium",inputRef:m,...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,b.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)),h&&[B(j,{px:2,py:1,children:B(To,{})},"footer-divider"),B("div",{children:h({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:h,onChange:f,onInputChange:x,disableIconError:P,...s})=>{let b=$o();if(!b)throw new Error("Para usar o <Searchable /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let d=V(b.formState.errors,e);return R(Mo,{control:b.control,name:e,rules:t,defaultValue:n,shouldUnregister:i,render:({field:{onChange:p,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)=>{p(o),f?.(o,b.getValues())},onInputChange:(r,o,m)=>{m==="input"&&setTimeout(()=>{x?.(o,b.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,m){return N(re,{children:[R("ul",{...o,ref:m}),!!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:h,...r,...v,inputRef:M})},e),R(S,{name:e,disableIcon:P})]})})});ke.displayName="Searchable";var No=ke;import{forwardRef as Yo,memo as Jo}from"react";import{Controller as Ko,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
- `,Bo=e=>Pe`
5
+ `,Wo=e=>we`
6
6
  .creatable,
7
7
  .editable {
8
- ${be}
8
+ ${Ve}
9
9
 
10
10
  .divider {
11
11
  width: 1px;
12
- height: ${Q(20)};
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 ${Q(6)};
24
- width: ${Q(28)};
25
- height: ${Q(28)};
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
- `,he=Eo.div`
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
- ${be}
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:r})=>!e&&Bo(r)}
54
- `;import{Fragment as ae,jsx as h,jsxs as A}from"react/jsx-runtime";import{createElement as ve}from"react";var Jo=({name:e,rules:r,defaultValue:i,shouldUnregister:t,label:n,required:b,options:p,editable:g,footer:I,onEditOption:c,onCreateOption:u,textFieldProps:a,hideAddButton:F,multiple:d,info:x,onChange:P,onInputChange:s,placeholder:C,disableIconError:m,...f})=>{let R=Mo();if(!R)throw new Error("Para usar o <Creatable /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let z=V(R.formState.errors,e),l=F||f.disabled,o=k=>{let q=0;return a?.InputProps||(q+=2.5),l||(q+=2.56,E(k)&&(q+=2.56)),!f.disableClearable&&!f.disabled&&(q+=1.3),q+"rem"},E=k=>f.disabled?!1:g&&zo(k)&&!qo(k);console.warn=()=>{};let w=k=>{u?u(k):console.error("onCreateOption n\xE3o foi definido")},N=k=>{c?c(k):console.error("onEditOption n\xE3o foi definido")};return h($o,{control:R.control,name:e,rules:r,defaultValue:i,shouldUnregister:t,render:({field:{value:k,onChange:q,ref:Le}})=>{let se=k?.label||k?.value||k;return A(U,{display:"flex",flexDirection:"column",children:[A("div",{style:{display:"flex"},children:[n&&h(U,{item:!0,children:h(v,{label:n,required:b})}),x&&h(U,{item:!0,children:h(Uo,{title:x,placement:"top",children:h("div",{style:{width:"fit-content"},children:h(Z,{icon:Yo,color:"#757575"})})})})]}),h(he,{hideAddButton:l,children:h(_o,{fullWidth:!0,onChange:(S,y)=>{q(y),P?.(y,R.getValues())},onInputChange:(S,y,te)=>{te==="input"&&setTimeout(()=>{s?.(y,R.getValues())},0)},slotProps:{...f.slotProps||{},paper:{...(f.slotProps||{}).paper||{},sx:{border:`1px solid ${Ho.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)",...(f.slotProps||{}).paper?.sx||{}}}},options:p,value:k||(d?[]:null),multiple:d,readOnly:f.disabled,noOptionsText:l?void 0:A(jo,{sx:{justifyContent:"flex-start",padding:`${Ce(6)} ${Ce(-16)}`,margin:0},fullWidth:!0,onClick:()=>w(k),variant:"text",startIcon:h(Z,{icon:ge}),children:["Adicionar ",se&&`"${se}"`]}),isOptionEqualToValue:(S,y)=>y?typeof S=="string"&&typeof y=="string"?S===y:typeof S=="object"&&typeof y=="object"?typeof S.value=="object"&&typeof y.value=="object"&&S.key!==void 0&&y.key!==void 0?S.key===y.key:S.value===y.value:typeof S=="object"&&typeof y=="string":!1,renderOption:(S,y)=>typeof y=="object"?ve("li",{...S,key:y.key||y.value},A(U,{container:!0,direction:"column",children:[h(U,{item:!0,children:y.label}),y.afterLabel&&h(U,{item:!0,children:y.afterLabel})]})):ve("li",{...S,key:y},y),ListboxComponent:Ao(function(y,te){return A(ae,{children:[h("ul",{...y,ref:te}),!!I&&h("div",{...y,children:A(ae,{children:[h(U,{px:2,py:1,children:h(No,{})}),I]})},"creatable-footer")]})}),...f,sx:{"& div.MuiInputBase-root":{paddingRight:`${o(k)} !important`},...f.sx},renderInput:S=>h(Oo,{placeholder:C,...S,error:!!z,InputProps:{...S.InputProps,inputRef:Le,endAdornment:A("div",{className:"endAdornments",children:[S.InputProps.endAdornment,!l&&A(ae,{children:[E(k)?A("div",{className:"editable",children:[h("div",{className:"divider"}),h("div",{className:"button",onClick:()=>N(k),children:h(Z,{icon:Wo,size:"24px",removeMargin:!0})})]}):null,A("div",{className:"creatable",children:[h("div",{className:"divider"}),h("div",{className:"button",onClick:()=>w(k),children:h(Z,{icon:ge,size:"24px",removeMargin:!0})})]})]})]})},...a})},e)}),h(T,{name:e,disableIcon:m})]})}})},Ko=Do(Jo);import{Controller as Xo,useFormContext as Qo}from"react-hook-form";import{Grid as Zo,Checkbox as er,FormControlLabel as or}from"@mui/material";import{jsx as Y,jsxs as ir}from"react/jsx-runtime";var rr=({name:e,rules:r,defaultValue:i,shouldUnregister:t,label:n,labelPlacement:b,required:p,disableIconError:g,onChange:I,...c})=>{let u=Qo();if(!u)throw new Error("Para usar o <Checkbox /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return Y(Xo,{control:u.control,name:e,rules:r,defaultValue:i,shouldUnregister:t,render:({field:{value:a,onChange:F}})=>ir(Zo,{display:"flex",flexDirection:"column",children:[Y(or,{control:Y(er,{checked:!!a,value:a??"",defaultValue:a,onChange:(d,x)=>{F(d,x),I?.(d,x)},...c},e),label:Y(v,{label:n,required:p,regular:!0}),labelPlacement:b||"end"}),Y(T,{name:e,disableIcon:g})]})})},tr=rr;import{Controller as lr,useFormContext as nr}from"react-hook-form";import{Grid as ar,Switch as sr,FormControlLabel as dr}from"@mui/material";import{jsx as J,jsxs as ur}from"react/jsx-runtime";var mr=({name:e,rules:r,defaultValue:i,shouldUnregister:t,label:n,labelPlacement:b,disableIconError:p,onChange:g,...I})=>{let c=nr();if(!c)throw new Error("Para usar o <Switch /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return J(lr,{control:c.control,name:e,rules:r,defaultValue:i,shouldUnregister:t,render:({field:{value:u,onChange:a}})=>ur(ar,{display:"flex",flexDirection:"column",children:[J(dr,{control:J(sr,{value:u??"",checked:u??!1,defaultValue:u,onChange:(F,d)=>{a(F,d),g?.(F,d)},...I},e),label:J(v,{label:n}),labelPlacement:b||"end"}),J(T,{name:e,disableIcon:p})]})})},pr=mr;import{Grid as fr,Radio as cr,FormControlLabel as xr}from"@mui/material";import{jsx as ee}from"react/jsx-runtime";var yr=({label:e,labelPlacement:r,...i})=>ee(fr,{display:"flex",flexDirection:"column",children:ee(xr,{control:ee(cr,{...i}),label:ee(v,{label:e}),labelPlacement:r||"end"})}),Fr=yr;import{Controller as Pr,useFormContext as br}from"react-hook-form";import{Grid as hr,RadioGroup as gr}from"@mui/material";import{jsx as oe,jsxs as Ir}from"react/jsx-runtime";var Cr=({name:e,rules:r,defaultValue:i,shouldUnregister:t,label:n,required:b,children:p,orientation:g="row",disableIconError:I,...c})=>{let u=br();if(!u)throw new Error("Para usar o <RadioGroup /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return oe(Pr,{control:u.control,name:e,rules:r,defaultValue:i,shouldUnregister:t,render:({field:{value:a,onChange:F}})=>Ir(hr,{display:"flex",flexDirection:"column",children:[n&&oe(v,{label:n,required:b}),oe(gr,{value:a||"",name:e,...c,onChange:d=>{c?.onChange?.(d,d.target?.value),F(d)},style:{display:"flex",flexDirection:g},children:p},e),oe(T,{name:e,disableIcon:I})]})})},vr=Cr;import{Controller as Tr,useFormContext as kr}from"react-hook-form";import{Slider as wr}from"@mui/material";import{jsx as Ie}from"react/jsx-runtime";var Sr=({name:e,rules:r,defaultValue:i,shouldUnregister:t,...n})=>{let b=kr();if(!b)throw new Error("Para usar o <Slider /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return Ie(Tr,{control:b.control,name:e,rules:r,defaultValue:i,shouldUnregister:t,render:({field:{value:p,onChange:g}})=>Ie(wr,{value:p||n?.min||0,onChange:g,valueLabelDisplay:"auto",...n},e)})},Gr=Sr;import{memo as Br}from"react";import{Controller as Ar,useFormContext as Dr}from"react-hook-form";import{Grid as $r}from"@s_mart/core";import{composeValidators as Mr,date as ke}from"@s_mart/rules";import{TextField as zr}from"@mui/material";import{DatePicker as qr}from"@mui/x-date-pickers/DatePicker";import{AdapterDayjs as _r}from"@mui/x-date-pickers/AdapterDayjs";import{LocalizationProvider as Or}from"@mui/x-date-pickers/LocalizationProvider";import{ptBR as Ur}from"@mui/x-date-pickers/locales/ptBR";import jr from"dayjs/locale/pt-br";import Lr from"@emotion/styled";import{IconButton as Vr}from"@mui/material";import{toRem as D}from"@s_mart/utils";var Rr=e=>{switch(e){case"small":return D(16);default:case"medium":return D(20);case"large":return D(24)}},Er=e=>{switch(e){case"small":return`${D(2)} ${D(8)}`;default:case"medium":return`${D(6)} ${D(8)}`;case"large":return`${D(10)}`}},Te=Lr(Vr)`
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:h,multiple:f,info:x,onChange:P,onInputChange:s,placeholder:b,disableIconError:d,...p})=>{let G=Xo();if(!G)throw new Error("Para usar o <Creatable /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let M=V(G.formState.errors,e),r=h||p.disabled,o=w=>{let O=0;return a?.InputProps||(O+=2.5),r||(O+=2.56,m(w)&&(O+=2.56)),!p.disableClearable&&!p.disabled&&(O+=1.3),O+"rem"},m=w=>p.disabled?!1:v&&Qo(w)&&!Zo(w);console.warn=()=>{};let c=w=>{y?y(w):console.error("onCreateOption n\xE3o foi definido")},E=w=>{u?u(w):console.error("onEditOption n\xE3o foi definido")};return k(Ko,{control:G.control,name:e,rules:t,defaultValue:n,shouldUnregister:i,render:({field:{value:w,onChange:O,ref:je}})=>{let xe=w?.label||w?.value||w;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:{...p.slotProps||{},paper:{...(p.slotProps||{}).paper||{},sx:{border:`1px solid ${lr.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)",...(p.slotProps||{}).paper?.sx||{}}}},options:F,value:w||(f?[]:null),multiple:f,readOnly:p.disabled,noOptionsText:r?void 0:q(tr,{sx:{justifyContent:"flex-start",padding:`${Le(6)} ${Le(-16)}`,margin:0},fullWidth:!0,onClick:()=>c(w),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")]})}),...p,sx:{"& div.MuiInputBase-root":{paddingRight:`${o(w)} !important`},...p.sx},renderInput:L=>k(or,{placeholder:b,...L,error:!!M,InputProps:{...L.InputProps,inputRef:je,endAdornment:q("div",{className:"endAdornments",children:[L.InputProps.endAdornment,!r&&q(fe,{children:[m(w)?q("div",{className:"editable",children:[k("div",{className:"divider"}),k("div",{className:"button",onClick:()=>E(w),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(w),children:k(ie,{icon:Ee,size:"24px",removeMargin:!0})})]})]})]})},...a})},e)}),k(S,{name:e,disableIcon:d})]})}})},dr=Jo(sr);import{Controller as mr,useFormContext as pr}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=pr();if(!y)throw new Error("Para usar o <Checkbox /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return Q(mr,{control:y.control,name:e,rules:t,defaultValue:n,shouldUnregister:i,render:({field:{value:a,onChange:h}})=>Fr(ur,{display:"flex",flexDirection:"column",children:[Q(cr,{control:Q(fr,{checked:!!a,value:a??"",defaultValue:a,onChange:(f,x)=>{h(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:(h,f)=>{a(h,f),v?.(h,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:h}})=>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),h(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 Jr}from"react-hook-form";import{Grid as Kr}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})=>Er(e)};
58
- border-radius: 0 ${D(4)} ${D(4)} 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})=>Rr(e)} !important;
61
+ width: ${({size:e})=>Nr(e)} !important;
62
62
  }
63
- `;import{jsx as K,jsxs as Yr}from"react/jsx-runtime";import{createElement as Wr}from"react";var Nr=({rules:e,name:r,defaultValue:i,shouldUnregister:t,datePickerProps:n,label:b,required:p,placeholder:g,disabled:I,disableIconError:c,...u})=>{let a=Dr();if(!a)throw new Error("Para usar o <DataPicker /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let F=V(a.formState.errors,r),d=n?.format||"DD/MM/YYYY",x=e?Mr([ke(d),e]):ke(d);return K(Or,{dateAdapter:_r,adapterLocale:jr,localeText:Ur.components.MuiLocalizationProvider.defaultProps.localeText,children:K(Ar,{control:a.control,name:r,rules:x,defaultValue:i,shouldUnregister:t,render:({field:{value:P,onChange:s,ref:C}})=>Yr($r,{display:"flex",flexDirection:"column",children:[b&&K(v,{label:b,required:p}),Wr(qr,{...n,key:r,value:P??null,format:d,onChange:(m,f)=>{s(m,f),n?.onChange?.(m,f)},disabled:I,slots:{textField:zr,openPickerButton:m=>K(Te,{...m,size:u.size})},slotProps:{textField:m=>({variant:"outlined",...m,error:!!F,...u,inputProps:{...m.inputProps,placeholder:g||m.inputProps?.placeholder},InputProps:{...m.InputProps,inputRef(f){C(f),typeof m.inputRef=="function"&&m.inputRef(f)}}})}}),K(T,{name:r,disableIcon:c})]})})})},Hr=Br(Nr);import{memo as Zr}from"react";import{Controller as et,useFormContext as ot}from"react-hook-form";import{Grid as rt}from"@s_mart/core";import{composeValidators as tt,time as Se}from"@s_mart/rules";import{TextField as it}from"@mui/material";import{TimePicker as lt}from"@mui/x-date-pickers/TimePicker";import{AdapterDayjs as nt}from"@mui/x-date-pickers/AdapterDayjs";import{LocalizationProvider as at}from"@mui/x-date-pickers/LocalizationProvider";import{ptBR as st}from"@mui/x-date-pickers/locales/ptBR";import dt from"dayjs/locale/pt-br";import Jr from"@emotion/styled";import{IconButton as Kr}from"@mui/material";import{toRem as $}from"@s_mart/utils";var Xr=e=>{switch(e){case"small":return $(16);default:case"medium":return $(20);case"large":return $(24)}},Qr=e=>{switch(e){case"small":return`${$(2)} ${$(8)}`;default:case"medium":return`${$(6)} ${$(8)}`;case"large":return`${$(10)}`}},we=Jr(Kr)`
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=Jr();if(!a)throw new Error("Para usar o <DataPicker /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let h=V(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:b}})=>at(Kr,{display:"flex",flexDirection:"column",children:[g&&ee(C,{label:g,required:F}),nt(Zr,{...l,key:t,value:P??null,format:f,onChange:(d,p)=>{s(d,p),l?.onChange?.(d,p)},disabled:I,slots:{textField:Qr,openPickerButton:d=>ee(De,{...d,size:y.size})},slotProps:{textField:d=>({variant:"outlined",...d,error:!!h,...y,inputProps:{...d.inputProps,placeholder:v||d.inputProps?.placeholder},InputProps:{...d.InputProps,inputRef(p){b(p),typeof d.inputRef=="function"&&d.inputRef(p)}}})}}),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 mt=e=>{switch(e){case"small":return _(16);default:case"medium":return _(20);case"large":return _(24)}},pt=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})=>Qr(e)};
67
- border-radius: 0 ${$(4)} ${$(4)} 0;
66
+ padding: ${({size:e})=>pt(e)};
67
+ border-radius: 0 ${_(4)} ${_(4)} 0;
68
68
 
69
69
  svg {
70
- width: ${({size:e})=>Xr(e)} !important;
70
+ width: ${({size:e})=>mt(e)} !important;
71
71
  }
72
- `;import{jsx as H,jsxs as ut}from"react/jsx-runtime";var mt=({rules:e,defaultValue:r,shouldUnregister:i,name:t,required:n,label:b,timePickerProps:p,placeholder:g,disabled:I,disableIconError:c,...u})=>{let a=ot();if(!a)throw new Error("Para usar o <TimePicker /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let F=V(a.formState.errors,t),d=p?.format||"HH:mm",x=e?tt([Se(d),e]):Se(d);return H(at,{dateAdapter:nt,adapterLocale:dt,localeText:st.components.MuiLocalizationProvider.defaultProps.localeText,children:H(et,{control:a.control,name:t,rules:x,defaultValue:r,shouldUnregister:i,render:({field:{value:P,onChange:s,ref:C}})=>ut(rt,{display:"flex",flexDirection:"column",children:[b&&H(v,{label:b,required:n}),H(lt,{ampm:!1,format:d,value:P??null,disabled:I,...p,onChange:(m,f)=>{s(m,f),p?.onChange?.(m,f)},slots:{textField:it,openPickerButton:m=>H(we,{...m,size:u.size})},slotProps:{textField:m=>({variant:"outlined",...m,error:!!F,...u,inputProps:{...m.inputProps,placeholder:g||m.inputProps?.placeholder},InputProps:{...m.InputProps,inputRef(f){C(f),typeof m.inputRef=="function"&&m.inputRef(f)}}})}},t),H(T,{name:t,disableIcon:c})]})})})},pt=Zr(mt);import{memo as ft}from"react";import{Controller as ct,useFormContext as xt}from"react-hook-form";import{Autocomplete as yt,TextField as Ft}from"@mui/material";import{Grid as re}from"@s_mart/core";import{colorPalette as Pt}from"@s_mart/tokens";import{jsx as j,jsxs as Ge}from"react/jsx-runtime";import{createElement as gt}from"react";var bt=({name:e,defaultValue:r,rules:i,shouldUnregister:t,label:n,required:b,noOptionsText:p,placeholder:g,onInputChange:I,onChange:c,disableIconError:u,...a})=>{let F=xt();if(!F)throw new Error("Para usar o <Autocomplete /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let d=V(F.formState.errors,e);return console.warn=()=>{},j(ct,{name:e,control:F.control,defaultValue:r,rules:i,shouldUnregister:t,render:({field:x})=>Ge(re,{display:"flex",flexDirection:"column",children:[n&&j(v,{label:n,required:b}),j(yt,{onChange:(P,s)=>{x.onChange(s),c?.(s,F.getValues())},onInputChange:(P,s,C)=>{C==="input"&&(x.onChange(s),setTimeout(()=>{I?.(s,F.getValues())},0))},slotProps:{...a.slotProps||{},paper:{...(a.slotProps||{}).paper||{},sx:{border:`1px solid ${Pt.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)=>gt("li",{...P,key:s.key||s.value,onClick:C=>{P.onClick?.(C),x.onChange(s)}},Ge(re,{container:!0,direction:"column",children:[j(re,{item:!0,children:s.label}),s.afterLabel&&j(re,{item:!0,children:s.afterLabel})]})),value:x.value||null,readOnly:a.disabled,noOptionsText:p||"Nenhuma op\xE7\xE3o encontrada",...a,renderInput:P=>j(Ft,{placeholder:g,...P,...a.textFieldProps,error:!!d,InputProps:{...P.InputProps,...a.textFieldProps?.InputProps,inputRef:x.ref,inputProps:{...P.inputProps,...a.textFieldProps?.InputProps?.inputProps}}})},e),j(T,{name:e,disableIcon:u})]})})},ht=ft(bt);export{ht as Autocomplete,tr as Checkbox,Ko as Creatable,Hr as DatePicker,v as FieldLabel,Me as Form,ie as FormProvider,Fr as RadioButton,vr as RadioGroup,Ro as Searchable,bo as Select,Gr as Slider,pr as Switch,to as TextField,pt as TimePicker,le as useForm};
72
+ `;import{jsx as J,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 h=V(a.formState.errors,i),f=F?.format||"HH:mm",x=e?xt([$e(f),e]):$e(f);return J(ht,{dateAdapter:bt,adapterLocale:vt,localeText:gt.components.MuiLocalizationProvider.defaultProps.localeText,children:J(ft,{control:a.control,name:i,rules:x,defaultValue:t,shouldUnregister:n,render:({field:{value:P,onChange:s,ref:b}})=>It(yt,{display:"flex",flexDirection:"column",children:[g&&J(C,{label:g,required:l}),J(Pt,{ampm:!1,format:f,value:P??null,disabled:I,...F,onChange:(d,p)=>{s(d,p),F?.onChange?.(d,p)},slots:{textField:Ft,openPickerButton:d=>J(Me,{...d,size:y.size})},slotProps:{textField:d=>({variant:"outlined",...d,error:!!h,...y,inputProps:{...d.inputProps,placeholder:v||d.inputProps?.placeholder},InputProps:{...d.InputProps,inputRef(p){b(p),typeof d.inputRef=="function"&&d.inputRef(p)}}})}},i),J(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 h=wt();if(!h)throw new Error("Para usar o <Autocomplete /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let f=V(h.formState.errors,e);return console.warn=()=>{},W(kt,{name:e,control:h.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,h.getValues())},onInputChange:(P,s,b)=>{b==="input"&&(x.onChange(s),setTimeout(()=>{I?.(s,h.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:b=>{P.onClick?.(b),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 Jt}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:h,onChange:f,onInputChange:x,getOptionAfterLabel:P,getOptionLabel:s,getOptionKey:b,...d})=>{let p=_t();if(!p)throw new Error("Para usar o <SearchableV2 /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let G=V(p.formState.errors,e);return A(zt,{control:p.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:(m,c)=>{M(c),f?.(c)},onInputChange:(m,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:(m,c)=>jt(m,c),getOptionLabel:m=>s(m),getOptionKey:m=>b(m),renderOption:typeof P=="function"?(m,c)=>{let E=P(c),w=b(c);return Jt("li",{...m,key:w},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:m=>A(Ot,{error:!!G,placeholder:h,...m,...v,inputRef:o})},e),A(S,{name:e})]})})},Yt=se(Wt);import{useState as Kt}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 K}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:h="outlined",getOptionKey:f,getOptionLabel:x,getOptionAfterLabel:P,...s})=>{let b=Qt(),[d,p]=Kt(!1);if(!b)throw new Error("Para usar o <SelectV2 /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let G=V(b.formState.errors,e);return D(Xt,{control:b.control,name:e,rules:t,defaultValue:n,shouldUnregister:i,render:({field:{value:M,onChange:r,ref:o}})=>K("div",{style:{display:"flex",flexDirection:"column"},children:[K("div",{style:{display:"flex"},children:[l&&D(C,{label:l,required:g}),u&&D(oe,{title:u})]}),K(ri,{open:d,onOpen:()=>p(!0),onClose:()=>p(!1),displayEmpty:!!v,variant:h,autoComplete:"off",value:M||"",renderValue:m=>m?.length===0?D("p",{style:{color:_e.neutral[100]},children:v}):x(m),onChange:m=>{r(m.target.value),a?.(m.target.value)},error:!!G,size:s.size||"medium",inputRef:o,...s,endAdornment:K(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(m=>{let c=f(m);if(typeof P=="function"){let E=P(m);return D(Ue,{value:m,children:K("div",{style:{display:"flex",flexDirection:"column"},children:[x(m),typeof E=="string"?D("span",{children:E}):E]})},c)}return D(Ue,{value:m,children:D("div",{children:x(m)})},c)}),y!==void 0&&K(Oe,{children:[D("div",{style:{padding:"8px 16px"},children:D(ti,{})},"footer-divider"),D("div",{children:y({closeSelect:()=>p(!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,me 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,pe as useForm};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@s_mart/form",
3
- "version": "6.1.1",
3
+ "version": "6.2.1",
4
4
  "main": "./dist/index.mjs",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.mts",