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