@s_mart/form 9.2.0-beta.9 → 10.0.0-beta.11
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 +18 -319
- package/dist/index.mjs +17 -70
- package/package.json +12 -12
package/dist/index.d.mts
CHANGED
|
@@ -1,47 +1,10 @@
|
|
|
1
|
-
import * as react from 'react';
|
|
2
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
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
2
|
import * as react_hook_form from 'react-hook-form';
|
|
5
|
-
import {
|
|
3
|
+
import { FieldValues, FieldPath, UseControllerProps, FieldPathValue, Control, UseFormReturn, FormProviderProps, UseFormProps } from 'react-hook-form';
|
|
4
|
+
import { CheckboxProps as CheckboxProps$1, AutocompleteProps, TextFieldProps as TextFieldProps$1, AutocompleteValue, AutocompleteFreeSoloValueMapping, RadioGroupProps as RadioGroupProps$1, RadioProps as RadioProps$1, SelectProps, SliderProps as SliderProps$1, SwitchProps as SwitchProps$1 } from '@mui/material';
|
|
6
5
|
import { DatePickerProps as DatePickerProps$1, TimePickerProps as TimePickerProps$1 } from '@mui/x-date-pickers';
|
|
7
6
|
import { z } from 'zod';
|
|
8
|
-
|
|
9
|
-
type AutoCompleteOption = {
|
|
10
|
-
key?: string | number;
|
|
11
|
-
label: string;
|
|
12
|
-
value: string | number | readonly string[] | undefined;
|
|
13
|
-
afterLabel?: string | React.ReactNode;
|
|
14
|
-
};
|
|
15
|
-
type AutocompleteProps<ValueType = any> = Omit<UseControllerProps, 'control'> & Omit<AutocompleteProps$1<ValueType, any, any, any>, 'renderInput' | 'size' | 'onInputChange' | 'onChange' | 'options'> & {
|
|
16
|
-
/**
|
|
17
|
-
* Opções do autocomplete
|
|
18
|
-
* @default []
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* [
|
|
22
|
-
* { label: 'Opção 1', value: '1' },
|
|
23
|
-
* ]
|
|
24
|
-
*
|
|
25
|
-
* @type {AutoCompleteOption[]}
|
|
26
|
-
* @memberof AutocompleteProps
|
|
27
|
-
*/
|
|
28
|
-
options: AutoCompleteOption[];
|
|
29
|
-
label?: React.ReactNode;
|
|
30
|
-
required?: boolean;
|
|
31
|
-
onInputChange?: (value: string, values: FieldValues) => void;
|
|
32
|
-
onChange?: (value: any, values: FieldValues) => void;
|
|
33
|
-
/**
|
|
34
|
-
* Desabilita o ícone de erro da validação do campo.
|
|
35
|
-
* @default false
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* <TextField disableIconError />
|
|
39
|
-
*/
|
|
40
|
-
disableIconError?: boolean;
|
|
41
|
-
placeholder?: string;
|
|
42
|
-
};
|
|
43
|
-
|
|
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>;
|
|
7
|
+
import * as react from 'react';
|
|
45
8
|
|
|
46
9
|
type CheckboxProps<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = CheckboxProps$1 & UseControllerProps<TFieldValues, TFieldName> & {
|
|
47
10
|
/**
|
|
@@ -70,121 +33,13 @@ type CheckboxProps<TFieldValues extends FieldValues = FieldValues, TFieldName ex
|
|
|
70
33
|
disableIconError?: boolean;
|
|
71
34
|
};
|
|
72
35
|
|
|
73
|
-
declare const
|
|
74
|
-
|
|
75
|
-
type ControllerCreatable = Omit<ControllerProps, 'render' | 'control'>;
|
|
76
|
-
/**
|
|
77
|
-
* @deprecated usar CreatableV2
|
|
78
|
-
*/
|
|
79
|
-
type CreatableOption = {
|
|
80
|
-
key?: string | number;
|
|
81
|
-
label: string;
|
|
82
|
-
value?: string | number | readonly string[] | undefined;
|
|
83
|
-
afterLabel?: string | React.ReactNode;
|
|
84
|
-
} | string;
|
|
85
|
-
/**
|
|
86
|
-
* @deprecated usar CreatableV2
|
|
87
|
-
*/
|
|
88
|
-
type CreatableProps = Omit<AutocompleteProps$1<CreatableOption, true, true, true>, 'renderInput' | 'size' | 'onInputChange' | 'onChange'> & ControllerCreatable & {
|
|
89
|
-
/**
|
|
90
|
-
* Opções do autocomplete
|
|
91
|
-
* @default []
|
|
92
|
-
*
|
|
93
|
-
* @example
|
|
94
|
-
* [
|
|
95
|
-
* { label: 'Opção 1', value: '1' },
|
|
96
|
-
* ]
|
|
97
|
-
*
|
|
98
|
-
* @type {CreatableOption[]}
|
|
99
|
-
* @memberof CreatableProps
|
|
100
|
-
*/
|
|
101
|
-
options: CreatableOption[];
|
|
102
|
-
/**
|
|
103
|
-
* Props do textField que é renderizado dentro do autocomplete
|
|
104
|
-
* @default {}
|
|
105
|
-
* @type {TextFieldProps}
|
|
106
|
-
* @memberof CreatableProps
|
|
107
|
-
*/
|
|
108
|
-
textFieldProps?: TextFieldProps$1;
|
|
109
|
-
/**
|
|
110
|
-
* Label do autocomplete
|
|
111
|
-
* @default ''
|
|
112
|
-
* @type {string}
|
|
113
|
-
* @memberof CreatableProps
|
|
114
|
-
*/
|
|
115
|
-
label?: React.ReactNode;
|
|
116
|
-
/**
|
|
117
|
-
* Adiciona um * ao label do autocomplete para indicar que o campo é obrigatório
|
|
118
|
-
* @default false
|
|
119
|
-
* @type {boolean}
|
|
120
|
-
* @memberof CreatableProps
|
|
121
|
-
*/
|
|
122
|
-
required?: boolean;
|
|
123
|
-
/**
|
|
124
|
-
* Função que será executada quando o usuário clicar no botão de criar uma nova opção
|
|
125
|
-
* @default () => {}
|
|
126
|
-
* @type {(value: string) => void}
|
|
127
|
-
* @memberof CreatableProps
|
|
128
|
-
*/
|
|
129
|
-
onCreateOption?: (value: string | Record<string, unknown>) => void;
|
|
130
|
-
/**
|
|
131
|
-
* Quando true, o botão de criar uma nova opção externo não será renderizado
|
|
132
|
-
* @default false
|
|
133
|
-
* @type {boolean}
|
|
134
|
-
* @memberof CreatableProps
|
|
135
|
-
*/
|
|
136
|
-
hideAddButton?: boolean;
|
|
137
|
-
/**
|
|
138
|
-
*
|
|
139
|
-
* @default false
|
|
140
|
-
* @type {boolean}
|
|
141
|
-
* @memberof CreatableProps
|
|
142
|
-
*/
|
|
143
|
-
editable?: boolean;
|
|
144
|
-
/**
|
|
145
|
-
* Função que será executada quando o usuário clicar no botão de editar uma opção
|
|
146
|
-
* @default () => {}
|
|
147
|
-
* @type {(value) => void}
|
|
148
|
-
* @memberof CreatableProps
|
|
149
|
-
*/
|
|
150
|
-
onEditOption?: (value: any) => void;
|
|
151
|
-
/**
|
|
152
|
-
* Componente que renderiza no footer do creatable (opcional)
|
|
153
|
-
*
|
|
154
|
-
* @example
|
|
155
|
-
* footer: (
|
|
156
|
-
* <Button onClick={handleClick}>Mostrar mais...</Button>
|
|
157
|
-
* )
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*/
|
|
161
|
-
footer?: React.ReactNode;
|
|
162
|
-
/**
|
|
163
|
-
* É o conteúdo passado para a tooltip que renderizará ao lado da label do campo,
|
|
164
|
-
* montada à tela como um ícone de informação.
|
|
165
|
-
*/
|
|
166
|
-
info?: React.ReactNode;
|
|
167
|
-
onInputChange?: (value: string, values: FieldValues) => void;
|
|
168
|
-
onChange?: (value: any, values: FieldValues) => void;
|
|
169
|
-
/**
|
|
170
|
-
* Desabilita o ícone de erro da validação do campo.
|
|
171
|
-
* @default false
|
|
172
|
-
*
|
|
173
|
-
* @example
|
|
174
|
-
* <TextField disableIconError />
|
|
175
|
-
*/
|
|
176
|
-
disableIconError?: boolean;
|
|
177
|
-
placeholder?: string;
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* @deprecated usar CreatableV2
|
|
182
|
-
*/
|
|
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>;
|
|
36
|
+
declare const _default$7: <TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ name, rules, defaultValue, shouldUnregister, control: controlFromProps, label, labelPlacement, required, disableIconError, onChange: onChangeProp, ...rest }: CheckboxProps<TFieldValues, TFieldName>) => react_jsx_runtime.JSX.Element;
|
|
184
37
|
|
|
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
|
|
38
|
+
type CreatableV2Props<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, FieldValue = FieldPathValue<TFieldValues, TFieldName>, Multiple extends boolean | undefined = undefined, DisableClearable extends boolean | undefined = undefined, FreeSolo extends boolean | undefined = undefined> = Omit<AutocompleteProps<FieldValue, Multiple, DisableClearable, FreeSolo>, 'renderInput' | 'options' | 'size' | 'onInputChange' | 'onChange' | 'getOptionLabel' | 'getOptionKey' | 'defaultValue' | 'value'> & UseControllerProps<TFieldValues, TFieldName> & {
|
|
186
39
|
options: FieldValue[];
|
|
187
|
-
|
|
40
|
+
slotProps?: AutocompleteProps<FieldValue, Multiple, DisableClearable, FreeSolo>['slotProps'] & {
|
|
41
|
+
textField: Omit<TextFieldProps$1<'outlined'>, 'variant'>;
|
|
42
|
+
};
|
|
188
43
|
label?: React.ReactNode;
|
|
189
44
|
required?: boolean;
|
|
190
45
|
/**
|
|
@@ -250,7 +105,7 @@ type CreatableV2Props<TFieldValues extends FieldValues = FieldValues, TFieldName
|
|
|
250
105
|
};
|
|
251
106
|
|
|
252
107
|
declare function CreatableV2<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, FieldValue = FieldPathValue<TFieldValues, TFieldName>, Multiple extends boolean | undefined = undefined, DisableClearable extends boolean | undefined = undefined, FreeSolo extends boolean | undefined = undefined>(props: CreatableV2Props<TFieldValues, TFieldName, FieldValue, Multiple, DisableClearable, FreeSolo>): react_jsx_runtime.JSX.Element;
|
|
253
|
-
declare const _default$
|
|
108
|
+
declare const _default$6: typeof CreatableV2;
|
|
254
109
|
|
|
255
110
|
type DatePickerProps<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = UseControllerProps<TFieldValues, TFieldName> & Pick<TextFieldProps$1, 'label' | 'error' | 'helperText' | 'size' | 'fullWidth' | 'variant' | 'autoFocus' | 'placeholder'> & {
|
|
256
111
|
datePickerProps?: Partial<DatePickerProps$1<any>>;
|
|
@@ -276,7 +131,7 @@ type DatePickerProps<TFieldValues extends FieldValues = FieldValues, TFieldName
|
|
|
276
131
|
disableIconError?: boolean;
|
|
277
132
|
};
|
|
278
133
|
|
|
279
|
-
declare const _default$
|
|
134
|
+
declare const _default$5: <TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ rules, name, defaultValue, shouldUnregister, control: controlFromProps, datePickerProps, label, required, placeholder, disabled, disableIconError, ...rest }: DatePickerProps<TFieldValues, TFieldName>) => react_jsx_runtime.JSX.Element;
|
|
280
135
|
|
|
281
136
|
type FieldLabelProps = {
|
|
282
137
|
label: React.ReactNode;
|
|
@@ -425,82 +280,7 @@ type RadioProps = RadioProps$1 & {
|
|
|
425
280
|
|
|
426
281
|
declare const RadioButton: ({ label, labelPlacement, ...rest }: RadioProps) => react_jsx_runtime.JSX.Element;
|
|
427
282
|
|
|
428
|
-
type
|
|
429
|
-
/**
|
|
430
|
-
* @deprecated usar SearchableV2
|
|
431
|
-
*/
|
|
432
|
-
type SearchableOption = {
|
|
433
|
-
key?: string | number;
|
|
434
|
-
label: string;
|
|
435
|
-
value: string | number | readonly string[] | undefined;
|
|
436
|
-
afterLabel?: string | React.ReactNode;
|
|
437
|
-
} | string;
|
|
438
|
-
/**
|
|
439
|
-
* @deprecated usar SearchableV2
|
|
440
|
-
*/
|
|
441
|
-
type SearchableProps = Omit<AutocompleteProps$1<SearchableOption, true, true, true>, 'renderInput' | 'size' | 'onInputChange' | 'onChange'> & ControllerSearchable & {
|
|
442
|
-
/**
|
|
443
|
-
* Opções do autocomplete
|
|
444
|
-
* @default []
|
|
445
|
-
*
|
|
446
|
-
* @example
|
|
447
|
-
* [
|
|
448
|
-
* { label: 'Opção 1', value: '1' },
|
|
449
|
-
* ]
|
|
450
|
-
*
|
|
451
|
-
* @type {SearchableOption[]}
|
|
452
|
-
* @memberof SearchableProps
|
|
453
|
-
*/
|
|
454
|
-
options: SearchableOption[];
|
|
455
|
-
/**
|
|
456
|
-
* Props do textField que é renderizado dentro do autocomplete
|
|
457
|
-
* @default {}
|
|
458
|
-
* @type {TextFieldProps}
|
|
459
|
-
* @memberof SearchableProps
|
|
460
|
-
*/
|
|
461
|
-
textFieldProps?: TextFieldProps$1;
|
|
462
|
-
label?: React.ReactNode;
|
|
463
|
-
required?: boolean;
|
|
464
|
-
/**
|
|
465
|
-
* Texto que será exibido quando não houver opções para serem exibidas
|
|
466
|
-
* @default 'Nenhuma opção encontrada'
|
|
467
|
-
*/
|
|
468
|
-
noOptionsText?: string;
|
|
469
|
-
/**
|
|
470
|
-
* Componente que renderiza no footer do searchable (opcional)
|
|
471
|
-
*
|
|
472
|
-
* @example
|
|
473
|
-
* footer: (
|
|
474
|
-
* <Button onClick={handleClick}>Mostrar mais...</Button>
|
|
475
|
-
* )
|
|
476
|
-
*
|
|
477
|
-
*
|
|
478
|
-
*/
|
|
479
|
-
footer?: React.ReactNode;
|
|
480
|
-
/**
|
|
481
|
-
* É o conteúdo passado para a tooltip que renderizará ao lado da label do campo,
|
|
482
|
-
* montada à tela como um ícone de informação.
|
|
483
|
-
*/
|
|
484
|
-
info?: React.ReactNode;
|
|
485
|
-
onInputChange?: (value: string, values: FieldValues) => void;
|
|
486
|
-
onChange?: (value: any, values: FieldValues) => void;
|
|
487
|
-
/**
|
|
488
|
-
* Desabilita o ícone de erro da validação do campo.
|
|
489
|
-
* @default false
|
|
490
|
-
*
|
|
491
|
-
* @example
|
|
492
|
-
* <TextField disableIconError />
|
|
493
|
-
*/
|
|
494
|
-
disableIconError?: boolean;
|
|
495
|
-
placeholder?: string;
|
|
496
|
-
};
|
|
497
|
-
|
|
498
|
-
/**
|
|
499
|
-
* @deprecated usar SearchableV2
|
|
500
|
-
*/
|
|
501
|
-
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>;
|
|
502
|
-
|
|
503
|
-
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> & {
|
|
283
|
+
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<FieldValue, Multiple, DisableClearable, FreeSolo>, 'renderInput' | 'size' | 'options' | 'onInputChange' | 'onChange' | 'getOptionLabel' | 'getOptionKey' | 'defaultValue' | 'value'> & UseControllerProps<TFieldValues, TFieldName> & {
|
|
504
284
|
options: FieldValue[];
|
|
505
285
|
textFieldProps?: TextFieldProps$1;
|
|
506
286
|
label?: React.ReactNode;
|
|
@@ -542,93 +322,12 @@ type SearchableV2Props<TFieldValues extends FieldValues = FieldValues, TFieldNam
|
|
|
542
322
|
getOptionAfterLabel?: (option: FieldValue | AutocompleteFreeSoloValueMapping<FreeSolo>) => string | React.ReactNode;
|
|
543
323
|
};
|
|
544
324
|
|
|
545
|
-
declare const _default$
|
|
546
|
-
|
|
547
|
-
type ControllerSelect = Omit<ControllerProps, 'render' | 'control'>;
|
|
548
|
-
/**
|
|
549
|
-
* @deprecated
|
|
550
|
-
*/
|
|
551
|
-
type SelectOption = {
|
|
552
|
-
label: string;
|
|
553
|
-
value: string | number | readonly string[] | undefined;
|
|
554
|
-
afterLabel?: string | React.ReactNode;
|
|
555
|
-
};
|
|
556
|
-
/**
|
|
557
|
-
* @deprecated
|
|
558
|
-
*/
|
|
559
|
-
type FooterProps = {
|
|
560
|
-
closeSelect: () => void;
|
|
561
|
-
};
|
|
562
|
-
/**
|
|
563
|
-
* @deprecated
|
|
564
|
-
*/
|
|
565
|
-
type SelectProps = Omit<SelectProps$1, 'onChange'> & ControllerSelect & {
|
|
566
|
-
/**
|
|
567
|
-
* As opções que serão renderizadas no select
|
|
568
|
-
*
|
|
569
|
-
* @type {SelectOption[]}
|
|
570
|
-
*
|
|
571
|
-
* @example
|
|
572
|
-
* options: [
|
|
573
|
-
* { label: 'Option 1', value: 'option1' },
|
|
574
|
-
* { label: 'Option 2', value: 'option2' },
|
|
575
|
-
* ]
|
|
576
|
-
*/
|
|
577
|
-
options: SelectOption[];
|
|
578
|
-
onChange?: (value: any, values: FieldValues) => void;
|
|
579
|
-
/**
|
|
580
|
-
* Desabilita o onChange do select, para que o onChange do form não seja disparado
|
|
581
|
-
*
|
|
582
|
-
* @type {boolean}
|
|
583
|
-
* @default false
|
|
584
|
-
*
|
|
585
|
-
* @example
|
|
586
|
-
* <Select name="select" options={options} disableOnChangeForm />
|
|
587
|
-
*/
|
|
588
|
-
disableOnChangeForm?: boolean;
|
|
589
|
-
/**
|
|
590
|
-
* Função que renderiza o footer do select (opcional) - recebe como parâmetro a função closeSelect que fecha o select
|
|
591
|
-
* @param {FooterProps} props
|
|
592
|
-
*
|
|
593
|
-
* @example
|
|
594
|
-
* footer: ({ closeSelect }) => (
|
|
595
|
-
* <Button onClick={closeSelect}>Fechar</Button>
|
|
596
|
-
* )
|
|
597
|
-
*
|
|
598
|
-
*/
|
|
599
|
-
footer?: (props: FooterProps) => React.ReactNode;
|
|
600
|
-
/**
|
|
601
|
-
* É o conteúdo passado para a tooltip que renderizará ao lado da label do campo,
|
|
602
|
-
* montada à tela como um ícone de informação.
|
|
603
|
-
*/
|
|
604
|
-
info?: React.ReactNode;
|
|
605
|
-
/**
|
|
606
|
-
* Desabilita o ícone de erro da validação do campo.
|
|
607
|
-
* @default false
|
|
608
|
-
*
|
|
609
|
-
* @example
|
|
610
|
-
* <Select disableIconError />
|
|
611
|
-
*/
|
|
612
|
-
disableIconError?: boolean;
|
|
613
|
-
/**
|
|
614
|
-
* Habilita ícone no endAdornment para limpar o valor do campo.
|
|
615
|
-
* @default false
|
|
616
|
-
*
|
|
617
|
-
* @example
|
|
618
|
-
* <Select clearable />
|
|
619
|
-
*/
|
|
620
|
-
clearable?: boolean;
|
|
621
|
-
};
|
|
622
|
-
|
|
623
|
-
/**
|
|
624
|
-
* @deprecated usar SelectV2
|
|
625
|
-
*/
|
|
626
|
-
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>;
|
|
325
|
+
declare const _default$4: <TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, FieldValue = FieldPathValue<TFieldValues, TFieldName>, Multiple extends boolean | undefined = undefined, DisableClearable extends boolean | undefined = undefined, FreeSolo extends boolean | undefined = undefined, AutocompleteFieldValue extends AutocompleteValue<FieldValue, Multiple, DisableClearable, FreeSolo> = AutocompleteValue<FieldValue, Multiple, DisableClearable, FreeSolo>>(props: SearchableV2Props<TFieldValues, TFieldName, FieldValue, Multiple, DisableClearable, FreeSolo, AutocompleteFieldValue>) => react_jsx_runtime.JSX.Element;
|
|
627
326
|
|
|
628
327
|
type FooterPropsV2 = {
|
|
629
328
|
closeSelect: () => void;
|
|
630
329
|
};
|
|
631
|
-
type SelectV2Props<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, FieldValue extends FieldPathValue<TFieldValues, TFieldName> = FieldPathValue<TFieldValues, TFieldName>> = Omit<SelectProps
|
|
330
|
+
type SelectV2Props<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, FieldValue extends FieldPathValue<TFieldValues, TFieldName> = FieldPathValue<TFieldValues, TFieldName>> = Omit<SelectProps, 'onChange' | 'multiple' | 'defaultValue' | 'variant'> & UseControllerProps<TFieldValues, TFieldName> & {
|
|
632
331
|
variant?: 'filled' | 'outlined' | 'standard';
|
|
633
332
|
/**
|
|
634
333
|
* As opções que serão renderizadas no select
|
|
@@ -684,7 +383,7 @@ type SelectV2ReturnValueProps<TFieldValues extends FieldValues = FieldValues, TF
|
|
|
684
383
|
getOptionLabel: (option: FieldPathValue<TFieldValues, TFieldName>) => string;
|
|
685
384
|
};
|
|
686
385
|
|
|
687
|
-
declare const _default$
|
|
386
|
+
declare const _default$3: <TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>(props: SelectV2Props<TFieldValues, TFieldName>) => react_jsx_runtime.JSX.Element;
|
|
688
387
|
|
|
689
388
|
type SliderProps<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = SliderProps$1 & UseControllerProps<TFieldValues, TFieldName> & {
|
|
690
389
|
/**
|
|
@@ -734,7 +433,7 @@ type SwitchProps<TFieldValues extends FieldValues = Record<string, boolean>, TFi
|
|
|
734
433
|
disableIconError?: boolean;
|
|
735
434
|
};
|
|
736
435
|
|
|
737
|
-
declare const
|
|
436
|
+
declare const _default$2: <TFieldValues extends FieldValues = Record<string, boolean>, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ name, rules, defaultValue, shouldUnregister, control: controlFromProps, label, labelPlacement, disableIconError, onChange: onChangeProp, ...rest }: SwitchProps<TFieldValues, TFieldName>) => react_jsx_runtime.JSX.Element;
|
|
738
437
|
|
|
739
438
|
type Masks = 'cpf' | 'cnpj' | 'cpfCnpj' | 'cep' | 'telefone' | 'decimal' | 'decimal3' | 'decimal4' | 'decimal5' | 'porcentagem' | 'porcentagem0' | 'nome' | 'numero' | 'numeroPontuacao' | 'placa' | 'valor' | 'valor3' | 'valor4';
|
|
740
439
|
type TextFieldProps<TFieldValues extends FieldValues = Record<string, string>, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = TextFieldProps$1 & UseControllerProps<TFieldValues, TFieldName> & {
|
|
@@ -778,7 +477,7 @@ type TextFieldProps<TFieldValues extends FieldValues = Record<string, string>, T
|
|
|
778
477
|
disableIconError?: boolean;
|
|
779
478
|
};
|
|
780
479
|
|
|
781
|
-
declare const
|
|
480
|
+
declare const _default$1: <TFieldValues extends FieldValues = Record<string, string>, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ name, rules, defaultValue, shouldUnregister, control: controlFromProps, label, required, mask, variant, info, parse, format, onInputChange, disableIconError, ...rest }: TextFieldProps<TFieldValues, TFieldName>) => react_jsx_runtime.JSX.Element;
|
|
782
481
|
|
|
783
482
|
type TimePickerProps<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = UseControllerProps<TFieldValues, TFieldName> & Pick<TextFieldProps$1, 'label' | 'error' | 'helperText' | 'size' | 'fullWidth' | 'variant' | 'autoFocus' | 'placeholder'> & {
|
|
784
483
|
timePickerProps?: Partial<TimePickerProps$1<any>>;
|
|
@@ -804,6 +503,6 @@ type TimePickerProps<TFieldValues extends FieldValues = FieldValues, TFieldName
|
|
|
804
503
|
disableIconError?: boolean;
|
|
805
504
|
};
|
|
806
505
|
|
|
807
|
-
declare const _default:
|
|
506
|
+
declare const _default: <TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ rules, defaultValue, shouldUnregister, name, control: controlFromProps, required, label, timePickerProps, placeholder, disabled, disableIconError, ...rest }: TimePickerProps<TFieldValues, TFieldName>) => react_jsx_runtime.JSX.Element;
|
|
808
507
|
|
|
809
|
-
export {
|
|
508
|
+
export { _default$7 as Checkbox, type CheckboxProps, _default$6 as CreatableV2, type CreatableV2Props, _default$5 as DatePicker, type DatePickerProps, FieldError, type FieldErrorProps, FieldInfo, type FieldInfoProps, FieldLabel, type FieldLabelProps, type FooterPropsV2, Form, FormProvider, type IFormProps, type IFormProviderProps, type IUseFormProps, type Masks, RadioButton, RadioGroup, type RadioGroupProps, type RadioProps, _default$4 as SearchableV2, type SearchableV2Props, _default$3 as SelectV2, type SelectV2Props, type SelectV2ReturnValueProps, Slider, type SliderProps, _default$2 as Switch, type SwitchProps, _default$1 as TextField, type TextFieldProps, _default as TimePicker, type TimePickerProps, useForm };
|
package/dist/index.mjs
CHANGED
|
@@ -1,68 +1,15 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{useController as ze,useFormContext as qe}from"react-hook-form";import{Checkbox as Ge,FormControlLabel as Ue}from"@mui/material";import{Indicator as Ee}from"@s_mart/core";import{useFormState as De}from"react-hook-form";var R=(e,o)=>o.replace(/[[\]]/g,"").split(".").reduce((l,d)=>l?.[d],e);import{jsx as Be}from"react/jsx-runtime";var Me=({name:e,disableIcon:o,control:r})=>{let l=De({control:r,name:e}),d=R(l?.errors,e);return d?Be(Ee,{severity:"error",icon:o?!1:void 0,children:d?.message}):null},g=Me;import{Typography as me}from"@mui/material";import{toRem as Ae}from"@s_mart/utils";import{jsx as ue,jsxs as Oe}from"react/jsx-runtime";var Ne=({label:e,required:o,regular:r})=>Oe("span",{style:{display:"flex",alignItems:"center",gap:Ae(2)},children:[ue(me,{variant:"caption",style:{display:"flex",alignItems:"center"},sx:{fontWeight:r?400:700},children:e}),o&&ue(me,{variant:"caption",color:"error",sx:{fontWeight:900},children:"*"})]}),P=Ne;var x=class extends Error{constructor(o){super(`O componente ${o} precisa de um control para funcionar. Passe o control como prop ou coloque o componente dentro de um <Form />`),this.name="FormComponentPrecisaDeControl"}};import{memo as $e}from"react";var w=$e;import{jsx as Q,jsxs as Ke}from"react/jsx-runtime";var _e=({name:e,rules:o,defaultValue:r,shouldUnregister:l,control:d,label:u,labelPlacement:f,required:s,disableIconError:h,onChange:F,...C})=>{let m=qe()?.control,c=d??m;if(!c)throw new x("Checkbox");let{field:a}=ze({control:c,name:e,rules:o,defaultValue:r,shouldUnregister:l});return Ke("span",{children:[Q(Ue,{control:Q(Ge,{checked:!!a.value,value:a.value??"",defaultValue:a.value,onChange:(p,L)=>{a.onChange(p,L),F?.(p,L)},...C},e),label:Q(P,{label:u,required:s,regular:!0}),labelPlacement:f||"end"}),Q(g,{name:e,disableIcon:h,control:c})]})},He=w(_e);import{forwardRef as je,useCallback as eo,useState as oo}from"react";import{useController as to,useFormContext as ro,useFormState as lo}from"react-hook-form";import io from"lodash-es/isObject";import ao from"lodash-es/isEmpty";import no from"lodash-es/isEqual";import{Autocomplete as so,TextField as po,Divider as Fe,Button as mo}from"@mui/material";import{LIcon as re}from"@s_mart/core";import{linePlus as ye,linePen as uo}from"@s_mart/solid-icons";import{toRem as Pe}from"@s_mart/utils";import{css as We,styled as Ye}from"@mui/material";import{toRem as Z}from"@s_mart/utils";var fe=We`
|
|
2
2
|
display: flex;
|
|
3
3
|
align-items: center;
|
|
4
4
|
justify-content: center;
|
|
5
|
-
`,
|
|
6
|
-
.creatable,
|
|
7
|
-
.editable {
|
|
8
|
-
${Re}
|
|
9
|
-
|
|
10
|
-
.divider {
|
|
11
|
-
width: 1px;
|
|
12
|
-
height: ${me(20)};
|
|
13
|
-
background-color: ${e.palette.grey[400]};
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.button {
|
|
17
|
-
display: flex;
|
|
18
|
-
justify-content: center;
|
|
19
|
-
align-items: center;
|
|
20
|
-
color: ${e.palette.grey[600]};
|
|
21
|
-
border-radius: 50%;
|
|
22
|
-
|
|
23
|
-
margin: 0 ${me(6)};
|
|
24
|
-
width: ${me(28)};
|
|
25
|
-
height: ${me(28)};
|
|
26
|
-
|
|
27
|
-
&:hover {
|
|
28
|
-
cursor: pointer;
|
|
29
|
-
background-color: ${e.palette.grey[100]};
|
|
30
|
-
transition: background-color 0.2s ease-in-out;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
`,De=Ao("div")`
|
|
35
|
-
display: flex;
|
|
36
|
-
|
|
37
|
-
div.endAdornments {
|
|
38
|
-
position: absolute;
|
|
39
|
-
right: 0;
|
|
40
|
-
|
|
41
|
-
${Re}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.MuiAutocomplete-endAdornment {
|
|
45
|
-
position: relative;
|
|
46
|
-
right: 0;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.endAdornments > .MuiAutocomplete-endAdornment {
|
|
50
|
-
transform: translate(0, 0);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
${({hideAddButton:e,theme:o})=>!e&&Ro(o)}
|
|
54
|
-
`;import{Fragment as be,jsx as R,jsxs as H}from"react/jsx-runtime";import{createElement as Me}from"react";var Oe=Bo(({name:e,rules:o,defaultValue:l,shouldUnregister:i,label:s,required:P,options:g,editable:c,footer:S,onEditOption:x,onCreateOption:C,textFieldProps:m,hideAddButton:u,multiple:a,info:p,onChange:V,onInputChange:n,placeholder:F,disableIconError:A,...r})=>{let y=Mo();if(!y)throw new v("Creatable");let G=D(y.formState.errors,e),b=u||r.disabled,d=t=>{let I=0;return m?.InputProps||(I+=2.5),b||(I+=2.56,w(t)&&(I+=2.56)),!r.disableClearable&&!r.disabled&&(I+=1.3),I+"rem"},w=t=>r.disabled?!1:c&&Oo(t)&&!$o(t);console.warn=()=>{};let L=t=>{C?C(t):console.error("onCreateOption n\xE3o foi definido")},f=t=>{x?x(t):console.error("onEditOption n\xE3o foi definido")};return R(Eo,{control:y.control,name:e,rules:o,defaultValue:l,shouldUnregister:i,render:({field:{value:t,onChange:I,ref:z}})=>{let X=t?.label||t?.value||t;return H(ee,{sx:{display:"flex",flexDirection:"column"},children:[H("div",{style:{display:"flex"},children:[s&&R(ee,{item:!0,children:R(T,{label:s,required:P})}),p&&R(ee,{item:!0,children:R(zo,{title:p,placement:"top",children:R("div",{style:{width:"fit-content"},children:R(ue,{icon:Ko,color:"#757575"})})})})]}),R(De,{hideAddButton:b,children:R(No,{fullWidth:!0,onChange:(B,h)=>{I(h),V?.(h,y.getValues())},onInputChange:(B,h,ne)=>{ne==="input"&&setTimeout(()=>{n?.(h,y.getValues())},0)},slotProps:{...r.slotProps||{},paper:{...(r.slotProps||{}).paper||{},sx:{border:`1px solid ${Uo.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}},listbox:{component:Do(function(h,ne){return H(be,{children:[R("ul",{...h,ref:ne}),!!S&&R("div",{...h,children:H(be,{children:[R(ee,{sx:{px:2,py:1},children:R(qo,{})}),S]})},"creatable-footer")]})})}},options:g,value:t||(a?[]:null),multiple:a,readOnly:r.disabled,noOptionsText:b?void 0:H(_o,{sx:{justifyContent:"flex-start",padding:`${Ee(6)} ${Ee(-16)}`,margin:0},fullWidth:!0,onClick:()=>L(t),variant:"text",startIcon:R(ue,{icon:Be}),children:["Adicionar ",X&&`"${X}"`]}),isOptionEqualToValue:(B,h)=>h?typeof B=="string"&&typeof h=="string"?B===h:typeof B=="object"&&typeof h=="object"?typeof B.value=="object"&&typeof h.value=="object"&&B.key!==void 0&&h.key!==void 0?B.key===h.key:B.value===h.value:typeof B=="object"&&typeof h=="string":!1,renderOption:(B,h)=>typeof h=="object"?Me("li",{...B,key:h.key||h.value},H(ee,{container:!0,direction:"column",children:[R(ee,{item:!0,children:h.label}),h.afterLabel&&R(ee,{item:!0,children:h.afterLabel})]})):Me("li",{...B,key:h},h),...r,sx:{"& div.MuiInputBase-root":{paddingRight:`${d(t)} !important`},...r.sx},renderInput:B=>R(Go,{placeholder:F,...B,error:!!G,...m,slotProps:{input:{...B.InputProps,inputRef:z,endAdornment:H("div",{className:"endAdornments",children:[B.InputProps.endAdornment,!b&&H(be,{children:[w(t)?H("div",{className:"editable",children:[R("div",{className:"divider"}),R("div",{className:"button",onClick:()=>f(t),children:R(ue,{icon:Ho,size:"24px",removeMargin:!0})})]}):null,H("div",{className:"creatable",children:[R("div",{className:"divider"}),R("div",{className:"button",onClick:()=>L(t),children:R(ue,{icon:Be,size:"24px",removeMargin:!0})})]})]})]})}}})},e)}),R(k,{name:e,disableIcon:A,control:y.control})]})}})});Oe.displayName="Creatable";var Wo=Oe;import{forwardRef as ot,useCallback as tt,useState as rt}from"react";import{useController as lt,useFormContext as it,useFormState as nt}from"react-hook-form";import{isObject as at,isEmpty as dt,isEqual as st}from"lodash-es";import{Autocomplete as pt,TextField as mt,Divider as Ge,Button as ut}from"@mui/material";import{LIcon as Pe}from"@s_mart/core";import{colorPalette as ft}from"@s_mart/tokens";import{linePlus as ze,linePen as ct}from"@s_mart/solid-icons";import{toRem as qe}from"@s_mart/utils";import{css as Yo,styled as jo}from"@mui/material";import{toRem as fe}from"@s_mart/utils";import"@mui/system";var $e=Yo`
|
|
55
|
-
display: flex;
|
|
56
|
-
align-items: center;
|
|
57
|
-
justify-content: center;
|
|
58
|
-
`,Ne=jo("div")`
|
|
5
|
+
`,ce=Ye("div")`
|
|
59
6
|
display: flex;
|
|
60
7
|
|
|
61
8
|
div.endAdornments {
|
|
62
9
|
position: absolute;
|
|
63
10
|
right: 0;
|
|
64
11
|
|
|
65
|
-
${
|
|
12
|
+
${fe}
|
|
66
13
|
}
|
|
67
14
|
|
|
68
15
|
.MuiAutocomplete-endAdornment {
|
|
@@ -76,11 +23,11 @@ import{Autocomplete as Fo,Grid as se,TextField as yo}from"@mui/material";import{
|
|
|
76
23
|
|
|
77
24
|
.creatable,
|
|
78
25
|
.editable {
|
|
79
|
-
${
|
|
26
|
+
${fe}
|
|
80
27
|
|
|
81
28
|
.divider {
|
|
82
29
|
width: 1px;
|
|
83
|
-
height: ${
|
|
30
|
+
height: ${Z(20)};
|
|
84
31
|
background-color: ${({theme:e})=>e.palette.grey[400]};
|
|
85
32
|
}
|
|
86
33
|
|
|
@@ -91,9 +38,9 @@ import{Autocomplete as Fo,Grid as se,TextField as yo}from"@mui/material";import{
|
|
|
91
38
|
color: ${({theme:e})=>e.palette.grey[600]};
|
|
92
39
|
border-radius: 50%;
|
|
93
40
|
|
|
94
|
-
margin: 0 ${
|
|
95
|
-
width: ${
|
|
96
|
-
height: ${
|
|
41
|
+
margin: 0 ${Z(6)};
|
|
42
|
+
width: ${Z(28)};
|
|
43
|
+
height: ${Z(28)};
|
|
97
44
|
|
|
98
45
|
&:hover {
|
|
99
46
|
cursor: pointer;
|
|
@@ -102,22 +49,22 @@ import{Autocomplete as Fo,Grid as se,TextField as yo}from"@mui/material";import{
|
|
|
102
49
|
}
|
|
103
50
|
}
|
|
104
51
|
}
|
|
105
|
-
`;import{Tooltip as
|
|
52
|
+
`;import{Tooltip as Je}from"@mui/material";import{LIcon as Xe}from"@s_mart/core";import{lineInfoCircle as Qe}from"@s_mart/solid-icons";import{jsx as te}from"react/jsx-runtime";var Ze=({title:e})=>te(Je,{title:e,placement:"top",children:te("div",{style:{width:"fit-content"},children:te(Xe,{icon:Qe,color:"#757575"})})}),_=Ze;import{Fragment as le,jsx as v,jsxs as B}from"react/jsx-runtime";import{createElement as Fo}from"react";function fo(e){let{name:o,rules:r,defaultValue:l,shouldUnregister:d,control:u,label:f,required:s,options:h,footer:F,showCreatableButton:C=!0,showEditableButton:m,onEditOption:c,onCreateOption:a,getOptionKey:p,getOptionLabel:L,getOptionAfterLabel:T,multiple:E,info:S,noOptionsText:i,onChange:V,onInputChange:N,placeholder:O,...y}=e,[U,D]=oo(""),n=ro()?.control,t=u??n;if(!t)throw new x("CreatableV2");let I=lo({control:t,name:o}),$=R(I.errors,o),J=!C||y.disabled,{field:Y}=to({name:o,control:t,rules:r,defaultValue:l,shouldUnregister:d}),Ie=k=>{let b=0;return e.slotProps?.textField?.slotProps?.input||(b+=2.5),J||(b+=2.56,se(k)&&(b+=2.56)),!y.disableClearable&&!y.disabled&&(b+=1.3),`${b}rem`},se=k=>y.disabled?!1:m&&io(k)&&!ao(k),we=()=>y.disabled?!1:C,pe=eo(()=>{typeof a<"u"&&(a(U),D(""))},[U,a]),Le=()=>{c?.(Y.value)};return B("div",{style:{display:"flex",flexDirection:"column"},children:[B("div",{style:{display:"flex"},children:[f&&v(P,{label:f,required:s}),S&&v(_,{title:S})]}),v(ce,{children:v(so,{fullWidth:!0,onChange:(k,b)=>{D(""),Y.onChange(b),V?.(b)},onInputChange:(k,b,H)=>{H==="input"&&(D(b),N?.(b))},slotProps:{...y.slotProps,listbox:{component:je(function(b,H){return B(le,{children:[v("ul",{...b,ref:H}),typeof F<"u"?B("div",{...b,children:[v("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:v(Fe,{})}),F()]},"creatable-footer"):null]})})}},value:Y.value,options:h,multiple:E,readOnly:y.disabled,noOptionsText:B(le,{children:[i||"Nenhuma op\xE7\xE3o encontrada",!J&&B(mo,{sx:{justifyContent:"flex-start",padding:`${Pe(6)} ${Pe(-16)}`,margin:0},fullWidth:!0,onClick:pe,variant:"text",startIcon:v(re,{icon:ye}),children:["Adicionar ",`"${U}"`]}),typeof F<"u"&&B(le,{children:[v("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:v(Fe,{})}),F()]})]}),isOptionEqualToValue:(k,b)=>no(k,b),getOptionLabel:L,getOptionKey:p,renderOption:typeof T=="function"?(k,b)=>{let H=T(b),Re=p(b);return Fo("li",{...k,key:Re},B("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[v("span",{children:L(b)}),typeof H=="string"?v("span",{children:H}):H]}))}:void 0,...y,sx:{"& div.MuiInputBase-root":{paddingRight:`${Ie(Y.value)} !important`},...y.sx},onBlur:k=>{y?.onBlur?.(k),D("")},renderInput:k=>v(po,{placeholder:O,...k,error:!!$,...e.slotProps?.textField,slotProps:{input:{...k.InputProps,...e.slotProps?.textField?.slotProps?.input,inputRef:Y.ref,endAdornment:B("div",{className:"endAdornments",children:[k.InputProps.endAdornment,e.slotProps?.textField?.slotProps?.input?.endAdornment??null,se(Y.value)?B("div",{className:"editable",children:[v("div",{className:"divider"}),v("div",{className:"button",onKeyUp:Le,children:v(re,{icon:uo,size:"24px",removeMargin:!0})})]}):null,we()&&B("div",{className:"creatable",children:[v("div",{className:"divider"}),v("div",{className:"button",onKeyUp:pe,children:v(re,{icon:ye,size:"24px",removeMargin:!0})})]})]})}}})},o)}),v(g,{name:o,control:t})]})}var co=w(fo);import{Stack as ho,TextField as To}from"@mui/material";import{AdapterDayjs as bo}from"@mui/x-date-pickers/AdapterDayjs";import{DatePicker as go}from"@mui/x-date-pickers/DatePicker";import{LocalizationProvider as vo}from"@mui/x-date-pickers/LocalizationProvider";import{ptBR as Co}from"@mui/x-date-pickers/locales/ptBR";import{composeValidators as So,date as Ve}from"@s_mart/rules";import ko from"dayjs/locale/pt-br";import{useController as Io,useFormContext as wo,useFormState as Lo}from"react-hook-form";import{IconButton as yo,styled as Po}from"@mui/material";import{toRem as z}from"@s_mart/utils";var xo=e=>{switch(e){case"small":return z(16);case"large":return z(24);default:return z(20)}},Vo=e=>{switch(e){case"small":return`${z(2)} ${z(8)}`;case"large":return`${z(10)}`;default:return`${z(6)} ${z(8)}`}},xe=Po(yo)`
|
|
106
53
|
margin: 0px;
|
|
107
54
|
|
|
108
|
-
padding: ${({size:e})=>
|
|
109
|
-
border-radius: 0 ${
|
|
55
|
+
padding: ${({size:e})=>Vo(e)};
|
|
56
|
+
border-radius: 0 ${z(4)} ${z(4)} 0;
|
|
110
57
|
|
|
111
58
|
svg {
|
|
112
|
-
width: ${({size:e})=>
|
|
59
|
+
width: ${({size:e})=>xo(e)} !important;
|
|
113
60
|
}
|
|
114
|
-
`;import{jsx as ce,jsxs as Ot}from"react/jsx-runtime";import{createElement as Mt}from"react";var Bt=({rules:e,name:o,defaultValue:l,shouldUnregister:i,control:s,datePickerProps:P,label:g,required:c,placeholder:S,disabled:x,disableIconError:C,...m})=>{let u=Rt()?.control,a=s??u;if(!a)throw new v("DatePicker");let p=Dt({control:a,name:o}),V=D(p.errors,o),n=P?.format||"DD/MM/YYYY",F=e?It([Ue(n),e]):Ue(n),{field:A}=At({control:a,name:o,rules:F,defaultValue:l,shouldUnregister:i});return ce(St,{dateAdapter:Tt,adapterLocale:wt,localeText:kt.components.MuiLocalizationProvider.defaultProps.localeText,children:Ot(Vt,{children:[g&&ce(T,{label:g,required:c}),Mt(vt,{...P,key:o,value:A.value??null,format:n,onChange:(r,y)=>{A.onChange(r,y),P?.onChange?.(r,y)},disabled:x,slots:{textField:Ct,openPickerButton:r=>ce(_e,{...r,size:m.size})},slotProps:{textField:r=>({variant:"outlined",...r,error:!!V,...m,inputProps:{...r.inputProps,placeholder:S||r.inputProps?.placeholder},InputProps:{...r.InputProps,inputRef:y=>{A.ref(y),typeof r.inputRef=="function"&&r.inputRef(y)}}})}}),ce(k,{name:o,disableIcon:C,control:a})]})})},Et=Lt(Bt);import{FormProvider as $t}from"react-hook-form";import{jsx as He}from"react/jsx-runtime";function Nt({children:e,style:o,onSubmit:l,...i}){return He($t,{...i,children:He("form",{onSubmit:s=>{s.preventDefault(),s.stopPropagation(),l(s)},style:o,children:e})})}var Ve=Nt;import{useEffect as Gt}from"react";import{useForm as zt}from"react-hook-form";import{zodResolver as qt}from"@hookform/resolvers/zod";var _t=({disableDefaultValuesUpdate:e,onSubmit:o,...l})=>{let i=zt({...l,resolver:l.schema&&qt(l.schema)});return Gt(()=>{e||i.reset(l.defaultValues)},[l.defaultValues,i.reset]),{...i,onSubmit:i.handleSubmit(s=>o(s,i))}},Ce=_t;import{jsx as Kt}from"react/jsx-runtime";function Ut({children:e,style:o,...l}){let i=Ce(l);return Kt(Ve,{...i,style:o,children:typeof e=="function"?e(i):e})}var Ht=Ut;import{RadioGroup as Wt,Stack as Yt}from"@mui/material";import{useController as jt,useFormContext as Jt}from"react-hook-form";import{jsx as Te,jsxs as Zt}from"react/jsx-runtime";var Xt=({name:e,rules:o,defaultValue:l,shouldUnregister:i,control:s,label:P,required:g,children:c,orientation:S="row",disableIconError:x,...C})=>{let m=Jt()?.control,u=s??m;if(!u)throw new v("RadioGroup");let{field:a}=jt({control:u,name:e,rules:o,defaultValue:l,shouldUnregister:i});return Zt(Yt,{children:[P&&Te(T,{label:P,required:g}),Te(Wt,{value:a.value||"",name:e,...C,onChange:p=>{C?.onChange?.(p,p.target?.value),a.onChange(p)},style:{display:"flex",flexDirection:S},children:c},e),Te(k,{name:e,disableIcon:x,control:u})]})},Qt=Xt;import{FormControlLabel as er,Grid2 as or,Radio as tr}from"@mui/material";import{jsx as Fe}from"react/jsx-runtime";var rr=({label:e,labelPlacement:o,...l})=>Fe(or,{sx:{display:"flex",flexDirection:"column"},children:Fe(er,{control:Fe(tr,{...l}),label:Fe(T,{label:e}),labelPlacement:o||"end"})}),lr=rr;import{Autocomplete as ir,Divider as Ke,Grid as J,TextField as nr,Tooltip as ar}from"@mui/material";import{LIcon as dr}from"@s_mart/core";import{lineInfoCircle as sr}from"@s_mart/solid-icons";import{colorPalette as pr}from"@s_mart/tokens";import{forwardRef as mr,memo as ur}from"react";import{Controller as fr,useFormContext as cr}from"react-hook-form";import{Fragment as ye,jsx as O,jsxs as oe}from"react/jsx-runtime";import{createElement as We}from"react";var Ye=ur(({name:e,rules:o,defaultValue:l,shouldUnregister:i,label:s,required:P,options:g,textFieldProps:c,noOptionsText:S,footer:x,multiple:C,info:m,placeholder:u,onChange:a,onInputChange:p,disableIconError:V,...n})=>{let F=cr();if(!F)throw new v("Searchable");let A=D(F.formState.errors,e);return O(fr,{control:F.control,name:e,rules:o,defaultValue:l,shouldUnregister:i,render:({field:{onChange:r,value:y,ref:G}})=>oe(J,{sx:{display:"flex",flexDirection:"column"},children:[oe("div",{style:{display:"flex"},children:[s&&O(J,{item:!0,children:O(T,{label:s,required:P})}),m&&O(J,{item:!0,children:O(ar,{title:m,placement:"top",children:O("div",{style:{width:"fit-content"},children:O(dr,{icon:sr,color:"#757575"})})})})]}),O(ir,{onChange:(b,d)=>{r(d),a?.(d,F.getValues())},onInputChange:(b,d,w)=>{w==="input"&&setTimeout(()=>{p?.(d,F.getValues())},0)},slotProps:{...n.slotProps||{},paper:{...(n.slotProps||{}).paper||{},sx:{border:`1px solid ${pr.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}},listbox:{component:mr(function(d,w){return oe(ye,{children:[O("ul",{...d,ref:w}),!!x&&O("div",{...d,children:oe(ye,{children:[O(J,{sx:{px:2,py:1},children:O(Ke,{})}),x]})},"searchable-footer")]})})}},value:y||(C?[]:null),options:g,multiple:C,readOnly:n.disabled,noOptionsText:oe(ye,{children:[S||"Nenhum resultado encontrado",x?oe(ye,{children:[O(J,{sx:{py:1},children:O(Ke,{})}),x]}):null]}),isOptionEqualToValue:(b,d)=>typeof b=="string"&&typeof d=="string"?b===d:typeof b=="object"&&typeof d=="object"?typeof b.value=="object"&&typeof d.value=="object"&&b.key!==void 0&&d.key!==void 0?b.key===d.key:b.value===d.value:!1,renderOption:(b,d)=>typeof d=="object"?We("li",{...b,key:d.key||d.value},oe(J,{container:!0,direction:"column",children:[O(J,{item:!0,children:d.label}),d.afterLabel&&O(J,{item:!0,children:d.afterLabel})]})):We("li",{...b,key:d},d),...n,renderInput:b=>O(nr,{error:!!A,placeholder:u,...b,...c,inputRef:G})},e),O(k,{name:e,disableIcon:V,control:F.control})]})})});Ye.displayName="Searchable";var Fr=Ye;import{Autocomplete as yr,Divider as je,TextField as xr}from"@mui/material";import{colorPalette as br}from"@s_mart/tokens";import{isEqual as hr}from"lodash-es";import{forwardRef as Pr}from"react";import{useController as gr,useFormContext as Vr,useFormState as Cr}from"react-hook-form";import{Fragment as ve,jsx as q,jsxs as te}from"react/jsx-runtime";import{createElement as Sr}from"react";var Tr=e=>{let{name:o,rules:l,defaultValue:i,shouldUnregister:s,control:P,label:g,required:c,options:S,textFieldProps:x,noOptionsText:C,footer:m,multiple:u,info:a,placeholder:p,onChange:V,onInputChange:n,getOptionAfterLabel:F,getOptionLabel:A,getOptionKey:r,...y}=e,G=Vr()?.control,b=P??G;if(!b)throw new v("SearchableV2");let d=Cr({control:b,name:o}),w=D(d.errors,o),{field:L}=gr({name:o,control:b,rules:l,defaultValue:i,shouldUnregister:s});return te("div",{style:{display:"flex",flexDirection:"column"},children:[te("div",{style:{display:"flex"},children:[g&&q(T,{label:g,required:c}),a&&q(j,{title:a})]}),q(yr,{onChange:(f,t)=>{L.onChange(t),V?.(t)},onInputChange:(f,t,I)=>{I==="input"&&n?.(t)},value:L.value,options:S,multiple:u,readOnly:y.disabled,slotProps:{...y.slotProps,paper:{...y.slotProps?.paper,sx:{border:`1px solid ${br.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}},listbox:{component:Pr(function(t,I){return te(ve,{children:[q("ul",{...t,ref:I}),typeof m<"u"?te("div",{...t,children:[q("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:q(je,{})}),m()]},"searchable-footer"):null]})})}},noOptionsText:te(ve,{children:[C||"Nenhuma op\xE7\xE3o encontrada",typeof m<"u"?te(ve,{children:[q("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:q(je,{})}),m()]}):null]}),isOptionEqualToValue:(f,t)=>hr(f,t),getOptionLabel:A,getOptionKey:r,renderOption:typeof F=="function"?(f,t)=>{let I=F(t),z=r(t);return Sr("li",{...f,key:z},te("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[q("span",{children:A(t)}),typeof I=="string"?q("span",{children:I}):I]}))}:void 0,...y,renderInput:f=>q(xr,{error:!!w,placeholder:p,...f,...x,inputRef:L.ref})},o),q(k,{name:o,control:b})]})},vr=ie(Tr);import{Divider as kr,Grid as re,MenuItem as Ir,Select as wr,Tooltip as Lr,useTheme as Ar}from"@mui/material";import{IconButton as Rr,LIcon as Je}from"@s_mart/core";import{lineTimes as Dr}from"@s_mart/regular-icons";import{lineInfoCircle as Br}from"@s_mart/solid-icons";import{colorPalette as Er}from"@s_mart/tokens";import{memo as Mr,useState as Or}from"react";import{Controller as $r,useFormContext as Nr}from"react-hook-form";import{Fragment as zr,jsx as N,jsxs as ae}from"react/jsx-runtime";var Xe=Mr(({name:e,rules:o,defaultValue:l,shouldUnregister:i,label:s,required:P,options:g,placeholder:c,clearable:S,disableOnChangeForm:x=!1,multiple:C,info:m,footer:u,onChange:a,disableIconError:p,variant:V="outlined",...n})=>{let F=Nr(),{palette:A}=Ar(),[r,y]=Or(!1);if(!F)throw new v("Select");let G=D(F.formState.errors,e);return N($r,{control:F.control,name:e,rules:o,defaultValue:l,shouldUnregister:i,render:({field:{value:b,onChange:d,ref:w}})=>ae(re,{sx:{display:"flex",flexDirection:"column"},children:[ae("div",{style:{display:"flex"},children:[s&&N(re,{item:!0,children:N(T,{label:s,required:P})}),m&&N(re,{item:!0,children:N(Lr,{title:m,placement:"top",children:N("div",{style:{width:"fit-content"},children:N(Je,{icon:Br,color:"#757575"})})})})]}),ae(wr,{open:r,onOpen:()=>y(!0),onClose:()=>y(!1),displayEmpty:!!c,variant:V,autoComplete:"off",value:b?b||"":C?[]:"",renderValue:L=>{if(L.label)return L.label;if(c)return N("p",{style:{color:A.grey[400]},children:c})},multiple:C,onChange:L=>{!x&&d(L.target.value),a&&a(L.target.value,F.getValues())},error:!!G,size:n.size||"medium",inputRef:w,...n,endAdornment:ae(zr,{children:[n.endAdornment,!!(S&&b)&&N(Rr,{variant:"text",color:"neutral",size:"small",sx:{borderRadius:"50%",position:"absolute",right:"2rem"},style:{padding:0},"aria-label":"Clear",title:"Clear",onClick:()=>{!x&&d(null),a&&a(null,F.getValues())},children:N(Je,{icon:Dr,color:Er.neutral[100],size:"25px",removeMargin:!0})})]}),children:[g?.map((L,f)=>N(Ir,{value:L,children:ae(re,{container:!0,direction:"column",children:[N(re,{item:!0,children:L.label}),L.afterLabel&&N(re,{item:!0,children:L.afterLabel})]})},f)),u&&[N(re,{sx:{px:2,py:1},children:N(kr,{})},"footer-divider"),N("div",{children:u({closeSelect:()=>y(!1)})},"footer-content")]]},e),N(k,{name:e,disableIcon:p,control:F.control})]})})});Xe.displayName="Select";var Gr=Xe;import{useState as Ur}from"react";import{useController as Hr,useFormContext as Kr,useFormState as Wr}from"react-hook-form";import{IconButton as Yr,LIcon as jr}from"@s_mart/core";import{lineTimes as Jr}from"@s_mart/regular-icons";import{colorPalette as Xr}from"@s_mart/tokens";import{Select as Qr,MenuItem as Zr,Divider as el}from"@mui/material";import{colorPalette as qr}from"@s_mart/tokens";import{jsx as _r}from"react/jsx-runtime";var Qe=({value:e,placeholder:o,getOptionLabel:l})=>e===null||e?.length===0?_r("p",{style:{color:qr.neutral[100]},children:o}):l(e);import{Fragment as rl,jsx as U,jsxs as le}from"react/jsx-runtime";var ol=e=>{let{name:o,rules:l,defaultValue:i,shouldUnregister:s,control:P,label:g,required:c,options:S,placeholder:x,clearable:C,info:m,footer:u,onChange:a,variant:p="outlined",getOptionKey:V,getOptionLabel:n,getOptionAfterLabel:F,getOptionIcon:A,...r}=e,y=Kr()?.control,G=P??y,[b,d]=Ur(!1);if(!G)throw new v("SelectV2");let w=Wr({control:G,name:o}),L=D(w.errors,o),{field:f}=Hr({control:G,name:o,rules:l,defaultValue:i,shouldUnregister:s});return le("div",{style:{display:"flex",flexDirection:"column"},children:[le("div",{style:{display:"flex"},children:[g&&U(T,{label:g,required:c}),m&&U(j,{title:m})]}),le(Qr,{open:b,onOpen:()=>d(!0),onClose:()=>d(!1),displayEmpty:!!x,variant:p,autoComplete:"off",value:f.value||null,renderValue:t=>U(Qe,{getOptionLabel:n,placeholder:x,value:t}),onChange:t=>{f.onChange(t.target.value),a?.(t.target.value)},error:!!L,size:r.size||"medium",inputRef:f.ref,...r,endAdornment:le(rl,{children:[r.endAdornment,!!(C&&f.value)&&U(Yr,{variant:"text",color:"neutral",size:"small",sx:{borderRadius:"50%",position:"absolute",right:"2rem"},style:{padding:0},"aria-label":"Limpar",title:"Limpar",onClick:()=>{f.onChange(null),a?.(null)},children:U(jr,{icon:Jr,color:Xr.neutral[100],size:"25px",removeMargin:!0})})]}),children:[S.map(t=>{let I=V(t),z=n(t),X=A?.(t);return U(Zr,{value:I??z,children:le("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[X!==void 0?le("div",{style:{display:"flex",alignItems:"center"},children:[X,z]}):z,U("span",{children:F?.(t)??null})]})},I)}),u!==void 0&&le("div",{children:[U("div",{style:{padding:"8px 16px"},children:U(el,{})},"footer-divider"),U("div",{children:u({closeSelect:()=>d(!1)})},"footer-content")]},"footer")]},o),U(k,{name:o,control:G})]})},tl=ie(ol);import{useController as ll,useFormContext as il}from"react-hook-form";import{Slider as nl}from"@mui/material";import{jsx as sl}from"react/jsx-runtime";var al=({name:e,rules:o,defaultValue:l,shouldUnregister:i,control:s,...P})=>{let g=il()?.control,c=s??g;if(!c)throw new v("Slider");let{field:S}=ll({control:c,name:e,rules:o,defaultValue:l,shouldUnregister:i});return sl(nl,{value:S.value||P?.min||0,onChange:S.onChange,valueLabelDisplay:"auto",...P},e)},dl=al;import{FormControlLabel as pl,Stack as ml,Switch as ul}from"@mui/material";import{useController as fl,useFormContext as cl}from"react-hook-form";import{jsx as xe,jsxs as xl}from"react/jsx-runtime";var Fl=({name:e,rules:o,defaultValue:l,shouldUnregister:i,control:s,label:P,labelPlacement:g,disableIconError:c,onChange:S,...x})=>{let C=cl()?.control,m=s??C;if(!m)throw new v("Switch");let{field:u}=fl({control:m,name:e,rules:o,defaultValue:l,shouldUnregister:i});return xl(ml,{children:[xe(pl,{control:xe(ul,{value:u.value??"",checked:u.value??!1,onChange:(a,p)=>{u.onChange(a,p),S?.(a,p)},...x},e),label:xe(T,{label:P}),labelPlacement:g||"end"}),xe(k,{name:e,disableIcon:c,control:m})]})},yl=Fl;import{InputAdornment as bl,Stack as hl,TextField as Pl,Tooltip as gl}from"@mui/material";import{LIcon as Ze}from"@s_mart/core";import*as eo from"@s_mart/masks";import{lineEye as Vl,lineEyeSlash as Cl,lineInfoCircle as Tl}from"@s_mart/solid-icons";import{useRef as vl,useState as Sl}from"react";import{useController as kl,useFormContext as Il,useFormState as wl}from"react-hook-form";import{jsx as W,jsxs as oo}from"react/jsx-runtime";var Ll=({name:e,rules:o,defaultValue:l,shouldUnregister:i,control:s,label:P,required:g,mask:c,variant:S="outlined",info:x,parse:C,format:m,onInputChange:u,disableIconError:a,...p})=>{let V=Il()?.control,n=s??V,F=vl(l||void 0);if(!n)throw new v("TextField");let[A,r]=Sl(!1),y=f=>{let t=f;return t=m?.(f)??f,c?eo?.[c]?.format(t):t},G=f=>{let t=f;return t=C?.(f)??t,c?eo?.[c]?.parse(t,F.current):t},b=f=>{if(!f||c!=="porcentagem"&&c!=="porcentagem0")return;f?.stopPropagation();let t=(f?.target).value;if(t){let I=String(t);if(I.length>0){let z=I.indexOf("%");z>-1&&(f.currentTarget.selectionEnd=z)}}},{field:d}=kl({control:n,name:e,rules:o,defaultValue:l,shouldUnregister:i}),w=wl({control:n,name:e}),L=D(w.errors,e);return oo(hl,{children:[oo("div",{style:{display:"flex"},children:[P&&W("div",{children:W(T,{label:P,required:g})}),x&&W("div",{children:W(gl,{title:x,placement:"top",children:W("div",{style:{width:"fit-content"},children:W(Ze,{icon:Tl,color:"#757575"})})})})]}),W(Pl,{variant:S,defaultValue:l,value:y(d.value||(d.value!=0?"":d.value)),onChange:f=>{let t=G(f?.target?.value);d.onChange(t),u?.(t),F.current=f.target.value},error:!!L,...p,type:p.type==="password"?A?"text":"password":p.type,autoComplete:p.autoComplete||"off",slotProps:{input:{onKeyDown:b,inputRef:d.ref,endAdornment:p.type==="password"&&W(bl,{position:"start",onClick:()=>r(!A),style:{cursor:"pointer"},children:W(Ze,{icon:A?Vl:Cl,size:"24px",removeMargin:!0})}),...p.InputProps}}},e),W(k,{name:e,disableIcon:a,control:n})]})},Al=Ll;import{Stack as Ml,TextField as Ol}from"@mui/material";import{AdapterDayjs as $l}from"@mui/x-date-pickers/AdapterDayjs";import{LocalizationProvider as Nl}from"@mui/x-date-pickers/LocalizationProvider";import{TimePicker as Gl}from"@mui/x-date-pickers/TimePicker";import{ptBR as zl}from"@mui/x-date-pickers/locales/ptBR";import{composeValidators as ql,time as ro}from"@s_mart/rules";import _l from"dayjs/locale/pt-br";import{memo as Ul}from"react";import{useController as Hl,useFormContext as Kl,useFormState as Wl}from"react-hook-form";import{styled as Rl}from"@mui/material";import{IconButton as Dl}from"@mui/material";import{toRem as Y}from"@s_mart/utils";var Bl=e=>{switch(e){case"small":return Y(16);case"large":return Y(24);default:return Y(20)}},El=e=>{switch(e){case"small":return`${Y(2)} ${Y(8)}`;case"large":return Y(10);default:return`${Y(6)} ${Y(8)}`}},to=Rl(Dl)`
|
|
61
|
+
`;import{jsx as j,jsxs as Mo}from"react/jsx-runtime";import{createElement as Do}from"react";var Ro=({rules:e,name:o,defaultValue:r,shouldUnregister:l,control:d,datePickerProps:u,label:f,required:s,placeholder:h,disabled:F,disableIconError:C,...m})=>{let c=wo()?.control,a=d??c;if(!a)throw new x("DatePicker");let p=Lo({control:a,name:o}),L=R(p.errors,o),T=u?.format||"DD/MM/YYYY",E=e?So([Ve(T),e]):Ve(T),{field:S}=Io({control:a,name:o,rules:E,defaultValue:r,shouldUnregister:l});return j(vo,{dateAdapter:bo,adapterLocale:ko,localeText:Co.components.MuiLocalizationProvider.defaultProps.localeText,children:Mo(ho,{children:[f&&j(P,{label:f,required:s}),Do(go,{...u,key:o,value:S.value??null,format:T,onChange:(i,V)=>{S.onChange(i,V),u?.onChange?.(i,V)},disabled:F,slots:{textField:To,openPickerButton:i=>j(xe,{...i,size:m.size})},slotProps:{textField:i=>({variant:"outlined",...i,error:!!L,...m,inputProps:{...i.inputProps,placeholder:h||i.inputProps?.placeholder},InputProps:{...i.InputProps,inputRef:V=>{S.ref(V),typeof i.inputRef=="function"&&i.inputRef(V)}}})}}),j(g,{name:o,disableIcon:C,control:a})]})})},Eo=w(Ro);import{FormProvider as Bo}from"react-hook-form";import{jsx as he}from"react/jsx-runtime";function Ao({children:e,style:o,onSubmit:r,...l}){return he(Bo,{...l,children:he("form",{onSubmit:d=>{d.preventDefault(),d.stopPropagation(),r(d)},style:o,children:e})})}var ie=Ao;import{useEffect as No}from"react";import{useForm as Oo}from"react-hook-form";import{zodResolver as $o}from"@hookform/resolvers/zod";var zo=({disableDefaultValuesUpdate:e,onSubmit:o,...r})=>{let l=Oo({...r,resolver:r.schema&&$o(r.schema)});return No(()=>{e||l.reset(r.defaultValues)},[r.defaultValues,l.reset]),{...l,onSubmit:l.handleSubmit(d=>o(d,l))}},ae=zo;import{jsx as Uo}from"react/jsx-runtime";function qo({children:e,style:o,...r}){let l=ae(r);return Uo(ie,{...l,style:o,children:typeof e=="function"?e(l):e})}var Go=qo;import{RadioGroup as _o,Stack as Ho}from"@mui/material";import{useController as Ko,useFormContext as Wo}from"react-hook-form";import{jsx as ne,jsxs as Xo}from"react/jsx-runtime";var Yo=({name:e,rules:o,defaultValue:r,shouldUnregister:l,control:d,label:u,required:f,children:s,orientation:h="row",disableIconError:F,...C})=>{let m=Wo()?.control,c=d??m;if(!c)throw new x("RadioGroup");let{field:a}=Ko({control:c,name:e,rules:o,defaultValue:r,shouldUnregister:l});return Xo(Ho,{children:[u&&ne(P,{label:u,required:f}),ne(_o,{value:a.value||"",name:e,...C,onChange:p=>{C?.onChange?.(p,p.target?.value),a.onChange(p)},style:{display:"flex",flexDirection:h},children:s},e),ne(g,{name:e,disableIcon:F,control:c})]})},Jo=Yo;import{FormControlLabel as Qo,Grid2 as Zo,Radio as jo}from"@mui/material";import{jsx as ee}from"react/jsx-runtime";var et=({label:e,labelPlacement:o,...r})=>ee(Zo,{sx:{display:"flex",flexDirection:"column"},children:ee(Qo,{control:ee(jo,{...r}),label:ee(P,{label:e}),labelPlacement:o||"end"})}),ot=et;import{Autocomplete as tt,Divider as Te,TextField as rt}from"@mui/material";import lt from"lodash-es/isEqual";import{forwardRef as it}from"react";import{useController as at,useFormContext as nt,useFormState as dt}from"react-hook-form";import{Fragment as de,jsx as M,jsxs as K}from"react/jsx-runtime";import{createElement as mt}from"react";var st=e=>{let{name:o,rules:r,defaultValue:l,shouldUnregister:d,control:u,label:f,required:s,options:h,textFieldProps:F,noOptionsText:C,footer:m,multiple:c,info:a,placeholder:p,onChange:L,onInputChange:T,getOptionAfterLabel:E,getOptionLabel:S,getOptionKey:i,...V}=e,N=nt()?.control,O=u??N;if(!O)throw new x("SearchableV2");let y=dt({control:O,name:o}),U=R(y.errors,o),{field:D}=at({name:o,control:O,rules:r,defaultValue:l,shouldUnregister:d});return K("div",{style:{display:"flex",flexDirection:"column"},children:[K("div",{style:{display:"flex"},children:[f&&M(P,{label:f,required:s}),a&&M(_,{title:a})]}),M(tt,{onChange:(n,t)=>{D.onChange(t),L?.(t)},onInputChange:(n,t,I)=>{I==="input"&&T?.(t)},value:D.value,options:h,multiple:c,readOnly:V.disabled,slotProps:{...V.slotProps,listbox:{component:it(function(t,I){return K(de,{children:[M("ul",{...t,ref:I}),typeof m<"u"?K("div",{...t,children:[M("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:M(Te,{})}),m()]},"searchable-footer"):null]})})}},noOptionsText:K(de,{children:[C||"Nenhuma op\xE7\xE3o encontrada",typeof m<"u"?K(de,{children:[M("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:M(Te,{})}),m()]}):null]}),isOptionEqualToValue:(n,t)=>lt(n,t),getOptionLabel:S,getOptionKey:i,renderOption:typeof E=="function"?(n,t)=>{let I=E(t),$=i(t);return mt("li",{...n,key:$},K("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[M("span",{children:S(t)}),typeof I=="string"?M("span",{children:I}):I]}))}:void 0,...V,renderInput:n=>M(rt,{error:!!U,placeholder:p,...n,...F,inputRef:D.ref})},o),M(g,{name:o,control:O})]})},pt=w(st);import{useState as ct}from"react";import{useController as Ft,useFormContext as yt,useFormState as Pt}from"react-hook-form";import{IconButton as xt,LIcon as Vt}from"@s_mart/core";import{lineTimes as ht}from"@s_mart/regular-icons";import{colorPalette as Tt}from"@s_mart/tokens";import{Select as bt,MenuItem as gt,Divider as vt}from"@mui/material";import{colorPalette as ut}from"@s_mart/tokens";import{jsx as ft}from"react/jsx-runtime";var be=({value:e,placeholder:o,getOptionLabel:r})=>e===null||e?.length===0?ft("p",{style:{color:ut.neutral[100]},children:o}):r(e);import{Fragment as kt,jsx as A,jsxs as W}from"react/jsx-runtime";var Ct=e=>{let{name:o,rules:r,defaultValue:l,shouldUnregister:d,control:u,label:f,required:s,options:h,placeholder:F,clearable:C,info:m,footer:c,onChange:a,variant:p="outlined",getOptionKey:L,getOptionLabel:T,getOptionAfterLabel:E,getOptionIcon:S,...i}=e,V=yt()?.control,N=u??V,[O,y]=ct(!1);if(!N)throw new x("SelectV2");let U=Pt({control:N,name:o}),D=R(U.errors,o),{field:n}=Ft({control:N,name:o,rules:r,defaultValue:l,shouldUnregister:d});return W("div",{style:{display:"flex",flexDirection:"column"},children:[W("div",{style:{display:"flex"},children:[f&&A(P,{label:f,required:s}),m&&A(_,{title:m})]}),W(bt,{open:O,onOpen:()=>y(!0),onClose:()=>y(!1),displayEmpty:!!F,variant:p,autoComplete:"off",value:n.value||null,renderValue:t=>A(be,{getOptionLabel:T,placeholder:F,value:t}),onChange:t=>{n.onChange(t.target.value),a?.(t.target.value)},error:!!D,size:i.size||"medium",inputRef:n.ref,...i,endAdornment:W(kt,{children:[i.endAdornment,!!(C&&n.value)&&A(xt,{variant:"text",color:"neutral",size:"small",sx:{borderRadius:"50%",position:"absolute",right:"2rem"},style:{padding:0},"aria-label":"Limpar",title:"Limpar",onClick:()=>{n.onChange(null),a?.(null)},children:A(Vt,{icon:ht,color:Tt.neutral[100],size:"25px",removeMargin:!0})})]}),children:[h.map(t=>{let I=L(t),$=T(t),J=S?.(t);return A(gt,{value:I??$,children:W("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[J!==void 0?W("div",{style:{display:"flex",alignItems:"center"},children:[J,$]}):$,A("span",{children:E?.(t)??null})]})},I)}),c!==void 0&&W("div",{children:[A("div",{style:{padding:"8px 16px"},children:A(vt,{})},"footer-divider"),A("div",{children:c({closeSelect:()=>y(!1)})},"footer-content")]},"footer")]},o),A(g,{name:o,control:N})]})},St=w(Ct);import{useController as It,useFormContext as wt}from"react-hook-form";import{Slider as Lt}from"@mui/material";import{jsx as Dt}from"react/jsx-runtime";var Rt=({name:e,rules:o,defaultValue:r,shouldUnregister:l,control:d,...u})=>{let f=wt()?.control,s=d??f;if(!s)throw new x("Slider");let{field:h}=It({control:s,name:e,rules:o,defaultValue:r,shouldUnregister:l});return Dt(Lt,{value:h.value||u?.min||0,onChange:h.onChange,valueLabelDisplay:"auto",...u},e)},Et=Rt;import{FormControlLabel as Mt,Stack as Bt,Switch as At}from"@mui/material";import{useController as Nt,useFormContext as Ot}from"react-hook-form";import{jsx as oe,jsxs as qt}from"react/jsx-runtime";var $t=({name:e,rules:o,defaultValue:r,shouldUnregister:l,control:d,label:u,labelPlacement:f,disableIconError:s,onChange:h,...F})=>{let C=Ot()?.control,m=d??C;if(!m)throw new x("Switch");let{field:c}=Nt({control:m,name:e,rules:o,defaultValue:r,shouldUnregister:l});return qt(Bt,{children:[oe(Mt,{control:oe(At,{value:c.value??"",checked:c.value??!1,onChange:(a,p)=>{c.onChange(a,p),h?.(a,p)},...F},e),label:oe(P,{label:u}),labelPlacement:f||"end"}),oe(g,{name:e,disableIcon:s,control:m})]})},zt=w($t);import{InputAdornment as Gt,Stack as Ut,TextField as _t,Tooltip as Ht}from"@mui/material";import{LIcon as ge}from"@s_mart/core";import*as ve from"@s_mart/masks";import{lineEye as Kt,lineEyeSlash as Wt,lineInfoCircle as Yt}from"@s_mart/solid-icons";import{useRef as Jt,useState as Xt}from"react";import{useController as Qt,useFormContext as Zt,useFormState as jt}from"react-hook-form";import{jsx as q,jsxs as Ce}from"react/jsx-runtime";var er=({name:e,rules:o,defaultValue:r,shouldUnregister:l,control:d,label:u,required:f,mask:s,variant:h="outlined",info:F,parse:C,format:m,onInputChange:c,disableIconError:a,...p})=>{let L=Zt()?.control,T=d??L,E=Jt(r||void 0);if(!T)throw new x("TextField");let[S,i]=Xt(!1),V=n=>{let t=n;return t=m?.(n)??n,s?ve?.[s]?.format(t):t},N=n=>{let t=n;return t=C?.(n)??t,s?ve?.[s]?.parse(t,E.current):t},O=n=>{if(!n||s!=="porcentagem"&&s!=="porcentagem0")return;n?.stopPropagation();let t=(n?.target).value;if(t){let I=String(t);if(I.length>0){let $=I.indexOf("%");$>-1&&(n.currentTarget.selectionEnd=$)}}},{field:y}=Qt({control:T,name:e,rules:o,defaultValue:r,shouldUnregister:l}),U=jt({control:T,name:e}),D=R(U.errors,e);return Ce(Ut,{children:[Ce("div",{style:{display:"flex"},children:[u&&q("div",{children:q(P,{label:u,required:f})}),F&&q("div",{children:q(Ht,{title:F,placement:"top",children:q("div",{style:{width:"fit-content"},children:q(ge,{icon:Yt,color:"#757575"})})})})]}),q(_t,{variant:h,defaultValue:r,value:V(y.value||(y.value!=0?"":y.value)),onChange:n=>{let t=N(n?.target?.value);y.onChange(t),c?.(t),E.current=n.target.value},error:!!D,...p,type:p.type==="password"?S?"text":"password":p.type,autoComplete:p.autoComplete||"off",slotProps:{input:{onKeyDown:O,inputRef:y.ref,endAdornment:p.type==="password"&&q(Gt,{position:"start",onClick:()=>i(!S),style:{cursor:"pointer"},children:q(ge,{icon:S?Kt:Wt,size:"24px",removeMargin:!0})}),...p.slotProps?.input}}},e),q(g,{name:e,disableIcon:a,control:T})]})},or=w(er);import{Stack as ar,TextField as nr}from"@mui/material";import{AdapterDayjs as dr}from"@mui/x-date-pickers/AdapterDayjs";import{LocalizationProvider as sr}from"@mui/x-date-pickers/LocalizationProvider";import{TimePicker as pr}from"@mui/x-date-pickers/TimePicker";import{ptBR as mr}from"@mui/x-date-pickers/locales/ptBR";import{composeValidators as ur,time as ke}from"@s_mart/rules";import fr from"dayjs/locale/pt-br";import{useController as cr,useFormContext as Fr,useFormState as yr}from"react-hook-form";import{styled as tr}from"@mui/material";import{IconButton as rr}from"@mui/material";import{toRem as G}from"@s_mart/utils";var lr=e=>{switch(e){case"small":return G(16);case"large":return G(24);default:return G(20)}},ir=e=>{switch(e){case"small":return`${G(2)} ${G(8)}`;case"large":return G(10);default:return`${G(6)} ${G(8)}`}},Se=tr(rr)`
|
|
115
62
|
margin: 0px;
|
|
116
63
|
|
|
117
|
-
padding: ${({size:e})=>
|
|
118
|
-
border-radius: 0 ${
|
|
64
|
+
padding: ${({size:e})=>ir(e)};
|
|
65
|
+
border-radius: 0 ${G(4)} ${G(4)} 0;
|
|
119
66
|
|
|
120
67
|
svg {
|
|
121
|
-
width: ${({size:e})=>
|
|
68
|
+
width: ${({size:e})=>lr(e)} !important;
|
|
122
69
|
}
|
|
123
|
-
`;import{jsx as
|
|
70
|
+
`;import{jsx as X,jsxs as Vr}from"react/jsx-runtime";var Pr=({rules:e,defaultValue:o,shouldUnregister:r,name:l,control:d,required:u,label:f,timePickerProps:s,placeholder:h,disabled:F,disableIconError:C,...m})=>{let c=Fr()?.control,a=d??c;if(!a)throw new x("TimePicker");let p=yr({control:a,name:l}),L=R(p.errors,l),T=s?.format||"HH:mm",E=e?ur([ke(T),e]):ke(T),{field:S}=cr({control:a,name:l,rules:E,defaultValue:o,shouldUnregister:r});return X(sr,{dateAdapter:dr,adapterLocale:fr,localeText:mr.components.MuiLocalizationProvider.defaultProps.localeText,children:Vr(ar,{children:[f&&X(P,{label:f,required:u}),X(pr,{ampm:!1,format:T,value:S.value??null,disabled:F,...s,onChange:(i,V)=>{S.onChange(i,V),s?.onChange?.(i,V)},slots:{textField:nr,openPickerButton:i=>X(Se,{...i,size:m.size})},slotProps:{textField:i=>({variant:"outlined",...i,error:!!L,...m,inputProps:{...i.inputProps,placeholder:h||i.inputProps?.placeholder},InputProps:{...i.InputProps,inputRef:V=>{S.ref(V),typeof i.inputRef=="function"&&i.inputRef(V)}}})}},l),X(g,{name:l,disableIcon:C,control:a})]})})},xr=w(Pr);export{He as Checkbox,co as CreatableV2,Eo as DatePicker,g as FieldError,_ as FieldInfo,P as FieldLabel,Go as Form,ie as FormProvider,ot as RadioButton,Jo as RadioGroup,pt as SearchableV2,St as SelectV2,Et as Slider,zt as Switch,or as TextField,xr as TimePicker,ae as useForm};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@s_mart/form",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0-beta.11",
|
|
4
4
|
"main": "./dist/index.mjs",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.mts",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"@emotion/react": "^11.11.4",
|
|
21
21
|
"@emotion/styled": "^11.13.0",
|
|
22
|
-
"@mui/material": "^6.
|
|
23
|
-
"@mui/system": "^6.4.
|
|
22
|
+
"@mui/material": "^6.4.11",
|
|
23
|
+
"@mui/system": "^6.4.11",
|
|
24
24
|
"@mui/x-date-pickers": "^7.22.0",
|
|
25
25
|
"@types/lodash-es": ">=4.17.12",
|
|
26
26
|
"@types/node": ">=22.15.17",
|
|
@@ -32,17 +32,17 @@
|
|
|
32
32
|
"react-hook-form": "^7.51.0",
|
|
33
33
|
"typescript": ">=5.4.2",
|
|
34
34
|
"zod": "^3.22.4",
|
|
35
|
-
"@s_mart/core": "
|
|
35
|
+
"@s_mart/core": "10.0.0-beta.4",
|
|
36
36
|
"@s_mart/masks": "5.2.0",
|
|
37
|
-
"@s_mart/
|
|
37
|
+
"@s_mart/utils": "5.3.4",
|
|
38
38
|
"@s_mart/tokens": "5.1.1",
|
|
39
|
-
"@s_mart/
|
|
40
|
-
"@s_mart/
|
|
39
|
+
"@s_mart/rules": "5.1.2-beta.0",
|
|
40
|
+
"@s_mart/typed": "7.2.2"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@emotion/styled": "^11.13.0",
|
|
44
|
-
"@mui/material": "^6.
|
|
45
|
-
"@mui/system": "^6.4.
|
|
44
|
+
"@mui/material": "^6.4.11",
|
|
45
|
+
"@mui/system": "^6.4.11",
|
|
46
46
|
"@mui/x-date-pickers": "^7.22.0",
|
|
47
47
|
"@types/lodash-es": ">=4.17.12",
|
|
48
48
|
"@types/node": ">=22.15.17",
|
|
@@ -50,12 +50,12 @@
|
|
|
50
50
|
"@types/react-dom": ">=18.3.1",
|
|
51
51
|
"dayjs": "^1.11.10",
|
|
52
52
|
"typescript": ">=5.4.2",
|
|
53
|
-
"@s_mart/core": "
|
|
53
|
+
"@s_mart/core": "10.0.0-beta.4",
|
|
54
54
|
"@s_mart/masks": "5.2.0",
|
|
55
55
|
"@s_mart/rules": "5.1.2-beta.0",
|
|
56
|
-
"@s_mart/
|
|
56
|
+
"@s_mart/utils": "5.3.4",
|
|
57
57
|
"@s_mart/typed": "7.2.2",
|
|
58
|
-
"@s_mart/
|
|
58
|
+
"@s_mart/tokens": "5.1.1"
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|
|
61
61
|
"build": "tsup src/index.tsx --minify --format esm --dts --external react",
|