@s_mart/form 9.2.0-beta.3 → 9.2.0-beta.5
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 +406 -379
- package/dist/index.mjs +37 -37
- package/package.json +3 -3
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 {
|
|
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, Control, 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
|
-
|
|
10
|
-
|
|
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
|
-
*
|
|
133
|
-
*
|
|
134
|
-
* @type {SelectOption[]}
|
|
17
|
+
* Opções do autocomplete
|
|
18
|
+
* @default []
|
|
135
19
|
*
|
|
136
20
|
* @example
|
|
137
|
-
*
|
|
138
|
-
* { label: '
|
|
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
|
-
*
|
|
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
24
|
*
|
|
25
|
+
* @type {AutoCompleteOption[]}
|
|
26
|
+
* @memberof AutocompleteProps
|
|
163
27
|
*/
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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
|
-
* <
|
|
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
|
|
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
|
-
*
|
|
222
|
-
* @default
|
|
223
|
-
* @
|
|
224
|
-
* @
|
|
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
|
-
/**
|
|
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
55
|
/**
|
|
235
|
-
*
|
|
236
|
-
*
|
|
56
|
+
* Posição do label em relação ao checkbox
|
|
57
|
+
* @default 'end'
|
|
58
|
+
* @type 'start' | 'end' | 'top' | 'bottom'
|
|
237
59
|
* @example
|
|
238
|
-
*
|
|
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
|
-
|
|
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
|
|
379
|
-
|
|
380
|
-
|
|
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
|
-
*
|
|
389
|
-
* @default
|
|
390
|
-
* @type
|
|
391
|
-
* @
|
|
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
|
-
|
|
196
|
+
showCreatableButton?: boolean;
|
|
395
197
|
/**
|
|
396
|
-
*
|
|
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
|
-
*
|
|
221
|
+
* footer: (
|
|
222
|
+
* <Button onClick={handleClick}>Mostrar mais...</Button>
|
|
223
|
+
* )
|
|
401
224
|
*/
|
|
402
|
-
|
|
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
|
|
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
|
|
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
|
-
*
|
|
410
|
-
*
|
|
411
|
-
* @
|
|
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
|
-
|
|
258
|
+
required?: boolean;
|
|
416
259
|
/**
|
|
417
|
-
*
|
|
418
|
-
*
|
|
419
|
-
* @
|
|
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
|
-
|
|
264
|
+
disabled?: boolean;
|
|
424
265
|
/**
|
|
425
266
|
* Desabilita o ícone de erro da validação do campo.
|
|
426
267
|
* @default false
|
|
@@ -431,7 +272,88 @@ type SwitchProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<
|
|
|
431
272
|
disableIconError?: boolean;
|
|
432
273
|
};
|
|
433
274
|
|
|
434
|
-
declare const
|
|
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
|
+
type FieldLabelProps = {
|
|
278
|
+
label: React.ReactNode;
|
|
279
|
+
required?: boolean;
|
|
280
|
+
regular?: boolean;
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
declare const FieldLabel: ({ label, required, regular }: FieldLabelProps) => react_jsx_runtime.JSX.Element;
|
|
284
|
+
|
|
285
|
+
type FieldErrorProps<TFieldValues extends FieldValues, TFieldNames extends FieldPath<TFieldValues>> = {
|
|
286
|
+
name: TFieldNames;
|
|
287
|
+
disableIcon?: boolean;
|
|
288
|
+
control: Control<TFieldValues>;
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
declare const FieldError: <TFieldValues extends FieldValues, TFieldNames extends FieldPath<TFieldValues>>({ name, disableIcon, control, }: FieldErrorProps<TFieldValues, TFieldNames>) => react_jsx_runtime.JSX.Element | null;
|
|
292
|
+
|
|
293
|
+
type FieldInfoProps = {
|
|
294
|
+
title: React.ReactNode;
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
declare const FieldInfo: ({ title }: FieldInfoProps) => react_jsx_runtime.JSX.Element;
|
|
298
|
+
|
|
299
|
+
interface IFormProps<T extends FieldValues> extends IUseFormProps<T> {
|
|
300
|
+
children: ((methods: UseFormReturn<T> & {
|
|
301
|
+
onSubmit: (e?: React.FormEvent | undefined) => Promise<void>;
|
|
302
|
+
}) => React.ReactNode) | React.ReactNode;
|
|
303
|
+
style?: React.HTMLAttributes<HTMLFormElement>['style'];
|
|
304
|
+
}
|
|
305
|
+
interface IFormProviderProps<TFieldValues extends FieldValues> extends FormProviderProps<TFieldValues> {
|
|
306
|
+
style?: React.HTMLAttributes<HTMLFormElement>['style'];
|
|
307
|
+
onSubmit: (e?: React.BaseSyntheticEvent) => void;
|
|
308
|
+
}
|
|
309
|
+
interface IUseFormProps<TValues extends FieldValues> extends Omit<UseFormProps<TValues>, 'resolver'> {
|
|
310
|
+
onSubmit: (data: TValues, methods: UseFormReturn<TValues>) => void;
|
|
311
|
+
/**
|
|
312
|
+
* Prop que faz com que o formulário não atualize ao mudar o defaultValue
|
|
313
|
+
*/
|
|
314
|
+
disableDefaultValuesUpdate?: boolean;
|
|
315
|
+
schema?: z.ZodObject<any> | z.ZodEffects<z.ZodObject<any>>;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Utilizado overloading para poder passar uma tipagem para o Componente
|
|
320
|
+
* @example
|
|
321
|
+
* // Não passar uma tipagem, todas as props terão o funcionamento normal, sem tipagem
|
|
322
|
+
* <Form onSubmit={({email}) => {}}>
|
|
323
|
+
* ...
|
|
324
|
+
* </Form>
|
|
325
|
+
* @example
|
|
326
|
+
* // Passar uma tipagem, todas as props derivadas do react-hook-form terão a tipagem passada no generic
|
|
327
|
+
* type Cadastro = {
|
|
328
|
+
* email: string;
|
|
329
|
+
* }
|
|
330
|
+
* <Form<Cadastro> onSubmit={({email}) => {}}>
|
|
331
|
+
* ...
|
|
332
|
+
* </Form>
|
|
333
|
+
*/
|
|
334
|
+
declare function Form(props: IFormProps<any>): JSX.Element;
|
|
335
|
+
declare function Form<T extends FieldValues>(props: IFormProps<T>): JSX.Element;
|
|
336
|
+
|
|
337
|
+
declare const useForm: <TValues extends FieldValues>({ disableDefaultValuesUpdate, onSubmit, ...rest }: IUseFormProps<TValues>) => {
|
|
338
|
+
onSubmit: (e?: react.BaseSyntheticEvent<object, any, any> | undefined) => Promise<void>;
|
|
339
|
+
watch: react_hook_form.UseFormWatch<TValues>;
|
|
340
|
+
getValues: react_hook_form.UseFormGetValues<TValues>;
|
|
341
|
+
getFieldState: react_hook_form.UseFormGetFieldState<TValues>;
|
|
342
|
+
setError: react_hook_form.UseFormSetError<TValues>;
|
|
343
|
+
clearErrors: react_hook_form.UseFormClearErrors<TValues>;
|
|
344
|
+
setValue: react_hook_form.UseFormSetValue<TValues>;
|
|
345
|
+
trigger: react_hook_form.UseFormTrigger<TValues>;
|
|
346
|
+
formState: react_hook_form.FormState<TValues>;
|
|
347
|
+
resetField: react_hook_form.UseFormResetField<TValues>;
|
|
348
|
+
reset: react_hook_form.UseFormReset<TValues>;
|
|
349
|
+
handleSubmit: react_hook_form.UseFormHandleSubmit<TValues, undefined>;
|
|
350
|
+
unregister: react_hook_form.UseFormUnregister<TValues>;
|
|
351
|
+
control: react_hook_form.Control<TValues, any>;
|
|
352
|
+
register: react_hook_form.UseFormRegister<TValues>;
|
|
353
|
+
setFocus: react_hook_form.UseFormSetFocus<TValues>;
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
declare function FormProvider<TFieldValues extends FieldValues>({ children, style, onSubmit, ...methods }: IFormProviderProps<TFieldValues>): react_jsx_runtime.JSX.Element;
|
|
435
357
|
|
|
436
358
|
type RadioGroupProps<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = RadioGroupProps$1 & UseControllerProps<TFieldValues, TFieldName> & {
|
|
437
359
|
/**
|
|
@@ -499,86 +421,20 @@ type RadioProps = RadioProps$1 & {
|
|
|
499
421
|
|
|
500
422
|
declare const RadioButton: ({ label, labelPlacement, ...rest }: RadioProps) => react_jsx_runtime.JSX.Element;
|
|
501
423
|
|
|
502
|
-
type
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
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 = {
|
|
424
|
+
type ControllerSearchable = Omit<ControllerProps, 'render' | 'control'>;
|
|
425
|
+
/**
|
|
426
|
+
* @deprecated usar SearchableV2
|
|
427
|
+
*/
|
|
428
|
+
type SearchableOption = {
|
|
576
429
|
key?: string | number;
|
|
577
430
|
label: string;
|
|
578
431
|
value: string | number | readonly string[] | undefined;
|
|
579
432
|
afterLabel?: string | React.ReactNode;
|
|
580
|
-
};
|
|
581
|
-
|
|
433
|
+
} | string;
|
|
434
|
+
/**
|
|
435
|
+
* @deprecated usar SearchableV2
|
|
436
|
+
*/
|
|
437
|
+
type SearchableProps = Omit<AutocompleteProps$1<SearchableOption, true, true, true>, 'renderInput' | 'size' | 'onInputChange' | 'onChange'> & ControllerSearchable & {
|
|
582
438
|
/**
|
|
583
439
|
* Opções do autocomplete
|
|
584
440
|
* @default []
|
|
@@ -588,12 +444,40 @@ type AutocompleteProps<ValueType = any> = Omit<UseControllerProps, 'control'> &
|
|
|
588
444
|
* { label: 'Opção 1', value: '1' },
|
|
589
445
|
* ]
|
|
590
446
|
*
|
|
591
|
-
* @type {
|
|
592
|
-
* @memberof
|
|
447
|
+
* @type {SearchableOption[]}
|
|
448
|
+
* @memberof SearchableProps
|
|
593
449
|
*/
|
|
594
|
-
options:
|
|
450
|
+
options: SearchableOption[];
|
|
451
|
+
/**
|
|
452
|
+
* Props do textField que é renderizado dentro do autocomplete
|
|
453
|
+
* @default {}
|
|
454
|
+
* @type {TextFieldProps}
|
|
455
|
+
* @memberof SearchableProps
|
|
456
|
+
*/
|
|
457
|
+
textFieldProps?: TextFieldProps$1;
|
|
595
458
|
label?: React.ReactNode;
|
|
596
459
|
required?: boolean;
|
|
460
|
+
/**
|
|
461
|
+
* Texto que será exibido quando não houver opções para serem exibidas
|
|
462
|
+
* @default 'Nenhuma opção encontrada'
|
|
463
|
+
*/
|
|
464
|
+
noOptionsText?: string;
|
|
465
|
+
/**
|
|
466
|
+
* Componente que renderiza no footer do searchable (opcional)
|
|
467
|
+
*
|
|
468
|
+
* @example
|
|
469
|
+
* footer: (
|
|
470
|
+
* <Button onClick={handleClick}>Mostrar mais...</Button>
|
|
471
|
+
* )
|
|
472
|
+
*
|
|
473
|
+
*
|
|
474
|
+
*/
|
|
475
|
+
footer?: React.ReactNode;
|
|
476
|
+
/**
|
|
477
|
+
* É o conteúdo passado para a tooltip que renderizará ao lado da label do campo,
|
|
478
|
+
* montada à tela como um ícone de informação.
|
|
479
|
+
*/
|
|
480
|
+
info?: React.ReactNode;
|
|
597
481
|
onInputChange?: (value: string, values: FieldValues) => void;
|
|
598
482
|
onChange?: (value: any, values: FieldValues) => void;
|
|
599
483
|
/**
|
|
@@ -607,7 +491,10 @@ type AutocompleteProps<ValueType = any> = Omit<UseControllerProps, 'control'> &
|
|
|
607
491
|
placeholder?: string;
|
|
608
492
|
};
|
|
609
493
|
|
|
610
|
-
|
|
494
|
+
/**
|
|
495
|
+
* @deprecated usar SearchableV2
|
|
496
|
+
*/
|
|
497
|
+
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
498
|
|
|
612
499
|
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
500
|
options: FieldValue[];
|
|
@@ -653,6 +540,87 @@ type SearchableV2Props<TFieldValues extends FieldValues = FieldValues, TFieldNam
|
|
|
653
540
|
|
|
654
541
|
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
542
|
|
|
543
|
+
type ControllerSelect = Omit<ControllerProps, 'render' | 'control'>;
|
|
544
|
+
/**
|
|
545
|
+
* @deprecated
|
|
546
|
+
*/
|
|
547
|
+
type SelectOption = {
|
|
548
|
+
label: string;
|
|
549
|
+
value: string | number | readonly string[] | undefined;
|
|
550
|
+
afterLabel?: string | React.ReactNode;
|
|
551
|
+
};
|
|
552
|
+
/**
|
|
553
|
+
* @deprecated
|
|
554
|
+
*/
|
|
555
|
+
type FooterProps = {
|
|
556
|
+
closeSelect: () => void;
|
|
557
|
+
};
|
|
558
|
+
/**
|
|
559
|
+
* @deprecated
|
|
560
|
+
*/
|
|
561
|
+
type SelectProps = Omit<SelectProps$1, 'onChange'> & ControllerSelect & {
|
|
562
|
+
/**
|
|
563
|
+
* As opções que serão renderizadas no select
|
|
564
|
+
*
|
|
565
|
+
* @type {SelectOption[]}
|
|
566
|
+
*
|
|
567
|
+
* @example
|
|
568
|
+
* options: [
|
|
569
|
+
* { label: 'Option 1', value: 'option1' },
|
|
570
|
+
* { label: 'Option 2', value: 'option2' },
|
|
571
|
+
* ]
|
|
572
|
+
*/
|
|
573
|
+
options: SelectOption[];
|
|
574
|
+
onChange?: (value: any, values: FieldValues) => void;
|
|
575
|
+
/**
|
|
576
|
+
* Desabilita o onChange do select, para que o onChange do form não seja disparado
|
|
577
|
+
*
|
|
578
|
+
* @type {boolean}
|
|
579
|
+
* @default false
|
|
580
|
+
*
|
|
581
|
+
* @example
|
|
582
|
+
* <Select name="select" options={options} disableOnChangeForm />
|
|
583
|
+
*/
|
|
584
|
+
disableOnChangeForm?: boolean;
|
|
585
|
+
/**
|
|
586
|
+
* Função que renderiza o footer do select (opcional) - recebe como parâmetro a função closeSelect que fecha o select
|
|
587
|
+
* @param {FooterProps} props
|
|
588
|
+
*
|
|
589
|
+
* @example
|
|
590
|
+
* footer: ({ closeSelect }) => (
|
|
591
|
+
* <Button onClick={closeSelect}>Fechar</Button>
|
|
592
|
+
* )
|
|
593
|
+
*
|
|
594
|
+
*/
|
|
595
|
+
footer?: (props: FooterProps) => React.ReactNode;
|
|
596
|
+
/**
|
|
597
|
+
* É o conteúdo passado para a tooltip que renderizará ao lado da label do campo,
|
|
598
|
+
* montada à tela como um ícone de informação.
|
|
599
|
+
*/
|
|
600
|
+
info?: React.ReactNode;
|
|
601
|
+
/**
|
|
602
|
+
* Desabilita o ícone de erro da validação do campo.
|
|
603
|
+
* @default false
|
|
604
|
+
*
|
|
605
|
+
* @example
|
|
606
|
+
* <Select disableIconError />
|
|
607
|
+
*/
|
|
608
|
+
disableIconError?: boolean;
|
|
609
|
+
/**
|
|
610
|
+
* Habilita ícone no endAdornment para limpar o valor do campo.
|
|
611
|
+
* @default false
|
|
612
|
+
*
|
|
613
|
+
* @example
|
|
614
|
+
* <Select clearable />
|
|
615
|
+
*/
|
|
616
|
+
clearable?: boolean;
|
|
617
|
+
};
|
|
618
|
+
|
|
619
|
+
/**
|
|
620
|
+
* @deprecated usar SelectV2
|
|
621
|
+
*/
|
|
622
|
+
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>;
|
|
623
|
+
|
|
656
624
|
type FooterPropsV2 = {
|
|
657
625
|
closeSelect: () => void;
|
|
658
626
|
};
|
|
@@ -706,73 +674,132 @@ type SelectV2Props<TFieldValues extends FieldValues = FieldValues, TFieldName ex
|
|
|
706
674
|
*/
|
|
707
675
|
getOptionIcon?: (option: FieldPathValue<TFieldValues, TFieldName>) => React.ReactNode;
|
|
708
676
|
};
|
|
677
|
+
type SelectV2ReturnValueProps<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = {
|
|
678
|
+
value: FieldPathValue<TFieldValues, TFieldName> | null;
|
|
679
|
+
placeholder: string | undefined;
|
|
680
|
+
getOptionLabel: (option: FieldPathValue<TFieldValues, TFieldName>) => string;
|
|
681
|
+
};
|
|
709
682
|
|
|
710
683
|
declare const _default$1: <TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>(props: SelectV2Props<TFieldValues, TFieldName>) => react_jsx_runtime.JSX.Element;
|
|
711
684
|
|
|
712
|
-
type
|
|
713
|
-
|
|
714
|
-
|
|
685
|
+
type SliderProps<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = SliderProps$1 & UseControllerProps<TFieldValues, TFieldName> & {
|
|
686
|
+
/**
|
|
687
|
+
* O nome do switch que será renderizado na tela
|
|
688
|
+
* @default ''
|
|
689
|
+
* @example 'Nome do switch'
|
|
690
|
+
* @type string
|
|
691
|
+
* @memberof SliderProps
|
|
692
|
+
*/
|
|
693
|
+
label?: string;
|
|
694
|
+
/**
|
|
695
|
+
* Posição do label em relação ao switch
|
|
696
|
+
* @default 'end'
|
|
697
|
+
* @type 'start' | 'end' | 'top' | 'bottom'
|
|
698
|
+
* @example
|
|
699
|
+
* <Slider label="Slider" labelPlacement="start" />
|
|
700
|
+
*/
|
|
701
|
+
labelPlacement?: 'start' | 'end' | 'top' | 'bottom';
|
|
702
|
+
};
|
|
703
|
+
|
|
704
|
+
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;
|
|
705
|
+
|
|
706
|
+
type SwitchProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = SwitchProps$1 & UseControllerProps<TFieldValues, TFieldName> & {
|
|
707
|
+
/**
|
|
708
|
+
* O nome do switch que será renderizado na tela
|
|
709
|
+
* @default ''
|
|
710
|
+
* @example 'Nome do switch'
|
|
711
|
+
* @type React.ReactNode
|
|
712
|
+
* @memberof SwitchProps
|
|
713
|
+
*/
|
|
715
714
|
label?: React.ReactNode;
|
|
716
|
-
required?: boolean;
|
|
717
715
|
/**
|
|
718
|
-
*
|
|
719
|
-
* @default
|
|
720
|
-
* @type
|
|
721
|
-
* @
|
|
716
|
+
* Posição do label em relação ao switch
|
|
717
|
+
* @default 'end'
|
|
718
|
+
* @type 'start' | 'end' | 'top' | 'bottom'
|
|
719
|
+
* @example
|
|
720
|
+
* <Switch label="Switch" labelPlacement="start" />
|
|
722
721
|
*/
|
|
723
|
-
|
|
722
|
+
labelPlacement?: 'start' | 'end' | 'top' | 'bottom';
|
|
724
723
|
/**
|
|
725
|
-
*
|
|
724
|
+
* Desabilita o ícone de erro da validação do campo.
|
|
726
725
|
* @default false
|
|
727
|
-
*
|
|
728
|
-
* @
|
|
726
|
+
*
|
|
727
|
+
* @example
|
|
728
|
+
* <TextField disableIconError />
|
|
729
729
|
*/
|
|
730
|
-
|
|
730
|
+
disableIconError?: boolean;
|
|
731
|
+
};
|
|
732
|
+
|
|
733
|
+
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;
|
|
734
|
+
|
|
735
|
+
type Masks = 'cpf' | 'cnpj' | 'cpfCnpj' | 'cep' | 'telefone' | 'decimal' | 'decimal3' | 'decimal4' | 'decimal5' | 'porcentagem' | 'porcentagem0' | 'nome' | 'numero' | 'numeroPontuacao' | 'placa' | 'valor' | 'valor3' | 'valor4';
|
|
736
|
+
type TextFieldProps<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = TextFieldProps$1 & UseControllerProps<TFieldValues, TFieldName> & {
|
|
737
|
+
mask?: Masks;
|
|
731
738
|
/**
|
|
732
|
-
* Função que será executada quando o
|
|
733
|
-
* @
|
|
734
|
-
* @
|
|
735
|
-
*
|
|
739
|
+
* @description Função que será executada quando o valor do input for alterado
|
|
740
|
+
* @param value valor atual do Field
|
|
741
|
+
* @param values valores atuais do Form
|
|
742
|
+
*
|
|
743
|
+
* @example onInputChange={(values,values) => console.log({value, values})}
|
|
736
744
|
*/
|
|
737
|
-
|
|
745
|
+
onInputChange?: (value: string) => void;
|
|
738
746
|
/**
|
|
739
|
-
*
|
|
740
|
-
* @
|
|
741
|
-
*
|
|
742
|
-
* @
|
|
747
|
+
* @param value Valor do input
|
|
748
|
+
* @returns Valor formatado para o input
|
|
749
|
+
*
|
|
750
|
+
* @example
|
|
751
|
+
* <TextField mask="cpf" parse={(value) => value.replace(/\D/g, '')} />
|
|
743
752
|
*/
|
|
744
|
-
|
|
753
|
+
parse?: (value: string) => string;
|
|
745
754
|
/**
|
|
746
|
-
*
|
|
755
|
+
* @param value Valor do input formatado
|
|
756
|
+
* @returns Valor sem formatação para o input
|
|
757
|
+
*
|
|
747
758
|
* @example
|
|
748
|
-
*
|
|
749
|
-
* <Button onClick={handleClick}>Mostrar mais...</Button>
|
|
750
|
-
* )
|
|
759
|
+
* <TextField mask="cpf" format={(value) => value.replace(/\D/g, '')} />
|
|
751
760
|
*/
|
|
752
|
-
|
|
761
|
+
format?: (value: string) => string;
|
|
753
762
|
/**
|
|
754
763
|
* É o conteúdo passado para a tooltip que renderizará ao lado da label do campo,
|
|
755
764
|
* montada à tela como um ícone de informação.
|
|
756
765
|
*/
|
|
757
766
|
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
767
|
/**
|
|
762
|
-
*
|
|
768
|
+
* Desabilita o ícone de erro da validação do campo.
|
|
769
|
+
* @default false
|
|
770
|
+
*
|
|
771
|
+
* @example
|
|
772
|
+
* <TextField disableIconError />
|
|
763
773
|
*/
|
|
764
|
-
|
|
774
|
+
disableIconError?: boolean;
|
|
775
|
+
};
|
|
776
|
+
|
|
777
|
+
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;
|
|
778
|
+
|
|
779
|
+
type TimePickerProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = UseControllerProps<TFieldValues, TFieldName> & Pick<TextFieldProps$1, 'label' | 'error' | 'helperText' | 'size' | 'fullWidth' | 'variant' | 'autoFocus' | 'placeholder'> & {
|
|
780
|
+
timePickerProps?: Partial<TimePickerProps$1<any>>;
|
|
765
781
|
/**
|
|
766
|
-
*
|
|
782
|
+
* Se `true` irá adicionar um asterisco ao label do campo
|
|
783
|
+
*
|
|
784
|
+
* @default false
|
|
767
785
|
*/
|
|
768
|
-
|
|
786
|
+
required?: boolean;
|
|
769
787
|
/**
|
|
770
|
-
*
|
|
788
|
+
* Se `true` irá desabilitar o campo e não será possível interagir com ele
|
|
789
|
+
*
|
|
790
|
+
* @default false
|
|
771
791
|
*/
|
|
772
|
-
|
|
792
|
+
disabled?: boolean;
|
|
793
|
+
/**
|
|
794
|
+
* Desabilita o ícone de erro da validação do campo.
|
|
795
|
+
* @default false
|
|
796
|
+
*
|
|
797
|
+
* @example
|
|
798
|
+
* <TextField disableIconError />
|
|
799
|
+
*/
|
|
800
|
+
disableIconError?: boolean;
|
|
773
801
|
};
|
|
774
802
|
|
|
775
|
-
declare
|
|
776
|
-
declare const _default: typeof CreatableV2;
|
|
803
|
+
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
804
|
|
|
778
|
-
export { _default$
|
|
805
|
+
export { type AutoCompleteOption, _default$5 as Autocomplete, type AutocompleteProps, Checkbox, type CheckboxProps, Creatable, type CreatableOption, type CreatableProps, _default$4 as CreatableV2, type CreatableV2Props, _default$3 as DatePicker, type DatePickerProps, FieldError, type FieldErrorProps, FieldInfo, type FieldInfoProps, FieldLabel, type FieldLabelProps, type FooterProps, type FooterPropsV2, Form, FormProvider, type IFormProps, type IFormProviderProps, type IUseFormProps, type Masks, RadioButton, RadioGroup, type RadioGroupProps, type RadioProps, Searchable, type SearchableOption, type SearchableProps, _default$2 as SearchableV2, type SearchableV2Props, Select, type SelectOption, type SelectProps, type SelectProps as SelectPropsMui, _default$1 as SelectV2, type SelectV2Props, type SelectV2ReturnValueProps, Slider, type SliderProps, Switch, type SwitchProps, TextField, type TextFieldProps, _default as TimePicker, type TimePickerProps, useForm };
|
package/dist/index.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Autocomplete as Fo,Grid as se,TextField as yo}from"@mui/material";import{colorPalette as xo}from"@s_mart/tokens";import{memo as bo}from"react";import{Controller as ho,useFormContext as Po}from"react-hook-form";import{Indicator as ao}from"@s_mart/core";import{useFormState as so}from"react-hook-form";var R=(e,o)=>o.replace(/[[\]]/g,"").split(".").reduce((i,s)=>i?.[s],e);import{jsx as mo}from"react/jsx-runtime";var po=({name:e,disableIcon:o,control:l})=>{let i=so({control:l,name:e}),s=R(i?.errors,e);return s?mo(ao,{severity:"error",icon:o?!1:void 0,children:s?.message}):null},k=po;import{Typography as Ie}from"@mui/material";import{toRem as uo}from"@s_mart/utils";import{jsx as we,jsxs as co}from"react/jsx-runtime";var fo=({label:e,required:o,regular:l})=>co("span",{style:{display:"flex",alignItems:"center",gap:uo(2)},children:[we(Ie,{variant:"caption",style:{display:"flex",alignItems:"center"},sx:{fontWeight:l?400:700},children:e}),o&&we(Ie,{variant:"caption",color:"error",sx:{fontWeight:900},children:"*"})]}),v=fo;var T=class extends Error{constructor(o){super(`O componente ${o} precisa de um control para funcionar. Passe o control como prop ou coloque o componente dentro de um <Form />`),this.name="FormComponentPrecisaDeControl"}};import{jsx as Z,jsxs as Le}from"react/jsx-runtime";import{createElement as Co}from"react";var go=({name:e,defaultValue:o,rules:l,shouldUnregister:i,label:s,required:P,noOptionsText:g,placeholder:c,onInputChange:S,onChange:x,disableIconError:C,...m})=>{let u=Po();if(!u)throw new T("Autocomplete");let a=R(u.formState.errors,e);return console.warn=()=>{},Z(ho,{name:e,control:u.control,defaultValue:o,rules:l,shouldUnregister:i,render:({field:p})=>Le(se,{sx:{display:"flex",flexDirection:"column"},children:[s&&Z(v,{label:s,required:P}),Z(Fo,{onChange:(V,n)=>{p.onChange(n),x?.(n,u.getValues())},onInputChange:(V,n,F)=>{F==="input"&&(p.onChange(n),setTimeout(()=>{S?.(n,u.getValues())},0))},slotProps:{...m.slotProps||{},paper:{...m.slotProps?.paper||{},sx:{border:`1px solid ${xo.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}}},isOptionEqualToValue:(V,n)=>V.value===n.value,renderOption:(V,n)=>Co("li",{...V,key:n.key||n.value,onClick:F=>{V.onClick?.(F),p.onChange(n)}},Le(se,{container:!0,direction:"column",children:[Z(se,{item:!0,children:n.label}),n.afterLabel&&Z(se,{item:!0,children:n.afterLabel})]})),value:p.value||null,readOnly:m.disabled,noOptionsText:g||"Nenhuma op\xE7\xE3o encontrada",...m,renderInput:V=>Z(yo,{placeholder:c,...V,error:!!a,slotProps:{input:{inputProps:V.inputProps,inputRef:p.ref}}})},e),Z(k,{name:e,disableIcon:C,control:u.control})]})})},Vo=bo(go);import{useController as vo,useFormContext as To}from"react-hook-form";import{Checkbox as So,FormControlLabel as ko}from"@mui/material";import{jsx as pe,jsxs as Lo}from"react/jsx-runtime";var Io=({name:e,rules:o,defaultValue:l,shouldUnregister:i,control:s,label:P,labelPlacement:g,required:c,disableIconError:S,onChange:x,...C})=>{let m=To()?.control,u=s??m;if(!u)throw new T("Checkbox");let{field:a}=vo({control:u,name:e,rules:o,defaultValue:l,shouldUnregister:i});return Lo("span",{children:[pe(ko,{control:pe(So,{checked:!!a.value,value:a.value??"",defaultValue:a.value,onChange:(p,V)=>{a.onChange(p,V),x?.(p,V)},...C},e),label:pe(v,{label:P,required:c,regular:!0}),labelPlacement:g||"end"}),pe(k,{name:e,disableIcon:S,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 ee,Autocomplete as No,TextField as Go,Tooltip as zo,Divider as qo}from"@mui/material";import{LIcon as ue,Button as _o}from"@s_mart/core";import{colorPalette as Uo}from"@s_mart/tokens";import{linePlus as Be,linePen as Ho,lineInfoCircle as Ko}from"@s_mart/solid-icons";import{toRem as Ee}from"@s_mart/utils";import{css as Ae}from"@emotion/react";import{styled as Ao}from"@mui/material";import{toRem as me}from"@s_mart/utils";var De=Ae`
|
|
2
2
|
display: flex;
|
|
3
3
|
align-items: center;
|
|
4
4
|
justify-content: center;
|
|
5
|
-
`,
|
|
5
|
+
`,Do=e=>Ae`
|
|
6
6
|
.creatable,
|
|
7
7
|
.editable {
|
|
8
|
-
${
|
|
8
|
+
${De}
|
|
9
9
|
|
|
10
10
|
.divider {
|
|
11
11
|
width: 1px;
|
|
12
|
-
height: ${
|
|
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 ${
|
|
24
|
-
width: ${
|
|
25
|
-
height: ${
|
|
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
|
-
`,
|
|
34
|
+
`,Re=Ao("div")`
|
|
35
35
|
display: flex;
|
|
36
36
|
|
|
37
37
|
div.endAdornments {
|
|
38
38
|
position: absolute;
|
|
39
39
|
right: 0;
|
|
40
40
|
|
|
41
|
-
${
|
|
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&&
|
|
54
|
-
`;import{Fragment as
|
|
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:s,required:P,options:g,editable:c,footer:S,onEditOption:x,onCreateOption:C,textFieldProps:m,hideAddButton:u,multiple:a,info:p,onChange:V,onInputChange:n,placeholder:F,disableIconError:A,...r})=>{let y=Mo();if(!y)throw new T("Creatable");let G=R(y.formState.errors,e),b=u||r.disabled,d=t=>{let I=0;return m?.InputProps||(I+=2.5),b||(I+=2.56,w(t)&&(I+=2.56)),!r.disableClearable&&!r.disabled&&(I+=1.3),I+"rem"},w=t=>r.disabled?!1:c&&Oo(t)&&!$o(t);console.warn=()=>{};let L=t=>{C?C(t):console.error("onCreateOption n\xE3o foi definido")},f=t=>{x?x(t):console.error("onEditOption n\xE3o foi definido")};return D(Eo,{control:y.control,name:e,rules:o,defaultValue:l,shouldUnregister:i,render:({field:{value:t,onChange:I,ref:z}})=>{let X=t?.label||t?.value||t;return H(ee,{sx:{display:"flex",flexDirection:"column"},children:[H("div",{style:{display:"flex"},children:[s&&D(ee,{item:!0,children:D(v,{label:s,required:P})}),p&&D(ee,{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)=>{I(h),V?.(h,y.getValues())},onInputChange:(B,h,ne)=>{ne==="input"&&setTimeout(()=>{n?.(h,y.getValues())},0)},slotProps:{...r.slotProps||{},paper:{...(r.slotProps||{}).paper||{},sx:{border:`1px solid ${Uo.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}},listbox:{component:Ro(function(h,ne){return H(be,{children:[D("ul",{...h,ref:ne}),!!S&&D("div",{...h,children:H(be,{children:[D(ee,{sx:{px:2,py:1},children:D(qo,{})}),S]})},"creatable-footer")]})})}},options:g,value:t||(a?[]:null),multiple:a,readOnly:r.disabled,noOptionsText:b?void 0:H(_o,{sx:{justifyContent:"flex-start",padding:`${Ee(6)} ${Ee(-16)}`,margin:0},fullWidth:!0,onClick:()=>L(t),variant:"text",startIcon:D(ue,{icon:Be}),children:["Adicionar ",X&&`"${X}"`]}),isOptionEqualToValue:(B,h)=>h?typeof B=="string"&&typeof h=="string"?B===h:typeof B=="object"&&typeof h=="object"?typeof B.value=="object"&&typeof h.value=="object"&&B.key!==void 0&&h.key!==void 0?B.key===h.key:B.value===h.value:typeof B=="object"&&typeof h=="string":!1,renderOption:(B,h)=>typeof h=="object"?Me("li",{...B,key:h.key||h.value},H(ee,{container:!0,direction:"column",children:[D(ee,{item:!0,children:h.label}),h.afterLabel&&D(ee,{item:!0,children:h.afterLabel})]})):Me("li",{...B,key:h},h),...r,sx:{"& div.MuiInputBase-root":{paddingRight:`${d(t)} !important`},...r.sx},renderInput:B=>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:()=>f(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:()=>L(t),children:D(ue,{icon:Be,size:"24px",removeMargin:!0})})]})]})]})}}})},e)}),D(k,{name:e,disableIcon:A,control:y.control})]})}})});Oe.displayName="Creatable";var Wo=Oe;import{forwardRef as ot,useCallback as tt,useState as rt}from"react";import{useController as lt,useFormContext as it,useFormState as nt}from"react-hook-form";import{isObject as at,isEmpty as dt,isEqual as st}from"lodash-es";import{Autocomplete as pt,TextField as mt,Divider as Ge,Button as ut}from"@mui/material";import{LIcon as Pe}from"@s_mart/core";import{colorPalette as ft}from"@s_mart/tokens";import{linePlus as ze,linePen as ct}from"@s_mart/solid-icons";import{toRem as qe}from"@s_mart/utils";import{css as Yo,styled as jo}from"@mui/material";import{toRem as fe}from"@s_mart/utils";import"@mui/system";var $e=Yo`
|
|
73
55
|
display: flex;
|
|
74
56
|
align-items: center;
|
|
75
57
|
justify-content: center;
|
|
76
|
-
`,
|
|
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
|
-
${
|
|
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
|
-
${
|
|
79
|
+
${$e}
|
|
98
80
|
|
|
99
81
|
.divider {
|
|
100
82
|
width: 1px;
|
|
101
|
-
height: ${
|
|
83
|
+
height: ${fe(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 ${
|
|
113
|
-
width: ${
|
|
114
|
-
height: ${
|
|
94
|
+
margin: 0 ${fe(6)};
|
|
95
|
+
width: ${fe(28)};
|
|
96
|
+
height: ${fe(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
|
|
105
|
+
`;import{Tooltip as Jo}from"@mui/material";import{LIcon as Xo}from"@s_mart/core";import{lineInfoCircle as Qo}from"@s_mart/solid-icons";import{jsx as he}from"react/jsx-runtime";var Zo=({title:e})=>he(Jo,{title:e,placement:"top",children:he("div",{style:{width:"fit-content"},children:he(Xo,{icon:Qo,color:"#757575"})})}),j=Zo;import{memo as et}from"react";var ie=et;import{Fragment as ge,jsx as M,jsxs as _}from"react/jsx-runtime";import{createElement as xt}from"react";function Ft(e){let{name:o,rules:l,defaultValue:i,shouldUnregister:s,control:P,label:g,required:c,options:S,footer:x,showCreatableButton:C=!0,showEditableButton:m,onEditOption:u,onCreateOption:a,getOptionKey:p,getOptionLabel:V,getOptionAfterLabel:n,textFieldProps:F,multiple:A,info:r,noOptionsText:y,onChange:G,onInputChange:b,placeholder:d,...w}=e,[L,f]=rt(""),t=it()?.control,I=P??t;if(!I)throw new T("CreatableV2");let z=nt({control:I,name:o}),X=R(z.errors,o),B=!C||w.disabled,{field:h}=lt({name:o,control:I,rules:l,defaultValue:i,shouldUnregister:s}),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)&&!dt(O),lo=()=>w.disabled?!1:C,ke=tt(()=>{typeof a<"u"&&(a(L),f(""))},[L,a]),io=O=>{u?.(O)};return _("div",{style:{display:"flex",flexDirection:"column"},children:[_("div",{style:{display:"flex"},children:[g&&M(v,{label:g,required:c}),r&&M(j,{title:r})]}),M(Ne,{children:M(pt,{fullWidth:!0,onChange:(O,E)=>{f(""),h.onChange(E),G?.(E)},onInputChange:(O,E,Q)=>{Q==="input"&&(f(E),b?.(E))},slotProps:{...w.slotProps,paper:{...w.slotProps?.paper,sx:{border:`1px solid ${ft.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}},listbox:{component:ot(function(E,Q){return _(ge,{children:[M("ul",{...E,ref:Q}),typeof x<"u"?_("div",{...E,children:[M("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:M(Ge,{})}),x()]},"creatable-footer"):null]})})}},value:h.value,options:S,multiple:A,readOnly:w.disabled,noOptionsText:_(ge,{children:[y||"Nenhuma op\xE7\xE3o encontrada",!B&&_(ut,{sx:{justifyContent:"flex-start",padding:`${qe(6)} ${qe(-16)}`,margin:0},fullWidth:!0,onClick:ke,variant:"text",startIcon:M(Pe,{icon:ze}),children:["Adicionar ",`"${L}"`]}),typeof x<"u"&&_(ge,{children:[M("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:M(Ge,{})}),x()]})]}),isOptionEqualToValue:(O,E)=>st(O,E),getOptionLabel:V,getOptionKey:p,renderOption:typeof n=="function"?(O,E)=>{let Q=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 Q=="string"?M("span",{children:Q}):Q]}))}:void 0,...w,sx:{"& div.MuiInputBase-root":{paddingRight:`${ne(h.value)} !important`},...w.sx},onBlur:O=>{w?.onBlur?.(O),f("")},renderInput:O=>M(mt,{placeholder:d,...O,error:!!X,...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:ct,size:"24px",removeMargin:!0})})]}):null,lo()&&_("div",{className:"creatable",children:[M("div",{className:"divider"}),M("div",{className:"button",onKeyUp:ke,children:M(Pe,{icon:ze,size:"24px",removeMargin:!0})})]})]})}}})},o)}),M(k,{name:o,control:I})]})}var yt=ie(Ft);import{Stack as Vt,TextField as Ct}from"@mui/material";import{AdapterDayjs as vt}from"@mui/x-date-pickers/AdapterDayjs";import{DatePicker as Tt}from"@mui/x-date-pickers/DatePicker";import{LocalizationProvider as St}from"@mui/x-date-pickers/LocalizationProvider";import{ptBR as kt}from"@mui/x-date-pickers/locales/ptBR";import{composeValidators as It,date as Ue}from"@s_mart/rules";import wt from"dayjs/locale/pt-br";import{memo as Lt}from"react";import{useController as At,useFormContext as 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 ce,jsxs as Ot}from"react/jsx-runtime";import{createElement as Mt}from"react";var Bt=({rules:e,name:o,defaultValue:l,shouldUnregister:i,control:s,datePickerProps:P,label:g,required:c,placeholder:S,disabled:x,disableIconError:C,...m})=>{let u=Dt()?.control,a=s??u;if(!a)throw new T("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:A}=At({control:a,name:o,rules:F,defaultValue:l,shouldUnregister:i});return ce(St,{dateAdapter:vt,adapterLocale:wt,localeText:kt.components.MuiLocalizationProvider.defaultProps.localeText,children:Ot(Vt,{children:[g&&ce(v,{label:g,required:c}),Mt(Tt,{...P,key:o,value:A.value??null,format:n,onChange:(r,y)=>{A.onChange(r,y),P?.onChange?.(r,y)},disabled:x,slots:{textField:Ct,openPickerButton:r=>ce(_e,{...r,size:m.size})},slotProps:{textField:r=>({variant:"outlined",...r,error:!!V,...m,inputProps:{...r.inputProps,placeholder:S||r.inputProps?.placeholder},InputProps:{...r.InputProps,inputRef:y=>{A.ref(y),typeof r.inputRef=="function"&&r.inputRef(y)}}})}}),ce(k,{name:o,disableIcon:C,control:a})]})})},Et=Lt(Bt);import{FormProvider as $t}from"react-hook-form";import{jsx as He}from"react/jsx-runtime";function Nt({children:e,style:o,onSubmit:l,...i}){return He($t,{...i,children:He("form",{onSubmit:s=>{s.preventDefault(),s.stopPropagation(),l(s)},style:o,children:e})})}var Ve=Nt;import{useEffect as Gt}from"react";import{useForm as zt}from"react-hook-form";import{zodResolver as qt}from"@hookform/resolvers/zod";var _t=({disableDefaultValuesUpdate:e,onSubmit:o,...l})=>{let i=zt({...l,resolver:l.schema&&qt(l.schema)});return Gt(()=>{e||i.reset(l.defaultValues)},[l.defaultValues,i.reset]),{...i,onSubmit:i.handleSubmit(s=>o(s,i))}},Ce=_t;import{jsx as Kt}from"react/jsx-runtime";function Ut({children:e,style:o,...l}){let i=Ce(l);return Kt(Ve,{...i,style:o,children:typeof e=="function"?e(i):e})}var Ht=Ut;import{RadioGroup as Wt,Stack as Yt}from"@mui/material";import{useController as jt,useFormContext as Jt}from"react-hook-form";import{jsx as ve,jsxs as Zt}from"react/jsx-runtime";var Xt=({name:e,rules:o,defaultValue:l,shouldUnregister:i,control:s,label:P,required:g,children:c,orientation:S="row",disableIconError:x,...C})=>{let m=Jt()?.control,u=s??m;if(!u)throw new T("RadioGroup");let{field:a}=jt({control:u,name:e,rules:o,defaultValue:l,shouldUnregister:i});return Zt(Yt,{children:[P&&ve(v,{label:P,required:g}),ve(Wt,{value:a.value||"",name:e,...C,onChange:p=>{C?.onChange?.(p,p.target?.value),a.onChange(p)},style:{display:"flex",flexDirection:S},children:c},e),ve(k,{name:e,disableIcon:x,control:u})]})},Qt=Xt;import{FormControlLabel as er,Grid2 as or,Radio as tr}from"@mui/material";import{jsx as Fe}from"react/jsx-runtime";var rr=({label:e,labelPlacement:o,...l})=>Fe(or,{sx:{display:"flex",flexDirection:"column"},children:Fe(er,{control:Fe(tr,{...l}),label:Fe(v,{label:e}),labelPlacement:o||"end"})}),lr=rr;import{Autocomplete as ir,Divider as Ke,Grid as J,TextField as nr,Tooltip as ar}from"@mui/material";import{LIcon as dr}from"@s_mart/core";import{lineInfoCircle as sr}from"@s_mart/solid-icons";import{colorPalette as pr}from"@s_mart/tokens";import{forwardRef as mr,memo as ur}from"react";import{Controller as fr,useFormContext as cr}from"react-hook-form";import{Fragment as ye,jsx as $,jsxs as oe}from"react/jsx-runtime";import{createElement as We}from"react";var Ye=ur(({name:e,rules:o,defaultValue:l,shouldUnregister:i,label:s,required:P,options:g,textFieldProps:c,noOptionsText:S,footer:x,multiple:C,info:m,placeholder:u,onChange:a,onInputChange:p,disableIconError:V,...n})=>{let F=cr();if(!F)throw new T("Searchable");let A=R(F.formState.errors,e);return $(fr,{control:F.control,name:e,rules:o,defaultValue:l,shouldUnregister:i,render:({field:{onChange:r,value:y,ref:G}})=>oe(J,{sx:{display:"flex",flexDirection:"column"},children:[oe("div",{style:{display:"flex"},children:[s&&$(J,{item:!0,children:$(v,{label:s,required:P})}),m&&$(J,{item:!0,children:$(ar,{title:m,placement:"top",children:$("div",{style:{width:"fit-content"},children:$(dr,{icon:sr,color:"#757575"})})})})]}),$(ir,{onChange:(b,d)=>{r(d),a?.(d,F.getValues())},onInputChange:(b,d,w)=>{w==="input"&&setTimeout(()=>{p?.(d,F.getValues())},0)},slotProps:{...n.slotProps||{},paper:{...(n.slotProps||{}).paper||{},sx:{border:`1px solid ${pr.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}},listbox:{component:mr(function(d,w){return oe(ye,{children:[$("ul",{...d,ref:w}),!!x&&$("div",{...d,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:[S||"Nenhum resultado encontrado",x?oe(ye,{children:[$(J,{sx:{py:1},children:$(Ke,{})}),x]}):null]}),isOptionEqualToValue:(b,d)=>typeof b=="string"&&typeof d=="string"?b===d:typeof b=="object"&&typeof d=="object"?typeof b.value=="object"&&typeof d.value=="object"&&b.key!==void 0&&d.key!==void 0?b.key===d.key:b.value===d.value:!1,renderOption:(b,d)=>typeof d=="object"?We("li",{...b,key:d.key||d.value},oe(J,{container:!0,direction:"column",children:[$(J,{item:!0,children:d.label}),d.afterLabel&&$(J,{item:!0,children:d.afterLabel})]})):We("li",{...b,key:d},d),...n,renderInput:b=>$(nr,{error:!!A,placeholder:u,...b,...c,inputRef:G})},e),$(k,{name:e,disableIcon:V,control:F.control})]})})});Ye.displayName="Searchable";var Fr=Ye;import{Autocomplete as yr,Divider as je,TextField as xr}from"@mui/material";import{colorPalette as br}from"@s_mart/tokens";import{isEqual as hr}from"lodash-es";import{forwardRef as Pr}from"react";import{useController as gr,useFormContext as Vr,useFormState as Cr}from"react-hook-form";import{Fragment as Te,jsx as q,jsxs as te}from"react/jsx-runtime";import{createElement as Sr}from"react";var vr=e=>{let{name:o,rules:l,defaultValue:i,shouldUnregister:s,control:P,label:g,required:c,options:S,textFieldProps:x,noOptionsText:C,footer:m,multiple:u,info:a,placeholder:p,onChange:V,onInputChange:n,getOptionAfterLabel:F,getOptionLabel:A,getOptionKey:r,...y}=e,G=Vr()?.control,b=P??G;if(!b)throw new T("SearchableV2");let d=Cr({control:b,name:o}),w=R(d.errors,o),{field:L}=gr({name:o,control:b,rules:l,defaultValue:i,shouldUnregister:s});return te("div",{style:{display:"flex",flexDirection:"column"},children:[te("div",{style:{display:"flex"},children:[g&&q(v,{label:g,required:c}),a&&q(j,{title:a})]}),q(yr,{onChange:(f,t)=>{L.onChange(t),V?.(t)},onInputChange:(f,t,I)=>{I==="input"&&n?.(t)},value:L.value,options:S,multiple:u,readOnly:y.disabled,slotProps:{...y.slotProps,paper:{...y.slotProps?.paper,sx:{border:`1px solid ${br.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}},listbox:{component:Pr(function(t,I){return te(Te,{children:[q("ul",{...t,ref:I}),typeof m<"u"?te("div",{...t,children:[q("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:q(je,{})}),m()]},"searchable-footer"):null]})})}},noOptionsText:te(Te,{children:[C||"Nenhuma op\xE7\xE3o encontrada",typeof m<"u"?te(Te,{children:[q("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:q(je,{})}),m()]}):null]}),isOptionEqualToValue:(f,t)=>hr(f,t),getOptionLabel:A,getOptionKey:r,renderOption:typeof F=="function"?(f,t)=>{let I=F(t),z=r(t);return Sr("li",{...f,key:z},te("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[q("span",{children:A(t)}),typeof I=="string"?q("span",{children:I}):I]}))}:void 0,...y,renderInput:f=>q(xr,{error:!!w,placeholder:p,...f,...x,inputRef:L.ref})},o),q(k,{name:o,control:b})]})},Tr=ie(vr);import{Divider as kr,Grid as re,MenuItem as Ir,Select as wr,Tooltip as Lr,useTheme as Ar}from"@mui/material";import{IconButton as 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:s,required:P,options:g,placeholder:c,clearable:S,disableOnChangeForm:x=!1,multiple:C,info:m,footer:u,onChange:a,disableIconError:p,variant:V="outlined",...n})=>{let F=Nr(),{palette:A}=Ar(),[r,y]=Or(!1);if(!F)throw new T("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:d,ref:w}})=>ae(re,{sx:{display:"flex",flexDirection:"column"},children:[ae("div",{style:{display:"flex"},children:[s&&N(re,{item:!0,children:N(v,{label:s,required:P})}),m&&N(re,{item:!0,children:N(Lr,{title:m,placement:"top",children:N("div",{style:{width:"fit-content"},children:N(Je,{icon:Br,color:"#757575"})})})})]}),ae(wr,{open:r,onOpen:()=>y(!0),onClose:()=>y(!1),displayEmpty:!!c,variant:V,autoComplete:"off",value:b?b||"":C?[]:"",renderValue:L=>{if(L.label)return L.label;if(c)return N("p",{style:{color:A.grey[400]},children:c})},multiple:C,onChange:L=>{!x&&d(L.target.value),a&&a(L.target.value,F.getValues())},error:!!G,size:n.size||"medium",inputRef:w,...n,endAdornment:ae(zr,{children:[n.endAdornment,!!(S&&b)&&N(Dr,{variant:"text",color:"neutral",size:"small",sx:{borderRadius:"50%",position:"absolute",right:"2rem"},style:{padding:0},"aria-label":"Clear",title:"Clear",onClick:()=>{!x&&d(null),a&&a(null,F.getValues())},children:N(Je,{icon:Rr,color:Er.neutral[100],size:"25px",removeMargin:!0})})]}),children:[g?.map((L,f)=>N(Ir,{value:L,children:ae(re,{container:!0,direction:"column",children:[N(re,{item:!0,children:L.label}),L.afterLabel&&N(re,{item:!0,children:L.afterLabel})]})},f)),u&&[N(re,{sx:{px:2,py:1},children:N(kr,{})},"footer-divider"),N("div",{children:u({closeSelect:()=>y(!1)})},"footer-content")]]},e),N(k,{name:e,disableIcon:p,control:F.control})]})})});Xe.displayName="Select";var Gr=Xe;import{useState as Ur}from"react";import{useController as Hr,useFormContext as Kr,useFormState as Wr}from"react-hook-form";import{IconButton as Yr,LIcon as jr}from"@s_mart/core";import{lineTimes as Jr}from"@s_mart/regular-icons";import{colorPalette as Xr}from"@s_mart/tokens";import{Select as Qr,MenuItem as Zr,Divider as el}from"@mui/material";import{colorPalette as qr}from"@s_mart/tokens";import{jsx as _r}from"react/jsx-runtime";var Qe=({value:e,placeholder:o,getOptionLabel:l})=>e===null||e?.length===0?_r("p",{style:{color:qr.neutral[100]},children:o}):l(e);import{Fragment as rl,jsx as U,jsxs as le}from"react/jsx-runtime";var ol=e=>{let{name:o,rules:l,defaultValue:i,shouldUnregister:s,control:P,label:g,required:c,options:S,placeholder:x,clearable:C,info:m,footer:u,onChange:a,variant:p="outlined",getOptionKey:V,getOptionLabel:n,getOptionAfterLabel:F,getOptionIcon:A,...r}=e,y=Kr()?.control,G=P??y,[b,d]=Ur(!1);if(!G)throw new T("SelectV2");let w=Wr({control:G,name:o}),L=R(w.errors,o),{field:f}=Hr({control:G,name:o,rules:l,defaultValue:i,shouldUnregister:s});return le("div",{style:{display:"flex",flexDirection:"column"},children:[le("div",{style:{display:"flex"},children:[g&&U(v,{label:g,required:c}),m&&U(j,{title:m})]}),le(Qr,{open:b,onOpen:()=>d(!0),onClose:()=>d(!1),displayEmpty:!!x,variant:p,autoComplete:"off",value:f.value||null,renderValue:t=>U(Qe,{getOptionLabel:n,placeholder:x,value:t}),onChange:t=>{f.onChange(t.target.value),a?.(t.target.value)},error:!!L,size:r.size||"medium",inputRef:f.ref,...r,endAdornment:le(rl,{children:[r.endAdornment,!!(C&&f.value)&&U(Yr,{variant:"text",color:"neutral",size:"small",sx:{borderRadius:"50%",position:"absolute",right:"2rem"},style:{padding:0},"aria-label":"Limpar",title:"Limpar",onClick:()=>{f.onChange(null),a?.(null)},children:U(jr,{icon:Jr,color:Xr.neutral[100],size:"25px",removeMargin:!0})})]}),children:[S.map(t=>{let I=V(t),z=n(t),X=A?.(t);return U(Zr,{value:I??z,children:le("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[X!==void 0?le("div",{style:{display:"flex",alignItems:"center"},children:[X,z]}):z,U("span",{children:F?.(t)??null})]})},I)}),u!==void 0&&le("div",{children:[U("div",{style:{padding:"8px 16px"},children:U(el,{})},"footer-divider"),U("div",{children:u({closeSelect:()=>d(!1)})},"footer-content")]},"footer")]},o),U(k,{name:o,control:G})]})},tl=ie(ol);import{useController as ll,useFormContext as il}from"react-hook-form";import{Slider as nl}from"@mui/material";import{jsx as sl}from"react/jsx-runtime";var al=({name:e,rules:o,defaultValue:l,shouldUnregister:i,control:s,...P})=>{let g=il()?.control,c=s??g;if(!c)throw new T("Slider");let{field:S}=ll({control:c,name:e,rules:o,defaultValue:l,shouldUnregister:i});return sl(nl,{value:S.value||P?.min||0,onChange:S.onChange,valueLabelDisplay:"auto",...P},e)},dl=al;import{FormControlLabel as pl,Stack as ml,Switch as ul}from"@mui/material";import{useController as fl,useFormContext as cl}from"react-hook-form";import{jsx as xe,jsxs as xl}from"react/jsx-runtime";var Fl=({name:e,rules:o,defaultValue:l,shouldUnregister:i,control:s,label:P,labelPlacement:g,disableIconError:c,onChange:S,...x})=>{let C=cl()?.control,m=s??C;if(!m)throw new T("Switch");let{field:u}=fl({control:m,name:e,rules:o,defaultValue:l,shouldUnregister:i});return xl(ml,{children:[xe(pl,{control:xe(ul,{value:u.value??"",checked:u.value??!1,defaultValue:u.value,onChange:(a,p)=>{u.onChange(a,p),S?.(a,p)},...x},e),label:xe(v,{label:P}),labelPlacement:g||"end"}),xe(k,{name:e,disableIcon:c,control:m})]})},yl=Fl;import{InputAdornment as bl,Stack as hl,TextField as Pl,Tooltip as gl}from"@mui/material";import{LIcon as Ze}from"@s_mart/core";import*as eo from"@s_mart/masks";import{lineEye as Vl,lineEyeSlash as Cl,lineInfoCircle as vl}from"@s_mart/solid-icons";import{useRef as Tl,useState as Sl}from"react";import{useController as kl,useFormContext as Il,useFormState as wl}from"react-hook-form";import{jsx as W,jsxs as oo}from"react/jsx-runtime";var Ll=({name:e,rules:o,defaultValue:l,shouldUnregister:i,control:s,label:P,required:g,mask:c,variant:S="outlined",info:x,parse:C,format:m,onInputChange:u,disableIconError:a,...p})=>{let V=Il()?.control,n=s??V,F=Tl(l||void 0);if(!n)throw new T("TextField");let[A,r]=Sl(!1),y=f=>{let t=f;return t=m?.(f)??f,c?eo?.[c]?.format(t):t},G=f=>{let t=f;return t=C?.(f)??t,c?eo?.[c]?.parse(t,F.current):t},b=f=>{if(!f||c!=="porcentagem"&&c!=="porcentagem0")return;f?.stopPropagation();let t=(f?.target).value;if(t){let I=String(t);if(I.length>0){let z=I.indexOf("%");z>-1&&(f.currentTarget.selectionEnd=z)}}},{field:d}=kl({control:n,name:e,rules:o,defaultValue:l,shouldUnregister:i}),w=wl({control:n,name:e}),L=R(w.errors,e);return oo(hl,{children:[oo("div",{style:{display:"flex"},children:[P&&W("div",{children:W(v,{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:S,defaultValue:l,value:y(d.value||(d.value!=0?"":d.value)),onChange:f=>{let t=G(f?.target?.value);d.onChange(t),u?.(t),F.current=f.target.value},error:!!L,...p,type:p.type==="password"?A?"text":"password":p.type,autoComplete:p.autoComplete||"off",slotProps:{input:{onKeyDown:b,inputRef:d.ref,endAdornment:p.type==="password"&&W(bl,{position:"start",onClick:()=>r(!A),style:{cursor:"pointer"},children:W(Ze,{icon:A?Vl:Cl,size:"24px",removeMargin:!0})}),...p.InputProps}}},e),W(k,{name:e,disableIcon:a,control:n})]})},Al=Ll;import{Stack as Ml,TextField as Ol}from"@mui/material";import{AdapterDayjs as $l}from"@mui/x-date-pickers/AdapterDayjs";import{LocalizationProvider as Nl}from"@mui/x-date-pickers/LocalizationProvider";import{TimePicker as Gl}from"@mui/x-date-pickers/TimePicker";import{ptBR as zl}from"@mui/x-date-pickers/locales/ptBR";import{composeValidators as ql,time as ro}from"@s_mart/rules";import _l from"dayjs/locale/pt-br";import{memo as Ul}from"react";import{useController as Hl,useFormContext as Kl,useFormState as Wl}from"react-hook-form";import{styled as 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 de,jsxs as Jl}from"react/jsx-runtime";var Yl=({rules:e,defaultValue:o,shouldUnregister:l,name:i,control:s,required:P,label:g,timePickerProps:c,placeholder:S,disabled:x,disableIconError:C,...m})=>{let u=Kl()?.control,a=s??u;if(!a)throw new T("TimePicker");let p=Wl({control:a,name:i}),V=R(p.errors,i),n=c?.format||"HH:mm",F=e?ql([ro(n),e]):ro(n),{field:A}=Hl({control:a,name:i,rules:F,defaultValue:o,shouldUnregister:l});return de(Nl,{dateAdapter:$l,adapterLocale:_l,localeText:zl.components.MuiLocalizationProvider.defaultProps.localeText,children:Jl(Ml,{children:[g&&de(v,{label:g,required:P}),de(Gl,{ampm:!1,format:n,value:A.value??null,disabled:x,...c,onChange:(r,y)=>{A.onChange(r,y),c?.onChange?.(r,y)},slots:{textField:Ol,openPickerButton:r=>de(to,{...r,size:m.size})},slotProps:{textField:r=>({variant:"outlined",...r,error:!!V,...m,inputProps:{...r.inputProps,placeholder:S||r.inputProps?.placeholder},InputProps:{...r.InputProps,inputRef:y=>{A.ref(y),typeof r.inputRef=="function"&&r.inputRef(y)}}})}},i),de(k,{name:i,disableIcon:C,control:a})]})})},jl=Ul(Yl);export{Vo as Autocomplete,wo as Checkbox,Wo as Creatable,yt as CreatableV2,Et as DatePicker,k as FieldError,j as FieldInfo,v as FieldLabel,Ht as Form,Ve as FormProvider,lr as RadioButton,Qt as RadioGroup,Fr as Searchable,Tr as SearchableV2,Gr as Select,tl as SelectV2,dl as Slider,yl as Switch,Al as TextField,jl as TimePicker,Ce as useForm};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@s_mart/form",
|
|
3
|
-
"version": "9.2.0-beta.
|
|
3
|
+
"version": "9.2.0-beta.5",
|
|
4
4
|
"main": "./dist/index.mjs",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.mts",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"react-hook-form": "^7.51.0",
|
|
33
33
|
"typescript": ">=5.4.2",
|
|
34
34
|
"zod": "^3.22.4",
|
|
35
|
-
"@s_mart/core": "9.1.5-beta.
|
|
35
|
+
"@s_mart/core": "9.1.5-beta.3",
|
|
36
36
|
"@s_mart/masks": "5.2.0",
|
|
37
37
|
"@s_mart/rules": "5.1.2-beta.0",
|
|
38
38
|
"@s_mart/tokens": "5.1.1",
|
|
@@ -50,7 +50,7 @@
|
|
|
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.
|
|
53
|
+
"@s_mart/core": "9.1.5-beta.3",
|
|
54
54
|
"@s_mart/masks": "5.2.0",
|
|
55
55
|
"@s_mart/rules": "5.1.2-beta.0",
|
|
56
56
|
"@s_mart/tokens": "5.1.1",
|