@s_mart/form 10.2.9 → 10.3.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
@@ -1,5 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { CheckboxProps as CheckboxProps$1, AutocompleteProps, TextFieldProps as TextFieldProps$1, AutocompleteValue, RadioGroupProps as RadioGroupProps$1, RadioProps as RadioProps$1, AutocompleteFreeSoloValueMapping, SelectProps, SliderProps as SliderProps$1, SwitchProps as SwitchProps$1 } from '@mui/material';
2
+ import { CheckboxProps as CheckboxProps$1, AutocompleteProps, TextFieldProps as TextFieldProps$1, AutocompleteValue, AutocompleteFreeSoloValueMapping, RadioGroupProps as RadioGroupProps$1, RadioProps as RadioProps$1, SelectProps, SliderProps as SliderProps$1, SwitchProps as SwitchProps$1 } from '@mui/material';
3
3
  import * as react_hook_form from 'react-hook-form';
4
4
  import { UseControllerProps, FieldValues, FieldPath, Control, UseFormProps, UseFormReturn, FormProviderProps, FieldPathValue } from 'react-hook-form';
5
5
  import { WithRequired } from '@s_mart/typed';
@@ -95,6 +95,14 @@ type CreatableV2Props<FieldValue, Multiple extends boolean | undefined = undefin
95
95
  * Componente renderizado embaixo da option da listagem
96
96
  */
97
97
  getOptionAfterLabel?: (option: FieldValue) => string | React.ReactNode;
98
+ /**
99
+ * Usado para montar a label do valor selecionado no campo
100
+ *
101
+ * Funciona apenas junto com `getOptionAfterLabel`
102
+ *
103
+ * Quando não informado é usado o `getOptionLabel`
104
+ */
105
+ getInputValueLabel?: (option: FieldValue | AutocompleteFreeSoloValueMapping<FreeSolo>) => string;
98
106
  };
99
107
 
100
108
  declare function CreatableV2<FieldValue, Multiple extends boolean | undefined = undefined, DisableClearable extends boolean | undefined = undefined, FreeSolo extends boolean | undefined = undefined>(props: CreatableV2Props<FieldValue, Multiple, DisableClearable, FreeSolo>): react_jsx_runtime.JSX.Element;
@@ -312,6 +320,14 @@ type SearchableV2Props<FieldValue, Multiple extends boolean | undefined = undefi
312
320
  * Componente renderizado embaixo da option da listagem
313
321
  */
314
322
  getOptionAfterLabel?: (option: FieldValue | AutocompleteFreeSoloValueMapping<FreeSolo>) => string | React.ReactNode;
323
+ /**
324
+ * Usado para montar a label do valor selecionado no campo
325
+ *
326
+ * Funciona apenas junto com `getOptionAfterLabel`
327
+ *
328
+ * Quando não informado é usado o `getOptionLabel`
329
+ */
330
+ getInputValueLabel?: (option: FieldValue | AutocompleteFreeSoloValueMapping<FreeSolo>) => string;
315
331
  };
316
332
 
317
333
  declare const _default$3: <FieldValue, Multiple extends boolean | undefined = undefined, DisableClearable extends boolean | undefined = undefined, FreeSolo extends boolean | undefined = undefined>(props: SearchableV2Props<FieldValue, Multiple, DisableClearable, FreeSolo>) => react_jsx_runtime.JSX.Element;
@@ -364,6 +380,14 @@ type SelectV2Props<FieldValue extends FieldValues | string | number> = Omit<Sele
364
380
  * Componente renderizado embaixo da option da listagem
365
381
  */
366
382
  getOptionAfterLabel?: (option: FieldValue) => string | React.ReactNode;
383
+ /**
384
+ * Usado para montar a label do valor selecionado no campo
385
+ *
386
+ * Funciona apenas junto com `getOptionAfterLabel`
387
+ *
388
+ * Quando não informado é usado o `getOptionLabel`
389
+ */
390
+ getInputValueLabel?: (option: FieldValue) => string;
367
391
  /**
368
392
  * Ícone renderizado ao lado da label
369
393
  */
package/dist/index.mjs CHANGED
@@ -1,15 +1,15 @@
1
- import{useController as _e,useFormContext as Ke}from"react-hook-form";import{Checkbox as We,FormControlLabel as Ye}from"@mui/material";import{Indicator as Oe}from"@s_mart/core";import{useFormState as $e}from"react-hook-form";var L=(e,o)=>o.replace(/[[\]]/g,"").split(".").reduce((l,a)=>l?.[a],e);import{jsx as qe}from"react/jsx-runtime";var ze=({name:e,disableIcon:o,control:t})=>{let l=$e({control:t,name:e}),a=L(l?.errors,e);return a?qe(Oe,{severity:"error",icon:o?!1:void 0,children:a?.message}):null},v=ze;import{Typography as me}from"@mui/material";import{toRem as He}from"@s_mart/utils";import{jsx as ue,jsxs as Ne}from"react/jsx-runtime";var Ge=({label:e,required:o,regular:t})=>Ne("span",{style:{display:"flex",alignItems:"center",gap:He(2)},children:[ue(me,{variant:"caption",style:{display:"flex",alignItems:"center"},sx:{fontWeight:t?400:700},children:e}),o&&ue(me,{variant:"caption",color:"error",sx:{fontWeight:900},children:"*"})]}),x=Ge;var P=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{memo as Ue}from"react";var w=Ue;import{jsx as Q,jsxs as Qe}from"react/jsx-runtime";var Je=({name:e,rules:o,defaultValue:t,shouldUnregister:l,control:a,label:f,labelPlacement:c,required:m,disableIconError:h,onChange:i,...V})=>{let p=Ke()?.control,d=a??p;if(!d)throw new P("Checkbox");let{field:s}=_e({control:d,name:e,rules:o,defaultValue:t,shouldUnregister:l});return Qe("span",{children:[Q(Ye,{control:Q(We,{checked:!!s.value,value:s.value??"",defaultValue:s.value,onChange:(n,S)=>{s.onChange(n,S),i?.(n,S)},...V},e),label:Q(x,{label:f,required:m,regular:!0}),labelPlacement:c||"end"}),Q(v,{name:e,disableIcon:h,control:d})]})},Xe=w(Je);import{forwardRef as io,useCallback as X,useState as no}from"react";import{useController as ao,useFormContext as so,useFormState as po}from"react-hook-form";import mo from"lodash-es/isObject";import uo from"lodash-es/isEmpty";import fo from"lodash-es/isEqual";import{Autocomplete as co,TextField as Fo,Divider as Fe,Button as yo,IconButton as ye}from"@mui/material";import{LIcon as te}from"@s_mart/core";import{linePlus as xe,linePen as xo}from"@s_mart/solid-icons";import{toRem as Pe}from"@s_mart/utils";import{css as Ze,styled as je}from"@mui/material";import{toRem as eo}from"@s_mart/utils";var fe=Ze`
1
+ import{useController as Ke,useFormContext as We}from"react-hook-form";import{Checkbox as Ye,FormControlLabel as Je}from"@mui/material";import{Indicator as $e}from"@s_mart/core";import{useFormState as ze}from"react-hook-form";var w=(e,o)=>o.replace(/[[\]]/g,"").split(".").reduce((r,i)=>r?.[i],e);import{jsx as He}from"react/jsx-runtime";var qe=({name:e,disableIcon:o,control:t})=>{let r=ze({control:t,name:e}),i=w(r?.errors,e);return i?He($e,{severity:"error",icon:o?!1:void 0,children:i?.message}):null},v=qe;import{Typography as ue}from"@mui/material";import{toRem as Ge}from"@s_mart/utils";import{jsx as fe,jsxs as Ue}from"react/jsx-runtime";var Ne=({label:e,required:o,regular:t})=>Ue("span",{style:{display:"flex",alignItems:"center",gap:Ge(2)},children:[fe(ue,{variant:"caption",style:{display:"flex",alignItems:"center"},sx:{fontWeight:t?400:700},children:e}),o&&fe(ue,{variant:"caption",color:"error",sx:{fontWeight:900},children:"*"})]}),x=Ne;var P=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{memo as _e}from"react";var R=_e;import{jsx as Z,jsxs as Ze}from"react/jsx-runtime";var Xe=({name:e,rules:o,defaultValue:t,shouldUnregister:r,control:i,label:F,labelPlacement:y,required:u,disableIconError:h,onChange:l,...V})=>{let s=We()?.control,d=i??s;if(!d)throw new P("Checkbox");let{field:a}=Ke({control:d,name:e,rules:o,defaultValue:t,shouldUnregister:r});return Ze("span",{children:[Z(Je,{control:Z(Ye,{checked:!!a.value,value:a.value??"",defaultValue:a.value,onChange:(n,I)=>{a.onChange(n,I),l?.(n,I)},...V},e),label:Z(x,{label:F,required:u,regular:!0}),labelPlacement:y||"end"}),Z(v,{name:e,disableIcon:h,control:d})]})},Qe=R(Xe);import{forwardRef as io,useCallback as Q,useState as ao}from"react";import{useController as so,useFormContext as po,useFormState as mo}from"react-hook-form";import uo from"lodash-es/isObject";import fo from"lodash-es/isEmpty";import co from"lodash-es/isEqual";import{Autocomplete as Fo,TextField as yo,Divider as ye,Button as xo,IconButton as xe}from"@mui/material";import{LIcon as re}from"@s_mart/core";import{linePlus as Pe,linePen as Po}from"@s_mart/solid-icons";import{toRem as he}from"@s_mart/utils";import{css as je,styled as eo}from"@mui/material";import{toRem as oo}from"@s_mart/utils";var ce=je`
2
2
  display: flex;
3
3
  align-items: center;
4
4
  justify-content: center;
5
- `,ce=je("div")`
5
+ `,Fe=eo("div")`
6
6
  display: flex;
7
7
 
8
8
  div.endAdornments {
9
9
  position: absolute;
10
10
  right: 0;
11
11
 
12
- ${fe}
12
+ ${ce}
13
13
  }
14
14
 
15
15
  .MuiAutocomplete-endAdornment {
@@ -23,30 +23,30 @@ import{useController as _e,useFormContext as Ke}from"react-hook-form";import{Che
23
23
 
24
24
  .creatable,
25
25
  .editable {
26
- ${fe}
26
+ ${ce}
27
27
 
28
28
  .divider {
29
29
  width: 1px;
30
- height: ${eo(20)};
30
+ height: ${oo(20)};
31
31
  background-color: ${({theme:e})=>e.palette.grey[400]};
32
32
  }
33
33
  }
34
- `;import{Tooltip as oo}from"@mui/material";import{LIcon as to}from"@s_mart/core";import{lineInfoCircle as ro}from"@s_mart/solid-icons";import{jsx as oe}from"react/jsx-runtime";var lo=({title:e})=>oe(oo,{title:e,placement:"top",children:oe("div",{style:{width:"fit-content"},children:oe(to,{icon:ro,color:"#757575"})})}),_=lo;import{Fragment as re,jsx as C,jsxs as D}from"react/jsx-runtime";import{createElement as bo}from"react";function Po(e){let{name:o,rules:t,defaultValue:l,shouldUnregister:a,control:f,label:c,required:m,options:h,footer:i,showCreatableButton:V=!0,showEditableButton:p,onEditOption:d,onCreateOption:s,getOptionKey:n,getOptionLabel:S,getOptionAfterLabel:F,multiple:k,info:I,noOptionsText:O="Nenhuma op\xE7\xE3o encontrada",onChange:$,onInputChange:M,placeholder:z,...y}=e,[N,R]=no(""),u=so()?.control,r=f??u;if(!r)throw new P("CreatableV2");let b=po({control:r,name:o}),E=L(b.errors,o),K=!V||y.disabled,{field:U}=ao({name:o,control:r,rules:t,defaultValue:l,shouldUnregister:a}),Ee=T=>{let g=0;return e.slotProps?.textField?.slotProps?.input||(g+=2.5),K||(g+=2.56,pe(T)&&(g+=2.56)),!y.disableClearable&&!y.disabled&&(g+=1.3),`${g}rem`},pe=T=>y.disabled?!1:p&&mo(T)&&!uo(T),Le=()=>y.disabled?!1:V,de=X(()=>{typeof s<"u"&&(s(N),R(""))},[N,s]),we=X(()=>{d?.(U.value)},[U.value,d]),Re=X((T,g,W)=>{W==="input"&&(R(g),M?.(g))},[M]),Be=X((T,g)=>{R(""),U.onChange(g),$?.(g)},[U.onChange,$]),Me=X(T=>{y?.onBlur?.(T),R("")},[y?.onBlur]),De=U.value?U.value:k?[]:null;return D("div",{style:{display:"flex",flexDirection:"column"},children:[D("div",{style:{display:"flex"},children:[c&&C(x,{label:c,required:m}),I&&C(_,{title:I})]}),C(ce,{children:C(co,{fullWidth:!0,onChange:Be,onInputChange:Re,onBlur:Me,slotProps:{...y.slotProps,listbox:{component:io(function(g,W){return D(re,{children:[C("ul",{...g,ref:W}),typeof i<"u"?D("div",{...g,children:[C("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:C(Fe,{})}),i()]},"creatable-footer"):null]})})}},value:De,options:h,multiple:k,readOnly:y.disabled,noOptionsText:D(re,{children:[O,!K&&D(yo,{sx:{justifyContent:"flex-start",padding:`${Pe(6)} ${Pe(-16)}`,margin:0},fullWidth:!0,onClick:de,variant:"text",startIcon:C(te,{icon:xe}),children:["Adicionar ",`"${N}"`]}),typeof i<"u"&&D(re,{children:[C("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:C(Fe,{})}),i()]})]}),isOptionEqualToValue:(T,g)=>fo(T,g),getOptionLabel:S,getOptionKey:n,renderOption:typeof F=="function"?(T,g)=>{let W=F(g),Ae=n(g);return bo("li",{...T,key:Ae},D("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[C("span",{children:S(g)}),typeof W=="string"?C("span",{children:W}):W]}))}:void 0,...y,sx:{"& div.MuiInputBase-root":{paddingRight:`${Ee(U.value)} !important`},...y.sx},renderInput:T=>C(Fo,{placeholder:z,...T,error:!!E,...e.slotProps?.textField,slotProps:{input:{...T.InputProps,...e.slotProps?.textField?.slotProps?.input,inputRef:U.ref,endAdornment:D("div",{className:"endAdornments",children:[T.InputProps.endAdornment,e.slotProps?.textField?.slotProps?.input?.endAdornment??null,pe(U.value)?D("div",{className:"editable",children:[C("div",{className:"divider"}),C(ye,{size:"small",onClick:we,sx:{mx:"3px"},tabIndex:-1,children:C(te,{icon:xo,size:"24px",removeMargin:!0})})]}):null,Le()&&D("div",{className:"creatable",children:[C("div",{className:"divider"}),C(ye,{size:"small",onClick:de,sx:{mx:"3px"},tabIndex:-1,children:C(te,{icon:xe,size:"24px",removeMargin:!0})})]})]})}}})},o)}),C(v,{name:o,control:r})]})}var ho=w(Po);import{Stack as So}from"@mui/material";import{AdapterDayjs as Io}from"@mui/x-date-pickers/AdapterDayjs";import{DatePicker as To}from"@mui/x-date-pickers";import{LocalizationProvider as ko}from"@mui/x-date-pickers/LocalizationProvider";import{ptBR as Eo}from"@mui/x-date-pickers/locales";import{composeValidators as Lo,date as be}from"@s_mart/rules";import{useController as wo,useFormContext as Ro,useFormState as Bo}from"react-hook-form";import{IconButton as go,styled as vo}from"@mui/material";import{toRem as q}from"@s_mart/utils";var Co=e=>{switch(e){case"small":return q(16);case"large":return q(24);default:return q(20)}},Vo=e=>{switch(e){case"small":return`${q(2)} ${q(8)}`;case"large":return`${q(10)}`;default:return`${q(6)} ${q(8)}`}},he=vo(go)`
34
+ `;import{Tooltip as to}from"@mui/material";import{LIcon as ro}from"@s_mart/core";import{lineInfoCircle as lo}from"@s_mart/solid-icons";import{jsx as te}from"react/jsx-runtime";var no=({title:e})=>te(to,{title:e,placement:"top",children:te("div",{style:{width:"fit-content"},children:te(ro,{icon:lo,color:"#757575"})})}),K=no;import{Fragment as le,jsx as C,jsxs as A}from"react/jsx-runtime";import{createElement as go}from"react";function ho(e){let{name:o,rules:t,defaultValue:r,shouldUnregister:i,control:F,label:y,required:u,options:h,footer:l,showCreatableButton:V=!0,showEditableButton:s,onEditOption:d,onCreateOption:a,getOptionKey:n,getOptionLabel:I,getOptionAfterLabel:f,getInputValueLabel:k,multiple:T,info:_,noOptionsText:$="Nenhuma op\xE7\xE3o encontrada",onChange:z,onInputChange:D,placeholder:L,...S}=e,[N,m]=ao(""),c=po()?.control,p=F??c;if(!p)throw new P("CreatableV2");let b=mo({control:p,name:o}),B=w(b.errors,o),W=!V||S.disabled,{field:U}=so({name:o,control:p,rules:t,defaultValue:r,shouldUnregister:i}),Le=E=>{let g=0;return e.slotProps?.textField?.slotProps?.input||(g+=2.5),W||(g+=2.56,de(E)&&(g+=2.56)),!S.disableClearable&&!S.disabled&&(g+=1.3),`${g}rem`},de=E=>S.disabled?!1:s&&uo(E)&&!fo(E),we=()=>S.disabled?!1:V,me=Q(()=>{typeof a<"u"&&(a(N),m(""))},[N,a]),Re=Q(()=>{d?.(U.value)},[U.value,d]),Be=Q((E,g,Y)=>{Y==="input"&&(m(g),D?.(g))},[D]),Me=Q((E,g)=>{m(""),U.onChange(g),z?.(g)},[U.onChange,z]),De=Q(E=>{S?.onBlur?.(E),m("")},[S?.onBlur]),Ae=U.value?U.value:T?[]:null;return A("div",{style:{display:"flex",flexDirection:"column"},children:[A("div",{style:{display:"flex"},children:[y&&C(x,{label:y,required:u}),_&&C(K,{title:_})]}),C(Fe,{children:C(Fo,{fullWidth:!0,onChange:Me,onInputChange:Be,onBlur:De,slotProps:{...S.slotProps,listbox:{component:io(function(g,Y){return A(le,{children:[C("ul",{...g,ref:Y}),typeof l<"u"?A("div",{...g,children:[C("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:C(ye,{})}),l()]},"creatable-footer"):null]})})}},value:Ae,options:h,multiple:T,readOnly:S.disabled,noOptionsText:A(le,{children:[$,!W&&A(xo,{sx:{justifyContent:"flex-start",padding:`${he(6)} ${he(-16)}`,margin:0},fullWidth:!0,onClick:me,variant:"text",startIcon:C(re,{icon:Pe}),children:["Adicionar ",`"${N}"`]}),typeof l<"u"&&A(le,{children:[C("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:C(ye,{})}),l()]})]}),isOptionEqualToValue:(E,g)=>co(E,g),getOptionLabel:f&&k||I,getOptionKey:n,renderOption:typeof f=="function"?(E,g)=>{let Y=f(g),Oe=n(g);return go("li",{...E,key:Oe},A("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[C("span",{children:I(g)}),typeof Y=="string"?C("span",{children:Y}):Y]}))}:void 0,...S,sx:{"& div.MuiInputBase-root":{paddingRight:`${Le(U.value)} !important`},...S.sx},renderInput:E=>C(yo,{placeholder:L,...E,error:!!B,...e.slotProps?.textField,slotProps:{input:{...E.InputProps,...e.slotProps?.textField?.slotProps?.input,inputRef:U.ref,endAdornment:A("div",{className:"endAdornments",children:[E.InputProps.endAdornment,e.slotProps?.textField?.slotProps?.input?.endAdornment??null,de(U.value)?A("div",{className:"editable",children:[C("div",{className:"divider"}),C(xe,{size:"small",onClick:Re,sx:{mx:"3px"},tabIndex:-1,children:C(re,{icon:Po,size:"24px",removeMargin:!0})})]}):null,we()&&A("div",{className:"creatable",children:[C("div",{className:"divider"}),C(xe,{size:"small",onClick:me,sx:{mx:"3px"},tabIndex:-1,children:C(re,{icon:Pe,size:"24px",removeMargin:!0})})]})]})}}})},o)}),C(v,{name:o,control:p})]})}var bo=R(ho);import{Stack as Io}from"@mui/material";import{AdapterDayjs as To}from"@mui/x-date-pickers/AdapterDayjs";import{DatePicker as ko}from"@mui/x-date-pickers";import{LocalizationProvider as Eo}from"@mui/x-date-pickers/LocalizationProvider";import{ptBR as Lo}from"@mui/x-date-pickers/locales";import{composeValidators as wo,date as ge}from"@s_mart/rules";import{useController as Ro,useFormContext as Bo,useFormState as Mo}from"react-hook-form";import{IconButton as vo,styled as Co}from"@mui/material";import{toRem as q}from"@s_mart/utils";var Vo=e=>{switch(e){case"small":return q(16);case"large":return q(24);default:return q(20)}},So=e=>{switch(e){case"small":return`${q(2)} ${q(8)}`;case"large":return`${q(10)}`;default:return`${q(6)} ${q(8)}`}},be=Co(vo)`
35
35
  margin: 0px;
36
36
 
37
- padding: ${({size:e})=>Vo(e)};
37
+ padding: ${({size:e})=>So(e)};
38
38
  border-radius: 0 ${q(4)} ${q(4)} 0;
39
39
 
40
40
  svg {
41
- width: ${({size:e})=>Co(e)} !important;
41
+ width: ${({size:e})=>Vo(e)} !important;
42
42
  }
43
- `;import"dayjs/locale/pt-br";import{jsx as le,jsxs as Oo}from"react/jsx-runtime";import{createElement as Ao}from"react";var Mo=({rules:e,name:o,defaultValue:t,shouldUnregister:l,control:a,label:f,required:c,disabled:m,disableIconError:h,...i})=>{let V=Ro()?.control,p=a??V;if(!p)throw new P("DatePicker");let d=Bo({control:p,name:o}),s=L(d.errors,o),n=i?.format||"DD/MM/YYYY",S=e?Lo([be(n),e]):be(n),{field:F}=wo({control:p,name:o,rules:S,defaultValue:t,shouldUnregister:l});return le(ko,{dateAdapter:Io,localeText:Eo.components.MuiLocalizationProvider.defaultProps.localeText,children:Oo(So,{children:[f&&le(x,{label:f,required:c}),Ao(To,{...i,key:o,value:F.value??null,format:n,onChange:(k,I)=>{F.onChange(k,I),i?.onChange?.(k,I)},disabled:m,enableAccessibleFieldDOMStructure:!1,slots:{openPickerButton:he},slotProps:{...i?.slotProps,textField:{error:!!s,...i.slotProps?.textField,inputRef:F.ref}}}),le(v,{name:o,disableIcon:h,control:p})]})})},Do=w(Mo);import{FormProvider as $o}from"react-hook-form";import{jsx as ge}from"react/jsx-runtime";function zo({children:e,style:o,onSubmit:t,...l}){return ge($o,{...l,children:ge("form",{onSubmit:a=>{a.preventDefault(),a.stopPropagation(),t(a)},style:o,children:e})})}var ie=zo;import{useEffect as qo}from"react";import{useForm as Ho}from"react-hook-form";import{zodResolver as Go}from"@hookform/resolvers/zod";var No=({disableDefaultValuesUpdate:e,onSubmit:o,...t})=>{let l=Ho({...t,resolver:t.schema&&Go(t.schema)});return qo(()=>{e||l.reset(t.defaultValues)},[t.defaultValues,l.reset]),{...l,onSubmit:l.handleSubmit(a=>o(a,l))}},ne=No;import{jsx as Ko}from"react/jsx-runtime";function Uo({children:e,style:o,...t}){let l=ne(t);return Ko(ie,{...l,style:o,children:typeof e=="function"?e(l):e})}var _o=Uo;import{RadioGroup as Wo,Stack as Yo}from"@mui/material";import{useController as Jo,useFormContext as Xo}from"react-hook-form";import{jsx as ae,jsxs as jo}from"react/jsx-runtime";var Qo=({name:e,rules:o,defaultValue:t,shouldUnregister:l,control:a,label:f,required:c,children:m,orientation:h="row",disableIconError:i,...V})=>{let p=Xo()?.control,d=a??p;if(!d)throw new P("RadioGroup");let{field:s}=Jo({control:d,name:e,rules:o,defaultValue:t,shouldUnregister:l});return jo(Yo,{children:[f&&ae(x,{label:f,required:c}),ae(Wo,{value:s.value||"",name:e,...V,onChange:n=>{V?.onChange?.(n,n.target?.value),s.onChange(n)},style:{display:"flex",flexDirection:h},children:m},e),ae(v,{name:e,disableIcon:i,control:d})]})},Zo=Qo;import{FormControlLabel as et,Grid as ot,Radio as tt}from"@mui/material";import{jsx as Z}from"react/jsx-runtime";var rt=({label:e,labelPlacement:o,...t})=>Z(ot,{sx:{display:"flex",flexDirection:"column"},children:Z(et,{control:Z(tt,{...t}),label:Z(x,{label:e}),labelPlacement:o||"end"})}),lt=rt;import{Autocomplete as it,Divider as ve,TextField as nt}from"@mui/material";import at from"lodash-es/isEqual";import{forwardRef as st}from"react";import{useController as pt,useFormContext as dt,useFormState as mt}from"react-hook-form";import{Fragment as se,jsx as B,jsxs as Y}from"react/jsx-runtime";import{createElement as ct}from"react";var ut=e=>{let{name:o,rules:t,defaultValue:l,shouldUnregister:a,control:f,label:c,required:m,options:h,textFieldProps:i,noOptionsText:V,footer:p,multiple:d,info:s,placeholder:n,onChange:S,onInputChange:F,getOptionAfterLabel:k,getOptionLabel:I,getOptionKey:O,...$}=e,M=dt()?.control,z=f??M;if(!z)throw new P("SearchableV2");let y=mt({control:z,name:o}),N=L(y.errors,o),{field:R}=pt({name:o,control:z,rules:t,defaultValue:l,shouldUnregister:a}),u=R.value?R.value:d?[]:null;return Y("div",{style:{display:"flex",flexDirection:"column"},children:[Y("div",{style:{display:"flex"},children:[c&&B(x,{label:c,required:m}),s&&B(_,{title:s})]}),B(it,{onChange:(r,b)=>{R.onChange(b),S?.(b)},onInputChange:(r,b,E)=>{E==="input"&&F?.(b)},value:u,options:h,multiple:d,readOnly:$.disabled,slotProps:{...$.slotProps,listbox:{component:st(function(b,E){return Y(se,{children:[B("ul",{...b,ref:E}),typeof p<"u"?Y("div",{...b,children:[B("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:B(ve,{})}),p()]},"searchable-footer"):null]})})}},noOptionsText:Y(se,{children:[V||"Nenhuma op\xE7\xE3o encontrada",typeof p<"u"?Y(se,{children:[B("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:B(ve,{})}),p()]}):null]}),isOptionEqualToValue:(r,b)=>at(r,b),getOptionLabel:I,getOptionKey:O,renderOption:typeof k=="function"?(r,b)=>{let E=k(b),K=O(b);return ct("li",{...r,key:K},Y("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[B("span",{children:I(b)}),typeof E=="string"?B("span",{children:E}):E]}))}:void 0,...$,renderInput:r=>B(nt,{error:!!N,placeholder:n,...r,...i,inputRef:R.ref})},o),B(v,{name:o,control:z})]})},ft=w(ut);import{useState as xt}from"react";import{useController as Pt,useFormContext as ht,useFormState as bt}from"react-hook-form";import{IconButton as gt,LIcon as vt}from"@s_mart/core";import{lineTimes as Ct}from"@s_mart/regular-icons";import{colorPalette as Vt}from"@s_mart/tokens";import{Select as St,MenuItem as It,Divider as Tt}from"@mui/material";import{colorPalette as Ft}from"@s_mart/tokens";import{jsx as yt}from"react/jsx-runtime";var Ce=({value:e,placeholder:o,getOptionLabel:t})=>e===null||e?.length===0?yt("p",{style:{color:Ft.neutral[100]},children:o}):t(e);import{Fragment as Lt,jsx as A,jsxs as J}from"react/jsx-runtime";var kt=e=>{let{name:o,rules:t,defaultValue:l,shouldUnregister:a,control:f,label:c,required:m,options:h,placeholder:i,clearable:V,info:p,footer:d,onChange:s,variant:n="outlined",getOptionKey:S,getOptionLabel:F,getOptionAfterLabel:k,getOptionIcon:I,...O}=e,$=ht()?.control,M=f??$,[z,y]=xt(!1);if(!M)throw new P("SelectV2");let N=bt({control:M,name:o}),R=L(N.errors,o),{field:u}=Pt({control:M,name:o,rules:t,defaultValue:l,shouldUnregister:a});return J("div",{style:{display:"flex",flexDirection:"column"},children:[J("div",{style:{display:"flex"},children:[c&&A(x,{label:c,required:m}),p&&A(_,{title:p})]}),J(St,{open:z,onOpen:()=>y(!0),onClose:()=>y(!1),displayEmpty:!!i,variant:n,autoComplete:"off",value:u.value||null,renderValue:r=>A(Ce,{getOptionLabel:F,placeholder:i,value:r}),onChange:r=>{u.onChange(r.target.value),s?.(r.target.value)},error:!!R,size:O.size||"medium",inputRef:u.ref,...O,endAdornment:J(Lt,{children:[O.endAdornment,!!(V&&u.value)&&A(gt,{variant:"text",color:"neutral",size:"small",sx:{borderRadius:"50%",position:"absolute",right:"2rem"},style:{padding:0},"aria-label":"Limpar",title:"Limpar",onClick:()=>{u.onChange(null),s?.(null)},children:A(vt,{icon:Ct,color:Vt.neutral[100],size:"25px",removeMargin:!0})})]}),children:[h.map(r=>{let b=S(r),E=F(r),K=I?.(r);return A(It,{value:r,children:J("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[K!==void 0?J("div",{style:{display:"flex",alignItems:"center"},children:[K,E]}):E,A("span",{children:k?.(r)??null})]})},b)}),d!==void 0&&J("div",{children:[A("div",{style:{padding:"8px 16px"},children:A(Tt,{})},"footer-divider"),A("div",{children:d({closeSelect:()=>y(!1)})},"footer-content")]},"footer")]},o),A(v,{name:o,control:M})]})},Et=w(kt);import{useController as wt,useFormContext as Rt}from"react-hook-form";import{Slider as Bt}from"@mui/material";import{jsx as At}from"react/jsx-runtime";var Mt=({name:e,rules:o,defaultValue:t,shouldUnregister:l,control:a,...f})=>{let c=Rt()?.control,m=a??c;if(!m)throw new P("Slider");let{field:h}=wt({control:m,name:e,rules:o,defaultValue:t,shouldUnregister:l});return At(Bt,{value:h.value||f?.min||0,onChange:h.onChange,valueLabelDisplay:"auto",...f},e)},Dt=Mt;import{FormControlLabel as Ot,Stack as $t,Switch as zt}from"@mui/material";import{useController as qt,useFormContext as Ht}from"react-hook-form";import{useCallback as Gt}from"react";import{jsx as j,jsxs as _t}from"react/jsx-runtime";var Nt=({name:e,rules:o,defaultValue:t,defaultChecked:l,shouldUnregister:a,control:f,label:c,labelPlacement:m="end",disableIconError:h,onChange:i,...V})=>{let p=Ht()?.control,d=f??p;if(!d)throw new P("Switch");let{field:s}=qt({control:d,name:e,rules:o,defaultValue:l??t??!1,shouldUnregister:a}),n=Gt((S,F)=>{s.onChange(F),i?.(S,F)},[s,i]);return _t($t,{children:[j(Ot,{control:j(zt,{...V,...s,checked:!!s.value,onChange:n}),label:j(x,{label:c}),labelPlacement:m}),j(v,{name:e,disableIcon:h,control:d})]})},Ut=Nt;import{InputAdornment as Kt,Stack as Wt,TextField as Yt,Tooltip as Jt}from"@mui/material";import{LIcon as Ve}from"@s_mart/core";import*as Se from"@s_mart/masks";import{lineEye as Xt,lineEyeSlash as Qt,lineInfoCircle as Zt}from"@s_mart/solid-icons";import{useRef as jt,useState as er}from"react";import{useController as or,useFormContext as tr,useFormState as rr}from"react-hook-form";import{jsx as H,jsxs as Ie}from"react/jsx-runtime";var lr=({name:e,rules:o,defaultValue:t,shouldUnregister:l,control:a,label:f,required:c,mask:m,variant:h="outlined",info:i,parse:V,format:p,onInputChange:d,disableIconError:s,...n})=>{let S=tr()?.control,F=a??S,k=jt(t||void 0);if(!F)throw new P("TextField");let[I,O]=er(!1),$=u=>{let r=u;return r=p?.(u)??u,m?Se?.[m]?.format(r):r},M=u=>{let r=u;return r=V?.(u)??r,m?Se?.[m]?.parse(r,k.current):r},z=u=>{if(!u||m!=="porcentagem"&&m!=="porcentagem0")return;u?.stopPropagation();let r=(u?.target).value;if(r){let b=String(r);if(b.length>0){let E=b.indexOf("%");E>-1&&(u.currentTarget.selectionEnd=E)}}},{field:y}=or({control:F,name:e,rules:o,defaultValue:t,shouldUnregister:l}),N=rr({control:F,name:e}),R=L(N.errors,e);return Ie(Wt,{children:[Ie("div",{style:{display:"flex"},children:[f&&H("div",{children:H(x,{label:f,required:c})}),i&&H("div",{children:H(Jt,{title:i,placement:"top",children:H("div",{style:{width:"fit-content"},children:H(Ve,{icon:Zt,color:"#757575"})})})})]}),H(Yt,{variant:h,defaultValue:t,value:$(y.value||(y.value!=0?"":y.value)),onChange:u=>{let r=M(u?.target?.value);y.onChange(r),d?.(r),k.current=u.target.value},error:!!R,...n,type:n.type==="password"?I?"text":"password":n.type,autoComplete:n.autoComplete||"off",slotProps:{...n.slotProps,input:{onKeyDown:z,inputRef:y.ref,endAdornment:n.type==="password"&&H(Kt,{position:"start",onClick:()=>O(!I),style:{cursor:"pointer"},children:H(Ve,{icon:I?Xt:Qt,size:"24px",removeMargin:!0})}),...n.slotProps?.input}}},e),H(v,{name:e,disableIcon:s,control:F})]})},ir=w(lr);import{Stack as dr}from"@mui/material";import{AdapterDayjs as mr}from"@mui/x-date-pickers/AdapterDayjs";import{LocalizationProvider as ur}from"@mui/x-date-pickers/LocalizationProvider";import{TimePicker as fr}from"@mui/x-date-pickers/TimePicker";import{composeValidators as cr,time as ke}from"@s_mart/rules";import{useController as Fr,useFormContext as yr,useFormState as xr}from"react-hook-form";import{styled as nr}from"@mui/material";import{IconButton as ar}from"@mui/material";import{toRem as G}from"@s_mart/utils";var sr=e=>{switch(e){case"small":return G(16);case"large":return G(24);default:return G(20)}},pr=e=>{switch(e){case"small":return`${G(2)} ${G(8)}`;case"large":return G(10);default:return`${G(6)} ${G(8)}`}},Te=nr(ar)`
43
+ `;import"dayjs/locale/pt-br";import{jsx as ne,jsxs as $o}from"react/jsx-runtime";import{createElement as Oo}from"react";var Do=({rules:e,name:o,defaultValue:t,shouldUnregister:r,control:i,label:F,required:y,disabled:u,disableIconError:h,...l})=>{let V=Bo()?.control,s=i??V;if(!s)throw new P("DatePicker");let d=Mo({control:s,name:o}),a=w(d.errors,o),n=l?.format||"DD/MM/YYYY",I=e?wo([ge(n),e]):ge(n),{field:f}=Ro({control:s,name:o,rules:I,defaultValue:t,shouldUnregister:r});return ne(Eo,{dateAdapter:To,localeText:Lo.components.MuiLocalizationProvider.defaultProps.localeText,children:$o(Io,{children:[F&&ne(x,{label:F,required:y}),Oo(ko,{...l,key:o,value:f.value??null,format:n,onChange:(k,T)=>{f.onChange(k,T),l?.onChange?.(k,T)},disabled:u,enableAccessibleFieldDOMStructure:!1,slots:{openPickerButton:be},slotProps:{...l?.slotProps,textField:{error:!!a,...l.slotProps?.textField,inputRef:f.ref}}}),ne(v,{name:o,disableIcon:h,control:s})]})})},Ao=R(Do);import{FormProvider as zo}from"react-hook-form";import{jsx as ve}from"react/jsx-runtime";function qo({children:e,style:o,onSubmit:t,...r}){return ve(zo,{...r,children:ve("form",{onSubmit:i=>{i.preventDefault(),i.stopPropagation(),t(i)},style:o,children:e})})}var ie=qo;import{useEffect as Ho}from"react";import{useForm as Go}from"react-hook-form";import{zodResolver as No}from"@hookform/resolvers/zod";var Uo=({disableDefaultValuesUpdate:e,onSubmit:o,...t})=>{let r=Go({...t,resolver:t.schema&&No(t.schema)});return Ho(()=>{e||r.reset(t.defaultValues)},[t.defaultValues,r.reset]),{...r,onSubmit:r.handleSubmit(i=>o(i,r))}},ae=Uo;import{jsx as Wo}from"react/jsx-runtime";function _o({children:e,style:o,...t}){let r=ae(t);return Wo(ie,{...r,style:o,children:typeof e=="function"?e(r):e})}var Ko=_o;import{RadioGroup as Yo,Stack as Jo}from"@mui/material";import{useController as Xo,useFormContext as Qo}from"react-hook-form";import{jsx as se,jsxs as et}from"react/jsx-runtime";var Zo=({name:e,rules:o,defaultValue:t,shouldUnregister:r,control:i,label:F,required:y,children:u,orientation:h="row",disableIconError:l,...V})=>{let s=Qo()?.control,d=i??s;if(!d)throw new P("RadioGroup");let{field:a}=Xo({control:d,name:e,rules:o,defaultValue:t,shouldUnregister:r});return et(Jo,{children:[F&&se(x,{label:F,required:y}),se(Yo,{value:a.value||"",name:e,...V,onChange:n=>{V?.onChange?.(n,n.target?.value),a.onChange(n)},style:{display:"flex",flexDirection:h},children:u},e),se(v,{name:e,disableIcon:l,control:d})]})},jo=Zo;import{FormControlLabel as ot,Grid as tt,Radio as rt}from"@mui/material";import{jsx as j}from"react/jsx-runtime";var lt=({label:e,labelPlacement:o,...t})=>j(tt,{sx:{display:"flex",flexDirection:"column"},children:j(ot,{control:j(rt,{...t}),label:j(x,{label:e}),labelPlacement:o||"end"})}),nt=lt;import{Autocomplete as it,Divider as Ce,TextField as at}from"@mui/material";import st from"lodash-es/isEqual";import{forwardRef as pt}from"react";import{useController as dt,useFormContext as mt,useFormState as ut}from"react-hook-form";import{Fragment as pe,jsx as M,jsxs as J}from"react/jsx-runtime";import{createElement as Ft}from"react";var ft=e=>{let{name:o,rules:t,defaultValue:r,shouldUnregister:i,control:F,label:y,required:u,options:h,textFieldProps:l,noOptionsText:V,footer:s,multiple:d,info:a,placeholder:n,onChange:I,onInputChange:f,getOptionAfterLabel:k,getOptionLabel:T,getInputValueLabel:_,getOptionKey:$,...z}=e,D=mt()?.control,L=F??D;if(!L)throw new P("SearchableV2");let S=ut({control:L,name:o}),N=w(S.errors,o),{field:m}=dt({name:o,control:L,rules:t,defaultValue:r,shouldUnregister:i}),c=m.value?m.value:d?[]:null;return J("div",{style:{display:"flex",flexDirection:"column"},children:[J("div",{style:{display:"flex"},children:[y&&M(x,{label:y,required:u}),a&&M(K,{title:a})]}),M(it,{onChange:(p,b)=>{m.onChange(b),I?.(b)},onInputChange:(p,b,B)=>{B==="input"&&f?.(b)},value:c,options:h,multiple:d,readOnly:z.disabled,slotProps:{...z.slotProps,listbox:{component:pt(function(b,B){return J(pe,{children:[M("ul",{...b,ref:B}),typeof s<"u"?J("div",{...b,children:[M("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:M(Ce,{})}),s()]},"searchable-footer"):null]})})}},noOptionsText:J(pe,{children:[V||"Nenhuma op\xE7\xE3o encontrada",typeof s<"u"?J(pe,{children:[M("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:M(Ce,{})}),s()]}):null]}),isOptionEqualToValue:(p,b)=>st(p,b),getOptionLabel:k&&_||T,getOptionKey:$,renderOption:typeof k=="function"?(p,b)=>{let B=k(b),W=$(b);return Ft("li",{...p,key:W},J("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[M("span",{children:T(b)}),typeof B=="string"?M("span",{children:B}):B]}))}:void 0,...z,renderInput:p=>M(at,{error:!!N,placeholder:n,...p,...l,inputRef:m.ref})},o),M(v,{name:o,control:L})]})},ct=R(ft);import{useState as Pt}from"react";import{useController as ht,useFormContext as bt,useFormState as gt}from"react-hook-form";import{IconButton as vt,LIcon as Ct}from"@s_mart/core";import{lineTimes as Vt}from"@s_mart/regular-icons";import{colorPalette as St}from"@s_mart/tokens";import{Select as It,MenuItem as Tt,Divider as kt}from"@mui/material";import{colorPalette as yt}from"@s_mart/tokens";import{jsx as xt}from"react/jsx-runtime";var Ve=({value:e,placeholder:o,getOptionLabel:t})=>e===null||e?.length===0?xt("p",{style:{color:yt.neutral[100]},children:o}):t(e);import{Fragment as wt,jsx as O,jsxs as X}from"react/jsx-runtime";var Et=e=>{let{name:o,rules:t,defaultValue:r,shouldUnregister:i,control:F,label:y,required:u,options:h,placeholder:l,clearable:V,info:s,footer:d,onChange:a,variant:n="outlined",getOptionKey:I,getOptionLabel:f,getOptionAfterLabel:k,getInputValueLabel:T,getOptionIcon:_,...$}=e,z=bt()?.control,D=F??z,[L,S]=Pt(!1);if(!D)throw new P("SelectV2");let N=gt({control:D,name:o}),m=w(N.errors,o),{field:c}=ht({control:D,name:o,rules:t,defaultValue:r,shouldUnregister:i});return X("div",{style:{display:"flex",flexDirection:"column"},children:[X("div",{style:{display:"flex"},children:[y&&O(x,{label:y,required:u}),s&&O(K,{title:s})]}),X(It,{open:L,onOpen:()=>S(!0),onClose:()=>S(!1),displayEmpty:!!l,variant:n,autoComplete:"off",value:c.value||null,renderValue:p=>O(Ve,{getOptionLabel:k&&T||f,placeholder:l,value:p}),onChange:p=>{c.onChange(p.target.value),a?.(p.target.value)},error:!!m,size:$.size||"medium",inputRef:c.ref,...$,endAdornment:X(wt,{children:[$.endAdornment,!!(V&&c.value)&&O(vt,{variant:"text",color:"neutral",size:"small",sx:{borderRadius:"50%",position:"absolute",right:"2rem"},style:{padding:0},"aria-label":"Limpar",title:"Limpar",onClick:()=>{c.onChange(null),a?.(null)},children:O(Ct,{icon:Vt,color:St.neutral[100],size:"25px",removeMargin:!0})})]}),children:[h.map(p=>{let b=I(p),B=f(p),W=_?.(p);return O(Tt,{value:p,children:X("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[W!==void 0?X("div",{style:{display:"flex",alignItems:"center"},children:[W,B]}):B,O("span",{children:k?.(p)??null})]})},b)}),d!==void 0&&X("div",{children:[O("div",{style:{padding:"8px 16px"},children:O(kt,{})},"footer-divider"),O("div",{children:d({closeSelect:()=>S(!1)})},"footer-content")]},"footer")]},o),O(v,{name:o,control:D})]})},Lt=R(Et);import{useController as Rt,useFormContext as Bt}from"react-hook-form";import{Slider as Mt}from"@mui/material";import{jsx as Ot}from"react/jsx-runtime";var Dt=({name:e,rules:o,defaultValue:t,shouldUnregister:r,control:i,...F})=>{let y=Bt()?.control,u=i??y;if(!u)throw new P("Slider");let{field:h}=Rt({control:u,name:e,rules:o,defaultValue:t,shouldUnregister:r});return Ot(Mt,{value:h.value||F?.min||0,onChange:h.onChange,valueLabelDisplay:"auto",...F},e)},At=Dt;import{FormControlLabel as $t,Stack as zt,Switch as qt}from"@mui/material";import{useController as Ht,useFormContext as Gt}from"react-hook-form";import{useCallback as Nt}from"react";import{jsx as ee,jsxs as Kt}from"react/jsx-runtime";var Ut=({name:e,rules:o,defaultValue:t,defaultChecked:r,shouldUnregister:i,control:F,label:y,labelPlacement:u="end",disableIconError:h,onChange:l,...V})=>{let s=Gt()?.control,d=F??s;if(!d)throw new P("Switch");let{field:a}=Ht({control:d,name:e,rules:o,defaultValue:r??t??!1,shouldUnregister:i}),n=Nt((I,f)=>{a.onChange(f),l?.(I,f)},[a,l]);return Kt(zt,{children:[ee($t,{control:ee(qt,{...V,...a,checked:!!a.value,onChange:n}),label:ee(x,{label:y}),labelPlacement:u}),ee(v,{name:e,disableIcon:h,control:d})]})},_t=Ut;import{InputAdornment as Wt,Stack as Yt,TextField as Jt,Tooltip as Xt}from"@mui/material";import{LIcon as Se}from"@s_mart/core";import*as Ie from"@s_mart/masks";import{lineEye as Qt,lineEyeSlash as Zt,lineInfoCircle as jt}from"@s_mart/solid-icons";import{useRef as er,useState as or}from"react";import{useController as tr,useFormContext as rr,useFormState as lr}from"react-hook-form";import{jsx as H,jsxs as Te}from"react/jsx-runtime";var nr=({name:e,rules:o,defaultValue:t,shouldUnregister:r,control:i,label:F,required:y,mask:u,variant:h="outlined",info:l,parse:V,format:s,onInputChange:d,disableIconError:a,...n})=>{let I=rr()?.control,f=i??I,k=er(t||void 0);if(!f)throw new P("TextField");let[T,_]=or(!1),$=m=>{let c=m;return c=s?.(m)??m,u?Ie?.[u]?.format(c):c},z=m=>{let c=m;return c=V?.(m)??c,u?Ie?.[u]?.parse(c,k.current):c},D=m=>{if(!m||u!=="porcentagem"&&u!=="porcentagem0")return;m?.stopPropagation();let c=(m?.target).value;if(c){let p=String(c);if(p.length>0){let b=p.indexOf("%");b>-1&&(m.currentTarget.selectionEnd=b)}}},{field:L}=tr({control:f,name:e,rules:o,defaultValue:t,shouldUnregister:r}),S=lr({control:f,name:e}),N=w(S.errors,e);return Te(Yt,{children:[Te("div",{style:{display:"flex"},children:[F&&H("div",{children:H(x,{label:F,required:y})}),l&&H("div",{children:H(Xt,{title:l,placement:"top",children:H("div",{style:{width:"fit-content"},children:H(Se,{icon:jt,color:"#757575"})})})})]}),H(Jt,{variant:h,defaultValue:t,value:$(L.value||(L.value!=0?"":L.value)),onChange:m=>{let c=z(m?.target?.value);L.onChange(c),d?.(c),k.current=m.target.value},error:!!N,...n,type:n.type==="password"?T?"text":"password":n.type,autoComplete:n.autoComplete||"off",slotProps:{...n.slotProps,input:{onKeyDown:D,inputRef:L.ref,endAdornment:n.type==="password"&&H(Wt,{position:"start",onClick:()=>_(!T),style:{cursor:"pointer"},children:H(Se,{icon:T?Qt:Zt,size:"24px",removeMargin:!0})}),...n.slotProps?.input}}},e),H(v,{name:e,disableIcon:a,control:f})]})},ir=R(nr);import{Stack as mr}from"@mui/material";import{AdapterDayjs as ur}from"@mui/x-date-pickers/AdapterDayjs";import{LocalizationProvider as fr}from"@mui/x-date-pickers/LocalizationProvider";import{TimePicker as cr}from"@mui/x-date-pickers/TimePicker";import{composeValidators as Fr,time as Ee}from"@s_mart/rules";import{useController as yr,useFormContext as xr,useFormState as Pr}from"react-hook-form";import{styled as ar}from"@mui/material";import{IconButton as sr}from"@mui/material";import{toRem as G}from"@s_mart/utils";var pr=e=>{switch(e){case"small":return G(16);case"large":return G(24);default:return G(20)}},dr=e=>{switch(e){case"small":return`${G(2)} ${G(8)}`;case"large":return G(10);default:return`${G(6)} ${G(8)}`}},ke=ar(sr)`
44
44
  margin: 0px;
45
45
 
46
- padding: ${({size:e})=>pr(e)};
46
+ padding: ${({size:e})=>dr(e)};
47
47
  border-radius: 0 ${G(4)} ${G(4)} 0;
48
48
 
49
49
  svg {
50
- width: ${({size:e})=>sr(e)} !important;
50
+ width: ${({size:e})=>pr(e)} !important;
51
51
  }
52
- `;import"dayjs/locale/pt-br";import{jsx as ee,jsxs as br}from"react/jsx-runtime";var Pr=({rules:e,defaultValue:o,shouldUnregister:t,name:l,control:a,required:f,label:c,disabled:m,disableIconError:h,...i})=>{let V=yr()?.control,p=a??V;if(!p)throw new P("TimePicker");let d=xr({control:p,name:l}),s=L(d.errors,l),n=i.format||"HH:mm",S=e?cr([ke(n),e]):ke(n),{field:F}=Fr({control:p,name:l,rules:S,defaultValue:o,shouldUnregister:t});return ee(ur,{dateAdapter:mr,children:br(dr,{children:[c&&ee(x,{label:c,required:f}),ee(fr,{ampm:!1,format:n,value:F.value??null,disabled:m,...i,enableAccessibleFieldDOMStructure:!1,onChange:(k,I)=>{F.onChange(k,I),i?.onChange?.(k,I)},slots:{openPickerButton:Te},slotProps:{...i.slotProps,textField:{error:!!s,...i.slotProps?.textField,inputRef:F.ref},actionBar:{actions:[],...i.slotProps?.actionBar}}},l),ee(v,{name:l,disableIcon:h,control:p})]})})},hr=w(Pr);export{Xe as Checkbox,ho as CreatableV2,Do as DatePicker,v as FieldError,_ as FieldInfo,x as FieldLabel,_o as Form,ie as FormProvider,lt as RadioButton,Zo as RadioGroup,ft as SearchableV2,Et as SelectV2,Dt as Slider,Ut as Switch,ir as TextField,hr as TimePicker,ne as useForm};
52
+ `;import"dayjs/locale/pt-br";import{jsx as oe,jsxs as gr}from"react/jsx-runtime";var hr=({rules:e,defaultValue:o,shouldUnregister:t,name:r,control:i,required:F,label:y,disabled:u,disableIconError:h,...l})=>{let V=xr()?.control,s=i??V;if(!s)throw new P("TimePicker");let d=Pr({control:s,name:r}),a=w(d.errors,r),n=l.format||"HH:mm",I=e?Fr([Ee(n),e]):Ee(n),{field:f}=yr({control:s,name:r,rules:I,defaultValue:o,shouldUnregister:t});return oe(fr,{dateAdapter:ur,children:gr(mr,{children:[y&&oe(x,{label:y,required:F}),oe(cr,{ampm:!1,format:n,value:f.value??null,disabled:u,...l,enableAccessibleFieldDOMStructure:!1,onChange:(k,T)=>{f.onChange(k,T),l?.onChange?.(k,T)},slots:{openPickerButton:ke},slotProps:{...l.slotProps,textField:{error:!!a,...l.slotProps?.textField,inputRef:f.ref},actionBar:{actions:[],...l.slotProps?.actionBar}}},r),oe(v,{name:r,disableIcon:h,control:s})]})})},br=R(hr);export{Qe as Checkbox,bo as CreatableV2,Ao as DatePicker,v as FieldError,K as FieldInfo,x as FieldLabel,Ko as Form,ie as FormProvider,nt as RadioButton,jo as RadioGroup,ct as SearchableV2,Lt as SelectV2,At as Slider,_t as Switch,ir as TextField,br as TimePicker,ae as useForm};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@s_mart/form",
3
- "version": "10.2.9",
3
+ "version": "10.3.1",
4
4
  "main": "./dist/index.mjs",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.mts",
@@ -31,11 +31,11 @@
31
31
  "react-hook-form": "^7.51.0",
32
32
  "typescript": ">=5.4.2",
33
33
  "zod": "^3.22.4",
34
- "@s_mart/core": "10.1.9",
34
+ "@s_mart/core": "10.1.10",
35
35
  "@s_mart/masks": "5.3.0",
36
- "@s_mart/regular-icons": "6.0.16",
36
+ "@s_mart/regular-icons": "6.0.17",
37
37
  "@s_mart/rules": "5.2.0",
38
- "@s_mart/solid-icons": "6.0.17",
38
+ "@s_mart/solid-icons": "6.0.18",
39
39
  "@s_mart/tokens": "6.0.0",
40
40
  "@s_mart/typed": "8.0.0",
41
41
  "@s_mart/utils": "5.4.1"
@@ -51,7 +51,7 @@
51
51
  "@types/react-dom": "^18.3.1",
52
52
  "dayjs": "^1.11.10",
53
53
  "typescript": ">=5.4.2",
54
- "@s_mart/core": "10.1.9",
54
+ "@s_mart/core": "10.1.10",
55
55
  "@s_mart/masks": "5.3.0",
56
56
  "@s_mart/rules": "5.2.0",
57
57
  "@s_mart/tokens": "6.0.0",