@s_mart/form 10.0.0-beta.12 → 10.0.0-beta.14
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 +28 -35
- package/dist/index.mjs +8 -8
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { CheckboxProps as CheckboxProps$1, AutocompleteProps, TextFieldProps as TextFieldProps$1, AutocompleteValue, RadioGroupProps as RadioGroupProps$1, RadioProps as RadioProps$1, AutocompleteFreeSoloValueMapping, SelectProps, SliderProps as SliderProps$1, SwitchProps as SwitchProps$1 } from '@mui/material';
|
|
2
3
|
import * as react_hook_form from 'react-hook-form';
|
|
3
|
-
import { FieldValues, FieldPath,
|
|
4
|
-
import {
|
|
4
|
+
import { UseControllerProps, FieldValues, FieldPath, Control, UseFormReturn, FormProviderProps, UseFormProps, FieldPathValue } from 'react-hook-form';
|
|
5
|
+
import { WithRequired } from '@s_mart/typed';
|
|
5
6
|
import { DatePickerProps as DatePickerProps$1, TimePickerProps as TimePickerProps$1 } from '@mui/x-date-pickers';
|
|
6
7
|
import { z } from 'zod';
|
|
7
8
|
import * as react from 'react';
|
|
8
9
|
|
|
9
|
-
type CheckboxProps
|
|
10
|
+
type CheckboxProps = CheckboxProps$1 & UseControllerProps & {
|
|
10
11
|
/**
|
|
11
12
|
* O nome do checkbox que será renderizado na tela
|
|
12
13
|
* @default ''
|
|
@@ -33,9 +34,9 @@ type CheckboxProps<TFieldValues extends FieldValues = FieldValues, TFieldName ex
|
|
|
33
34
|
disableIconError?: boolean;
|
|
34
35
|
};
|
|
35
36
|
|
|
36
|
-
declare const _default$7:
|
|
37
|
+
declare const _default$7: ({ name, rules, defaultValue, shouldUnregister, control: controlFromProps, label, labelPlacement, required, disableIconError, onChange: onChangeProp, ...rest }: CheckboxProps) => react_jsx_runtime.JSX.Element;
|
|
37
38
|
|
|
38
|
-
type CreatableV2Props<
|
|
39
|
+
type CreatableV2Props<FieldValue, Multiple extends boolean | undefined = undefined, DisableClearable extends boolean | undefined = undefined, FreeSolo extends boolean | undefined = undefined> = WithRequired<Omit<AutocompleteProps<FieldValue, Multiple, DisableClearable, FreeSolo>, 'renderInput' | 'options' | 'size' | 'onInputChange' | 'onChange' | 'defaultValue' | 'value'>, 'getOptionKey' | 'getOptionLabel'> & UseControllerProps & {
|
|
39
40
|
options: FieldValue[];
|
|
40
41
|
slotProps?: AutocompleteProps<FieldValue, Multiple, DisableClearable, FreeSolo>['slotProps'] & {
|
|
41
42
|
textField: Omit<TextFieldProps$1<'outlined'>, 'variant'>;
|
|
@@ -90,24 +91,16 @@ type CreatableV2Props<TFieldValues extends FieldValues = FieldValues, TFieldName
|
|
|
90
91
|
onInputChange?: (value: string) => void;
|
|
91
92
|
onChange?: (value: AutocompleteValue<FieldValue, Multiple, DisableClearable, FreeSolo> | (DisableClearable extends true ? never : null)) => void;
|
|
92
93
|
placeholder?: string;
|
|
93
|
-
/**
|
|
94
|
-
* Define a key unica da option
|
|
95
|
-
*/
|
|
96
|
-
getOptionKey: (option: FieldValue | AutocompleteFreeSoloValueMapping<FreeSolo>) => string | number;
|
|
97
|
-
/**
|
|
98
|
-
* Define a label da option
|
|
99
|
-
*/
|
|
100
|
-
getOptionLabel: (option: FieldValue | AutocompleteFreeSoloValueMapping<FreeSolo>) => string;
|
|
101
94
|
/**
|
|
102
95
|
* Componente renderizado embaixo da option da listagem
|
|
103
96
|
*/
|
|
104
97
|
getOptionAfterLabel?: (option: FieldValue) => string | React.ReactNode;
|
|
105
98
|
};
|
|
106
99
|
|
|
107
|
-
declare function CreatableV2<
|
|
100
|
+
declare function CreatableV2<FieldValue, Multiple extends boolean | undefined = undefined, DisableClearable extends boolean | undefined = undefined, FreeSolo extends boolean | undefined = undefined>(props: CreatableV2Props<FieldValue, Multiple, DisableClearable, FreeSolo>): react_jsx_runtime.JSX.Element;
|
|
108
101
|
declare const _default$6: typeof CreatableV2;
|
|
109
102
|
|
|
110
|
-
type DatePickerProps
|
|
103
|
+
type DatePickerProps = UseControllerProps & Pick<TextFieldProps$1, 'label' | 'error' | 'helperText' | 'size' | 'fullWidth' | 'variant' | 'autoFocus' | 'placeholder'> & {
|
|
111
104
|
datePickerProps?: Partial<DatePickerProps$1<any>>;
|
|
112
105
|
/**
|
|
113
106
|
* Se `true` irá adicionar um asterisco ao label do campo
|
|
@@ -131,7 +124,7 @@ type DatePickerProps<TFieldValues extends FieldValues = FieldValues, TFieldName
|
|
|
131
124
|
disableIconError?: boolean;
|
|
132
125
|
};
|
|
133
126
|
|
|
134
|
-
declare const _default$5:
|
|
127
|
+
declare const _default$5: ({ rules, name, defaultValue, shouldUnregister, control: controlFromProps, datePickerProps, label, required, placeholder, disabled, disableIconError, ...rest }: DatePickerProps) => react_jsx_runtime.JSX.Element;
|
|
135
128
|
|
|
136
129
|
type FieldLabelProps = {
|
|
137
130
|
label: React.ReactNode;
|
|
@@ -214,7 +207,7 @@ declare const useForm: <TValues extends FieldValues>({ disableDefaultValuesUpdat
|
|
|
214
207
|
|
|
215
208
|
declare function FormProvider<TFieldValues extends FieldValues>({ children, style, onSubmit, ...methods }: IFormProviderProps<TFieldValues>): react_jsx_runtime.JSX.Element;
|
|
216
209
|
|
|
217
|
-
type RadioGroupProps
|
|
210
|
+
type RadioGroupProps = RadioGroupProps$1 & UseControllerProps & {
|
|
218
211
|
/**
|
|
219
212
|
* O nome do checkbox que será renderizado na tela
|
|
220
213
|
* @default ''
|
|
@@ -257,7 +250,7 @@ type RadioGroupProps<TFieldValues extends FieldValues = FieldValues, TFieldName
|
|
|
257
250
|
disableIconError?: boolean;
|
|
258
251
|
};
|
|
259
252
|
|
|
260
|
-
declare const RadioGroup:
|
|
253
|
+
declare const RadioGroup: ({ name, rules, defaultValue, shouldUnregister, control: controlFromProps, label, required, children, orientation, disableIconError, ...rest }: RadioGroupProps) => react_jsx_runtime.JSX.Element;
|
|
261
254
|
|
|
262
255
|
type RadioProps = RadioProps$1 & {
|
|
263
256
|
/**
|
|
@@ -280,7 +273,7 @@ type RadioProps = RadioProps$1 & {
|
|
|
280
273
|
|
|
281
274
|
declare const RadioButton: ({ label, labelPlacement, ...rest }: RadioProps) => react_jsx_runtime.JSX.Element;
|
|
282
275
|
|
|
283
|
-
type SearchableV2Props<
|
|
276
|
+
type SearchableV2Props<FieldValue, Multiple extends boolean | undefined = undefined, DisableClearable extends boolean | undefined = undefined, FreeSolo extends boolean | undefined = undefined, AutocompleteFieldValue extends AutocompleteValue<FieldValue, Multiple, DisableClearable, FreeSolo> = AutocompleteValue<FieldValue, Multiple, DisableClearable, FreeSolo>> = Omit<AutocompleteProps<FieldValue, Multiple, DisableClearable, FreeSolo>, 'renderInput' | 'size' | 'options' | 'onInputChange' | 'onChange' | 'getOptionLabel' | 'getOptionKey' | 'defaultValue' | 'value'> & UseControllerProps & {
|
|
284
277
|
options: FieldValue[];
|
|
285
278
|
textFieldProps?: TextFieldProps$1;
|
|
286
279
|
label?: React.ReactNode;
|
|
@@ -322,12 +315,12 @@ type SearchableV2Props<TFieldValues extends FieldValues = FieldValues, TFieldNam
|
|
|
322
315
|
getOptionAfterLabel?: (option: FieldValue | AutocompleteFreeSoloValueMapping<FreeSolo>) => string | React.ReactNode;
|
|
323
316
|
};
|
|
324
317
|
|
|
325
|
-
declare const _default$4: <
|
|
318
|
+
declare const _default$4: <FieldValue, Multiple extends boolean | undefined = undefined, DisableClearable extends boolean | undefined = undefined, FreeSolo extends boolean | undefined = undefined>(props: SearchableV2Props<FieldValue, Multiple, DisableClearable, FreeSolo>) => react_jsx_runtime.JSX.Element;
|
|
326
319
|
|
|
327
320
|
type FooterPropsV2 = {
|
|
328
321
|
closeSelect: () => void;
|
|
329
322
|
};
|
|
330
|
-
type SelectV2Props<
|
|
323
|
+
type SelectV2Props<FieldValue extends FieldValues | string | number> = Omit<SelectProps<FieldValue>, 'onChange' | 'multiple' | 'defaultValue' | 'variant'> & UseControllerProps & {
|
|
331
324
|
variant?: 'filled' | 'outlined' | 'standard';
|
|
332
325
|
/**
|
|
333
326
|
* As opções que serão renderizadas no select
|
|
@@ -359,23 +352,23 @@ type SelectV2Props<TFieldValues extends FieldValues = FieldValues, TFieldName ex
|
|
|
359
352
|
*/
|
|
360
353
|
clearable?: boolean;
|
|
361
354
|
placeholder?: string;
|
|
362
|
-
defaultValue?:
|
|
355
|
+
defaultValue?: FieldValue;
|
|
363
356
|
/**
|
|
364
357
|
* Define a key unica da option
|
|
365
358
|
*/
|
|
366
|
-
getOptionKey: (option:
|
|
359
|
+
getOptionKey: (option: FieldValue) => string | number;
|
|
367
360
|
/**
|
|
368
361
|
* Define a label da option
|
|
369
362
|
*/
|
|
370
|
-
getOptionLabel: (option:
|
|
363
|
+
getOptionLabel: (option: FieldValue) => string;
|
|
371
364
|
/**
|
|
372
365
|
* Componente renderizado embaixo da option da listagem
|
|
373
366
|
*/
|
|
374
|
-
getOptionAfterLabel?: (option:
|
|
367
|
+
getOptionAfterLabel?: (option: FieldValue) => string | React.ReactNode;
|
|
375
368
|
/**
|
|
376
369
|
* Ícone renderizado ao lado da label
|
|
377
370
|
*/
|
|
378
|
-
getOptionIcon?: (option:
|
|
371
|
+
getOptionIcon?: (option: FieldValue) => React.ReactNode;
|
|
379
372
|
};
|
|
380
373
|
type SelectV2ReturnValueProps<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = {
|
|
381
374
|
value: FieldPathValue<TFieldValues, TFieldName> | null;
|
|
@@ -383,9 +376,9 @@ type SelectV2ReturnValueProps<TFieldValues extends FieldValues = FieldValues, TF
|
|
|
383
376
|
getOptionLabel: (option: FieldPathValue<TFieldValues, TFieldName>) => string;
|
|
384
377
|
};
|
|
385
378
|
|
|
386
|
-
declare const _default$3: <
|
|
379
|
+
declare const _default$3: <FieldValue extends string | number | FieldValues>(props: SelectV2Props<FieldValue>) => react_jsx_runtime.JSX.Element;
|
|
387
380
|
|
|
388
|
-
type SliderProps
|
|
381
|
+
type SliderProps = SliderProps$1 & UseControllerProps & {
|
|
389
382
|
/**
|
|
390
383
|
* O nome do switch que será renderizado na tela
|
|
391
384
|
* @default ''
|
|
@@ -404,9 +397,9 @@ type SliderProps<TFieldValues extends FieldValues = FieldValues, TFieldName exte
|
|
|
404
397
|
labelPlacement?: 'start' | 'end' | 'top' | 'bottom';
|
|
405
398
|
};
|
|
406
399
|
|
|
407
|
-
declare const Slider:
|
|
400
|
+
declare const Slider: ({ name, rules, defaultValue, shouldUnregister, control: controlFromProps, ...rest }: SliderProps) => react_jsx_runtime.JSX.Element;
|
|
408
401
|
|
|
409
|
-
type SwitchProps
|
|
402
|
+
type SwitchProps = SwitchProps$1 & UseControllerProps & {
|
|
410
403
|
/**
|
|
411
404
|
* O nome do switch que será renderizado na tela
|
|
412
405
|
* @default ''
|
|
@@ -433,10 +426,10 @@ type SwitchProps<TFieldValues extends FieldValues = Record<string, boolean>, TFi
|
|
|
433
426
|
disableIconError?: boolean;
|
|
434
427
|
};
|
|
435
428
|
|
|
436
|
-
declare const _default$2:
|
|
429
|
+
declare const _default$2: ({ name, rules, defaultValue, shouldUnregister, control: controlFromProps, label, labelPlacement, disableIconError, onChange: onChangeProp, ...rest }: SwitchProps) => react_jsx_runtime.JSX.Element;
|
|
437
430
|
|
|
438
431
|
type Masks = 'cpf' | 'cnpj' | 'cpfCnpj' | 'cep' | 'telefone' | 'decimal' | 'decimal3' | 'decimal4' | 'decimal5' | 'porcentagem' | 'porcentagem0' | 'nome' | 'numero' | 'numeroPontuacao' | 'placa' | 'valor' | 'valor3' | 'valor4';
|
|
439
|
-
type TextFieldProps
|
|
432
|
+
type TextFieldProps = TextFieldProps$1 & UseControllerProps & {
|
|
440
433
|
mask?: Masks;
|
|
441
434
|
/**
|
|
442
435
|
* @description Função que será executada quando o valor do input for alterado
|
|
@@ -477,9 +470,9 @@ type TextFieldProps<TFieldValues extends FieldValues = Record<string, string>, T
|
|
|
477
470
|
disableIconError?: boolean;
|
|
478
471
|
};
|
|
479
472
|
|
|
480
|
-
declare const _default$1:
|
|
473
|
+
declare const _default$1: ({ name, rules, defaultValue, shouldUnregister, control: controlFromProps, label, required, mask, variant, info, parse, format, onInputChange, disableIconError, ...rest }: TextFieldProps) => react_jsx_runtime.JSX.Element;
|
|
481
474
|
|
|
482
|
-
type TimePickerProps
|
|
475
|
+
type TimePickerProps = UseControllerProps & Pick<TextFieldProps$1, 'label' | 'error' | 'helperText' | 'size' | 'fullWidth' | 'variant' | 'autoFocus' | 'placeholder'> & {
|
|
483
476
|
timePickerProps?: Partial<TimePickerProps$1<any>>;
|
|
484
477
|
/**
|
|
485
478
|
* Se `true` irá adicionar um asterisco ao label do campo
|
|
@@ -503,6 +496,6 @@ type TimePickerProps<TFieldValues extends FieldValues = FieldValues, TFieldName
|
|
|
503
496
|
disableIconError?: boolean;
|
|
504
497
|
};
|
|
505
498
|
|
|
506
|
-
declare const _default:
|
|
499
|
+
declare const _default: ({ rules, defaultValue, shouldUnregister, name, control: controlFromProps, required, label, timePickerProps, placeholder, disabled, disableIconError, ...rest }: TimePickerProps) => react_jsx_runtime.JSX.Element;
|
|
507
500
|
|
|
508
501
|
export { _default$7 as Checkbox, type CheckboxProps, _default$6 as CreatableV2, type CreatableV2Props, _default$5 as DatePicker, type DatePickerProps, FieldError, type FieldErrorProps, FieldInfo, type FieldInfoProps, FieldLabel, type FieldLabelProps, type FooterPropsV2, Form, FormProvider, type IFormProps, type IFormProviderProps, type IUseFormProps, type Masks, RadioButton, RadioGroup, type RadioGroupProps, type RadioProps, _default$4 as SearchableV2, type SearchableV2Props, _default$3 as SelectV2, type SelectV2Props, type SelectV2ReturnValueProps, Slider, type SliderProps, _default$2 as Switch, type SwitchProps, _default$1 as TextField, type TextFieldProps, _default as TimePicker, type TimePickerProps, useForm };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{useController as
|
|
1
|
+
import{useController as qe,useFormContext as Ge}from"react-hook-form";import{Checkbox as Ne,FormControlLabel as Ue}from"@mui/material";import{Indicator as Ee}from"@s_mart/core";import{useFormState as Be}from"react-hook-form";var R=(e,o)=>o.replace(/[[\]]/g,"").split(".").reduce((l,p)=>l?.[p],e);import{jsx as Me}from"react/jsx-runtime";var De=({name:e,disableIcon:o,control:r})=>{let l=Be({control:r,name:e}),p=R(l?.errors,e);return p?Me(Ee,{severity:"error",icon:o?!1:void 0,children:p?.message}):null},C=De;import{Typography as me}from"@mui/material";import{toRem as Ae}from"@s_mart/utils";import{jsx as ue,jsxs as $e}from"react/jsx-runtime";var Oe=({label:e,required:o,regular:r})=>$e("span",{style:{display:"flex",alignItems:"center",gap:Ae(2)},children:[ue(me,{variant:"caption",style:{display:"flex",alignItems:"center"},sx:{fontWeight:r?400:700},children:e}),o&&ue(me,{variant:"caption",color:"error",sx:{fontWeight:900},children:"*"})]}),x=Oe;var P=class extends Error{constructor(o){super(`O componente ${o} precisa de um control para funcionar. Passe o control como prop ou coloque o componente dentro de um <Form />`),this.name="FormComponentPrecisaDeControl"}};import{memo as ze}from"react";var I=ze;import{jsx as Q,jsxs as Ke}from"react/jsx-runtime";var _e=({name:e,rules:o,defaultValue:r,shouldUnregister:l,control:p,label:u,labelPlacement:f,required:s,disableIconError:b,onChange:y,...S})=>{let m=Ge()?.control,c=p??m;if(!c)throw new P("Checkbox");let{field:n}=qe({control:c,name:e,rules:o,defaultValue:r,shouldUnregister:l});return Ke("span",{children:[Q(Ue,{control:Q(Ne,{checked:!!n.value,value:n.value??"",defaultValue:n.value,onChange:(d,w)=>{n.onChange(d,w),y?.(d,w)},...S},e),label:Q(x,{label:u,required:s,regular:!0}),labelPlacement:f||"end"}),Q(C,{name:e,disableIcon:b,control:c})]})},He=I(_e);import{forwardRef as je,useCallback as eo,useState as oo}from"react";import{useController as to,useFormContext as ro,useFormState as lo}from"react-hook-form";import io from"lodash-es/isObject";import no from"lodash-es/isEmpty";import ao from"lodash-es/isEqual";import{Autocomplete as po,TextField as so,Divider as ye,Button as mo}from"@mui/material";import{LIcon as re}from"@s_mart/core";import{linePlus as Fe,linePen as uo}from"@s_mart/solid-icons";import{toRem as xe}from"@s_mart/utils";import{css as We,styled as Ye}from"@mui/material";import{toRem as Z}from"@s_mart/utils";var fe=We`
|
|
2
2
|
display: flex;
|
|
3
3
|
align-items: center;
|
|
4
4
|
justify-content: center;
|
|
@@ -49,22 +49,22 @@ import{useController as ze,useFormContext as qe}from"react-hook-form";import{Che
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
`;import{Tooltip as Je}from"@mui/material";import{LIcon as Xe}from"@s_mart/core";import{lineInfoCircle as Qe}from"@s_mart/solid-icons";import{jsx as te}from"react/jsx-runtime";var Ze=({title:e})=>te(Je,{title:e,placement:"top",children:te("div",{style:{width:"fit-content"},children:te(Xe,{icon:Qe,color:"#757575"})})}),_=Ze;import{Fragment as le,jsx as
|
|
52
|
+
`;import{Tooltip as Je}from"@mui/material";import{LIcon as Xe}from"@s_mart/core";import{lineInfoCircle as Qe}from"@s_mart/solid-icons";import{jsx as te}from"react/jsx-runtime";var Ze=({title:e})=>te(Je,{title:e,placement:"top",children:te("div",{style:{width:"fit-content"},children:te(Xe,{icon:Qe,color:"#757575"})})}),_=Ze;import{Fragment as le,jsx as V,jsxs as M}from"react/jsx-runtime";import{createElement as yo}from"react";function fo(e){let{name:o,rules:r,defaultValue:l,shouldUnregister:p,control:u,label:f,required:s,options:b,footer:y,showCreatableButton:S=!0,showEditableButton:m,onEditOption:c,onCreateOption:n,getOptionKey:d,getOptionLabel:w,getOptionAfterLabel:g,multiple:E,info:T,noOptionsText:i,onChange:h,onInputChange:O,placeholder:$,...F}=e,[U,B]=oo(""),a=ro()?.control,t=u??a;if(!t)throw new P("CreatableV2");let L=lo({control:t,name:o}),z=R(L.errors,o),J=!S||F.disabled,{field:Y}=to({name:o,control:t,rules:r,defaultValue:l,shouldUnregister:p}),Ie=k=>{let v=0;return e.slotProps?.textField?.slotProps?.input||(v+=2.5),J||(v+=2.56,se(k)&&(v+=2.56)),!F.disableClearable&&!F.disabled&&(v+=1.3),`${v}rem`},se=k=>F.disabled?!1:m&&io(k)&&!no(k),we=()=>F.disabled?!1:S,de=eo(()=>{typeof n<"u"&&(n(U),B(""))},[U,n]),Le=()=>{c?.(Y.value)};return M("div",{style:{display:"flex",flexDirection:"column"},children:[M("div",{style:{display:"flex"},children:[f&&V(x,{label:f,required:s}),T&&V(_,{title:T})]}),V(ce,{children:V(po,{fullWidth:!0,onChange:(k,v)=>{B(""),Y.onChange(v),h?.(v)},onInputChange:(k,v,H)=>{H==="input"&&(B(v),O?.(v))},slotProps:{...F.slotProps,listbox:{component:je(function(v,H){return M(le,{children:[V("ul",{...v,ref:H}),typeof y<"u"?M("div",{...v,children:[V("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:V(ye,{})}),y()]},"creatable-footer"):null]})})}},value:Y.value,options:b,multiple:E,readOnly:F.disabled,noOptionsText:M(le,{children:[i||"Nenhuma op\xE7\xE3o encontrada",!J&&M(mo,{sx:{justifyContent:"flex-start",padding:`${xe(6)} ${xe(-16)}`,margin:0},fullWidth:!0,onClick:de,variant:"text",startIcon:V(re,{icon:Fe}),children:["Adicionar ",`"${U}"`]}),typeof y<"u"&&M(le,{children:[V("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:V(ye,{})}),y()]})]}),isOptionEqualToValue:(k,v)=>ao(k,v),getOptionLabel:w,getOptionKey:d,renderOption:typeof g=="function"?(k,v)=>{let H=g(v),Re=d(v);return yo("li",{...k,key:Re},M("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[V("span",{children:w(v)}),typeof H=="string"?V("span",{children:H}):H]}))}:void 0,...F,sx:{"& div.MuiInputBase-root":{paddingRight:`${Ie(Y.value)} !important`},...F.sx},onBlur:k=>{F?.onBlur?.(k),B("")},renderInput:k=>V(so,{placeholder:$,...k,error:!!z,...e.slotProps?.textField,slotProps:{input:{...k.InputProps,...e.slotProps?.textField?.slotProps?.input,inputRef:Y.ref,endAdornment:M("div",{className:"endAdornments",children:[k.InputProps.endAdornment,e.slotProps?.textField?.slotProps?.input?.endAdornment??null,se(Y.value)?M("div",{className:"editable",children:[V("div",{className:"divider"}),V("div",{className:"button",onKeyUp:Le,children:V(re,{icon:uo,size:"24px",removeMargin:!0})})]}):null,we()&&M("div",{className:"creatable",children:[V("div",{className:"divider"}),V("div",{className:"button",onKeyUp:de,children:V(re,{icon:Fe,size:"24px",removeMargin:!0})})]})]})}}})},o)}),V(C,{name:o,control:t})]})}var co=I(fo);import{Stack as bo,TextField as go}from"@mui/material";import{AdapterDayjs as vo}from"@mui/x-date-pickers/AdapterDayjs";import{DatePicker as Co}from"@mui/x-date-pickers/DatePicker";import{LocalizationProvider as Vo}from"@mui/x-date-pickers/LocalizationProvider";import{ptBR as So}from"@mui/x-date-pickers/locales/ptBR";import{composeValidators as To,date as he}from"@s_mart/rules";import ko from"dayjs/locale/pt-br";import{useController as Io,useFormContext as wo,useFormState as Lo}from"react-hook-form";import{IconButton as Fo,styled as xo}from"@mui/material";import{toRem as q}from"@s_mart/utils";var Po=e=>{switch(e){case"small":return q(16);case"large":return q(24);default:return q(20)}},ho=e=>{switch(e){case"small":return`${q(2)} ${q(8)}`;case"large":return`${q(10)}`;default:return`${q(6)} ${q(8)}`}},Pe=xo(Fo)`
|
|
53
53
|
margin: 0px;
|
|
54
54
|
|
|
55
|
-
padding: ${({size:e})=>
|
|
56
|
-
border-radius: 0 ${
|
|
55
|
+
padding: ${({size:e})=>ho(e)};
|
|
56
|
+
border-radius: 0 ${q(4)} ${q(4)} 0;
|
|
57
57
|
|
|
58
58
|
svg {
|
|
59
|
-
width: ${({size:e})=>
|
|
59
|
+
width: ${({size:e})=>Po(e)} !important;
|
|
60
60
|
}
|
|
61
|
-
`;import{jsx as j,jsxs as Mo}from"react/jsx-runtime";import{createElement as Do}from"react";var Ro=({rules:e,name:o,defaultValue:r,shouldUnregister:l,control:d,datePickerProps:u,label:f,required:s,placeholder:h,disabled:F,disableIconError:C,...m})=>{let c=wo()?.control,a=d??c;if(!a)throw new x("DatePicker");let p=Lo({control:a,name:o}),L=R(p.errors,o),T=u?.format||"DD/MM/YYYY",E=e?So([Ve(T),e]):Ve(T),{field:S}=Io({control:a,name:o,rules:E,defaultValue:r,shouldUnregister:l});return j(vo,{dateAdapter:bo,adapterLocale:ko,localeText:Co.components.MuiLocalizationProvider.defaultProps.localeText,children:Mo(ho,{children:[f&&j(P,{label:f,required:s}),Do(go,{...u,key:o,value:S.value??null,format:T,onChange:(i,V)=>{S.onChange(i,V),u?.onChange?.(i,V)},disabled:F,slots:{textField:To,openPickerButton:i=>j(xe,{...i,size:m.size})},slotProps:{textField:i=>({variant:"outlined",...i,error:!!L,...m,inputProps:{...i.inputProps,placeholder:h||i.inputProps?.placeholder},InputProps:{...i.InputProps,inputRef:V=>{S.ref(V),typeof i.inputRef=="function"&&i.inputRef(V)}}})}}),j(g,{name:o,disableIcon:C,control:a})]})})},Eo=w(Ro);import{FormProvider as Bo}from"react-hook-form";import{jsx as he}from"react/jsx-runtime";function Ao({children:e,style:o,onSubmit:r,...l}){return he(Bo,{...l,children:he("form",{onSubmit:d=>{d.preventDefault(),d.stopPropagation(),r(d)},style:o,children:e})})}var ie=Ao;import{useEffect as No}from"react";import{useForm as Oo}from"react-hook-form";import{zodResolver as $o}from"@hookform/resolvers/zod";var zo=({disableDefaultValuesUpdate:e,onSubmit:o,...r})=>{let l=Oo({...r,resolver:r.schema&&$o(r.schema)});return No(()=>{e||l.reset(r.defaultValues)},[r.defaultValues,l.reset]),{...l,onSubmit:l.handleSubmit(d=>o(d,l))}},ae=zo;import{jsx as Uo}from"react/jsx-runtime";function qo({children:e,style:o,...r}){let l=ae(r);return Uo(ie,{...l,style:o,children:typeof e=="function"?e(l):e})}var Go=qo;import{RadioGroup as _o,Stack as Ho}from"@mui/material";import{useController as Ko,useFormContext as Wo}from"react-hook-form";import{jsx as ne,jsxs as Xo}from"react/jsx-runtime";var Yo=({name:e,rules:o,defaultValue:r,shouldUnregister:l,control:d,label:u,required:f,children:s,orientation:h="row",disableIconError:F,...C})=>{let m=Wo()?.control,c=d??m;if(!c)throw new x("RadioGroup");let{field:a}=Ko({control:c,name:e,rules:o,defaultValue:r,shouldUnregister:l});return Xo(Ho,{children:[u&&ne(P,{label:u,required:f}),ne(_o,{value:a.value||"",name:e,...C,onChange:p=>{C?.onChange?.(p,p.target?.value),a.onChange(p)},style:{display:"flex",flexDirection:h},children:s},e),ne(g,{name:e,disableIcon:F,control:c})]})},Jo=Yo;import{FormControlLabel as Qo,Grid2 as Zo,Radio as jo}from"@mui/material";import{jsx as ee}from"react/jsx-runtime";var et=({label:e,labelPlacement:o,...r})=>ee(Zo,{sx:{display:"flex",flexDirection:"column"},children:ee(Qo,{control:ee(jo,{...r}),label:ee(P,{label:e}),labelPlacement:o||"end"})}),ot=et;import{Autocomplete as tt,Divider as Te,TextField as rt}from"@mui/material";import lt from"lodash-es/isEqual";import{forwardRef as it}from"react";import{useController as at,useFormContext as nt,useFormState as dt}from"react-hook-form";import{Fragment as de,jsx as M,jsxs as K}from"react/jsx-runtime";import{createElement as mt}from"react";var st=e=>{let{name:o,rules:r,defaultValue:l,shouldUnregister:d,control:u,label:f,required:s,options:h,textFieldProps:F,noOptionsText:C,footer:m,multiple:c,info:a,placeholder:p,onChange:L,onInputChange:T,getOptionAfterLabel:E,getOptionLabel:S,getOptionKey:i,...V}=e,N=nt()?.control,O=u??N;if(!O)throw new x("SearchableV2");let y=dt({control:O,name:o}),U=R(y.errors,o),{field:D}=at({name:o,control:O,rules:r,defaultValue:l,shouldUnregister:d});return K("div",{style:{display:"flex",flexDirection:"column"},children:[K("div",{style:{display:"flex"},children:[f&&M(P,{label:f,required:s}),a&&M(_,{title:a})]}),M(tt,{onChange:(n,t)=>{D.onChange(t),L?.(t)},onInputChange:(n,t,I)=>{I==="input"&&T?.(t)},value:D.value,options:h,multiple:c,readOnly:V.disabled,slotProps:{...V.slotProps,listbox:{component:it(function(t,I){return K(de,{children:[M("ul",{...t,ref:I}),typeof m<"u"?K("div",{...t,children:[M("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:M(Te,{})}),m()]},"searchable-footer"):null]})})}},noOptionsText:K(de,{children:[C||"Nenhuma op\xE7\xE3o encontrada",typeof m<"u"?K(de,{children:[M("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:M(Te,{})}),m()]}):null]}),isOptionEqualToValue:(n,t)=>lt(n,t),getOptionLabel:S,getOptionKey:i,renderOption:typeof E=="function"?(n,t)=>{let I=E(t),$=i(t);return mt("li",{...n,key:$},K("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[M("span",{children:S(t)}),typeof I=="string"?M("span",{children:I}):I]}))}:void 0,...V,renderInput:n=>M(rt,{error:!!U,placeholder:p,...n,...F,inputRef:D.ref})},o),M(g,{name:o,control:O})]})},pt=w(st);import{useState as ct}from"react";import{useController as Ft,useFormContext as yt,useFormState as Pt}from"react-hook-form";import{IconButton as xt,LIcon as Vt}from"@s_mart/core";import{lineTimes as ht}from"@s_mart/regular-icons";import{colorPalette as Tt}from"@s_mart/tokens";import{Select as bt,MenuItem as gt,Divider as vt}from"@mui/material";import{colorPalette as ut}from"@s_mart/tokens";import{jsx as ft}from"react/jsx-runtime";var be=({value:e,placeholder:o,getOptionLabel:r})=>e===null||e?.length===0?ft("p",{style:{color:ut.neutral[100]},children:o}):r(e);import{Fragment as kt,jsx as A,jsxs as W}from"react/jsx-runtime";var Ct=e=>{let{name:o,rules:r,defaultValue:l,shouldUnregister:d,control:u,label:f,required:s,options:h,placeholder:F,clearable:C,info:m,footer:c,onChange:a,variant:p="outlined",getOptionKey:L,getOptionLabel:T,getOptionAfterLabel:E,getOptionIcon:S,...i}=e,V=yt()?.control,N=u??V,[O,y]=ct(!1);if(!N)throw new x("SelectV2");let U=Pt({control:N,name:o}),D=R(U.errors,o),{field:n}=Ft({control:N,name:o,rules:r,defaultValue:l,shouldUnregister:d});return W("div",{style:{display:"flex",flexDirection:"column"},children:[W("div",{style:{display:"flex"},children:[f&&A(P,{label:f,required:s}),m&&A(_,{title:m})]}),W(bt,{open:O,onOpen:()=>y(!0),onClose:()=>y(!1),displayEmpty:!!F,variant:p,autoComplete:"off",value:n.value||null,renderValue:t=>A(be,{getOptionLabel:T,placeholder:F,value:t}),onChange:t=>{n.onChange(t.target.value),a?.(t.target.value)},error:!!D,size:i.size||"medium",inputRef:n.ref,...i,endAdornment:W(kt,{children:[i.endAdornment,!!(C&&n.value)&&A(xt,{variant:"text",color:"neutral",size:"small",sx:{borderRadius:"50%",position:"absolute",right:"2rem"},style:{padding:0},"aria-label":"Limpar",title:"Limpar",onClick:()=>{n.onChange(null),a?.(null)},children:A(Vt,{icon:ht,color:Tt.neutral[100],size:"25px",removeMargin:!0})})]}),children:[h.map(t=>{let I=L(t),$=T(t),J=S?.(t);return A(gt,{value:I??$,children:W("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[J!==void 0?W("div",{style:{display:"flex",alignItems:"center"},children:[J,$]}):$,A("span",{children:E?.(t)??null})]})},I)}),c!==void 0&&W("div",{children:[A("div",{style:{padding:"8px 16px"},children:A(vt,{})},"footer-divider"),A("div",{children:c({closeSelect:()=>y(!1)})},"footer-content")]},"footer")]},o),A(g,{name:o,control:N})]})},St=w(Ct);import{useController as It,useFormContext as wt}from"react-hook-form";import{Slider as Lt}from"@mui/material";import{jsx as Dt}from"react/jsx-runtime";var Rt=({name:e,rules:o,defaultValue:r,shouldUnregister:l,control:d,...u})=>{let f=wt()?.control,s=d??f;if(!s)throw new x("Slider");let{field:h}=It({control:s,name:e,rules:o,defaultValue:r,shouldUnregister:l});return Dt(Lt,{value:h.value||u?.min||0,onChange:h.onChange,valueLabelDisplay:"auto",...u},e)},Et=Rt;import{FormControlLabel as Mt,Stack as Bt,Switch as At}from"@mui/material";import{useController as Nt,useFormContext as Ot}from"react-hook-form";import{jsx as oe,jsxs as qt}from"react/jsx-runtime";var $t=({name:e,rules:o,defaultValue:r,shouldUnregister:l,control:d,label:u,labelPlacement:f,disableIconError:s,onChange:h,...F})=>{let C=Ot()?.control,m=d??C;if(!m)throw new x("Switch");let{field:c}=Nt({control:m,name:e,rules:o,defaultValue:r,shouldUnregister:l});return qt(Bt,{children:[oe(Mt,{control:oe(At,{value:c.value??"",checked:c.value??!1,onChange:(a,p)=>{c.onChange(a,p),h?.(a,p)},...F},e),label:oe(P,{label:u}),labelPlacement:f||"end"}),oe(g,{name:e,disableIcon:s,control:m})]})},zt=w($t);import{InputAdornment as Gt,Stack as Ut,TextField as _t,Tooltip as Ht}from"@mui/material";import{LIcon as ge}from"@s_mart/core";import*as ve from"@s_mart/masks";import{lineEye as Kt,lineEyeSlash as Wt,lineInfoCircle as Yt}from"@s_mart/solid-icons";import{useRef as Jt,useState as Xt}from"react";import{useController as Qt,useFormContext as Zt,useFormState as jt}from"react-hook-form";import{jsx as q,jsxs as Ce}from"react/jsx-runtime";var er=({name:e,rules:o,defaultValue:r,shouldUnregister:l,control:d,label:u,required:f,mask:s,variant:h="outlined",info:F,parse:C,format:m,onInputChange:c,disableIconError:a,...p})=>{let L=Zt()?.control,T=d??L,E=Jt(r||void 0);if(!T)throw new x("TextField");let[S,i]=Xt(!1),V=n=>{let t=n;return t=m?.(n)??n,s?ve?.[s]?.format(t):t},N=n=>{let t=n;return t=C?.(n)??t,s?ve?.[s]?.parse(t,E.current):t},O=n=>{if(!n||s!=="porcentagem"&&s!=="porcentagem0")return;n?.stopPropagation();let t=(n?.target).value;if(t){let I=String(t);if(I.length>0){let $=I.indexOf("%");$>-1&&(n.currentTarget.selectionEnd=$)}}},{field:y}=Qt({control:T,name:e,rules:o,defaultValue:r,shouldUnregister:l}),U=jt({control:T,name:e}),D=R(U.errors,e);return Ce(Ut,{children:[Ce("div",{style:{display:"flex"},children:[u&&q("div",{children:q(P,{label:u,required:f})}),F&&q("div",{children:q(Ht,{title:F,placement:"top",children:q("div",{style:{width:"fit-content"},children:q(ge,{icon:Yt,color:"#757575"})})})})]}),q(_t,{variant:h,defaultValue:r,value:V(y.value||(y.value!=0?"":y.value)),onChange:n=>{let t=N(n?.target?.value);y.onChange(t),c?.(t),E.current=n.target.value},error:!!D,...p,type:p.type==="password"?S?"text":"password":p.type,autoComplete:p.autoComplete||"off",slotProps:{input:{onKeyDown:O,inputRef:y.ref,endAdornment:p.type==="password"&&q(Gt,{position:"start",onClick:()=>i(!S),style:{cursor:"pointer"},children:q(ge,{icon:S?Kt:Wt,size:"24px",removeMargin:!0})}),...p.slotProps?.input}}},e),q(g,{name:e,disableIcon:a,control:T})]})},or=w(er);import{Stack as ar,TextField as nr}from"@mui/material";import{AdapterDayjs as dr}from"@mui/x-date-pickers/AdapterDayjs";import{LocalizationProvider as sr}from"@mui/x-date-pickers/LocalizationProvider";import{TimePicker as pr}from"@mui/x-date-pickers/TimePicker";import{ptBR as mr}from"@mui/x-date-pickers/locales/ptBR";import{composeValidators as ur,time as ke}from"@s_mart/rules";import fr from"dayjs/locale/pt-br";import{useController as cr,useFormContext as Fr,useFormState as yr}from"react-hook-form";import{styled as tr}from"@mui/material";import{IconButton as rr}from"@mui/material";import{toRem as G}from"@s_mart/utils";var lr=e=>{switch(e){case"small":return G(16);case"large":return G(24);default:return G(20)}},ir=e=>{switch(e){case"small":return`${G(2)} ${G(8)}`;case"large":return G(10);default:return`${G(6)} ${G(8)}`}},Se=tr(rr)`
|
|
61
|
+
`;import{jsx as j,jsxs as Do}from"react/jsx-runtime";import{createElement as Bo}from"react";var Ro=({rules:e,name:o,defaultValue:r,shouldUnregister:l,control:p,datePickerProps:u,label:f,required:s,placeholder:b,disabled:y,disableIconError:S,...m})=>{let c=wo()?.control,n=p??c;if(!n)throw new P("DatePicker");let d=Lo({control:n,name:o}),w=R(d.errors,o),g=u?.format||"DD/MM/YYYY",E=e?To([he(g),e]):he(g),{field:T}=Io({control:n,name:o,rules:E,defaultValue:r,shouldUnregister:l});return j(Vo,{dateAdapter:vo,adapterLocale:ko,localeText:So.components.MuiLocalizationProvider.defaultProps.localeText,children:Do(bo,{children:[f&&j(x,{label:f,required:s}),Bo(Co,{...u,key:o,value:T.value??null,format:g,onChange:(i,h)=>{T.onChange(i,h),u?.onChange?.(i,h)},disabled:y,slots:{textField:go,openPickerButton:i=>j(Pe,{...i,size:m.size})},slotProps:{textField:i=>({variant:"outlined",...i,error:!!w,...m,inputProps:{...i.inputProps,placeholder:b||i.inputProps?.placeholder},InputProps:{...i.InputProps,inputRef:h=>{T.ref(h),typeof i.inputRef=="function"&&i.inputRef(h)}}})}}),j(C,{name:o,disableIcon:S,control:n})]})})},Eo=I(Ro);import{FormProvider as Mo}from"react-hook-form";import{jsx as be}from"react/jsx-runtime";function Ao({children:e,style:o,onSubmit:r,...l}){return be(Mo,{...l,children:be("form",{onSubmit:p=>{p.preventDefault(),p.stopPropagation(),r(p)},style:o,children:e})})}var ie=Ao;import{useEffect as Oo}from"react";import{useForm as $o}from"react-hook-form";import{zodResolver as zo}from"@hookform/resolvers/zod";var qo=({disableDefaultValuesUpdate:e,onSubmit:o,...r})=>{let l=$o({...r,resolver:r.schema&&zo(r.schema)});return Oo(()=>{e||l.reset(r.defaultValues)},[r.defaultValues,l.reset]),{...l,onSubmit:l.handleSubmit(p=>o(p,l))}},ne=qo;import{jsx as Uo}from"react/jsx-runtime";function Go({children:e,style:o,...r}){let l=ne(r);return Uo(ie,{...l,style:o,children:typeof e=="function"?e(l):e})}var No=Go;import{RadioGroup as _o,Stack as Ho}from"@mui/material";import{useController as Ko,useFormContext as Wo}from"react-hook-form";import{jsx as ae,jsxs as Xo}from"react/jsx-runtime";var Yo=({name:e,rules:o,defaultValue:r,shouldUnregister:l,control:p,label:u,required:f,children:s,orientation:b="row",disableIconError:y,...S})=>{let m=Wo()?.control,c=p??m;if(!c)throw new P("RadioGroup");let{field:n}=Ko({control:c,name:e,rules:o,defaultValue:r,shouldUnregister:l});return Xo(Ho,{children:[u&&ae(x,{label:u,required:f}),ae(_o,{value:n.value||"",name:e,...S,onChange:d=>{S?.onChange?.(d,d.target?.value),n.onChange(d)},style:{display:"flex",flexDirection:b},children:s},e),ae(C,{name:e,disableIcon:y,control:c})]})},Jo=Yo;import{FormControlLabel as Qo,Grid2 as Zo,Radio as jo}from"@mui/material";import{jsx as ee}from"react/jsx-runtime";var et=({label:e,labelPlacement:o,...r})=>ee(Zo,{sx:{display:"flex",flexDirection:"column"},children:ee(Qo,{control:ee(jo,{...r}),label:ee(x,{label:e}),labelPlacement:o||"end"})}),ot=et;import{Autocomplete as tt,Divider as ge,TextField as rt}from"@mui/material";import lt from"lodash-es/isEqual";import{forwardRef as it}from"react";import{useController as nt,useFormContext as at,useFormState as pt}from"react-hook-form";import{Fragment as pe,jsx as D,jsxs as K}from"react/jsx-runtime";import{createElement as mt}from"react";var st=e=>{let{name:o,rules:r,defaultValue:l,shouldUnregister:p,control:u,label:f,required:s,options:b,textFieldProps:y,noOptionsText:S,footer:m,multiple:c,info:n,placeholder:d,onChange:w,onInputChange:g,getOptionAfterLabel:E,getOptionLabel:T,getOptionKey:i,...h}=e,O=at()?.control,$=u??O;if(!$)throw new P("SearchableV2");let F=pt({control:$,name:o}),U=R(F.errors,o),{field:B}=nt({name:o,control:$,rules:r,defaultValue:l,shouldUnregister:p});return K("div",{style:{display:"flex",flexDirection:"column"},children:[K("div",{style:{display:"flex"},children:[f&&D(x,{label:f,required:s}),n&&D(_,{title:n})]}),D(tt,{onChange:(a,t)=>{B.onChange(t),w?.(t)},onInputChange:(a,t,L)=>{L==="input"&&g?.(t)},value:B.value,options:b,multiple:c,readOnly:h.disabled,slotProps:{...h.slotProps,listbox:{component:it(function(t,L){return K(pe,{children:[D("ul",{...t,ref:L}),typeof m<"u"?K("div",{...t,children:[D("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:D(ge,{})}),m()]},"searchable-footer"):null]})})}},noOptionsText:K(pe,{children:[S||"Nenhuma op\xE7\xE3o encontrada",typeof m<"u"?K(pe,{children:[D("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:D(ge,{})}),m()]}):null]}),isOptionEqualToValue:(a,t)=>lt(a,t),getOptionLabel:T,getOptionKey:i,renderOption:typeof E=="function"?(a,t)=>{let L=E(t),z=i(t);return mt("li",{...a,key:z},K("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[D("span",{children:T(t)}),typeof L=="string"?D("span",{children:L}):L]}))}:void 0,...h,renderInput:a=>D(rt,{error:!!U,placeholder:d,...a,...y,inputRef:B.ref})},o),D(C,{name:o,control:$})]})},dt=I(st);import{useState as ct}from"react";import{useController as yt,useFormContext as Ft,useFormState as xt}from"react-hook-form";import{IconButton as Pt,LIcon as ht}from"@s_mart/core";import{lineTimes as bt}from"@s_mart/regular-icons";import{colorPalette as gt}from"@s_mart/tokens";import{Select as vt,MenuItem as Ct,Divider as Vt}from"@mui/material";import{colorPalette as ut}from"@s_mart/tokens";import{jsx as ft}from"react/jsx-runtime";var ve=({value:e,placeholder:o,getOptionLabel:r})=>e===null||e?.length===0?ft("p",{style:{color:ut.neutral[100]},children:o}):r(e);import{Fragment as kt,jsx as A,jsxs as W}from"react/jsx-runtime";var St=e=>{let{name:o,rules:r,defaultValue:l,shouldUnregister:p,control:u,label:f,required:s,options:b,placeholder:y,clearable:S,info:m,footer:c,onChange:n,variant:d="outlined",getOptionKey:w,getOptionLabel:g,getOptionAfterLabel:E,getOptionIcon:T,...i}=e,h=Ft()?.control,O=u??h,[$,F]=ct(!1);if(!O)throw new P("SelectV2");let U=xt({control:O,name:o}),B=R(U.errors,o),{field:a}=yt({control:O,name:o,rules:r,defaultValue:l,shouldUnregister:p});return W("div",{style:{display:"flex",flexDirection:"column"},children:[W("div",{style:{display:"flex"},children:[f&&A(x,{label:f,required:s}),m&&A(_,{title:m})]}),W(vt,{open:$,onOpen:()=>F(!0),onClose:()=>F(!1),displayEmpty:!!y,variant:d,autoComplete:"off",value:a.value||null,renderValue:t=>A(ve,{getOptionLabel:g,placeholder:y,value:t}),onChange:t=>{a.onChange(t.target.value),n?.(t.target.value)},error:!!B,size:i.size||"medium",inputRef:a.ref,...i,endAdornment:W(kt,{children:[i.endAdornment,!!(S&&a.value)&&A(Pt,{variant:"text",color:"neutral",size:"small",sx:{borderRadius:"50%",position:"absolute",right:"2rem"},style:{padding:0},"aria-label":"Limpar",title:"Limpar",onClick:()=>{a.onChange(null),n?.(null)},children:A(ht,{icon:bt,color:gt.neutral[100],size:"25px",removeMargin:!0})})]}),children:[b.map(t=>{let L=w(t),z=g(t),J=T?.(t);return A(Ct,{value:L??z,children:W("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[J!==void 0?W("div",{style:{display:"flex",alignItems:"center"},children:[J,z]}):z,A("span",{children:E?.(t)??null})]})},L)}),c!==void 0&&W("div",{children:[A("div",{style:{padding:"8px 16px"},children:A(Vt,{})},"footer-divider"),A("div",{children:c({closeSelect:()=>F(!1)})},"footer-content")]},"footer")]},o),A(C,{name:o,control:O})]})},Tt=I(St);import{useController as It,useFormContext as wt}from"react-hook-form";import{Slider as Lt}from"@mui/material";import{jsx as Bt}from"react/jsx-runtime";var Rt=({name:e,rules:o,defaultValue:r,shouldUnregister:l,control:p,...u})=>{let f=wt()?.control,s=p??f;if(!s)throw new P("Slider");let{field:b}=It({control:s,name:e,rules:o,defaultValue:r,shouldUnregister:l});return Bt(Lt,{value:b.value||u?.min||0,onChange:b.onChange,valueLabelDisplay:"auto",...u},e)},Et=Rt;import{FormControlLabel as Dt,Stack as Mt,Switch as At}from"@mui/material";import{useController as Ot,useFormContext as $t}from"react-hook-form";import{jsx as oe,jsxs as Gt}from"react/jsx-runtime";var zt=({name:e,rules:o,defaultValue:r,shouldUnregister:l,control:p,label:u,labelPlacement:f,disableIconError:s,onChange:b,...y})=>{let S=$t()?.control,m=p??S;if(!m)throw new P("Switch");let{field:c}=Ot({control:m,name:e,rules:o,defaultValue:r,shouldUnregister:l});return Gt(Mt,{children:[oe(Dt,{control:oe(At,{value:c.value??"",checked:c.value??!1,onChange:(n,d)=>{c.onChange(n,d),b?.(n,d)},...y},e),label:oe(x,{label:u}),labelPlacement:f||"end"}),oe(C,{name:e,disableIcon:s,control:m})]})},qt=I(zt);import{InputAdornment as Nt,Stack as Ut,TextField as _t,Tooltip as Ht}from"@mui/material";import{LIcon as Ce}from"@s_mart/core";import*as Ve from"@s_mart/masks";import{lineEye as Kt,lineEyeSlash as Wt,lineInfoCircle as Yt}from"@s_mart/solid-icons";import{useRef as Jt,useState as Xt}from"react";import{useController as Qt,useFormContext as Zt,useFormState as jt}from"react-hook-form";import{jsx as G,jsxs as Se}from"react/jsx-runtime";var er=({name:e,rules:o,defaultValue:r,shouldUnregister:l,control:p,label:u,required:f,mask:s,variant:b="outlined",info:y,parse:S,format:m,onInputChange:c,disableIconError:n,...d})=>{let w=Zt()?.control,g=p??w,E=Jt(r||void 0);if(!g)throw new P("TextField");let[T,i]=Xt(!1),h=a=>{let t=a;return t=m?.(a)??a,s?Ve?.[s]?.format(t):t},O=a=>{let t=a;return t=S?.(a)??t,s?Ve?.[s]?.parse(t,E.current):t},$=a=>{if(!a||s!=="porcentagem"&&s!=="porcentagem0")return;a?.stopPropagation();let t=(a?.target).value;if(t){let L=String(t);if(L.length>0){let z=L.indexOf("%");z>-1&&(a.currentTarget.selectionEnd=z)}}},{field:F}=Qt({control:g,name:e,rules:o,defaultValue:r,shouldUnregister:l}),U=jt({control:g,name:e}),B=R(U.errors,e);return Se(Ut,{children:[Se("div",{style:{display:"flex"},children:[u&&G("div",{children:G(x,{label:u,required:f})}),y&&G("div",{children:G(Ht,{title:y,placement:"top",children:G("div",{style:{width:"fit-content"},children:G(Ce,{icon:Yt,color:"#757575"})})})})]}),G(_t,{variant:b,defaultValue:r,value:h(F.value||(F.value!=0?"":F.value)),onChange:a=>{let t=O(a?.target?.value);F.onChange(t),c?.(t),E.current=a.target.value},error:!!B,...d,type:d.type==="password"?T?"text":"password":d.type,autoComplete:d.autoComplete||"off",slotProps:{input:{onKeyDown:$,inputRef:F.ref,endAdornment:d.type==="password"&&G(Nt,{position:"start",onClick:()=>i(!T),style:{cursor:"pointer"},children:G(Ce,{icon:T?Kt:Wt,size:"24px",removeMargin:!0})}),...d.slotProps?.input}}},e),G(C,{name:e,disableIcon:n,control:g})]})},or=I(er);import{Stack as nr,TextField as ar}from"@mui/material";import{AdapterDayjs as pr}from"@mui/x-date-pickers/AdapterDayjs";import{LocalizationProvider as sr}from"@mui/x-date-pickers/LocalizationProvider";import{TimePicker as dr}from"@mui/x-date-pickers/TimePicker";import{ptBR as mr}from"@mui/x-date-pickers/locales/ptBR";import{composeValidators as ur,time as ke}from"@s_mart/rules";import fr from"dayjs/locale/pt-br";import{useController as cr,useFormContext as yr,useFormState as Fr}from"react-hook-form";import{styled as tr}from"@mui/material";import{IconButton as rr}from"@mui/material";import{toRem as N}from"@s_mart/utils";var lr=e=>{switch(e){case"small":return N(16);case"large":return N(24);default:return N(20)}},ir=e=>{switch(e){case"small":return`${N(2)} ${N(8)}`;case"large":return N(10);default:return`${N(6)} ${N(8)}`}},Te=tr(rr)`
|
|
62
62
|
margin: 0px;
|
|
63
63
|
|
|
64
64
|
padding: ${({size:e})=>ir(e)};
|
|
65
|
-
border-radius: 0 ${
|
|
65
|
+
border-radius: 0 ${N(4)} ${N(4)} 0;
|
|
66
66
|
|
|
67
67
|
svg {
|
|
68
68
|
width: ${({size:e})=>lr(e)} !important;
|
|
69
69
|
}
|
|
70
|
-
`;import{jsx as X,jsxs as
|
|
70
|
+
`;import{jsx as X,jsxs as hr}from"react/jsx-runtime";var xr=({rules:e,defaultValue:o,shouldUnregister:r,name:l,control:p,required:u,label:f,timePickerProps:s,placeholder:b,disabled:y,disableIconError:S,...m})=>{let c=yr()?.control,n=p??c;if(!n)throw new P("TimePicker");let d=Fr({control:n,name:l}),w=R(d.errors,l),g=s?.format||"HH:mm",E=e?ur([ke(g),e]):ke(g),{field:T}=cr({control:n,name:l,rules:E,defaultValue:o,shouldUnregister:r});return X(sr,{dateAdapter:pr,adapterLocale:fr,localeText:mr.components.MuiLocalizationProvider.defaultProps.localeText,children:hr(nr,{children:[f&&X(x,{label:f,required:u}),X(dr,{ampm:!1,format:g,value:T.value??null,disabled:y,...s,onChange:(i,h)=>{T.onChange(i,h),s?.onChange?.(i,h)},slots:{textField:ar,openPickerButton:i=>X(Te,{...i,size:m.size})},slotProps:{textField:i=>({variant:"outlined",...i,error:!!w,...m,inputProps:{...i.inputProps,placeholder:b||i.inputProps?.placeholder},InputProps:{...i.InputProps,inputRef:h=>{T.ref(h),typeof i.inputRef=="function"&&i.inputRef(h)}}})}},l),X(C,{name:l,disableIcon:S,control:n})]})})},Pr=I(xr);export{He as Checkbox,co as CreatableV2,Eo as DatePicker,C as FieldError,_ as FieldInfo,x as FieldLabel,No as Form,ie as FormProvider,ot as RadioButton,Jo as RadioGroup,dt as SearchableV2,Tt as SelectV2,Et as Slider,qt as Switch,or as TextField,Pr as TimePicker,ne as useForm};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@s_mart/form",
|
|
3
|
-
"version": "10.0.0-beta.
|
|
3
|
+
"version": "10.0.0-beta.14",
|
|
4
4
|
"main": "./dist/index.mjs",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.mts",
|
|
@@ -12,9 +12,7 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@hookform/resolvers": "^3.1.0",
|
|
14
14
|
"lodash-es": "^4.17.21",
|
|
15
|
-
"tsup": "8.0.2"
|
|
16
|
-
"@s_mart/regular-icons": "6.0.10",
|
|
17
|
-
"@s_mart/solid-icons": "6.0.7"
|
|
15
|
+
"tsup": "8.0.2"
|
|
18
16
|
},
|
|
19
17
|
"peerDependencies": {
|
|
20
18
|
"@emotion/react": "^11.11.4",
|
|
@@ -32,9 +30,11 @@
|
|
|
32
30
|
"react-hook-form": "^7.51.0",
|
|
33
31
|
"typescript": ">=5.4.2",
|
|
34
32
|
"zod": "^3.22.4",
|
|
35
|
-
"@s_mart/
|
|
33
|
+
"@s_mart/regular-icons": "6.0.10",
|
|
34
|
+
"@s_mart/core": "10.0.0-beta.8",
|
|
36
35
|
"@s_mart/masks": "5.2.0",
|
|
37
36
|
"@s_mart/rules": "5.1.2-beta.0",
|
|
37
|
+
"@s_mart/solid-icons": "6.0.7",
|
|
38
38
|
"@s_mart/tokens": "5.1.1",
|
|
39
39
|
"@s_mart/typed": "7.2.3",
|
|
40
40
|
"@s_mart/utils": "5.3.4"
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"@types/react-dom": ">=18.3.1",
|
|
51
51
|
"dayjs": "^1.11.10",
|
|
52
52
|
"typescript": ">=5.4.2",
|
|
53
|
+
"@s_mart/core": "10.0.0-beta.8",
|
|
53
54
|
"@s_mart/masks": "5.2.0",
|
|
54
|
-
"@s_mart/core": "10.0.0-beta.5",
|
|
55
55
|
"@s_mart/rules": "5.1.2-beta.0",
|
|
56
56
|
"@s_mart/tokens": "5.1.1",
|
|
57
57
|
"@s_mart/typed": "7.2.3",
|