@s_mart/form 9.2.0-beta.3 → 9.2.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,254 +1,65 @@
1
- import * as react_hook_form from 'react-hook-form';
2
- import { FieldValues, UseFormReturn, FormProviderProps, UseFormProps, FieldPath, UseControllerProps, ControllerProps, FieldPathValue } from 'react-hook-form';
3
- import { z } from 'zod';
4
1
  import * as react from 'react';
5
2
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
- import { TextFieldProps as TextFieldProps$1, SelectProps as SelectProps$1, AutocompleteProps as AutocompleteProps$1, CheckboxProps as CheckboxProps$1, SwitchProps as SwitchProps$1, RadioGroupProps as RadioGroupProps$1, RadioProps as RadioProps$1, SliderProps as SliderProps$1, AutocompleteValue, AutocompleteFreeSoloValueMapping } from '@mui/material';
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
+ import * as react_hook_form from 'react-hook-form';
5
+ import { UseControllerProps, FieldValues, FieldPath, ControllerProps, FieldPathValue, UseFormReturn, FormProviderProps, UseFormProps } from 'react-hook-form';
7
6
  import { DatePickerProps as DatePickerProps$1, TimePickerProps as TimePickerProps$1 } from '@mui/x-date-pickers';
7
+ import { z } from 'zod';
8
8
 
9
- interface IFormProps<T extends FieldValues> extends IUseFormProps<T> {
10
- children: ((methods: UseFormReturn<T> & {
11
- onSubmit: (e?: React.FormEvent | undefined) => Promise<void>;
12
- }) => React.ReactNode) | React.ReactNode;
13
- style?: React.HTMLAttributes<HTMLFormElement>['style'];
14
- }
15
- interface IFormProviderProps<TFieldValues extends FieldValues> extends FormProviderProps<TFieldValues> {
16
- style?: React.HTMLAttributes<HTMLFormElement>['style'];
17
- onSubmit: (e?: React.BaseSyntheticEvent) => void;
18
- }
19
- interface IUseFormProps<TValues extends FieldValues> extends Omit<UseFormProps<TValues>, 'resolver'> {
20
- onSubmit: (data: TValues, methods: UseFormReturn<TValues>) => void;
21
- /**
22
- * Prop que faz com que o formulário não atualize ao mudar o defaultValue
23
- */
24
- disableDefaultValuesUpdate?: boolean;
25
- schema?: z.ZodObject<any> | z.ZodEffects<z.ZodObject<any>>;
26
- }
27
-
28
- /**
29
- * Utilizado overloading para poder passar uma tipagem para o Componente
30
- * @example
31
- * // Não passar uma tipagem, todas as props terão o funcionamento normal, sem tipagem
32
- * <Form onSubmit={({email}) => {}}>
33
- * ...
34
- * </Form>
35
- * @example
36
- * // Passar uma tipagem, todas as props derivadas do react-hook-form terão a tipagem passada no generic
37
- * type Cadastro = {
38
- * email: string;
39
- * }
40
- * <Form<Cadastro> onSubmit={({email}) => {}}>
41
- * ...
42
- * </Form>
43
- */
44
- declare function Form(props: IFormProps<any>): JSX.Element;
45
- declare function Form<T extends FieldValues>(props: IFormProps<T>): JSX.Element;
46
-
47
- declare const useForm: <TValues extends FieldValues>({ disableDefaultValuesUpdate, onSubmit, ...rest }: IUseFormProps<TValues>) => {
48
- onSubmit: (e?: react.BaseSyntheticEvent<object, any, any> | undefined) => Promise<void>;
49
- watch: react_hook_form.UseFormWatch<TValues>;
50
- getValues: react_hook_form.UseFormGetValues<TValues>;
51
- getFieldState: react_hook_form.UseFormGetFieldState<TValues>;
52
- setError: react_hook_form.UseFormSetError<TValues>;
53
- clearErrors: react_hook_form.UseFormClearErrors<TValues>;
54
- setValue: react_hook_form.UseFormSetValue<TValues>;
55
- trigger: react_hook_form.UseFormTrigger<TValues>;
56
- formState: react_hook_form.FormState<TValues>;
57
- resetField: react_hook_form.UseFormResetField<TValues>;
58
- reset: react_hook_form.UseFormReset<TValues>;
59
- handleSubmit: react_hook_form.UseFormHandleSubmit<TValues, undefined>;
60
- unregister: react_hook_form.UseFormUnregister<TValues>;
61
- control: react_hook_form.Control<TValues, any>;
62
- register: react_hook_form.UseFormRegister<TValues>;
63
- setFocus: react_hook_form.UseFormSetFocus<TValues>;
64
- };
65
-
66
- declare function FormProvider<TFieldValues extends FieldValues>({ children, style, onSubmit, ...methods }: IFormProviderProps<TFieldValues>): react_jsx_runtime.JSX.Element;
67
-
68
- type Masks = 'cpf' | 'cnpj' | 'cpfCnpj' | 'cep' | 'telefone' | 'decimal' | 'decimal3' | 'decimal4' | 'decimal5' | 'porcentagem' | 'porcentagem0' | 'nome' | 'numero' | 'numeroPontuacao' | 'placa' | 'valor' | 'valor3' | 'valor4';
69
- type TextFieldProps<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = TextFieldProps$1 & UseControllerProps<TFieldValues, TFieldName> & {
70
- mask?: Masks;
71
- /**
72
- * @description Função que será executada quando o valor do input for alterado
73
- * @param value valor atual do Field
74
- * @param values valores atuais do Form
75
- *
76
- * @example onInputChange={(values,values) => console.log({value, values})}
77
- */
78
- onInputChange?: (value: string) => void;
79
- /**
80
- * @param value Valor do input
81
- * @returns Valor formatado para o input
82
- *
83
- * @example
84
- * <TextField mask="cpf" parse={(value) => value.replace(/\D/g, '')} />
85
- */
86
- parse?: (value: string) => string;
87
- /**
88
- * @param value Valor do input formatado
89
- * @returns Valor sem formatação para o input
90
- *
91
- * @example
92
- * <TextField mask="cpf" format={(value) => value.replace(/\D/g, '')} />
93
- */
94
- format?: (value: string) => string;
95
- /**
96
- * É o conteúdo passado para a tooltip que renderizará ao lado da label do campo,
97
- * montada à tela como um ícone de informação.
98
- */
99
- info?: React.ReactNode;
100
- /**
101
- * Desabilita o ícone de erro da validação do campo.
102
- * @default false
103
- *
104
- * @example
105
- * <TextField disableIconError />
106
- */
107
- disableIconError?: boolean;
108
- };
109
-
110
- 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;
111
-
112
- type ControllerSelect = Omit<ControllerProps, 'render' | 'control'>;
113
- /**
114
- * @deprecated
115
- */
116
- type SelectOption = {
9
+ type AutoCompleteOption = {
10
+ key?: string | number;
117
11
  label: string;
118
12
  value: string | number | readonly string[] | undefined;
119
13
  afterLabel?: string | React.ReactNode;
120
14
  };
121
- /**
122
- * @deprecated
123
- */
124
- type FooterProps = {
125
- closeSelect: () => void;
126
- };
127
- /**
128
- * @deprecated
129
- */
130
- type SelectProps = Omit<SelectProps$1, 'onChange'> & ControllerSelect & {
15
+ type AutocompleteProps<ValueType = any> = Omit<UseControllerProps, 'control'> & Omit<AutocompleteProps$1<ValueType, any, any, any>, 'renderInput' | 'size' | 'onInputChange' | 'onChange' | 'options'> & {
131
16
  /**
132
- * As opções que serão renderizadas no select
133
- *
134
- * @type {SelectOption[]}
17
+ * Opções do autocomplete
18
+ * @default []
135
19
  *
136
20
  * @example
137
- * options: [
138
- * { label: 'Option 1', value: 'option1' },
139
- * { label: 'Option 2', value: 'option2' },
21
+ * [
22
+ * { label: 'Opção 1', value: '1' },
140
23
  * ]
141
- */
142
- options: SelectOption[];
143
- onChange?: (value: any, values: FieldValues) => void;
144
- /**
145
- * Desabilita o onChange do select, para que o onChange do form não seja disparado
146
- *
147
- * @type {boolean}
148
- * @default false
149
24
  *
150
- * @example
151
- * <Select name="select" options={options} disableOnChangeForm />
152
- */
153
- disableOnChangeForm?: boolean;
154
- /**
155
- * Função que renderiza o footer do select (opcional) - recebe como parâmetro a função closeSelect que fecha o select
156
- * @param {FooterProps} props
157
- *
158
- * @example
159
- * footer: ({ closeSelect }) => (
160
- * <Button onClick={closeSelect}>Fechar</Button>
161
- * )
162
- *
163
- */
164
- footer?: (props: FooterProps) => React.ReactNode;
165
- /**
166
- * É o conteúdo passado para a tooltip que renderizará ao lado da label do campo,
167
- * montada à tela como um ícone de informação.
25
+ * @type {AutoCompleteOption[]}
26
+ * @memberof AutocompleteProps
168
27
  */
169
- info?: React.ReactNode;
28
+ options: AutoCompleteOption[];
29
+ label?: React.ReactNode;
30
+ required?: boolean;
31
+ onInputChange?: (value: string, values: FieldValues) => void;
32
+ onChange?: (value: any, values: FieldValues) => void;
170
33
  /**
171
34
  * Desabilita o ícone de erro da validação do campo.
172
35
  * @default false
173
36
  *
174
37
  * @example
175
- * <Select disableIconError />
38
+ * <TextField disableIconError />
176
39
  */
177
40
  disableIconError?: boolean;
178
- /**
179
- * Habilita ícone no endAdornment para limpar o valor do campo.
180
- * @default false
181
- *
182
- * @example
183
- * <Select clearable />
184
- */
185
- clearable?: boolean;
41
+ placeholder?: string;
186
42
  };
187
43
 
188
- /**
189
- * @deprecated usar SelectV2
190
- */
191
- declare const Select: react.MemoExoticComponent<({ name, rules, defaultValue, shouldUnregister, label, required, options, placeholder, clearable, disableOnChangeForm, multiple, info, footer, onChange: onChangeProp, disableIconError, variant, ...rest }: SelectProps) => react_jsx_runtime.JSX.Element>;
44
+ declare const _default$5: react.MemoExoticComponent<({ name, defaultValue, rules, shouldUnregister, label, required, noOptionsText, placeholder, onInputChange, onChange, disableIconError, ...rest }: AutocompleteProps) => react_jsx_runtime.JSX.Element>;
192
45
 
193
- type ControllerSearchable = Omit<ControllerProps, 'render' | 'control'>;
194
- /**
195
- * @deprecated usar SearchableV2
196
- */
197
- type SearchableOption = {
198
- key?: string | number;
199
- label: string;
200
- value: string | number | readonly string[] | undefined;
201
- afterLabel?: string | React.ReactNode;
202
- } | string;
203
- /**
204
- * @deprecated usar SearchableV2
205
- */
206
- type SearchableProps = Omit<AutocompleteProps$1<SearchableOption, true, true, true>, 'renderInput' | 'size' | 'onInputChange' | 'onChange'> & ControllerSearchable & {
207
- /**
208
- * Opções do autocomplete
209
- * @default []
210
- *
211
- * @example
212
- * [
213
- * { label: 'Opção 1', value: '1' },
214
- * ]
215
- *
216
- * @type {SearchableOption[]}
217
- * @memberof SearchableProps
218
- */
219
- options: SearchableOption[];
46
+ type CheckboxProps<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = CheckboxProps$1 & UseControllerProps<TFieldValues, TFieldName> & {
220
47
  /**
221
- * Props do textField que é renderizado dentro do autocomplete
222
- * @default {}
223
- * @type {TextFieldProps}
224
- * @memberof SearchableProps
48
+ * O nome do checkbox que será renderizado na tela
49
+ * @default ''
50
+ * @example 'Nome do checkbox'
51
+ * @type string
52
+ * @memberof CheckboxProps
225
53
  */
226
- textFieldProps?: TextFieldProps$1;
227
54
  label?: React.ReactNode;
228
- required?: boolean;
229
55
  /**
230
- * Texto que será exibido quando não houver opções para serem exibidas
231
- * @default 'Nenhuma opção encontrada'
232
- */
233
- noOptionsText?: string;
234
- /**
235
- * Componente que renderiza no footer do searchable (opcional)
236
- *
56
+ * Posição do label em relação ao checkbox
57
+ * @default 'end'
58
+ * @type 'start' | 'end' | 'top' | 'bottom'
237
59
  * @example
238
- * footer: (
239
- * <Button onClick={handleClick}>Mostrar mais...</Button>
240
- * )
241
- *
242
- *
243
- */
244
- footer?: React.ReactNode;
245
- /**
246
- * É o conteúdo passado para a tooltip que renderizará ao lado da label do campo,
247
- * montada à tela como um ícone de informação.
60
+ * <Checkbox label="Checkbox" labelPlacement="start" />
248
61
  */
249
- info?: React.ReactNode;
250
- onInputChange?: (value: string, values: FieldValues) => void;
251
- onChange?: (value: any, values: FieldValues) => void;
62
+ labelPlacement?: 'start' | 'end' | 'top' | 'bottom';
252
63
  /**
253
64
  * Desabilita o ícone de erro da validação do campo.
254
65
  * @default false
@@ -257,13 +68,9 @@ type SearchableProps = Omit<AutocompleteProps$1<SearchableOption, true, true, tr
257
68
  * <TextField disableIconError />
258
69
  */
259
70
  disableIconError?: boolean;
260
- placeholder?: string;
261
71
  };
262
72
 
263
- /**
264
- * @deprecated usar SearchableV2
265
- */
266
- declare const Searchable: react.MemoExoticComponent<({ name, rules, defaultValue, shouldUnregister, label, required, options, textFieldProps, noOptionsText, footer, multiple, info, placeholder, onChange: onChangeProp, onInputChange, disableIconError, ...rest }: SearchableProps) => react_jsx_runtime.JSX.Element>;
73
+ declare const Checkbox: <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;
267
74
 
268
75
  type ControllerCreatable = Omit<ControllerProps, 'render' | 'control'>;
269
76
  /**
@@ -375,52 +182,86 @@ type CreatableProps = Omit<AutocompleteProps$1<CreatableOption, true, true, true
375
182
  */
376
183
  declare const Creatable: react.MemoExoticComponent<({ name, rules, defaultValue, shouldUnregister, label, required, options, editable, footer, onEditOption, onCreateOption, textFieldProps, hideAddButton, multiple, info, onChange: onChangeProp, onInputChange, placeholder, disableIconError, ...rest }: CreatableProps) => react_jsx_runtime.JSX.Element>;
377
184
 
378
- type CheckboxProps<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = CheckboxProps$1 & UseControllerProps<TFieldValues, TFieldName> & {
379
- /**
380
- * O nome do checkbox que será renderizado na tela
381
- * @default ''
382
- * @example 'Nome do checkbox'
383
- * @type string
384
- * @memberof CheckboxProps
385
- */
185
+ 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$1<FieldValue, Multiple, DisableClearable, FreeSolo>, 'renderInput' | 'options' | 'size' | 'onInputChange' | 'onChange' | 'getOptionLabel' | 'getOptionKey' | 'defaultValue' | 'value'> & UseControllerProps<TFieldValues, TFieldName> & {
186
+ options: FieldValue[];
187
+ textFieldProps?: TextFieldProps$1;
386
188
  label?: React.ReactNode;
189
+ required?: boolean;
387
190
  /**
388
- * Posição do label em relação ao checkbox
389
- * @default 'end'
390
- * @type 'start' | 'end' | 'top' | 'bottom'
391
- * @example
392
- * <Checkbox label="Checkbox" labelPlacement="start" />
191
+ * Define se mostra o botão para criar uma nova opção
192
+ * @default true
193
+ * @type {boolean}
194
+ * @memberof CreatableV2Props
393
195
  */
394
- labelPlacement?: 'start' | 'end' | 'top' | 'bottom';
196
+ showCreatableButton?: boolean;
395
197
  /**
396
- * Desabilita o ícone de erro da validação do campo.
198
+ * Define se mostra o botão para editar uma opção existente
397
199
  * @default false
398
- *
200
+ * @type {boolean}
201
+ * @memberof CreatableV2Props
202
+ */
203
+ showEditableButton?: boolean;
204
+ /**
205
+ * Função que será executada quando o usuário clicar no botão de criar uma nova opção
206
+ * @default () => {}
207
+ * @type {(value: string) => void}
208
+ * @memberof CreatableV2Props
209
+ */
210
+ onCreateOption?: (value: string) => void;
211
+ /**
212
+ * Função que será executada quando o usuário clicar no botão de editar uma opção
213
+ * @default () => {}
214
+ * @type {(value) => void}
215
+ * @memberof CreatableV2Props
216
+ */
217
+ onEditOption?: (value: AutocompleteValue<FieldValue, Multiple, DisableClearable, FreeSolo>) => void;
218
+ /**
219
+ * Componente que renderiza no footer do searchable (opcional)
399
220
  * @example
400
- * <TextField disableIconError />
221
+ * footer: (
222
+ * <Button onClick={handleClick}>Mostrar mais...</Button>
223
+ * )
401
224
  */
402
- disableIconError?: boolean;
225
+ footer?: () => React.ReactNode;
226
+ /**
227
+ * É o conteúdo passado para a tooltip que renderizará ao lado da label do campo,
228
+ * montada à tela como um ícone de informação.
229
+ */
230
+ info?: React.ReactNode;
231
+ onInputChange?: (value: string) => void;
232
+ onChange?: (value: AutocompleteValue<FieldValue, Multiple, DisableClearable, FreeSolo> | (DisableClearable extends true ? never : null)) => void;
233
+ placeholder?: string;
234
+ /**
235
+ * Define a key unica da option
236
+ */
237
+ getOptionKey: (option: FieldValue | AutocompleteFreeSoloValueMapping<FreeSolo>) => string | number;
238
+ /**
239
+ * Define a label da option
240
+ */
241
+ getOptionLabel: (option: FieldValue | AutocompleteFreeSoloValueMapping<FreeSolo>) => string;
242
+ /**
243
+ * Componente renderizado embaixo da option da listagem
244
+ */
245
+ getOptionAfterLabel?: (option: FieldValue) => string | React.ReactNode;
403
246
  };
404
247
 
405
- declare const Checkbox: <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;
248
+ 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;
249
+ declare const _default$4: typeof CreatableV2;
406
250
 
407
- type SwitchProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = SwitchProps$1 & UseControllerProps<TFieldValues, TFieldName> & {
251
+ 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'> & {
252
+ datePickerProps?: Partial<DatePickerProps$1<any>>;
408
253
  /**
409
- * O nome do switch que será renderizado na tela
410
- * @default ''
411
- * @example 'Nome do switch'
412
- * @type React.ReactNode
413
- * @memberof SwitchProps
254
+ * Se `true` irá adicionar um asterisco ao label do campo
255
+ *
256
+ * @default false
414
257
  */
415
- label?: React.ReactNode;
258
+ required?: boolean;
416
259
  /**
417
- * Posição do label em relação ao switch
418
- * @default 'end'
419
- * @type 'start' | 'end' | 'top' | 'bottom'
420
- * @example
421
- * <Switch label="Switch" labelPlacement="start" />
260
+ * Se `true` irá desabilitar o campo e não será possível interagir com ele
261
+ *
262
+ * @default false
422
263
  */
423
- labelPlacement?: 'start' | 'end' | 'top' | 'bottom';
264
+ disabled?: boolean;
424
265
  /**
425
266
  * Desabilita o ícone de erro da validação do campo.
426
267
  * @default false
@@ -431,7 +272,66 @@ type SwitchProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<
431
272
  disableIconError?: boolean;
432
273
  };
433
274
 
434
- 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;
275
+ 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
+
277
+ interface IFormProps<T extends FieldValues> extends IUseFormProps<T> {
278
+ children: ((methods: UseFormReturn<T> & {
279
+ onSubmit: (e?: React.FormEvent | undefined) => Promise<void>;
280
+ }) => React.ReactNode) | React.ReactNode;
281
+ style?: React.HTMLAttributes<HTMLFormElement>['style'];
282
+ }
283
+ interface IFormProviderProps<TFieldValues extends FieldValues> extends FormProviderProps<TFieldValues> {
284
+ style?: React.HTMLAttributes<HTMLFormElement>['style'];
285
+ onSubmit: (e?: React.BaseSyntheticEvent) => void;
286
+ }
287
+ interface IUseFormProps<TValues extends FieldValues> extends Omit<UseFormProps<TValues>, 'resolver'> {
288
+ onSubmit: (data: TValues, methods: UseFormReturn<TValues>) => void;
289
+ /**
290
+ * Prop que faz com que o formulário não atualize ao mudar o defaultValue
291
+ */
292
+ disableDefaultValuesUpdate?: boolean;
293
+ schema?: z.ZodObject<any> | z.ZodEffects<z.ZodObject<any>>;
294
+ }
295
+
296
+ /**
297
+ * Utilizado overloading para poder passar uma tipagem para o Componente
298
+ * @example
299
+ * // Não passar uma tipagem, todas as props terão o funcionamento normal, sem tipagem
300
+ * <Form onSubmit={({email}) => {}}>
301
+ * ...
302
+ * </Form>
303
+ * @example
304
+ * // Passar uma tipagem, todas as props derivadas do react-hook-form terão a tipagem passada no generic
305
+ * type Cadastro = {
306
+ * email: string;
307
+ * }
308
+ * <Form<Cadastro> onSubmit={({email}) => {}}>
309
+ * ...
310
+ * </Form>
311
+ */
312
+ declare function Form(props: IFormProps<any>): JSX.Element;
313
+ declare function Form<T extends FieldValues>(props: IFormProps<T>): JSX.Element;
314
+
315
+ declare const useForm: <TValues extends FieldValues>({ disableDefaultValuesUpdate, onSubmit, ...rest }: IUseFormProps<TValues>) => {
316
+ onSubmit: (e?: react.BaseSyntheticEvent<object, any, any> | undefined) => Promise<void>;
317
+ watch: react_hook_form.UseFormWatch<TValues>;
318
+ getValues: react_hook_form.UseFormGetValues<TValues>;
319
+ getFieldState: react_hook_form.UseFormGetFieldState<TValues>;
320
+ setError: react_hook_form.UseFormSetError<TValues>;
321
+ clearErrors: react_hook_form.UseFormClearErrors<TValues>;
322
+ setValue: react_hook_form.UseFormSetValue<TValues>;
323
+ trigger: react_hook_form.UseFormTrigger<TValues>;
324
+ formState: react_hook_form.FormState<TValues>;
325
+ resetField: react_hook_form.UseFormResetField<TValues>;
326
+ reset: react_hook_form.UseFormReset<TValues>;
327
+ handleSubmit: react_hook_form.UseFormHandleSubmit<TValues, undefined>;
328
+ unregister: react_hook_form.UseFormUnregister<TValues>;
329
+ control: react_hook_form.Control<TValues, any>;
330
+ register: react_hook_form.UseFormRegister<TValues>;
331
+ setFocus: react_hook_form.UseFormSetFocus<TValues>;
332
+ };
333
+
334
+ declare function FormProvider<TFieldValues extends FieldValues>({ children, style, onSubmit, ...methods }: IFormProviderProps<TFieldValues>): react_jsx_runtime.JSX.Element;
435
335
 
436
336
  type RadioGroupProps<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = RadioGroupProps$1 & UseControllerProps<TFieldValues, TFieldName> & {
437
337
  /**
@@ -499,86 +399,20 @@ type RadioProps = RadioProps$1 & {
499
399
 
500
400
  declare const RadioButton: ({ label, labelPlacement, ...rest }: RadioProps) => react_jsx_runtime.JSX.Element;
501
401
 
502
- type SliderProps<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = SliderProps$1 & UseControllerProps<TFieldValues, TFieldName> & {
503
- /**
504
- * O nome do switch que será renderizado na tela
505
- * @default ''
506
- * @example 'Nome do switch'
507
- * @type string
508
- * @memberof SliderProps
509
- */
510
- label?: string;
511
- /**
512
- * Posição do label em relação ao switch
513
- * @default 'end'
514
- * @type 'start' | 'end' | 'top' | 'bottom'
515
- * @example
516
- * <Slider label="Slider" labelPlacement="start" />
517
- */
518
- labelPlacement?: 'start' | 'end' | 'top' | 'bottom';
519
- };
520
-
521
- 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;
522
-
523
- 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'> & {
524
- datePickerProps?: Partial<DatePickerProps$1<any>>;
525
- /**
526
- * Se `true` irá adicionar um asterisco ao label do campo
527
- *
528
- * @default false
529
- */
530
- required?: boolean;
531
- /**
532
- * Se `true` irá desabilitar o campo e não será possível interagir com ele
533
- *
534
- * @default false
535
- */
536
- disabled?: boolean;
537
- /**
538
- * Desabilita o ícone de erro da validação do campo.
539
- * @default false
540
- *
541
- * @example
542
- * <TextField disableIconError />
543
- */
544
- disableIconError?: boolean;
545
- };
546
-
547
- declare const _default$5: 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)>;
548
-
549
- type TimePickerProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = UseControllerProps<TFieldValues, TFieldName> & Pick<TextFieldProps$1, 'label' | 'error' | 'helperText' | 'size' | 'fullWidth' | 'variant' | 'autoFocus' | 'placeholder'> & {
550
- timePickerProps?: Partial<TimePickerProps$1<any>>;
551
- /**
552
- * Se `true` irá adicionar um asterisco ao label do campo
553
- *
554
- * @default false
555
- */
556
- required?: boolean;
557
- /**
558
- * Se `true` irá desabilitar o campo e não será possível interagir com ele
559
- *
560
- * @default false
561
- */
562
- disabled?: boolean;
563
- /**
564
- * Desabilita o ícone de erro da validação do campo.
565
- * @default false
566
- *
567
- * @example
568
- * <TextField disableIconError />
569
- */
570
- disableIconError?: boolean;
571
- };
572
-
573
- declare const _default$4: 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)>;
574
-
575
- type AutoCompleteOption = {
402
+ type ControllerSearchable = Omit<ControllerProps, 'render' | 'control'>;
403
+ /**
404
+ * @deprecated usar SearchableV2
405
+ */
406
+ type SearchableOption = {
576
407
  key?: string | number;
577
408
  label: string;
578
409
  value: string | number | readonly string[] | undefined;
579
410
  afterLabel?: string | React.ReactNode;
580
- };
581
- type AutocompleteProps<ValueType = any> = Omit<UseControllerProps, 'control'> & Omit<AutocompleteProps$1<ValueType, any, any, any>, 'renderInput' | 'size' | 'onInputChange' | 'onChange' | 'options'> & {
411
+ } | string;
412
+ /**
413
+ * @deprecated usar SearchableV2
414
+ */
415
+ type SearchableProps = Omit<AutocompleteProps$1<SearchableOption, true, true, true>, 'renderInput' | 'size' | 'onInputChange' | 'onChange'> & ControllerSearchable & {
582
416
  /**
583
417
  * Opções do autocomplete
584
418
  * @default []
@@ -588,12 +422,40 @@ type AutocompleteProps<ValueType = any> = Omit<UseControllerProps, 'control'> &
588
422
  * { label: 'Opção 1', value: '1' },
589
423
  * ]
590
424
  *
591
- * @type {AutoCompleteOption[]}
592
- * @memberof AutocompleteProps
425
+ * @type {SearchableOption[]}
426
+ * @memberof SearchableProps
593
427
  */
594
- options: AutoCompleteOption[];
428
+ options: SearchableOption[];
429
+ /**
430
+ * Props do textField que é renderizado dentro do autocomplete
431
+ * @default {}
432
+ * @type {TextFieldProps}
433
+ * @memberof SearchableProps
434
+ */
435
+ textFieldProps?: TextFieldProps$1;
595
436
  label?: React.ReactNode;
596
437
  required?: boolean;
438
+ /**
439
+ * Texto que será exibido quando não houver opções para serem exibidas
440
+ * @default 'Nenhuma opção encontrada'
441
+ */
442
+ noOptionsText?: string;
443
+ /**
444
+ * Componente que renderiza no footer do searchable (opcional)
445
+ *
446
+ * @example
447
+ * footer: (
448
+ * <Button onClick={handleClick}>Mostrar mais...</Button>
449
+ * )
450
+ *
451
+ *
452
+ */
453
+ footer?: React.ReactNode;
454
+ /**
455
+ * É o conteúdo passado para a tooltip que renderizará ao lado da label do campo,
456
+ * montada à tela como um ícone de informação.
457
+ */
458
+ info?: React.ReactNode;
597
459
  onInputChange?: (value: string, values: FieldValues) => void;
598
460
  onChange?: (value: any, values: FieldValues) => void;
599
461
  /**
@@ -607,7 +469,10 @@ type AutocompleteProps<ValueType = any> = Omit<UseControllerProps, 'control'> &
607
469
  placeholder?: string;
608
470
  };
609
471
 
610
- declare const _default$3: react.MemoExoticComponent<({ name, defaultValue, rules, shouldUnregister, label, required, noOptionsText, placeholder, onInputChange, onChange, disableIconError, ...rest }: AutocompleteProps) => react_jsx_runtime.JSX.Element>;
472
+ /**
473
+ * @deprecated usar SearchableV2
474
+ */
475
+ declare const Searchable: react.MemoExoticComponent<({ name, rules, defaultValue, shouldUnregister, label, required, options, textFieldProps, noOptionsText, footer, multiple, info, placeholder, onChange: onChangeProp, onInputChange, disableIconError, ...rest }: SearchableProps) => react_jsx_runtime.JSX.Element>;
611
476
 
612
477
  type SearchableV2Props<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>> = Omit<AutocompleteProps$1<FieldValue, Multiple, DisableClearable, FreeSolo>, 'renderInput' | 'size' | 'options' | 'onInputChange' | 'onChange' | 'getOptionLabel' | 'getOptionKey' | 'defaultValue' | 'value'> & UseControllerProps<TFieldValues, TFieldName> & {
613
478
  options: FieldValue[];
@@ -653,6 +518,87 @@ type SearchableV2Props<TFieldValues extends FieldValues = FieldValues, TFieldNam
653
518
 
654
519
  declare const _default$2: <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;
655
520
 
521
+ type ControllerSelect = Omit<ControllerProps, 'render' | 'control'>;
522
+ /**
523
+ * @deprecated
524
+ */
525
+ type SelectOption = {
526
+ label: string;
527
+ value: string | number | readonly string[] | undefined;
528
+ afterLabel?: string | React.ReactNode;
529
+ };
530
+ /**
531
+ * @deprecated
532
+ */
533
+ type FooterProps = {
534
+ closeSelect: () => void;
535
+ };
536
+ /**
537
+ * @deprecated
538
+ */
539
+ type SelectProps = Omit<SelectProps$1, 'onChange'> & ControllerSelect & {
540
+ /**
541
+ * As opções que serão renderizadas no select
542
+ *
543
+ * @type {SelectOption[]}
544
+ *
545
+ * @example
546
+ * options: [
547
+ * { label: 'Option 1', value: 'option1' },
548
+ * { label: 'Option 2', value: 'option2' },
549
+ * ]
550
+ */
551
+ options: SelectOption[];
552
+ onChange?: (value: any, values: FieldValues) => void;
553
+ /**
554
+ * Desabilita o onChange do select, para que o onChange do form não seja disparado
555
+ *
556
+ * @type {boolean}
557
+ * @default false
558
+ *
559
+ * @example
560
+ * <Select name="select" options={options} disableOnChangeForm />
561
+ */
562
+ disableOnChangeForm?: boolean;
563
+ /**
564
+ * Função que renderiza o footer do select (opcional) - recebe como parâmetro a função closeSelect que fecha o select
565
+ * @param {FooterProps} props
566
+ *
567
+ * @example
568
+ * footer: ({ closeSelect }) => (
569
+ * <Button onClick={closeSelect}>Fechar</Button>
570
+ * )
571
+ *
572
+ */
573
+ footer?: (props: FooterProps) => React.ReactNode;
574
+ /**
575
+ * É o conteúdo passado para a tooltip que renderizará ao lado da label do campo,
576
+ * montada à tela como um ícone de informação.
577
+ */
578
+ info?: React.ReactNode;
579
+ /**
580
+ * Desabilita o ícone de erro da validação do campo.
581
+ * @default false
582
+ *
583
+ * @example
584
+ * <Select disableIconError />
585
+ */
586
+ disableIconError?: boolean;
587
+ /**
588
+ * Habilita ícone no endAdornment para limpar o valor do campo.
589
+ * @default false
590
+ *
591
+ * @example
592
+ * <Select clearable />
593
+ */
594
+ clearable?: boolean;
595
+ };
596
+
597
+ /**
598
+ * @deprecated usar SelectV2
599
+ */
600
+ declare const Select: react.MemoExoticComponent<({ name, rules, defaultValue, shouldUnregister, label, required, options, placeholder, clearable, disableOnChangeForm, multiple, info, footer, onChange: onChangeProp, disableIconError, variant, ...rest }: SelectProps) => react_jsx_runtime.JSX.Element>;
601
+
656
602
  type FooterPropsV2 = {
657
603
  closeSelect: () => void;
658
604
  };
@@ -706,73 +652,132 @@ type SelectV2Props<TFieldValues extends FieldValues = FieldValues, TFieldName ex
706
652
  */
707
653
  getOptionIcon?: (option: FieldPathValue<TFieldValues, TFieldName>) => React.ReactNode;
708
654
  };
655
+ type SelectV2ReturnValueProps<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = {
656
+ value: FieldPathValue<TFieldValues, TFieldName> | null;
657
+ placeholder: string | undefined;
658
+ getOptionLabel: (option: FieldPathValue<TFieldValues, TFieldName>) => string;
659
+ };
709
660
 
710
661
  declare const _default$1: <TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>(props: SelectV2Props<TFieldValues, TFieldName>) => react_jsx_runtime.JSX.Element;
711
662
 
712
- 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$1<FieldValue, Multiple, DisableClearable, FreeSolo>, 'renderInput' | 'options' | 'size' | 'onInputChange' | 'onChange' | 'getOptionLabel' | 'getOptionKey' | 'defaultValue' | 'value'> & UseControllerProps<TFieldValues, TFieldName> & {
713
- options: FieldValue[];
714
- textFieldProps?: TextFieldProps$1;
663
+ type SliderProps<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = SliderProps$1 & UseControllerProps<TFieldValues, TFieldName> & {
664
+ /**
665
+ * O nome do switch que será renderizado na tela
666
+ * @default ''
667
+ * @example 'Nome do switch'
668
+ * @type string
669
+ * @memberof SliderProps
670
+ */
671
+ label?: string;
672
+ /**
673
+ * Posição do label em relação ao switch
674
+ * @default 'end'
675
+ * @type 'start' | 'end' | 'top' | 'bottom'
676
+ * @example
677
+ * <Slider label="Slider" labelPlacement="start" />
678
+ */
679
+ labelPlacement?: 'start' | 'end' | 'top' | 'bottom';
680
+ };
681
+
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;
683
+
684
+ type SwitchProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = SwitchProps$1 & UseControllerProps<TFieldValues, TFieldName> & {
685
+ /**
686
+ * O nome do switch que será renderizado na tela
687
+ * @default ''
688
+ * @example 'Nome do switch'
689
+ * @type React.ReactNode
690
+ * @memberof SwitchProps
691
+ */
715
692
  label?: React.ReactNode;
716
- required?: boolean;
717
693
  /**
718
- * Define se mostra o botão para criar uma nova opção
719
- * @default true
720
- * @type {boolean}
721
- * @memberof CreatableV2Props
694
+ * Posição do label em relação ao switch
695
+ * @default 'end'
696
+ * @type 'start' | 'end' | 'top' | 'bottom'
697
+ * @example
698
+ * <Switch label="Switch" labelPlacement="start" />
722
699
  */
723
- showCreatableButton?: boolean;
700
+ labelPlacement?: 'start' | 'end' | 'top' | 'bottom';
724
701
  /**
725
- * Define se mostra o botão para editar uma opção existente
702
+ * Desabilita o ícone de erro da validação do campo.
726
703
  * @default false
727
- * @type {boolean}
728
- * @memberof CreatableV2Props
704
+ *
705
+ * @example
706
+ * <TextField disableIconError />
729
707
  */
730
- showEditableButton?: boolean;
708
+ disableIconError?: boolean;
709
+ };
710
+
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;
712
+
713
+ type Masks = 'cpf' | 'cnpj' | 'cpfCnpj' | 'cep' | 'telefone' | 'decimal' | 'decimal3' | 'decimal4' | 'decimal5' | 'porcentagem' | 'porcentagem0' | 'nome' | 'numero' | 'numeroPontuacao' | 'placa' | 'valor' | 'valor3' | 'valor4';
714
+ type TextFieldProps<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = TextFieldProps$1 & UseControllerProps<TFieldValues, TFieldName> & {
715
+ mask?: Masks;
731
716
  /**
732
- * Função que será executada quando o usuário clicar no botão de criar uma nova opção
733
- * @default () => {}
734
- * @type {(value: string) => void}
735
- * @memberof CreatableV2Props
717
+ * @description Função que será executada quando o valor do input for alterado
718
+ * @param value valor atual do Field
719
+ * @param values valores atuais do Form
720
+ *
721
+ * @example onInputChange={(values,values) => console.log({value, values})}
736
722
  */
737
- onCreateOption?: (value: string) => void;
723
+ onInputChange?: (value: string) => void;
738
724
  /**
739
- * Função que será executada quando o usuário clicar no botão de editar uma opção
740
- * @default () => {}
741
- * @type {(value) => void}
742
- * @memberof CreatableV2Props
725
+ * @param value Valor do input
726
+ * @returns Valor formatado para o input
727
+ *
728
+ * @example
729
+ * <TextField mask="cpf" parse={(value) => value.replace(/\D/g, '')} />
743
730
  */
744
- onEditOption?: (value: AutocompleteValue<FieldValue, Multiple, DisableClearable, FreeSolo>) => void;
731
+ parse?: (value: string) => string;
745
732
  /**
746
- * Componente que renderiza no footer do searchable (opcional)
733
+ * @param value Valor do input formatado
734
+ * @returns Valor sem formatação para o input
735
+ *
747
736
  * @example
748
- * footer: (
749
- * <Button onClick={handleClick}>Mostrar mais...</Button>
750
- * )
737
+ * <TextField mask="cpf" format={(value) => value.replace(/\D/g, '')} />
751
738
  */
752
- footer?: () => React.ReactNode;
739
+ format?: (value: string) => string;
753
740
  /**
754
741
  * É o conteúdo passado para a tooltip que renderizará ao lado da label do campo,
755
742
  * montada à tela como um ícone de informação.
756
743
  */
757
744
  info?: React.ReactNode;
758
- onInputChange?: (value: string) => void;
759
- onChange?: (value: AutocompleteValue<FieldValue, Multiple, DisableClearable, FreeSolo> | (DisableClearable extends true ? never : null)) => void;
760
- placeholder?: string;
761
745
  /**
762
- * Define a key unica da option
746
+ * Desabilita o ícone de erro da validação do campo.
747
+ * @default false
748
+ *
749
+ * @example
750
+ * <TextField disableIconError />
763
751
  */
764
- getOptionKey: (option: FieldValue | AutocompleteFreeSoloValueMapping<FreeSolo>) => string | number;
752
+ disableIconError?: boolean;
753
+ };
754
+
755
+ 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
+
757
+ type TimePickerProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = UseControllerProps<TFieldValues, TFieldName> & Pick<TextFieldProps$1, 'label' | 'error' | 'helperText' | 'size' | 'fullWidth' | 'variant' | 'autoFocus' | 'placeholder'> & {
758
+ timePickerProps?: Partial<TimePickerProps$1<any>>;
765
759
  /**
766
- * Define a label da option
760
+ * Se `true` irá adicionar um asterisco ao label do campo
761
+ *
762
+ * @default false
767
763
  */
768
- getOptionLabel: (option: FieldValue | AutocompleteFreeSoloValueMapping<FreeSolo>) => string;
764
+ required?: boolean;
769
765
  /**
770
- * Componente renderizado embaixo da option da listagem
766
+ * Se `true` irá desabilitar o campo e não será possível interagir com ele
767
+ *
768
+ * @default false
771
769
  */
772
- getOptionAfterLabel?: (option: FieldValue) => string | React.ReactNode;
770
+ disabled?: boolean;
771
+ /**
772
+ * Desabilita o ícone de erro da validação do campo.
773
+ * @default false
774
+ *
775
+ * @example
776
+ * <TextField disableIconError />
777
+ */
778
+ disableIconError?: boolean;
773
779
  };
774
780
 
775
- 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;
776
- declare const _default: typeof CreatableV2;
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)>;
777
782
 
778
- export { _default$3 as Autocomplete, type AutocompleteProps, Checkbox, type CheckboxProps, Creatable, type CreatableProps, _default as CreatableV2, type CreatableV2Props, _default$5 as DatePicker, type DatePickerProps, Form, FormProvider, type IFormProps, type IFormProviderProps, type IUseFormProps, RadioButton, RadioGroup, type RadioGroupProps, type RadioProps, Searchable, type SearchableProps, _default$2 as SearchableV2, type SearchableV2Props, Select, type SelectProps, _default$1 as SelectV2, type SelectV2Props, Slider, type SliderProps, Switch, type SwitchProps, TextField, type TextFieldProps, _default$4 as TimePicker, type TimePickerProps, useForm };
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 };
package/dist/index.mjs CHANGED
@@ -1,15 +1,15 @@
1
- import{FormProvider as ao}from"react-hook-form";import{jsx as Ie}from"react/jsx-runtime";function so({children:e,style:o,onSubmit:l,...i}){return Ie(ao,{...i,children:Ie("form",{onSubmit:s=>{s.preventDefault(),s.stopPropagation(),l(s)},style:o,children:e})})}var be=so;import{useEffect as po}from"react";import{useForm as mo}from"react-hook-form";import{zodResolver as uo}from"@hookform/resolvers/zod";var co=({disableDefaultValuesUpdate:e,onSubmit:o,...l})=>{let i=mo({...l,resolver:l.schema&&uo(l.schema)});return po(()=>{e||i.reset(l.defaultValues)},[l.defaultValues,i.reset]),{...i,onSubmit:i.handleSubmit(s=>o(s,i))}},he=co;import{jsx as yo}from"react/jsx-runtime";function fo({children:e,style:o,...l}){let i=he(l);return yo(be,{...i,style:o,children:typeof e=="function"?e(i):e})}var Fo=fo;import{InputAdornment as vo,Stack as To,TextField as So,Tooltip as ko}from"@mui/material";import{LIcon as Ae}from"@s_mart/core";import*as De from"@s_mart/masks";import{lineEye as Io,lineEyeSlash as wo,lineInfoCircle as Lo}from"@s_mart/solid-icons";import{useRef as Ao,useState as Do}from"react";import{useController as Ro,useFormContext as Bo,useFormState as Eo}from"react-hook-form";import{Indicator as xo}from"@s_mart/core";import{useFormState as bo}from"react-hook-form";var R=(e,o)=>o.replace(/[[\]]/g,"").split(".").reduce((i,s)=>i?.[s],e);import{jsx as Po}from"react/jsx-runtime";var ho=({name:e,disableIcon:o,control:l})=>{let i=bo({control:l,name:e}),s=R(i?.errors,e);return s?Po(xo,{severity:"error",icon:o?!1:void 0,children:s?.message}):null},I=ho;import{Typography as we}from"@mui/material";import{toRem as go}from"@s_mart/utils";import{jsx as Le,jsxs as Co}from"react/jsx-runtime";var Vo=({label:e,required:o,regular:l})=>Co("span",{style:{display:"flex",alignItems:"center",gap:go(2)},children:[Le(we,{variant:"caption",style:{display:"flex",alignItems:"center"},sx:{fontWeight:l?400:700},children:e}),o&&Le(we,{variant:"caption",color:"error",sx:{fontWeight:900},children:"*"})]}),S=Vo;var v=class extends Error{constructor(o){super(`O componente ${o} precisa de um control para funcionar. Passe o control como prop ou coloque o componente dentro de um <Form />`),this.name="FormComponentPrecisaDeControl"}};import{jsx as H,jsxs as Re}from"react/jsx-runtime";var Mo=({name:e,rules:o,defaultValue:l,shouldUnregister:i,control:s,label:P,required:g,mask:f,variant:T="outlined",info:x,parse:C,format:m,onInputChange:u,disableIconError:a,...p})=>{let V=Bo()?.control,n=s??V,F=Ao(l||void 0);if(!n)throw new v("TextField");let[A,r]=Do(!1),y=c=>{let t=c;return t=m?.(c)??c,f?De?.[f]?.format(t):t},G=c=>{let t=c;return t=C?.(c)??t,f?De?.[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:d}=Ro({control:n,name:e,rules:o,defaultValue:l,shouldUnregister:i}),w=Eo({control:n,name:e}),L=R(w.errors,e);return Re(To,{children:[Re("div",{style:{display:"flex"},children:[P&&H("div",{children:H(S,{label:P,required:g})}),x&&H("div",{children:H(ko,{title:x,placement:"top",children:H("div",{style:{width:"fit-content"},children:H(Ae,{icon:Lo,color:"#757575"})})})})]}),H(So,{variant:T,defaultValue:l,value:y(d.value||(d.value!=0?"":d.value)),onChange:c=>{let t=G(c?.target?.value);d.onChange(t),u?.(t),F.current=c.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"&&H(vo,{position:"start",onClick:()=>r(!A),style:{cursor:"pointer"},children:H(Ae,{icon:A?Io:wo,size:"24px",removeMargin:!0})}),...p.InputProps}}},e),H(I,{name:e,disableIcon:a,control:n})]})},$o=Mo;import{Divider as Oo,Grid as Q,MenuItem as No,Select as Go,Tooltip as zo,useTheme as qo}from"@mui/material";import{IconButton as _o,LIcon as Be}from"@s_mart/core";import{lineTimes as Uo}from"@s_mart/regular-icons";import{lineInfoCircle as Ho}from"@s_mart/solid-icons";import{colorPalette as Ko}from"@s_mart/tokens";import{memo as Wo,useState as Yo}from"react";import{Controller as jo,useFormContext as Jo}from"react-hook-form";import{Fragment as Qo,jsx as N,jsxs as ae}from"react/jsx-runtime";var Ee=Wo(({name:e,rules:o,defaultValue:l,shouldUnregister:i,label:s,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=Jo(),{palette:A}=qo(),[r,y]=Yo(!1);if(!F)throw new v("Select");let G=R(F.formState.errors,e);return N(jo,{control:F.control,name:e,rules:o,defaultValue:l,shouldUnregister:i,render:({field:{value:b,onChange:d,ref:w}})=>ae(Q,{sx:{display:"flex",flexDirection:"column"},children:[ae("div",{style:{display:"flex"},children:[s&&N(Q,{item:!0,children:N(S,{label:s,required:P})}),m&&N(Q,{item:!0,children:N(zo,{title:m,placement:"top",children:N("div",{style:{width:"fit-content"},children:N(Be,{icon:Ho,color:"#757575"})})})})]}),ae(Go,{open:r,onOpen:()=>y(!0),onClose:()=>y(!1),displayEmpty:!!f,variant:V,autoComplete:"off",value:b?b||"":C?[]:"",renderValue:L=>{if(L.label)return L.label;if(f)return N("p",{style:{color:A.grey[400]},children:f})},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(Qo,{children:[n.endAdornment,!!(T&&b)&&N(_o,{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(Be,{icon:Uo,color:Ko.neutral[100],size:"25px",removeMargin:!0})})]}),children:[g?.map((L,c)=>N(No,{value:L,children:ae(Q,{container:!0,direction:"column",children:[N(Q,{item:!0,children:L.label}),L.afterLabel&&N(Q,{item:!0,children:L.afterLabel})]})},c)),u&&[N(Q,{sx:{px:2,py:1},children:N(Oo,{})},"footer-divider"),N("div",{children:u({closeSelect:()=>y(!1)})},"footer-content")]]},e),N(I,{name:e,disableIcon:p,control:F.control})]})})});Ee.displayName="Select";var Xo=Ee;import{Autocomplete as Zo,Divider as Me,Grid as j,TextField as et,Tooltip as ot}from"@mui/material";import{LIcon as tt}from"@s_mart/core";import{lineInfoCircle as rt}from"@s_mart/solid-icons";import{colorPalette as lt}from"@s_mart/tokens";import{forwardRef as it,memo as nt}from"react";import{Controller as at,useFormContext as dt}from"react-hook-form";import{Fragment as se,jsx as O,jsxs as Z}from"react/jsx-runtime";import{createElement as $e}from"react";var Oe=nt(({name:e,rules:o,defaultValue:l,shouldUnregister:i,label:s,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=dt();if(!F)throw new v("Searchable");let A=R(F.formState.errors,e);return O(at,{control:F.control,name:e,rules:o,defaultValue:l,shouldUnregister:i,render:({field:{onChange:r,value:y,ref:G}})=>Z(j,{sx:{display:"flex",flexDirection:"column"},children:[Z("div",{style:{display:"flex"},children:[s&&O(j,{item:!0,children:O(S,{label:s,required:P})}),m&&O(j,{item:!0,children:O(ot,{title:m,placement:"top",children:O("div",{style:{width:"fit-content"},children:O(tt,{icon:rt,color:"#757575"})})})})]}),O(Zo,{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 ${lt.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}},listbox:{component:it(function(d,w){return Z(se,{children:[O("ul",{...d,ref:w}),!!x&&O("div",{...d,children:Z(se,{children:[O(j,{sx:{px:2,py:1},children:O(Me,{})}),x]})},"searchable-footer")]})})}},value:y||(C?[]:null),options:g,multiple:C,readOnly:n.disabled,noOptionsText:Z(se,{children:[T||"Nenhum resultado encontrado",x?Z(se,{children:[O(j,{sx:{py:1},children:O(Me,{})}),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"?$e("li",{...b,key:d.key||d.value},Z(j,{container:!0,direction:"column",children:[O(j,{item:!0,children:d.label}),d.afterLabel&&O(j,{item:!0,children:d.afterLabel})]})):$e("li",{...b,key:d},d),...n,renderInput:b=>O(et,{error:!!A,placeholder:u,...b,...f,inputRef:G})},e),O(I,{name:e,disableIcon:V,control:F.control})]})})});Oe.displayName="Searchable";var st=Oe;import{forwardRef as ut,memo as ct}from"react";import{Controller as ft,useFormContext as Ft}from"react-hook-form";import{isObject as yt,isEmpty as xt}from"lodash-es";import{Grid as ee,Autocomplete as bt,TextField as ht,Tooltip as Pt,Divider as gt}from"@mui/material";import{LIcon as me,Button as Vt}from"@s_mart/core";import{colorPalette as Ct}from"@s_mart/tokens";import{linePlus as qe,linePen as vt,lineInfoCircle as Tt}from"@s_mart/solid-icons";import{toRem as _e}from"@s_mart/utils";import{css as Ne}from"@emotion/react";import{styled as pt}from"@mui/material";import{toRem as pe}from"@s_mart/utils";var Ge=Ne`
1
+ import{Autocomplete as Fo,Grid as de,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 R=(e,o)=>o.replace(/[[\]]/g,"").split(".").reduce((i,d)=>i?.[d],e);import{jsx as mo}from"react/jsx-runtime";var po=({name:e,disableIcon:o,control:l})=>{let i=so({control:l,name:e}),d=R(i?.errors,e);return d?mo(ao,{severity:"error",icon:o?!1:void 0,children:d?.message}):null},I=po;import{Typography as Ie}from"@mui/material";import{toRem as uo}from"@s_mart/utils";import{jsx as we,jsxs as fo}from"react/jsx-runtime";var co=({label:e,required:o,regular:l})=>fo("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:"*"})]}),S=co;var v=class extends Error{constructor(o){super(`O componente ${o} precisa de um control para funcionar. Passe o control como prop ou coloque o componente dentro de um <Form />`),this.name="FormComponentPrecisaDeControl"}};import{jsx as Q,jsxs as Ae}from"react/jsx-runtime";import{createElement as Co}from"react";var go=({name:e,defaultValue:o,rules:l,shouldUnregister:i,label:d,required:P,noOptionsText:g,placeholder:f,onInputChange:T,onChange:x,disableIconError:C,...m})=>{let u=Po();if(!u)throw new v("Autocomplete");let a=R(u.formState.errors,e);return console.warn=()=>{},Q(ho,{name:e,control:u.control,defaultValue:o,rules:l,shouldUnregister:i,render:({field:p})=>Ae(de,{sx:{display:"flex",flexDirection:"column"},children:[d&&Q(S,{label:d,required:P}),Q(Fo,{onChange:(V,n)=>{p.onChange(n),x?.(n,u.getValues())},onInputChange:(V,n,F)=>{F==="input"&&(p.onChange(n),setTimeout(()=>{T?.(n,u.getValues())},0))},slotProps:{...m.slotProps||{},paper:{...m.slotProps?.paper||{},sx:{border:`1px solid ${xo.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}}},isOptionEqualToValue:(V,n)=>V.value===n.value,renderOption:(V,n)=>Co("li",{...V,key:n.key||n.value,onClick:F=>{V.onClick?.(F),p.onChange(n)}},Ae(de,{container:!0,direction:"column",children:[Q(de,{item:!0,children:n.label}),n.afterLabel&&Q(de,{item:!0,children:n.afterLabel})]})),value:p.value||null,readOnly:m.disabled,noOptionsText:g||"Nenhuma op\xE7\xE3o encontrada",...m,renderInput:V=>Q(yo,{placeholder:f,...V,error:!!a,slotProps:{input:{inputProps:V.inputProps,inputRef:p.ref}}})},e),Q(I,{name:e,disableIcon:C,control:u.control})]})})},Vo=bo(go);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 Ao}from"react/jsx-runtime";var Io=({name:e,rules:o,defaultValue:l,shouldUnregister:i,control:d,label:P,labelPlacement:g,required:f,disableIconError:T,onChange:x,...C})=>{let m=To()?.control,u=d??m;if(!u)throw new v("Checkbox");let{field:a}=vo({control:u,name:e,rules:o,defaultValue:l,shouldUnregister:i});return Ao("span",{children:[pe(ko,{control:pe(So,{checked:!!a.value,value:a.value??"",defaultValue:a.value,onChange:(p,V)=>{a.onChange(p,V),x?.(p,V)},...C},e),label:pe(S,{label:P,required:f,regular:!0}),labelPlacement:g||"end"}),pe(I,{name:e,disableIcon:T,control:u})]})},wo=Io;import{forwardRef as Ro,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 Z,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 Le}from"@emotion/react";import{styled as Lo}from"@mui/material";import{toRem as me}from"@s_mart/utils";var De=Le`
2
2
  display: flex;
3
3
  align-items: center;
4
4
  justify-content: center;
5
- `,mt=e=>Ne`
5
+ `,Do=e=>Le`
6
6
  .creatable,
7
7
  .editable {
8
- ${Ge}
8
+ ${De}
9
9
 
10
10
  .divider {
11
11
  width: 1px;
12
- height: ${pe(20)};
12
+ height: ${me(20)};
13
13
  background-color: ${e.palette.grey[400]};
14
14
  }
15
15
 
@@ -20,9 +20,9 @@ import{FormProvider as ao}from"react-hook-form";import{jsx as Ie}from"react/jsx-
20
20
  color: ${e.palette.grey[600]};
21
21
  border-radius: 50%;
22
22
 
23
- margin: 0 ${pe(6)};
24
- width: ${pe(28)};
25
- height: ${pe(28)};
23
+ margin: 0 ${me(6)};
24
+ width: ${me(28)};
25
+ height: ${me(28)};
26
26
 
27
27
  &:hover {
28
28
  cursor: pointer;
@@ -31,14 +31,14 @@ import{FormProvider as ao}from"react-hook-form";import{jsx as Ie}from"react/jsx-
31
31
  }
32
32
  }
33
33
  }
34
- `,ze=pt("div")`
34
+ `,Re=Lo("div")`
35
35
  display: flex;
36
36
 
37
37
  div.endAdornments {
38
38
  position: absolute;
39
39
  right: 0;
40
40
 
41
- ${Ge}
41
+ ${De}
42
42
  }
43
43
 
44
44
  .MuiAutocomplete-endAdornment {
@@ -50,37 +50,19 @@ import{FormProvider as ao}from"react-hook-form";import{jsx as Ie}from"react/jsx-
50
50
  transform: translate(0, 0);
51
51
  }
52
52
 
53
- ${({hideAddButton:e,theme:o})=>!e&&mt(o)}
54
- `;import{Fragment as Pe,jsx as D,jsxs as K}from"react/jsx-runtime";import{createElement as Ue}from"react";var He=ct(({name:e,rules:o,defaultValue:l,shouldUnregister:i,label:s,required:P,options:g,editable:f,footer:T,onEditOption:x,onCreateOption:C,textFieldProps:m,hideAddButton:u,multiple:a,info:p,onChange:V,onInputChange:n,placeholder:F,disableIconError:A,...r})=>{let y=Ft();if(!y)throw new v("Creatable");let G=R(y.formState.errors,e),b=u||r.disabled,d=t=>{let k=0;return m?.InputProps||(k+=2.5),b||(k+=2.56,w(t)&&(k+=2.56)),!r.disableClearable&&!r.disabled&&(k+=1.3),k+"rem"},w=t=>r.disabled?!1:f&&yt(t)&&!xt(t);console.warn=()=>{};let L=t=>{C?C(t):console.error("onCreateOption n\xE3o foi definido")},c=t=>{x?x(t):console.error("onEditOption n\xE3o foi definido")};return D(ft,{control:y.control,name:e,rules:o,defaultValue:l,shouldUnregister:i,render:({field:{value:t,onChange:k,ref:z}})=>{let J=t?.label||t?.value||t;return K(ee,{sx:{display:"flex",flexDirection:"column"},children:[K("div",{style:{display:"flex"},children:[s&&D(ee,{item:!0,children:D(S,{label:s,required:P})}),p&&D(ee,{item:!0,children:D(Pt,{title:p,placement:"top",children:D("div",{style:{width:"fit-content"},children:D(me,{icon:Tt,color:"#757575"})})})})]}),D(ze,{hideAddButton:b,children:D(bt,{fullWidth:!0,onChange:(B,h)=>{k(h),V?.(h,y.getValues())},onInputChange:(B,h,ne)=>{ne==="input"&&setTimeout(()=>{n?.(h,y.getValues())},0)},slotProps:{...r.slotProps||{},paper:{...(r.slotProps||{}).paper||{},sx:{border:`1px solid ${Ct.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}},listbox:{component:ut(function(h,ne){return K(Pe,{children:[D("ul",{...h,ref:ne}),!!T&&D("div",{...h,children:K(Pe,{children:[D(ee,{sx:{px:2,py:1},children:D(gt,{})}),T]})},"creatable-footer")]})})}},options:g,value:t||(a?[]:null),multiple:a,readOnly:r.disabled,noOptionsText:b?void 0:K(Vt,{sx:{justifyContent:"flex-start",padding:`${_e(6)} ${_e(-16)}`,margin:0},fullWidth:!0,onClick:()=>L(t),variant:"text",startIcon:D(me,{icon:qe}),children:["Adicionar ",J&&`"${J}"`]}),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"?Ue("li",{...B,key:h.key||h.value},K(ee,{container:!0,direction:"column",children:[D(ee,{item:!0,children:h.label}),h.afterLabel&&D(ee,{item:!0,children:h.afterLabel})]})):Ue("li",{...B,key:h},h),...r,sx:{"& div.MuiInputBase-root":{paddingRight:`${d(t)} !important`},...r.sx},renderInput:B=>D(ht,{placeholder:F,...B,error:!!G,...m,slotProps:{input:{...B.InputProps,inputRef:z,endAdornment:K("div",{className:"endAdornments",children:[B.InputProps.endAdornment,!b&&K(Pe,{children:[w(t)?K("div",{className:"editable",children:[D("div",{className:"divider"}),D("div",{className:"button",onClick:()=>c(t),children:D(me,{icon:vt,size:"24px",removeMargin:!0})})]}):null,K("div",{className:"creatable",children:[D("div",{className:"divider"}),D("div",{className:"button",onClick:()=>L(t),children:D(me,{icon:qe,size:"24px",removeMargin:!0})})]})]})]})}}})},e)}),D(I,{name:e,disableIcon:A,control:y.control})]})}})});He.displayName="Creatable";var St=He;import{useController as kt,useFormContext as It}from"react-hook-form";import{Checkbox as wt,FormControlLabel as Lt}from"@mui/material";import{jsx as ue,jsxs as Rt}from"react/jsx-runtime";var At=({name:e,rules:o,defaultValue:l,shouldUnregister:i,control:s,label:P,labelPlacement:g,required:f,disableIconError:T,onChange:x,...C})=>{let m=It()?.control,u=s??m;if(!u)throw new v("Checkbox");let{field:a}=kt({control:u,name:e,rules:o,defaultValue:l,shouldUnregister:i});return Rt("span",{children:[ue(Lt,{control:ue(wt,{checked:!!a.value,value:a.value??"",defaultValue:a.value,onChange:(p,V)=>{a.onChange(p,V),x?.(p,V)},...C},e),label:ue(S,{label:P,required:f,regular:!0}),labelPlacement:g||"end"}),ue(I,{name:e,disableIcon:T,control:u})]})},Dt=At;import{FormControlLabel as Bt,Stack as Et,Switch as Mt}from"@mui/material";import{useController as $t,useFormContext as Ot}from"react-hook-form";import{jsx as ce,jsxs as zt}from"react/jsx-runtime";var Nt=({name:e,rules:o,defaultValue:l,shouldUnregister:i,control:s,label:P,labelPlacement:g,disableIconError:f,onChange:T,...x})=>{let C=Ot()?.control,m=s??C;if(!m)throw new v("Switch");let{field:u}=$t({control:m,name:e,rules:o,defaultValue:l,shouldUnregister:i});return zt(Et,{children:[ce(Bt,{control:ce(Mt,{value:u.value??"",checked:u.value??!1,defaultValue:u.value,onChange:(a,p)=>{u.onChange(a,p),T?.(a,p)},...x},e),label:ce(S,{label:P}),labelPlacement:g||"end"}),ce(I,{name:e,disableIcon:f,control:m})]})},Gt=Nt;import{RadioGroup as qt,Stack as _t}from"@mui/material";import{useController as Ut,useFormContext as Ht}from"react-hook-form";import{jsx as ge,jsxs as Yt}from"react/jsx-runtime";var Kt=({name:e,rules:o,defaultValue:l,shouldUnregister:i,control:s,label:P,required:g,children:f,orientation:T="row",disableIconError:x,...C})=>{let m=Ht()?.control,u=s??m;if(!u)throw new v("RadioGroup");let{field:a}=Ut({control:u,name:e,rules:o,defaultValue:l,shouldUnregister:i});return Yt(_t,{children:[P&&ge(S,{label:P,required:g}),ge(qt,{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),ge(I,{name:e,disableIcon:x,control:u})]})},Wt=Kt;import{FormControlLabel as jt,Grid2 as Jt,Radio as Xt}from"@mui/material";import{jsx as fe}from"react/jsx-runtime";var Qt=({label:e,labelPlacement:o,...l})=>fe(Jt,{sx:{display:"flex",flexDirection:"column"},children:fe(jt,{control:fe(Xt,{...l}),label:fe(S,{label:e}),labelPlacement:o||"end"})}),Zt=Qt;import{useController as er,useFormContext as or}from"react-hook-form";import{Slider as tr}from"@mui/material";import{jsx as ir}from"react/jsx-runtime";var rr=({name:e,rules:o,defaultValue:l,shouldUnregister:i,control:s,...P})=>{let g=or()?.control,f=s??g;if(!f)throw new v("Slider");let{field:T}=er({control:f,name:e,rules:o,defaultValue:l,shouldUnregister:i});return ir(tr,{value:T.value||P?.min||0,onChange:T.onChange,valueLabelDisplay:"auto",...P},e)},lr=rr;import{Stack as pr,TextField as mr}from"@mui/material";import{AdapterDayjs as ur}from"@mui/x-date-pickers/AdapterDayjs";import{DatePicker as cr}from"@mui/x-date-pickers/DatePicker";import{LocalizationProvider as fr}from"@mui/x-date-pickers/LocalizationProvider";import{ptBR as Fr}from"@mui/x-date-pickers/locales/ptBR";import{composeValidators as yr,date as We}from"@s_mart/rules";import xr from"dayjs/locale/pt-br";import{memo as br}from"react";import{useController as hr,useFormContext as Pr,useFormState as gr}from"react-hook-form";import{IconButton as nr,styled as ar}from"@mui/material";import{toRem as W}from"@s_mart/utils";var dr=e=>{switch(e){case"small":return W(16);default:case"medium":return W(20);case"large":return W(24)}},sr=e=>{switch(e){case"small":return`${W(2)} ${W(8)}`;default:case"medium":return`${W(6)} ${W(8)}`;case"large":return`${W(10)}`}},Ke=ar(nr)`
55
- margin: 0px;
56
-
57
- padding: ${({size:e})=>sr(e)};
58
- border-radius: 0 ${W(4)} ${W(4)} 0;
59
-
60
- svg {
61
- width: ${({size:e})=>dr(e)} !important;
62
- }
63
- `;import{jsx as Fe,jsxs as Tr}from"react/jsx-runtime";import{createElement as vr}from"react";var Vr=({rules:e,name:o,defaultValue:l,shouldUnregister:i,control:s,datePickerProps:P,label:g,required:f,placeholder:T,disabled:x,disableIconError:C,...m})=>{let u=Pr()?.control,a=s??u;if(!a)throw new v("DatePicker");let p=gr({control:a,name:o}),V=R(p.errors,o),n=P?.format||"DD/MM/YYYY",F=e?yr([We(n),e]):We(n),{field:A}=hr({control:a,name:o,rules:F,defaultValue:l,shouldUnregister:i});return Fe(fr,{dateAdapter:ur,adapterLocale:xr,localeText:Fr.components.MuiLocalizationProvider.defaultProps.localeText,children:Tr(pr,{children:[g&&Fe(S,{label:g,required:f}),vr(cr,{...P,key:o,value:A.value??null,format:n,onChange:(r,y)=>{A.onChange(r,y),P?.onChange?.(r,y)},disabled:x,slots:{textField:mr,openPickerButton:r=>Fe(Ke,{...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=>{A.ref(y),typeof r.inputRef=="function"&&r.inputRef(y)}}})}}),Fe(I,{name:o,disableIcon:C,control:a})]})})},Cr=br(Vr);import{Stack as Lr,TextField as Ar}from"@mui/material";import{AdapterDayjs as Dr}from"@mui/x-date-pickers/AdapterDayjs";import{LocalizationProvider as Rr}from"@mui/x-date-pickers/LocalizationProvider";import{TimePicker as Br}from"@mui/x-date-pickers/TimePicker";import{ptBR as Er}from"@mui/x-date-pickers/locales/ptBR";import{composeValidators as Mr,time as je}from"@s_mart/rules";import $r from"dayjs/locale/pt-br";import{memo as Or}from"react";import{useController as Nr,useFormContext as Gr,useFormState as zr}from"react-hook-form";import{styled as Sr}from"@mui/material";import{IconButton as kr}from"@mui/material";import{toRem as Y}from"@s_mart/utils";var Ir=e=>{switch(e){case"small":return Y(16);case"large":return Y(24);default:return Y(20)}},wr=e=>{switch(e){case"small":return`${Y(2)} ${Y(8)}`;case"large":return Y(10);default:return`${Y(6)} ${Y(8)}`}},Ye=Sr(kr)`
64
- margin: 0px;
65
-
66
- padding: ${({size:e})=>wr(e)};
67
- border-radius: 0 ${Y(4)} ${Y(4)} 0;
68
-
69
- svg {
70
- width: ${({size:e})=>Ir(e)} !important;
71
- }
72
- `;import{jsx as de,jsxs as Ur}from"react/jsx-runtime";var qr=({rules:e,defaultValue:o,shouldUnregister:l,name:i,control:s,required:P,label:g,timePickerProps:f,placeholder:T,disabled:x,disableIconError:C,...m})=>{let u=Gr()?.control,a=s??u;if(!a)throw new v("TimePicker");let p=zr({control:a,name:i}),V=R(p.errors,i),n=f?.format||"HH:mm",F=e?Mr([je(n),e]):je(n),{field:A}=Nr({control:a,name:i,rules:F,defaultValue:o,shouldUnregister:l});return de(Rr,{dateAdapter:Dr,adapterLocale:$r,localeText:Er.components.MuiLocalizationProvider.defaultProps.localeText,children:Ur(Lr,{children:[g&&de(S,{label:g,required:P}),de(Br,{ampm:!1,format:n,value:A.value??null,disabled:x,...f,onChange:(r,y)=>{A.onChange(r,y),f?.onChange?.(r,y)},slots:{textField:Ar,openPickerButton:r=>de(Ye,{...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=>{A.ref(y),typeof r.inputRef=="function"&&r.inputRef(y)}}})}},i),de(I,{name:i,disableIcon:C,control:a})]})})},_r=Or(qr);import{Autocomplete as Hr,Grid as ye,TextField as Kr}from"@mui/material";import{colorPalette as Wr}from"@s_mart/tokens";import{memo as Yr}from"react";import{Controller as jr,useFormContext as Jr}from"react-hook-form";import{jsx as oe,jsxs as Je}from"react/jsx-runtime";import{createElement as Zr}from"react";var Xr=({name:e,defaultValue:o,rules:l,shouldUnregister:i,label:s,required:P,noOptionsText:g,placeholder:f,onInputChange:T,onChange:x,disableIconError:C,...m})=>{let u=Jr();if(!u)throw new v("Autocomplete");let a=R(u.formState.errors,e);return console.warn=()=>{},oe(jr,{name:e,control:u.control,defaultValue:o,rules:l,shouldUnregister:i,render:({field:p})=>Je(ye,{sx:{display:"flex",flexDirection:"column"},children:[s&&oe(S,{label:s,required:P}),oe(Hr,{onChange:(V,n)=>{p.onChange(n),x?.(n,u.getValues())},onInputChange:(V,n,F)=>{F==="input"&&(p.onChange(n),setTimeout(()=>{T?.(n,u.getValues())},0))},slotProps:{...m.slotProps||{},paper:{...m.slotProps?.paper||{},sx:{border:`1px solid ${Wr.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}}},isOptionEqualToValue:(V,n)=>V.value===n.value,renderOption:(V,n)=>Zr("li",{...V,key:n.key||n.value,onClick:F=>{V.onClick?.(F),p.onChange(n)}},Je(ye,{container:!0,direction:"column",children:[oe(ye,{item:!0,children:n.label}),n.afterLabel&&oe(ye,{item:!0,children:n.afterLabel})]})),value:p.value||null,readOnly:m.disabled,noOptionsText:g||"Nenhuma op\xE7\xE3o encontrada",...m,renderInput:V=>oe(Kr,{placeholder:f,...V,error:!!a,slotProps:{input:{inputProps:V.inputProps,inputRef:p.ref}}})},e),oe(I,{name:e,disableIcon:C,control:u.control})]})})},Qr=Yr(Xr);import{Autocomplete as il,Divider as Xe,TextField as nl}from"@mui/material";import{colorPalette as al}from"@s_mart/tokens";import{isEqual as dl}from"lodash-es";import{forwardRef as sl}from"react";import{useController as pl,useFormContext as ml,useFormState as ul}from"react-hook-form";import{Tooltip as el}from"@mui/material";import{LIcon as ol}from"@s_mart/core";import{lineInfoCircle as tl}from"@s_mart/solid-icons";import{jsx as Ve}from"react/jsx-runtime";var rl=({title:e})=>Ve(el,{title:e,placement:"top",children:Ve("div",{style:{width:"fit-content"},children:Ve(ol,{icon:tl,color:"#757575"})})}),te=rl;import{memo as ll}from"react";var ie=ll;import{Fragment as Ce,jsx as q,jsxs as re}from"react/jsx-runtime";import{createElement as Fl}from"react";var cl=e=>{let{name:o,rules:l,defaultValue:i,shouldUnregister:s,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:A,getOptionKey:r,...y}=e,G=ml()?.control,b=P??G;if(!b)throw new v("SearchableV2");let d=ul({control:b,name:o}),w=R(d.errors,o),{field:L}=pl({name:o,control:b,rules:l,defaultValue:i,shouldUnregister:s});return re("div",{style:{display:"flex",flexDirection:"column"},children:[re("div",{style:{display:"flex"},children:[g&&q(S,{label:g,required:f}),a&&q(te,{title:a})]}),q(il,{onChange:(c,t)=>{L.onChange(t),V?.(t)},onInputChange:(c,t,k)=>{k==="input"&&n?.(t)},value:L.value,options:T,multiple:u,readOnly:y.disabled,slotProps:{...y.slotProps,paper:{...y.slotProps?.paper,sx:{border:`1px solid ${al.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}},listbox:{component:sl(function(t,k){return re(Ce,{children:[q("ul",{...t,ref:k}),typeof m<"u"?re("div",{...t,children:[q("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:q(Xe,{})}),m()]},"searchable-footer"):null]})})}},noOptionsText:re(Ce,{children:[C||"Nenhuma op\xE7\xE3o encontrada",typeof m<"u"?re(Ce,{children:[q("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:q(Xe,{})}),m()]}):null]}),isOptionEqualToValue:(c,t)=>dl(c,t),getOptionLabel:A,getOptionKey:r,renderOption:typeof F=="function"?(c,t)=>{let k=F(t),z=r(t);return Fl("li",{...c,key:z},re("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[q("span",{children:A(t)}),typeof k=="string"?q("span",{children:k}):k]}))}:void 0,...y,renderInput:c=>q(nl,{error:!!w,placeholder:p,...c,...x,inputRef:L.ref})},o),q(I,{name:o,control:b})]})},fl=ie(cl);import{useState as bl}from"react";import{useController as hl,useFormContext as Pl,useFormState as gl}from"react-hook-form";import{IconButton as Vl,LIcon as Cl}from"@s_mart/core";import{lineTimes as vl}from"@s_mart/regular-icons";import{colorPalette as Tl}from"@s_mart/tokens";import{Select as Sl,MenuItem as kl,Divider as Il}from"@mui/material";import{colorPalette as yl}from"@s_mart/tokens";import{jsx as xl}from"react/jsx-runtime";var Qe=({value:e,placeholder:o,getOptionLabel:l})=>e===null||e?.length===0?xl("p",{style:{color:yl.neutral[100]},children:o}):l(e);import{Fragment as Al,jsx as _,jsxs as le}from"react/jsx-runtime";var wl=e=>{let{name:o,rules:l,defaultValue:i,shouldUnregister:s,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:A,...r}=e,y=Pl()?.control,G=P??y,[b,d]=bl(!1);if(!G)throw new v("SelectV2");let w=gl({control:G,name:o}),L=R(w.errors,o),{field:c}=hl({control:G,name:o,rules:l,defaultValue:i,shouldUnregister:s});return le("div",{style:{display:"flex",flexDirection:"column"},children:[le("div",{style:{display:"flex"},children:[g&&_(S,{label:g,required:f}),m&&_(te,{title:m})]}),le(Sl,{open:b,onOpen:()=>d(!0),onClose:()=>d(!1),displayEmpty:!!x,variant:p,autoComplete:"off",value:c.value||null,renderValue:t=>_(Qe,{getOptionLabel:n,placeholder:x,value:t}),onChange:t=>{c.onChange(t.target.value),a?.(t.target.value)},error:!!L,size:r.size||"medium",inputRef:c.ref,...r,endAdornment:le(Al,{children:[r.endAdornment,!!(C&&c.value)&&_(Vl,{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:_(Cl,{icon:vl,color:Tl.neutral[100],size:"25px",removeMargin:!0})})]}),children:[T.map(t=>{let k=V(t),z=n(t),J=A?.(t);return _(kl,{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,_("span",{children:F?.(t)??null})]})},k)}),u!==void 0&&le("div",{children:[_("div",{style:{padding:"8px 16px"},children:_(Il,{})},"footer-divider"),_("div",{children:u({closeSelect:()=>d(!1)})},"footer-content")]},"footer")]},o),_(I,{name:o,control:G})]})},Ll=ie(wl);import{forwardRef as Bl,useCallback as El,useState as Ml}from"react";import{useController as $l,useFormContext as Ol,useFormState as Nl}from"react-hook-form";import{isObject as Gl,isEmpty as zl,isEqual as ql}from"lodash-es";import{Autocomplete as _l,TextField as Ul,Divider as oo,Button as Hl}from"@mui/material";import{LIcon as ve}from"@s_mart/core";import{colorPalette as Kl}from"@s_mart/tokens";import{linePlus as to,linePen as Wl}from"@s_mart/solid-icons";import{toRem as ro}from"@s_mart/utils";import{css as Dl,styled as Rl}from"@mui/material";import{toRem as xe}from"@s_mart/utils";import"@mui/system";var Ze=Dl`
53
+ ${({hideAddButton:e,theme:o})=>!e&&Do(o)}
54
+ `;import{Fragment as be,jsx as D,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:d,required:P,options:g,editable:f,footer:T,onEditOption:x,onCreateOption:C,textFieldProps:m,hideAddButton:u,multiple:a,info:p,onChange:V,onInputChange:n,placeholder:F,disableIconError:L,...r})=>{let y=Mo();if(!y)throw new v("Creatable");let G=R(y.formState.errors,e),b=u||r.disabled,s=t=>{let k=0;return m?.InputProps||(k+=2.5),b||(k+=2.56,w(t)&&(k+=2.56)),!r.disableClearable&&!r.disabled&&(k+=1.3),k+"rem"},w=t=>r.disabled?!1:f&&Oo(t)&&!$o(t);console.warn=()=>{};let A=t=>{C?C(t):console.error("onCreateOption n\xE3o foi definido")},c=t=>{x?x(t):console.error("onEditOption n\xE3o foi definido")};return D(Eo,{control:y.control,name:e,rules:o,defaultValue:l,shouldUnregister:i,render:({field:{value:t,onChange:k,ref:z}})=>{let J=t?.label||t?.value||t;return H(Z,{sx:{display:"flex",flexDirection:"column"},children:[H("div",{style:{display:"flex"},children:[d&&D(Z,{item:!0,children:D(S,{label:d,required:P})}),p&&D(Z,{item:!0,children:D(zo,{title:p,placement:"top",children:D("div",{style:{width:"fit-content"},children:D(ue,{icon:Ko,color:"#757575"})})})})]}),D(Re,{hideAddButton:b,children:D(No,{fullWidth:!0,onChange:(B,h)=>{k(h),V?.(h,y.getValues())},onInputChange:(B,h,ne)=>{ne==="input"&&setTimeout(()=>{n?.(h,y.getValues())},0)},slotProps:{...r.slotProps||{},paper:{...(r.slotProps||{}).paper||{},sx:{border:`1px solid ${Uo.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}},listbox:{component:Ro(function(h,ne){return H(be,{children:[D("ul",{...h,ref:ne}),!!T&&D("div",{...h,children:H(be,{children:[D(Z,{sx:{px:2,py:1},children:D(qo,{})}),T]})},"creatable-footer")]})})}},options:g,value:t||(a?[]:null),multiple:a,readOnly:r.disabled,noOptionsText:b?void 0:H(_o,{sx:{justifyContent:"flex-start",padding:`${Ee(6)} ${Ee(-16)}`,margin:0},fullWidth:!0,onClick:()=>A(t),variant:"text",startIcon:D(ue,{icon:Be}),children:["Adicionar ",J&&`"${J}"`]}),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(Z,{container:!0,direction:"column",children:[D(Z,{item:!0,children:h.label}),h.afterLabel&&D(Z,{item:!0,children:h.afterLabel})]})):Me("li",{...B,key:h},h),...r,sx:{"& div.MuiInputBase-root":{paddingRight:`${s(t)} !important`},...r.sx},renderInput:B=>D(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:[D("div",{className:"divider"}),D("div",{className:"button",onClick:()=>c(t),children:D(ue,{icon:Ho,size:"24px",removeMargin:!0})})]}):null,H("div",{className:"creatable",children:[D("div",{className:"divider"}),D("div",{className:"button",onClick:()=>A(t),children:D(ue,{icon:Be,size:"24px",removeMargin:!0})})]})]})]})}}})},e)}),D(I,{name:e,disableIcon:L,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 st,isEqual as dt}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 ct}from"@s_mart/tokens";import{linePlus as ze,linePen as ft}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 ce}from"@s_mart/utils";import"@mui/system";var $e=Yo`
73
55
  display: flex;
74
56
  align-items: center;
75
57
  justify-content: center;
76
- `,eo=Rl("div")`
58
+ `,Ne=jo("div")`
77
59
  display: flex;
78
60
 
79
61
  div.endAdornments {
80
62
  position: absolute;
81
63
  right: 0;
82
64
 
83
- ${Ze}
65
+ ${$e}
84
66
  }
85
67
 
86
68
  .MuiAutocomplete-endAdornment {
@@ -94,11 +76,11 @@ import{FormProvider as ao}from"react-hook-form";import{jsx as Ie}from"react/jsx-
94
76
 
95
77
  .creatable,
96
78
  .editable {
97
- ${Ze}
79
+ ${$e}
98
80
 
99
81
  .divider {
100
82
  width: 1px;
101
- height: ${xe(20)};
83
+ height: ${ce(20)};
102
84
  background-color: ${({theme:e})=>e.palette.grey[400]};
103
85
  }
104
86
 
@@ -109,9 +91,9 @@ import{FormProvider as ao}from"react-hook-form";import{jsx as Ie}from"react/jsx-
109
91
  color: ${({theme:e})=>e.palette.grey[600]};
110
92
  border-radius: 50%;
111
93
 
112
- margin: 0 ${xe(6)};
113
- width: ${xe(28)};
114
- height: ${xe(28)};
94
+ margin: 0 ${ce(6)};
95
+ width: ${ce(28)};
96
+ height: ${ce(28)};
115
97
 
116
98
  &:hover {
117
99
  cursor: pointer;
@@ -120,4 +102,22 @@ import{FormProvider as ao}from"react-hook-form";import{jsx as Ie}from"react/jsx-
120
102
  }
121
103
  }
122
104
  }
123
- `;import{Fragment as Te,jsx as M,jsxs as U}from"react/jsx-runtime";import{createElement as Jl}from"react";function Yl(e){let{name:o,rules:l,defaultValue:i,shouldUnregister:s,control:P,label:g,required:f,options:T,footer:x,showCreatableButton:C=!0,showEditableButton:m,onEditOption:u,onCreateOption:a,getOptionKey:p,getOptionLabel:V,getOptionAfterLabel:n,textFieldProps:F,multiple:A,info:r,noOptionsText:y,onChange:G,onInputChange:b,placeholder:d,...w}=e,[L,c]=Ml(""),t=Ol()?.control,k=P??t;if(!k)throw new v("CreatableV2");let z=Nl({control:k,name:o}),J=R(z.errors,o),B=!C||w.disabled,{field:h}=$l({name:o,control:k,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&&Gl($)&&!zl($),lo=()=>w.disabled?!1:C,ke=El(()=>{typeof a<"u"&&(a(L),c(""))},[L,a]),io=$=>{u?.($)};return U("div",{style:{display:"flex",flexDirection:"column"},children:[U("div",{style:{display:"flex"},children:[g&&M(S,{label:g,required:f}),r&&M(te,{title:r})]}),M(eo,{children:M(_l,{fullWidth:!0,onChange:($,E)=>{c(""),h.onChange(E),G?.(E)},onInputChange:($,E,X)=>{X==="input"&&(c(E),b?.(E))},slotProps:{...w.slotProps,paper:{...w.slotProps?.paper,sx:{border:`1px solid ${Kl.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}},listbox:{component:Bl(function(E,X){return U(Te,{children:[M("ul",{...E,ref:X}),typeof x<"u"?U("div",{...E,children:[M("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:M(oo,{})}),x()]},"creatable-footer"):null]})})}},value:h.value,options:T,multiple:A,readOnly:w.disabled,noOptionsText:U(Te,{children:[y||"Nenhuma op\xE7\xE3o encontrada",!B&&U(Hl,{sx:{justifyContent:"flex-start",padding:`${ro(6)} ${ro(-16)}`,margin:0},fullWidth:!0,onClick:ke,variant:"text",startIcon:M(ve,{icon:to}),children:["Adicionar ",`"${L}"`]}),typeof x<"u"&&U(Te,{children:[M("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:M(oo,{})}),x()]})]}),isOptionEqualToValue:($,E)=>ql($,E),getOptionLabel:V,getOptionKey:p,renderOption:typeof n=="function"?($,E)=>{let X=n(E),no=p(E);return Jl("li",{...$,key:no},U("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[M("span",{children:V(E)}),typeof X=="string"?M("span",{children:X}):X]}))}:void 0,...w,sx:{"& div.MuiInputBase-root":{paddingRight:`${ne(h.value)} !important`},...w.sx},onBlur:$=>{w?.onBlur?.($),c("")},renderInput:$=>M(Ul,{placeholder:d,...$,error:!!J,...F,slotProps:{input:{...$.InputProps,...F?.InputProps,inputRef:h.ref,endAdornment:U("div",{className:"endAdornments",children:[$.InputProps.endAdornment,F?.InputProps?.endAdornment??null,Se(h.value)?U("div",{className:"editable",children:[M("div",{className:"divider"}),M("div",{className:"button",onKeyUp:()=>io(h.value),children:M(ve,{icon:Wl,size:"24px",removeMargin:!0})})]}):null,lo()&&U("div",{className:"creatable",children:[M("div",{className:"divider"}),M("div",{className:"button",onKeyUp:ke,children:M(ve,{icon:to,size:"24px",removeMargin:!0})})]})]})}}})},o)}),M(I,{name:o,control:k})]})}var jl=ie(Yl);export{Qr as Autocomplete,Dt as Checkbox,St as Creatable,jl as CreatableV2,Cr as DatePicker,Fo as Form,be as FormProvider,Zt as RadioButton,Wt as RadioGroup,st as Searchable,fl as SearchableV2,Xo as Select,Ll as SelectV2,lr as Slider,Gt as Switch,$o as TextField,_r as TimePicker,he as useForm};
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"})})}),ee=Zo;import{memo as et}from"react";var ie=et;import{Fragment as ge,jsx as M,jsxs as _}from"react/jsx-runtime";import{createElement as xt}from"react";function Ft(e){let{name:o,rules:l,defaultValue:i,shouldUnregister:d,control:P,label:g,required:f,options:T,footer:x,showCreatableButton:C=!0,showEditableButton:m,onEditOption:u,onCreateOption:a,getOptionKey:p,getOptionLabel:V,getOptionAfterLabel:n,textFieldProps:F,multiple:L,info:r,noOptionsText:y,onChange:G,onInputChange:b,placeholder:s,...w}=e,[A,c]=rt(""),t=it()?.control,k=P??t;if(!k)throw new v("CreatableV2");let z=nt({control:k,name:o}),J=R(z.errors,o),B=!C||w.disabled,{field:h}=lt({name:o,control:k,rules:l,defaultValue:i,shouldUnregister:d}),ne=O=>{let E=0;return F?.InputProps||(E+=2.5),B||(E+=2.56,Se(O)&&(E+=2.56)),!w.disableClearable&&!w.disabled&&(E+=1.3),`${E}rem`},Se=O=>w.disabled?!1:m&&at(O)&&!st(O),lo=()=>w.disabled?!1:C,ke=tt(()=>{typeof a<"u"&&(a(A),c(""))},[A,a]),io=O=>{u?.(O)};return _("div",{style:{display:"flex",flexDirection:"column"},children:[_("div",{style:{display:"flex"},children:[g&&M(S,{label:g,required:f}),r&&M(ee,{title:r})]}),M(Ne,{children:M(pt,{fullWidth:!0,onChange:(O,E)=>{c(""),h.onChange(E),G?.(E)},onInputChange:(O,E,X)=>{X==="input"&&(c(E),b?.(E))},slotProps:{...w.slotProps,paper:{...w.slotProps?.paper,sx:{border:`1px solid ${ct.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}},listbox:{component:ot(function(E,X){return _(ge,{children:[M("ul",{...E,ref:X}),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:T,multiple:L,readOnly:w.disabled,noOptionsText:_(ge,{children:[y||"Nenhuma op\xE7\xE3o encontrada",!B&&_(ut,{sx:{justifyContent:"flex-start",padding:`${qe(6)} ${qe(-16)}`,margin:0},fullWidth:!0,onClick:ke,variant:"text",startIcon:M(Pe,{icon:ze}),children:["Adicionar ",`"${A}"`]}),typeof x<"u"&&_(ge,{children:[M("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:M(Ge,{})}),x()]})]}),isOptionEqualToValue:(O,E)=>dt(O,E),getOptionLabel:V,getOptionKey:p,renderOption:typeof n=="function"?(O,E)=>{let X=n(E),no=p(E);return xt("li",{...O,key:no},_("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[M("span",{children:V(E)}),typeof X=="string"?M("span",{children:X}):X]}))}:void 0,...w,sx:{"& div.MuiInputBase-root":{paddingRight:`${ne(h.value)} !important`},...w.sx},onBlur:O=>{w?.onBlur?.(O),c("")},renderInput:O=>M(mt,{placeholder:s,...O,error:!!J,...F,slotProps:{input:{...O.InputProps,...F?.InputProps,inputRef:h.ref,endAdornment:_("div",{className:"endAdornments",children:[O.InputProps.endAdornment,F?.InputProps?.endAdornment??null,Se(h.value)?_("div",{className:"editable",children:[M("div",{className:"divider"}),M("div",{className:"button",onKeyUp:()=>io(h.value),children:M(Pe,{icon:ft,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(I,{name:o,control:k})]})}var yt=ie(Ft);import{Stack as Vt,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 At}from"react";import{useController as Lt,useFormContext as Dt,useFormState as Rt}from"react-hook-form";import{IconButton as bt,styled as ht}from"@mui/material";import{toRem as K}from"@s_mart/utils";var Pt=e=>{switch(e){case"small":return K(16);default:case"medium":return K(20);case"large":return K(24)}},gt=e=>{switch(e){case"small":return`${K(2)} ${K(8)}`;default:case"medium":return`${K(6)} ${K(8)}`;case"large":return`${K(10)}`}},_e=ht(bt)`
106
+ margin: 0px;
107
+
108
+ padding: ${({size:e})=>gt(e)};
109
+ border-radius: 0 ${K(4)} ${K(4)} 0;
110
+
111
+ svg {
112
+ width: ${({size:e})=>Pt(e)} !important;
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)`
115
+ margin: 0px;
116
+
117
+ padding: ${({size:e})=>El(e)};
118
+ border-radius: 0 ${Y(4)} ${Y(4)} 0;
119
+
120
+ svg {
121
+ width: ${({size:e})=>Bl(e)} !important;
122
+ }
123
+ `;import{jsx as se,jsxs as Jl}from"react/jsx-runtime";var Yl=({rules:e,defaultValue:o,shouldUnregister:l,name:i,control:d,required:P,label:g,timePickerProps:f,placeholder:T,disabled:x,disableIconError:C,...m})=>{let u=Kl()?.control,a=d??u;if(!a)throw new v("TimePicker");let p=Wl({control:a,name:i}),V=R(p.errors,i),n=f?.format||"HH:mm",F=e?ql([ro(n),e]):ro(n),{field:L}=Hl({control:a,name:i,rules:F,defaultValue:o,shouldUnregister:l});return se(Nl,{dateAdapter:$l,adapterLocale:_l,localeText:zl.components.MuiLocalizationProvider.defaultProps.localeText,children:Jl(Ml,{children:[g&&se(S,{label:g,required:P}),se(Gl,{ampm:!1,format:n,value:L.value??null,disabled:x,...f,onChange:(r,y)=>{L.onChange(r,y),f?.onChange?.(r,y)},slots:{textField:Ol,openPickerButton:r=>se(to,{...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)}}})}},i),se(I,{name:i,disableIcon:C,control:a})]})})},jl=Ul(Yl);export{Vo as Autocomplete,wo as Checkbox,Wo as Creatable,yt as CreatableV2,Et as DatePicker,Ht as Form,Ve as FormProvider,lr as RadioButton,Qt as RadioGroup,Fr as Searchable,Tr as SearchableV2,Gr as Select,tl as SelectV2,sl as Slider,yl as Switch,Ll 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",
3
+ "version": "9.2.0-beta.4",
4
4
  "main": "./dist/index.mjs",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.mts",
@@ -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.2",
54
53
  "@s_mart/masks": "5.2.0",
55
54
  "@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"