@s_mart/form 9.1.4 → 9.2.0-beta.1

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,10 +1,9 @@
1
1
  import * as react_hook_form from 'react-hook-form';
2
- import { FieldValues, UseFormReturn, FormProviderProps, UseFormProps, ControllerProps, UseControllerProps } from 'react-hook-form';
2
+ import { FieldValues, UseFormReturn, FormProviderProps, UseFormProps, FieldPath, UseControllerProps, ControllerProps, FieldPathValue } from 'react-hook-form';
3
3
  import { z } from 'zod';
4
4
  import * as react from 'react';
5
- import react__default from 'react';
6
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
7
- import { TextFieldProps as TextFieldProps$1, SelectProps as SelectProps$1, AutocompleteProps as AutocompleteProps$1, CheckboxProps as CheckboxProps$1, SwitchProps as SwitchProps$1, RadioProps as RadioProps$1, RadioGroupProps as RadioGroupProps$1, SliderProps as SliderProps$1 } from '@mui/material';
6
+ import { TextFieldProps as TextFieldProps$1, SelectProps as SelectProps$1, AutocompleteProps as AutocompleteProps$1, CheckboxProps as CheckboxProps$1, SwitchProps as SwitchProps$1, RadioGroupProps as RadioGroupProps$1, RadioProps as RadioProps$1, SliderProps as SliderProps$1, AutocompleteValue, AutocompleteFreeSoloValueMapping } from '@mui/material';
8
7
  import { DatePickerProps as DatePickerProps$1, TimePickerProps as TimePickerProps$1 } from '@mui/x-date-pickers';
9
8
 
10
9
  interface IFormProps<T extends FieldValues> extends IUseFormProps<T> {
@@ -66,9 +65,8 @@ declare const useForm: <TValues extends FieldValues>({ disableDefaultValuesUpdat
66
65
 
67
66
  declare function FormProvider<TFieldValues extends FieldValues>({ children, style, onSubmit, ...methods }: IFormProviderProps<TFieldValues>): react_jsx_runtime.JSX.Element;
68
67
 
69
- type ControllerTextField = Omit<ControllerProps, 'render' | 'control'>;
70
68
  type Masks = 'cpf' | 'cnpj' | 'cpfCnpj' | 'cep' | 'telefone' | 'decimal' | 'decimal3' | 'decimal4' | 'decimal5' | 'porcentagem' | 'porcentagem0' | 'nome' | 'numero' | 'numeroPontuacao' | 'placa' | 'valor' | 'valor3' | 'valor4';
71
- type TextFieldProps = TextFieldProps$1 & ControllerTextField & {
69
+ type TextFieldProps<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = TextFieldProps$1 & UseControllerProps<TFieldValues, TFieldName> & {
72
70
  mask?: Masks;
73
71
  /**
74
72
  * @description Função que será executada quando o valor do input for alterado
@@ -77,7 +75,7 @@ type TextFieldProps = TextFieldProps$1 & ControllerTextField & {
77
75
  *
78
76
  * @example onInputChange={(values,values) => console.log({value, values})}
79
77
  */
80
- onInputChange?: (value: string, values: FieldValues) => void;
78
+ onInputChange?: (value: string) => void;
81
79
  /**
82
80
  * @param value Valor do input
83
81
  * @returns Valor formatado para o input
@@ -109,14 +107,9 @@ type TextFieldProps = TextFieldProps$1 & ControllerTextField & {
109
107
  disableIconError?: boolean;
110
108
  };
111
109
 
112
- declare const _default$6: react.MemoExoticComponent<({ name, rules, defaultValue, shouldUnregister, label, required, mask, variant, info, parse, format, onInputChange, disableIconError, ...rest }: TextFieldProps) => react_jsx_runtime.JSX.Element>;
113
-
114
- /**
115
- * @deprecated usar SelectV2
116
- */
117
- 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>;
110
+ declare const TextField: <TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ name, rules, defaultValue, shouldUnregister, control: controlFromProps, label, required, mask, variant, info, parse, format, onInputChange, disableIconError, ...rest }: TextFieldProps<TFieldValues, TFieldName>) => react_jsx_runtime.JSX.Element;
118
111
 
119
- type ControllerSelect$1 = Omit<ControllerProps, 'render' | 'control'>;
112
+ type ControllerSelect = Omit<ControllerProps, 'render' | 'control'>;
120
113
  /**
121
114
  * @deprecated
122
115
  */
@@ -134,7 +127,7 @@ type FooterProps = {
134
127
  /**
135
128
  * @deprecated
136
129
  */
137
- type SelectProps = Omit<SelectProps$1, 'onChange'> & ControllerSelect$1 & {
130
+ type SelectProps = Omit<SelectProps$1, 'onChange'> & ControllerSelect & {
138
131
  /**
139
132
  * As opções que serão renderizadas no select
140
133
  *
@@ -192,6 +185,11 @@ type SelectProps = Omit<SelectProps$1, 'onChange'> & ControllerSelect$1 & {
192
185
  clearable?: boolean;
193
186
  };
194
187
 
188
+ /**
189
+ * @deprecated usar SelectV2
190
+ */
191
+ declare const Select: react.MemoExoticComponent<({ name, rules, defaultValue, shouldUnregister, label, required, options, placeholder, clearable, disableOnChangeForm, multiple, info, footer, onChange: onChangeProp, disableIconError, variant, ...rest }: SelectProps) => react_jsx_runtime.JSX.Element>;
192
+
195
193
  type ControllerSearchable = Omit<ControllerProps, 'render' | 'control'>;
196
194
  /**
197
195
  * @deprecated usar SearchableV2
@@ -377,8 +375,7 @@ type CreatableProps = Omit<AutocompleteProps$1<CreatableOption, true, true, true
377
375
  */
378
376
  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>;
379
377
 
380
- type ControllerCheckbox = Omit<ControllerProps, 'render' | 'control'>;
381
- type CheckboxProps = CheckboxProps$1 & ControllerCheckbox & {
378
+ type CheckboxProps<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = CheckboxProps$1 & UseControllerProps<TFieldValues, TFieldName> & {
382
379
  /**
383
380
  * O nome do checkbox que será renderizado na tela
384
381
  * @default ''
@@ -405,10 +402,9 @@ type CheckboxProps = CheckboxProps$1 & ControllerCheckbox & {
405
402
  disableIconError?: boolean;
406
403
  };
407
404
 
408
- declare const Checkbox: ({ name, rules, defaultValue, shouldUnregister, label, labelPlacement, required, disableIconError, onChange: onChangeProp, ...rest }: CheckboxProps) => react_jsx_runtime.JSX.Element;
405
+ declare const Checkbox: <TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ name, rules, defaultValue, shouldUnregister, control: controlFromProps, label, labelPlacement, required, disableIconError, onChange: onChangeProp, ...rest }: CheckboxProps<TFieldValues, TFieldName>) => react_jsx_runtime.JSX.Element;
409
406
 
410
- type ControllerSwitch = Omit<ControllerProps, 'render' | 'control'>;
411
- type SwitchProps = SwitchProps$1 & ControllerSwitch & {
407
+ type SwitchProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = SwitchProps$1 & UseControllerProps<TFieldValues, TFieldName> & {
412
408
  /**
413
409
  * O nome do switch que será renderizado na tela
414
410
  * @default ''
@@ -435,31 +431,9 @@ type SwitchProps = SwitchProps$1 & ControllerSwitch & {
435
431
  disableIconError?: boolean;
436
432
  };
437
433
 
438
- declare const Switch: ({ name, rules, defaultValue, shouldUnregister, label, labelPlacement, disableIconError, onChange: onChangeProp, ...rest }: SwitchProps) => react_jsx_runtime.JSX.Element;
434
+ declare const Switch: <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>>({ name, rules, defaultValue, shouldUnregister, control: controlFromProps, label, labelPlacement, disableIconError, onChange: onChangeProp, ...rest }: SwitchProps<TFieldValues, TFieldName>) => react_jsx_runtime.JSX.Element;
439
435
 
440
- type RadioProps = RadioProps$1 & {
441
- /**
442
- * O nome do checkbox que será renderizado na tela
443
- * @default ''
444
- * @example 'Nome do checkbox'
445
- * @type React.ReactNode
446
- * @memberof RadioProps
447
- */
448
- label?: React.ReactNode;
449
- /**
450
- * Posição do label em relação ao checkbox
451
- * @default 'end'
452
- * @type 'start' | 'end' | 'top' | 'bottom'
453
- * @example
454
- * <Radio label="Radio" labelPlacement="start" />
455
- */
456
- labelPlacement?: 'start' | 'end' | 'top' | 'bottom';
457
- };
458
-
459
- declare const RadioButton: ({ label, labelPlacement, ...rest }: RadioProps) => react_jsx_runtime.JSX.Element;
460
-
461
- type ControllerRadioGroup = Omit<ControllerProps, 'render' | 'control'>;
462
- type RadioGroupProps = RadioGroupProps$1 & ControllerRadioGroup & {
436
+ type RadioGroupProps<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = RadioGroupProps$1 & UseControllerProps<TFieldValues, TFieldName> & {
463
437
  /**
464
438
  * O nome do checkbox que será renderizado na tela
465
439
  * @default ''
@@ -502,10 +476,30 @@ type RadioGroupProps = RadioGroupProps$1 & ControllerRadioGroup & {
502
476
  disableIconError?: boolean;
503
477
  };
504
478
 
505
- declare const RadioGroup: ({ name, rules, defaultValue, shouldUnregister, label, required, children, orientation, disableIconError, ...rest }: RadioGroupProps) => react_jsx_runtime.JSX.Element;
479
+ declare const RadioGroup: <TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ name, rules, defaultValue, shouldUnregister, control: controlFromProps, label, required, children, orientation, disableIconError, ...rest }: RadioGroupProps<TFieldValues, TFieldName>) => react_jsx_runtime.JSX.Element;
480
+
481
+ type RadioProps = RadioProps$1 & {
482
+ /**
483
+ * O nome do checkbox que será renderizado na tela
484
+ * @default ''
485
+ * @example 'Nome do checkbox'
486
+ * @type React.ReactNode
487
+ * @memberof RadioProps
488
+ */
489
+ label?: React.ReactNode;
490
+ /**
491
+ * Posição do label em relação ao checkbox
492
+ * @default 'end'
493
+ * @type 'start' | 'end' | 'top' | 'bottom'
494
+ * @example
495
+ * <Radio label="Radio" labelPlacement="start" />
496
+ */
497
+ labelPlacement?: 'start' | 'end' | 'top' | 'bottom';
498
+ };
499
+
500
+ declare const RadioButton: ({ label, labelPlacement, ...rest }: RadioProps) => react_jsx_runtime.JSX.Element;
506
501
 
507
- type ControllerSlider = Omit<ControllerProps, 'render' | 'control'>;
508
- type SliderProps = SliderProps$1 & ControllerSlider & {
502
+ type SliderProps<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = SliderProps$1 & UseControllerProps<TFieldValues, TFieldName> & {
509
503
  /**
510
504
  * O nome do switch que será renderizado na tela
511
505
  * @default ''
@@ -524,9 +518,9 @@ type SliderProps = SliderProps$1 & ControllerSlider & {
524
518
  labelPlacement?: 'start' | 'end' | 'top' | 'bottom';
525
519
  };
526
520
 
527
- declare const Slider: ({ name, rules, defaultValue, shouldUnregister, ...rest }: SliderProps) => react_jsx_runtime.JSX.Element;
521
+ declare const Slider: <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>>({ name, rules, defaultValue, shouldUnregister, control: controlFromProps, ...rest }: SliderProps<TFieldValues, TFieldName>) => react_jsx_runtime.JSX.Element;
528
522
 
529
- type DatePickerProps = Omit<UseControllerProps, 'control'> & Pick<TextFieldProps$1, 'label' | 'error' | 'helperText' | 'size' | 'fullWidth' | 'variant' | 'autoFocus' | 'placeholder'> & {
523
+ type DatePickerProps<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = UseControllerProps<TFieldValues, TFieldName> & Pick<TextFieldProps$1, 'label' | 'error' | 'helperText' | 'size' | 'fullWidth' | 'variant' | 'autoFocus' | 'placeholder'> & {
530
524
  datePickerProps?: Partial<DatePickerProps$1<any>>;
531
525
  /**
532
526
  * Se `true` irá adicionar um asterisco ao label do campo
@@ -550,9 +544,9 @@ type DatePickerProps = Omit<UseControllerProps, 'control'> & Pick<TextFieldProps
550
544
  disableIconError?: boolean;
551
545
  };
552
546
 
553
- declare const _default$5: react.MemoExoticComponent<({ rules, name, defaultValue, shouldUnregister, datePickerProps, label, required, placeholder, disabled, disableIconError, ...rest }: DatePickerProps) => react_jsx_runtime.JSX.Element>;
547
+ declare const _default$5: react.MemoExoticComponent<(<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ rules, name, defaultValue, shouldUnregister, control: controlFromProps, datePickerProps, label, required, placeholder, disabled, disableIconError, ...rest }: DatePickerProps<TFieldValues, TFieldName>) => react_jsx_runtime.JSX.Element)>;
554
548
 
555
- type TimePickerProps = Omit<UseControllerProps, 'control'> & Pick<TextFieldProps$1, 'label' | 'error' | 'helperText' | 'size' | 'fullWidth' | 'variant' | 'autoFocus' | 'placeholder'> & {
549
+ type TimePickerProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = UseControllerProps<TFieldValues, TFieldName> & Pick<TextFieldProps$1, 'label' | 'error' | 'helperText' | 'size' | 'fullWidth' | 'variant' | 'autoFocus' | 'placeholder'> & {
556
550
  timePickerProps?: Partial<TimePickerProps$1<any>>;
557
551
  /**
558
552
  * Se `true` irá adicionar um asterisco ao label do campo
@@ -576,7 +570,7 @@ type TimePickerProps = Omit<UseControllerProps, 'control'> & Pick<TextFieldProps
576
570
  disableIconError?: boolean;
577
571
  };
578
572
 
579
- declare const _default$4: react__default.MemoExoticComponent<({ rules, defaultValue, shouldUnregister, name, required, label, timePickerProps, placeholder, disabled, disableIconError, ...rest }: TimePickerProps) => react_jsx_runtime.JSX.Element>;
573
+ declare const _default$4: react.MemoExoticComponent<(<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>>({ rules, defaultValue, shouldUnregister, name, control: controlFromProps, required, label, timePickerProps, placeholder, disabled, disableIconError, ...rest }: TimePickerProps<TFieldValues, TFieldName>) => react_jsx_runtime.JSX.Element)>;
580
574
 
581
575
  type AutoCompleteOption = {
582
576
  key?: string | number;
@@ -615,18 +609,8 @@ type AutocompleteProps<ValueType = any> = Omit<UseControllerProps, 'control'> &
615
609
 
616
610
  declare const _default$3: react.MemoExoticComponent<({ name, defaultValue, rules, shouldUnregister, label, required, noOptionsText, placeholder, onInputChange, onChange, disableIconError, ...rest }: AutocompleteProps) => react_jsx_runtime.JSX.Element>;
617
611
 
618
- type FieldLabelProps = {
619
- label: React.ReactNode;
620
- required?: boolean;
621
- regular?: boolean;
622
- };
623
-
624
- declare const FieldLabel: ({ label, required, regular }: FieldLabelProps) => react_jsx_runtime.JSX.Element;
625
-
626
- type ConditionalArrayType<T, Multiple extends boolean | undefined = undefined> = Multiple extends true ? T[] : T;
627
-
628
- type SearchableV2Props<T extends FieldValues | string | number, Multiple extends boolean | undefined, _ValueType = unknown> = Omit<AutocompleteProps$1<T, Multiple, true, true>, 'renderInput' | 'size' | 'onInputChange' | 'onChange' | 'getOptionLabel' | 'getOptionKey' | 'defaultValue' | 'value'> & Omit<ControllerProps, 'render' | 'control'> & {
629
- options: T[];
612
+ type SearchableV2Props<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, FieldValue extends FieldPathValue<TFieldValues, TFieldName> = FieldPathValue<TFieldValues, TFieldName>, Multiple extends boolean = false, DisableClearable extends boolean = false, FreeSolo extends boolean = false, AutocompleteFieldValue extends AutocompleteValue<FieldValue, Multiple, DisableClearable, FreeSolo> = AutocompleteValue<FieldValue, Multiple, DisableClearable, FreeSolo>> = Omit<AutocompleteProps$1<FieldValue, Multiple, DisableClearable, FreeSolo>, 'renderInput' | 'size' | 'options' | 'onInputChange' | 'onChange' | 'getOptionLabel' | 'getOptionKey' | 'defaultValue' | 'value'> & UseControllerProps<TFieldValues, TFieldName> & {
613
+ options: FieldValue[];
630
614
  textFieldProps?: TextFieldProps$1;
631
615
  label?: React.ReactNode;
632
616
  required?: boolean;
@@ -648,38 +632,37 @@ type SearchableV2Props<T extends FieldValues | string | number, Multiple extends
648
632
  * montada à tela como um ícone de informação.
649
633
  */
650
634
  info?: React.ReactNode;
651
- defaultValue?: _ValueType;
652
- value?: _ValueType;
635
+ defaultValue?: AutocompleteFieldValue;
636
+ value?: AutocompleteFieldValue;
653
637
  placeholder?: string;
654
638
  onInputChange?: (value: string) => void;
655
- onChange?: (value: _ValueType | null) => void;
639
+ onChange?: (value: AutocompleteValue<FieldValue, Multiple, DisableClearable, FreeSolo>) => void;
656
640
  /**
657
641
  * Define a key unica da option
658
642
  */
659
- getOptionKey: (option: T) => string | number;
643
+ getOptionKey: (option: FieldValue | AutocompleteFreeSoloValueMapping<FreeSolo>) => string | number;
660
644
  /**
661
645
  * Define a label da option
662
646
  */
663
- getOptionLabel: (option: T) => string;
647
+ getOptionLabel: (option: FieldValue | AutocompleteFreeSoloValueMapping<FreeSolo>) => string;
664
648
  /**
665
649
  * Componente renderizado embaixo da option da listagem
666
650
  */
667
- getOptionAfterLabel?: (option: T) => string | React.ReactNode;
651
+ getOptionAfterLabel?: (option: FieldValue | AutocompleteFreeSoloValueMapping<FreeSolo>) => string | React.ReactNode;
668
652
  };
669
653
 
670
- declare const _default$2: <T extends string | number | FieldValues, Multiple extends boolean | undefined = undefined, _ValueType = ConditionalArrayType<T, Multiple>>({ name, rules, defaultValue, shouldUnregister, label, required, options, textFieldProps, noOptionsText, footer, multiple, info, placeholder, onChange: onChangeProp, onInputChange, getOptionAfterLabel, getOptionLabel, getOptionKey, ...rest }: SearchableV2Props<T, Multiple, _ValueType>) => react_jsx_runtime.JSX.Element;
654
+ declare const _default$2: <TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, FieldValue extends FieldPathValue<TFieldValues, TFieldName> = FieldPathValue<TFieldValues, TFieldName>, Multiple extends boolean = false, DisableClearable extends boolean = false, FreeSolo extends boolean = false, 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;
671
655
 
672
- type ControllerSelect = Omit<ControllerProps, 'render' | 'control'>;
673
656
  type FooterPropsV2 = {
674
657
  closeSelect: () => void;
675
658
  };
676
- type SelectV2Props<T extends FieldValues | string | number> = Omit<SelectProps$1, 'onChange' | 'multiple' | 'defaultValue' | 'variant'> & ControllerSelect & {
659
+ 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> & {
677
660
  variant?: 'filled' | 'outlined' | 'standard';
678
661
  /**
679
662
  * As opções que serão renderizadas no select
680
663
  */
681
- options: T[];
682
- onChange?: (value: T | null) => void;
664
+ options: FieldValue[];
665
+ onChange?: (value: FieldValue | null) => void;
683
666
  /**
684
667
  * Função que renderiza o footer do select (opcional) - recebe como parâmetro a função closeSelect que fecha o select
685
668
  * @param {FooterProps} props
@@ -705,29 +688,29 @@ type SelectV2Props<T extends FieldValues | string | number> = Omit<SelectProps$1
705
688
  */
706
689
  clearable?: boolean;
707
690
  placeholder?: string;
708
- defaultValue?: T;
691
+ defaultValue?: FieldPathValue<TFieldValues, TFieldName>;
709
692
  /**
710
693
  * Define a key unica da option
711
694
  */
712
- getOptionKey: (option: T) => string | number;
695
+ getOptionKey: (option: FieldPathValue<TFieldValues, TFieldName>) => string | number;
713
696
  /**
714
697
  * Define a label da option
715
698
  */
716
- getOptionLabel: (option: T) => string;
699
+ getOptionLabel: (option: FieldPathValue<TFieldValues, TFieldName>) => string;
717
700
  /**
718
701
  * Componente renderizado embaixo da option da listagem
719
702
  */
720
- getOptionAfterLabel?: (option: T) => string | React.ReactNode;
703
+ getOptionAfterLabel?: (option: FieldPathValue<TFieldValues, TFieldName>) => string | React.ReactNode;
721
704
  /**
722
705
  * Ícone renderizado ao lado da label
723
706
  */
724
- getOptionIcon?: (option: T) => React.ReactNode;
707
+ getOptionIcon?: (option: FieldPathValue<TFieldValues, TFieldName>) => React.ReactNode;
725
708
  };
726
709
 
727
- declare const _default$1: <T extends string | number | FieldValues>({ name, rules, defaultValue, shouldUnregister, label, required, options, placeholder, clearable, info, footer, onChange: onChangeProp, variant, getOptionKey, getOptionLabel, getOptionAfterLabel, getOptionIcon, ...rest }: SelectV2Props<T>) => react_jsx_runtime.JSX.Element;
710
+ declare const _default$1: <TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>(props: SelectV2Props<TFieldValues, TFieldName>) => react_jsx_runtime.JSX.Element;
728
711
 
729
- type CreatableV2Props<T extends FieldValues | string | number, Multiple extends boolean | undefined, _ValueType = unknown> = Omit<AutocompleteProps$1<T, Multiple, true, true>, 'renderInput' | 'size' | 'onInputChange' | 'onChange' | 'getOptionLabel' | 'getOptionKey' | 'defaultValue' | 'value'> & Omit<ControllerProps, 'render' | 'control'> & {
730
- options: T[];
712
+ type CreatableV2Props<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, FieldValue extends FieldPathValue<TFieldValues, TFieldName> = 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> = FieldValue> = Omit<AutocompleteProps$1<FieldValue, Multiple, DisableClearable, FreeSolo>, 'renderInput' | 'options' | 'size' | 'onInputChange' | 'onChange' | 'getOptionLabel' | 'getOptionKey' | 'defaultValue' | 'value'> & UseControllerProps<TFieldValues, TFieldName> & {
713
+ options: FieldValue[];
731
714
  textFieldProps?: TextFieldProps$1;
732
715
  label?: React.ReactNode;
733
716
  required?: boolean;
@@ -758,7 +741,7 @@ type CreatableV2Props<T extends FieldValues | string | number, Multiple extends
758
741
  * @type {(value) => void}
759
742
  * @memberof CreatableV2Props
760
743
  */
761
- onEditOption?: (value: _ValueType) => void;
744
+ onEditOption?: (value: AutocompleteFieldValue) => void;
762
745
  /**
763
746
  * Componente que renderiza no footer do searchable (opcional)
764
747
  * @example
@@ -773,22 +756,23 @@ type CreatableV2Props<T extends FieldValues | string | number, Multiple extends
773
756
  */
774
757
  info?: React.ReactNode;
775
758
  onInputChange?: (value: string) => void;
776
- onChange?: (value: _ValueType | null) => void;
759
+ onChange?: (value: AutocompleteValue<FieldValue, Multiple, DisableClearable, FreeSolo>) => void;
777
760
  placeholder?: string;
778
761
  /**
779
762
  * Define a key unica da option
780
763
  */
781
- getOptionKey: (option: T) => string | number;
764
+ getOptionKey: (option: FieldValue | AutocompleteFreeSoloValueMapping<FreeSolo>) => string | number;
782
765
  /**
783
766
  * Define a label da option
784
767
  */
785
- getOptionLabel: (option: T) => string;
768
+ getOptionLabel: (option: FieldValue | AutocompleteFreeSoloValueMapping<FreeSolo>) => string;
786
769
  /**
787
770
  * Componente renderizado embaixo da option da listagem
788
771
  */
789
- getOptionAfterLabel?: (option: T) => string | React.ReactNode;
772
+ getOptionAfterLabel?: (option: FieldValue) => string | React.ReactNode;
790
773
  };
791
774
 
792
- declare const _default: <T extends string | number | FieldValues, Multiple extends boolean | undefined = undefined, _ValueType = ConditionalArrayType<T, Multiple>>({ name, rules, defaultValue, shouldUnregister, label, required, options, footer, showCreatableButton, showEditableButton, onEditOption, onCreateOption, getOptionKey, getOptionLabel, getOptionAfterLabel, textFieldProps, multiple, info, noOptionsText, onChange: onChangeProp, onInputChange, placeholder, ...rest }: CreatableV2Props<T, Multiple, _ValueType>) => react_jsx_runtime.JSX.Element;
775
+ declare function CreatableV2<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, FieldValue extends FieldPathValue<TFieldValues, TFieldName> = FieldPathValue<TFieldValues, TFieldName>, AutocompleteFieldValue extends AutocompleteValue<FieldValue, Multiple, DisableClearable, FreeSolo> = FieldValue, Multiple extends boolean | undefined = undefined, DisableClearable extends boolean | undefined = undefined, FreeSolo extends boolean | undefined = undefined>(props: CreatableV2Props<TFieldValues, TFieldName, FieldValue, Multiple, DisableClearable, FreeSolo, AutocompleteFieldValue>): react_jsx_runtime.JSX.Element;
776
+ declare const _default: typeof CreatableV2;
793
777
 
794
- export { _default$3 as Autocomplete, type AutocompleteProps, Checkbox, type CheckboxProps, Creatable, type CreatableOption, type CreatableProps, _default as CreatableV2, type CreatableV2Props, _default$5 as DatePicker, type DatePickerProps, FieldLabel, type FieldLabelProps, type FooterProps, type FooterPropsV2, Form, FormProvider, type IFormProps, type IFormProviderProps, type IUseFormProps, RadioButton, RadioGroup, type RadioGroupProps, type RadioProps, Searchable, type SearchableOption, type SearchableProps, _default$2 as SearchableV2, type SearchableV2Props, Select, type SelectOption, type SelectProps, _default$1 as SelectV2, type SelectV2Props, Slider, type SliderProps, Switch, type SwitchProps, _default$6 as TextField, type TextFieldProps, _default$4 as TimePicker, type TimePickerProps, useForm };
778
+ export { _default$3 as Autocomplete, type AutocompleteProps, Checkbox, type CheckboxProps, Creatable, type CreatableProps, _default as CreatableV2, type CreatableV2Props, _default$5 as DatePicker, type DatePickerProps, Form, FormProvider, type IFormProps, type IFormProviderProps, type IUseFormProps, RadioButton, RadioGroup, type RadioGroupProps, type RadioProps, Searchable, type SearchableProps, _default$2 as SearchableV2, type SearchableV2Props, Select, type SelectProps, _default$1 as SelectV2, type SelectV2Props, Slider, type SliderProps, Switch, type SwitchProps, TextField, type TextFieldProps, _default$4 as TimePicker, type TimePickerProps, useForm };
package/dist/index.mjs CHANGED
@@ -1,11 +1,11 @@
1
- import{FormProvider as io}from"react-hook-form";import{jsx as ke}from"react/jsx-runtime";function lo({children:e,style:t,onSubmit:i,...n}){return ke(io,{...n,children:ke("form",{onSubmit:l=>{l.preventDefault(),l.stopPropagation(),i(l)},style:t,children:e})})}var Fe=lo;import{useEffect as no}from"react";import{useForm as ao}from"react-hook-form";import{zodResolver as so}from"@hookform/resolvers/zod";var po=({disableDefaultValuesUpdate:e,onSubmit:t,...i})=>{let n=ao({...i,resolver:i.schema&&so(i.schema)});return no(()=>{e||n.reset(i.defaultValues)},[i.defaultValues,n.reset]),{...n,onSubmit:n.handleSubmit(l=>t(l,n))}},ge=po;import{jsx as fo}from"react/jsx-runtime";function mo({children:e,style:t,...i}){let n=ge(i);return fo(Fe,{...n,style:t,children:typeof e=="function"?e(n):e})}var uo=mo;import{Grid as he,InputAdornment as vo,TextField as Po,Tooltip as Co}from"@mui/material";import{LIcon as we}from"@s_mart/core";import*as Re from"@s_mart/masks";import{lineEye as To,lineEyeSlash as So,lineInfoCircle as ko}from"@s_mart/solid-icons";import{memo as Io,useRef as Vo,useState as wo}from"react";import{Controller as Ro,useFormContext as Eo}from"react-hook-form";import{Indicator as co}from"@s_mart/core";import{useFormContext as yo}from"react-hook-form";var E=(e,t)=>t.replace(/[[\]]/g,"").split(".").reduce((n,l)=>n?.[l],e);import{jsx as bo}from"react/jsx-runtime";var xo=({name:e,disableIcon:t})=>{let i=yo(),n=E(i?.formState?.errors,e);return n?bo(co,{severity:"error",icon:t?!1:void 0,children:n?.message}):null},k=xo;import{Typography as Ie}from"@mui/material";import{toRem as Fo}from"@s_mart/utils";import{jsx as Ve,jsxs as ho}from"react/jsx-runtime";var go=({label:e,required:t,regular:i})=>ho("span",{style:{display:"flex",alignItems:"center",gap:Fo(2)},children:[Ve(Ie,{variant:"caption",style:{display:"flex",alignItems:"center"},sx:{fontWeight:i?400:700},children:e}),t&&Ve(Ie,{variant:"caption",color:"error",sx:{fontWeight:900},children:"*"})]}),P=go;import{jsx as z,jsxs as Ee}from"react/jsx-runtime";var Ao=({name:e,rules:t,defaultValue:i,shouldUnregister:n,label:l,required:g,mask:c,variant:y="outlined",info:C,parse:m,format:u,onInputChange:d,disableIconError:x,...a})=>{let h=Eo(),F=Vo(i||void 0);if(!h)throw new Error("Para usar o <TextField /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let[p,b]=wo(!1),s=r=>{let o=r;return o=u?.(r)??r,c?Re?.[c]?.format(o):o},f=r=>{let o=r;return o=m?.(r)??o,c?Re?.[c]?.parse(o,F.current):o},w=r=>{if(!r||c!=="porcentagem"&&c!=="porcentagem0")return;r?.stopPropagation();let o=(r?.target).value;if(o){let T=String(o);if(T.length>0){let S=T.indexOf("%");S>-1&&(r.currentTarget.selectionEnd=S)}}},$=E(h.formState.errors,e);return z(Ro,{control:h.control,name:e,rules:t,defaultValue:i,shouldUnregister:n,render:({field:{value:r,onChange:o,ref:T}})=>Ee(he,{sx:{display:"flex",flexDirection:"column"},children:[Ee("div",{style:{display:"flex"},children:[l&&z(he,{item:!0,children:z(P,{label:l,required:g})}),C&&z(he,{item:!0,children:z(Co,{title:C,placement:"top",children:z("div",{style:{width:"fit-content"},children:z(we,{icon:ko,color:"#757575"})})})})]}),z(Po,{variant:y,defaultValue:i,value:s(r||(r!=0?"":r)),onChange:S=>{let _=f(S?.target?.value);o(_),d?.(_,h.getValues()),F.current=S.target.value},error:!!$,...a,type:a.type==="password"?p?"text":"password":a.type,autoComplete:a.autoComplete||"off",slotProps:{input:{onKeyDown:w,inputRef:T,endAdornment:a.type==="password"&&z(vo,{position:"start",onClick:()=>b(!p),style:{cursor:"pointer"},children:z(we,{icon:p?To:So,size:"24px",removeMargin:!0})}),...a.InputProps}}},e),z(k,{name:e,disableIcon:x})]})})},Bo=Io(Ao);import{Divider as Lo,Grid as J,MenuItem as Go,Select as Mo,Tooltip as $o,useTheme as Do}from"@mui/material";import{IconButton as qo,LIcon as Ae}from"@s_mart/core";import{lineTimes as _o}from"@s_mart/regular-icons";import{lineInfoCircle as zo}from"@s_mart/solid-icons";import{colorPalette as Oo}from"@s_mart/tokens";import{memo as No,useState as Uo}from"react";import{Controller as jo,useFormContext as Ho}from"react-hook-form";import{Fragment as Yo,jsx as M,jsxs as ne}from"react/jsx-runtime";var Be=No(({name:e,rules:t,defaultValue:i,shouldUnregister:n,label:l,required:g,options:c,placeholder:y,clearable:C,disableOnChangeForm:m=!1,multiple:u,info:d,footer:x,onChange:a,disableIconError:h,variant:F="outlined",...p})=>{let b=Ho(),{palette:s}=Do(),[f,w]=Uo(!1);if(!b)throw new Error("Para usar o <Select /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let $=E(b.formState.errors,e);return M(jo,{control:b.control,name:e,rules:t,defaultValue:i,shouldUnregister:n,render:({field:{value:r,onChange:o,ref:T}})=>ne(J,{sx:{display:"flex",flexDirection:"column"},children:[ne("div",{style:{display:"flex"},children:[l&&M(J,{item:!0,children:M(P,{label:l,required:g})}),d&&M(J,{item:!0,children:M($o,{title:d,placement:"top",children:M("div",{style:{width:"fit-content"},children:M(Ae,{icon:zo,color:"#757575"})})})})]}),ne(Mo,{open:f,onOpen:()=>w(!0),onClose:()=>w(!1),displayEmpty:!!y,variant:F,autoComplete:"off",value:r?r||"":u?[]:"",renderValue:S=>{if(S.label)return S.label;if(y)return M("p",{style:{color:s.grey[400]},children:y})},multiple:u,onChange:S=>{!m&&o(S.target.value),a&&a(S.target.value,b.getValues())},error:!!$,size:p.size||"medium",inputRef:T,...p,endAdornment:ne(Yo,{children:[p.endAdornment,!!(C&&r)&&M(qo,{variant:"text",color:"neutral",size:"small",sx:{borderRadius:"50%",position:"absolute",right:"2rem"},style:{padding:0},"aria-label":"Clear",title:"Clear",onClick:()=>{!m&&o(null),a&&a(null,b.getValues())},children:M(Ae,{icon:_o,color:Oo.neutral[100],size:"25px",removeMargin:!0})})]}),children:[c?.map((S,_)=>M(Go,{value:S,children:ne(J,{container:!0,direction:"column",children:[M(J,{item:!0,children:S.label}),S.afterLabel&&M(J,{item:!0,children:S.afterLabel})]})},_)),x&&[M(J,{sx:{px:2,py:1},children:M(Lo,{})},"footer-divider"),M("div",{children:x({closeSelect:()=>w(!1)})},"footer-content")]]},e),M(k,{name:e,disableIcon:h})]})})});Be.displayName="Select";var Wo=Be;import{Autocomplete as Jo,Divider as Le,Grid as W,TextField as Ko,Tooltip as Xo}from"@mui/material";import{LIcon as Qo}from"@s_mart/core";import{lineInfoCircle as Zo}from"@s_mart/solid-icons";import{colorPalette as er}from"@s_mart/tokens";import{forwardRef as or,memo as rr}from"react";import{Controller as tr,useFormContext as ir}from"react-hook-form";import{Fragment as de,jsx as G,jsxs as K}from"react/jsx-runtime";import{createElement as Ge}from"react";var Me=rr(({name:e,rules:t,defaultValue:i,shouldUnregister:n,label:l,required:g,options:c,textFieldProps:y,noOptionsText:C,footer:m,multiple:u,info:d,placeholder:x,onChange:a,onInputChange:h,disableIconError:F,...p})=>{let b=ir();if(!b)throw new Error("Para usar o <Searchable /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let s=E(b.formState.errors,e);return G(tr,{control:b.control,name:e,rules:t,defaultValue:i,shouldUnregister:n,render:({field:{onChange:f,value:w,ref:$}})=>K(W,{sx:{display:"flex",flexDirection:"column"},children:[K("div",{style:{display:"flex"},children:[l&&G(W,{item:!0,children:G(P,{label:l,required:g})}),d&&G(W,{item:!0,children:G(Xo,{title:d,placement:"top",children:G("div",{style:{width:"fit-content"},children:G(Qo,{icon:Zo,color:"#757575"})})})})]}),G(Jo,{onChange:(r,o)=>{f(o),a?.(o,b.getValues())},onInputChange:(r,o,T)=>{T==="input"&&setTimeout(()=>{h?.(o,b.getValues())},0)},slotProps:{...p.slotProps||{},paper:{...(p.slotProps||{}).paper||{},sx:{border:`1px solid ${er.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}},listbox:{component:or(function(o,T){return K(de,{children:[G("ul",{...o,ref:T}),!!m&&G("div",{...o,children:K(de,{children:[G(W,{sx:{px:2,py:1},children:G(Le,{})}),m]})},"searchable-footer")]})})}},value:w||(u?[]:null),options:c,multiple:u,readOnly:p.disabled,noOptionsText:K(de,{children:[C||"Nenhum resultado encontrado",m?K(de,{children:[G(W,{sx:{py:1},children:G(Le,{})}),m]}):null]}),isOptionEqualToValue:(r,o)=>typeof r=="string"&&typeof o=="string"?r===o:typeof r=="object"&&typeof o=="object"?typeof r.value=="object"&&typeof o.value=="object"&&r.key!==void 0&&o.key!==void 0?r.key===o.key:r.value===o.value:!1,renderOption:(r,o)=>typeof o=="object"?Ge("li",{...r,key:o.key||o.value},K(W,{container:!0,direction:"column",children:[G(W,{item:!0,children:o.label}),o.afterLabel&&G(W,{item:!0,children:o.afterLabel})]})):Ge("li",{...r,key:o},o),...p,renderInput:r=>G(Ko,{error:!!s,placeholder:x,...r,...y,inputRef:$})},e),G(k,{name:e,disableIcon:F})]})})});Me.displayName="Searchable";var lr=Me;import{forwardRef as sr,memo as dr}from"react";import{Controller as pr,useFormContext as mr}from"react-hook-form";import{isObject as ur,isEmpty as fr}from"lodash-es";import{Grid as X,Autocomplete as cr,TextField as yr,Tooltip as xr,Divider as br}from"@mui/material";import{LIcon as me,Button as Fr}from"@s_mart/core";import{colorPalette as gr}from"@s_mart/tokens";import{linePlus as _e,linePen as hr,lineInfoCircle as vr}from"@s_mart/solid-icons";import{toRem as ze}from"@s_mart/utils";import{css as $e}from"@emotion/react";import{styled as nr}from"@mui/material";import{toRem as pe}from"@s_mart/utils";var De=$e`
1
+ import{FormProvider as ao}from"react-hook-form";import{jsx as Ie}from"react/jsx-runtime";function so({children:e,style:o,onSubmit:l,...i}){return Ie(ao,{...i,children:Ie("form",{onSubmit:d=>{d.preventDefault(),d.stopPropagation(),l(d)},style:o,children:e})})}var be=so;import{useEffect as po}from"react";import{useForm as mo}from"react-hook-form";import{zodResolver as uo}from"@hookform/resolvers/zod";var co=({disableDefaultValuesUpdate:e,onSubmit:o,...l})=>{let i=mo({...l,resolver:l.schema&&uo(l.schema)});return po(()=>{e||i.reset(l.defaultValues)},[l.defaultValues,i.reset]),{...i,onSubmit:i.handleSubmit(d=>o(d,i))}},he=co;import{jsx as yo}from"react/jsx-runtime";function fo({children:e,style:o,...l}){let i=he(l);return yo(be,{...i,style:o,children:typeof e=="function"?e(i):e})}var Fo=fo;import{InputAdornment as vo,Stack as To,TextField as So,Tooltip as ko}from"@mui/material";import{LIcon as Le}from"@s_mart/core";import*as Re from"@s_mart/masks";import{lineEye as Io,lineEyeSlash as wo,lineInfoCircle as Ao}from"@s_mart/solid-icons";import{useRef as Lo,useState as Ro}from"react";import{useController as Do,useFormContext as Bo,useFormState as Eo}from"react-hook-form";import{Indicator as xo}from"@s_mart/core";import{useFormState as bo}from"react-hook-form";var D=(e,o)=>o.replace(/[[\]]/g,"").split(".").reduce((i,d)=>i?.[d],e);import{jsx as Po}from"react/jsx-runtime";var ho=({name:e,disableIcon:o,control:l})=>{let i=bo({control:l,name:e}),d=D(i?.errors,e);return d?Po(xo,{severity:"error",icon:o?!1:void 0,children:d?.message}):null},I=ho;import{Typography as we}from"@mui/material";import{toRem as go}from"@s_mart/utils";import{jsx as Ae,jsxs as Co}from"react/jsx-runtime";var Vo=({label:e,required:o,regular:l})=>Co("span",{style:{display:"flex",alignItems:"center",gap:go(2)},children:[Ae(we,{variant:"caption",style:{display:"flex",alignItems:"center"},sx:{fontWeight:l?400:700},children:e}),o&&Ae(we,{variant:"caption",color:"error",sx:{fontWeight:900},children:"*"})]}),S=Vo;var v=class extends Error{constructor(o){super(`O componente ${o} precisa de um control para funcionar. Passe o control como prop ou coloque o componente dentro de um <Form />`),this.name="FormComponentPrecisaDeControl"}};import{jsx as H,jsxs as De}from"react/jsx-runtime";var Mo=({name:e,rules:o,defaultValue:l,shouldUnregister:i,control:d,label:P,required:g,mask:f,variant:T="outlined",info:x,parse:C,format:m,onInputChange:u,disableIconError:a,...p})=>{let V=Bo()?.control,n=d??V,F=Lo(l||void 0);if(!n)throw new v("TextField");let[L,r]=Ro(!1),y=c=>{let t=c;return t=m?.(c)??c,f?Re?.[f]?.format(t):t},G=c=>{let t=c;return t=C?.(c)??t,f?Re?.[f]?.parse(t,F.current):t},b=c=>{if(!c||f!=="porcentagem"&&f!=="porcentagem0")return;c?.stopPropagation();let t=(c?.target).value;if(t){let k=String(t);if(k.length>0){let z=k.indexOf("%");z>-1&&(c.currentTarget.selectionEnd=z)}}},{field:s}=Do({control:n,name:e,rules:o,defaultValue:l,shouldUnregister:i}),w=Eo({control:n,name:e}),A=D(w.errors,e);return De(To,{children:[De("div",{style:{display:"flex"},children:[P&&H("div",{children:H(S,{label:P,required:g})}),x&&H("div",{children:H(ko,{title:x,placement:"top",children:H("div",{style:{width:"fit-content"},children:H(Le,{icon:Ao,color:"#757575"})})})})]}),H(So,{variant:T,defaultValue:l,value:y(s.value||(s.value!=0?"":s.value)),onChange:c=>{let t=G(c?.target?.value);s.onChange(t),u?.(t),F.current=c.target.value},error:!!A,...p,type:p.type==="password"?L?"text":"password":p.type,autoComplete:p.autoComplete||"off",slotProps:{input:{onKeyDown:b,inputRef:s.ref,endAdornment:p.type==="password"&&H(vo,{position:"start",onClick:()=>r(!L),style:{cursor:"pointer"},children:H(Le,{icon:L?Io:wo,size:"24px",removeMargin:!0})}),...p.InputProps}}},e),H(I,{name:e,disableIcon:a,control:n})]})},$o=Mo;import{Divider as No,Grid as Q,MenuItem as Oo,Select as Go,Tooltip as zo,useTheme as qo}from"@mui/material";import{IconButton as _o,LIcon as Be}from"@s_mart/core";import{lineTimes as Uo}from"@s_mart/regular-icons";import{lineInfoCircle as Ho}from"@s_mart/solid-icons";import{colorPalette as Ko}from"@s_mart/tokens";import{memo as Wo,useState as Yo}from"react";import{Controller as jo,useFormContext as Jo}from"react-hook-form";import{Fragment as Qo,jsx as O,jsxs as ae}from"react/jsx-runtime";var Ee=Wo(({name:e,rules:o,defaultValue:l,shouldUnregister:i,label:d,required:P,options:g,placeholder:f,clearable:T,disableOnChangeForm:x=!1,multiple:C,info:m,footer:u,onChange:a,disableIconError:p,variant:V="outlined",...n})=>{let F=Jo(),{palette:L}=qo(),[r,y]=Yo(!1);if(!F)throw new v("Select");let G=D(F.formState.errors,e);return O(jo,{control:F.control,name:e,rules:o,defaultValue:l,shouldUnregister:i,render:({field:{value:b,onChange:s,ref:w}})=>ae(Q,{sx:{display:"flex",flexDirection:"column"},children:[ae("div",{style:{display:"flex"},children:[d&&O(Q,{item:!0,children:O(S,{label:d,required:P})}),m&&O(Q,{item:!0,children:O(zo,{title:m,placement:"top",children:O("div",{style:{width:"fit-content"},children:O(Be,{icon:Ho,color:"#757575"})})})})]}),ae(Go,{open:r,onOpen:()=>y(!0),onClose:()=>y(!1),displayEmpty:!!f,variant:V,autoComplete:"off",value:b?b||"":C?[]:"",renderValue:A=>{if(A.label)return A.label;if(f)return O("p",{style:{color:L.grey[400]},children:f})},multiple:C,onChange:A=>{!x&&s(A.target.value),a&&a(A.target.value,F.getValues())},error:!!G,size:n.size||"medium",inputRef:w,...n,endAdornment:ae(Qo,{children:[n.endAdornment,!!(T&&b)&&O(_o,{variant:"text",color:"neutral",size:"small",sx:{borderRadius:"50%",position:"absolute",right:"2rem"},style:{padding:0},"aria-label":"Clear",title:"Clear",onClick:()=>{!x&&s(null),a&&a(null,F.getValues())},children:O(Be,{icon:Uo,color:Ko.neutral[100],size:"25px",removeMargin:!0})})]}),children:[g?.map((A,c)=>O(Oo,{value:A,children:ae(Q,{container:!0,direction:"column",children:[O(Q,{item:!0,children:A.label}),A.afterLabel&&O(Q,{item:!0,children:A.afterLabel})]})},c)),u&&[O(Q,{sx:{px:2,py:1},children:O(No,{})},"footer-divider"),O("div",{children:u({closeSelect:()=>y(!1)})},"footer-content")]]},e),O(I,{name:e,disableIcon:p,control:F.control})]})})});Ee.displayName="Select";var Xo=Ee;import{Autocomplete as Zo,Divider as Me,Grid as j,TextField as et,Tooltip as ot}from"@mui/material";import{LIcon as tt}from"@s_mart/core";import{lineInfoCircle as rt}from"@s_mart/solid-icons";import{colorPalette as lt}from"@s_mart/tokens";import{forwardRef as it,memo as nt}from"react";import{Controller as at,useFormContext as st}from"react-hook-form";import{Fragment as de,jsx as N,jsxs as Z}from"react/jsx-runtime";import{createElement as $e}from"react";var Ne=nt(({name:e,rules:o,defaultValue:l,shouldUnregister:i,label:d,required:P,options:g,textFieldProps:f,noOptionsText:T,footer:x,multiple:C,info:m,placeholder:u,onChange:a,onInputChange:p,disableIconError:V,...n})=>{let F=st();if(!F)throw new v("Searchable");let L=D(F.formState.errors,e);return N(at,{control:F.control,name:e,rules:o,defaultValue:l,shouldUnregister:i,render:({field:{onChange:r,value:y,ref:G}})=>Z(j,{sx:{display:"flex",flexDirection:"column"},children:[Z("div",{style:{display:"flex"},children:[d&&N(j,{item:!0,children:N(S,{label:d,required:P})}),m&&N(j,{item:!0,children:N(ot,{title:m,placement:"top",children:N("div",{style:{width:"fit-content"},children:N(tt,{icon:rt,color:"#757575"})})})})]}),N(Zo,{onChange:(b,s)=>{r(s),a?.(s,F.getValues())},onInputChange:(b,s,w)=>{w==="input"&&setTimeout(()=>{p?.(s,F.getValues())},0)},slotProps:{...n.slotProps||{},paper:{...(n.slotProps||{}).paper||{},sx:{border:`1px solid ${lt.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}},listbox:{component:it(function(s,w){return Z(de,{children:[N("ul",{...s,ref:w}),!!x&&N("div",{...s,children:Z(de,{children:[N(j,{sx:{px:2,py:1},children:N(Me,{})}),x]})},"searchable-footer")]})})}},value:y||(C?[]:null),options:g,multiple:C,readOnly:n.disabled,noOptionsText:Z(de,{children:[T||"Nenhum resultado encontrado",x?Z(de,{children:[N(j,{sx:{py:1},children:N(Me,{})}),x]}):null]}),isOptionEqualToValue:(b,s)=>typeof b=="string"&&typeof s=="string"?b===s:typeof b=="object"&&typeof s=="object"?typeof b.value=="object"&&typeof s.value=="object"&&b.key!==void 0&&s.key!==void 0?b.key===s.key:b.value===s.value:!1,renderOption:(b,s)=>typeof s=="object"?$e("li",{...b,key:s.key||s.value},Z(j,{container:!0,direction:"column",children:[N(j,{item:!0,children:s.label}),s.afterLabel&&N(j,{item:!0,children:s.afterLabel})]})):$e("li",{...b,key:s},s),...n,renderInput:b=>N(et,{error:!!L,placeholder:u,...b,...f,inputRef:G})},e),N(I,{name:e,disableIcon:V,control:F.control})]})})});Ne.displayName="Searchable";var dt=Ne;import{forwardRef as ut,memo as ct}from"react";import{Controller as ft,useFormContext as Ft}from"react-hook-form";import{isObject as yt,isEmpty as xt}from"lodash-es";import{Grid as ee,Autocomplete as bt,TextField as ht,Tooltip as Pt,Divider as gt}from"@mui/material";import{LIcon as me,Button as Vt}from"@s_mart/core";import{colorPalette as Ct}from"@s_mart/tokens";import{linePlus as qe,linePen as vt,lineInfoCircle as Tt}from"@s_mart/solid-icons";import{toRem as _e}from"@s_mart/utils";import{css as Oe}from"@emotion/react";import{styled as pt}from"@mui/material";import{toRem as pe}from"@s_mart/utils";var Ge=Oe`
2
2
  display: flex;
3
3
  align-items: center;
4
4
  justify-content: center;
5
- `,ar=e=>$e`
5
+ `,mt=e=>Oe`
6
6
  .creatable,
7
7
  .editable {
8
- ${De}
8
+ ${Ge}
9
9
 
10
10
  .divider {
11
11
  width: 1px;
@@ -31,14 +31,14 @@ import{FormProvider as io}from"react-hook-form";import{jsx as ke}from"react/jsx-
31
31
  }
32
32
  }
33
33
  }
34
- `,qe=nr("div")`
34
+ `,ze=pt("div")`
35
35
  display: flex;
36
36
 
37
37
  div.endAdornments {
38
38
  position: absolute;
39
39
  right: 0;
40
40
 
41
- ${De}
41
+ ${Ge}
42
42
  }
43
43
 
44
44
  .MuiAutocomplete-endAdornment {
@@ -50,37 +50,37 @@ import{FormProvider as io}from"react-hook-form";import{jsx as ke}from"react/jsx-
50
50
  transform: translate(0, 0);
51
51
  }
52
52
 
53
- ${({hideAddButton:e,theme:t})=>!e&&ar(t)}
54
- `;import{Fragment as ve,jsx as I,jsxs as U}from"react/jsx-runtime";import{createElement as Oe}from"react";var Ne=dr(({name:e,rules:t,defaultValue:i,shouldUnregister:n,label:l,required:g,options:c,editable:y,footer:C,onEditOption:m,onCreateOption:u,textFieldProps:d,hideAddButton:x,multiple:a,info:h,onChange:F,onInputChange:p,placeholder:b,disableIconError:s,...f})=>{let w=mr();if(!w)throw new Error("Para usar o <Creatable /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let $=E(w.formState.errors,e),r=x||f.disabled,o=R=>{let D=0;return d?.InputProps||(D+=2.5),r||(D+=2.56,T(R)&&(D+=2.56)),!f.disableClearable&&!f.disabled&&(D+=1.3),D+"rem"},T=R=>f.disabled?!1:y&&ur(R)&&!fr(R);console.warn=()=>{};let S=R=>{u?u(R):console.error("onCreateOption n\xE3o foi definido")},_=R=>{m?m(R):console.error("onEditOption n\xE3o foi definido")};return I(pr,{control:w.control,name:e,rules:t,defaultValue:i,shouldUnregister:n,render:({field:{value:R,onChange:D,ref:be}})=>{let ie=R?.label||R?.value||R;return U(X,{sx:{display:"flex",flexDirection:"column"},children:[U("div",{style:{display:"flex"},children:[l&&I(X,{item:!0,children:I(P,{label:l,required:g})}),h&&I(X,{item:!0,children:I(xr,{title:h,placement:"top",children:I("div",{style:{width:"fit-content"},children:I(me,{icon:vr,color:"#757575"})})})})]}),I(qe,{hideAddButton:r,children:I(cr,{fullWidth:!0,onChange:(A,v)=>{D(v),F?.(v,w.getValues())},onInputChange:(A,v,le)=>{le==="input"&&setTimeout(()=>{p?.(v,w.getValues())},0)},slotProps:{...f.slotProps||{},paper:{...(f.slotProps||{}).paper||{},sx:{border:`1px solid ${gr.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}},listbox:{component:sr(function(v,le){return U(ve,{children:[I("ul",{...v,ref:le}),!!C&&I("div",{...v,children:U(ve,{children:[I(X,{sx:{px:2,py:1},children:I(br,{})}),C]})},"creatable-footer")]})})}},options:c,value:R||(a?[]:null),multiple:a,readOnly:f.disabled,noOptionsText:r?void 0:U(Fr,{sx:{justifyContent:"flex-start",padding:`${ze(6)} ${ze(-16)}`,margin:0},fullWidth:!0,onClick:()=>S(R),variant:"text",startIcon:I(me,{icon:_e}),children:["Adicionar ",ie&&`"${ie}"`]}),isOptionEqualToValue:(A,v)=>v?typeof A=="string"&&typeof v=="string"?A===v:typeof A=="object"&&typeof v=="object"?typeof A.value=="object"&&typeof v.value=="object"&&A.key!==void 0&&v.key!==void 0?A.key===v.key:A.value===v.value:typeof A=="object"&&typeof v=="string":!1,renderOption:(A,v)=>typeof v=="object"?Oe("li",{...A,key:v.key||v.value},U(X,{container:!0,direction:"column",children:[I(X,{item:!0,children:v.label}),v.afterLabel&&I(X,{item:!0,children:v.afterLabel})]})):Oe("li",{...A,key:v},v),...f,sx:{"& div.MuiInputBase-root":{paddingRight:`${o(R)} !important`},...f.sx},renderInput:A=>I(yr,{placeholder:b,...A,error:!!$,...d,slotProps:{input:{...A.InputProps,inputRef:be,endAdornment:U("div",{className:"endAdornments",children:[A.InputProps.endAdornment,!r&&U(ve,{children:[T(R)?U("div",{className:"editable",children:[I("div",{className:"divider"}),I("div",{className:"button",onClick:()=>_(R),children:I(me,{icon:hr,size:"24px",removeMargin:!0})})]}):null,U("div",{className:"creatable",children:[I("div",{className:"divider"}),I("div",{className:"button",onClick:()=>S(R),children:I(me,{icon:_e,size:"24px",removeMargin:!0})})]})]})]})}}})},e)}),I(k,{name:e,disableIcon:s})]})}})});Ne.displayName="Creatable";var Pr=Ne;import{useController as Cr,useFormContext as Tr}from"react-hook-form";import{Checkbox as Sr,FormControlLabel as kr}from"@mui/material";import{jsx as ue,jsxs as wr}from"react/jsx-runtime";var Ir=({name:e,rules:t,defaultValue:i,shouldUnregister:n,label:l,labelPlacement:g,required:c,disableIconError:y,onChange:C,...m})=>{let u=Tr();if(!u)throw new Error("Para usar o <Checkbox /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let{field:d}=Cr({control:u.control,name:e,rules:t,defaultValue:i,shouldUnregister:n});return wr("span",{children:[ue(kr,{control:ue(Sr,{checked:!!d.value,value:d.value??"",defaultValue:d.value,onChange:(x,a)=>{d.onChange(x,a),C?.(x,a)},...m},e),label:ue(P,{label:l,required:c,regular:!0}),labelPlacement:g||"end"}),ue(k,{name:e,disableIcon:y})]})},Vr=Ir;import{FormControlLabel as Rr,Grid as Er,Switch as Ar}from"@mui/material";import{Controller as Br,useFormContext as Lr}from"react-hook-form";import{jsx as ae,jsxs as $r}from"react/jsx-runtime";var Gr=({name:e,rules:t,defaultValue:i,shouldUnregister:n,label:l,labelPlacement:g,disableIconError:c,onChange:y,...C})=>{let m=Lr();if(!m)throw new Error("Para usar o <Switch /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return ae(Br,{control:m.control,name:e,rules:t,defaultValue:i,shouldUnregister:n,render:({field:{value:u,onChange:d}})=>$r(Er,{sx:{display:"flex",flexDirection:"column"},children:[ae(Rr,{control:ae(Ar,{value:u??"",checked:u??!1,defaultValue:u,onChange:(x,a)=>{d(x,a),y?.(x,a)},...C},e),label:ae(P,{label:l}),labelPlacement:g||"end"}),ae(k,{name:e,disableIcon:c})]})})},Mr=Gr;import{FormControlLabel as Dr,Grid as qr,Radio as _r}from"@mui/material";import{jsx as fe}from"react/jsx-runtime";var zr=({label:e,labelPlacement:t,...i})=>fe(qr,{sx:{display:"flex",flexDirection:"column"},children:fe(Dr,{control:fe(_r,{...i}),label:fe(P,{label:e}),labelPlacement:t||"end"})}),Or=zr;import{Grid as Nr,RadioGroup as Ur}from"@mui/material";import{Controller as jr,useFormContext as Hr}from"react-hook-form";import{jsx as ce,jsxs as Jr}from"react/jsx-runtime";var Wr=({name:e,rules:t,defaultValue:i,shouldUnregister:n,label:l,required:g,children:c,orientation:y="row",disableIconError:C,...m})=>{let u=Hr();if(!u)throw new Error("Para usar o <RadioGroup /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return ce(jr,{control:u.control,name:e,rules:t,defaultValue:i,shouldUnregister:n,render:({field:{value:d,onChange:x}})=>Jr(Nr,{sx:{display:"flex",flexDirection:"column"},children:[l&&ce(P,{label:l,required:g}),ce(Ur,{value:d||"",name:e,...m,onChange:a=>{m?.onChange?.(a,a.target?.value),x(a)},style:{display:"flex",flexDirection:y},children:c},e),ce(k,{name:e,disableIcon:C})]})})},Yr=Wr;import{Controller as Kr,useFormContext as Xr}from"react-hook-form";import{Slider as Qr}from"@mui/material";import{jsx as Ue}from"react/jsx-runtime";var Zr=({name:e,rules:t,defaultValue:i,shouldUnregister:n,...l})=>{let g=Xr();if(!g)throw new Error("Para usar o <Slider /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return Ue(Kr,{control:g.control,name:e,rules:t,defaultValue:i,shouldUnregister:n,render:({field:{value:c,onChange:y}})=>Ue(Qr,{value:c||l?.min||0,onChange:y,valueLabelDisplay:"auto",...l},e)})},et=Zr;import{Grid as lt,TextField as nt}from"@mui/material";import{AdapterDayjs as at}from"@mui/x-date-pickers/AdapterDayjs";import{DatePicker as st}from"@mui/x-date-pickers/DatePicker";import{LocalizationProvider as dt}from"@mui/x-date-pickers/LocalizationProvider";import{ptBR as pt}from"@mui/x-date-pickers/locales/ptBR";import{composeValidators as mt,date as He}from"@s_mart/rules";import ut from"dayjs/locale/pt-br";import{memo as ft}from"react";import{Controller as ct,useFormContext as yt}from"react-hook-form";import{IconButton as ot,styled as rt}from"@mui/material";import{toRem as j}from"@s_mart/utils";var tt=e=>{switch(e){case"small":return j(16);default:case"medium":return j(20);case"large":return j(24)}},it=e=>{switch(e){case"small":return`${j(2)} ${j(8)}`;default:case"medium":return`${j(6)} ${j(8)}`;case"large":return`${j(10)}`}},je=rt(ot)`
53
+ ${({hideAddButton:e,theme:o})=>!e&&mt(o)}
54
+ `;import{Fragment as Pe,jsx as R,jsxs as K}from"react/jsx-runtime";import{createElement as Ue}from"react";var He=ct(({name:e,rules:o,defaultValue:l,shouldUnregister:i,label:d,required:P,options:g,editable:f,footer:T,onEditOption:x,onCreateOption:C,textFieldProps:m,hideAddButton:u,multiple:a,info:p,onChange:V,onInputChange:n,placeholder:F,disableIconError:L,...r})=>{let y=Ft();if(!y)throw new v("Creatable");let G=D(y.formState.errors,e),b=u||r.disabled,s=t=>{let k=0;return m?.InputProps||(k+=2.5),b||(k+=2.56,w(t)&&(k+=2.56)),!r.disableClearable&&!r.disabled&&(k+=1.3),k+"rem"},w=t=>r.disabled?!1:f&&yt(t)&&!xt(t);console.warn=()=>{};let A=t=>{C?C(t):console.error("onCreateOption n\xE3o foi definido")},c=t=>{x?x(t):console.error("onEditOption n\xE3o foi definido")};return R(ft,{control:y.control,name:e,rules:o,defaultValue:l,shouldUnregister:i,render:({field:{value:t,onChange:k,ref:z}})=>{let J=t?.label||t?.value||t;return K(ee,{sx:{display:"flex",flexDirection:"column"},children:[K("div",{style:{display:"flex"},children:[d&&R(ee,{item:!0,children:R(S,{label:d,required:P})}),p&&R(ee,{item:!0,children:R(Pt,{title:p,placement:"top",children:R("div",{style:{width:"fit-content"},children:R(me,{icon:Tt,color:"#757575"})})})})]}),R(ze,{hideAddButton:b,children:R(bt,{fullWidth:!0,onChange:(B,h)=>{k(h),V?.(h,y.getValues())},onInputChange:(B,h,ne)=>{ne==="input"&&setTimeout(()=>{n?.(h,y.getValues())},0)},slotProps:{...r.slotProps||{},paper:{...(r.slotProps||{}).paper||{},sx:{border:`1px solid ${Ct.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}},listbox:{component:ut(function(h,ne){return K(Pe,{children:[R("ul",{...h,ref:ne}),!!T&&R("div",{...h,children:K(Pe,{children:[R(ee,{sx:{px:2,py:1},children:R(gt,{})}),T]})},"creatable-footer")]})})}},options:g,value:t||(a?[]:null),multiple:a,readOnly:r.disabled,noOptionsText:b?void 0:K(Vt,{sx:{justifyContent:"flex-start",padding:`${_e(6)} ${_e(-16)}`,margin:0},fullWidth:!0,onClick:()=>A(t),variant:"text",startIcon:R(me,{icon:qe}),children:["Adicionar ",J&&`"${J}"`]}),isOptionEqualToValue:(B,h)=>h?typeof B=="string"&&typeof h=="string"?B===h:typeof B=="object"&&typeof h=="object"?typeof B.value=="object"&&typeof h.value=="object"&&B.key!==void 0&&h.key!==void 0?B.key===h.key:B.value===h.value:typeof B=="object"&&typeof h=="string":!1,renderOption:(B,h)=>typeof h=="object"?Ue("li",{...B,key:h.key||h.value},K(ee,{container:!0,direction:"column",children:[R(ee,{item:!0,children:h.label}),h.afterLabel&&R(ee,{item:!0,children:h.afterLabel})]})):Ue("li",{...B,key:h},h),...r,sx:{"& div.MuiInputBase-root":{paddingRight:`${s(t)} !important`},...r.sx},renderInput:B=>R(ht,{placeholder:F,...B,error:!!G,...m,slotProps:{input:{...B.InputProps,inputRef:z,endAdornment:K("div",{className:"endAdornments",children:[B.InputProps.endAdornment,!b&&K(Pe,{children:[w(t)?K("div",{className:"editable",children:[R("div",{className:"divider"}),R("div",{className:"button",onClick:()=>c(t),children:R(me,{icon:vt,size:"24px",removeMargin:!0})})]}):null,K("div",{className:"creatable",children:[R("div",{className:"divider"}),R("div",{className:"button",onClick:()=>A(t),children:R(me,{icon:qe,size:"24px",removeMargin:!0})})]})]})]})}}})},e)}),R(I,{name:e,disableIcon:L,control:y.control})]})}})});He.displayName="Creatable";var St=He;import{useController as kt,useFormContext as It}from"react-hook-form";import{Checkbox as wt,FormControlLabel as At}from"@mui/material";import{jsx as ue,jsxs as Dt}from"react/jsx-runtime";var Lt=({name:e,rules:o,defaultValue:l,shouldUnregister:i,control:d,label:P,labelPlacement:g,required:f,disableIconError:T,onChange:x,...C})=>{let m=It()?.control,u=d??m;if(!u)throw new v("Checkbox");let{field:a}=kt({control:u,name:e,rules:o,defaultValue:l,shouldUnregister:i});return Dt("span",{children:[ue(At,{control:ue(wt,{checked:!!a.value,value:a.value??"",defaultValue:a.value,onChange:(p,V)=>{a.onChange(p,V),x?.(p,V)},...C},e),label:ue(S,{label:P,required:f,regular:!0}),labelPlacement:g||"end"}),ue(I,{name:e,disableIcon:T,control:u})]})},Rt=Lt;import{FormControlLabel as Bt,Stack as Et,Switch as Mt}from"@mui/material";import{useController as $t,useFormContext as Nt}from"react-hook-form";import{jsx as ce,jsxs as zt}from"react/jsx-runtime";var Ot=({name:e,rules:o,defaultValue:l,shouldUnregister:i,control:d,label:P,labelPlacement:g,disableIconError:f,onChange:T,...x})=>{let C=Nt()?.control,m=d??C;if(!m)throw new v("Switch");let{field:u}=$t({control:m,name:e,rules:o,defaultValue:l,shouldUnregister:i});return zt(Et,{children:[ce(Bt,{control:ce(Mt,{value:u.value??"",checked:u.value??!1,defaultValue:u.value,onChange:(a,p)=>{u.onChange(a,p),T?.(a,p)},...x},e),label:ce(S,{label:P}),labelPlacement:g||"end"}),ce(I,{name:e,disableIcon:f,control:m})]})},Gt=Ot;import{RadioGroup as qt,Stack as _t}from"@mui/material";import{useController as Ut,useFormContext as Ht}from"react-hook-form";import{jsx as ge,jsxs as Yt}from"react/jsx-runtime";var Kt=({name:e,rules:o,defaultValue:l,shouldUnregister:i,control:d,label:P,required:g,children:f,orientation:T="row",disableIconError:x,...C})=>{let m=Ht()?.control,u=d??m;if(!u)throw new v("RadioGroup");let{field:a}=Ut({control:u,name:e,rules:o,defaultValue:l,shouldUnregister:i});return Yt(_t,{children:[P&&ge(S,{label:P,required:g}),ge(qt,{value:a.value||"",name:e,...C,onChange:p=>{C?.onChange?.(p,p.target?.value),a.onChange(p)},style:{display:"flex",flexDirection:T},children:f},e),ge(I,{name:e,disableIcon:x,control:u})]})},Wt=Kt;import{FormControlLabel as jt,Grid2 as Jt,Radio as Xt}from"@mui/material";import{jsx as fe}from"react/jsx-runtime";var Qt=({label:e,labelPlacement:o,...l})=>fe(Jt,{sx:{display:"flex",flexDirection:"column"},children:fe(jt,{control:fe(Xt,{...l}),label:fe(S,{label:e}),labelPlacement:o||"end"})}),Zt=Qt;import{useController as er,useFormContext as or}from"react-hook-form";import{Slider as tr}from"@mui/material";import{jsx as ir}from"react/jsx-runtime";var rr=({name:e,rules:o,defaultValue:l,shouldUnregister:i,control:d,...P})=>{let g=or()?.control,f=d??g;if(!f)throw new v("Slider");let{field:T}=er({control:f,name:e,rules:o,defaultValue:l,shouldUnregister:i});return ir(tr,{value:T.value||P?.min||0,onChange:T.onChange,valueLabelDisplay:"auto",...P},e)},lr=rr;import{Stack as pr,TextField as mr}from"@mui/material";import{AdapterDayjs as ur}from"@mui/x-date-pickers/AdapterDayjs";import{DatePicker as cr}from"@mui/x-date-pickers/DatePicker";import{LocalizationProvider as fr}from"@mui/x-date-pickers/LocalizationProvider";import{ptBR as Fr}from"@mui/x-date-pickers/locales/ptBR";import{composeValidators as yr,date as We}from"@s_mart/rules";import xr from"dayjs/locale/pt-br";import{memo as br}from"react";import{useController as hr,useFormContext as Pr,useFormState as gr}from"react-hook-form";import{IconButton as nr,styled as ar}from"@mui/material";import{toRem as W}from"@s_mart/utils";var sr=e=>{switch(e){case"small":return W(16);default:case"medium":return W(20);case"large":return W(24)}},dr=e=>{switch(e){case"small":return`${W(2)} ${W(8)}`;default:case"medium":return`${W(6)} ${W(8)}`;case"large":return`${W(10)}`}},Ke=ar(nr)`
55
55
  margin: 0px;
56
56
 
57
- padding: ${({size:e})=>it(e)};
58
- border-radius: 0 ${j(4)} ${j(4)} 0;
57
+ padding: ${({size:e})=>dr(e)};
58
+ border-radius: 0 ${W(4)} ${W(4)} 0;
59
59
 
60
60
  svg {
61
- width: ${({size:e})=>tt(e)} !important;
61
+ width: ${({size:e})=>sr(e)} !important;
62
62
  }
63
- `;import{jsx as se,jsxs as gt}from"react/jsx-runtime";import{createElement as Ft}from"react";var xt=({rules:e,name:t,defaultValue:i,shouldUnregister:n,datePickerProps:l,label:g,required:c,placeholder:y,disabled:C,disableIconError:m,...u})=>{let d=yt();if(!d)throw new Error("Para usar o <DataPicker /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let x=E(d.formState.errors,t),a=l?.format||"DD/MM/YYYY",h=e?mt([He(a),e]):He(a);return se(dt,{dateAdapter:at,adapterLocale:ut,localeText:pt.components.MuiLocalizationProvider.defaultProps.localeText,children:se(ct,{control:d.control,name:t,rules:h,defaultValue:i,shouldUnregister:n,render:({field:{value:F,onChange:p,ref:b}})=>gt(lt,{sx:{display:"flex",flexDirection:"column"},children:[g&&se(P,{label:g,required:c}),Ft(st,{...l,key:t,value:F??null,format:a,onChange:(s,f)=>{p(s,f),l?.onChange?.(s,f)},disabled:C,slots:{textField:nt,openPickerButton:s=>se(je,{...s,size:u.size})},slotProps:{textField:s=>({variant:"outlined",...s,error:!!x,...u,inputProps:{...s.inputProps,placeholder:y||s.inputProps?.placeholder},InputProps:{...s.InputProps,inputRef:f=>{b(f),typeof s.inputRef=="function"&&s.inputRef(f)}}})}}),se(k,{name:t,disableIcon:m})]})})})},bt=ft(xt);import{Grid as Tt,TextField as St}from"@mui/material";import{AdapterDayjs as kt}from"@mui/x-date-pickers/AdapterDayjs";import{LocalizationProvider as It}from"@mui/x-date-pickers/LocalizationProvider";import{TimePicker as Vt}from"@mui/x-date-pickers/TimePicker";import{ptBR as wt}from"@mui/x-date-pickers/locales/ptBR";import{composeValidators as Rt,time as Ye}from"@s_mart/rules";import Et from"dayjs/locale/pt-br";import{memo as At}from"react";import{Controller as Bt,useFormContext as Lt}from"react-hook-form";import{styled as ht}from"@mui/material";import{IconButton as vt}from"@mui/material";import{toRem as H}from"@s_mart/utils";var Pt=e=>{switch(e){case"small":return H(16);default:case"medium":return H(20);case"large":return H(24)}},Ct=e=>{switch(e){case"small":return`${H(2)} ${H(8)}`;default:case"medium":return`${H(6)} ${H(8)}`;case"large":return`${H(10)}`}},We=ht(vt)`
63
+ `;import{jsx as Fe,jsxs as Tr}from"react/jsx-runtime";import{createElement as vr}from"react";var Vr=({rules:e,name:o,defaultValue:l,shouldUnregister:i,control:d,datePickerProps:P,label:g,required:f,placeholder:T,disabled:x,disableIconError:C,...m})=>{let u=Pr()?.control,a=d??u;if(!a)throw new v("DatePicker");let p=gr({control:a,name:o}),V=D(p.errors,o),n=P?.format||"DD/MM/YYYY",F=e?yr([We(n),e]):We(n),{field:L}=hr({control:a,name:o,rules:F,defaultValue:l,shouldUnregister:i});return Fe(fr,{dateAdapter:ur,adapterLocale:xr,localeText:Fr.components.MuiLocalizationProvider.defaultProps.localeText,children:Tr(pr,{children:[g&&Fe(S,{label:g,required:f}),vr(cr,{...P,key:o,value:L.value??null,format:n,onChange:(r,y)=>{L.onChange(r,y),P?.onChange?.(r,y)},disabled:x,slots:{textField:mr,openPickerButton:r=>Fe(Ke,{...r,size:m.size})},slotProps:{textField:r=>({variant:"outlined",...r,error:!!V,...m,inputProps:{...r.inputProps,placeholder:T||r.inputProps?.placeholder},InputProps:{...r.InputProps,inputRef:y=>{L.ref(y),typeof r.inputRef=="function"&&r.inputRef(y)}}})}}),Fe(I,{name:o,disableIcon:C,control:a})]})})},Cr=br(Vr);import{Stack as Ar,TextField as Lr}from"@mui/material";import{AdapterDayjs as Rr}from"@mui/x-date-pickers/AdapterDayjs";import{LocalizationProvider as Dr}from"@mui/x-date-pickers/LocalizationProvider";import{TimePicker as Br}from"@mui/x-date-pickers/TimePicker";import{ptBR as Er}from"@mui/x-date-pickers/locales/ptBR";import{composeValidators as Mr,time as je}from"@s_mart/rules";import $r from"dayjs/locale/pt-br";import{memo as Nr}from"react";import{useController as Or,useFormContext as Gr,useFormState as zr}from"react-hook-form";import{styled as Sr}from"@mui/material";import{IconButton as kr}from"@mui/material";import{toRem as Y}from"@s_mart/utils";var Ir=e=>{switch(e){case"small":return Y(16);case"large":return Y(24);default:return Y(20)}},wr=e=>{switch(e){case"small":return`${Y(2)} ${Y(8)}`;case"large":return Y(10);default:return`${Y(6)} ${Y(8)}`}},Ye=Sr(kr)`
64
64
  margin: 0px;
65
65
 
66
- padding: ${({size:e})=>Ct(e)};
67
- border-radius: 0 ${H(4)} ${H(4)} 0;
66
+ padding: ${({size:e})=>wr(e)};
67
+ border-radius: 0 ${Y(4)} ${Y(4)} 0;
68
68
 
69
69
  svg {
70
- width: ${({size:e})=>Pt(e)} !important;
70
+ width: ${({size:e})=>Ir(e)} !important;
71
71
  }
72
- `;import{jsx as re,jsxs as $t}from"react/jsx-runtime";var Gt=({rules:e,defaultValue:t,shouldUnregister:i,name:n,required:l,label:g,timePickerProps:c,placeholder:y,disabled:C,disableIconError:m,...u})=>{let d=Lt();if(!d)throw new Error("Para usar o <TimePicker /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let x=E(d.formState.errors,n),a=c?.format||"HH:mm",h=e?Rt([Ye(a),e]):Ye(a);return re(It,{dateAdapter:kt,adapterLocale:Et,localeText:wt.components.MuiLocalizationProvider.defaultProps.localeText,children:re(Bt,{control:d.control,name:n,rules:h,defaultValue:t,shouldUnregister:i,render:({field:{value:F,onChange:p,ref:b}})=>$t(Tt,{sx:{display:"flex",flexDirection:"column"},children:[g&&re(P,{label:g,required:l}),re(Vt,{ampm:!1,format:a,value:F??null,disabled:C,...c,onChange:(s,f)=>{p(s,f),c?.onChange?.(s,f)},slots:{textField:St,openPickerButton:s=>re(We,{...s,size:u.size})},slotProps:{textField:s=>({variant:"outlined",...s,error:!!x,...u,inputProps:{...s.inputProps,placeholder:y||s.inputProps?.placeholder},InputProps:{...s.InputProps,inputRef:f=>{b(f),typeof s.inputRef=="function"&&s.inputRef(f)}}})}},n),re(k,{name:n,disableIcon:m})]})})})},Mt=At(Gt);import{Autocomplete as Dt,Grid as ye,TextField as qt}from"@mui/material";import{colorPalette as _t}from"@s_mart/tokens";import{memo as zt}from"react";import{Controller as Ot,useFormContext as Nt}from"react-hook-form";import{jsx as Q,jsxs as Je}from"react/jsx-runtime";import{createElement as Ht}from"react";var Ut=({name:e,defaultValue:t,rules:i,shouldUnregister:n,label:l,required:g,noOptionsText:c,placeholder:y,onInputChange:C,onChange:m,disableIconError:u,...d})=>{let x=Nt();if(!x)throw new Error("Para usar o <Autocomplete /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let a=E(x.formState.errors,e);return console.warn=()=>{},Q(Ot,{name:e,control:x.control,defaultValue:t,rules:i,shouldUnregister:n,render:({field:h})=>Je(ye,{sx:{display:"flex",flexDirection:"column"},children:[l&&Q(P,{label:l,required:g}),Q(Dt,{onChange:(F,p)=>{h.onChange(p),m?.(p,x.getValues())},onInputChange:(F,p,b)=>{b==="input"&&(h.onChange(p),setTimeout(()=>{C?.(p,x.getValues())},0))},slotProps:{...d.slotProps||{},paper:{...d.slotProps?.paper||{},sx:{border:`1px solid ${_t.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}}},isOptionEqualToValue:(F,p)=>F.value===p.value,renderOption:(F,p)=>Ht("li",{...F,key:p.key||p.value,onClick:b=>{F.onClick?.(b),h.onChange(p)}},Je(ye,{container:!0,direction:"column",children:[Q(ye,{item:!0,children:p.label}),p.afterLabel&&Q(ye,{item:!0,children:p.afterLabel})]})),value:h.value||null,readOnly:d.disabled,noOptionsText:c||"Nenhuma op\xE7\xE3o encontrada",...d,renderInput:F=>Q(qt,{placeholder:y,...F,error:!!a,slotProps:{input:{inputProps:F.inputProps,inputRef:h.ref}}})},e),Q(k,{name:e,disableIcon:u})]})})},jt=zt(Ut);import{Autocomplete as Qt,Divider as Ke,TextField as Zt}from"@mui/material";import{colorPalette as ei}from"@s_mart/tokens";import{isEqual as oi}from"lodash-es";import{forwardRef as ri}from"react";import{useController as ti,useFormContext as ii}from"react-hook-form";import{Tooltip as Wt}from"@mui/material";import{LIcon as Yt}from"@s_mart/core";import{lineInfoCircle as Jt}from"@s_mart/solid-icons";import{jsx as Pe}from"react/jsx-runtime";var Kt=({title:e})=>Pe(Wt,{title:e,placement:"top",children:Pe("div",{style:{width:"fit-content"},children:Pe(Yt,{icon:Jt,color:"#757575"})})}),Z=Kt;import{memo as Xt}from"react";var te=Xt;import{Fragment as Ce,jsx as q,jsxs as ee}from"react/jsx-runtime";import{createElement as ai}from"react";var li=({name:e,rules:t,defaultValue:i,shouldUnregister:n,label:l,required:g,options:c,textFieldProps:y,noOptionsText:C,footer:m,multiple:u,info:d,placeholder:x,onChange:a,onInputChange:h,getOptionAfterLabel:F,getOptionLabel:p,getOptionKey:b,...s})=>{let f=ii();if(!f)throw new Error("Para usar o <SearchableV2 /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let w=E(f.formState.errors,e),{field:$}=ti({name:e,control:f.control,rules:t,defaultValue:i,shouldUnregister:n});return ee("div",{style:{display:"flex",flexDirection:"column"},children:[ee("div",{style:{display:"flex"},children:[l&&q(P,{label:l,required:g}),d&&q(Z,{title:d})]}),q(Qt,{onChange:(r,o)=>{$.onChange(o),a?.(o)},onInputChange:(r,o,T)=>{T==="input"&&h?.(o)},value:$.value?$.value:u?[]:null,options:c,multiple:u,readOnly:s.disabled,slotProps:{...s.slotProps,paper:{...s.slotProps?.paper,sx:{border:`1px solid ${ei.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}},listbox:{component:ri(function(o,T){return ee(Ce,{children:[q("ul",{...o,ref:T}),typeof m<"u"?ee("div",{...o,children:[q("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:q(Ke,{})}),m()]},"searchable-footer"):null]})})}},noOptionsText:ee(Ce,{children:[C||"Nenhuma op\xE7\xE3o encontrada",typeof m<"u"?ee(Ce,{children:[q("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:q(Ke,{})}),m()]}):null]}),isOptionEqualToValue:(r,o)=>oi(r,o),getOptionLabel:r=>p(r),getOptionKey:r=>b(r),renderOption:typeof F=="function"?(r,o)=>{let T=F(o),S=b(o);return ai("li",{...r,key:S},ee("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[q("span",{children:p(o)}),typeof T=="string"?q("span",{children:T}):T]}))}:void 0,...s,renderInput:r=>q(Zt,{error:!!w,placeholder:x,...r,...y,inputRef:$.ref})},e),q(k,{name:e})]})},ni=te(li);import{useState as pi}from"react";import{useController as mi,useFormContext as ui}from"react-hook-form";import{IconButton as fi,LIcon as ci}from"@s_mart/core";import{lineTimes as yi}from"@s_mart/regular-icons";import{colorPalette as xi}from"@s_mart/tokens";import{Select as bi,MenuItem as Fi,Divider as gi}from"@mui/material";import{colorPalette as si}from"@s_mart/tokens";import{jsx as di}from"react/jsx-runtime";var Xe=({value:e,placeholder:t,getOptionLabel:i})=>e===null||e?.length===0?di("p",{style:{color:si.neutral[100]},children:t}):i(e);import{Fragment as Pi,jsx as O,jsxs as oe}from"react/jsx-runtime";var hi=({name:e,rules:t,defaultValue:i,shouldUnregister:n,label:l,required:g,options:c,placeholder:y,clearable:C,info:m,footer:u,onChange:d,variant:x="outlined",getOptionKey:a,getOptionLabel:h,getOptionAfterLabel:F,getOptionIcon:p,...b})=>{let s=ui(),[f,w]=pi(!1);if(!s)throw new Error("Para usar o <SelectV2 /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let $=E(s.formState.errors,e),{field:r}=mi({control:s.control,name:e,rules:t,defaultValue:i,shouldUnregister:n});return oe("div",{style:{display:"flex",flexDirection:"column"},children:[oe("div",{style:{display:"flex"},children:[l&&O(P,{label:l,required:g}),m&&O(Z,{title:m})]}),oe(bi,{open:f,onOpen:()=>w(!0),onClose:()=>w(!1),displayEmpty:!!y,variant:x,autoComplete:"off",value:r.value||null,renderValue:o=>O(Xe,{getOptionLabel:h,placeholder:y,value:o}),onChange:o=>{r.onChange(o.target.value),d?.(o.target.value)},error:!!$,size:b.size||"medium",inputRef:r.ref,...b,endAdornment:oe(Pi,{children:[b.endAdornment,!!(C&&r.value)&&O(fi,{variant:"text",color:"neutral",size:"small",sx:{borderRadius:"50%",position:"absolute",right:"2rem"},style:{padding:0},"aria-label":"Limpar",title:"Limpar",onClick:()=>{r.onChange(null),d?.(null)},children:O(ci,{icon:yi,color:xi.neutral[100],size:"25px",removeMargin:!0})})]}),children:[c.map(o=>{let T=a(o),S=h(o),_=p?.(o);return O(Fi,{value:o,children:oe("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[_!==void 0?oe("div",{style:{display:"flex",alignItems:"center"},children:[_,S]}):S,O("span",{children:F?.(o)??null})]})},T)}),u!==void 0&&oe("div",{children:[O("div",{style:{padding:"8px 16px"},children:O(gi,{})},"footer-divider"),O("div",{children:u({closeSelect:()=>w(!1)})},"footer-content")]},"footer")]},e),O(k,{name:e})]})},vi=te(hi);import{forwardRef as Si,useCallback as ki,useState as Ii}from"react";import{useController as Vi,useFormContext as wi}from"react-hook-form";import{isObject as Ri,isEmpty as Ei,isEqual as Ai}from"lodash-es";import{Autocomplete as Bi,TextField as Li,Divider as eo}from"@mui/material";import{LIcon as Te,Button as Gi}from"@s_mart/core";import{colorPalette as Mi}from"@s_mart/tokens";import{linePlus as oo,linePen as $i}from"@s_mart/solid-icons";import{toRem as ro}from"@s_mart/utils";import{css as Ci,styled as Ti}from"@mui/material";import{toRem as xe}from"@s_mart/utils";import"@mui/system";var Qe=Ci`
72
+ `;import{jsx as se,jsxs as Ur}from"react/jsx-runtime";var qr=({rules:e,defaultValue:o,shouldUnregister:l,name:i,control:d,required:P,label:g,timePickerProps:f,placeholder:T,disabled:x,disableIconError:C,...m})=>{let u=Gr()?.control,a=d??u;if(!a)throw new v("TimePicker");let p=zr({control:a,name:i}),V=D(p.errors,i),n=f?.format||"HH:mm",F=e?Mr([je(n),e]):je(n),{field:L}=Or({control:a,name:i,rules:F,defaultValue:o,shouldUnregister:l});return se(Dr,{dateAdapter:Rr,adapterLocale:$r,localeText:Er.components.MuiLocalizationProvider.defaultProps.localeText,children:Ur(Ar,{children:[g&&se(S,{label:g,required:P}),se(Br,{ampm:!1,format:n,value:L.value??null,disabled:x,...f,onChange:(r,y)=>{L.onChange(r,y),f?.onChange?.(r,y)},slots:{textField:Lr,openPickerButton:r=>se(Ye,{...r,size:m.size})},slotProps:{textField:r=>({variant:"outlined",...r,error:!!V,...m,inputProps:{...r.inputProps,placeholder:T||r.inputProps?.placeholder},InputProps:{...r.InputProps,inputRef:y=>{L.ref(y),typeof r.inputRef=="function"&&r.inputRef(y)}}})}},i),se(I,{name:i,disableIcon:C,control:a})]})})},_r=Nr(qr);import{Autocomplete as Hr,Grid as ye,TextField as Kr}from"@mui/material";import{colorPalette as Wr}from"@s_mart/tokens";import{memo as Yr}from"react";import{Controller as jr,useFormContext as Jr}from"react-hook-form";import{jsx as oe,jsxs as Je}from"react/jsx-runtime";import{createElement as Zr}from"react";var Xr=({name:e,defaultValue:o,rules:l,shouldUnregister:i,label:d,required:P,noOptionsText:g,placeholder:f,onInputChange:T,onChange:x,disableIconError:C,...m})=>{let u=Jr();if(!u)throw new v("Autocomplete");let a=D(u.formState.errors,e);return console.warn=()=>{},oe(jr,{name:e,control:u.control,defaultValue:o,rules:l,shouldUnregister:i,render:({field:p})=>Je(ye,{sx:{display:"flex",flexDirection:"column"},children:[d&&oe(S,{label:d,required:P}),oe(Hr,{onChange:(V,n)=>{p.onChange(n),x?.(n,u.getValues())},onInputChange:(V,n,F)=>{F==="input"&&(p.onChange(n),setTimeout(()=>{T?.(n,u.getValues())},0))},slotProps:{...m.slotProps||{},paper:{...m.slotProps?.paper||{},sx:{border:`1px solid ${Wr.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}}},isOptionEqualToValue:(V,n)=>V.value===n.value,renderOption:(V,n)=>Zr("li",{...V,key:n.key||n.value,onClick:F=>{V.onClick?.(F),p.onChange(n)}},Je(ye,{container:!0,direction:"column",children:[oe(ye,{item:!0,children:n.label}),n.afterLabel&&oe(ye,{item:!0,children:n.afterLabel})]})),value:p.value||null,readOnly:m.disabled,noOptionsText:g||"Nenhuma op\xE7\xE3o encontrada",...m,renderInput:V=>oe(Kr,{placeholder:f,...V,error:!!a,slotProps:{input:{inputProps:V.inputProps,inputRef:p.ref}}})},e),oe(I,{name:e,disableIcon:C,control:u.control})]})})},Qr=Yr(Xr);import{Autocomplete as il,Divider as Xe,TextField as nl}from"@mui/material";import{colorPalette as al}from"@s_mart/tokens";import{isEqual as sl}from"lodash-es";import{forwardRef as dl}from"react";import{useController as pl,useFormContext as ml,useFormState as ul}from"react-hook-form";import{Tooltip as el}from"@mui/material";import{LIcon as ol}from"@s_mart/core";import{lineInfoCircle as tl}from"@s_mart/solid-icons";import{jsx as Ve}from"react/jsx-runtime";var rl=({title:e})=>Ve(el,{title:e,placement:"top",children:Ve("div",{style:{width:"fit-content"},children:Ve(ol,{icon:tl,color:"#757575"})})}),te=rl;import{memo as ll}from"react";var ie=ll;import{Fragment as Ce,jsx as q,jsxs as re}from"react/jsx-runtime";import{createElement as Fl}from"react";var cl=e=>{let{name:o,rules:l,defaultValue:i,shouldUnregister:d,control:P,label:g,required:f,options:T,textFieldProps:x,noOptionsText:C,footer:m,multiple:u,info:a,placeholder:p,onChange:V,onInputChange:n,getOptionAfterLabel:F,getOptionLabel:L,getOptionKey:r,...y}=e,G=ml()?.control,b=P??G;if(!b)throw new v("SearchableV2");let s=ul({control:b,name:o}),w=D(s.errors,o),{field:A}=pl({name:o,control:b,rules:l,defaultValue:i,shouldUnregister:d});return re("div",{style:{display:"flex",flexDirection:"column"},children:[re("div",{style:{display:"flex"},children:[g&&q(S,{label:g,required:f}),a&&q(te,{title:a})]}),q(il,{onChange:(c,t)=>{A.onChange(t),V?.(t)},onInputChange:(c,t,k)=>{k==="input"&&n?.(t)},value:A.value,options:T,multiple:u,readOnly:y.disabled,slotProps:{...y.slotProps,paper:{...y.slotProps?.paper,sx:{border:`1px solid ${al.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}},listbox:{component:dl(function(t,k){return re(Ce,{children:[q("ul",{...t,ref:k}),typeof m<"u"?re("div",{...t,children:[q("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:q(Xe,{})}),m()]},"searchable-footer"):null]})})}},noOptionsText:re(Ce,{children:[C||"Nenhuma op\xE7\xE3o encontrada",typeof m<"u"?re(Ce,{children:[q("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:q(Xe,{})}),m()]}):null]}),isOptionEqualToValue:(c,t)=>sl(c,t),getOptionLabel:L,getOptionKey:r,renderOption:typeof F=="function"?(c,t)=>{let k=F(t),z=r(t);return Fl("li",{...c,key:z},re("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[q("span",{children:L(t)}),typeof k=="string"?q("span",{children:k}):k]}))}:void 0,...y,renderInput:c=>q(nl,{error:!!w,placeholder:p,...c,...x,inputRef:A.ref})},o),q(I,{name:o,control:b})]})},fl=ie(cl);import{useState as bl}from"react";import{useController as hl,useFormContext as Pl,useFormState as gl}from"react-hook-form";import{IconButton as Vl,LIcon as Cl}from"@s_mart/core";import{lineTimes as vl}from"@s_mart/regular-icons";import{colorPalette as Tl}from"@s_mart/tokens";import{Select as Sl,MenuItem as kl,Divider as Il}from"@mui/material";import{colorPalette as yl}from"@s_mart/tokens";import{jsx as xl}from"react/jsx-runtime";var Qe=({value:e,placeholder:o,getOptionLabel:l})=>e===null||e?.length===0?xl("p",{style:{color:yl.neutral[100]},children:o}):l(e);import{Fragment as Ll,jsx as _,jsxs as le}from"react/jsx-runtime";var wl=e=>{let{name:o,rules:l,defaultValue:i,shouldUnregister:d,control:P,label:g,required:f,options:T,placeholder:x,clearable:C,info:m,footer:u,onChange:a,variant:p="outlined",getOptionKey:V,getOptionLabel:n,getOptionAfterLabel:F,getOptionIcon:L,...r}=e,y=Pl()?.control,G=P??y,[b,s]=bl(!1);if(!G)throw new v("SelectV2");let w=gl({control:G,name:o}),A=D(w.errors,o),{field:c}=hl({control:G,name:o,rules:l,defaultValue:i,shouldUnregister:d});return le("div",{style:{display:"flex",flexDirection:"column"},children:[le("div",{style:{display:"flex"},children:[g&&_(S,{label:g,required:f}),m&&_(te,{title:m})]}),le(Sl,{open:b,onOpen:()=>s(!0),onClose:()=>s(!1),displayEmpty:!!x,variant:p,autoComplete:"off",value:c.value||null,renderValue:t=>_(Qe,{getOptionLabel:n,placeholder:x,value:t}),onChange:t=>{c.onChange(t.target.value),a?.(t.target.value)},error:!!A,size:r.size||"medium",inputRef:c.ref,...r,endAdornment:le(Ll,{children:[r.endAdornment,!!(C&&c.value)&&_(Vl,{variant:"text",color:"neutral",size:"small",sx:{borderRadius:"50%",position:"absolute",right:"2rem"},style:{padding:0},"aria-label":"Limpar",title:"Limpar",onClick:()=>{c.onChange(null),a?.(null)},children:_(Cl,{icon:vl,color:Tl.neutral[100],size:"25px",removeMargin:!0})})]}),children:[T.map(t=>{let k=V(t),z=n(t),J=L?.(t);return _(kl,{value:k??z,children:le("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[J!==void 0?le("div",{style:{display:"flex",alignItems:"center"},children:[J,z]}):z,_("span",{children:F?.(t)??null})]})},k)}),u!==void 0&&le("div",{children:[_("div",{style:{padding:"8px 16px"},children:_(Il,{})},"footer-divider"),_("div",{children:u({closeSelect:()=>s(!1)})},"footer-content")]},"footer")]},o),_(I,{name:o,control:G})]})},Al=ie(wl);import{forwardRef as Bl,useCallback as El,useState as Ml}from"react";import{useController as $l,useFormContext as Nl,useFormState as Ol}from"react-hook-form";import{isObject as Gl,isEmpty as zl,isEqual as ql}from"lodash-es";import{Autocomplete as _l,TextField as Ul,Divider as oo,Button as Hl}from"@mui/material";import{LIcon as ve}from"@s_mart/core";import{colorPalette as Kl}from"@s_mart/tokens";import{linePlus as to,linePen as Wl}from"@s_mart/solid-icons";import{toRem as ro}from"@s_mart/utils";import{css as Rl,styled as Dl}from"@mui/material";import{toRem as xe}from"@s_mart/utils";import"@mui/system";var Ze=Rl`
73
73
  display: flex;
74
74
  align-items: center;
75
75
  justify-content: center;
76
- `,Ze=Ti("div")`
76
+ `,eo=Dl("div")`
77
77
  display: flex;
78
78
 
79
79
  div.endAdornments {
80
80
  position: absolute;
81
81
  right: 0;
82
82
 
83
- ${Qe}
83
+ ${Ze}
84
84
  }
85
85
 
86
86
  .MuiAutocomplete-endAdornment {
@@ -94,7 +94,7 @@ import{FormProvider as io}from"react-hook-form";import{jsx as ke}from"react/jsx-
94
94
 
95
95
  .creatable,
96
96
  .editable {
97
- ${Qe}
97
+ ${Ze}
98
98
 
99
99
  .divider {
100
100
  width: 1px;
@@ -120,4 +120,4 @@ import{FormProvider as io}from"react-hook-form";import{jsx as ke}from"react/jsx-
120
120
  }
121
121
  }
122
122
  }
123
- `;import{Fragment as Se,jsx as L,jsxs as N}from"react/jsx-runtime";import{createElement as _i}from"react";var Di=({name:e,rules:t,defaultValue:i,shouldUnregister:n,label:l,required:g,options:c,footer:y,showCreatableButton:C=!0,showEditableButton:m,onEditOption:u,onCreateOption:d,getOptionKey:x,getOptionLabel:a,getOptionAfterLabel:h,textFieldProps:F,multiple:p,info:b,noOptionsText:s,onChange:f,onInputChange:w,placeholder:$,...r})=>{let[o,T]=Ii(""),S=wi();if(!S)throw new Error("Para usar o <CreatableV2 /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let _=E(S.formState.errors,e),R=!C||r.disabled,{field:D}=Vi({name:e,control:S.control,rules:t,defaultValue:i,shouldUnregister:n}),be=V=>{let B=0;return F?.InputProps||(B+=2.5),R||(B+=2.56,ie(V)&&(B+=2.56)),!r.disableClearable&&!r.disabled&&(B+=1.3),B+"rem"},ie=V=>r.disabled?!1:m&&Ri(V)&&!Ei(V),A=()=>r.disabled?!1:C,v=ki(()=>{typeof d<"u"&&(d(o),T(""))},[o]),le=V=>{u?.(V)};return N("div",{style:{display:"flex",flexDirection:"column"},children:[N("div",{style:{display:"flex"},children:[l&&L(P,{label:l,required:g}),b&&L(Z,{title:b})]}),L(Ze,{children:L(Bi,{fullWidth:!0,onChange:(V,B)=>{T(""),D.onChange(B),f?.(B)},onInputChange:(V,B,Y)=>{Y==="input"&&(T(B),w?.(B))},slotProps:{...r.slotProps,paper:{...r.slotProps?.paper,sx:{border:`1px solid ${Mi.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}},listbox:{component:Si(function(B,Y){return N(Se,{children:[L("ul",{...B,ref:Y}),typeof y<"u"?N("div",{...B,children:[L("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:L(eo,{})}),y()]},"creatable-footer"):null]})})}},value:D.value?D.value:p?[]:null,options:c,multiple:p,readOnly:r.disabled,noOptionsText:N(Se,{children:[s||"Nenhuma op\xE7\xE3o encontrada",!R&&N(Gi,{sx:{justifyContent:"flex-start",padding:`${ro(6)} ${ro(-16)}`,margin:0},fullWidth:!0,onClick:v,variant:"text",startIcon:L(Te,{icon:oo}),children:["Adicionar ",`"${o}"`]}),typeof y<"u"&&N(Se,{children:[L("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:L(eo,{})}),y()]})]}),isOptionEqualToValue:(V,B)=>Ai(V,B),getOptionLabel:V=>a(V),getOptionKey:V=>x(V),renderOption:typeof h=="function"?(V,B)=>{let Y=h(B),to=x(B);return _i("li",{...V,key:to},N("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[L("span",{children:a(B)}),typeof Y=="string"?L("span",{children:Y}):Y]}))}:void 0,...r,sx:{"& div.MuiInputBase-root":{paddingRight:`${be(D.value)} !important`},...r.sx},onBlur:V=>{r?.onBlur?.(V),T("")},renderInput:V=>L(Li,{placeholder:$,...V,error:!!_,...F,slotProps:{input:{...V.InputProps,...F?.InputProps,inputRef:D.ref,endAdornment:N("div",{className:"endAdornments",children:[V.InputProps.endAdornment,F?.InputProps?.endAdornment??null,ie(D.value)?N("div",{className:"editable",children:[L("div",{className:"divider"}),L("div",{className:"button",onClick:()=>le(D.value),children:L(Te,{icon:$i,size:"24px",removeMargin:!0})})]}):null,A()&&N("div",{className:"creatable",children:[L("div",{className:"divider"}),L("div",{className:"button",onClick:v,children:L(Te,{icon:oo,size:"24px",removeMargin:!0})})]})]})}}})},e)}),L(k,{name:e})]})},qi=te(Di);export{jt as Autocomplete,Vr as Checkbox,Pr as Creatable,qi as CreatableV2,bt as DatePicker,P as FieldLabel,uo as Form,Fe as FormProvider,Or as RadioButton,Yr as RadioGroup,lr as Searchable,ni as SearchableV2,Wo as Select,vi as SelectV2,et as Slider,Mr as Switch,Bo as TextField,Mt as TimePicker,ge as useForm};
123
+ `;import{Fragment as Te,jsx as M,jsxs as U}from"react/jsx-runtime";import{createElement as Jl}from"react";function Yl(e){let{name:o,rules:l,defaultValue:i,shouldUnregister:d,control:P,label:g,required:f,options:T,footer:x,showCreatableButton:C=!0,showEditableButton:m,onEditOption:u,onCreateOption:a,getOptionKey:p,getOptionLabel:V,getOptionAfterLabel:n,textFieldProps:F,multiple:L,info:r,noOptionsText:y,onChange:G,onInputChange:b,placeholder:s,...w}=e,[A,c]=Ml(""),t=Nl()?.control,k=P??t;if(!k)throw new v("CreatableV2");let z=Ol({control:k,name:o}),J=D(z.errors,o),B=!C||w.disabled,{field:h}=$l({name:o,control:k,rules:l,defaultValue:i,shouldUnregister:d}),ne=$=>{let E=0;return F?.InputProps||(E+=2.5),B||(E+=2.56,Se($)&&(E+=2.56)),!w.disableClearable&&!w.disabled&&(E+=1.3),`${E}rem`},Se=$=>w.disabled?!1:m&&Gl($)&&!zl($),lo=()=>w.disabled?!1:C,ke=El(()=>{typeof a<"u"&&(a(A),c(""))},[A,a]),io=$=>{u?.($)};return U("div",{style:{display:"flex",flexDirection:"column"},children:[U("div",{style:{display:"flex"},children:[g&&M(S,{label:g,required:f}),r&&M(te,{title:r})]}),M(eo,{children:M(_l,{fullWidth:!0,onChange:($,E)=>{c(""),h.onChange(E),G?.(E)},onInputChange:($,E,X)=>{X==="input"&&(c(E),b?.(E))},slotProps:{...w.slotProps,paper:{...w.slotProps?.paper,sx:{border:`1px solid ${Kl.neutral[30]}`,boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.15)"}},listbox:{component:Bl(function(E,X){return U(Te,{children:[M("ul",{...E,ref:X}),typeof x<"u"?U("div",{...E,children:[M("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:M(oo,{})}),x()]},"creatable-footer"):null]})})}},value:h.value,options:T,multiple:L,readOnly:w.disabled,noOptionsText:U(Te,{children:[y||"Nenhuma op\xE7\xE3o encontrada",!B&&U(Hl,{sx:{justifyContent:"flex-start",padding:`${ro(6)} ${ro(-16)}`,margin:0},fullWidth:!0,onClick:ke,variant:"text",startIcon:M(ve,{icon:to}),children:["Adicionar ",`"${A}"`]}),typeof x<"u"&&U(Te,{children:[M("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:M(oo,{})}),x()]})]}),isOptionEqualToValue:($,E)=>ql($,E),getOptionLabel:V,getOptionKey:p,renderOption:typeof n=="function"?($,E)=>{let X=n(E),no=p(E);return Jl("li",{...$,key:no},U("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[M("span",{children:V(E)}),typeof X=="string"?M("span",{children:X}):X]}))}:void 0,...w,sx:{"& div.MuiInputBase-root":{paddingRight:`${ne(h.value)} !important`},...w.sx},onBlur:$=>{w?.onBlur?.($),c("")},renderInput:$=>M(Ul,{placeholder:s,...$,error:!!J,...F,slotProps:{input:{...$.InputProps,...F?.InputProps,inputRef:h.ref,endAdornment:U("div",{className:"endAdornments",children:[$.InputProps.endAdornment,F?.InputProps?.endAdornment??null,Se(h.value)?U("div",{className:"editable",children:[M("div",{className:"divider"}),M("div",{className:"button",onKeyUp:()=>io(h.value),children:M(ve,{icon:Wl,size:"24px",removeMargin:!0})})]}):null,lo()&&U("div",{className:"creatable",children:[M("div",{className:"divider"}),M("div",{className:"button",onKeyUp:ke,children:M(ve,{icon:to,size:"24px",removeMargin:!0})})]})]})}}})},o)}),M(I,{name:o,control:k})]})}var jl=ie(Yl);export{Qr as Autocomplete,Rt as Checkbox,St as Creatable,jl as CreatableV2,Cr as DatePicker,Fo as Form,be as FormProvider,Zt as RadioButton,Wt as RadioGroup,dt as Searchable,fl as SearchableV2,Xo as Select,Al as SelectV2,lr as Slider,Gt as Switch,$o as TextField,_r as TimePicker,he as useForm};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@s_mart/form",
3
- "version": "9.1.4",
3
+ "version": "9.2.0-beta.1",
4
4
  "main": "./dist/index.mjs",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.mts",
@@ -23,7 +23,7 @@
23
23
  "@mui/system": "^6.4.0",
24
24
  "@mui/x-date-pickers": "^7.22.0",
25
25
  "@types/lodash-es": ">=4.17.12",
26
- "@types/node": ">=20.0.0",
26
+ "@types/node": ">=22.15.17",
27
27
  "@types/react": ">=18.3.12",
28
28
  "@types/react-dom": ">=18.3.1",
29
29
  "dayjs": "^1.11.10",
@@ -32,12 +32,12 @@
32
32
  "react-hook-form": "^7.51.0",
33
33
  "typescript": ">=5.4.2",
34
34
  "zod": "^3.22.4",
35
- "@s_mart/core": "9.1.4",
36
- "@s_mart/masks": "5.2.0",
35
+ "@s_mart/core": "9.1.5-beta.1",
37
36
  "@s_mart/rules": "5.1.1",
38
- "@s_mart/tokens": "5.1.1",
39
37
  "@s_mart/typed": "7.2.2",
40
- "@s_mart/utils": "5.3.4"
38
+ "@s_mart/utils": "5.3.4",
39
+ "@s_mart/tokens": "5.1.1",
40
+ "@s_mart/masks": "5.2.0"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@emotion/styled": "^11.13.0",
@@ -45,15 +45,15 @@
45
45
  "@mui/system": "^6.4.0",
46
46
  "@mui/x-date-pickers": "^7.22.0",
47
47
  "@types/lodash-es": ">=4.17.12",
48
- "@types/node": ">=20.0.0",
48
+ "@types/node": ">=22.15.17",
49
49
  "@types/react": ">=18.3.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": "9.1.4",
54
- "@s_mart/masks": "5.2.0",
53
+ "@s_mart/core": "9.1.5-beta.1",
55
54
  "@s_mart/rules": "5.1.1",
56
55
  "@s_mart/tokens": "5.1.1",
56
+ "@s_mart/masks": "5.2.0",
57
57
  "@s_mart/typed": "7.2.2",
58
58
  "@s_mart/utils": "5.3.4"
59
59
  },