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

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