@s_mart/form 10.0.0-beta.17 → 10.0.0-beta.19

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
@@ -38,9 +38,9 @@ declare const _default$6: ({ name, rules, defaultValue, shouldUnregister, contro
38
38
 
39
39
  type CreatableV2Props<FieldValue, Multiple extends boolean | undefined = undefined, DisableClearable extends boolean | undefined = undefined, FreeSolo extends boolean | undefined = undefined> = WithRequired<Omit<AutocompleteProps<FieldValue, Multiple, DisableClearable, FreeSolo>, 'renderInput' | 'options' | 'size' | 'onInputChange' | 'onChange' | 'defaultValue' | 'value'>, 'getOptionKey' | 'getOptionLabel'> & UseControllerProps & {
40
40
  options: FieldValue[];
41
- slotProps?: AutocompleteProps<FieldValue, Multiple, DisableClearable, FreeSolo>['slotProps'] & {
41
+ slotProps?: AutocompleteProps<FieldValue, Multiple, DisableClearable, FreeSolo>['slotProps'] & Partial<{
42
42
  textField: Omit<TextFieldProps$1<'outlined'>, 'variant'>;
43
- };
43
+ }>;
44
44
  label?: React.ReactNode;
45
45
  required?: boolean;
46
46
  /**
@@ -100,8 +100,7 @@ type CreatableV2Props<FieldValue, Multiple extends boolean | undefined = undefin
100
100
  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;
101
101
  declare const _default$5: typeof CreatableV2;
102
102
 
103
- type DatePickerProps = UseControllerProps & Pick<TextFieldProps$1, 'label' | 'error' | 'helperText' | 'size' | 'fullWidth' | 'variant' | 'autoFocus' | 'placeholder'> & {
104
- datePickerProps?: Partial<DatePickerProps$1<any>>;
103
+ type DatePickerProps = DatePickerProps$1 & UseControllerProps & {
105
104
  /**
106
105
  * Se `true` irá adicionar um asterisco ao label do campo
107
106
  *
@@ -124,7 +123,7 @@ type DatePickerProps = UseControllerProps & Pick<TextFieldProps$1, 'label' | 'er
124
123
  disableIconError?: boolean;
125
124
  };
126
125
 
127
- declare const _default$4: ({ rules, name, defaultValue, shouldUnregister, control: controlFromProps, datePickerProps, label, required, placeholder, disabled, disableIconError, ...rest }: DatePickerProps) => react_jsx_runtime.JSX.Element;
126
+ declare const _default$4: ({ rules, name, defaultValue, shouldUnregister, control: controlFromProps, label, required, disabled, disableIconError, ...rest }: DatePickerProps) => react_jsx_runtime.JSX.Element;
128
127
 
129
128
  type FieldLabelProps = {
130
129
  label: React.ReactNode;
@@ -472,8 +471,7 @@ type TextFieldProps = TextFieldProps$1 & UseControllerProps & {
472
471
 
473
472
  declare const _default$1: ({ name, rules, defaultValue, shouldUnregister, control: controlFromProps, label, required, mask, variant, info, parse, format, onInputChange, disableIconError, ...rest }: TextFieldProps) => react_jsx_runtime.JSX.Element;
474
473
 
475
- type TimePickerProps = UseControllerProps & Pick<TextFieldProps$1, 'label' | 'error' | 'helperText' | 'size' | 'fullWidth' | 'variant' | 'autoFocus' | 'placeholder'> & {
476
- timePickerProps?: Partial<TimePickerProps$1<any>>;
474
+ type TimePickerProps = TimePickerProps$1 & UseControllerProps & {
477
475
  /**
478
476
  * Se `true` irá adicionar um asterisco ao label do campo
479
477
  *
@@ -496,6 +494,6 @@ type TimePickerProps = UseControllerProps & Pick<TextFieldProps$1, 'label' | 'er
496
494
  disableIconError?: boolean;
497
495
  };
498
496
 
499
- declare const _default: ({ rules, defaultValue, shouldUnregister, name, control: controlFromProps, required, label, timePickerProps, placeholder, disabled, disableIconError, ...rest }: TimePickerProps) => react_jsx_runtime.JSX.Element;
497
+ declare const _default: ({ rules, defaultValue, shouldUnregister, name, control: controlFromProps, required, label, disabled, disableIconError, ...rest }: TimePickerProps) => react_jsx_runtime.JSX.Element;
500
498
 
501
499
  export { _default$6 as Checkbox, type CheckboxProps, _default$5 as CreatableV2, type CreatableV2Props, _default$4 as DatePicker, type DatePickerProps, FieldError, type FieldErrorProps, FieldInfo, type FieldInfoProps, FieldLabel, type FieldLabelProps, type FooterPropsV2, Form, FormProvider, type IFormProps, type IFormProviderProps, type IUseFormProps, type Masks, RadioButton, RadioGroup, type RadioGroupProps, type RadioProps, _default$3 as SearchableV2, type SearchableV2Props, _default$2 as SelectV2, type SelectV2Props, type SelectV2ReturnValueProps, Slider, type SliderProps, Switch, type SwitchProps, _default$1 as TextField, type TextFieldProps, _default as TimePicker, type TimePickerProps, useForm };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import{useController as Ge,useFormContext as Ne}from"react-hook-form";import{Checkbox as Ue,FormControlLabel as He}from"@mui/material";import{Indicator as Be}from"@s_mart/core";import{useFormState as De}from"react-hook-form";var E=(e,o)=>o.replace(/[[\]]/g,"").split(".").reduce((l,a)=>l?.[a],e);import{jsx as Ae}from"react/jsx-runtime";var Me=({name:e,disableIcon:o,control:t})=>{let l=De({control:t,name:e}),a=E(l?.errors,e);return a?Ae(Be,{severity:"error",icon:o?!1:void 0,children:a?.message}):null},V=Me;import{Typography as me}from"@mui/material";import{toRem as Oe}from"@s_mart/utils";import{jsx as ue,jsxs as ze}from"react/jsx-runtime";var $e=({label:e,required:o,regular:t})=>ze("span",{style:{display:"flex",alignItems:"center",gap:Oe(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:"*"})]}),P=$e;var h=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 qe}from"react";var B=qe;import{jsx as Q,jsxs as We}from"react/jsx-runtime";var _e=({name:e,rules:o,defaultValue:t,shouldUnregister:l,control:a,label:m,labelPlacement:u,required:s,disableIconError:g,onChange:c,...T})=>{let y=Ne()?.control,d=a??y;if(!d)throw new h("Checkbox");let{field:i}=Ge({control:d,name:e,rules:o,defaultValue:t,shouldUnregister:l});return We("span",{children:[Q(He,{control:Q(Ue,{checked:!!i.value,value:i.value??"",defaultValue:i.value,onChange:(p,k)=>{i.onChange(p,k),c?.(p,k)},...T},e),label:Q(P,{label:m,required:s,regular:!0}),labelPlacement:u||"end"}),Q(V,{name:e,disableIcon:g,control:d})]})},Ke=B(_e);import{forwardRef as eo,useCallback as oo,useState as to}from"react";import{useController as ro,useFormContext as lo,useFormState as io}from"react-hook-form";import no from"lodash-es/isObject";import ao from"lodash-es/isEmpty";import so from"lodash-es/isEqual";import{Autocomplete as po,TextField as mo,Divider as ye,Button as uo}from"@mui/material";import{LIcon as re}from"@s_mart/core";import{linePlus as Fe,linePen as fo}from"@s_mart/solid-icons";import{toRem as xe}from"@s_mart/utils";import{css as Ye,styled as Je}from"@mui/material";import{toRem as Z}from"@s_mart/utils";var fe=Ye`
1
+ import{useController as Ge,useFormContext as Ne}from"react-hook-form";import{Checkbox as Ue,FormControlLabel as He}from"@mui/material";import{Indicator as De}from"@s_mart/core";import{useFormState as Be}from"react-hook-form";var L=(e,o)=>o.replace(/[[\]]/g,"").split(".").reduce((l,n)=>l?.[n],e);import{jsx as Ae}from"react/jsx-runtime";var Me=({name:e,disableIcon:o,control:t})=>{let l=Be({control:t,name:e}),n=L(l?.errors,e);return n?Ae(De,{severity:"error",icon:o?!1:void 0,children:n?.message}):null},v=Me;import{Typography as me}from"@mui/material";import{toRem as Oe}from"@s_mart/utils";import{jsx as ue,jsxs as ze}from"react/jsx-runtime";var $e=({label:e,required:o,regular:t})=>ze("span",{style:{display:"flex",alignItems:"center",gap:Oe(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:"*"})]}),P=$e;var x=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 qe}from"react";var E=qe;import{jsx as X,jsxs as We}from"react/jsx-runtime";var _e=({name:e,rules:o,defaultValue:t,shouldUnregister:l,control:n,label:f,labelPlacement:c,required:d,disableIconError:h,onChange:i,...V})=>{let p=Ne()?.control,m=n??p;if(!m)throw new x("Checkbox");let{field:s}=Ge({control:m,name:e,rules:o,defaultValue:t,shouldUnregister:l});return We("span",{children:[X(He,{control:X(Ue,{checked:!!s.value,value:s.value??"",defaultValue:s.value,onChange:(a,S)=>{s.onChange(a,S),i?.(a,S)},...V},e),label:X(P,{label:f,required:d,regular:!0}),labelPlacement:c||"end"}),X(v,{name:e,disableIcon:h,control:m})]})},Ke=E(_e);import{forwardRef as eo,useCallback as oo,useState as to}from"react";import{useController as ro,useFormContext as lo,useFormState as io}from"react-hook-form";import no from"lodash-es/isObject";import ao from"lodash-es/isEmpty";import so from"lodash-es/isEqual";import{Autocomplete as po,TextField as mo,Divider as Fe,Button as uo}from"@mui/material";import{LIcon as te}from"@s_mart/core";import{linePlus as ye,linePen as fo}from"@s_mart/solid-icons";import{toRem as Pe}from"@s_mart/utils";import{css as Ye,styled as Je}from"@mui/material";import{toRem as Q}from"@s_mart/utils";var fe=Ye`
2
2
  display: flex;
3
3
  align-items: center;
4
4
  justify-content: center;
@@ -27,7 +27,7 @@ import{useController as Ge,useFormContext as Ne}from"react-hook-form";import{Che
27
27
 
28
28
  .divider {
29
29
  width: 1px;
30
- height: ${Z(20)};
30
+ height: ${Q(20)};
31
31
  background-color: ${({theme:e})=>e.palette.grey[400]};
32
32
  }
33
33
 
@@ -38,9 +38,9 @@ import{useController as Ge,useFormContext as Ne}from"react-hook-form";import{Che
38
38
  color: ${({theme:e})=>e.palette.grey[600]};
39
39
  border-radius: 50%;
40
40
 
41
- margin: 0 ${Z(6)};
42
- width: ${Z(28)};
43
- height: ${Z(28)};
41
+ margin: 0 ${Q(6)};
42
+ width: ${Q(28)};
43
+ height: ${Q(28)};
44
44
 
45
45
  &:hover {
46
46
  cursor: pointer;
@@ -49,22 +49,22 @@ import{useController as Ge,useFormContext as Ne}from"react-hook-form";import{Che
49
49
  }
50
50
  }
51
51
  }
52
- `;import{Tooltip as Xe}from"@mui/material";import{LIcon as Qe}from"@s_mart/core";import{lineInfoCircle as Ze}from"@s_mart/solid-icons";import{jsx as te}from"react/jsx-runtime";var je=({title:e})=>te(Xe,{title:e,placement:"top",children:te("div",{style:{width:"fit-content"},children:te(Qe,{icon:Ze,color:"#757575"})})}),H=je;import{Fragment as le,jsx as S,jsxs as A}from"react/jsx-runtime";import{createElement as Fo}from"react";function co(e){let{name:o,rules:t,defaultValue:l,shouldUnregister:a,control:m,label:u,required:s,options:g,footer:c,showCreatableButton:T=!0,showEditableButton:y,onEditOption:d,onCreateOption:i,getOptionKey:p,getOptionLabel:k,getOptionAfterLabel:F,multiple:R,info:I,noOptionsText:n,onChange:b,onInputChange:$,placeholder:z,...x}=e,[U,D]=to(""),f=lo()?.control,r=m??f;if(!r)throw new h("CreatableV2");let v=io({control:r,name:o}),L=E(v.errors,o),_=!T||x.disabled,{field:K}=ro({name:o,control:r,rules:t,defaultValue:l,shouldUnregister:a}),ke=w=>{let C=0;return e.slotProps?.textField?.slotProps?.input||(C+=2.5),_||(C+=2.56,pe(w)&&(C+=2.56)),!x.disableClearable&&!x.disabled&&(C+=1.3),`${C}rem`},pe=w=>x.disabled?!1:y&&no(w)&&!ao(w),we=()=>x.disabled?!1:T,de=oo(()=>{typeof i<"u"&&(i(U),D(""))},[U,i]),Le=()=>{d?.(K.value)},Re=K.value?K.value:R?[]:null;return A("div",{style:{display:"flex",flexDirection:"column"},children:[A("div",{style:{display:"flex"},children:[u&&S(P,{label:u,required:s}),I&&S(H,{title:I})]}),S(ce,{children:S(po,{fullWidth:!0,onChange:(w,C)=>{D(""),K.onChange(C),b?.(C)},onInputChange:(w,C,W)=>{W==="input"&&(D(C),$?.(C))},slotProps:{...x.slotProps,listbox:{component:eo(function(C,W){return A(le,{children:[S("ul",{...C,ref:W}),typeof c<"u"?A("div",{...C,children:[S("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:S(ye,{})}),c()]},"creatable-footer"):null]})})}},value:Re,options:g,multiple:R,readOnly:x.disabled,noOptionsText:A(le,{children:[n||"Nenhuma op\xE7\xE3o encontrada",!_&&A(uo,{sx:{justifyContent:"flex-start",padding:`${xe(6)} ${xe(-16)}`,margin:0},fullWidth:!0,onClick:de,variant:"text",startIcon:S(re,{icon:Fe}),children:["Adicionar ",`"${U}"`]}),typeof c<"u"&&A(le,{children:[S("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:S(ye,{})}),c()]})]}),isOptionEqualToValue:(w,C)=>so(w,C),getOptionLabel:k,getOptionKey:p,renderOption:typeof F=="function"?(w,C)=>{let W=F(C),Ee=p(C);return Fo("li",{...w,key:Ee},A("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[S("span",{children:k(C)}),typeof W=="string"?S("span",{children:W}):W]}))}:void 0,...x,sx:{"& div.MuiInputBase-root":{paddingRight:`${ke(K.value)} !important`},...x.sx},onBlur:w=>{x?.onBlur?.(w),D("")},renderInput:w=>S(mo,{placeholder:z,...w,error:!!L,...e.slotProps?.textField,slotProps:{input:{...w.InputProps,...e.slotProps?.textField?.slotProps?.input,inputRef:K.ref,endAdornment:A("div",{className:"endAdornments",children:[w.InputProps.endAdornment,e.slotProps?.textField?.slotProps?.input?.endAdornment??null,pe(K.value)?A("div",{className:"editable",children:[S("div",{className:"divider"}),S("div",{className:"button",onKeyUp:Le,children:S(re,{icon:fo,size:"24px",removeMargin:!0})})]}):null,we()&&A("div",{className:"creatable",children:[S("div",{className:"divider"}),S("div",{className:"button",onKeyUp:de,children:S(re,{icon:Fe,size:"24px",removeMargin:!0})})]})]})}}})},o)}),S(V,{name:o,control:r})]})}var yo=B(co);import{Stack as go,TextField as vo}from"@mui/material";import{AdapterDayjs as Co}from"@mui/x-date-pickers/AdapterDayjs";import{DatePicker as Vo}from"@mui/x-date-pickers/DatePicker";import{LocalizationProvider as So}from"@mui/x-date-pickers/LocalizationProvider";import{ptBR as To}from"@mui/x-date-pickers/locales/ptBR";import{composeValidators as Io,date as he}from"@s_mart/rules";import ko from"dayjs/locale/pt-br";import{useController as wo,useFormContext as Lo,useFormState as Ro}from"react-hook-form";import{IconButton as xo,styled as Po}from"@mui/material";import{toRem as q}from"@s_mart/utils";var ho=e=>{switch(e){case"small":return q(16);case"large":return q(24);default:return q(20)}},bo=e=>{switch(e){case"small":return`${q(2)} ${q(8)}`;case"large":return`${q(10)}`;default:return`${q(6)} ${q(8)}`}},Pe=Po(xo)`
52
+ `;import{Tooltip as Xe}from"@mui/material";import{LIcon as Qe}from"@s_mart/core";import{lineInfoCircle as Ze}from"@s_mart/solid-icons";import{jsx as oe}from"react/jsx-runtime";var je=({title:e})=>oe(Xe,{title:e,placement:"top",children:oe("div",{style:{width:"fit-content"},children:oe(Qe,{icon:Ze,color:"#757575"})})}),H=je;import{Fragment as re,jsx as C,jsxs as B}from"react/jsx-runtime";import{createElement as yo}from"react";function co(e){let{name:o,rules:t,defaultValue:l,shouldUnregister:n,control:f,label:c,required:d,options:h,footer:i,showCreatableButton:V=!0,showEditableButton:p,onEditOption:m,onCreateOption:s,getOptionKey:a,getOptionLabel:S,getOptionAfterLabel:F,multiple:I,info:T,noOptionsText:A,onChange:N,onInputChange:O,placeholder:$,...y}=e,[U,R]=to(""),u=lo()?.control,r=f??u;if(!r)throw new x("CreatableV2");let b=io({control:r,name:o}),w=L(b.errors,o),_=!V||y.disabled,{field:K}=ro({name:o,control:r,rules:t,defaultValue:l,shouldUnregister:n}),Ie=k=>{let g=0;return e.slotProps?.textField?.slotProps?.input||(g+=2.5),_||(g+=2.56,pe(k)&&(g+=2.56)),!y.disableClearable&&!y.disabled&&(g+=1.3),`${g}rem`},pe=k=>y.disabled?!1:p&&no(k)&&!ao(k),we=()=>y.disabled?!1:V,de=oo(()=>{typeof s<"u"&&(s(U),R(""))},[U,s]),Le=()=>{m?.(K.value)},Ee=K.value?K.value:I?[]:null;return B("div",{style:{display:"flex",flexDirection:"column"},children:[B("div",{style:{display:"flex"},children:[c&&C(P,{label:c,required:d}),T&&C(H,{title:T})]}),C(ce,{children:C(po,{fullWidth:!0,onChange:(k,g)=>{R(""),K.onChange(g),N?.(g)},onInputChange:(k,g,W)=>{W==="input"&&(R(g),O?.(g))},slotProps:{...y.slotProps,listbox:{component:eo(function(g,W){return B(re,{children:[C("ul",{...g,ref:W}),typeof i<"u"?B("div",{...g,children:[C("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:C(Fe,{})}),i()]},"creatable-footer"):null]})})}},value:Ee,options:h,multiple:I,readOnly:y.disabled,noOptionsText:B(re,{children:[A||"Nenhuma op\xE7\xE3o encontrada",!_&&B(uo,{sx:{justifyContent:"flex-start",padding:`${Pe(6)} ${Pe(-16)}`,margin:0},fullWidth:!0,onClick:de,variant:"text",startIcon:C(te,{icon:ye}),children:["Adicionar ",`"${U}"`]}),typeof i<"u"&&B(re,{children:[C("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:C(Fe,{})}),i()]})]}),isOptionEqualToValue:(k,g)=>so(k,g),getOptionLabel:S,getOptionKey:a,renderOption:typeof F=="function"?(k,g)=>{let W=F(g),Re=a(g);return yo("li",{...k,key:Re},B("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:`${Ie(K.value)} !important`},...y.sx},onBlur:k=>{y?.onBlur?.(k),R("")},renderInput:k=>C(mo,{placeholder:$,...k,error:!!w,...e.slotProps?.textField,slotProps:{input:{...k.InputProps,...e.slotProps?.textField?.slotProps?.input,inputRef:K.ref,endAdornment:B("div",{className:"endAdornments",children:[k.InputProps.endAdornment,e.slotProps?.textField?.slotProps?.input?.endAdornment??null,pe(K.value)?B("div",{className:"editable",children:[C("div",{className:"divider"}),C("div",{className:"button",onKeyUp:Le,children:C(te,{icon:fo,size:"24px",removeMargin:!0})})]}):null,we()&&B("div",{className:"creatable",children:[C("div",{className:"divider"}),C("div",{className:"button",onKeyUp:de,children:C(te,{icon:ye,size:"24px",removeMargin:!0})})]})]})}}})},o)}),C(v,{name:o,control:r})]})}var Fo=E(co);import{Stack as go}from"@mui/material";import{AdapterDayjs as vo}from"@mui/x-date-pickers/AdapterDayjs";import{DatePicker as Co}from"@mui/x-date-pickers";import{LocalizationProvider as Vo}from"@mui/x-date-pickers/LocalizationProvider";import{ptBR as So}from"@mui/x-date-pickers/locales";import{composeValidators as To,date as he}from"@s_mart/rules";import{useController as ko,useFormContext as Io,useFormState as wo}from"react-hook-form";import{IconButton as Po,styled as xo}from"@mui/material";import{toRem as z}from"@s_mart/utils";var ho=e=>{switch(e){case"small":return z(16);case"large":return z(24);default:return z(20)}},bo=e=>{switch(e){case"small":return`${z(2)} ${z(8)}`;case"large":return`${z(10)}`;default:return`${z(6)} ${z(8)}`}},xe=xo(Po)`
53
53
  margin: 0px;
54
54
 
55
55
  padding: ${({size:e})=>bo(e)};
56
- border-radius: 0 ${q(4)} ${q(4)} 0;
56
+ border-radius: 0 ${z(4)} ${z(4)} 0;
57
57
 
58
58
  svg {
59
59
  width: ${({size:e})=>ho(e)} !important;
60
60
  }
61
- `;import{jsx as j,jsxs as Mo}from"react/jsx-runtime";import{createElement as Do}from"react";var Eo=({rules:e,name:o,defaultValue:t,shouldUnregister:l,control:a,datePickerProps:m,label:u,required:s,placeholder:g,disabled:c,disableIconError:T,...y})=>{let d=Lo()?.control,i=a??d;if(!i)throw new h("DatePicker");let p=Ro({control:i,name:o}),k=E(p.errors,o),F=m?.format||"DD/MM/YYYY",R=e?Io([he(F),e]):he(F),{field:I}=wo({control:i,name:o,rules:R,defaultValue:t,shouldUnregister:l});return j(So,{dateAdapter:Co,adapterLocale:ko,localeText:To.components.MuiLocalizationProvider.defaultProps.localeText,children:Mo(go,{children:[u&&j(P,{label:u,required:s}),Do(Vo,{...m,key:o,value:I.value??null,format:F,onChange:(n,b)=>{I.onChange(n,b),m?.onChange?.(n,b)},disabled:c,slots:{textField:vo,openPickerButton:n=>j(Pe,{...n,size:y.size})},slotProps:{textField:n=>({variant:"outlined",...n,error:!!k,...y,inputProps:{...n.inputProps,placeholder:g||n.inputProps?.placeholder},InputProps:{...n.InputProps,inputRef:b=>{I.ref(b),typeof n.inputRef=="function"&&n.inputRef(b)}}})}}),j(V,{name:o,disableIcon:T,control:i})]})})},Bo=B(Eo);import{FormProvider as Ao}from"react-hook-form";import{jsx as be}from"react/jsx-runtime";function Oo({children:e,style:o,onSubmit:t,...l}){return be(Ao,{...l,children:be("form",{onSubmit:a=>{a.preventDefault(),a.stopPropagation(),t(a)},style:o,children:e})})}var ie=Oo;import{useEffect as $o}from"react";import{useForm as zo}from"react-hook-form";import{zodResolver as qo}from"@hookform/resolvers/zod";var Go=({disableDefaultValuesUpdate:e,onSubmit:o,...t})=>{let l=zo({...t,resolver:t.schema&&qo(t.schema)});return $o(()=>{e||l.reset(t.defaultValues)},[t.defaultValues,l.reset]),{...l,onSubmit:l.handleSubmit(a=>o(a,l))}},ne=Go;import{jsx as Ho}from"react/jsx-runtime";function No({children:e,style:o,...t}){let l=ne(t);return Ho(ie,{...l,style:o,children:typeof e=="function"?e(l):e})}var Uo=No;import{RadioGroup as _o,Stack as Ko}from"@mui/material";import{useController as Wo,useFormContext as Yo}from"react-hook-form";import{jsx as ae,jsxs as Qo}from"react/jsx-runtime";var Jo=({name:e,rules:o,defaultValue:t,shouldUnregister:l,control:a,label:m,required:u,children:s,orientation:g="row",disableIconError:c,...T})=>{let y=Yo()?.control,d=a??y;if(!d)throw new h("RadioGroup");let{field:i}=Wo({control:d,name:e,rules:o,defaultValue:t,shouldUnregister:l});return Qo(Ko,{children:[m&&ae(P,{label:m,required:u}),ae(_o,{value:i.value||"",name:e,...T,onChange:p=>{T?.onChange?.(p,p.target?.value),i.onChange(p)},style:{display:"flex",flexDirection:g},children:s},e),ae(V,{name:e,disableIcon:c,control:d})]})},Xo=Jo;import{FormControlLabel as Zo,Grid2 as jo,Radio as et}from"@mui/material";import{jsx as ee}from"react/jsx-runtime";var ot=({label:e,labelPlacement:o,...t})=>ee(jo,{sx:{display:"flex",flexDirection:"column"},children:ee(Zo,{control:ee(et,{...t}),label:ee(P,{label:e}),labelPlacement:o||"end"})}),tt=ot;import{Autocomplete as rt,Divider as ge,TextField as lt}from"@mui/material";import it from"lodash-es/isEqual";import{forwardRef as nt}from"react";import{useController as at,useFormContext as st,useFormState as pt}from"react-hook-form";import{Fragment as se,jsx as M,jsxs as Y}from"react/jsx-runtime";import{createElement as ut}from"react";var dt=e=>{let{name:o,rules:t,defaultValue:l,shouldUnregister:a,control:m,label:u,required:s,options:g,textFieldProps:c,noOptionsText:T,footer:y,multiple:d,info:i,placeholder:p,onChange:k,onInputChange:F,getOptionAfterLabel:R,getOptionLabel:I,getOptionKey:n,...b}=e,$=st()?.control,z=m??$;if(!z)throw new h("SearchableV2");let x=pt({control:z,name:o}),U=E(x.errors,o),{field:D}=at({name:o,control:z,rules:t,defaultValue:l,shouldUnregister:a}),f=D.value?D.value:d?[]:null;return Y("div",{style:{display:"flex",flexDirection:"column"},children:[Y("div",{style:{display:"flex"},children:[u&&M(P,{label:u,required:s}),i&&M(H,{title:i})]}),M(rt,{onChange:(r,v)=>{D.onChange(v),k?.(v)},onInputChange:(r,v,L)=>{L==="input"&&F?.(v)},value:f,options:g,multiple:d,readOnly:b.disabled,slotProps:{...b.slotProps,listbox:{component:nt(function(v,L){return Y(se,{children:[M("ul",{...v,ref:L}),typeof y<"u"?Y("div",{...v,children:[M("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:M(ge,{})}),y()]},"searchable-footer"):null]})})}},noOptionsText:Y(se,{children:[T||"Nenhuma op\xE7\xE3o encontrada",typeof y<"u"?Y(se,{children:[M("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:M(ge,{})}),y()]}):null]}),isOptionEqualToValue:(r,v)=>it(r,v),getOptionLabel:I,getOptionKey:n,renderOption:typeof R=="function"?(r,v)=>{let L=R(v),_=n(v);return ut("li",{...r,key:_},Y("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[M("span",{children:I(v)}),typeof L=="string"?M("span",{children:L}):L]}))}:void 0,...b,renderInput:r=>M(lt,{error:!!U,placeholder:p,...r,...c,inputRef:D.ref})},o),M(V,{name:o,control:z})]})},mt=B(dt);import{useState as yt}from"react";import{useController as Ft,useFormContext as xt,useFormState as Pt}from"react-hook-form";import{IconButton as ht,LIcon as bt}from"@s_mart/core";import{lineTimes as gt}from"@s_mart/regular-icons";import{colorPalette as vt}from"@s_mart/tokens";import{Select as Ct,MenuItem as Vt,Divider as St}from"@mui/material";import{colorPalette as ft}from"@s_mart/tokens";import{jsx as ct}from"react/jsx-runtime";var ve=({value:e,placeholder:o,getOptionLabel:t})=>e===null||e?.length===0?ct("p",{style:{color:ft.neutral[100]},children:o}):t(e);import{Fragment as kt,jsx as O,jsxs as J}from"react/jsx-runtime";var Tt=e=>{let{name:o,rules:t,defaultValue:l,shouldUnregister:a,control:m,label:u,required:s,options:g,placeholder:c,clearable:T,info:y,footer:d,onChange:i,variant:p="outlined",getOptionKey:k,getOptionLabel:F,getOptionAfterLabel:R,getOptionIcon:I,...n}=e,b=xt()?.control,$=m??b,[z,x]=yt(!1);if(!$)throw new h("SelectV2");let U=Pt({control:$,name:o}),D=E(U.errors,o),{field:f}=Ft({control:$,name:o,rules:t,defaultValue:l,shouldUnregister:a});return J("div",{style:{display:"flex",flexDirection:"column"},children:[J("div",{style:{display:"flex"},children:[u&&O(P,{label:u,required:s}),y&&O(H,{title:y})]}),J(Ct,{open:z,onOpen:()=>x(!0),onClose:()=>x(!1),displayEmpty:!!c,variant:p,autoComplete:"off",value:f.value||null,renderValue:r=>O(ve,{getOptionLabel:F,placeholder:c,value:r}),onChange:r=>{console.log(r),f.onChange(r.target.value),i?.(r.target.value)},error:!!D,size:n.size||"medium",inputRef:f.ref,...n,endAdornment:J(kt,{children:[n.endAdornment,!!(T&&f.value)&&O(ht,{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),i?.(null)},children:O(bt,{icon:gt,color:vt.neutral[100],size:"25px",removeMargin:!0})})]}),children:[g.map(r=>{let v=k(r),L=F(r),_=I?.(r);return O(Vt,{value:r,children:J("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[_!==void 0?J("div",{style:{display:"flex",alignItems:"center"},children:[_,L]}):L,O("span",{children:R?.(r)??null})]})},v)}),d!==void 0&&J("div",{children:[O("div",{style:{padding:"8px 16px"},children:O(St,{})},"footer-divider"),O("div",{children:d({closeSelect:()=>x(!1)})},"footer-content")]},"footer")]},o),O(V,{name:o,control:$})]})},It=B(Tt);import{useController as wt,useFormContext as Lt}from"react-hook-form";import{Slider as Rt}from"@mui/material";import{jsx as Dt}from"react/jsx-runtime";var Et=({name:e,rules:o,defaultValue:t,shouldUnregister:l,control:a,...m})=>{let u=Lt()?.control,s=a??u;if(!s)throw new h("Slider");let{field:g}=wt({control:s,name:e,rules:o,defaultValue:t,shouldUnregister:l});return Dt(Rt,{value:g.value||m?.min||0,onChange:g.onChange,valueLabelDisplay:"auto",...m},e)},Bt=Et;import{FormControlLabel as Mt,Stack as At,Switch as Ot}from"@mui/material";import{useController as $t,useFormContext as zt}from"react-hook-form";import{useCallback as qt}from"react";import{jsx as oe,jsxs as Ut}from"react/jsx-runtime";var Gt=({name:e,rules:o,defaultValue:t,defaultChecked:l,shouldUnregister:a,control:m,label:u,labelPlacement:s="end",disableIconError:g,onChange:c,...T})=>{let y=zt()?.control,d=m??y;if(!d)throw new h("Switch");let{field:i}=$t({control:d,name:e,rules:o,defaultValue:l??t??!1,shouldUnregister:a}),p=qt((k,F)=>{i.onChange(F),c?.(k,F)},[i,c]);return Ut(At,{children:[oe(Mt,{control:oe(Ot,{...T,...i,checked:!!i.value,onChange:p}),label:oe(P,{label:u}),labelPlacement:s}),oe(V,{name:e,disableIcon:g,control:d})]})},Nt=Gt;import{InputAdornment as Ht,Stack as _t,TextField as Kt,Tooltip as Wt}from"@mui/material";import{LIcon as Ce}from"@s_mart/core";import*as Ve from"@s_mart/masks";import{lineEye as Yt,lineEyeSlash as Jt,lineInfoCircle as Xt}from"@s_mart/solid-icons";import{useRef as Qt,useState as Zt}from"react";import{useController as jt,useFormContext as er,useFormState as or}from"react-hook-form";import{jsx as G,jsxs as Se}from"react/jsx-runtime";var tr=({name:e,rules:o,defaultValue:t,shouldUnregister:l,control:a,label:m,required:u,mask:s,variant:g="outlined",info:c,parse:T,format:y,onInputChange:d,disableIconError:i,...p})=>{let k=er()?.control,F=a??k,R=Qt(t||void 0);if(!F)throw new h("TextField");let[I,n]=Zt(!1),b=f=>{let r=f;return r=y?.(f)??f,s?Ve?.[s]?.format(r):r},$=f=>{let r=f;return r=T?.(f)??r,s?Ve?.[s]?.parse(r,R.current):r},z=f=>{if(!f||s!=="porcentagem"&&s!=="porcentagem0")return;f?.stopPropagation();let r=(f?.target).value;if(r){let v=String(r);if(v.length>0){let L=v.indexOf("%");L>-1&&(f.currentTarget.selectionEnd=L)}}},{field:x}=jt({control:F,name:e,rules:o,defaultValue:t,shouldUnregister:l}),U=or({control:F,name:e}),D=E(U.errors,e);return Se(_t,{children:[Se("div",{style:{display:"flex"},children:[m&&G("div",{children:G(P,{label:m,required:u})}),c&&G("div",{children:G(Wt,{title:c,placement:"top",children:G("div",{style:{width:"fit-content"},children:G(Ce,{icon:Xt,color:"#757575"})})})})]}),G(Kt,{variant:g,defaultValue:t,value:b(x.value||(x.value!=0?"":x.value)),onChange:f=>{let r=$(f?.target?.value);x.onChange(r),d?.(r),R.current=f.target.value},error:!!D,...p,type:p.type==="password"?I?"text":"password":p.type,autoComplete:p.autoComplete||"off",slotProps:{input:{onKeyDown:z,inputRef:x.ref,endAdornment:p.type==="password"&&G(Ht,{position:"start",onClick:()=>n(!I),style:{cursor:"pointer"},children:G(Ce,{icon:I?Yt:Jt,size:"24px",removeMargin:!0})}),...p.slotProps?.input}}},e),G(V,{name:e,disableIcon:i,control:F})]})},rr=B(tr);import{Stack as sr,TextField as pr}from"@mui/material";import{AdapterDayjs as dr}from"@mui/x-date-pickers/AdapterDayjs";import{LocalizationProvider as mr}from"@mui/x-date-pickers/LocalizationProvider";import{TimePicker as ur}from"@mui/x-date-pickers/TimePicker";import{ptBR as fr}from"@mui/x-date-pickers/locales/ptBR";import{composeValidators as cr,time as Ie}from"@s_mart/rules";import yr from"dayjs/locale/pt-br";import{useController as Fr,useFormContext as xr,useFormState as Pr}from"react-hook-form";import{styled as lr}from"@mui/material";import{IconButton as ir}from"@mui/material";import{toRem as N}from"@s_mart/utils";var nr=e=>{switch(e){case"small":return N(16);case"large":return N(24);default:return N(20)}},ar=e=>{switch(e){case"small":return`${N(2)} ${N(8)}`;case"large":return N(10);default:return`${N(6)} ${N(8)}`}},Te=lr(ir)`
61
+ `;import"dayjs/locale/pt-br";import{jsx as le,jsxs as Do}from"react/jsx-runtime";import{createElement as Ro}from"react";var Lo=({rules:e,name:o,defaultValue:t,shouldUnregister:l,control:n,label:f,required:c,disabled:d,disableIconError:h,...i})=>{let V=Io()?.control,p=n??V;if(!p)throw new x("DatePicker");let m=wo({control:p,name:o}),s=L(m.errors,o),a=i?.format||"DD/MM/YYYY",S=e?To([he(a),e]):he(a),{field:F}=ko({control:p,name:o,rules:S,defaultValue:t,shouldUnregister:l});return le(Vo,{dateAdapter:vo,localeText:So.components.MuiLocalizationProvider.defaultProps.localeText,children:Do(go,{children:[f&&le(P,{label:f,required:c}),Ro(Co,{...i,key:o,value:F.value??null,format:a,onChange:(I,T)=>{F.onChange(I,T),i?.onChange?.(I,T)},disabled:d,enableAccessibleFieldDOMStructure:!1,slots:{openPickerButton:xe},slotProps:{...i?.slotProps,textField:{error:!!s,...i.slotProps?.textField,inputRef:F.ref}}}),le(v,{name:o,disableIcon:h,control:p})]})})},Eo=E(Lo);import{FormProvider as Bo}from"react-hook-form";import{jsx as be}from"react/jsx-runtime";function Mo({children:e,style:o,onSubmit:t,...l}){return be(Bo,{...l,children:be("form",{onSubmit:n=>{n.preventDefault(),n.stopPropagation(),t(n)},style:o,children:e})})}var ie=Mo;import{useEffect as Ao}from"react";import{useForm as Oo}from"react-hook-form";import{zodResolver as $o}from"@hookform/resolvers/zod";var zo=({disableDefaultValuesUpdate:e,onSubmit:o,...t})=>{let l=Oo({...t,resolver:t.schema&&$o(t.schema)});return Ao(()=>{e||l.reset(t.defaultValues)},[t.defaultValues,l.reset]),{...l,onSubmit:l.handleSubmit(n=>o(n,l))}},ne=zo;import{jsx as No}from"react/jsx-runtime";function qo({children:e,style:o,...t}){let l=ne(t);return No(ie,{...l,style:o,children:typeof e=="function"?e(l):e})}var Go=qo;import{RadioGroup as Uo,Stack as Ho}from"@mui/material";import{useController as _o,useFormContext as Ko}from"react-hook-form";import{jsx as ae,jsxs as Jo}from"react/jsx-runtime";var Wo=({name:e,rules:o,defaultValue:t,shouldUnregister:l,control:n,label:f,required:c,children:d,orientation:h="row",disableIconError:i,...V})=>{let p=Ko()?.control,m=n??p;if(!m)throw new x("RadioGroup");let{field:s}=_o({control:m,name:e,rules:o,defaultValue:t,shouldUnregister:l});return Jo(Ho,{children:[f&&ae(P,{label:f,required:c}),ae(Uo,{value:s.value||"",name:e,...V,onChange:a=>{V?.onChange?.(a,a.target?.value),s.onChange(a)},style:{display:"flex",flexDirection:h},children:d},e),ae(v,{name:e,disableIcon:i,control:m})]})},Yo=Wo;import{FormControlLabel as Xo,Grid as Qo,Radio as Zo}from"@mui/material";import{jsx as Z}from"react/jsx-runtime";var jo=({label:e,labelPlacement:o,...t})=>Z(Qo,{sx:{display:"flex",flexDirection:"column"},children:Z(Xo,{control:Z(Zo,{...t}),label:Z(P,{label:e}),labelPlacement:o||"end"})}),et=jo;import{Autocomplete as ot,Divider as ge,TextField as tt}from"@mui/material";import rt from"lodash-es/isEqual";import{forwardRef as lt}from"react";import{useController as it,useFormContext as nt,useFormState as at}from"react-hook-form";import{Fragment as se,jsx as D,jsxs as Y}from"react/jsx-runtime";import{createElement as dt}from"react";var st=e=>{let{name:o,rules:t,defaultValue:l,shouldUnregister:n,control:f,label:c,required:d,options:h,textFieldProps:i,noOptionsText:V,footer:p,multiple:m,info:s,placeholder:a,onChange:S,onInputChange:F,getOptionAfterLabel:I,getOptionLabel:T,getOptionKey:A,...N}=e,O=nt()?.control,$=f??O;if(!$)throw new x("SearchableV2");let y=at({control:$,name:o}),U=L(y.errors,o),{field:R}=it({name:o,control:$,rules:t,defaultValue:l,shouldUnregister:n}),u=R.value?R.value:m?[]:null;return Y("div",{style:{display:"flex",flexDirection:"column"},children:[Y("div",{style:{display:"flex"},children:[c&&D(P,{label:c,required:d}),s&&D(H,{title:s})]}),D(ot,{onChange:(r,b)=>{R.onChange(b),S?.(b)},onInputChange:(r,b,w)=>{w==="input"&&F?.(b)},value:u,options:h,multiple:m,readOnly:N.disabled,slotProps:{...N.slotProps,listbox:{component:lt(function(b,w){return Y(se,{children:[D("ul",{...b,ref:w}),typeof p<"u"?Y("div",{...b,children:[D("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:D(ge,{})}),p()]},"searchable-footer"):null]})})}},noOptionsText:Y(se,{children:[V||"Nenhuma op\xE7\xE3o encontrada",typeof p<"u"?Y(se,{children:[D("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:D(ge,{})}),p()]}):null]}),isOptionEqualToValue:(r,b)=>rt(r,b),getOptionLabel:T,getOptionKey:A,renderOption:typeof I=="function"?(r,b)=>{let w=I(b),_=A(b);return dt("li",{...r,key:_},Y("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[D("span",{children:T(b)}),typeof w=="string"?D("span",{children:w}):w]}))}:void 0,...N,renderInput:r=>D(tt,{error:!!U,placeholder:a,...r,...i,inputRef:R.ref})},o),D(v,{name:o,control:$})]})},pt=E(st);import{useState as ft}from"react";import{useController as ct,useFormContext as Ft,useFormState as yt}from"react-hook-form";import{IconButton as Pt,LIcon as xt}from"@s_mart/core";import{lineTimes as ht}from"@s_mart/regular-icons";import{colorPalette as bt}from"@s_mart/tokens";import{Select as gt,MenuItem as vt,Divider as Ct}from"@mui/material";import{colorPalette as mt}from"@s_mart/tokens";import{jsx as ut}from"react/jsx-runtime";var ve=({value:e,placeholder:o,getOptionLabel:t})=>e===null||e?.length===0?ut("p",{style:{color:mt.neutral[100]},children:o}):t(e);import{Fragment as Tt,jsx as M,jsxs as J}from"react/jsx-runtime";var Vt=e=>{let{name:o,rules:t,defaultValue:l,shouldUnregister:n,control:f,label:c,required:d,options:h,placeholder:i,clearable:V,info:p,footer:m,onChange:s,variant:a="outlined",getOptionKey:S,getOptionLabel:F,getOptionAfterLabel:I,getOptionIcon:T,...A}=e,N=Ft()?.control,O=f??N,[$,y]=ft(!1);if(!O)throw new x("SelectV2");let U=yt({control:O,name:o}),R=L(U.errors,o),{field:u}=ct({control:O,name:o,rules:t,defaultValue:l,shouldUnregister:n});return J("div",{style:{display:"flex",flexDirection:"column"},children:[J("div",{style:{display:"flex"},children:[c&&M(P,{label:c,required:d}),p&&M(H,{title:p})]}),J(gt,{open:$,onOpen:()=>y(!0),onClose:()=>y(!1),displayEmpty:!!i,variant:a,autoComplete:"off",value:u.value||null,renderValue:r=>M(ve,{getOptionLabel:F,placeholder:i,value:r}),onChange:r=>{console.log(r),u.onChange(r.target.value),s?.(r.target.value)},error:!!R,size:A.size||"medium",inputRef:u.ref,...A,endAdornment:J(Tt,{children:[A.endAdornment,!!(V&&u.value)&&M(Pt,{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:M(xt,{icon:ht,color:bt.neutral[100],size:"25px",removeMargin:!0})})]}),children:[h.map(r=>{let b=S(r),w=F(r),_=T?.(r);return M(vt,{value:r,children:J("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[_!==void 0?J("div",{style:{display:"flex",alignItems:"center"},children:[_,w]}):w,M("span",{children:I?.(r)??null})]})},b)}),m!==void 0&&J("div",{children:[M("div",{style:{padding:"8px 16px"},children:M(Ct,{})},"footer-divider"),M("div",{children:m({closeSelect:()=>y(!1)})},"footer-content")]},"footer")]},o),M(v,{name:o,control:O})]})},St=E(Vt);import{useController as kt,useFormContext as It}from"react-hook-form";import{Slider as wt}from"@mui/material";import{jsx as Rt}from"react/jsx-runtime";var Lt=({name:e,rules:o,defaultValue:t,shouldUnregister:l,control:n,...f})=>{let c=It()?.control,d=n??c;if(!d)throw new x("Slider");let{field:h}=kt({control:d,name:e,rules:o,defaultValue:t,shouldUnregister:l});return Rt(wt,{value:h.value||f?.min||0,onChange:h.onChange,valueLabelDisplay:"auto",...f},e)},Et=Lt;import{FormControlLabel as Dt,Stack as Bt,Switch as Mt}from"@mui/material";import{useController as At,useFormContext as Ot}from"react-hook-form";import{useCallback as $t}from"react";import{jsx as j,jsxs as Gt}from"react/jsx-runtime";var zt=({name:e,rules:o,defaultValue:t,defaultChecked:l,shouldUnregister:n,control:f,label:c,labelPlacement:d="end",disableIconError:h,onChange:i,...V})=>{let p=Ot()?.control,m=f??p;if(!m)throw new x("Switch");let{field:s}=At({control:m,name:e,rules:o,defaultValue:l??t??!1,shouldUnregister:n}),a=$t((S,F)=>{s.onChange(F),i?.(S,F)},[s,i]);return Gt(Bt,{children:[j(Dt,{control:j(Mt,{...V,...s,checked:!!s.value,onChange:a}),label:j(P,{label:c}),labelPlacement:d}),j(v,{name:e,disableIcon:h,control:m})]})},qt=zt;import{InputAdornment as Nt,Stack as Ut,TextField as Ht,Tooltip as _t}from"@mui/material";import{LIcon as Ce}from"@s_mart/core";import*as Ve from"@s_mart/masks";import{lineEye as Kt,lineEyeSlash as Wt,lineInfoCircle as Yt}from"@s_mart/solid-icons";import{useRef as Jt,useState as Xt}from"react";import{useController as Qt,useFormContext as Zt,useFormState as jt}from"react-hook-form";import{jsx as q,jsxs as Se}from"react/jsx-runtime";var er=({name:e,rules:o,defaultValue:t,shouldUnregister:l,control:n,label:f,required:c,mask:d,variant:h="outlined",info:i,parse:V,format:p,onInputChange:m,disableIconError:s,...a})=>{let S=Zt()?.control,F=n??S,I=Jt(t||void 0);if(!F)throw new x("TextField");let[T,A]=Xt(!1),N=u=>{let r=u;return r=p?.(u)??u,d?Ve?.[d]?.format(r):r},O=u=>{let r=u;return r=V?.(u)??r,d?Ve?.[d]?.parse(r,I.current):r},$=u=>{if(!u||d!=="porcentagem"&&d!=="porcentagem0")return;u?.stopPropagation();let r=(u?.target).value;if(r){let b=String(r);if(b.length>0){let w=b.indexOf("%");w>-1&&(u.currentTarget.selectionEnd=w)}}},{field:y}=Qt({control:F,name:e,rules:o,defaultValue:t,shouldUnregister:l}),U=jt({control:F,name:e}),R=L(U.errors,e);return Se(Ut,{children:[Se("div",{style:{display:"flex"},children:[f&&q("div",{children:q(P,{label:f,required:c})}),i&&q("div",{children:q(_t,{title:i,placement:"top",children:q("div",{style:{width:"fit-content"},children:q(Ce,{icon:Yt,color:"#757575"})})})})]}),q(Ht,{variant:h,defaultValue:t,value:N(y.value||(y.value!=0?"":y.value)),onChange:u=>{let r=O(u?.target?.value);y.onChange(r),m?.(r),I.current=u.target.value},error:!!R,...a,type:a.type==="password"?T?"text":"password":a.type,autoComplete:a.autoComplete||"off",slotProps:{input:{onKeyDown:$,inputRef:y.ref,endAdornment:a.type==="password"&&q(Nt,{position:"start",onClick:()=>A(!T),style:{cursor:"pointer"},children:q(Ce,{icon:T?Kt:Wt,size:"24px",removeMargin:!0})}),...a.slotProps?.input}}},e),q(v,{name:e,disableIcon:s,control:F})]})},or=E(er);import{Stack as nr}from"@mui/material";import{AdapterDayjs as ar}from"@mui/x-date-pickers/AdapterDayjs";import{LocalizationProvider as sr}from"@mui/x-date-pickers/LocalizationProvider";import{TimePicker as pr}from"@mui/x-date-pickers/TimePicker";import{composeValidators as dr,time as ke}from"@s_mart/rules";import{useController as mr,useFormContext as ur,useFormState as fr}from"react-hook-form";import{styled as tr}from"@mui/material";import{IconButton as rr}from"@mui/material";import{toRem as G}from"@s_mart/utils";var lr=e=>{switch(e){case"small":return G(16);case"large":return G(24);default:return G(20)}},ir=e=>{switch(e){case"small":return`${G(2)} ${G(8)}`;case"large":return G(10);default:return`${G(6)} ${G(8)}`}},Te=tr(rr)`
62
62
  margin: 0px;
63
63
 
64
- padding: ${({size:e})=>ar(e)};
65
- border-radius: 0 ${N(4)} ${N(4)} 0;
64
+ padding: ${({size:e})=>ir(e)};
65
+ border-radius: 0 ${G(4)} ${G(4)} 0;
66
66
 
67
67
  svg {
68
- width: ${({size:e})=>nr(e)} !important;
68
+ width: ${({size:e})=>lr(e)} !important;
69
69
  }
70
- `;import{jsx as X,jsxs as gr}from"react/jsx-runtime";var hr=({rules:e,defaultValue:o,shouldUnregister:t,name:l,control:a,required:m,label:u,timePickerProps:s,placeholder:g,disabled:c,disableIconError:T,...y})=>{let d=xr()?.control,i=a??d;if(!i)throw new h("TimePicker");let p=Pr({control:i,name:l}),k=E(p.errors,l),F=s?.format||"HH:mm",R=e?cr([Ie(F),e]):Ie(F),{field:I}=Fr({control:i,name:l,rules:R,defaultValue:o,shouldUnregister:t});return X(mr,{dateAdapter:dr,adapterLocale:yr,localeText:fr.components.MuiLocalizationProvider.defaultProps.localeText,children:gr(sr,{children:[u&&X(P,{label:u,required:m}),X(ur,{ampm:!1,format:F,value:I.value??null,disabled:c,...s,onChange:(n,b)=>{I.onChange(n,b),s?.onChange?.(n,b)},slots:{textField:pr,openPickerButton:n=>X(Te,{...n,size:y.size})},slotProps:{textField:n=>({variant:"outlined",...n,error:!!k,...y,inputProps:{...n.inputProps,placeholder:g||n.inputProps?.placeholder},InputProps:{...n.InputProps,inputRef:b=>{I.ref(b),typeof n.inputRef=="function"&&n.inputRef(b)}}})}},l),X(V,{name:l,disableIcon:T,control:i})]})})},br=B(hr);console.log("opa");export{Ke as Checkbox,yo as CreatableV2,Bo as DatePicker,V as FieldError,H as FieldInfo,P as FieldLabel,Uo as Form,ie as FormProvider,tt as RadioButton,Xo as RadioGroup,mt as SearchableV2,It as SelectV2,Bt as Slider,Nt as Switch,rr as TextField,br as TimePicker,ne as useForm};
70
+ `;import"dayjs/locale/pt-br";import{jsx as ee,jsxs as yr}from"react/jsx-runtime";var cr=({rules:e,defaultValue:o,shouldUnregister:t,name:l,control:n,required:f,label:c,disabled:d,disableIconError:h,...i})=>{let V=ur()?.control,p=n??V;if(!p)throw new x("TimePicker");let m=fr({control:p,name:l}),s=L(m.errors,l),a=i.format||"HH:mm",S=e?dr([ke(a),e]):ke(a),{field:F}=mr({control:p,name:l,rules:S,defaultValue:o,shouldUnregister:t});return ee(sr,{dateAdapter:ar,children:yr(nr,{children:[c&&ee(P,{label:c,required:f}),ee(pr,{ampm:!1,format:a,value:F.value??null,disabled:d,...i,enableAccessibleFieldDOMStructure:!1,onChange:(I,T)=>{F.onChange(I,T),i?.onChange?.(I,T)},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})]})})},Fr=E(cr);console.log("opa");export{Ke as Checkbox,Fo as CreatableV2,Eo as DatePicker,v as FieldError,H as FieldInfo,P as FieldLabel,Go as Form,ie as FormProvider,et as RadioButton,Yo as RadioGroup,pt as SearchableV2,St as SelectV2,Et as Slider,qt as Switch,or as TextField,Fr as TimePicker,ne as useForm};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@s_mart/form",
3
- "version": "10.0.0-beta.17",
3
+ "version": "10.0.0-beta.19",
4
4
  "main": "./dist/index.mjs",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.mts",
@@ -12,14 +12,15 @@
12
12
  "dependencies": {
13
13
  "@hookform/resolvers": "^3.1.0",
14
14
  "lodash-es": "^4.17.21",
15
+ "react-is": "^18.3.1",
15
16
  "tsup": "8.0.2"
16
17
  },
17
18
  "peerDependencies": {
18
19
  "@emotion/react": "^11.11.4",
19
20
  "@emotion/styled": "^11.13.0",
20
- "@mui/material": "^6.4.11",
21
- "@mui/system": "^6.4.11",
22
- "@mui/x-date-pickers": "^7.22.0",
21
+ "@mui/material": "^7.2.0",
22
+ "@mui/system": "^7.2.0",
23
+ "@mui/x-date-pickers": "^8.6.0",
23
24
  "@types/lodash-es": ">=4.17.12",
24
25
  "@types/node": ">=22.15.17",
25
26
  "@types/react": ">=18.3.12",
@@ -30,33 +31,36 @@
30
31
  "react-hook-form": "^7.51.0",
31
32
  "typescript": ">=5.4.2",
32
33
  "zod": "^3.22.4",
33
- "@s_mart/regular-icons": "6.0.10",
34
- "@s_mart/solid-icons": "6.0.7",
34
+ "@s_mart/core": "10.0.0-beta.9",
35
35
  "@s_mart/masks": "5.2.0",
36
- "@s_mart/core": "10.0.0-beta.8",
36
+ "@s_mart/regular-icons": "6.0.11-beta.0",
37
37
  "@s_mart/rules": "5.1.2-beta.0",
38
- "@s_mart/typed": "7.2.3",
39
- "@s_mart/tokens": "5.1.1",
38
+ "@s_mart/solid-icons": "6.0.8-beta.0",
39
+ "@s_mart/tokens": "6.0.0-beta.0",
40
+ "@s_mart/typed": "8.0.0-beta.0",
40
41
  "@s_mart/utils": "5.3.4"
41
42
  },
42
43
  "devDependencies": {
43
44
  "@emotion/styled": "^11.13.0",
44
- "@mui/material": "^6.4.11",
45
- "@mui/system": "^6.4.11",
46
- "@mui/x-date-pickers": "^7.22.0",
45
+ "@mui/material": "^7.2.0",
46
+ "@mui/system": "^7.2.0",
47
+ "@mui/x-date-pickers": "^8.6.0",
47
48
  "@types/lodash-es": ">=4.17.12",
48
49
  "@types/node": ">=22.15.17",
49
50
  "@types/react": ">=18.3.12",
50
51
  "@types/react-dom": ">=18.3.1",
51
52
  "dayjs": "^1.11.10",
52
53
  "typescript": ">=5.4.2",
53
- "@s_mart/core": "10.0.0-beta.8",
54
+ "@s_mart/core": "10.0.0-beta.9",
54
55
  "@s_mart/masks": "5.2.0",
55
56
  "@s_mart/rules": "5.1.2-beta.0",
56
- "@s_mart/tokens": "5.1.1",
57
- "@s_mart/typed": "7.2.3",
57
+ "@s_mart/tokens": "6.0.0-beta.0",
58
+ "@s_mart/typed": "8.0.0-beta.0",
58
59
  "@s_mart/utils": "5.3.4"
59
60
  },
61
+ "overrides": {
62
+ "react-is": "^18.3.1"
63
+ },
60
64
  "scripts": {
61
65
  "build": "tsup src/index.tsx --minify --format esm --dts --external react",
62
66
  "dev": "tsup src/index.tsx --format esm --watch --dts --external react"