@s_mart/form 10.0.0-beta.10 → 10.0.0-beta.12
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 +10 -10
- package/dist/index.mjs +10 -10
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
|
@@ -2,9 +2,9 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
2
2
|
import * as react_hook_form from 'react-hook-form';
|
|
3
3
|
import { FieldValues, FieldPath, UseControllerProps, FieldPathValue, Control, UseFormReturn, FormProviderProps, UseFormProps } from 'react-hook-form';
|
|
4
4
|
import { CheckboxProps as CheckboxProps$1, AutocompleteProps, TextFieldProps as TextFieldProps$1, AutocompleteValue, AutocompleteFreeSoloValueMapping, RadioGroupProps as RadioGroupProps$1, RadioProps as RadioProps$1, SelectProps, SliderProps as SliderProps$1, SwitchProps as SwitchProps$1 } from '@mui/material';
|
|
5
|
-
import * as react from 'react';
|
|
6
5
|
import { DatePickerProps as DatePickerProps$1, TimePickerProps as TimePickerProps$1 } from '@mui/x-date-pickers';
|
|
7
6
|
import { z } from 'zod';
|
|
7
|
+
import * as react from 'react';
|
|
8
8
|
|
|
9
9
|
type CheckboxProps<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = CheckboxProps$1 & UseControllerProps<TFieldValues, TFieldName> & {
|
|
10
10
|
/**
|
|
@@ -33,7 +33,7 @@ type CheckboxProps<TFieldValues extends FieldValues = FieldValues, TFieldName ex
|
|
|
33
33
|
disableIconError?: boolean;
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
-
declare const
|
|
36
|
+
declare const _default$7: <TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ name, rules, defaultValue, shouldUnregister, control: controlFromProps, label, labelPlacement, required, disableIconError, onChange: onChangeProp, ...rest }: CheckboxProps<TFieldValues, TFieldName>) => react_jsx_runtime.JSX.Element;
|
|
37
37
|
|
|
38
38
|
type CreatableV2Props<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, FieldValue = FieldPathValue<TFieldValues, TFieldName>, Multiple extends boolean | undefined = undefined, DisableClearable extends boolean | undefined = undefined, FreeSolo extends boolean | undefined = undefined> = Omit<AutocompleteProps<FieldValue, Multiple, DisableClearable, FreeSolo>, 'renderInput' | 'options' | 'size' | 'onInputChange' | 'onChange' | 'getOptionLabel' | 'getOptionKey' | 'defaultValue' | 'value'> & UseControllerProps<TFieldValues, TFieldName> & {
|
|
39
39
|
options: FieldValue[];
|
|
@@ -105,7 +105,7 @@ type CreatableV2Props<TFieldValues extends FieldValues = FieldValues, TFieldName
|
|
|
105
105
|
};
|
|
106
106
|
|
|
107
107
|
declare function CreatableV2<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, FieldValue = FieldPathValue<TFieldValues, TFieldName>, Multiple extends boolean | undefined = undefined, DisableClearable extends boolean | undefined = undefined, FreeSolo extends boolean | undefined = undefined>(props: CreatableV2Props<TFieldValues, TFieldName, FieldValue, Multiple, DisableClearable, FreeSolo>): react_jsx_runtime.JSX.Element;
|
|
108
|
-
declare const _default$
|
|
108
|
+
declare const _default$6: typeof CreatableV2;
|
|
109
109
|
|
|
110
110
|
type DatePickerProps<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = UseControllerProps<TFieldValues, TFieldName> & Pick<TextFieldProps$1, 'label' | 'error' | 'helperText' | 'size' | 'fullWidth' | 'variant' | 'autoFocus' | 'placeholder'> & {
|
|
111
111
|
datePickerProps?: Partial<DatePickerProps$1<any>>;
|
|
@@ -131,7 +131,7 @@ type DatePickerProps<TFieldValues extends FieldValues = FieldValues, TFieldName
|
|
|
131
131
|
disableIconError?: boolean;
|
|
132
132
|
};
|
|
133
133
|
|
|
134
|
-
declare const _default$
|
|
134
|
+
declare const _default$5: <TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ rules, name, defaultValue, shouldUnregister, control: controlFromProps, datePickerProps, label, required, placeholder, disabled, disableIconError, ...rest }: DatePickerProps<TFieldValues, TFieldName>) => react_jsx_runtime.JSX.Element;
|
|
135
135
|
|
|
136
136
|
type FieldLabelProps = {
|
|
137
137
|
label: React.ReactNode;
|
|
@@ -322,7 +322,7 @@ type SearchableV2Props<TFieldValues extends FieldValues = FieldValues, TFieldNam
|
|
|
322
322
|
getOptionAfterLabel?: (option: FieldValue | AutocompleteFreeSoloValueMapping<FreeSolo>) => string | React.ReactNode;
|
|
323
323
|
};
|
|
324
324
|
|
|
325
|
-
declare const _default$
|
|
325
|
+
declare const _default$4: <TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, FieldValue = FieldPathValue<TFieldValues, TFieldName>, Multiple extends boolean | undefined = undefined, DisableClearable extends boolean | undefined = undefined, FreeSolo extends boolean | undefined = undefined, AutocompleteFieldValue extends AutocompleteValue<FieldValue, Multiple, DisableClearable, FreeSolo> = AutocompleteValue<FieldValue, Multiple, DisableClearable, FreeSolo>>(props: SearchableV2Props<TFieldValues, TFieldName, FieldValue, Multiple, DisableClearable, FreeSolo, AutocompleteFieldValue>) => react_jsx_runtime.JSX.Element;
|
|
326
326
|
|
|
327
327
|
type FooterPropsV2 = {
|
|
328
328
|
closeSelect: () => void;
|
|
@@ -383,7 +383,7 @@ type SelectV2ReturnValueProps<TFieldValues extends FieldValues = FieldValues, TF
|
|
|
383
383
|
getOptionLabel: (option: FieldPathValue<TFieldValues, TFieldName>) => string;
|
|
384
384
|
};
|
|
385
385
|
|
|
386
|
-
declare const _default$
|
|
386
|
+
declare const _default$3: <TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>(props: SelectV2Props<TFieldValues, TFieldName>) => react_jsx_runtime.JSX.Element;
|
|
387
387
|
|
|
388
388
|
type SliderProps<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = SliderProps$1 & UseControllerProps<TFieldValues, TFieldName> & {
|
|
389
389
|
/**
|
|
@@ -433,7 +433,7 @@ type SwitchProps<TFieldValues extends FieldValues = Record<string, boolean>, TFi
|
|
|
433
433
|
disableIconError?: boolean;
|
|
434
434
|
};
|
|
435
435
|
|
|
436
|
-
declare const
|
|
436
|
+
declare const _default$2: <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;
|
|
437
437
|
|
|
438
438
|
type Masks = 'cpf' | 'cnpj' | 'cpfCnpj' | 'cep' | 'telefone' | 'decimal' | 'decimal3' | 'decimal4' | 'decimal5' | 'porcentagem' | 'porcentagem0' | 'nome' | 'numero' | 'numeroPontuacao' | 'placa' | 'valor' | 'valor3' | 'valor4';
|
|
439
439
|
type TextFieldProps<TFieldValues extends FieldValues = Record<string, string>, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = TextFieldProps$1 & UseControllerProps<TFieldValues, TFieldName> & {
|
|
@@ -477,7 +477,7 @@ type TextFieldProps<TFieldValues extends FieldValues = Record<string, string>, T
|
|
|
477
477
|
disableIconError?: boolean;
|
|
478
478
|
};
|
|
479
479
|
|
|
480
|
-
declare const
|
|
480
|
+
declare const _default$1: <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;
|
|
481
481
|
|
|
482
482
|
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'> & {
|
|
483
483
|
timePickerProps?: Partial<TimePickerProps$1<any>>;
|
|
@@ -503,6 +503,6 @@ type TimePickerProps<TFieldValues extends FieldValues = FieldValues, TFieldName
|
|
|
503
503
|
disableIconError?: boolean;
|
|
504
504
|
};
|
|
505
505
|
|
|
506
|
-
declare const _default:
|
|
506
|
+
declare const _default: <TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ rules, defaultValue, shouldUnregister, name, control: controlFromProps, required, label, timePickerProps, placeholder, disabled, disableIconError, ...rest }: TimePickerProps<TFieldValues, TFieldName>) => react_jsx_runtime.JSX.Element;
|
|
507
507
|
|
|
508
|
-
export { Checkbox, type CheckboxProps, _default$
|
|
508
|
+
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 };
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{useController as
|
|
1
|
+
import{useController as ze,useFormContext as qe}from"react-hook-form";import{Checkbox as Ge,FormControlLabel as Ue}from"@mui/material";import{Indicator as Ee}from"@s_mart/core";import{useFormState as De}from"react-hook-form";var R=(e,o)=>o.replace(/[[\]]/g,"").split(".").reduce((l,d)=>l?.[d],e);import{jsx as Be}from"react/jsx-runtime";var Me=({name:e,disableIcon:o,control:r})=>{let l=De({control:r,name:e}),d=R(l?.errors,e);return d?Be(Ee,{severity:"error",icon:o?!1:void 0,children:d?.message}):null},g=Me;import{Typography as me}from"@mui/material";import{toRem as Ae}from"@s_mart/utils";import{jsx as ue,jsxs as Oe}from"react/jsx-runtime";var Ne=({label:e,required:o,regular:r})=>Oe("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:"*"})]}),P=Ne;var x=class extends Error{constructor(o){super(`O componente ${o} precisa de um control para funcionar. Passe o control como prop ou coloque o componente dentro de um <Form />`),this.name="FormComponentPrecisaDeControl"}};import{memo as $e}from"react";var w=$e;import{jsx as Q,jsxs as Ke}from"react/jsx-runtime";var _e=({name:e,rules:o,defaultValue:r,shouldUnregister:l,control:d,label:u,labelPlacement:f,required:s,disableIconError:h,onChange:F,...C})=>{let m=qe()?.control,c=d??m;if(!c)throw new x("Checkbox");let{field:a}=ze({control:c,name:e,rules:o,defaultValue:r,shouldUnregister:l});return Ke("span",{children:[Q(Ue,{control:Q(Ge,{checked:!!a.value,value:a.value??"",defaultValue:a.value,onChange:(p,L)=>{a.onChange(p,L),F?.(p,L)},...C},e),label:Q(P,{label:u,required:s,regular:!0}),labelPlacement:f||"end"}),Q(g,{name:e,disableIcon:h,control:c})]})},He=w(_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 ao from"lodash-es/isEmpty";import no from"lodash-es/isEqual";import{Autocomplete as so,TextField as po,Divider as Fe,Button as mo}from"@mui/material";import{LIcon as re}from"@s_mart/core";import{linePlus as ye,linePen as uo}from"@s_mart/solid-icons";import{toRem as Pe}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`
|
|
2
2
|
display: flex;
|
|
3
3
|
align-items: center;
|
|
4
4
|
justify-content: center;
|
|
5
|
-
`,ce=
|
|
5
|
+
`,ce=Ye("div")`
|
|
6
6
|
display: flex;
|
|
7
7
|
|
|
8
8
|
div.endAdornments {
|
|
@@ -49,22 +49,22 @@ import{useController as $e,useFormContext as ze}from"react-hook-form";import{Che
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
`;import{Tooltip as
|
|
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 B}from"react/jsx-runtime";import{createElement as Fo}from"react";function fo(e){let{name:o,rules:r,defaultValue:l,shouldUnregister:d,control:u,label:f,required:s,options:h,footer:F,showCreatableButton:C=!0,showEditableButton:m,onEditOption:c,onCreateOption:a,getOptionKey:p,getOptionLabel:L,getOptionAfterLabel:T,multiple:E,info:S,noOptionsText:i,onChange:V,onInputChange:N,placeholder:O,...y}=e,[U,D]=oo(""),n=ro()?.control,t=u??n;if(!t)throw new x("CreatableV2");let I=lo({control:t,name:o}),$=R(I.errors,o),J=!C||y.disabled,{field:Y}=to({name:o,control:t,rules:r,defaultValue:l,shouldUnregister:d}),Ie=k=>{let b=0;return e.slotProps?.textField?.slotProps?.input||(b+=2.5),J||(b+=2.56,se(k)&&(b+=2.56)),!y.disableClearable&&!y.disabled&&(b+=1.3),`${b}rem`},se=k=>y.disabled?!1:m&&io(k)&&!ao(k),we=()=>y.disabled?!1:C,pe=eo(()=>{typeof a<"u"&&(a(U),D(""))},[U,a]),Le=()=>{c?.(Y.value)};return B("div",{style:{display:"flex",flexDirection:"column"},children:[B("div",{style:{display:"flex"},children:[f&&v(P,{label:f,required:s}),S&&v(_,{title:S})]}),v(ce,{children:v(so,{fullWidth:!0,onChange:(k,b)=>{D(""),Y.onChange(b),V?.(b)},onInputChange:(k,b,H)=>{H==="input"&&(D(b),N?.(b))},slotProps:{...y.slotProps,listbox:{component:je(function(b,H){return B(le,{children:[v("ul",{...b,ref:H}),typeof F<"u"?B("div",{...b,children:[v("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:v(Fe,{})}),F()]},"creatable-footer"):null]})})}},value:Y.value,options:h,multiple:E,readOnly:y.disabled,noOptionsText:B(le,{children:[i||"Nenhuma op\xE7\xE3o encontrada",!J&&B(mo,{sx:{justifyContent:"flex-start",padding:`${Pe(6)} ${Pe(-16)}`,margin:0},fullWidth:!0,onClick:pe,variant:"text",startIcon:v(re,{icon:ye}),children:["Adicionar ",`"${U}"`]}),typeof F<"u"&&B(le,{children:[v("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:v(Fe,{})}),F()]})]}),isOptionEqualToValue:(k,b)=>no(k,b),getOptionLabel:L,getOptionKey:p,renderOption:typeof T=="function"?(k,b)=>{let H=T(b),Re=p(b);return Fo("li",{...k,key:Re},B("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[v("span",{children:L(b)}),typeof H=="string"?v("span",{children:H}):H]}))}:void 0,...y,sx:{"& div.MuiInputBase-root":{paddingRight:`${Ie(Y.value)} !important`},...y.sx},onBlur:k=>{y?.onBlur?.(k),D("")},renderInput:k=>v(po,{placeholder:O,...k,error:!!$,...e.slotProps?.textField,slotProps:{input:{...k.InputProps,...e.slotProps?.textField?.slotProps?.input,inputRef:Y.ref,endAdornment:B("div",{className:"endAdornments",children:[k.InputProps.endAdornment,e.slotProps?.textField?.slotProps?.input?.endAdornment??null,se(Y.value)?B("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()&&B("div",{className:"creatable",children:[v("div",{className:"divider"}),v("div",{className:"button",onKeyUp:pe,children:v(re,{icon:ye,size:"24px",removeMargin:!0})})]})]})}}})},o)}),v(g,{name:o,control:t})]})}var co=w(fo);import{Stack as ho,TextField as To}from"@mui/material";import{AdapterDayjs as bo}from"@mui/x-date-pickers/AdapterDayjs";import{DatePicker as go}from"@mui/x-date-pickers/DatePicker";import{LocalizationProvider as vo}from"@mui/x-date-pickers/LocalizationProvider";import{ptBR as Co}from"@mui/x-date-pickers/locales/ptBR";import{composeValidators as So,date as Ve}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 yo,styled as Po}from"@mui/material";import{toRem as z}from"@s_mart/utils";var xo=e=>{switch(e){case"small":return z(16);case"large":return z(24);default:return z(20)}},Vo=e=>{switch(e){case"small":return`${z(2)} ${z(8)}`;case"large":return`${z(10)}`;default:return`${z(6)} ${z(8)}`}},xe=Po(yo)`
|
|
53
53
|
margin: 0px;
|
|
54
54
|
|
|
55
55
|
padding: ${({size:e})=>Vo(e)};
|
|
56
|
-
border-radius: 0 ${
|
|
56
|
+
border-radius: 0 ${z(4)} ${z(4)} 0;
|
|
57
57
|
|
|
58
58
|
svg {
|
|
59
|
-
width: ${({size:e})=>
|
|
59
|
+
width: ${({size:e})=>xo(e)} !important;
|
|
60
60
|
}
|
|
61
|
-
`;import{jsx as j,jsxs as Mo}from"react/jsx-runtime";import{createElement as Bo}from"react";var Eo=({rules:e,name:o,defaultValue:r,shouldUnregister:l,control:d,datePickerProps:u,label:f,required:s,placeholder:h,disabled:F,disableIconError:C,...m})=>{let c=Lo()?.control,a=d??c;if(!a)throw new P("DatePicker");let p=Ro({control:a,name:o}),w=L(p.errors,o),T=u?.format||"DD/MM/YYYY",R=e?So([Ve(T),e]):Ve(T),{field:S}=wo({control:a,name:o,rules:R,defaultValue:r,shouldUnregister:l});return j(vo,{dateAdapter:bo,adapterLocale:ko,localeText:Co.components.MuiLocalizationProvider.defaultProps.localeText,children:Mo(ho,{children:[f&&j(x,{label:f,required:s}),Bo(go,{...u,key:o,value:S.value??null,format:T,onChange:(i,V)=>{S.onChange(i,V),u?.onChange?.(i,V)},disabled:F,slots:{textField:To,openPickerButton:i=>j(Pe,{...i,size:m.size})},slotProps:{textField:i=>({variant:"outlined",...i,error:!!w,...m,inputProps:{...i.inputProps,placeholder:h||i.inputProps?.placeholder},InputProps:{...i.InputProps,inputRef:V=>{S.ref(V),typeof i.inputRef=="function"&&i.inputRef(V)}}})}}),j(g,{name:o,disableIcon:C,control:a})]})})},Do=Io(Eo);import{FormProvider as Ao}from"react-hook-form";import{jsx as he}from"react/jsx-runtime";function No({children:e,style:o,onSubmit:r,...l}){return he(Ao,{...l,children:he("form",{onSubmit:d=>{d.preventDefault(),d.stopPropagation(),r(d)},style:o,children:e})})}var ie=No;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(d=>o(d,l))}},ae=qo;import{jsx as _o}from"react/jsx-runtime";function Go({children:e,style:o,...r}){let l=ae(r);return _o(ie,{...l,style:o,children:typeof e=="function"?e(l):e})}var Uo=Go;import{RadioGroup as Ho,Stack as Ko}from"@mui/material";import{useController as Wo,useFormContext as Yo}from"react-hook-form";import{jsx as ne,jsxs as Qo}from"react/jsx-runtime";var Jo=({name:e,rules:o,defaultValue:r,shouldUnregister:l,control:d,label:u,required:f,children:s,orientation:h="row",disableIconError:F,...C})=>{let m=Yo()?.control,c=d??m;if(!c)throw new P("RadioGroup");let{field:a}=Wo({control:c,name:e,rules:o,defaultValue:r,shouldUnregister:l});return Qo(Ko,{children:[u&&ne(x,{label:u,required:f}),ne(Ho,{value:a.value||"",name:e,...C,onChange:p=>{C?.onChange?.(p,p.target?.value),a.onChange(p)},style:{display:"flex",flexDirection:h},children:s},e),ne(g,{name:e,disableIcon:F,control:c})]})},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,...r})=>ee(jo,{sx:{display:"flex",flexDirection:"column"},children:ee(Zo,{control:ee(et,{...r}),label:ee(x,{label:e}),labelPlacement:o||"end"})}),tt=ot;import{Autocomplete as rt,Divider as Te,TextField as lt}from"@mui/material";import it from"lodash-es/isEqual";import{forwardRef as at}from"react";import{useController as nt,useFormContext as dt,useFormState as st}from"react-hook-form";import{Fragment as de,jsx as D,jsxs as H}from"react/jsx-runtime";import{createElement as ut}from"react";var pt=e=>{let{name:o,rules:r,defaultValue:l,shouldUnregister:d,control:u,label:f,required:s,options:h,textFieldProps:F,noOptionsText:C,footer:m,multiple:c,info:a,placeholder:p,onChange:w,onInputChange:T,getOptionAfterLabel:R,getOptionLabel:S,getOptionKey:i,...V}=e,A=dt()?.control,N=u??A;if(!N)throw new P("SearchableV2");let y=st({control:N,name:o}),G=L(y.errors,o),{field:E}=nt({name:o,control:N,rules:r,defaultValue:l,shouldUnregister:d});return H("div",{style:{display:"flex",flexDirection:"column"},children:[H("div",{style:{display:"flex"},children:[f&&D(x,{label:f,required:s}),a&&D(U,{title:a})]}),D(rt,{onChange:(n,t)=>{E.onChange(t),w?.(t)},onInputChange:(n,t,I)=>{I==="input"&&T?.(t)},value:E.value,options:h,multiple:c,readOnly:V.disabled,slotProps:{...V.slotProps,listbox:{component:at(function(t,I){return H(de,{children:[D("ul",{...t,ref:I}),typeof m<"u"?H("div",{...t,children:[D("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:D(Te,{})}),m()]},"searchable-footer"):null]})})}},noOptionsText:H(de,{children:[C||"Nenhuma op\xE7\xE3o encontrada",typeof m<"u"?H(de,{children:[D("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:D(Te,{})}),m()]}):null]}),isOptionEqualToValue:(n,t)=>it(n,t),getOptionLabel:S,getOptionKey:i,renderOption:typeof R=="function"?(n,t)=>{let I=R(t),O=i(t);return ut("li",{...n,key:O},H("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[D("span",{children:S(t)}),typeof I=="string"?D("span",{children:I}):I]}))}:void 0,...V,renderInput:n=>D(lt,{error:!!G,placeholder:p,...n,...F,inputRef:E.ref})},o),D(g,{name:o,control:N})]})},mt=Y(pt);import{useState as Ft}from"react";import{useController as yt,useFormContext as xt,useFormState as Pt}from"react-hook-form";import{IconButton as Vt,LIcon as ht}from"@s_mart/core";import{lineTimes as Tt}from"@s_mart/regular-icons";import{colorPalette as bt}from"@s_mart/tokens";import{Select as gt,MenuItem as vt,Divider as Ct}from"@mui/material";import{colorPalette as ft}from"@s_mart/tokens";import{jsx as ct}from"react/jsx-runtime";var be=({value:e,placeholder:o,getOptionLabel:r})=>e===null||e?.length===0?ct("p",{style:{color:ft.neutral[100]},children:o}):r(e);import{Fragment as It,jsx as M,jsxs as K}from"react/jsx-runtime";var St=e=>{let{name:o,rules:r,defaultValue:l,shouldUnregister:d,control:u,label:f,required:s,options:h,placeholder:F,clearable:C,info:m,footer:c,onChange:a,variant:p="outlined",getOptionKey:w,getOptionLabel:T,getOptionAfterLabel:R,getOptionIcon:S,...i}=e,V=xt()?.control,A=u??V,[N,y]=Ft(!1);if(!A)throw new P("SelectV2");let G=Pt({control:A,name:o}),E=L(G.errors,o),{field:n}=yt({control:A,name:o,rules:r,defaultValue:l,shouldUnregister:d});return K("div",{style:{display:"flex",flexDirection:"column"},children:[K("div",{style:{display:"flex"},children:[f&&M(x,{label:f,required:s}),m&&M(U,{title:m})]}),K(gt,{open:N,onOpen:()=>y(!0),onClose:()=>y(!1),displayEmpty:!!F,variant:p,autoComplete:"off",value:n.value||null,renderValue:t=>M(be,{getOptionLabel:T,placeholder:F,value:t}),onChange:t=>{n.onChange(t.target.value),a?.(t.target.value)},error:!!E,size:i.size||"medium",inputRef:n.ref,...i,endAdornment:K(It,{children:[i.endAdornment,!!(C&&n.value)&&M(Vt,{variant:"text",color:"neutral",size:"small",sx:{borderRadius:"50%",position:"absolute",right:"2rem"},style:{padding:0},"aria-label":"Limpar",title:"Limpar",onClick:()=>{n.onChange(null),a?.(null)},children:M(ht,{icon:Tt,color:bt.neutral[100],size:"25px",removeMargin:!0})})]}),children:[h.map(t=>{let I=w(t),O=T(t),J=S?.(t);return M(vt,{value:I??O,children:K("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[J!==void 0?K("div",{style:{display:"flex",alignItems:"center"},children:[J,O]}):O,M("span",{children:R?.(t)??null})]})},I)}),c!==void 0&&K("div",{children:[M("div",{style:{padding:"8px 16px"},children:M(Ct,{})},"footer-divider"),M("div",{children:c({closeSelect:()=>y(!1)})},"footer-content")]},"footer")]},o),M(g,{name:o,control:A})]})},kt=Y(St);import{useController as wt,useFormContext as Lt}from"react-hook-form";import{Slider as Rt}from"@mui/material";import{jsx as Bt}from"react/jsx-runtime";var Et=({name:e,rules:o,defaultValue:r,shouldUnregister:l,control:d,...u})=>{let f=Lt()?.control,s=d??f;if(!s)throw new P("Slider");let{field:h}=wt({control:s,name:e,rules:o,defaultValue:r,shouldUnregister:l});return Bt(Rt,{value:h.value||u?.min||0,onChange:h.onChange,valueLabelDisplay:"auto",...u},e)},Dt=Et;import{FormControlLabel as Mt,Stack as At,Switch as Nt}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:d,label:u,labelPlacement:f,disableIconError:s,onChange:h,...F})=>{let C=$t()?.control,m=d??C;if(!m)throw new P("Switch");let{field:c}=Ot({control:m,name:e,rules:o,defaultValue:r,shouldUnregister:l});return Gt(At,{children:[oe(Mt,{control:oe(Nt,{value:c.value??"",checked:c.value??!1,onChange:(a,p)=>{c.onChange(a,p),h?.(a,p)},...F},e),label:oe(x,{label:u}),labelPlacement:f||"end"}),oe(g,{name:e,disableIcon:s,control:m})]})},qt=zt;import{InputAdornment as Ut,Stack as _t,TextField as Ht,Tooltip as Kt}from"@mui/material";import{LIcon as ge}from"@s_mart/core";import*as ve from"@s_mart/masks";import{lineEye as Wt,lineEyeSlash as Yt,lineInfoCircle as Jt}from"@s_mart/solid-icons";import{useRef as Xt,useState as Qt}from"react";import{useController as Zt,useFormContext as jt,useFormState as er}from"react-hook-form";import{jsx as z,jsxs as Ce}from"react/jsx-runtime";var or=({name:e,rules:o,defaultValue:r,shouldUnregister:l,control:d,label:u,required:f,mask:s,variant:h="outlined",info:F,parse:C,format:m,onInputChange:c,disableIconError:a,...p})=>{let w=jt()?.control,T=d??w,R=Xt(r||void 0);if(!T)throw new P("TextField");let[S,i]=Qt(!1),V=n=>{let t=n;return t=m?.(n)??n,s?ve?.[s]?.format(t):t},A=n=>{let t=n;return t=C?.(n)??t,s?ve?.[s]?.parse(t,R.current):t},N=n=>{if(!n||s!=="porcentagem"&&s!=="porcentagem0")return;n?.stopPropagation();let t=(n?.target).value;if(t){let I=String(t);if(I.length>0){let O=I.indexOf("%");O>-1&&(n.currentTarget.selectionEnd=O)}}},{field:y}=Zt({control:T,name:e,rules:o,defaultValue:r,shouldUnregister:l}),G=er({control:T,name:e}),E=L(G.errors,e);return Ce(_t,{children:[Ce("div",{style:{display:"flex"},children:[u&&z("div",{children:z(x,{label:u,required:f})}),F&&z("div",{children:z(Kt,{title:F,placement:"top",children:z("div",{style:{width:"fit-content"},children:z(ge,{icon:Jt,color:"#757575"})})})})]}),z(Ht,{variant:h,defaultValue:r,value:V(y.value||(y.value!=0?"":y.value)),onChange:n=>{let t=A(n?.target?.value);y.onChange(t),c?.(t),R.current=n.target.value},error:!!E,...p,type:p.type==="password"?S?"text":"password":p.type,autoComplete:p.autoComplete||"off",slotProps:{input:{onKeyDown:N,inputRef:y.ref,endAdornment:p.type==="password"&&z(Ut,{position:"start",onClick:()=>i(!S),style:{cursor:"pointer"},children:z(ge,{icon:S?Wt:Yt,size:"24px",removeMargin:!0})}),...p.slotProps?.input}}},e),z(g,{name:e,disableIcon:a,control:T})]})},tr=or;import{Stack as nr,TextField as dr}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 mr}from"@mui/x-date-pickers/TimePicker";import{ptBR as ur}from"@mui/x-date-pickers/locales/ptBR";import{composeValidators as fr,time as ke}from"@s_mart/rules";import cr from"dayjs/locale/pt-br";import{memo as Fr}from"react";import{useController as yr,useFormContext as xr,useFormState as Pr}from"react-hook-form";import{styled as rr}from"@mui/material";import{IconButton as lr}from"@mui/material";import{toRem as q}from"@s_mart/utils";var ir=e=>{switch(e){case"small":return q(16);case"large":return q(24);default:return q(20)}},ar=e=>{switch(e){case"small":return`${q(2)} ${q(8)}`;case"large":return q(10);default:return`${q(6)} ${q(8)}`}},Se=rr(lr)`
|
|
61
|
+
`;import{jsx as j,jsxs as Mo}from"react/jsx-runtime";import{createElement as Do}from"react";var Ro=({rules:e,name:o,defaultValue:r,shouldUnregister:l,control:d,datePickerProps:u,label:f,required:s,placeholder:h,disabled:F,disableIconError:C,...m})=>{let c=wo()?.control,a=d??c;if(!a)throw new x("DatePicker");let p=Lo({control:a,name:o}),L=R(p.errors,o),T=u?.format||"DD/MM/YYYY",E=e?So([Ve(T),e]):Ve(T),{field:S}=Io({control:a,name:o,rules:E,defaultValue:r,shouldUnregister:l});return j(vo,{dateAdapter:bo,adapterLocale:ko,localeText:Co.components.MuiLocalizationProvider.defaultProps.localeText,children:Mo(ho,{children:[f&&j(P,{label:f,required:s}),Do(go,{...u,key:o,value:S.value??null,format:T,onChange:(i,V)=>{S.onChange(i,V),u?.onChange?.(i,V)},disabled:F,slots:{textField:To,openPickerButton:i=>j(xe,{...i,size:m.size})},slotProps:{textField:i=>({variant:"outlined",...i,error:!!L,...m,inputProps:{...i.inputProps,placeholder:h||i.inputProps?.placeholder},InputProps:{...i.InputProps,inputRef:V=>{S.ref(V),typeof i.inputRef=="function"&&i.inputRef(V)}}})}}),j(g,{name:o,disableIcon:C,control:a})]})})},Eo=w(Ro);import{FormProvider as Bo}from"react-hook-form";import{jsx as he}from"react/jsx-runtime";function Ao({children:e,style:o,onSubmit:r,...l}){return he(Bo,{...l,children:he("form",{onSubmit:d=>{d.preventDefault(),d.stopPropagation(),r(d)},style:o,children:e})})}var ie=Ao;import{useEffect as No}from"react";import{useForm as Oo}from"react-hook-form";import{zodResolver as $o}from"@hookform/resolvers/zod";var zo=({disableDefaultValuesUpdate:e,onSubmit:o,...r})=>{let l=Oo({...r,resolver:r.schema&&$o(r.schema)});return No(()=>{e||l.reset(r.defaultValues)},[r.defaultValues,l.reset]),{...l,onSubmit:l.handleSubmit(d=>o(d,l))}},ae=zo;import{jsx as Uo}from"react/jsx-runtime";function qo({children:e,style:o,...r}){let l=ae(r);return Uo(ie,{...l,style:o,children:typeof e=="function"?e(l):e})}var Go=qo;import{RadioGroup as _o,Stack as Ho}from"@mui/material";import{useController as Ko,useFormContext as Wo}from"react-hook-form";import{jsx as ne,jsxs as Xo}from"react/jsx-runtime";var Yo=({name:e,rules:o,defaultValue:r,shouldUnregister:l,control:d,label:u,required:f,children:s,orientation:h="row",disableIconError:F,...C})=>{let m=Wo()?.control,c=d??m;if(!c)throw new x("RadioGroup");let{field:a}=Ko({control:c,name:e,rules:o,defaultValue:r,shouldUnregister:l});return Xo(Ho,{children:[u&&ne(P,{label:u,required:f}),ne(_o,{value:a.value||"",name:e,...C,onChange:p=>{C?.onChange?.(p,p.target?.value),a.onChange(p)},style:{display:"flex",flexDirection:h},children:s},e),ne(g,{name:e,disableIcon:F,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(P,{label:e}),labelPlacement:o||"end"})}),ot=et;import{Autocomplete as tt,Divider as Te,TextField as rt}from"@mui/material";import lt from"lodash-es/isEqual";import{forwardRef as it}from"react";import{useController as at,useFormContext as nt,useFormState as dt}from"react-hook-form";import{Fragment as de,jsx as M,jsxs as K}from"react/jsx-runtime";import{createElement as mt}from"react";var st=e=>{let{name:o,rules:r,defaultValue:l,shouldUnregister:d,control:u,label:f,required:s,options:h,textFieldProps:F,noOptionsText:C,footer:m,multiple:c,info:a,placeholder:p,onChange:L,onInputChange:T,getOptionAfterLabel:E,getOptionLabel:S,getOptionKey:i,...V}=e,N=nt()?.control,O=u??N;if(!O)throw new x("SearchableV2");let y=dt({control:O,name:o}),U=R(y.errors,o),{field:D}=at({name:o,control:O,rules:r,defaultValue:l,shouldUnregister:d});return K("div",{style:{display:"flex",flexDirection:"column"},children:[K("div",{style:{display:"flex"},children:[f&&M(P,{label:f,required:s}),a&&M(_,{title:a})]}),M(tt,{onChange:(n,t)=>{D.onChange(t),L?.(t)},onInputChange:(n,t,I)=>{I==="input"&&T?.(t)},value:D.value,options:h,multiple:c,readOnly:V.disabled,slotProps:{...V.slotProps,listbox:{component:it(function(t,I){return K(de,{children:[M("ul",{...t,ref:I}),typeof m<"u"?K("div",{...t,children:[M("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:M(Te,{})}),m()]},"searchable-footer"):null]})})}},noOptionsText:K(de,{children:[C||"Nenhuma op\xE7\xE3o encontrada",typeof m<"u"?K(de,{children:[M("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:M(Te,{})}),m()]}):null]}),isOptionEqualToValue:(n,t)=>lt(n,t),getOptionLabel:S,getOptionKey:i,renderOption:typeof E=="function"?(n,t)=>{let I=E(t),$=i(t);return mt("li",{...n,key:$},K("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[M("span",{children:S(t)}),typeof I=="string"?M("span",{children:I}):I]}))}:void 0,...V,renderInput:n=>M(rt,{error:!!U,placeholder:p,...n,...F,inputRef:D.ref})},o),M(g,{name:o,control:O})]})},pt=w(st);import{useState as ct}from"react";import{useController as Ft,useFormContext as yt,useFormState as Pt}from"react-hook-form";import{IconButton as xt,LIcon as Vt}from"@s_mart/core";import{lineTimes as ht}from"@s_mart/regular-icons";import{colorPalette as Tt}from"@s_mart/tokens";import{Select as bt,MenuItem as gt,Divider as vt}from"@mui/material";import{colorPalette as ut}from"@s_mart/tokens";import{jsx as ft}from"react/jsx-runtime";var be=({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 Ct=e=>{let{name:o,rules:r,defaultValue:l,shouldUnregister:d,control:u,label:f,required:s,options:h,placeholder:F,clearable:C,info:m,footer:c,onChange:a,variant:p="outlined",getOptionKey:L,getOptionLabel:T,getOptionAfterLabel:E,getOptionIcon:S,...i}=e,V=yt()?.control,N=u??V,[O,y]=ct(!1);if(!N)throw new x("SelectV2");let U=Pt({control:N,name:o}),D=R(U.errors,o),{field:n}=Ft({control:N,name:o,rules:r,defaultValue:l,shouldUnregister:d});return W("div",{style:{display:"flex",flexDirection:"column"},children:[W("div",{style:{display:"flex"},children:[f&&A(P,{label:f,required:s}),m&&A(_,{title:m})]}),W(bt,{open:O,onOpen:()=>y(!0),onClose:()=>y(!1),displayEmpty:!!F,variant:p,autoComplete:"off",value:n.value||null,renderValue:t=>A(be,{getOptionLabel:T,placeholder:F,value:t}),onChange:t=>{n.onChange(t.target.value),a?.(t.target.value)},error:!!D,size:i.size||"medium",inputRef:n.ref,...i,endAdornment:W(kt,{children:[i.endAdornment,!!(C&&n.value)&&A(xt,{variant:"text",color:"neutral",size:"small",sx:{borderRadius:"50%",position:"absolute",right:"2rem"},style:{padding:0},"aria-label":"Limpar",title:"Limpar",onClick:()=>{n.onChange(null),a?.(null)},children:A(Vt,{icon:ht,color:Tt.neutral[100],size:"25px",removeMargin:!0})})]}),children:[h.map(t=>{let I=L(t),$=T(t),J=S?.(t);return A(gt,{value:I??$,children:W("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[J!==void 0?W("div",{style:{display:"flex",alignItems:"center"},children:[J,$]}):$,A("span",{children:E?.(t)??null})]})},I)}),c!==void 0&&W("div",{children:[A("div",{style:{padding:"8px 16px"},children:A(vt,{})},"footer-divider"),A("div",{children:c({closeSelect:()=>y(!1)})},"footer-content")]},"footer")]},o),A(g,{name:o,control:N})]})},St=w(Ct);import{useController as It,useFormContext as wt}from"react-hook-form";import{Slider as Lt}from"@mui/material";import{jsx as Dt}from"react/jsx-runtime";var Rt=({name:e,rules:o,defaultValue:r,shouldUnregister:l,control:d,...u})=>{let f=wt()?.control,s=d??f;if(!s)throw new x("Slider");let{field:h}=It({control:s,name:e,rules:o,defaultValue:r,shouldUnregister:l});return Dt(Lt,{value:h.value||u?.min||0,onChange:h.onChange,valueLabelDisplay:"auto",...u},e)},Et=Rt;import{FormControlLabel as Mt,Stack as Bt,Switch as At}from"@mui/material";import{useController as Nt,useFormContext as Ot}from"react-hook-form";import{jsx as oe,jsxs as qt}from"react/jsx-runtime";var $t=({name:e,rules:o,defaultValue:r,shouldUnregister:l,control:d,label:u,labelPlacement:f,disableIconError:s,onChange:h,...F})=>{let C=Ot()?.control,m=d??C;if(!m)throw new x("Switch");let{field:c}=Nt({control:m,name:e,rules:o,defaultValue:r,shouldUnregister:l});return qt(Bt,{children:[oe(Mt,{control:oe(At,{value:c.value??"",checked:c.value??!1,onChange:(a,p)=>{c.onChange(a,p),h?.(a,p)},...F},e),label:oe(P,{label:u}),labelPlacement:f||"end"}),oe(g,{name:e,disableIcon:s,control:m})]})},zt=w($t);import{InputAdornment as Gt,Stack as Ut,TextField as _t,Tooltip as Ht}from"@mui/material";import{LIcon as ge}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 Ce}from"react/jsx-runtime";var er=({name:e,rules:o,defaultValue:r,shouldUnregister:l,control:d,label:u,required:f,mask:s,variant:h="outlined",info:F,parse:C,format:m,onInputChange:c,disableIconError:a,...p})=>{let L=Zt()?.control,T=d??L,E=Jt(r||void 0);if(!T)throw new x("TextField");let[S,i]=Xt(!1),V=n=>{let t=n;return t=m?.(n)??n,s?ve?.[s]?.format(t):t},N=n=>{let t=n;return t=C?.(n)??t,s?ve?.[s]?.parse(t,E.current):t},O=n=>{if(!n||s!=="porcentagem"&&s!=="porcentagem0")return;n?.stopPropagation();let t=(n?.target).value;if(t){let I=String(t);if(I.length>0){let $=I.indexOf("%");$>-1&&(n.currentTarget.selectionEnd=$)}}},{field:y}=Qt({control:T,name:e,rules:o,defaultValue:r,shouldUnregister:l}),U=jt({control:T,name:e}),D=R(U.errors,e);return Ce(Ut,{children:[Ce("div",{style:{display:"flex"},children:[u&&q("div",{children:q(P,{label:u,required:f})}),F&&q("div",{children:q(Ht,{title:F,placement:"top",children:q("div",{style:{width:"fit-content"},children:q(ge,{icon:Yt,color:"#757575"})})})})]}),q(_t,{variant:h,defaultValue:r,value:V(y.value||(y.value!=0?"":y.value)),onChange:n=>{let t=N(n?.target?.value);y.onChange(t),c?.(t),E.current=n.target.value},error:!!D,...p,type:p.type==="password"?S?"text":"password":p.type,autoComplete:p.autoComplete||"off",slotProps:{input:{onKeyDown:O,inputRef:y.ref,endAdornment:p.type==="password"&&q(Gt,{position:"start",onClick:()=>i(!S),style:{cursor:"pointer"},children:q(ge,{icon:S?Kt:Wt,size:"24px",removeMargin:!0})}),...p.slotProps?.input}}},e),q(g,{name:e,disableIcon:a,control:T})]})},or=w(er);import{Stack as ar,TextField as nr}from"@mui/material";import{AdapterDayjs as dr}from"@mui/x-date-pickers/AdapterDayjs";import{LocalizationProvider as sr}from"@mui/x-date-pickers/LocalizationProvider";import{TimePicker as pr}from"@mui/x-date-pickers/TimePicker";import{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 Fr,useFormState as yr}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)}`}},Se=tr(rr)`
|
|
62
62
|
margin: 0px;
|
|
63
63
|
|
|
64
|
-
padding: ${({size:e})=>
|
|
65
|
-
border-radius: 0 ${
|
|
64
|
+
padding: ${({size:e})=>ir(e)};
|
|
65
|
+
border-radius: 0 ${G(4)} ${G(4)} 0;
|
|
66
66
|
|
|
67
67
|
svg {
|
|
68
|
-
width: ${({size:e})=>
|
|
68
|
+
width: ${({size:e})=>lr(e)} !important;
|
|
69
69
|
}
|
|
70
|
-
`;import{jsx as X,jsxs as
|
|
70
|
+
`;import{jsx as X,jsxs as Vr}from"react/jsx-runtime";var Pr=({rules:e,defaultValue:o,shouldUnregister:r,name:l,control:d,required:u,label:f,timePickerProps:s,placeholder:h,disabled:F,disableIconError:C,...m})=>{let c=Fr()?.control,a=d??c;if(!a)throw new x("TimePicker");let p=yr({control:a,name:l}),L=R(p.errors,l),T=s?.format||"HH:mm",E=e?ur([ke(T),e]):ke(T),{field:S}=cr({control:a,name:l,rules:E,defaultValue:o,shouldUnregister:r});return X(sr,{dateAdapter:dr,adapterLocale:fr,localeText:mr.components.MuiLocalizationProvider.defaultProps.localeText,children:Vr(ar,{children:[f&&X(P,{label:f,required:u}),X(pr,{ampm:!1,format:T,value:S.value??null,disabled:F,...s,onChange:(i,V)=>{S.onChange(i,V),s?.onChange?.(i,V)},slots:{textField:nr,openPickerButton:i=>X(Se,{...i,size:m.size})},slotProps:{textField:i=>({variant:"outlined",...i,error:!!L,...m,inputProps:{...i.inputProps,placeholder:h||i.inputProps?.placeholder},InputProps:{...i.InputProps,inputRef:V=>{S.ref(V),typeof i.inputRef=="function"&&i.inputRef(V)}}})}},l),X(g,{name:l,disableIcon:C,control:a})]})})},xr=w(Pr);export{He as Checkbox,co as CreatableV2,Eo as DatePicker,g as FieldError,_ as FieldInfo,P as FieldLabel,Go as Form,ie as FormProvider,ot as RadioButton,Jo as RadioGroup,pt as SearchableV2,St as SelectV2,Et as Slider,zt as Switch,or as TextField,xr as TimePicker,ae as useForm};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@s_mart/form",
|
|
3
|
-
"version": "10.0.0-beta.
|
|
3
|
+
"version": "10.0.0-beta.12",
|
|
4
4
|
"main": "./dist/index.mjs",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.mts",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"@hookform/resolvers": "^3.1.0",
|
|
14
14
|
"lodash-es": "^4.17.21",
|
|
15
15
|
"tsup": "8.0.2",
|
|
16
|
-
"@s_mart/regular-icons": "6.0.
|
|
17
|
-
"@s_mart/solid-icons": "6.0.
|
|
16
|
+
"@s_mart/regular-icons": "6.0.10",
|
|
17
|
+
"@s_mart/solid-icons": "6.0.7"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"@emotion/react": "^11.11.4",
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
"react-hook-form": "^7.51.0",
|
|
33
33
|
"typescript": ">=5.4.2",
|
|
34
34
|
"zod": "^3.22.4",
|
|
35
|
-
"@s_mart/core": "10.0.0-beta.
|
|
35
|
+
"@s_mart/core": "10.0.0-beta.5",
|
|
36
36
|
"@s_mart/masks": "5.2.0",
|
|
37
37
|
"@s_mart/rules": "5.1.2-beta.0",
|
|
38
38
|
"@s_mart/tokens": "5.1.1",
|
|
39
|
-
"@s_mart/typed": "7.2.
|
|
39
|
+
"@s_mart/typed": "7.2.3",
|
|
40
40
|
"@s_mart/utils": "5.3.4"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
@@ -50,11 +50,11 @@
|
|
|
50
50
|
"@types/react-dom": ">=18.3.1",
|
|
51
51
|
"dayjs": "^1.11.10",
|
|
52
52
|
"typescript": ">=5.4.2",
|
|
53
|
-
"@s_mart/core": "10.0.0-beta.4",
|
|
54
53
|
"@s_mart/masks": "5.2.0",
|
|
54
|
+
"@s_mart/core": "10.0.0-beta.5",
|
|
55
55
|
"@s_mart/rules": "5.1.2-beta.0",
|
|
56
56
|
"@s_mart/tokens": "5.1.1",
|
|
57
|
-
"@s_mart/typed": "7.2.
|
|
57
|
+
"@s_mart/typed": "7.2.3",
|
|
58
58
|
"@s_mart/utils": "5.3.4"
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|