@s_mart/form 9.2.0-beta.8 → 10.0.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,48 +1,11 @@
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 { UseControllerProps, FieldValues, FieldPath, ControllerProps, FieldPathValue, Control, UseFormReturn, FormProviderProps, UseFormProps } from 'react-hook-form';
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';
5
+ import * as react from 'react';
6
6
  import { DatePickerProps as DatePickerProps$1, TimePickerProps as TimePickerProps$1 } from '@mui/x-date-pickers';
7
7
  import { z } from 'zod';
8
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>;
45
-
46
9
  type CheckboxProps<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = CheckboxProps$1 & UseControllerProps<TFieldValues, TFieldName> & {
47
10
  /**
48
11
  * O nome do checkbox que será renderizado na tela
@@ -72,119 +35,11 @@ type CheckboxProps<TFieldValues extends FieldValues = FieldValues, TFieldName ex
72
35
 
73
36
  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;
74
37
 
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>;
184
-
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> & {
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
- textFieldProps?: TextFieldProps$1;
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
  /**
@@ -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 ControllerSearchable = Omit<ControllerProps, 'render' | 'control'>;
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;
@@ -544,91 +324,10 @@ type SearchableV2Props<TFieldValues extends FieldValues = FieldValues, TFieldNam
544
324
 
545
325
  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;
546
326
 
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>;
627
-
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$1, 'onChange' | 'multiple' | 'defaultValue' | 'variant'> & UseControllerProps<TFieldValues, TFieldName> & {
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
@@ -707,7 +406,7 @@ type SliderProps<TFieldValues extends FieldValues = FieldValues, TFieldName exte
707
406
 
708
407
  declare const Slider: <TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ name, rules, defaultValue, shouldUnregister, control: controlFromProps, ...rest }: SliderProps<TFieldValues, TFieldName>) => react_jsx_runtime.JSX.Element;
709
408
 
710
- type SwitchProps<TFieldValues extends Record<string, boolean>, TFieldName extends FieldPath<TFieldValues>> = SwitchProps$1 & UseControllerProps<TFieldValues, TFieldName> & {
409
+ type SwitchProps<TFieldValues extends FieldValues = Record<string, boolean>, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = SwitchProps$1 & UseControllerProps<TFieldValues, TFieldName> & {
711
410
  /**
712
411
  * O nome do switch que será renderizado na tela
713
412
  * @default ''
@@ -737,7 +436,7 @@ type SwitchProps<TFieldValues extends Record<string, boolean>, TFieldName extend
737
436
  declare const Switch: <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
- type TextFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = TextFieldProps$1 & UseControllerProps<TFieldValues, TFieldName> & {
439
+ type TextFieldProps<TFieldValues extends FieldValues = Record<string, string>, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = TextFieldProps$1 & UseControllerProps<TFieldValues, TFieldName> & {
741
440
  mask?: Masks;
742
441
  /**
743
442
  * @description Função que será executada quando o valor do input for alterado
@@ -806,4 +505,4 @@ type TimePickerProps<TFieldValues extends FieldValues = FieldValues, TFieldName
806
505
 
807
506
  declare const _default: react.MemoExoticComponent<(<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ rules, defaultValue, shouldUnregister, name, control: controlFromProps, required, label, timePickerProps, placeholder, disabled, disableIconError, ...rest }: TimePickerProps<TFieldValues, TFieldName>) => react_jsx_runtime.JSX.Element)>;
808
507
 
809
- export { type AutoCompleteOption, _default$5 as Autocomplete, type AutocompleteProps, Checkbox, type CheckboxProps, Creatable, type CreatableOption, type CreatableProps, _default$4 as CreatableV2, type CreatableV2Props, _default$3 as DatePicker, type DatePickerProps, FieldError, type FieldErrorProps, FieldInfo, type FieldInfoProps, FieldLabel, type FieldLabelProps, type FooterProps, type FooterPropsV2, Form, FormProvider, type IFormProps, type IFormProviderProps, type IUseFormProps, type Masks, RadioButton, RadioGroup, type RadioGroupProps, type RadioProps, Searchable, type SearchableOption, type SearchableProps, _default$2 as SearchableV2, type SearchableV2Props, Select, type SelectOption, type SelectProps, type SelectProps as SelectPropsMui, _default$1 as SelectV2, type SelectV2Props, type SelectV2ReturnValueProps, Slider, type SliderProps, Switch, type SwitchProps, TextField, type TextFieldProps, _default as TimePicker, type TimePickerProps, useForm };
508
+ export { Checkbox, type CheckboxProps, _default$4 as CreatableV2, type CreatableV2Props, _default$3 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$2 as SearchableV2, type SearchableV2Props, _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,68 +1,15 @@
1
- import{Autocomplete as Fo,Grid as se,TextField as yo}from"@mui/material";import{colorPalette as xo}from"@s_mart/tokens";import{memo as bo}from"react";import{Controller as ho,useFormContext as Po}from"react-hook-form";import{Indicator as ao}from"@s_mart/core";import{useFormState as so}from"react-hook-form";var D=(e,o)=>o.replace(/[[\]]/g,"").split(".").reduce((i,s)=>i?.[s],e);import{jsx as mo}from"react/jsx-runtime";var po=({name:e,disableIcon:o,control:l})=>{let i=so({control:l,name:e}),s=D(i?.errors,e);return s?mo(ao,{severity:"error",icon:o?!1:void 0,children:s?.message}):null},k=po;import{Typography as Ie}from"@mui/material";import{toRem as uo}from"@s_mart/utils";import{jsx as we,jsxs as co}from"react/jsx-runtime";var fo=({label:e,required:o,regular:l})=>co("span",{style:{display:"flex",alignItems:"center",gap:uo(2)},children:[we(Ie,{variant:"caption",style:{display:"flex",alignItems:"center"},sx:{fontWeight:l?400:700},children:e}),o&&we(Ie,{variant:"caption",color:"error",sx:{fontWeight:900},children:"*"})]}),T=fo;var v=class extends Error{constructor(o){super(`O componente ${o} precisa de um control para funcionar. Passe o control como prop ou coloque o componente dentro de um <Form />`),this.name="FormComponentPrecisaDeControl"}};import{jsx as 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 v("Autocomplete");let a=D(u.formState.errors,e);return console.warn=()=>{},Z(ho,{name:e,control:u.control,defaultValue:o,rules:l,shouldUnregister:i,render:({field:p})=>Le(se,{sx:{display:"flex",flexDirection:"column"},children:[s&&Z(T,{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 To,useFormContext as vo}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=vo()?.control,u=s??m;if(!u)throw new v("Checkbox");let{field:a}=To({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(T,{label:P,required:c,regular:!0}),labelPlacement:g||"end"}),pe(k,{name:e,disableIcon:S,control:u})]})},wo=Io;import{forwardRef as Do,memo as Bo}from"react";import{Controller as Eo,useFormContext as Mo}from"react-hook-form";import{isObject as Oo,isEmpty as $o}from"lodash-es";import{Grid as ee,Autocomplete as No,TextField as Go,Tooltip as zo,Divider as qo}from"@mui/material";import{LIcon as ue,Button as _o}from"@s_mart/core";import{colorPalette as Uo}from"@s_mart/tokens";import{linePlus as Be,linePen as Ho,lineInfoCircle as Ko}from"@s_mart/solid-icons";import{toRem as Ee}from"@s_mart/utils";import{css as Ae}from"@emotion/react";import{styled as Ao}from"@mui/material";import{toRem as me}from"@s_mart/utils";var Re=Ae`
1
+ import{useController as $e,useFormContext as ze}from"react-hook-form";import{Checkbox as qe,FormControlLabel as Ge}from"@mui/material";import{Indicator as Ee}from"@s_mart/core";import{useFormState as De}from"react-hook-form";var L=(e,o)=>o.replace(/[[\]]/g,"").split(".").reduce((l,d)=>l?.[d],e);import{jsx as Me}from"react/jsx-runtime";var Be=({name:e,disableIcon:o,control:r})=>{let l=De({control:r,name:e}),d=L(l?.errors,e);return d?Me(Ee,{severity:"error",icon:o?!1:void 0,children:d?.message}):null},g=Be;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:"*"})]}),x=Ne;var P=class extends Error{constructor(o){super(`O componente ${o} precisa de um control para funcionar. Passe o control como prop ou coloque o componente dentro de um <Form />`),this.name="FormComponentPrecisaDeControl"}};import{jsx as Q,jsxs as He}from"react/jsx-runtime";var Ue=({name:e,rules:o,defaultValue:r,shouldUnregister:l,control:d,label:u,labelPlacement:f,required:s,disableIconError:h,onChange:F,...C})=>{let m=ze()?.control,c=d??m;if(!c)throw new P("Checkbox");let{field:a}=$e({control:c,name:e,rules:o,defaultValue:r,shouldUnregister:l});return He("span",{children:[Q(Ge,{control:Q(qe,{checked:!!a.value,value:a.value??"",defaultValue:a.value,onChange:(p,w)=>{a.onChange(p,w),F?.(p,w)},...C},e),label:Q(x,{label:u,required:s,regular:!0}),labelPlacement:f||"end"}),Q(g,{name:e,disableIcon:h,control:c})]})},_e=Ue;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 xe}from"@s_mart/utils";import{css as Ke,styled as We}from"@mui/material";import{toRem as Z}from"@s_mart/utils";var fe=Ke`
2
2
  display: flex;
3
3
  align-items: center;
4
4
  justify-content: center;
5
- `,Ro=e=>Ae`
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=We("div")`
59
6
  display: flex;
60
7
 
61
8
  div.endAdornments {
62
9
  position: absolute;
63
10
  right: 0;
64
11
 
65
- ${$e}
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
- ${$e}
26
+ ${fe}
80
27
 
81
28
  .divider {
82
29
  width: 1px;
83
- height: ${fe(20)};
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 ${fe(6)};
95
- width: ${fe(28)};
96
- height: ${fe(28)};
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 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 v("CreatableV2");let z=nt({control:I,name:o}),X=D(z.errors,o),B=!C||w.disabled,{field:h}=lt({name:o,control:I,rules:l,defaultValue:i,shouldUnregister:s}),ne=$=>{let E=0;return F?.InputProps||(E+=2.5),B||(E+=2.56,Se($)&&(E+=2.56)),!w.disableClearable&&!w.disabled&&(E+=1.3),`${E}rem`},Se=$=>w.disabled?!1:m&&at($)&&!dt($),lo=()=>w.disabled?!1:C,ke=tt(()=>{typeof a<"u"&&(a(L),f(""))},[L,a]),io=()=>{u?.(h.value)};return _("div",{style:{display:"flex",flexDirection:"column"},children:[_("div",{style:{display:"flex"},children:[g&&M(T,{label:g,required:c}),r&&M(j,{title:r})]}),M(Ne,{children:M(pt,{fullWidth:!0,onChange:($,E)=>{f(""),h.onChange(E),G?.(E)},onInputChange:($,E,Q)=>{Q==="input"&&(f(E),b?.(E))},slotProps:{...w.slotProps,paper:{...w.slotProps?.paper,sx:{border:`1px solid ${ft.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}},listbox:{component:ot(function(E,Q){return _(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:($,E)=>st($,E),getOptionLabel:V,getOptionKey:p,renderOption:typeof n=="function"?($,E)=>{let Q=n(E),no=p(E);return xt("li",{...$,key:no},_("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[M("span",{children: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:$=>{w?.onBlur?.($),f("")},renderInput:$=>M(mt,{placeholder:d,...$,error:!!X,...F,slotProps:{input:{...$.InputProps,...F?.InputProps,inputRef:h.ref,endAdornment:_("div",{className:"endAdornments",children:[$.InputProps.endAdornment,F?.InputProps?.endAdornment??null,Se(h.value)?_("div",{className:"editable",children:[M("div",{className:"divider"}),M("div",{className:"button",onKeyUp:io,children:M(Pe,{icon:ct,size:"24px",removeMargin:!0})})]}):null,lo()&&_("div",{className:"creatable",children:[M("div",{className:"divider"}),M("div",{className:"button",onKeyUp:ke,children:M(Pe,{icon:ze,size:"24px",removeMargin:!0})})]})]})}}})},o)}),M(k,{name:o,control:I})]})}var yt=ie(Ft);import{Stack as Vt,TextField as Ct}from"@mui/material";import{AdapterDayjs as Tt}from"@mui/x-date-pickers/AdapterDayjs";import{DatePicker as vt}from"@mui/x-date-pickers/DatePicker";import{LocalizationProvider as St}from"@mui/x-date-pickers/LocalizationProvider";import{ptBR as kt}from"@mui/x-date-pickers/locales/ptBR";import{composeValidators as It,date as Ue}from"@s_mart/rules";import wt from"dayjs/locale/pt-br";import{memo as Lt}from"react";import{useController as At,useFormContext as Rt,useFormState as Dt}from"react-hook-form";import{IconButton as bt,styled as ht}from"@mui/material";import{toRem as K}from"@s_mart/utils";var Pt=e=>{switch(e){case"small":return K(16);default:case"medium":return K(20);case"large":return K(24)}},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)`
52
+ `;import{Tooltip as Ye}from"@mui/material";import{LIcon as Je}from"@s_mart/core";import{lineInfoCircle as Xe}from"@s_mart/solid-icons";import{jsx as te}from"react/jsx-runtime";var Qe=({title:e})=>te(Ye,{title:e,placement:"top",children:te("div",{style:{width:"fit-content"},children:te(Je,{icon:Xe,color:"#757575"})})}),U=Qe;import{memo as Ze}from"react";var Y=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:w,getOptionAfterLabel:T,multiple:R,info:S,noOptionsText:i,onChange:V,onInputChange:A,placeholder:N,...y}=e,[G,E]=oo(""),n=ro()?.control,t=u??n;if(!t)throw new P("CreatableV2");let I=lo({control:t,name:o}),O=L(I.errors,o),J=!C||y.disabled,{field:W}=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(G),E(""))},[G,a]),Le=()=>{c?.(W.value)};return B("div",{style:{display:"flex",flexDirection:"column"},children:[B("div",{style:{display:"flex"},children:[f&&v(x,{label:f,required:s}),S&&v(U,{title:S})]}),v(ce,{children:v(so,{fullWidth:!0,onChange:(k,b)=>{E(""),W.onChange(b),V?.(b)},onInputChange:(k,b,_)=>{_==="input"&&(E(b),A?.(b))},slotProps:{...y.slotProps,listbox:{component:je(function(b,_){return B(le,{children:[v("ul",{...b,ref:_}),typeof F<"u"?B("div",{...b,children:[v("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:v(Fe,{})}),F()]},"creatable-footer"):null]})})}},value:W.value,options:h,multiple:R,readOnly:y.disabled,noOptionsText:B(le,{children:[i||"Nenhuma op\xE7\xE3o encontrada",!J&&B(mo,{sx:{justifyContent:"flex-start",padding:`${xe(6)} ${xe(-16)}`,margin:0},fullWidth:!0,onClick:pe,variant:"text",startIcon:v(re,{icon:ye}),children:["Adicionar ",`"${G}"`]}),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:w,getOptionKey:p,renderOption:typeof T=="function"?(k,b)=>{let _=T(b),Re=p(b);return Fo("li",{...k,key:Re},B("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[v("span",{children:w(b)}),typeof _=="string"?v("span",{children:_}):_]}))}:void 0,...y,sx:{"& div.MuiInputBase-root":{paddingRight:`${Ie(W.value)} !important`},...y.sx},onBlur:k=>{y?.onBlur?.(k),E("")},renderInput:k=>v(po,{placeholder:N,...k,error:!!O,...e.slotProps?.textField,slotProps:{input:{...k.InputProps,...e.slotProps?.textField?.slotProps?.input,inputRef:W.ref,endAdornment:B("div",{className:"endAdornments",children:[k.InputProps.endAdornment,e.slotProps?.textField?.slotProps?.input?.endAdornment??null,se(W.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=Y(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{memo as Io}from"react";import{useController as wo,useFormContext as Lo,useFormState as Ro}from"react-hook-form";import{IconButton as yo,styled as xo}from"@mui/material";import{toRem as $}from"@s_mart/utils";var Po=e=>{switch(e){case"small":return $(16);case"large":return $(24);default:return $(20)}},Vo=e=>{switch(e){case"small":return`${$(2)} ${$(8)}`;case"large":return`${$(10)}`;default:return`${$(6)} ${$(8)}`}},Pe=xo(yo)`
106
53
  margin: 0px;
107
54
 
108
- padding: ${({size:e})=>gt(e)};
109
- border-radius: 0 ${K(4)} ${K(4)} 0;
55
+ padding: ${({size:e})=>Vo(e)};
56
+ border-radius: 0 ${$(4)} ${$(4)} 0;
110
57
 
111
58
  svg {
112
- width: ${({size:e})=>Pt(e)} !important;
59
+ width: ${({size:e})=>Po(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 Bo}from"react";var Eo=({rules:e,name:o,defaultValue:r,shouldUnregister:l,control:d,datePickerProps:u,label:f,required:s,placeholder:h,disabled:F,disableIconError:C,...m})=>{let c=Lo()?.control,a=d??c;if(!a)throw new P("DatePicker");let p=Ro({control:a,name:o}),w=L(p.errors,o),T=u?.format||"DD/MM/YYYY",R=e?So([Ve(T),e]):Ve(T),{field:S}=wo({control:a,name:o,rules:R,defaultValue:r,shouldUnregister:l});return j(vo,{dateAdapter:bo,adapterLocale:ko,localeText:Co.components.MuiLocalizationProvider.defaultProps.localeText,children:Mo(ho,{children:[f&&j(x,{label:f,required:s}),Bo(go,{...u,key:o,value:S.value??null,format:T,onChange:(i,V)=>{S.onChange(i,V),u?.onChange?.(i,V)},disabled:F,slots:{textField:To,openPickerButton:i=>j(Pe,{...i,size:m.size})},slotProps:{textField:i=>({variant:"outlined",...i,error:!!w,...m,inputProps:{...i.inputProps,placeholder:h||i.inputProps?.placeholder},InputProps:{...i.InputProps,inputRef:V=>{S.ref(V),typeof i.inputRef=="function"&&i.inputRef(V)}}})}}),j(g,{name:o,disableIcon:C,control:a})]})})},Do=Io(Eo);import{FormProvider as Ao}from"react-hook-form";import{jsx as he}from"react/jsx-runtime";function No({children:e,style:o,onSubmit:r,...l}){return he(Ao,{...l,children:he("form",{onSubmit:d=>{d.preventDefault(),d.stopPropagation(),r(d)},style:o,children:e})})}var ie=No;import{useEffect as Oo}from"react";import{useForm as $o}from"react-hook-form";import{zodResolver as zo}from"@hookform/resolvers/zod";var qo=({disableDefaultValuesUpdate:e,onSubmit:o,...r})=>{let l=$o({...r,resolver:r.schema&&zo(r.schema)});return Oo(()=>{e||l.reset(r.defaultValues)},[r.defaultValues,l.reset]),{...l,onSubmit:l.handleSubmit(d=>o(d,l))}},ae=qo;import{jsx as _o}from"react/jsx-runtime";function Go({children:e,style:o,...r}){let l=ae(r);return _o(ie,{...l,style:o,children:typeof e=="function"?e(l):e})}var Uo=Go;import{RadioGroup as Ho,Stack as Ko}from"@mui/material";import{useController as Wo,useFormContext as Yo}from"react-hook-form";import{jsx as ne,jsxs as Qo}from"react/jsx-runtime";var Jo=({name:e,rules:o,defaultValue:r,shouldUnregister:l,control:d,label:u,required:f,children:s,orientation:h="row",disableIconError:F,...C})=>{let m=Yo()?.control,c=d??m;if(!c)throw new P("RadioGroup");let{field:a}=Wo({control:c,name:e,rules:o,defaultValue:r,shouldUnregister:l});return Qo(Ko,{children:[u&&ne(x,{label:u,required:f}),ne(Ho,{value:a.value||"",name:e,...C,onChange:p=>{C?.onChange?.(p,p.target?.value),a.onChange(p)},style:{display:"flex",flexDirection:h},children:s},e),ne(g,{name:e,disableIcon:F,control:c})]})},Xo=Jo;import{FormControlLabel as Zo,Grid2 as jo,Radio as et}from"@mui/material";import{jsx as ee}from"react/jsx-runtime";var ot=({label:e,labelPlacement:o,...r})=>ee(jo,{sx:{display:"flex",flexDirection:"column"},children:ee(Zo,{control:ee(et,{...r}),label:ee(x,{label:e}),labelPlacement:o||"end"})}),tt=ot;import{Autocomplete as rt,Divider as Te,TextField as lt}from"@mui/material";import it from"lodash-es/isEqual";import{forwardRef as at}from"react";import{useController as nt,useFormContext as dt,useFormState as st}from"react-hook-form";import{Fragment as de,jsx as D,jsxs as H}from"react/jsx-runtime";import{createElement as ut}from"react";var pt=e=>{let{name:o,rules:r,defaultValue:l,shouldUnregister:d,control:u,label:f,required:s,options:h,textFieldProps:F,noOptionsText:C,footer:m,multiple:c,info:a,placeholder:p,onChange:w,onInputChange:T,getOptionAfterLabel:R,getOptionLabel:S,getOptionKey:i,...V}=e,A=dt()?.control,N=u??A;if(!N)throw new P("SearchableV2");let y=st({control:N,name:o}),G=L(y.errors,o),{field:E}=nt({name:o,control:N,rules:r,defaultValue:l,shouldUnregister:d});return H("div",{style:{display:"flex",flexDirection:"column"},children:[H("div",{style:{display:"flex"},children:[f&&D(x,{label:f,required:s}),a&&D(U,{title:a})]}),D(rt,{onChange:(n,t)=>{E.onChange(t),w?.(t)},onInputChange:(n,t,I)=>{I==="input"&&T?.(t)},value:E.value,options:h,multiple:c,readOnly:V.disabled,slotProps:{...V.slotProps,listbox:{component:at(function(t,I){return H(de,{children:[D("ul",{...t,ref:I}),typeof m<"u"?H("div",{...t,children:[D("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:D(Te,{})}),m()]},"searchable-footer"):null]})})}},noOptionsText:H(de,{children:[C||"Nenhuma op\xE7\xE3o encontrada",typeof m<"u"?H(de,{children:[D("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:D(Te,{})}),m()]}):null]}),isOptionEqualToValue:(n,t)=>it(n,t),getOptionLabel:S,getOptionKey:i,renderOption:typeof R=="function"?(n,t)=>{let I=R(t),O=i(t);return ut("li",{...n,key:O},H("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[D("span",{children:S(t)}),typeof I=="string"?D("span",{children:I}):I]}))}:void 0,...V,renderInput:n=>D(lt,{error:!!G,placeholder:p,...n,...F,inputRef:E.ref})},o),D(g,{name:o,control:N})]})},mt=Y(pt);import{useState as Ft}from"react";import{useController as yt,useFormContext as xt,useFormState as Pt}from"react-hook-form";import{IconButton as Vt,LIcon as ht}from"@s_mart/core";import{lineTimes as Tt}from"@s_mart/regular-icons";import{colorPalette as bt}from"@s_mart/tokens";import{Select as gt,MenuItem as vt,Divider as Ct}from"@mui/material";import{colorPalette as ft}from"@s_mart/tokens";import{jsx as ct}from"react/jsx-runtime";var be=({value:e,placeholder:o,getOptionLabel:r})=>e===null||e?.length===0?ct("p",{style:{color:ft.neutral[100]},children:o}):r(e);import{Fragment as It,jsx as M,jsxs as K}from"react/jsx-runtime";var St=e=>{let{name:o,rules:r,defaultValue:l,shouldUnregister:d,control:u,label:f,required:s,options:h,placeholder:F,clearable:C,info:m,footer:c,onChange:a,variant:p="outlined",getOptionKey:w,getOptionLabel:T,getOptionAfterLabel:R,getOptionIcon:S,...i}=e,V=xt()?.control,A=u??V,[N,y]=Ft(!1);if(!A)throw new P("SelectV2");let G=Pt({control:A,name:o}),E=L(G.errors,o),{field:n}=yt({control:A,name:o,rules:r,defaultValue:l,shouldUnregister:d});return K("div",{style:{display:"flex",flexDirection:"column"},children:[K("div",{style:{display:"flex"},children:[f&&M(x,{label:f,required:s}),m&&M(U,{title:m})]}),K(gt,{open:N,onOpen:()=>y(!0),onClose:()=>y(!1),displayEmpty:!!F,variant:p,autoComplete:"off",value:n.value||null,renderValue:t=>M(be,{getOptionLabel:T,placeholder:F,value:t}),onChange:t=>{n.onChange(t.target.value),a?.(t.target.value)},error:!!E,size:i.size||"medium",inputRef:n.ref,...i,endAdornment:K(It,{children:[i.endAdornment,!!(C&&n.value)&&M(Vt,{variant:"text",color:"neutral",size:"small",sx:{borderRadius:"50%",position:"absolute",right:"2rem"},style:{padding:0},"aria-label":"Limpar",title:"Limpar",onClick:()=>{n.onChange(null),a?.(null)},children:M(ht,{icon:Tt,color:bt.neutral[100],size:"25px",removeMargin:!0})})]}),children:[h.map(t=>{let I=w(t),O=T(t),J=S?.(t);return M(vt,{value:I??O,children:K("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[J!==void 0?K("div",{style:{display:"flex",alignItems:"center"},children:[J,O]}):O,M("span",{children:R?.(t)??null})]})},I)}),c!==void 0&&K("div",{children:[M("div",{style:{padding:"8px 16px"},children:M(Ct,{})},"footer-divider"),M("div",{children:c({closeSelect:()=>y(!1)})},"footer-content")]},"footer")]},o),M(g,{name:o,control:A})]})},kt=Y(St);import{useController as wt,useFormContext as Lt}from"react-hook-form";import{Slider as Rt}from"@mui/material";import{jsx as Bt}from"react/jsx-runtime";var Et=({name:e,rules:o,defaultValue:r,shouldUnregister:l,control:d,...u})=>{let f=Lt()?.control,s=d??f;if(!s)throw new P("Slider");let{field:h}=wt({control:s,name:e,rules:o,defaultValue:r,shouldUnregister:l});return Bt(Rt,{value:h.value||u?.min||0,onChange:h.onChange,valueLabelDisplay:"auto",...u},e)},Dt=Et;import{FormControlLabel as Mt,Stack as At,Switch as Nt}from"@mui/material";import{useController as Ot,useFormContext as $t}from"react-hook-form";import{jsx as oe,jsxs as Gt}from"react/jsx-runtime";var zt=({name:e,rules:o,defaultValue:r,shouldUnregister:l,control:d,label:u,labelPlacement:f,disableIconError:s,onChange:h,...F})=>{let C=$t()?.control,m=d??C;if(!m)throw new P("Switch");let{field:c}=Ot({control:m,name:e,rules:o,defaultValue:r,shouldUnregister:l});return Gt(At,{children:[oe(Mt,{control:oe(Nt,{value:c.value??"",checked:c.value??!1,onChange:(a,p)=>{c.onChange(a,p),h?.(a,p)},...F},e),label:oe(x,{label:u}),labelPlacement:f||"end"}),oe(g,{name:e,disableIcon:s,control:m})]})},qt=zt;import{InputAdornment as Ut,Stack as _t,TextField as Ht,Tooltip as Kt}from"@mui/material";import{LIcon as ge}from"@s_mart/core";import*as ve from"@s_mart/masks";import{lineEye as Wt,lineEyeSlash as Yt,lineInfoCircle as Jt}from"@s_mart/solid-icons";import{useRef as Xt,useState as Qt}from"react";import{useController as Zt,useFormContext as jt,useFormState as er}from"react-hook-form";import{jsx as z,jsxs as Ce}from"react/jsx-runtime";var or=({name:e,rules:o,defaultValue:r,shouldUnregister:l,control:d,label:u,required:f,mask:s,variant:h="outlined",info:F,parse:C,format:m,onInputChange:c,disableIconError:a,...p})=>{let w=jt()?.control,T=d??w,R=Xt(r||void 0);if(!T)throw new P("TextField");let[S,i]=Qt(!1),V=n=>{let t=n;return t=m?.(n)??n,s?ve?.[s]?.format(t):t},A=n=>{let t=n;return t=C?.(n)??t,s?ve?.[s]?.parse(t,R.current):t},N=n=>{if(!n||s!=="porcentagem"&&s!=="porcentagem0")return;n?.stopPropagation();let t=(n?.target).value;if(t){let I=String(t);if(I.length>0){let O=I.indexOf("%");O>-1&&(n.currentTarget.selectionEnd=O)}}},{field:y}=Zt({control:T,name:e,rules:o,defaultValue:r,shouldUnregister:l}),G=er({control:T,name:e}),E=L(G.errors,e);return Ce(_t,{children:[Ce("div",{style:{display:"flex"},children:[u&&z("div",{children:z(x,{label:u,required:f})}),F&&z("div",{children:z(Kt,{title:F,placement:"top",children:z("div",{style:{width:"fit-content"},children:z(ge,{icon:Jt,color:"#757575"})})})})]}),z(Ht,{variant:h,defaultValue:r,value:V(y.value||(y.value!=0?"":y.value)),onChange:n=>{let t=A(n?.target?.value);y.onChange(t),c?.(t),R.current=n.target.value},error:!!E,...p,type:p.type==="password"?S?"text":"password":p.type,autoComplete:p.autoComplete||"off",slotProps:{input:{onKeyDown:N,inputRef:y.ref,endAdornment:p.type==="password"&&z(Ut,{position:"start",onClick:()=>i(!S),style:{cursor:"pointer"},children:z(ge,{icon:S?Wt:Yt,size:"24px",removeMargin:!0})}),...p.slotProps?.input}}},e),z(g,{name:e,disableIcon:a,control:T})]})},tr=or;import{Stack as nr,TextField as dr}from"@mui/material";import{AdapterDayjs as sr}from"@mui/x-date-pickers/AdapterDayjs";import{LocalizationProvider as pr}from"@mui/x-date-pickers/LocalizationProvider";import{TimePicker as mr}from"@mui/x-date-pickers/TimePicker";import{ptBR as ur}from"@mui/x-date-pickers/locales/ptBR";import{composeValidators as fr,time as ke}from"@s_mart/rules";import cr from"dayjs/locale/pt-br";import{memo as Fr}from"react";import{useController as yr,useFormContext as xr,useFormState as Pr}from"react-hook-form";import{styled as rr}from"@mui/material";import{IconButton as lr}from"@mui/material";import{toRem as q}from"@s_mart/utils";var ir=e=>{switch(e){case"small":return q(16);case"large":return q(24);default:return q(20)}},ar=e=>{switch(e){case"small":return`${q(2)} ${q(8)}`;case"large":return q(10);default:return`${q(6)} ${q(8)}`}},Se=rr(lr)`
115
62
  margin: 0px;
116
63
 
117
- padding: ${({size:e})=>El(e)};
118
- border-radius: 0 ${Y(4)} ${Y(4)} 0;
64
+ padding: ${({size:e})=>ar(e)};
65
+ border-radius: 0 ${q(4)} ${q(4)} 0;
119
66
 
120
67
  svg {
121
- width: ${({size:e})=>Bl(e)} !important;
68
+ width: ${({size:e})=>ir(e)} !important;
122
69
  }
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 v("TimePicker");let p=Wl({control:a,name:i}),V=D(p.errors,i),n=c?.format||"HH:mm",F=e?ql([ro(n),e]):ro(n),{field:A}=Hl({control:a,name:i,rules:F,defaultValue:o,shouldUnregister:l});return de(Nl,{dateAdapter:$l,adapterLocale:_l,localeText:zl.components.MuiLocalizationProvider.defaultProps.localeText,children:Jl(Ml,{children:[g&&de(T,{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,T as FieldLabel,Ht as Form,Ve as FormProvider,lr as RadioButton,Qt as RadioGroup,Fr as Searchable,vr as SearchableV2,Gr as Select,tl as SelectV2,dl as Slider,yl as Switch,Al as TextField,jl as TimePicker,Ce as useForm};
70
+ `;import{jsx as X,jsxs as Tr}from"react/jsx-runtime";var Vr=({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=xr()?.control,a=d??c;if(!a)throw new P("TimePicker");let p=Pr({control:a,name:l}),w=L(p.errors,l),T=s?.format||"HH:mm",R=e?fr([ke(T),e]):ke(T),{field:S}=yr({control:a,name:l,rules:R,defaultValue:o,shouldUnregister:r});return X(pr,{dateAdapter:sr,adapterLocale:cr,localeText:ur.components.MuiLocalizationProvider.defaultProps.localeText,children:Tr(nr,{children:[f&&X(x,{label:f,required:u}),X(mr,{ampm:!1,format:T,value:S.value??null,disabled:F,...s,onChange:(i,V)=>{S.onChange(i,V),s?.onChange?.(i,V)},slots:{textField:dr,openPickerButton:i=>X(Se,{...i,size:m.size})},slotProps:{textField:i=>({variant:"outlined",...i,error:!!w,...m,inputProps:{...i.inputProps,placeholder:h||i.inputProps?.placeholder},InputProps:{...i.InputProps,inputRef:V=>{S.ref(V),typeof i.inputRef=="function"&&i.inputRef(V)}}})}},l),X(g,{name:l,disableIcon:C,control:a})]})})},hr=Fr(Vr);export{_e as Checkbox,co as CreatableV2,Do as DatePicker,g as FieldError,U as FieldInfo,x as FieldLabel,Uo as Form,ie as FormProvider,tt as RadioButton,Xo as RadioGroup,mt as SearchableV2,kt as SelectV2,Dt as Slider,qt as Switch,tr as TextField,hr as TimePicker,ae as useForm};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@s_mart/form",
3
- "version": "9.2.0-beta.8",
3
+ "version": "10.0.0-beta.10",
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.1.3",
23
- "@mui/system": "^6.4.0",
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": "9.1.5-beta.3",
35
+ "@s_mart/core": "10.0.0-beta.4",
36
36
  "@s_mart/masks": "5.2.0",
37
37
  "@s_mart/rules": "5.1.2-beta.0",
38
38
  "@s_mart/tokens": "5.1.1",
39
- "@s_mart/utils": "5.3.4",
40
- "@s_mart/typed": "7.2.2"
39
+ "@s_mart/typed": "7.2.2",
40
+ "@s_mart/utils": "5.3.4"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@emotion/styled": "^11.13.0",
44
- "@mui/material": "^6.1.3",
45
- "@mui/system": "^6.4.0",
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,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.3",
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
56
  "@s_mart/tokens": "5.1.1",