@s_mart/form 9.2.0-beta.5 → 9.2.0-beta.7

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
@@ -196,6 +196,7 @@ type CreatableV2Props<TFieldValues extends FieldValues = FieldValues, TFieldName
196
196
  showCreatableButton?: boolean;
197
197
  /**
198
198
  * Define se mostra o botão para editar uma opção existente
199
+ * Só é possível utilizar se a prop `multiple` for `false | undefined`
199
200
  * @default false
200
201
  * @type {boolean}
201
202
  * @memberof CreatableV2Props
@@ -203,18 +204,21 @@ type CreatableV2Props<TFieldValues extends FieldValues = FieldValues, TFieldName
203
204
  showEditableButton?: boolean;
204
205
  /**
205
206
  * Função que será executada quando o usuário clicar no botão de criar uma nova opção
206
- * @default () => {}
207
+ * @default undefined
207
208
  * @type {(value: string) => void}
208
209
  * @memberof CreatableV2Props
209
210
  */
210
211
  onCreateOption?: (value: string) => void;
211
212
  /**
212
213
  * Função que será executada quando o usuário clicar no botão de editar uma opção
213
- * @default () => {}
214
- * @type {(value) => void}
214
+ * é possível utilizar se a prop `multiple` for `false | undefined`
215
+ * é possível editar se o valor for um Objeto
216
+ *
217
+ * @default undefined
218
+ * @type {(value: FieldValue) => Promise<void> | void}
215
219
  * @memberof CreatableV2Props
216
220
  */
217
- onEditOption?: (value: AutocompleteValue<FieldValue, Multiple, DisableClearable, FreeSolo>) => void;
221
+ onEditOption?: (value: FieldValue) => Promise<void> | void;
218
222
  /**
219
223
  * Componente que renderiza no footer do searchable (opcional)
220
224
  * @example
@@ -282,13 +286,13 @@ type FieldLabelProps = {
282
286
 
283
287
  declare const FieldLabel: ({ label, required, regular }: FieldLabelProps) => react_jsx_runtime.JSX.Element;
284
288
 
285
- type FieldErrorProps<TFieldValues extends FieldValues, TFieldNames extends FieldPath<TFieldValues>> = {
289
+ type FieldErrorProps<TFieldValues extends FieldValues = FieldValues, TFieldNames extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = {
286
290
  name: TFieldNames;
287
291
  disableIcon?: boolean;
288
292
  control: Control<TFieldValues>;
289
293
  };
290
294
 
291
- declare const FieldError: <TFieldValues extends FieldValues, TFieldNames extends FieldPath<TFieldValues>>({ name, disableIcon, control, }: FieldErrorProps<TFieldValues, TFieldNames>) => react_jsx_runtime.JSX.Element | null;
295
+ declare const FieldError: <TFieldValues extends FieldValues = FieldValues, TFieldNames extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ name, disableIcon, control, }: FieldErrorProps<TFieldValues, TFieldNames>) => react_jsx_runtime.JSX.Element | null;
292
296
 
293
297
  type FieldInfoProps = {
294
298
  title: React.ReactNode;
@@ -701,9 +705,9 @@ type SliderProps<TFieldValues extends FieldValues = FieldValues, TFieldName exte
701
705
  labelPlacement?: 'start' | 'end' | 'top' | 'bottom';
702
706
  };
703
707
 
704
- declare const Slider: <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>>({ name, rules, defaultValue, shouldUnregister, control: controlFromProps, ...rest }: SliderProps<TFieldValues, TFieldName>) => react_jsx_runtime.JSX.Element;
708
+ declare const Slider: <TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ name, rules, defaultValue, shouldUnregister, control: controlFromProps, ...rest }: SliderProps<TFieldValues, TFieldName>) => react_jsx_runtime.JSX.Element;
705
709
 
706
- type SwitchProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = SwitchProps$1 & UseControllerProps<TFieldValues, TFieldName> & {
710
+ type SwitchProps<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = SwitchProps$1 & UseControllerProps<TFieldValues, TFieldName> & {
707
711
  /**
708
712
  * O nome do switch que será renderizado na tela
709
713
  * @default ''
@@ -730,7 +734,7 @@ type SwitchProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<
730
734
  disableIconError?: boolean;
731
735
  };
732
736
 
733
- declare const Switch: <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>>({ name, rules, defaultValue, shouldUnregister, control: controlFromProps, label, labelPlacement, disableIconError, onChange: onChangeProp, ...rest }: SwitchProps<TFieldValues, TFieldName>) => react_jsx_runtime.JSX.Element;
737
+ declare const Switch: <TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ name, rules, defaultValue, shouldUnregister, control: controlFromProps, label, labelPlacement, disableIconError, onChange: onChangeProp, ...rest }: SwitchProps<TFieldValues, TFieldName>) => react_jsx_runtime.JSX.Element;
734
738
 
735
739
  type Masks = 'cpf' | 'cnpj' | 'cpfCnpj' | 'cep' | 'telefone' | 'decimal' | 'decimal3' | 'decimal4' | 'decimal5' | 'porcentagem' | 'porcentagem0' | 'nome' | 'numero' | 'numeroPontuacao' | 'placa' | 'valor' | 'valor3' | 'valor4';
736
740
  type TextFieldProps<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = TextFieldProps$1 & UseControllerProps<TFieldValues, TFieldName> & {
@@ -776,7 +780,7 @@ type TextFieldProps<TFieldValues extends FieldValues = FieldValues, TFieldName e
776
780
 
777
781
  declare const TextField: <TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ name, rules, defaultValue, shouldUnregister, control: controlFromProps, label, required, mask, variant, info, parse, format, onInputChange, disableIconError, ...rest }: TextFieldProps<TFieldValues, TFieldName>) => react_jsx_runtime.JSX.Element;
778
782
 
779
- type TimePickerProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = UseControllerProps<TFieldValues, TFieldName> & Pick<TextFieldProps$1, 'label' | 'error' | 'helperText' | 'size' | 'fullWidth' | 'variant' | 'autoFocus' | 'placeholder'> & {
783
+ type TimePickerProps<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = UseControllerProps<TFieldValues, TFieldName> & Pick<TextFieldProps$1, 'label' | 'error' | 'helperText' | 'size' | 'fullWidth' | 'variant' | 'autoFocus' | 'placeholder'> & {
780
784
  timePickerProps?: Partial<TimePickerProps$1<any>>;
781
785
  /**
782
786
  * Se `true` irá adicionar um asterisco ao label do campo
@@ -800,6 +804,6 @@ type TimePickerProps<TFieldValues extends FieldValues, TFieldName extends FieldP
800
804
  disableIconError?: boolean;
801
805
  };
802
806
 
803
- declare const _default: react.MemoExoticComponent<(<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>>({ rules, defaultValue, shouldUnregister, name, control: controlFromProps, required, label, timePickerProps, placeholder, disabled, disableIconError, ...rest }: TimePickerProps<TFieldValues, TFieldName>) => react_jsx_runtime.JSX.Element)>;
807
+ declare const _default: react.MemoExoticComponent<(<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ rules, defaultValue, shouldUnregister, name, control: controlFromProps, required, label, timePickerProps, placeholder, disabled, disableIconError, ...rest }: TimePickerProps<TFieldValues, TFieldName>) => react_jsx_runtime.JSX.Element)>;
804
808
 
805
809
  export { type AutoCompleteOption, _default$5 as Autocomplete, type AutocompleteProps, Checkbox, type CheckboxProps, Creatable, type CreatableOption, type CreatableProps, _default$4 as CreatableV2, type CreatableV2Props, _default$3 as DatePicker, type DatePickerProps, FieldError, type FieldErrorProps, FieldInfo, type FieldInfoProps, FieldLabel, type FieldLabelProps, type FooterProps, type FooterPropsV2, Form, FormProvider, type IFormProps, type IFormProviderProps, type IUseFormProps, type Masks, RadioButton, RadioGroup, type RadioGroupProps, type RadioProps, Searchable, type SearchableOption, type SearchableProps, _default$2 as SearchableV2, type SearchableV2Props, Select, type SelectOption, type SelectProps, type SelectProps as SelectPropsMui, _default$1 as SelectV2, type SelectV2Props, type SelectV2ReturnValueProps, Slider, type SliderProps, Switch, type SwitchProps, TextField, type TextFieldProps, _default as TimePicker, type TimePickerProps, useForm };
package/dist/index.mjs CHANGED
@@ -1,11 +1,11 @@
1
- import{Autocomplete as Fo,Grid as se,TextField as yo}from"@mui/material";import{colorPalette as xo}from"@s_mart/tokens";import{memo as bo}from"react";import{Controller as ho,useFormContext as Po}from"react-hook-form";import{Indicator as ao}from"@s_mart/core";import{useFormState as so}from"react-hook-form";var R=(e,o)=>o.replace(/[[\]]/g,"").split(".").reduce((i,s)=>i?.[s],e);import{jsx as mo}from"react/jsx-runtime";var po=({name:e,disableIcon:o,control:l})=>{let i=so({control:l,name:e}),s=R(i?.errors,e);return s?mo(ao,{severity:"error",icon:o?!1:void 0,children:s?.message}):null},k=po;import{Typography as Ie}from"@mui/material";import{toRem as uo}from"@s_mart/utils";import{jsx as we,jsxs as co}from"react/jsx-runtime";var fo=({label:e,required:o,regular:l})=>co("span",{style:{display:"flex",alignItems:"center",gap:uo(2)},children:[we(Ie,{variant:"caption",style:{display:"flex",alignItems:"center"},sx:{fontWeight:l?400:700},children:e}),o&&we(Ie,{variant:"caption",color:"error",sx:{fontWeight:900},children:"*"})]}),v=fo;var T=class extends Error{constructor(o){super(`O componente ${o} precisa de um control para funcionar. Passe o control como prop ou coloque o componente dentro de um <Form />`),this.name="FormComponentPrecisaDeControl"}};import{jsx as Z,jsxs as Le}from"react/jsx-runtime";import{createElement as Co}from"react";var go=({name:e,defaultValue:o,rules:l,shouldUnregister:i,label:s,required:P,noOptionsText:g,placeholder:c,onInputChange:S,onChange:x,disableIconError:C,...m})=>{let u=Po();if(!u)throw new T("Autocomplete");let a=R(u.formState.errors,e);return console.warn=()=>{},Z(ho,{name:e,control:u.control,defaultValue:o,rules:l,shouldUnregister:i,render:({field:p})=>Le(se,{sx:{display:"flex",flexDirection:"column"},children:[s&&Z(v,{label:s,required:P}),Z(Fo,{onChange:(V,n)=>{p.onChange(n),x?.(n,u.getValues())},onInputChange:(V,n,F)=>{F==="input"&&(p.onChange(n),setTimeout(()=>{S?.(n,u.getValues())},0))},slotProps:{...m.slotProps||{},paper:{...m.slotProps?.paper||{},sx:{border:`1px solid ${xo.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}}},isOptionEqualToValue:(V,n)=>V.value===n.value,renderOption:(V,n)=>Co("li",{...V,key:n.key||n.value,onClick:F=>{V.onClick?.(F),p.onChange(n)}},Le(se,{container:!0,direction:"column",children:[Z(se,{item:!0,children:n.label}),n.afterLabel&&Z(se,{item:!0,children:n.afterLabel})]})),value:p.value||null,readOnly:m.disabled,noOptionsText:g||"Nenhuma op\xE7\xE3o encontrada",...m,renderInput:V=>Z(yo,{placeholder:c,...V,error:!!a,slotProps:{input:{inputProps:V.inputProps,inputRef:p.ref}}})},e),Z(k,{name:e,disableIcon:C,control:u.control})]})})},Vo=bo(go);import{useController as vo,useFormContext as To}from"react-hook-form";import{Checkbox as So,FormControlLabel as ko}from"@mui/material";import{jsx as pe,jsxs as Lo}from"react/jsx-runtime";var Io=({name:e,rules:o,defaultValue:l,shouldUnregister:i,control:s,label:P,labelPlacement:g,required:c,disableIconError:S,onChange:x,...C})=>{let m=To()?.control,u=s??m;if(!u)throw new T("Checkbox");let{field:a}=vo({control:u,name:e,rules:o,defaultValue:l,shouldUnregister:i});return Lo("span",{children:[pe(ko,{control:pe(So,{checked:!!a.value,value:a.value??"",defaultValue:a.value,onChange:(p,V)=>{a.onChange(p,V),x?.(p,V)},...C},e),label:pe(v,{label:P,required:c,regular:!0}),labelPlacement:g||"end"}),pe(k,{name:e,disableIcon:S,control:u})]})},wo=Io;import{forwardRef as Ro,memo as Bo}from"react";import{Controller as Eo,useFormContext as Mo}from"react-hook-form";import{isObject as Oo,isEmpty as $o}from"lodash-es";import{Grid as ee,Autocomplete as No,TextField as Go,Tooltip as zo,Divider as qo}from"@mui/material";import{LIcon as ue,Button as _o}from"@s_mart/core";import{colorPalette as Uo}from"@s_mart/tokens";import{linePlus as Be,linePen as Ho,lineInfoCircle as Ko}from"@s_mart/solid-icons";import{toRem as Ee}from"@s_mart/utils";import{css as Ae}from"@emotion/react";import{styled as Ao}from"@mui/material";import{toRem as me}from"@s_mart/utils";var De=Ae`
1
+ import{Autocomplete as Fo,Grid as se,TextField as yo}from"@mui/material";import{colorPalette as xo}from"@s_mart/tokens";import{memo as bo}from"react";import{Controller as ho,useFormContext as Po}from"react-hook-form";import{Indicator as ao}from"@s_mart/core";import{useFormState as so}from"react-hook-form";var D=(e,o)=>o.replace(/[[\]]/g,"").split(".").reduce((i,s)=>i?.[s],e);import{jsx as mo}from"react/jsx-runtime";var po=({name:e,disableIcon:o,control:l})=>{let i=so({control:l,name:e}),s=D(i?.errors,e);return s?mo(ao,{severity:"error",icon:o?!1:void 0,children:s?.message}):null},k=po;import{Typography as Ie}from"@mui/material";import{toRem as uo}from"@s_mart/utils";import{jsx as we,jsxs as co}from"react/jsx-runtime";var fo=({label:e,required:o,regular:l})=>co("span",{style:{display:"flex",alignItems:"center",gap:uo(2)},children:[we(Ie,{variant:"caption",style:{display:"flex",alignItems:"center"},sx:{fontWeight:l?400:700},children:e}),o&&we(Ie,{variant:"caption",color:"error",sx:{fontWeight:900},children:"*"})]}),v=fo;var T=class extends Error{constructor(o){super(`O componente ${o} precisa de um control para funcionar. Passe o control como prop ou coloque o componente dentro de um <Form />`),this.name="FormComponentPrecisaDeControl"}};import{jsx as Z,jsxs as Le}from"react/jsx-runtime";import{createElement as Co}from"react";var Vo=({name:e,defaultValue:o,rules:l,shouldUnregister:i,label:s,required:P,noOptionsText:V,placeholder:c,onInputChange:S,onChange:x,disableIconError:C,...m})=>{let u=Po();if(!u)throw new T("Autocomplete");let a=D(u.formState.errors,e);return console.warn=()=>{},Z(ho,{name:e,control:u.control,defaultValue:o,rules:l,shouldUnregister:i,render:({field:p})=>Le(se,{sx:{display:"flex",flexDirection:"column"},children:[s&&Z(v,{label:s,required:P}),Z(Fo,{onChange:(g,n)=>{p.onChange(n),x?.(n,u.getValues())},onInputChange:(g,n,F)=>{F==="input"&&(p.onChange(n),setTimeout(()=>{S?.(n,u.getValues())},0))},slotProps:{...m.slotProps||{},paper:{...m.slotProps?.paper||{},sx:{border:`1px solid ${xo.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}}},isOptionEqualToValue:(g,n)=>g.value===n.value,renderOption:(g,n)=>Co("li",{...g,key:n.key||n.value,onClick:F=>{g.onClick?.(F),p.onChange(n)}},Le(se,{container:!0,direction:"column",children:[Z(se,{item:!0,children:n.label}),n.afterLabel&&Z(se,{item:!0,children:n.afterLabel})]})),value:p.value||null,readOnly:m.disabled,noOptionsText:V||"Nenhuma op\xE7\xE3o encontrada",...m,renderInput:g=>Z(yo,{placeholder:c,...g,error:!!a,slotProps:{input:{inputProps:g.inputProps,inputRef:p.ref}}})},e),Z(k,{name:e,disableIcon:C,control:u.control})]})})},go=bo(Vo);import{useController as vo,useFormContext as To}from"react-hook-form";import{Checkbox as So,FormControlLabel as ko}from"@mui/material";import{jsx as pe,jsxs as Lo}from"react/jsx-runtime";var Io=({name:e,rules:o,defaultValue:l,shouldUnregister:i,control:s,label:P,labelPlacement:V,required:c,disableIconError:S,onChange:x,...C})=>{let m=To()?.control,u=s??m;if(!u)throw new T("Checkbox");let{field:a}=vo({control:u,name:e,rules:o,defaultValue:l,shouldUnregister:i});return Lo("span",{children:[pe(ko,{control:pe(So,{checked:!!a.value,value:a.value??"",defaultValue:a.value,onChange:(p,g)=>{a.onChange(p,g),x?.(p,g)},...C},e),label:pe(v,{label:P,required:c,regular:!0}),labelPlacement:V||"end"}),pe(k,{name:e,disableIcon:S,control:u})]})},wo=Io;import{forwardRef as Do,memo as Bo}from"react";import{Controller as Eo,useFormContext as Mo}from"react-hook-form";import{isObject as Oo,isEmpty as $o}from"lodash-es";import{Grid as ee,Autocomplete as No,TextField as Go,Tooltip as zo,Divider as qo}from"@mui/material";import{LIcon as ue,Button as _o}from"@s_mart/core";import{colorPalette as Uo}from"@s_mart/tokens";import{linePlus as Be,linePen as Ho,lineInfoCircle as Ko}from"@s_mart/solid-icons";import{toRem as Ee}from"@s_mart/utils";import{css as Ae}from"@emotion/react";import{styled as Ao}from"@mui/material";import{toRem as me}from"@s_mart/utils";var Re=Ae`
2
2
  display: flex;
3
3
  align-items: center;
4
4
  justify-content: center;
5
- `,Do=e=>Ae`
5
+ `,Ro=e=>Ae`
6
6
  .creatable,
7
7
  .editable {
8
- ${De}
8
+ ${Re}
9
9
 
10
10
  .divider {
11
11
  width: 1px;
@@ -31,14 +31,14 @@ import{Autocomplete as Fo,Grid as se,TextField as yo}from"@mui/material";import{
31
31
  }
32
32
  }
33
33
  }
34
- `,Re=Ao("div")`
34
+ `,De=Ao("div")`
35
35
  display: flex;
36
36
 
37
37
  div.endAdornments {
38
38
  position: absolute;
39
39
  right: 0;
40
40
 
41
- ${De}
41
+ ${Re}
42
42
  }
43
43
 
44
44
  .MuiAutocomplete-endAdornment {
@@ -50,8 +50,8 @@ import{Autocomplete as Fo,Grid as se,TextField as yo}from"@mui/material";import{
50
50
  transform: translate(0, 0);
51
51
  }
52
52
 
53
- ${({hideAddButton:e,theme:o})=>!e&&Do(o)}
54
- `;import{Fragment as be,jsx as D,jsxs as H}from"react/jsx-runtime";import{createElement as Me}from"react";var Oe=Bo(({name:e,rules:o,defaultValue:l,shouldUnregister:i,label:s,required:P,options:g,editable:c,footer:S,onEditOption:x,onCreateOption:C,textFieldProps:m,hideAddButton:u,multiple:a,info:p,onChange:V,onInputChange:n,placeholder:F,disableIconError:A,...r})=>{let y=Mo();if(!y)throw new T("Creatable");let G=R(y.formState.errors,e),b=u||r.disabled,d=t=>{let I=0;return m?.InputProps||(I+=2.5),b||(I+=2.56,w(t)&&(I+=2.56)),!r.disableClearable&&!r.disabled&&(I+=1.3),I+"rem"},w=t=>r.disabled?!1:c&&Oo(t)&&!$o(t);console.warn=()=>{};let L=t=>{C?C(t):console.error("onCreateOption n\xE3o foi definido")},f=t=>{x?x(t):console.error("onEditOption n\xE3o foi definido")};return D(Eo,{control:y.control,name:e,rules:o,defaultValue:l,shouldUnregister:i,render:({field:{value:t,onChange:I,ref:z}})=>{let X=t?.label||t?.value||t;return H(ee,{sx:{display:"flex",flexDirection:"column"},children:[H("div",{style:{display:"flex"},children:[s&&D(ee,{item:!0,children:D(v,{label:s,required:P})}),p&&D(ee,{item:!0,children:D(zo,{title:p,placement:"top",children:D("div",{style:{width:"fit-content"},children:D(ue,{icon:Ko,color:"#757575"})})})})]}),D(Re,{hideAddButton:b,children:D(No,{fullWidth:!0,onChange:(B,h)=>{I(h),V?.(h,y.getValues())},onInputChange:(B,h,ne)=>{ne==="input"&&setTimeout(()=>{n?.(h,y.getValues())},0)},slotProps:{...r.slotProps||{},paper:{...(r.slotProps||{}).paper||{},sx:{border:`1px solid ${Uo.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}},listbox:{component:Ro(function(h,ne){return H(be,{children:[D("ul",{...h,ref:ne}),!!S&&D("div",{...h,children:H(be,{children:[D(ee,{sx:{px:2,py:1},children:D(qo,{})}),S]})},"creatable-footer")]})})}},options:g,value:t||(a?[]:null),multiple:a,readOnly:r.disabled,noOptionsText:b?void 0:H(_o,{sx:{justifyContent:"flex-start",padding:`${Ee(6)} ${Ee(-16)}`,margin:0},fullWidth:!0,onClick:()=>L(t),variant:"text",startIcon:D(ue,{icon:Be}),children:["Adicionar ",X&&`"${X}"`]}),isOptionEqualToValue:(B,h)=>h?typeof B=="string"&&typeof h=="string"?B===h:typeof B=="object"&&typeof h=="object"?typeof B.value=="object"&&typeof h.value=="object"&&B.key!==void 0&&h.key!==void 0?B.key===h.key:B.value===h.value:typeof B=="object"&&typeof h=="string":!1,renderOption:(B,h)=>typeof h=="object"?Me("li",{...B,key:h.key||h.value},H(ee,{container:!0,direction:"column",children:[D(ee,{item:!0,children:h.label}),h.afterLabel&&D(ee,{item:!0,children:h.afterLabel})]})):Me("li",{...B,key:h},h),...r,sx:{"& div.MuiInputBase-root":{paddingRight:`${d(t)} !important`},...r.sx},renderInput:B=>D(Go,{placeholder:F,...B,error:!!G,...m,slotProps:{input:{...B.InputProps,inputRef:z,endAdornment:H("div",{className:"endAdornments",children:[B.InputProps.endAdornment,!b&&H(be,{children:[w(t)?H("div",{className:"editable",children:[D("div",{className:"divider"}),D("div",{className:"button",onClick:()=>f(t),children:D(ue,{icon:Ho,size:"24px",removeMargin:!0})})]}):null,H("div",{className:"creatable",children:[D("div",{className:"divider"}),D("div",{className:"button",onClick:()=>L(t),children:D(ue,{icon:Be,size:"24px",removeMargin:!0})})]})]})]})}}})},e)}),D(k,{name:e,disableIcon:A,control:y.control})]})}})});Oe.displayName="Creatable";var Wo=Oe;import{forwardRef as ot,useCallback as tt,useState as rt}from"react";import{useController as lt,useFormContext as it,useFormState as nt}from"react-hook-form";import{isObject as at,isEmpty as dt,isEqual as st}from"lodash-es";import{Autocomplete as pt,TextField as mt,Divider as Ge,Button as ut}from"@mui/material";import{LIcon as Pe}from"@s_mart/core";import{colorPalette as ft}from"@s_mart/tokens";import{linePlus as ze,linePen as ct}from"@s_mart/solid-icons";import{toRem as qe}from"@s_mart/utils";import{css as Yo,styled as jo}from"@mui/material";import{toRem as fe}from"@s_mart/utils";import"@mui/system";var $e=Yo`
53
+ ${({hideAddButton:e,theme:o})=>!e&&Ro(o)}
54
+ `;import{Fragment as be,jsx as R,jsxs as H}from"react/jsx-runtime";import{createElement as Me}from"react";var Oe=Bo(({name:e,rules:o,defaultValue:l,shouldUnregister:i,label:s,required:P,options:V,editable:c,footer:S,onEditOption:x,onCreateOption:C,textFieldProps:m,hideAddButton:u,multiple:a,info:p,onChange:g,onInputChange:n,placeholder:F,disableIconError:A,...r})=>{let y=Mo();if(!y)throw new T("Creatable");let G=D(y.formState.errors,e),b=u||r.disabled,d=t=>{let I=0;return m?.InputProps||(I+=2.5),b||(I+=2.56,w(t)&&(I+=2.56)),!r.disableClearable&&!r.disabled&&(I+=1.3),I+"rem"},w=t=>r.disabled?!1:c&&Oo(t)&&!$o(t);console.warn=()=>{};let L=t=>{C?C(t):console.error("onCreateOption n\xE3o foi definido")},f=t=>{x?x(t):console.error("onEditOption n\xE3o foi definido")};return R(Eo,{control:y.control,name:e,rules:o,defaultValue:l,shouldUnregister:i,render:({field:{value:t,onChange:I,ref:z}})=>{let X=t?.label||t?.value||t;return H(ee,{sx:{display:"flex",flexDirection:"column"},children:[H("div",{style:{display:"flex"},children:[s&&R(ee,{item:!0,children:R(v,{label:s,required:P})}),p&&R(ee,{item:!0,children:R(zo,{title:p,placement:"top",children:R("div",{style:{width:"fit-content"},children:R(ue,{icon:Ko,color:"#757575"})})})})]}),R(De,{hideAddButton:b,children:R(No,{fullWidth:!0,onChange:(B,h)=>{I(h),g?.(h,y.getValues())},onInputChange:(B,h,ne)=>{ne==="input"&&setTimeout(()=>{n?.(h,y.getValues())},0)},slotProps:{...r.slotProps||{},paper:{...(r.slotProps||{}).paper||{},sx:{border:`1px solid ${Uo.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}},listbox:{component:Do(function(h,ne){return H(be,{children:[R("ul",{...h,ref:ne}),!!S&&R("div",{...h,children:H(be,{children:[R(ee,{sx:{px:2,py:1},children:R(qo,{})}),S]})},"creatable-footer")]})})}},options:V,value:t||(a?[]:null),multiple:a,readOnly:r.disabled,noOptionsText:b?void 0:H(_o,{sx:{justifyContent:"flex-start",padding:`${Ee(6)} ${Ee(-16)}`,margin:0},fullWidth:!0,onClick:()=>L(t),variant:"text",startIcon:R(ue,{icon:Be}),children:["Adicionar ",X&&`"${X}"`]}),isOptionEqualToValue:(B,h)=>h?typeof B=="string"&&typeof h=="string"?B===h:typeof B=="object"&&typeof h=="object"?typeof B.value=="object"&&typeof h.value=="object"&&B.key!==void 0&&h.key!==void 0?B.key===h.key:B.value===h.value:typeof B=="object"&&typeof h=="string":!1,renderOption:(B,h)=>typeof h=="object"?Me("li",{...B,key:h.key||h.value},H(ee,{container:!0,direction:"column",children:[R(ee,{item:!0,children:h.label}),h.afterLabel&&R(ee,{item:!0,children:h.afterLabel})]})):Me("li",{...B,key:h},h),...r,sx:{"& div.MuiInputBase-root":{paddingRight:`${d(t)} !important`},...r.sx},renderInput:B=>R(Go,{placeholder:F,...B,error:!!G,...m,slotProps:{input:{...B.InputProps,inputRef:z,endAdornment:H("div",{className:"endAdornments",children:[B.InputProps.endAdornment,!b&&H(be,{children:[w(t)?H("div",{className:"editable",children:[R("div",{className:"divider"}),R("div",{className:"button",onClick:()=>f(t),children:R(ue,{icon:Ho,size:"24px",removeMargin:!0})})]}):null,H("div",{className:"creatable",children:[R("div",{className:"divider"}),R("div",{className:"button",onClick:()=>L(t),children:R(ue,{icon:Be,size:"24px",removeMargin:!0})})]})]})]})}}})},e)}),R(k,{name:e,disableIcon:A,control:y.control})]})}})});Oe.displayName="Creatable";var Wo=Oe;import{forwardRef as ot,useCallback as tt,useState as rt}from"react";import{useController as lt,useFormContext as it,useFormState as nt}from"react-hook-form";import{isObject as at,isEmpty as dt,isEqual as st}from"lodash-es";import{Autocomplete as pt,TextField as mt,Divider as Ge,Button as ut}from"@mui/material";import{LIcon as Pe}from"@s_mart/core";import{colorPalette as ft}from"@s_mart/tokens";import{linePlus as ze,linePen as ct}from"@s_mart/solid-icons";import{toRem as qe}from"@s_mart/utils";import{css as Yo,styled as jo}from"@mui/material";import{toRem as fe}from"@s_mart/utils";import"@mui/system";var $e=Yo`
55
55
  display: flex;
56
56
  align-items: center;
57
57
  justify-content: center;
@@ -102,16 +102,16 @@ import{Autocomplete as Fo,Grid as se,TextField as yo}from"@mui/material";import{
102
102
  }
103
103
  }
104
104
  }
105
- `;import{Tooltip as Jo}from"@mui/material";import{LIcon as Xo}from"@s_mart/core";import{lineInfoCircle as Qo}from"@s_mart/solid-icons";import{jsx as he}from"react/jsx-runtime";var Zo=({title:e})=>he(Jo,{title:e,placement:"top",children:he("div",{style:{width:"fit-content"},children:he(Xo,{icon:Qo,color:"#757575"})})}),j=Zo;import{memo as et}from"react";var ie=et;import{Fragment as ge,jsx as M,jsxs as _}from"react/jsx-runtime";import{createElement as xt}from"react";function Ft(e){let{name:o,rules:l,defaultValue:i,shouldUnregister:s,control:P,label:g,required:c,options:S,footer:x,showCreatableButton:C=!0,showEditableButton:m,onEditOption:u,onCreateOption:a,getOptionKey:p,getOptionLabel:V,getOptionAfterLabel:n,textFieldProps:F,multiple:A,info:r,noOptionsText:y,onChange:G,onInputChange:b,placeholder:d,...w}=e,[L,f]=rt(""),t=it()?.control,I=P??t;if(!I)throw new T("CreatableV2");let z=nt({control:I,name:o}),X=R(z.errors,o),B=!C||w.disabled,{field:h}=lt({name:o,control:I,rules:l,defaultValue:i,shouldUnregister:s}),ne=O=>{let E=0;return F?.InputProps||(E+=2.5),B||(E+=2.56,Se(O)&&(E+=2.56)),!w.disableClearable&&!w.disabled&&(E+=1.3),`${E}rem`},Se=O=>w.disabled?!1:m&&at(O)&&!dt(O),lo=()=>w.disabled?!1:C,ke=tt(()=>{typeof a<"u"&&(a(L),f(""))},[L,a]),io=O=>{u?.(O)};return _("div",{style:{display:"flex",flexDirection:"column"},children:[_("div",{style:{display:"flex"},children:[g&&M(v,{label:g,required:c}),r&&M(j,{title:r})]}),M(Ne,{children:M(pt,{fullWidth:!0,onChange:(O,E)=>{f(""),h.onChange(E),G?.(E)},onInputChange:(O,E,Q)=>{Q==="input"&&(f(E),b?.(E))},slotProps:{...w.slotProps,paper:{...w.slotProps?.paper,sx:{border:`1px solid ${ft.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}},listbox:{component:ot(function(E,Q){return _(ge,{children:[M("ul",{...E,ref:Q}),typeof x<"u"?_("div",{...E,children:[M("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:M(Ge,{})}),x()]},"creatable-footer"):null]})})}},value:h.value,options:S,multiple:A,readOnly:w.disabled,noOptionsText:_(ge,{children:[y||"Nenhuma op\xE7\xE3o encontrada",!B&&_(ut,{sx:{justifyContent:"flex-start",padding:`${qe(6)} ${qe(-16)}`,margin:0},fullWidth:!0,onClick:ke,variant:"text",startIcon:M(Pe,{icon:ze}),children:["Adicionar ",`"${L}"`]}),typeof x<"u"&&_(ge,{children:[M("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:M(Ge,{})}),x()]})]}),isOptionEqualToValue:(O,E)=>st(O,E),getOptionLabel:V,getOptionKey:p,renderOption:typeof n=="function"?(O,E)=>{let Q=n(E),no=p(E);return xt("li",{...O,key:no},_("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[M("span",{children:V(E)}),typeof Q=="string"?M("span",{children:Q}):Q]}))}:void 0,...w,sx:{"& div.MuiInputBase-root":{paddingRight:`${ne(h.value)} !important`},...w.sx},onBlur:O=>{w?.onBlur?.(O),f("")},renderInput:O=>M(mt,{placeholder:d,...O,error:!!X,...F,slotProps:{input:{...O.InputProps,...F?.InputProps,inputRef:h.ref,endAdornment:_("div",{className:"endAdornments",children:[O.InputProps.endAdornment,F?.InputProps?.endAdornment??null,Se(h.value)?_("div",{className:"editable",children:[M("div",{className:"divider"}),M("div",{className:"button",onKeyUp:()=>io(h.value),children:M(Pe,{icon:ct,size:"24px",removeMargin:!0})})]}):null,lo()&&_("div",{className:"creatable",children:[M("div",{className:"divider"}),M("div",{className:"button",onKeyUp:ke,children:M(Pe,{icon:ze,size:"24px",removeMargin:!0})})]})]})}}})},o)}),M(k,{name:o,control:I})]})}var yt=ie(Ft);import{Stack as Vt,TextField as Ct}from"@mui/material";import{AdapterDayjs as vt}from"@mui/x-date-pickers/AdapterDayjs";import{DatePicker as Tt}from"@mui/x-date-pickers/DatePicker";import{LocalizationProvider as St}from"@mui/x-date-pickers/LocalizationProvider";import{ptBR as kt}from"@mui/x-date-pickers/locales/ptBR";import{composeValidators as It,date as Ue}from"@s_mart/rules";import wt from"dayjs/locale/pt-br";import{memo as Lt}from"react";import{useController as At,useFormContext as Dt,useFormState as Rt}from"react-hook-form";import{IconButton as bt,styled as ht}from"@mui/material";import{toRem as K}from"@s_mart/utils";var Pt=e=>{switch(e){case"small":return K(16);default:case"medium":return K(20);case"large":return K(24)}},gt=e=>{switch(e){case"small":return`${K(2)} ${K(8)}`;default:case"medium":return`${K(6)} ${K(8)}`;case"large":return`${K(10)}`}},_e=ht(bt)`
105
+ `;import{Tooltip as Jo}from"@mui/material";import{LIcon as Xo}from"@s_mart/core";import{lineInfoCircle as Qo}from"@s_mart/solid-icons";import{jsx as he}from"react/jsx-runtime";var Zo=({title:e})=>he(Jo,{title:e,placement:"top",children:he("div",{style:{width:"fit-content"},children:he(Xo,{icon:Qo,color:"#757575"})})}),j=Zo;import{memo as et}from"react";var ie=et;import{Fragment as Ve,jsx as M,jsxs as _}from"react/jsx-runtime";import{createElement as xt}from"react";function Ft(e){let{name:o,rules:l,defaultValue:i,shouldUnregister:s,control:P,label:V,required:c,options:S,footer:x,showCreatableButton:C=!0,showEditableButton:m,onEditOption:u,onCreateOption:a,getOptionKey:p,getOptionLabel:g,getOptionAfterLabel:n,textFieldProps:F,multiple:A,info:r,noOptionsText:y,onChange:G,onInputChange:b,placeholder:d,...w}=e,[L,f]=rt(""),t=it()?.control,I=P??t;if(!I)throw new T("CreatableV2");let z=nt({control:I,name:o}),X=D(z.errors,o),B=!C||w.disabled,{field:h}=lt({name:o,control:I,rules:l,defaultValue:i,shouldUnregister:s}),ne=$=>{let E=0;return F?.InputProps||(E+=2.5),B||(E+=2.56,Se($)&&(E+=2.56)),!w.disableClearable&&!w.disabled&&(E+=1.3),`${E}rem`},Se=$=>w.disabled?!1:m&&at($)&&!dt($),lo=()=>w.disabled?!1:C,ke=tt(()=>{typeof a<"u"&&(a(L),f(""))},[L,a]),io=()=>{u?.(h.value)};return _("div",{style:{display:"flex",flexDirection:"column"},children:[_("div",{style:{display:"flex"},children:[V&&M(v,{label:V,required:c}),r&&M(j,{title:r})]}),M(Ne,{children:M(pt,{fullWidth:!0,onChange:($,E)=>{f(""),h.onChange(E),G?.(E)},onInputChange:($,E,Q)=>{Q==="input"&&(f(E),b?.(E))},slotProps:{...w.slotProps,paper:{...w.slotProps?.paper,sx:{border:`1px solid ${ft.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}},listbox:{component:ot(function(E,Q){return _(Ve,{children:[M("ul",{...E,ref:Q}),typeof x<"u"?_("div",{...E,children:[M("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:M(Ge,{})}),x()]},"creatable-footer"):null]})})}},value:h.value,options:S,multiple:A,readOnly:w.disabled,noOptionsText:_(Ve,{children:[y||"Nenhuma op\xE7\xE3o encontrada",!B&&_(ut,{sx:{justifyContent:"flex-start",padding:`${qe(6)} ${qe(-16)}`,margin:0},fullWidth:!0,onClick:ke,variant:"text",startIcon:M(Pe,{icon:ze}),children:["Adicionar ",`"${L}"`]}),typeof x<"u"&&_(Ve,{children:[M("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:M(Ge,{})}),x()]})]}),isOptionEqualToValue:($,E)=>st($,E),getOptionLabel:g,getOptionKey:p,renderOption:typeof n=="function"?($,E)=>{let Q=n(E),no=p(E);return xt("li",{...$,key:no},_("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[M("span",{children:g(E)}),typeof Q=="string"?M("span",{children:Q}):Q]}))}:void 0,...w,sx:{"& div.MuiInputBase-root":{paddingRight:`${ne(h.value)} !important`},...w.sx},onBlur:$=>{w?.onBlur?.($),f("")},renderInput:$=>M(mt,{placeholder:d,...$,error:!!X,...F,slotProps:{input:{...$.InputProps,...F?.InputProps,inputRef:h.ref,endAdornment:_("div",{className:"endAdornments",children:[$.InputProps.endAdornment,F?.InputProps?.endAdornment??null,Se(h.value)?_("div",{className:"editable",children:[M("div",{className:"divider"}),M("div",{className:"button",onKeyUp:io,children:M(Pe,{icon:ct,size:"24px",removeMargin:!0})})]}):null,lo()&&_("div",{className:"creatable",children:[M("div",{className:"divider"}),M("div",{className:"button",onKeyUp:ke,children:M(Pe,{icon:ze,size:"24px",removeMargin:!0})})]})]})}}})},o)}),M(k,{name:o,control:I})]})}var yt=ie(Ft);import{Stack as gt,TextField as Ct}from"@mui/material";import{AdapterDayjs as vt}from"@mui/x-date-pickers/AdapterDayjs";import{DatePicker as Tt}from"@mui/x-date-pickers/DatePicker";import{LocalizationProvider as St}from"@mui/x-date-pickers/LocalizationProvider";import{ptBR as kt}from"@mui/x-date-pickers/locales/ptBR";import{composeValidators as It,date as Ue}from"@s_mart/rules";import wt from"dayjs/locale/pt-br";import{memo as Lt}from"react";import{useController as At,useFormContext as Rt,useFormState as Dt}from"react-hook-form";import{IconButton as bt,styled as ht}from"@mui/material";import{toRem as K}from"@s_mart/utils";var Pt=e=>{switch(e){case"small":return K(16);default:case"medium":return K(20);case"large":return K(24)}},Vt=e=>{switch(e){case"small":return`${K(2)} ${K(8)}`;default:case"medium":return`${K(6)} ${K(8)}`;case"large":return`${K(10)}`}},_e=ht(bt)`
106
106
  margin: 0px;
107
107
 
108
- padding: ${({size:e})=>gt(e)};
108
+ padding: ${({size:e})=>Vt(e)};
109
109
  border-radius: 0 ${K(4)} ${K(4)} 0;
110
110
 
111
111
  svg {
112
112
  width: ${({size:e})=>Pt(e)} !important;
113
113
  }
114
- `;import{jsx as ce,jsxs as Ot}from"react/jsx-runtime";import{createElement as Mt}from"react";var Bt=({rules:e,name:o,defaultValue:l,shouldUnregister:i,control:s,datePickerProps:P,label:g,required:c,placeholder:S,disabled:x,disableIconError:C,...m})=>{let u=Dt()?.control,a=s??u;if(!a)throw new T("DatePicker");let p=Rt({control:a,name:o}),V=R(p.errors,o),n=P?.format||"DD/MM/YYYY",F=e?It([Ue(n),e]):Ue(n),{field:A}=At({control:a,name:o,rules:F,defaultValue:l,shouldUnregister:i});return ce(St,{dateAdapter:vt,adapterLocale:wt,localeText:kt.components.MuiLocalizationProvider.defaultProps.localeText,children:Ot(Vt,{children:[g&&ce(v,{label:g,required:c}),Mt(Tt,{...P,key:o,value:A.value??null,format:n,onChange:(r,y)=>{A.onChange(r,y),P?.onChange?.(r,y)},disabled:x,slots:{textField:Ct,openPickerButton:r=>ce(_e,{...r,size:m.size})},slotProps:{textField:r=>({variant:"outlined",...r,error:!!V,...m,inputProps:{...r.inputProps,placeholder:S||r.inputProps?.placeholder},InputProps:{...r.InputProps,inputRef:y=>{A.ref(y),typeof r.inputRef=="function"&&r.inputRef(y)}}})}}),ce(k,{name:o,disableIcon:C,control:a})]})})},Et=Lt(Bt);import{FormProvider as $t}from"react-hook-form";import{jsx as He}from"react/jsx-runtime";function Nt({children:e,style:o,onSubmit:l,...i}){return He($t,{...i,children:He("form",{onSubmit:s=>{s.preventDefault(),s.stopPropagation(),l(s)},style:o,children:e})})}var Ve=Nt;import{useEffect as Gt}from"react";import{useForm as zt}from"react-hook-form";import{zodResolver as qt}from"@hookform/resolvers/zod";var _t=({disableDefaultValuesUpdate:e,onSubmit:o,...l})=>{let i=zt({...l,resolver:l.schema&&qt(l.schema)});return Gt(()=>{e||i.reset(l.defaultValues)},[l.defaultValues,i.reset]),{...i,onSubmit:i.handleSubmit(s=>o(s,i))}},Ce=_t;import{jsx as Kt}from"react/jsx-runtime";function Ut({children:e,style:o,...l}){let i=Ce(l);return Kt(Ve,{...i,style:o,children:typeof e=="function"?e(i):e})}var Ht=Ut;import{RadioGroup as Wt,Stack as Yt}from"@mui/material";import{useController as jt,useFormContext as Jt}from"react-hook-form";import{jsx as ve,jsxs as Zt}from"react/jsx-runtime";var Xt=({name:e,rules:o,defaultValue:l,shouldUnregister:i,control:s,label:P,required:g,children:c,orientation:S="row",disableIconError:x,...C})=>{let m=Jt()?.control,u=s??m;if(!u)throw new T("RadioGroup");let{field:a}=jt({control:u,name:e,rules:o,defaultValue:l,shouldUnregister:i});return Zt(Yt,{children:[P&&ve(v,{label:P,required:g}),ve(Wt,{value:a.value||"",name:e,...C,onChange:p=>{C?.onChange?.(p,p.target?.value),a.onChange(p)},style:{display:"flex",flexDirection:S},children:c},e),ve(k,{name:e,disableIcon:x,control:u})]})},Qt=Xt;import{FormControlLabel as er,Grid2 as or,Radio as tr}from"@mui/material";import{jsx as Fe}from"react/jsx-runtime";var rr=({label:e,labelPlacement:o,...l})=>Fe(or,{sx:{display:"flex",flexDirection:"column"},children:Fe(er,{control:Fe(tr,{...l}),label:Fe(v,{label:e}),labelPlacement:o||"end"})}),lr=rr;import{Autocomplete as ir,Divider as Ke,Grid as J,TextField as nr,Tooltip as ar}from"@mui/material";import{LIcon as dr}from"@s_mart/core";import{lineInfoCircle as sr}from"@s_mart/solid-icons";import{colorPalette as pr}from"@s_mart/tokens";import{forwardRef as mr,memo as ur}from"react";import{Controller as fr,useFormContext as cr}from"react-hook-form";import{Fragment as ye,jsx as $,jsxs as oe}from"react/jsx-runtime";import{createElement as We}from"react";var Ye=ur(({name:e,rules:o,defaultValue:l,shouldUnregister:i,label:s,required:P,options:g,textFieldProps:c,noOptionsText:S,footer:x,multiple:C,info:m,placeholder:u,onChange:a,onInputChange:p,disableIconError:V,...n})=>{let F=cr();if(!F)throw new T("Searchable");let A=R(F.formState.errors,e);return $(fr,{control:F.control,name:e,rules:o,defaultValue:l,shouldUnregister:i,render:({field:{onChange:r,value:y,ref:G}})=>oe(J,{sx:{display:"flex",flexDirection:"column"},children:[oe("div",{style:{display:"flex"},children:[s&&$(J,{item:!0,children:$(v,{label:s,required:P})}),m&&$(J,{item:!0,children:$(ar,{title:m,placement:"top",children:$("div",{style:{width:"fit-content"},children:$(dr,{icon:sr,color:"#757575"})})})})]}),$(ir,{onChange:(b,d)=>{r(d),a?.(d,F.getValues())},onInputChange:(b,d,w)=>{w==="input"&&setTimeout(()=>{p?.(d,F.getValues())},0)},slotProps:{...n.slotProps||{},paper:{...(n.slotProps||{}).paper||{},sx:{border:`1px solid ${pr.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}},listbox:{component:mr(function(d,w){return oe(ye,{children:[$("ul",{...d,ref:w}),!!x&&$("div",{...d,children:oe(ye,{children:[$(J,{sx:{px:2,py:1},children:$(Ke,{})}),x]})},"searchable-footer")]})})}},value:y||(C?[]:null),options:g,multiple:C,readOnly:n.disabled,noOptionsText:oe(ye,{children:[S||"Nenhum resultado encontrado",x?oe(ye,{children:[$(J,{sx:{py:1},children:$(Ke,{})}),x]}):null]}),isOptionEqualToValue:(b,d)=>typeof b=="string"&&typeof d=="string"?b===d:typeof b=="object"&&typeof d=="object"?typeof b.value=="object"&&typeof d.value=="object"&&b.key!==void 0&&d.key!==void 0?b.key===d.key:b.value===d.value:!1,renderOption:(b,d)=>typeof d=="object"?We("li",{...b,key:d.key||d.value},oe(J,{container:!0,direction:"column",children:[$(J,{item:!0,children:d.label}),d.afterLabel&&$(J,{item:!0,children:d.afterLabel})]})):We("li",{...b,key:d},d),...n,renderInput:b=>$(nr,{error:!!A,placeholder:u,...b,...c,inputRef:G})},e),$(k,{name:e,disableIcon:V,control:F.control})]})})});Ye.displayName="Searchable";var Fr=Ye;import{Autocomplete as yr,Divider as je,TextField as xr}from"@mui/material";import{colorPalette as br}from"@s_mart/tokens";import{isEqual as hr}from"lodash-es";import{forwardRef as Pr}from"react";import{useController as gr,useFormContext as Vr,useFormState as Cr}from"react-hook-form";import{Fragment as Te,jsx as q,jsxs as te}from"react/jsx-runtime";import{createElement as Sr}from"react";var vr=e=>{let{name:o,rules:l,defaultValue:i,shouldUnregister:s,control:P,label:g,required:c,options:S,textFieldProps:x,noOptionsText:C,footer:m,multiple:u,info:a,placeholder:p,onChange:V,onInputChange:n,getOptionAfterLabel:F,getOptionLabel:A,getOptionKey:r,...y}=e,G=Vr()?.control,b=P??G;if(!b)throw new T("SearchableV2");let d=Cr({control:b,name:o}),w=R(d.errors,o),{field:L}=gr({name:o,control:b,rules:l,defaultValue:i,shouldUnregister:s});return te("div",{style:{display:"flex",flexDirection:"column"},children:[te("div",{style:{display:"flex"},children:[g&&q(v,{label:g,required:c}),a&&q(j,{title:a})]}),q(yr,{onChange:(f,t)=>{L.onChange(t),V?.(t)},onInputChange:(f,t,I)=>{I==="input"&&n?.(t)},value:L.value,options:S,multiple:u,readOnly:y.disabled,slotProps:{...y.slotProps,paper:{...y.slotProps?.paper,sx:{border:`1px solid ${br.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}},listbox:{component:Pr(function(t,I){return te(Te,{children:[q("ul",{...t,ref:I}),typeof m<"u"?te("div",{...t,children:[q("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:q(je,{})}),m()]},"searchable-footer"):null]})})}},noOptionsText:te(Te,{children:[C||"Nenhuma op\xE7\xE3o encontrada",typeof m<"u"?te(Te,{children:[q("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:q(je,{})}),m()]}):null]}),isOptionEqualToValue:(f,t)=>hr(f,t),getOptionLabel:A,getOptionKey:r,renderOption:typeof F=="function"?(f,t)=>{let I=F(t),z=r(t);return Sr("li",{...f,key:z},te("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[q("span",{children:A(t)}),typeof I=="string"?q("span",{children:I}):I]}))}:void 0,...y,renderInput:f=>q(xr,{error:!!w,placeholder:p,...f,...x,inputRef:L.ref})},o),q(k,{name:o,control:b})]})},Tr=ie(vr);import{Divider as kr,Grid as re,MenuItem as Ir,Select as wr,Tooltip as Lr,useTheme as Ar}from"@mui/material";import{IconButton as Dr,LIcon as Je}from"@s_mart/core";import{lineTimes as Rr}from"@s_mart/regular-icons";import{lineInfoCircle as Br}from"@s_mart/solid-icons";import{colorPalette as Er}from"@s_mart/tokens";import{memo as Mr,useState as Or}from"react";import{Controller as $r,useFormContext as Nr}from"react-hook-form";import{Fragment as zr,jsx as N,jsxs as ae}from"react/jsx-runtime";var Xe=Mr(({name:e,rules:o,defaultValue:l,shouldUnregister:i,label:s,required:P,options:g,placeholder:c,clearable:S,disableOnChangeForm:x=!1,multiple:C,info:m,footer:u,onChange:a,disableIconError:p,variant:V="outlined",...n})=>{let F=Nr(),{palette:A}=Ar(),[r,y]=Or(!1);if(!F)throw new T("Select");let G=R(F.formState.errors,e);return N($r,{control:F.control,name:e,rules:o,defaultValue:l,shouldUnregister:i,render:({field:{value:b,onChange:d,ref:w}})=>ae(re,{sx:{display:"flex",flexDirection:"column"},children:[ae("div",{style:{display:"flex"},children:[s&&N(re,{item:!0,children:N(v,{label:s,required:P})}),m&&N(re,{item:!0,children:N(Lr,{title:m,placement:"top",children:N("div",{style:{width:"fit-content"},children:N(Je,{icon:Br,color:"#757575"})})})})]}),ae(wr,{open:r,onOpen:()=>y(!0),onClose:()=>y(!1),displayEmpty:!!c,variant:V,autoComplete:"off",value:b?b||"":C?[]:"",renderValue:L=>{if(L.label)return L.label;if(c)return N("p",{style:{color:A.grey[400]},children:c})},multiple:C,onChange:L=>{!x&&d(L.target.value),a&&a(L.target.value,F.getValues())},error:!!G,size:n.size||"medium",inputRef:w,...n,endAdornment:ae(zr,{children:[n.endAdornment,!!(S&&b)&&N(Dr,{variant:"text",color:"neutral",size:"small",sx:{borderRadius:"50%",position:"absolute",right:"2rem"},style:{padding:0},"aria-label":"Clear",title:"Clear",onClick:()=>{!x&&d(null),a&&a(null,F.getValues())},children:N(Je,{icon:Rr,color:Er.neutral[100],size:"25px",removeMargin:!0})})]}),children:[g?.map((L,f)=>N(Ir,{value:L,children:ae(re,{container:!0,direction:"column",children:[N(re,{item:!0,children:L.label}),L.afterLabel&&N(re,{item:!0,children:L.afterLabel})]})},f)),u&&[N(re,{sx:{px:2,py:1},children:N(kr,{})},"footer-divider"),N("div",{children:u({closeSelect:()=>y(!1)})},"footer-content")]]},e),N(k,{name:e,disableIcon:p,control:F.control})]})})});Xe.displayName="Select";var Gr=Xe;import{useState as Ur}from"react";import{useController as Hr,useFormContext as Kr,useFormState as Wr}from"react-hook-form";import{IconButton as Yr,LIcon as jr}from"@s_mart/core";import{lineTimes as Jr}from"@s_mart/regular-icons";import{colorPalette as Xr}from"@s_mart/tokens";import{Select as Qr,MenuItem as Zr,Divider as el}from"@mui/material";import{colorPalette as qr}from"@s_mart/tokens";import{jsx as _r}from"react/jsx-runtime";var Qe=({value:e,placeholder:o,getOptionLabel:l})=>e===null||e?.length===0?_r("p",{style:{color:qr.neutral[100]},children:o}):l(e);import{Fragment as rl,jsx as U,jsxs as le}from"react/jsx-runtime";var ol=e=>{let{name:o,rules:l,defaultValue:i,shouldUnregister:s,control:P,label:g,required:c,options:S,placeholder:x,clearable:C,info:m,footer:u,onChange:a,variant:p="outlined",getOptionKey:V,getOptionLabel:n,getOptionAfterLabel:F,getOptionIcon:A,...r}=e,y=Kr()?.control,G=P??y,[b,d]=Ur(!1);if(!G)throw new T("SelectV2");let w=Wr({control:G,name:o}),L=R(w.errors,o),{field:f}=Hr({control:G,name:o,rules:l,defaultValue:i,shouldUnregister:s});return le("div",{style:{display:"flex",flexDirection:"column"},children:[le("div",{style:{display:"flex"},children:[g&&U(v,{label:g,required:c}),m&&U(j,{title:m})]}),le(Qr,{open:b,onOpen:()=>d(!0),onClose:()=>d(!1),displayEmpty:!!x,variant:p,autoComplete:"off",value:f.value||null,renderValue:t=>U(Qe,{getOptionLabel:n,placeholder:x,value:t}),onChange:t=>{f.onChange(t.target.value),a?.(t.target.value)},error:!!L,size:r.size||"medium",inputRef:f.ref,...r,endAdornment:le(rl,{children:[r.endAdornment,!!(C&&f.value)&&U(Yr,{variant:"text",color:"neutral",size:"small",sx:{borderRadius:"50%",position:"absolute",right:"2rem"},style:{padding:0},"aria-label":"Limpar",title:"Limpar",onClick:()=>{f.onChange(null),a?.(null)},children:U(jr,{icon:Jr,color:Xr.neutral[100],size:"25px",removeMargin:!0})})]}),children:[S.map(t=>{let I=V(t),z=n(t),X=A?.(t);return U(Zr,{value:I??z,children:le("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[X!==void 0?le("div",{style:{display:"flex",alignItems:"center"},children:[X,z]}):z,U("span",{children:F?.(t)??null})]})},I)}),u!==void 0&&le("div",{children:[U("div",{style:{padding:"8px 16px"},children:U(el,{})},"footer-divider"),U("div",{children:u({closeSelect:()=>d(!1)})},"footer-content")]},"footer")]},o),U(k,{name:o,control:G})]})},tl=ie(ol);import{useController as ll,useFormContext as il}from"react-hook-form";import{Slider as nl}from"@mui/material";import{jsx as sl}from"react/jsx-runtime";var al=({name:e,rules:o,defaultValue:l,shouldUnregister:i,control:s,...P})=>{let g=il()?.control,c=s??g;if(!c)throw new T("Slider");let{field:S}=ll({control:c,name:e,rules:o,defaultValue:l,shouldUnregister:i});return sl(nl,{value:S.value||P?.min||0,onChange:S.onChange,valueLabelDisplay:"auto",...P},e)},dl=al;import{FormControlLabel as pl,Stack as ml,Switch as ul}from"@mui/material";import{useController as fl,useFormContext as cl}from"react-hook-form";import{jsx as xe,jsxs as xl}from"react/jsx-runtime";var Fl=({name:e,rules:o,defaultValue:l,shouldUnregister:i,control:s,label:P,labelPlacement:g,disableIconError:c,onChange:S,...x})=>{let C=cl()?.control,m=s??C;if(!m)throw new T("Switch");let{field:u}=fl({control:m,name:e,rules:o,defaultValue:l,shouldUnregister:i});return xl(ml,{children:[xe(pl,{control:xe(ul,{value:u.value??"",checked:u.value??!1,defaultValue:u.value,onChange:(a,p)=>{u.onChange(a,p),S?.(a,p)},...x},e),label:xe(v,{label:P}),labelPlacement:g||"end"}),xe(k,{name:e,disableIcon:c,control:m})]})},yl=Fl;import{InputAdornment as bl,Stack as hl,TextField as Pl,Tooltip as gl}from"@mui/material";import{LIcon as Ze}from"@s_mart/core";import*as eo from"@s_mart/masks";import{lineEye as Vl,lineEyeSlash as Cl,lineInfoCircle as vl}from"@s_mart/solid-icons";import{useRef as Tl,useState as Sl}from"react";import{useController as kl,useFormContext as Il,useFormState as wl}from"react-hook-form";import{jsx as W,jsxs as oo}from"react/jsx-runtime";var Ll=({name:e,rules:o,defaultValue:l,shouldUnregister:i,control:s,label:P,required:g,mask:c,variant:S="outlined",info:x,parse:C,format:m,onInputChange:u,disableIconError:a,...p})=>{let V=Il()?.control,n=s??V,F=Tl(l||void 0);if(!n)throw new T("TextField");let[A,r]=Sl(!1),y=f=>{let t=f;return t=m?.(f)??f,c?eo?.[c]?.format(t):t},G=f=>{let t=f;return t=C?.(f)??t,c?eo?.[c]?.parse(t,F.current):t},b=f=>{if(!f||c!=="porcentagem"&&c!=="porcentagem0")return;f?.stopPropagation();let t=(f?.target).value;if(t){let I=String(t);if(I.length>0){let z=I.indexOf("%");z>-1&&(f.currentTarget.selectionEnd=z)}}},{field:d}=kl({control:n,name:e,rules:o,defaultValue:l,shouldUnregister:i}),w=wl({control:n,name:e}),L=R(w.errors,e);return oo(hl,{children:[oo("div",{style:{display:"flex"},children:[P&&W("div",{children:W(v,{label:P,required:g})}),x&&W("div",{children:W(gl,{title:x,placement:"top",children:W("div",{style:{width:"fit-content"},children:W(Ze,{icon:vl,color:"#757575"})})})})]}),W(Pl,{variant:S,defaultValue:l,value:y(d.value||(d.value!=0?"":d.value)),onChange:f=>{let t=G(f?.target?.value);d.onChange(t),u?.(t),F.current=f.target.value},error:!!L,...p,type:p.type==="password"?A?"text":"password":p.type,autoComplete:p.autoComplete||"off",slotProps:{input:{onKeyDown:b,inputRef:d.ref,endAdornment:p.type==="password"&&W(bl,{position:"start",onClick:()=>r(!A),style:{cursor:"pointer"},children:W(Ze,{icon:A?Vl:Cl,size:"24px",removeMargin:!0})}),...p.InputProps}}},e),W(k,{name:e,disableIcon:a,control:n})]})},Al=Ll;import{Stack as Ml,TextField as Ol}from"@mui/material";import{AdapterDayjs as $l}from"@mui/x-date-pickers/AdapterDayjs";import{LocalizationProvider as Nl}from"@mui/x-date-pickers/LocalizationProvider";import{TimePicker as Gl}from"@mui/x-date-pickers/TimePicker";import{ptBR as zl}from"@mui/x-date-pickers/locales/ptBR";import{composeValidators as ql,time as ro}from"@s_mart/rules";import _l from"dayjs/locale/pt-br";import{memo as Ul}from"react";import{useController as Hl,useFormContext as Kl,useFormState as Wl}from"react-hook-form";import{styled as Dl}from"@mui/material";import{IconButton as Rl}from"@mui/material";import{toRem as Y}from"@s_mart/utils";var Bl=e=>{switch(e){case"small":return Y(16);case"large":return Y(24);default:return Y(20)}},El=e=>{switch(e){case"small":return`${Y(2)} ${Y(8)}`;case"large":return Y(10);default:return`${Y(6)} ${Y(8)}`}},to=Dl(Rl)`
114
+ `;import{jsx as ce,jsxs as Ot}from"react/jsx-runtime";import{createElement as Mt}from"react";var Bt=({rules:e,name:o,defaultValue:l,shouldUnregister:i,control:s,datePickerProps:P,label:V,required:c,placeholder:S,disabled:x,disableIconError:C,...m})=>{let u=Rt()?.control,a=s??u;if(!a)throw new T("DatePicker");let p=Dt({control:a,name:o}),g=D(p.errors,o),n=P?.format||"DD/MM/YYYY",F=e?It([Ue(n),e]):Ue(n),{field:A}=At({control:a,name:o,rules:F,defaultValue:l,shouldUnregister:i});return ce(St,{dateAdapter:vt,adapterLocale:wt,localeText:kt.components.MuiLocalizationProvider.defaultProps.localeText,children:Ot(gt,{children:[V&&ce(v,{label:V,required:c}),Mt(Tt,{...P,key:o,value:A.value??null,format:n,onChange:(r,y)=>{A.onChange(r,y),P?.onChange?.(r,y)},disabled:x,slots:{textField:Ct,openPickerButton:r=>ce(_e,{...r,size:m.size})},slotProps:{textField:r=>({variant:"outlined",...r,error:!!g,...m,inputProps:{...r.inputProps,placeholder:S||r.inputProps?.placeholder},InputProps:{...r.InputProps,inputRef:y=>{A.ref(y),typeof r.inputRef=="function"&&r.inputRef(y)}}})}}),ce(k,{name:o,disableIcon:C,control:a})]})})},Et=Lt(Bt);import{FormProvider as $t}from"react-hook-form";import{jsx as He}from"react/jsx-runtime";function Nt({children:e,style:o,onSubmit:l,...i}){return He($t,{...i,children:He("form",{onSubmit:s=>{s.preventDefault(),s.stopPropagation(),l(s)},style:o,children:e})})}var ge=Nt;import{useEffect as Gt}from"react";import{useForm as zt}from"react-hook-form";import{zodResolver as qt}from"@hookform/resolvers/zod";var _t=({disableDefaultValuesUpdate:e,onSubmit:o,...l})=>{let i=zt({...l,resolver:l.schema&&qt(l.schema)});return Gt(()=>{e||i.reset(l.defaultValues)},[l.defaultValues,i.reset]),{...i,onSubmit:i.handleSubmit(s=>o(s,i))}},Ce=_t;import{jsx as Kt}from"react/jsx-runtime";function Ut({children:e,style:o,...l}){let i=Ce(l);return Kt(ge,{...i,style:o,children:typeof e=="function"?e(i):e})}var Ht=Ut;import{RadioGroup as Wt,Stack as Yt}from"@mui/material";import{useController as jt,useFormContext as Jt}from"react-hook-form";import{jsx as ve,jsxs as Zt}from"react/jsx-runtime";var Xt=({name:e,rules:o,defaultValue:l,shouldUnregister:i,control:s,label:P,required:V,children:c,orientation:S="row",disableIconError:x,...C})=>{let m=Jt()?.control,u=s??m;if(!u)throw new T("RadioGroup");let{field:a}=jt({control:u,name:e,rules:o,defaultValue:l,shouldUnregister:i});return Zt(Yt,{children:[P&&ve(v,{label:P,required:V}),ve(Wt,{value:a.value||"",name:e,...C,onChange:p=>{C?.onChange?.(p,p.target?.value),a.onChange(p)},style:{display:"flex",flexDirection:S},children:c},e),ve(k,{name:e,disableIcon:x,control:u})]})},Qt=Xt;import{FormControlLabel as er,Grid2 as or,Radio as tr}from"@mui/material";import{jsx as Fe}from"react/jsx-runtime";var rr=({label:e,labelPlacement:o,...l})=>Fe(or,{sx:{display:"flex",flexDirection:"column"},children:Fe(er,{control:Fe(tr,{...l}),label:Fe(v,{label:e}),labelPlacement:o||"end"})}),lr=rr;import{Autocomplete as ir,Divider as Ke,Grid as J,TextField as nr,Tooltip as ar}from"@mui/material";import{LIcon as dr}from"@s_mart/core";import{lineInfoCircle as sr}from"@s_mart/solid-icons";import{colorPalette as pr}from"@s_mart/tokens";import{forwardRef as mr,memo as ur}from"react";import{Controller as fr,useFormContext as cr}from"react-hook-form";import{Fragment as ye,jsx as O,jsxs as oe}from"react/jsx-runtime";import{createElement as We}from"react";var Ye=ur(({name:e,rules:o,defaultValue:l,shouldUnregister:i,label:s,required:P,options:V,textFieldProps:c,noOptionsText:S,footer:x,multiple:C,info:m,placeholder:u,onChange:a,onInputChange:p,disableIconError:g,...n})=>{let F=cr();if(!F)throw new T("Searchable");let A=D(F.formState.errors,e);return O(fr,{control:F.control,name:e,rules:o,defaultValue:l,shouldUnregister:i,render:({field:{onChange:r,value:y,ref:G}})=>oe(J,{sx:{display:"flex",flexDirection:"column"},children:[oe("div",{style:{display:"flex"},children:[s&&O(J,{item:!0,children:O(v,{label:s,required:P})}),m&&O(J,{item:!0,children:O(ar,{title:m,placement:"top",children:O("div",{style:{width:"fit-content"},children:O(dr,{icon:sr,color:"#757575"})})})})]}),O(ir,{onChange:(b,d)=>{r(d),a?.(d,F.getValues())},onInputChange:(b,d,w)=>{w==="input"&&setTimeout(()=>{p?.(d,F.getValues())},0)},slotProps:{...n.slotProps||{},paper:{...(n.slotProps||{}).paper||{},sx:{border:`1px solid ${pr.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}},listbox:{component:mr(function(d,w){return oe(ye,{children:[O("ul",{...d,ref:w}),!!x&&O("div",{...d,children:oe(ye,{children:[O(J,{sx:{px:2,py:1},children:O(Ke,{})}),x]})},"searchable-footer")]})})}},value:y||(C?[]:null),options:V,multiple:C,readOnly:n.disabled,noOptionsText:oe(ye,{children:[S||"Nenhum resultado encontrado",x?oe(ye,{children:[O(J,{sx:{py:1},children:O(Ke,{})}),x]}):null]}),isOptionEqualToValue:(b,d)=>typeof b=="string"&&typeof d=="string"?b===d:typeof b=="object"&&typeof d=="object"?typeof b.value=="object"&&typeof d.value=="object"&&b.key!==void 0&&d.key!==void 0?b.key===d.key:b.value===d.value:!1,renderOption:(b,d)=>typeof d=="object"?We("li",{...b,key:d.key||d.value},oe(J,{container:!0,direction:"column",children:[O(J,{item:!0,children:d.label}),d.afterLabel&&O(J,{item:!0,children:d.afterLabel})]})):We("li",{...b,key:d},d),...n,renderInput:b=>O(nr,{error:!!A,placeholder:u,...b,...c,inputRef:G})},e),O(k,{name:e,disableIcon:g,control:F.control})]})})});Ye.displayName="Searchable";var Fr=Ye;import{Autocomplete as yr,Divider as je,TextField as xr}from"@mui/material";import{colorPalette as br}from"@s_mart/tokens";import{isEqual as hr}from"lodash-es";import{forwardRef as Pr}from"react";import{useController as Vr,useFormContext as gr,useFormState as Cr}from"react-hook-form";import{Fragment as Te,jsx as q,jsxs as te}from"react/jsx-runtime";import{createElement as Sr}from"react";var vr=e=>{let{name:o,rules:l,defaultValue:i,shouldUnregister:s,control:P,label:V,required:c,options:S,textFieldProps:x,noOptionsText:C,footer:m,multiple:u,info:a,placeholder:p,onChange:g,onInputChange:n,getOptionAfterLabel:F,getOptionLabel:A,getOptionKey:r,...y}=e,G=gr()?.control,b=P??G;if(!b)throw new T("SearchableV2");let d=Cr({control:b,name:o}),w=D(d.errors,o),{field:L}=Vr({name:o,control:b,rules:l,defaultValue:i,shouldUnregister:s});return te("div",{style:{display:"flex",flexDirection:"column"},children:[te("div",{style:{display:"flex"},children:[V&&q(v,{label:V,required:c}),a&&q(j,{title:a})]}),q(yr,{onChange:(f,t)=>{L.onChange(t),g?.(t)},onInputChange:(f,t,I)=>{I==="input"&&n?.(t)},value:L.value,options:S,multiple:u,readOnly:y.disabled,slotProps:{...y.slotProps,paper:{...y.slotProps?.paper,sx:{border:`1px solid ${br.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}},listbox:{component:Pr(function(t,I){return te(Te,{children:[q("ul",{...t,ref:I}),typeof m<"u"?te("div",{...t,children:[q("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:q(je,{})}),m()]},"searchable-footer"):null]})})}},noOptionsText:te(Te,{children:[C||"Nenhuma op\xE7\xE3o encontrada",typeof m<"u"?te(Te,{children:[q("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:q(je,{})}),m()]}):null]}),isOptionEqualToValue:(f,t)=>hr(f,t),getOptionLabel:A,getOptionKey:r,renderOption:typeof F=="function"?(f,t)=>{let I=F(t),z=r(t);return Sr("li",{...f,key:z},te("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[q("span",{children:A(t)}),typeof I=="string"?q("span",{children:I}):I]}))}:void 0,...y,renderInput:f=>q(xr,{error:!!w,placeholder:p,...f,...x,inputRef:L.ref})},o),q(k,{name:o,control:b})]})},Tr=ie(vr);import{Divider as kr,Grid as re,MenuItem as Ir,Select as wr,Tooltip as Lr,useTheme as Ar}from"@mui/material";import{IconButton as Rr,LIcon as Je}from"@s_mart/core";import{lineTimes as Dr}from"@s_mart/regular-icons";import{lineInfoCircle as Br}from"@s_mart/solid-icons";import{colorPalette as Er}from"@s_mart/tokens";import{memo as Mr,useState as Or}from"react";import{Controller as $r,useFormContext as Nr}from"react-hook-form";import{Fragment as zr,jsx as N,jsxs as ae}from"react/jsx-runtime";var Xe=Mr(({name:e,rules:o,defaultValue:l,shouldUnregister:i,label:s,required:P,options:V,placeholder:c,clearable:S,disableOnChangeForm:x=!1,multiple:C,info:m,footer:u,onChange:a,disableIconError:p,variant:g="outlined",...n})=>{let F=Nr(),{palette:A}=Ar(),[r,y]=Or(!1);if(!F)throw new T("Select");let G=D(F.formState.errors,e);return N($r,{control:F.control,name:e,rules:o,defaultValue:l,shouldUnregister:i,render:({field:{value:b,onChange:d,ref:w}})=>ae(re,{sx:{display:"flex",flexDirection:"column"},children:[ae("div",{style:{display:"flex"},children:[s&&N(re,{item:!0,children:N(v,{label:s,required:P})}),m&&N(re,{item:!0,children:N(Lr,{title:m,placement:"top",children:N("div",{style:{width:"fit-content"},children:N(Je,{icon:Br,color:"#757575"})})})})]}),ae(wr,{open:r,onOpen:()=>y(!0),onClose:()=>y(!1),displayEmpty:!!c,variant:g,autoComplete:"off",value:b?b||"":C?[]:"",renderValue:L=>{if(L.label)return L.label;if(c)return N("p",{style:{color:A.grey[400]},children:c})},multiple:C,onChange:L=>{!x&&d(L.target.value),a&&a(L.target.value,F.getValues())},error:!!G,size:n.size||"medium",inputRef:w,...n,endAdornment:ae(zr,{children:[n.endAdornment,!!(S&&b)&&N(Rr,{variant:"text",color:"neutral",size:"small",sx:{borderRadius:"50%",position:"absolute",right:"2rem"},style:{padding:0},"aria-label":"Clear",title:"Clear",onClick:()=>{!x&&d(null),a&&a(null,F.getValues())},children:N(Je,{icon:Dr,color:Er.neutral[100],size:"25px",removeMargin:!0})})]}),children:[V?.map((L,f)=>N(Ir,{value:L,children:ae(re,{container:!0,direction:"column",children:[N(re,{item:!0,children:L.label}),L.afterLabel&&N(re,{item:!0,children:L.afterLabel})]})},f)),u&&[N(re,{sx:{px:2,py:1},children:N(kr,{})},"footer-divider"),N("div",{children:u({closeSelect:()=>y(!1)})},"footer-content")]]},e),N(k,{name:e,disableIcon:p,control:F.control})]})})});Xe.displayName="Select";var Gr=Xe;import{useState as Ur}from"react";import{useController as Hr,useFormContext as Kr,useFormState as Wr}from"react-hook-form";import{IconButton as Yr,LIcon as jr}from"@s_mart/core";import{lineTimes as Jr}from"@s_mart/regular-icons";import{colorPalette as Xr}from"@s_mart/tokens";import{Select as Qr,MenuItem as Zr,Divider as el}from"@mui/material";import{colorPalette as qr}from"@s_mart/tokens";import{jsx as _r}from"react/jsx-runtime";var Qe=({value:e,placeholder:o,getOptionLabel:l})=>e===null||e?.length===0?_r("p",{style:{color:qr.neutral[100]},children:o}):l(e);import{Fragment as rl,jsx as U,jsxs as le}from"react/jsx-runtime";var ol=e=>{let{name:o,rules:l,defaultValue:i,shouldUnregister:s,control:P,label:V,required:c,options:S,placeholder:x,clearable:C,info:m,footer:u,onChange:a,variant:p="outlined",getOptionKey:g,getOptionLabel:n,getOptionAfterLabel:F,getOptionIcon:A,...r}=e,y=Kr()?.control,G=P??y,[b,d]=Ur(!1);if(!G)throw new T("SelectV2");let w=Wr({control:G,name:o}),L=D(w.errors,o),{field:f}=Hr({control:G,name:o,rules:l,defaultValue:i,shouldUnregister:s});return le("div",{style:{display:"flex",flexDirection:"column"},children:[le("div",{style:{display:"flex"},children:[V&&U(v,{label:V,required:c}),m&&U(j,{title:m})]}),le(Qr,{open:b,onOpen:()=>d(!0),onClose:()=>d(!1),displayEmpty:!!x,variant:p,autoComplete:"off",value:f.value||null,renderValue:t=>U(Qe,{getOptionLabel:n,placeholder:x,value:t}),onChange:t=>{f.onChange(t.target.value),a?.(t.target.value)},error:!!L,size:r.size||"medium",inputRef:f.ref,...r,endAdornment:le(rl,{children:[r.endAdornment,!!(C&&f.value)&&U(Yr,{variant:"text",color:"neutral",size:"small",sx:{borderRadius:"50%",position:"absolute",right:"2rem"},style:{padding:0},"aria-label":"Limpar",title:"Limpar",onClick:()=>{f.onChange(null),a?.(null)},children:U(jr,{icon:Jr,color:Xr.neutral[100],size:"25px",removeMargin:!0})})]}),children:[S.map(t=>{let I=g(t),z=n(t),X=A?.(t);return U(Zr,{value:I??z,children:le("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[X!==void 0?le("div",{style:{display:"flex",alignItems:"center"},children:[X,z]}):z,U("span",{children:F?.(t)??null})]})},I)}),u!==void 0&&le("div",{children:[U("div",{style:{padding:"8px 16px"},children:U(el,{})},"footer-divider"),U("div",{children:u({closeSelect:()=>d(!1)})},"footer-content")]},"footer")]},o),U(k,{name:o,control:G})]})},tl=ie(ol);import{useController as ll,useFormContext as il}from"react-hook-form";import{Slider as nl}from"@mui/material";import{jsx as sl}from"react/jsx-runtime";var al=({name:e,rules:o,defaultValue:l,shouldUnregister:i,control:s,...P})=>{let V=il()?.control,c=s??V;if(!c)throw new T("Slider");let{field:S}=ll({control:c,name:e,rules:o,defaultValue:l,shouldUnregister:i});return sl(nl,{value:S.value||P?.min||0,onChange:S.onChange,valueLabelDisplay:"auto",...P},e)},dl=al;import{FormControlLabel as pl,Stack as ml,Switch as ul}from"@mui/material";import{useController as fl,useFormContext as cl}from"react-hook-form";import{jsx as xe,jsxs as xl}from"react/jsx-runtime";var Fl=({name:e,rules:o,defaultValue:l,shouldUnregister:i,control:s,label:P,labelPlacement:V,disableIconError:c,onChange:S,...x})=>{let C=cl()?.control,m=s??C;if(!m)throw new T("Switch");let{field:u}=fl({control:m,name:e,rules:o,defaultValue:l,shouldUnregister:i});return xl(ml,{children:[xe(pl,{control:xe(ul,{value:u.value??"",checked:u.value??!1,defaultValue:u.value,onChange:(a,p)=>{u.onChange(a,p),S?.(a,p)},...x},e),label:xe(v,{label:P}),labelPlacement:V||"end"}),xe(k,{name:e,disableIcon:c,control:m})]})},yl=Fl;import{InputAdornment as bl,Stack as hl,TextField as Pl,Tooltip as Vl}from"@mui/material";import{LIcon as Ze}from"@s_mart/core";import*as eo from"@s_mart/masks";import{lineEye as gl,lineEyeSlash as Cl,lineInfoCircle as vl}from"@s_mart/solid-icons";import{useRef as Tl,useState as Sl}from"react";import{useController as kl,useFormContext as Il,useFormState as wl}from"react-hook-form";import{jsx as W,jsxs as oo}from"react/jsx-runtime";var Ll=({name:e,rules:o,defaultValue:l,shouldUnregister:i,control:s,label:P,required:V,mask:c,variant:S="outlined",info:x,parse:C,format:m,onInputChange:u,disableIconError:a,...p})=>{let g=Il()?.control,n=s??g,F=Tl(l||void 0);if(!n)throw new T("TextField");let[A,r]=Sl(!1),y=f=>{let t=f;return t=m?.(f)??f,c?eo?.[c]?.format(t):t},G=f=>{let t=f;return t=C?.(f)??t,c?eo?.[c]?.parse(t,F.current):t},b=f=>{if(!f||c!=="porcentagem"&&c!=="porcentagem0")return;f?.stopPropagation();let t=(f?.target).value;if(t){let I=String(t);if(I.length>0){let z=I.indexOf("%");z>-1&&(f.currentTarget.selectionEnd=z)}}},{field:d}=kl({control:n,name:e,rules:o,defaultValue:l,shouldUnregister:i}),w=wl({control:n,name:e}),L=D(w.errors,e);return oo(hl,{children:[oo("div",{style:{display:"flex"},children:[P&&W("div",{children:W(v,{label:P,required:V})}),x&&W("div",{children:W(Vl,{title:x,placement:"top",children:W("div",{style:{width:"fit-content"},children:W(Ze,{icon:vl,color:"#757575"})})})})]}),W(Pl,{variant:S,defaultValue:l,value:y(d.value||(d.value!=0?"":d.value)),onChange:f=>{let t=G(f?.target?.value);d.onChange(t),u?.(t),F.current=f.target.value},error:!!L,...p,type:p.type==="password"?A?"text":"password":p.type,autoComplete:p.autoComplete||"off",slotProps:{input:{onKeyDown:b,inputRef:d.ref,endAdornment:p.type==="password"&&W(bl,{position:"start",onClick:()=>r(!A),style:{cursor:"pointer"},children:W(Ze,{icon:A?gl:Cl,size:"24px",removeMargin:!0})}),...p.InputProps}}},e),W(k,{name:e,disableIcon:a,control:n})]})},Al=Ll;import{Stack as Ml,TextField as Ol}from"@mui/material";import{AdapterDayjs as $l}from"@mui/x-date-pickers/AdapterDayjs";import{LocalizationProvider as Nl}from"@mui/x-date-pickers/LocalizationProvider";import{TimePicker as Gl}from"@mui/x-date-pickers/TimePicker";import{ptBR as zl}from"@mui/x-date-pickers/locales/ptBR";import{composeValidators as ql,time as ro}from"@s_mart/rules";import _l from"dayjs/locale/pt-br";import{memo as Ul}from"react";import{useController as Hl,useFormContext as Kl,useFormState as Wl}from"react-hook-form";import{styled as Rl}from"@mui/material";import{IconButton as Dl}from"@mui/material";import{toRem as Y}from"@s_mart/utils";var Bl=e=>{switch(e){case"small":return Y(16);case"large":return Y(24);default:return Y(20)}},El=e=>{switch(e){case"small":return`${Y(2)} ${Y(8)}`;case"large":return Y(10);default:return`${Y(6)} ${Y(8)}`}},to=Rl(Dl)`
115
115
  margin: 0px;
116
116
 
117
117
  padding: ${({size:e})=>El(e)};
@@ -120,4 +120,4 @@ import{Autocomplete as Fo,Grid as se,TextField as yo}from"@mui/material";import{
120
120
  svg {
121
121
  width: ${({size:e})=>Bl(e)} !important;
122
122
  }
123
- `;import{jsx as de,jsxs as Jl}from"react/jsx-runtime";var Yl=({rules:e,defaultValue:o,shouldUnregister:l,name:i,control:s,required:P,label:g,timePickerProps:c,placeholder:S,disabled:x,disableIconError:C,...m})=>{let u=Kl()?.control,a=s??u;if(!a)throw new T("TimePicker");let p=Wl({control:a,name:i}),V=R(p.errors,i),n=c?.format||"HH:mm",F=e?ql([ro(n),e]):ro(n),{field:A}=Hl({control:a,name:i,rules:F,defaultValue:o,shouldUnregister:l});return de(Nl,{dateAdapter:$l,adapterLocale:_l,localeText:zl.components.MuiLocalizationProvider.defaultProps.localeText,children:Jl(Ml,{children:[g&&de(v,{label:g,required:P}),de(Gl,{ampm:!1,format:n,value:A.value??null,disabled:x,...c,onChange:(r,y)=>{A.onChange(r,y),c?.onChange?.(r,y)},slots:{textField:Ol,openPickerButton:r=>de(to,{...r,size:m.size})},slotProps:{textField:r=>({variant:"outlined",...r,error:!!V,...m,inputProps:{...r.inputProps,placeholder:S||r.inputProps?.placeholder},InputProps:{...r.InputProps,inputRef:y=>{A.ref(y),typeof r.inputRef=="function"&&r.inputRef(y)}}})}},i),de(k,{name:i,disableIcon:C,control:a})]})})},jl=Ul(Yl);export{Vo as Autocomplete,wo as Checkbox,Wo as Creatable,yt as CreatableV2,Et as DatePicker,k as FieldError,j as FieldInfo,v as FieldLabel,Ht as Form,Ve as FormProvider,lr as RadioButton,Qt as RadioGroup,Fr as Searchable,Tr as SearchableV2,Gr as Select,tl as SelectV2,dl as Slider,yl as Switch,Al as TextField,jl as TimePicker,Ce as useForm};
123
+ `;import{jsx as de,jsxs as Jl}from"react/jsx-runtime";var Yl=({rules:e,defaultValue:o,shouldUnregister:l,name:i,control:s,required:P,label:V,timePickerProps:c,placeholder:S,disabled:x,disableIconError:C,...m})=>{let u=Kl()?.control,a=s??u;if(!a)throw new T("TimePicker");let p=Wl({control:a,name:i}),g=D(p.errors,i),n=c?.format||"HH:mm",F=e?ql([ro(n),e]):ro(n),{field:A}=Hl({control:a,name:i,rules:F,defaultValue:o,shouldUnregister:l});return de(Nl,{dateAdapter:$l,adapterLocale:_l,localeText:zl.components.MuiLocalizationProvider.defaultProps.localeText,children:Jl(Ml,{children:[V&&de(v,{label:V,required:P}),de(Gl,{ampm:!1,format:n,value:A.value??null,disabled:x,...c,onChange:(r,y)=>{A.onChange(r,y),c?.onChange?.(r,y)},slots:{textField:Ol,openPickerButton:r=>de(to,{...r,size:m.size})},slotProps:{textField:r=>({variant:"outlined",...r,error:!!g,...m,inputProps:{...r.inputProps,placeholder:S||r.inputProps?.placeholder},InputProps:{...r.InputProps,inputRef:y=>{A.ref(y),typeof r.inputRef=="function"&&r.inputRef(y)}}})}},i),de(k,{name:i,disableIcon:C,control:a})]})})},jl=Ul(Yl);export{go as Autocomplete,wo as Checkbox,Wo as Creatable,yt as CreatableV2,Et as DatePicker,k as FieldError,j as FieldInfo,v as FieldLabel,Ht as Form,ge as FormProvider,lr as RadioButton,Qt as RadioGroup,Fr as Searchable,Tr as SearchableV2,Gr as Select,tl as SelectV2,dl as Slider,yl as Switch,Al as TextField,jl as TimePicker,Ce as useForm};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@s_mart/form",
3
- "version": "9.2.0-beta.5",
3
+ "version": "9.2.0-beta.7",
4
4
  "main": "./dist/index.mjs",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.mts",
@@ -32,12 +32,12 @@
32
32
  "react-hook-form": "^7.51.0",
33
33
  "typescript": ">=5.4.2",
34
34
  "zod": "^3.22.4",
35
- "@s_mart/core": "9.1.5-beta.3",
36
35
  "@s_mart/masks": "5.2.0",
37
36
  "@s_mart/rules": "5.1.2-beta.0",
38
37
  "@s_mart/tokens": "5.1.1",
39
38
  "@s_mart/typed": "7.2.2",
40
- "@s_mart/utils": "5.3.4"
39
+ "@s_mart/utils": "5.3.4",
40
+ "@s_mart/core": "9.1.5-beta.3"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@emotion/styled": "^11.13.0",