@s_mart/form 9.2.0-beta.4 → 9.2.0-beta.6
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 +38 -12
- package/dist/index.mjs +15 -15
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import * as react from 'react';
|
|
|
2
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
3
|
import { AutocompleteProps as AutocompleteProps$1, CheckboxProps as CheckboxProps$1, TextFieldProps as TextFieldProps$1, AutocompleteValue, AutocompleteFreeSoloValueMapping, RadioGroupProps as RadioGroupProps$1, RadioProps as RadioProps$1, SelectProps as SelectProps$1, SliderProps as SliderProps$1, SwitchProps as SwitchProps$1 } from '@mui/material';
|
|
4
4
|
import * as react_hook_form from 'react-hook-form';
|
|
5
|
-
import { UseControllerProps, FieldValues, FieldPath, ControllerProps, FieldPathValue, UseFormReturn, FormProviderProps, UseFormProps } from 'react-hook-form';
|
|
5
|
+
import { UseControllerProps, FieldValues, FieldPath, ControllerProps, FieldPathValue, Control, UseFormReturn, FormProviderProps, UseFormProps } from 'react-hook-form';
|
|
6
6
|
import { DatePickerProps as DatePickerProps$1, TimePickerProps as TimePickerProps$1 } from '@mui/x-date-pickers';
|
|
7
7
|
import { z } from 'zod';
|
|
8
8
|
|
|
@@ -196,25 +196,29 @@ type CreatableV2Props<TFieldValues extends FieldValues = FieldValues, TFieldName
|
|
|
196
196
|
showCreatableButton?: boolean;
|
|
197
197
|
/**
|
|
198
198
|
* Define se mostra o botão para editar uma opção existente
|
|
199
|
+
* Só é possível utilizar se a prop `multiple` for `false | undefined`
|
|
199
200
|
* @default false
|
|
200
201
|
* @type {boolean}
|
|
201
202
|
* @memberof CreatableV2Props
|
|
202
203
|
*/
|
|
203
|
-
showEditableButton?: boolean;
|
|
204
|
+
showEditableButton?: Multiple extends true ? never : boolean;
|
|
204
205
|
/**
|
|
205
206
|
* Função que será executada quando o usuário clicar no botão de criar uma nova opção
|
|
206
|
-
* @default
|
|
207
|
+
* @default undefined
|
|
207
208
|
* @type {(value: string) => void}
|
|
208
209
|
* @memberof CreatableV2Props
|
|
209
210
|
*/
|
|
210
211
|
onCreateOption?: (value: string) => void;
|
|
211
212
|
/**
|
|
212
213
|
* Função que será executada quando o usuário clicar no botão de editar uma opção
|
|
213
|
-
*
|
|
214
|
-
*
|
|
214
|
+
* Só é possível utilizar se a prop `multiple` for `false | undefined`
|
|
215
|
+
* Só é possível editar se o valor for um Objeto
|
|
216
|
+
*
|
|
217
|
+
* @default undefined
|
|
218
|
+
* @type {(value: FieldValue) => Promise<void> | void}
|
|
215
219
|
* @memberof CreatableV2Props
|
|
216
220
|
*/
|
|
217
|
-
onEditOption?: (value:
|
|
221
|
+
onEditOption?: Multiple extends true ? never : ((value: FieldValue) => Promise<void> | void);
|
|
218
222
|
/**
|
|
219
223
|
* Componente que renderiza no footer do searchable (opcional)
|
|
220
224
|
* @example
|
|
@@ -274,6 +278,28 @@ type DatePickerProps<TFieldValues extends FieldValues = FieldValues, TFieldName
|
|
|
274
278
|
|
|
275
279
|
declare const _default$3: react.MemoExoticComponent<(<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)>;
|
|
276
280
|
|
|
281
|
+
type FieldLabelProps = {
|
|
282
|
+
label: React.ReactNode;
|
|
283
|
+
required?: boolean;
|
|
284
|
+
regular?: boolean;
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
declare const FieldLabel: ({ label, required, regular }: FieldLabelProps) => react_jsx_runtime.JSX.Element;
|
|
288
|
+
|
|
289
|
+
type FieldErrorProps<TFieldValues extends FieldValues = FieldValues, TFieldNames extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = {
|
|
290
|
+
name: TFieldNames;
|
|
291
|
+
disableIcon?: boolean;
|
|
292
|
+
control: Control<TFieldValues>;
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
declare const FieldError: <TFieldValues extends FieldValues = FieldValues, TFieldNames extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ name, disableIcon, control, }: FieldErrorProps<TFieldValues, TFieldNames>) => react_jsx_runtime.JSX.Element | null;
|
|
296
|
+
|
|
297
|
+
type FieldInfoProps = {
|
|
298
|
+
title: React.ReactNode;
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
declare const FieldInfo: ({ title }: FieldInfoProps) => react_jsx_runtime.JSX.Element;
|
|
302
|
+
|
|
277
303
|
interface IFormProps<T extends FieldValues> extends IUseFormProps<T> {
|
|
278
304
|
children: ((methods: UseFormReturn<T> & {
|
|
279
305
|
onSubmit: (e?: React.FormEvent | undefined) => Promise<void>;
|
|
@@ -679,9 +705,9 @@ type SliderProps<TFieldValues extends FieldValues = FieldValues, TFieldName exte
|
|
|
679
705
|
labelPlacement?: 'start' | 'end' | 'top' | 'bottom';
|
|
680
706
|
};
|
|
681
707
|
|
|
682
|
-
declare const Slider: <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>>({ name, rules, defaultValue, shouldUnregister, control: controlFromProps, ...rest }: SliderProps<TFieldValues, TFieldName>) => react_jsx_runtime.JSX.Element;
|
|
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;
|
|
683
709
|
|
|
684
|
-
type SwitchProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = SwitchProps$1 & UseControllerProps<TFieldValues, TFieldName> & {
|
|
710
|
+
type SwitchProps<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = SwitchProps$1 & UseControllerProps<TFieldValues, TFieldName> & {
|
|
685
711
|
/**
|
|
686
712
|
* O nome do switch que será renderizado na tela
|
|
687
713
|
* @default ''
|
|
@@ -708,7 +734,7 @@ type SwitchProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<
|
|
|
708
734
|
disableIconError?: boolean;
|
|
709
735
|
};
|
|
710
736
|
|
|
711
|
-
declare const Switch: <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>>({ name, rules, defaultValue, shouldUnregister, control: controlFromProps, label, labelPlacement, disableIconError, onChange: onChangeProp, ...rest }: SwitchProps<TFieldValues, TFieldName>) => react_jsx_runtime.JSX.Element;
|
|
737
|
+
declare const Switch: <TFieldValues extends FieldValues = FieldValues, 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;
|
|
712
738
|
|
|
713
739
|
type Masks = 'cpf' | 'cnpj' | 'cpfCnpj' | 'cep' | 'telefone' | 'decimal' | 'decimal3' | 'decimal4' | 'decimal5' | 'porcentagem' | 'porcentagem0' | 'nome' | 'numero' | 'numeroPontuacao' | 'placa' | 'valor' | 'valor3' | 'valor4';
|
|
714
740
|
type TextFieldProps<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = TextFieldProps$1 & UseControllerProps<TFieldValues, TFieldName> & {
|
|
@@ -754,7 +780,7 @@ type TextFieldProps<TFieldValues extends FieldValues = FieldValues, TFieldName e
|
|
|
754
780
|
|
|
755
781
|
declare const TextField: <TFieldValues extends FieldValues = FieldValues, 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;
|
|
756
782
|
|
|
757
|
-
type TimePickerProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = UseControllerProps<TFieldValues, TFieldName> & Pick<TextFieldProps$1, 'label' | 'error' | 'helperText' | 'size' | 'fullWidth' | 'variant' | 'autoFocus' | 'placeholder'> & {
|
|
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'> & {
|
|
758
784
|
timePickerProps?: Partial<TimePickerProps$1<any>>;
|
|
759
785
|
/**
|
|
760
786
|
* Se `true` irá adicionar um asterisco ao label do campo
|
|
@@ -778,6 +804,6 @@ type TimePickerProps<TFieldValues extends FieldValues, TFieldName extends FieldP
|
|
|
778
804
|
disableIconError?: boolean;
|
|
779
805
|
};
|
|
780
806
|
|
|
781
|
-
declare const _default: react.MemoExoticComponent<(<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>>({ rules, defaultValue, shouldUnregister, name, control: controlFromProps, required, label, timePickerProps, placeholder, disabled, disableIconError, ...rest }: TimePickerProps<TFieldValues, TFieldName>) => react_jsx_runtime.JSX.Element)>;
|
|
807
|
+
declare const _default: react.MemoExoticComponent<(<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)>;
|
|
782
808
|
|
|
783
|
-
export { type AutoCompleteOption, _default$5 as Autocomplete, type AutocompleteProps, Checkbox, type CheckboxProps, Creatable, type CreatableOption, type CreatableProps, _default$4 as CreatableV2, type CreatableV2Props, _default$3 as DatePicker, type DatePickerProps, type FooterProps, type FooterPropsV2, Form, FormProvider, type IFormProps, type IFormProviderProps, type IUseFormProps, type Masks, RadioButton, RadioGroup, type RadioGroupProps, type RadioProps, Searchable, type SearchableOption, type SearchableProps, _default$2 as SearchableV2, type SearchableV2Props, Select, type SelectOption, type SelectProps, type SelectProps as SelectPropsMui, _default$1 as SelectV2, type SelectV2Props, type SelectV2ReturnValueProps, Slider, type SliderProps, Switch, type SwitchProps, TextField, type TextFieldProps, _default as TimePicker, type TimePickerProps, useForm };
|
|
809
|
+
export { type AutoCompleteOption, _default$5 as Autocomplete, type AutocompleteProps, Checkbox, type CheckboxProps, Creatable, type CreatableOption, type CreatableProps, _default$4 as CreatableV2, type CreatableV2Props, _default$3 as DatePicker, type DatePickerProps, FieldError, type FieldErrorProps, FieldInfo, type FieldInfoProps, FieldLabel, type FieldLabelProps, type FooterProps, type FooterPropsV2, Form, FormProvider, type IFormProps, type IFormProviderProps, type IUseFormProps, type Masks, RadioButton, RadioGroup, type RadioGroupProps, type RadioProps, Searchable, type SearchableOption, type SearchableProps, _default$2 as SearchableV2, type SearchableV2Props, Select, type SelectOption, type SelectProps, type SelectProps as SelectPropsMui, _default$1 as SelectV2, type SelectV2Props, type SelectV2ReturnValueProps, Slider, type SliderProps, Switch, type SwitchProps, TextField, type TextFieldProps, _default as TimePicker, type TimePickerProps, useForm };
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import{Autocomplete as Fo,Grid as
|
|
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:"*"})]}),v=fo;var T=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 Vo=({name:e,defaultValue:o,rules:l,shouldUnregister:i,label:s,required:P,noOptionsText:V,placeholder:c,onInputChange:S,onChange:x,disableIconError:C,...m})=>{let u=Po();if(!u)throw new T("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(v,{label:s,required:P}),Z(Fo,{onChange:(g,n)=>{p.onChange(n),x?.(n,u.getValues())},onInputChange:(g,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:(g,n)=>g.value===n.value,renderOption:(g,n)=>Co("li",{...g,key:n.key||n.value,onClick:F=>{g.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:V||"Nenhuma op\xE7\xE3o encontrada",...m,renderInput:g=>Z(yo,{placeholder:c,...g,error:!!a,slotProps:{input:{inputProps:g.inputProps,inputRef:p.ref}}})},e),Z(k,{name:e,disableIcon:C,control:u.control})]})})},go=bo(Vo);import{useController as vo,useFormContext as To}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:V,required:c,disableIconError:S,onChange:x,...C})=>{let m=To()?.control,u=s??m;if(!u)throw new T("Checkbox");let{field:a}=vo({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,g)=>{a.onChange(p,g),x?.(p,g)},...C},e),label:pe(v,{label:P,required:c,regular:!0}),labelPlacement:V||"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;
|
|
5
|
-
`,
|
|
5
|
+
`,Ro=e=>Ae`
|
|
6
6
|
.creatable,
|
|
7
7
|
.editable {
|
|
8
|
-
${
|
|
8
|
+
${Re}
|
|
9
9
|
|
|
10
10
|
.divider {
|
|
11
11
|
width: 1px;
|
|
@@ -31,14 +31,14 @@ import{Autocomplete as Fo,Grid as de,TextField as yo}from"@mui/material";import{
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
`,
|
|
34
|
+
`,De=Ao("div")`
|
|
35
35
|
display: flex;
|
|
36
36
|
|
|
37
37
|
div.endAdornments {
|
|
38
38
|
position: absolute;
|
|
39
39
|
right: 0;
|
|
40
40
|
|
|
41
|
-
${
|
|
41
|
+
${Re}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
.MuiAutocomplete-endAdornment {
|
|
@@ -50,8 +50,8 @@ import{Autocomplete as Fo,Grid as de,TextField as yo}from"@mui/material";import{
|
|
|
50
50
|
transform: translate(0, 0);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
${({hideAddButton:e,theme:o})=>!e&&
|
|
54
|
-
`;import{Fragment as be,jsx as
|
|
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:V,editable:c,footer:S,onEditOption:x,onCreateOption:C,textFieldProps:m,hideAddButton:u,multiple:a,info:p,onChange:g,onInputChange:n,placeholder:F,disableIconError:A,...r})=>{let y=Mo();if(!y)throw new T("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(v,{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),g?.(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:V,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;
|
|
@@ -80,7 +80,7 @@ import{Autocomplete as Fo,Grid as de,TextField as yo}from"@mui/material";import{
|
|
|
80
80
|
|
|
81
81
|
.divider {
|
|
82
82
|
width: 1px;
|
|
83
|
-
height: ${
|
|
83
|
+
height: ${fe(20)};
|
|
84
84
|
background-color: ${({theme:e})=>e.palette.grey[400]};
|
|
85
85
|
}
|
|
86
86
|
|
|
@@ -91,9 +91,9 @@ import{Autocomplete as Fo,Grid as de,TextField as yo}from"@mui/material";import{
|
|
|
91
91
|
color: ${({theme:e})=>e.palette.grey[600]};
|
|
92
92
|
border-radius: 50%;
|
|
93
93
|
|
|
94
|
-
margin: 0 ${
|
|
95
|
-
width: ${
|
|
96
|
-
height: ${
|
|
94
|
+
margin: 0 ${fe(6)};
|
|
95
|
+
width: ${fe(28)};
|
|
96
|
+
height: ${fe(28)};
|
|
97
97
|
|
|
98
98
|
&:hover {
|
|
99
99
|
cursor: pointer;
|
|
@@ -102,16 +102,16 @@ import{Autocomplete as Fo,Grid as de,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"})})}),
|
|
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 Ve,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:V,required:c,options:S,footer:x,showCreatableButton:C=!0,showEditableButton:m,onEditOption:u,onCreateOption:a,getOptionKey:p,getOptionLabel:g,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 T("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:[V&&M(v,{label:V,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 _(Ve,{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:_(Ve,{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"&&_(Ve,{children:[M("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:M(Ge,{})}),x()]})]}),isOptionEqualToValue:($,E)=>st($,E),getOptionLabel:g,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:g(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 gt,TextField as Ct}from"@mui/material";import{AdapterDayjs as vt}from"@mui/x-date-pickers/AdapterDayjs";import{DatePicker as Tt}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)}},Vt=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})=>Vt(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 fe,jsxs as Ot}from"react/jsx-runtime";import{createElement as Mt}from"react";var Bt=({rules:e,name:o,defaultValue:l,shouldUnregister:i,control:d,datePickerProps:P,label:g,required:f,placeholder:T,disabled:x,disableIconError:C,...m})=>{let u=Dt()?.control,a=d??u;if(!a)throw new v("DatePicker");let p=Rt({control:a,name:o}),V=R(p.errors,o),n=P?.format||"DD/MM/YYYY",F=e?It([Ue(n),e]):Ue(n),{field:L}=Lt({control:a,name:o,rules:F,defaultValue:l,shouldUnregister:i});return fe(St,{dateAdapter:vt,adapterLocale:wt,localeText:kt.components.MuiLocalizationProvider.defaultProps.localeText,children:Ot(Vt,{children:[g&&fe(S,{label:g,required:f}),Mt(Tt,{...P,key:o,value:L.value??null,format:n,onChange:(r,y)=>{L.onChange(r,y),P?.onChange?.(r,y)},disabled:x,slots:{textField:Ct,openPickerButton:r=>fe(_e,{...r,size:m.size})},slotProps:{textField:r=>({variant:"outlined",...r,error:!!V,...m,inputProps:{...r.inputProps,placeholder:T||r.inputProps?.placeholder},InputProps:{...r.InputProps,inputRef:y=>{L.ref(y),typeof r.inputRef=="function"&&r.inputRef(y)}}})}}),fe(I,{name:o,disableIcon:C,control:a})]})})},Et=At(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:d=>{d.preventDefault(),d.stopPropagation(),l(d)},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(d=>o(d,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 ve,jsxs as Zt}from"react/jsx-runtime";var Xt=({name:e,rules:o,defaultValue:l,shouldUnregister:i,control:d,label:P,required:g,children:f,orientation:T="row",disableIconError:x,...C})=>{let m=Jt()?.control,u=d??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&&ve(S,{label:P,required:g}),ve(Wt,{value:a.value||"",name:e,...C,onChange:p=>{C?.onChange?.(p,p.target?.value),a.onChange(p)},style:{display:"flex",flexDirection:T},children:f},e),ve(I,{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(S,{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 sr}from"@s_mart/core";import{lineInfoCircle as dr}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 cr,useFormContext as fr}from"react-hook-form";import{Fragment as ye,jsx as $,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:d,required:P,options:g,textFieldProps:f,noOptionsText:T,footer:x,multiple:C,info:m,placeholder:u,onChange:a,onInputChange:p,disableIconError:V,...n})=>{let F=fr();if(!F)throw new v("Searchable");let L=R(F.formState.errors,e);return $(cr,{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:[d&&$(j,{item:!0,children:$(S,{label:d,required:P})}),m&&$(j,{item:!0,children:$(ar,{title:m,placement:"top",children:$("div",{style:{width:"fit-content"},children:$(sr,{icon:dr,color:"#757575"})})})})]}),$(ir,{onChange:(b,s)=>{r(s),a?.(s,F.getValues())},onInputChange:(b,s,w)=>{w==="input"&&setTimeout(()=>{p?.(s,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(s,w){return oe(ye,{children:[$("ul",{...s,ref:w}),!!x&&$("div",{...s,children:oe(ye,{children:[$(j,{sx:{px:2,py:1},children:$(Ke,{})}),x]})},"searchable-footer")]})})}},value:y||(C?[]:null),options:g,multiple:C,readOnly:n.disabled,noOptionsText:oe(ye,{children:[T||"Nenhum resultado encontrado",x?oe(ye,{children:[$(j,{sx:{py:1},children:$(Ke,{})}),x]}):null]}),isOptionEqualToValue:(b,s)=>typeof b=="string"&&typeof s=="string"?b===s:typeof b=="object"&&typeof s=="object"?typeof b.value=="object"&&typeof s.value=="object"&&b.key!==void 0&&s.key!==void 0?b.key===s.key:b.value===s.value:!1,renderOption:(b,s)=>typeof s=="object"?We("li",{...b,key:s.key||s.value},oe(j,{container:!0,direction:"column",children:[$(j,{item:!0,children:s.label}),s.afterLabel&&$(j,{item:!0,children:s.afterLabel})]})):We("li",{...b,key:s},s),...n,renderInput:b=>$(nr,{error:!!L,placeholder:u,...b,...f,inputRef:G})},e),$(I,{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 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:d,control:P,label:g,required:f,options:T,textFieldProps:x,noOptionsText:C,footer:m,multiple:u,info:a,placeholder:p,onChange:V,onInputChange:n,getOptionAfterLabel:F,getOptionLabel:L,getOptionKey:r,...y}=e,G=Vr()?.control,b=P??G;if(!b)throw new v("SearchableV2");let s=Cr({control:b,name:o}),w=R(s.errors,o),{field:A}=gr({name:o,control:b,rules:l,defaultValue:i,shouldUnregister:d});return te("div",{style:{display:"flex",flexDirection:"column"},children:[te("div",{style:{display:"flex"},children:[g&&q(S,{label:g,required:f}),a&&q(ee,{title:a})]}),q(yr,{onChange:(c,t)=>{A.onChange(t),V?.(t)},onInputChange:(c,t,k)=>{k==="input"&&n?.(t)},value:A.value,options:T,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,k){return te(Te,{children:[q("ul",{...t,ref:k}),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:(c,t)=>hr(c,t),getOptionLabel:L,getOptionKey:r,renderOption:typeof F=="function"?(c,t)=>{let k=F(t),z=r(t);return Sr("li",{...c,key:z},te("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[q("span",{children:L(t)}),typeof k=="string"?q("span",{children:k}):k]}))}:void 0,...y,renderInput:c=>q(xr,{error:!!w,placeholder:p,...c,...x,inputRef:A.ref})},o),q(I,{name:o,control:b})]})},Tr=ie(vr);import{Divider as kr,Grid as re,MenuItem as Ir,Select as wr,Tooltip as Ar,useTheme as Lr}from"@mui/material";import{IconButton as Dr,LIcon as Je}from"@s_mart/core";import{lineTimes as Rr}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:d,required:P,options:g,placeholder:f,clearable:T,disableOnChangeForm:x=!1,multiple:C,info:m,footer:u,onChange:a,disableIconError:p,variant:V="outlined",...n})=>{let F=Nr(),{palette:L}=Lr(),[r,y]=Or(!1);if(!F)throw new v("Select");let G=R(F.formState.errors,e);return N($r,{control:F.control,name:e,rules:o,defaultValue:l,shouldUnregister:i,render:({field:{value:b,onChange:s,ref:w}})=>ae(re,{sx:{display:"flex",flexDirection:"column"},children:[ae("div",{style:{display:"flex"},children:[d&&N(re,{item:!0,children:N(S,{label:d,required:P})}),m&&N(re,{item:!0,children:N(Ar,{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:!!f,variant:V,autoComplete:"off",value:b?b||"":C?[]:"",renderValue:A=>{if(A.label)return A.label;if(f)return N("p",{style:{color:L.grey[400]},children:f})},multiple:C,onChange:A=>{!x&&s(A.target.value),a&&a(A.target.value,F.getValues())},error:!!G,size:n.size||"medium",inputRef:w,...n,endAdornment:ae(zr,{children:[n.endAdornment,!!(T&&b)&&N(Dr,{variant:"text",color:"neutral",size:"small",sx:{borderRadius:"50%",position:"absolute",right:"2rem"},style:{padding:0},"aria-label":"Clear",title:"Clear",onClick:()=>{!x&&s(null),a&&a(null,F.getValues())},children:N(Je,{icon:Rr,color:Er.neutral[100],size:"25px",removeMargin:!0})})]}),children:[g?.map((A,c)=>N(Ir,{value:A,children:ae(re,{container:!0,direction:"column",children:[N(re,{item:!0,children:A.label}),A.afterLabel&&N(re,{item:!0,children:A.afterLabel})]})},c)),u&&[N(re,{sx:{px:2,py:1},children:N(kr,{})},"footer-divider"),N("div",{children:u({closeSelect:()=>y(!1)})},"footer-content")]]},e),N(I,{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:d,control:P,label:g,required:f,options:T,placeholder:x,clearable:C,info:m,footer:u,onChange:a,variant:p="outlined",getOptionKey:V,getOptionLabel:n,getOptionAfterLabel:F,getOptionIcon:L,...r}=e,y=Kr()?.control,G=P??y,[b,s]=Ur(!1);if(!G)throw new v("SelectV2");let w=Wr({control:G,name:o}),A=R(w.errors,o),{field:c}=Hr({control:G,name:o,rules:l,defaultValue:i,shouldUnregister:d});return le("div",{style:{display:"flex",flexDirection:"column"},children:[le("div",{style:{display:"flex"},children:[g&&U(S,{label:g,required:f}),m&&U(ee,{title:m})]}),le(Qr,{open:b,onOpen:()=>s(!0),onClose:()=>s(!1),displayEmpty:!!x,variant:p,autoComplete:"off",value:c.value||null,renderValue:t=>U(Qe,{getOptionLabel:n,placeholder:x,value:t}),onChange:t=>{c.onChange(t.target.value),a?.(t.target.value)},error:!!A,size:r.size||"medium",inputRef:c.ref,...r,endAdornment:le(rl,{children:[r.endAdornment,!!(C&&c.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:()=>{c.onChange(null),a?.(null)},children:U(jr,{icon:Jr,color:Xr.neutral[100],size:"25px",removeMargin:!0})})]}),children:[T.map(t=>{let k=V(t),z=n(t),J=L?.(t);return U(Zr,{value:k??z,children:le("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[J!==void 0?le("div",{style:{display:"flex",alignItems:"center"},children:[J,z]}):z,U("span",{children:F?.(t)??null})]})},k)}),u!==void 0&&le("div",{children:[U("div",{style:{padding:"8px 16px"},children:U(el,{})},"footer-divider"),U("div",{children:u({closeSelect:()=>s(!1)})},"footer-content")]},"footer")]},o),U(I,{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 dl}from"react/jsx-runtime";var al=({name:e,rules:o,defaultValue:l,shouldUnregister:i,control:d,...P})=>{let g=il()?.control,f=d??g;if(!f)throw new v("Slider");let{field:T}=ll({control:f,name:e,rules:o,defaultValue:l,shouldUnregister:i});return dl(nl,{value:T.value||P?.min||0,onChange:T.onChange,valueLabelDisplay:"auto",...P},e)},sl=al;import{FormControlLabel as pl,Stack as ml,Switch as ul}from"@mui/material";import{useController as cl,useFormContext as fl}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:d,label:P,labelPlacement:g,disableIconError:f,onChange:T,...x})=>{let C=fl()?.control,m=d??C;if(!m)throw new v("Switch");let{field:u}=cl({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),T?.(a,p)},...x},e),label:xe(S,{label:P}),labelPlacement:g||"end"}),xe(I,{name:e,disableIcon:f,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 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 Al=({name:e,rules:o,defaultValue:l,shouldUnregister:i,control:d,label:P,required:g,mask:f,variant:T="outlined",info:x,parse:C,format:m,onInputChange:u,disableIconError:a,...p})=>{let V=Il()?.control,n=d??V,F=Tl(l||void 0);if(!n)throw new v("TextField");let[L,r]=Sl(!1),y=c=>{let t=c;return t=m?.(c)??c,f?eo?.[f]?.format(t):t},G=c=>{let t=c;return t=C?.(c)??t,f?eo?.[f]?.parse(t,F.current):t},b=c=>{if(!c||f!=="porcentagem"&&f!=="porcentagem0")return;c?.stopPropagation();let t=(c?.target).value;if(t){let k=String(t);if(k.length>0){let z=k.indexOf("%");z>-1&&(c.currentTarget.selectionEnd=z)}}},{field:s}=kl({control:n,name:e,rules:o,defaultValue:l,shouldUnregister:i}),w=wl({control:n,name:e}),A=R(w.errors,e);return oo(hl,{children:[oo("div",{style:{display:"flex"},children:[P&&W("div",{children:W(S,{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:vl,color:"#757575"})})})})]}),W(Pl,{variant:T,defaultValue:l,value:y(s.value||(s.value!=0?"":s.value)),onChange:c=>{let t=G(c?.target?.value);s.onChange(t),u?.(t),F.current=c.target.value},error:!!A,...p,type:p.type==="password"?L?"text":"password":p.type,autoComplete:p.autoComplete||"off",slotProps:{input:{onKeyDown:b,inputRef:s.ref,endAdornment:p.type==="password"&&W(bl,{position:"start",onClick:()=>r(!L),style:{cursor:"pointer"},children:W(Ze,{icon:L?Vl:Cl,size:"24px",removeMargin:!0})}),...p.InputProps}}},e),W(I,{name:e,disableIcon:a,control:n})]})},Ll=Al;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 Dl}from"@mui/material";import{IconButton as Rl}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=Dl(Rl)`
|
|
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)`
|
|
115
115
|
margin: 0px;
|
|
116
116
|
|
|
117
117
|
padding: ${({size:e})=>El(e)};
|
|
@@ -120,4 +120,4 @@ import{Autocomplete as Fo,Grid as de,TextField as yo}from"@mui/material";import{
|
|
|
120
120
|
svg {
|
|
121
121
|
width: ${({size:e})=>Bl(e)} !important;
|
|
122
122
|
}
|
|
123
|
-
`;import{jsx as
|
|
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:V,timePickerProps:c,placeholder:S,disabled:x,disableIconError:C,...m})=>{let u=Kl()?.control,a=s??u;if(!a)throw new T("TimePicker");let p=Wl({control:a,name:i}),g=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:[V&&de(v,{label:V,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:!!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)}}})}},i),de(k,{name:i,disableIcon:C,control:a})]})})},jl=Ul(Yl);export{go as Autocomplete,wo as Checkbox,Wo as Creatable,yt as CreatableV2,Et as DatePicker,k as FieldError,j as FieldInfo,v as FieldLabel,Ht as Form,ge as FormProvider,lr as RadioButton,Qt as RadioGroup,Fr as Searchable,Tr 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.6",
|
|
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.
|
|
35
|
+
"@s_mart/core": "9.1.5-beta.3",
|
|
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/
|
|
40
|
-
"@s_mart/
|
|
39
|
+
"@s_mart/utils": "5.3.4",
|
|
40
|
+
"@s_mart/typed": "7.2.2"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@emotion/styled": "^11.13.0",
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
"@types/react-dom": ">=18.3.1",
|
|
51
51
|
"dayjs": "^1.11.10",
|
|
52
52
|
"typescript": ">=5.4.2",
|
|
53
|
+
"@s_mart/core": "9.1.5-beta.3",
|
|
53
54
|
"@s_mart/masks": "5.2.0",
|
|
54
55
|
"@s_mart/rules": "5.1.2-beta.0",
|
|
55
|
-
"@s_mart/core": "9.1.5-beta.2",
|
|
56
56
|
"@s_mart/tokens": "5.1.1",
|
|
57
57
|
"@s_mart/typed": "7.2.2",
|
|
58
58
|
"@s_mart/utils": "5.3.4"
|