@s_mart/form 3.2.2 → 3.3.0
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.ts +33 -5
- package/dist/index.js +15 -15
- package/dist/index.mjs +15 -15
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
2
|
+
import * as react_hook_form from 'react-hook-form';
|
|
3
|
+
import { FieldValues, UseFormReturn, FormProviderProps, UseFormProps, ControllerProps, UseControllerProps } from 'react-hook-form';
|
|
3
4
|
import { z } from 'zod';
|
|
4
5
|
import * as react from 'react';
|
|
5
6
|
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
7
|
import { DatePickerProps as DatePickerProps$1, TimePickerProps as TimePickerProps$1 } from '@mui/x-date-pickers';
|
|
7
8
|
|
|
8
|
-
interface IFormProps<T extends FieldValues> extends
|
|
9
|
-
onSubmit: (data: T, methods: UseFormReturn<T>) => void;
|
|
9
|
+
interface IFormProps<T extends FieldValues> extends IUseFormProps<T> {
|
|
10
10
|
children: ((methods: UseFormReturn<T> & {
|
|
11
11
|
onSubmit: (e?: React.FormEvent | undefined) => Promise<void>;
|
|
12
12
|
}) => React.ReactNode) | React.ReactNode;
|
|
13
13
|
style?: React.HTMLAttributes<HTMLFormElement>['style'];
|
|
14
|
+
}
|
|
15
|
+
interface IFormProviderProps extends FormProviderProps<any> {
|
|
16
|
+
style?: React.HTMLAttributes<HTMLFormElement>['style'];
|
|
17
|
+
onSubmit: (e?: React.BaseSyntheticEvent) => void;
|
|
18
|
+
}
|
|
19
|
+
interface IUseFormProps<TValues extends FieldValues> extends Omit<UseFormProps<TValues>, 'resolver'> {
|
|
20
|
+
onSubmit: (data: TValues, methods: UseFormReturn<TValues>) => void;
|
|
14
21
|
/**
|
|
15
22
|
* Prop que faz com que o formulário não atualize ao mudar o defaultValue
|
|
16
23
|
*/
|
|
@@ -18,7 +25,28 @@ interface IFormProps<T extends FieldValues> extends Omit<UseFormProps, 'resolver
|
|
|
18
25
|
schema?: z.ZodObject<any> | z.ZodEffects<z.ZodObject<any>>;
|
|
19
26
|
}
|
|
20
27
|
|
|
21
|
-
declare function Form({ children,
|
|
28
|
+
declare function Form({ children, style, ...useFormProps }: IFormProps<any>): react_jsx_runtime.JSX.Element;
|
|
29
|
+
|
|
30
|
+
declare const useForm: <TValues extends FieldValues>({ disableDefaultValuesUpdate, onSubmit, ...rest }: IUseFormProps<TValues>) => {
|
|
31
|
+
onSubmit: (e?: react.BaseSyntheticEvent<object, any, any> | undefined) => Promise<void>;
|
|
32
|
+
watch: react_hook_form.UseFormWatch<TValues>;
|
|
33
|
+
getValues: react_hook_form.UseFormGetValues<TValues>;
|
|
34
|
+
getFieldState: react_hook_form.UseFormGetFieldState<TValues>;
|
|
35
|
+
setError: react_hook_form.UseFormSetError<TValues>;
|
|
36
|
+
clearErrors: react_hook_form.UseFormClearErrors<TValues>;
|
|
37
|
+
setValue: react_hook_form.UseFormSetValue<TValues>;
|
|
38
|
+
trigger: react_hook_form.UseFormTrigger<TValues>;
|
|
39
|
+
formState: react_hook_form.FormState<TValues>;
|
|
40
|
+
resetField: react_hook_form.UseFormResetField<TValues>;
|
|
41
|
+
reset: react_hook_form.UseFormReset<TValues>;
|
|
42
|
+
handleSubmit: react_hook_form.UseFormHandleSubmit<TValues>;
|
|
43
|
+
unregister: react_hook_form.UseFormUnregister<TValues>;
|
|
44
|
+
control: react_hook_form.Control<TValues, any>;
|
|
45
|
+
register: react_hook_form.UseFormRegister<TValues>;
|
|
46
|
+
setFocus: react_hook_form.UseFormSetFocus<TValues>;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
declare const FormProvider: ({ children, style, onSubmit, ...methods }: IFormProviderProps) => react_jsx_runtime.JSX.Element;
|
|
22
50
|
|
|
23
51
|
type ControllerTextField = Omit<ControllerProps, 'render' | 'control'>;
|
|
24
52
|
type Masks = 'cpf' | 'cnpj' | 'cpfCnpj' | 'cep' | 'telefone' | 'decimal' | 'decimal3' | 'decimal4' | 'decimal5' | 'porcentagem' | 'porcentagem0' | 'nome' | 'numero' | 'numeroPontuacao' | 'placa' | 'valor';
|
|
@@ -444,4 +472,4 @@ type AutocompleteProps<T = any> = Omit<UseControllerProps, 'control'> & Omit<Aut
|
|
|
444
472
|
|
|
445
473
|
declare const _default: react.MemoExoticComponent<({ name, defaultValue, rules, shouldUnregister, label, required, noOptionsText, placeholder, onInputChange, onChange, ...rest }: AutocompleteProps) => react_jsx_runtime.JSX.Element>;
|
|
446
474
|
|
|
447
|
-
export { _default as Autocomplete, AutocompleteProps, Checkbox, CheckboxProps, _default$3 as Creatable, CreatableOption, CreatableProps, _default$2 as DatePicker, DatePickerProps, FooterProps, Form, IFormProps, RadioButton, RadioGroup, RadioGroupProps, RadioProps, _default$4 as Searchable, SearchableOption, SearchableProps, _default$5 as Select, SelectOption, SelectProps, Slider, SliderProps, Switch, SwitchProps, _default$6 as TextField, TextFieldProps, _default$1 as TimePicker, TimePickerProps };
|
|
475
|
+
export { _default as Autocomplete, AutocompleteProps, Checkbox, CheckboxProps, _default$3 as Creatable, CreatableOption, CreatableProps, _default$2 as DatePicker, DatePickerProps, FooterProps, Form, FormProvider, IFormProps, IFormProviderProps, IUseFormProps, RadioButton, RadioGroup, RadioGroupProps, RadioProps, _default$4 as Searchable, SearchableOption, SearchableProps, _default$5 as Select, SelectOption, SelectProps, Slider, SliderProps, Switch, SwitchProps, _default$6 as TextField, TextFieldProps, _default$1 as TimePicker, TimePickerProps, useForm };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";var I0=Object.create;var o1=Object.defineProperty,q0=Object.defineProperties,$0=Object.getOwnPropertyDescriptor,z0=Object.getOwnPropertyDescriptors,U0=Object.getOwnPropertyNames,Z1=Object.getOwnPropertySymbols,O0=Object.getPrototypeOf,E1=Object.prototype.hasOwnProperty,O1=Object.prototype.propertyIsEnumerable;var U1=(c,l,i)=>l in c?o1(c,l,{enumerable:!0,configurable:!0,writable:!0,value:i}):c[l]=i,a=(c,l)=>{for(var i in l||(l={}))E1.call(l,i)&&U1(c,i,l[i]);if(Z1)for(var i of Z1(l))O1.call(l,i)&&U1(c,i,l[i]);return c},t=(c,l)=>q0(c,z0(l));var g=(c,l)=>{var i={};for(var r in c)E1.call(c,r)&&l.indexOf(r)<0&&(i[r]=c[r]);if(c!=null&&Z1)for(var r of Z1(c))l.indexOf(r)<0&&O1.call(c,r)&&(i[r]=c[r]);return i};var _0=(c,l)=>{for(var i in l)o1(c,i,{get:l[i],enumerable:!0})},_1=(c,l,i,r)=>{if(l&&typeof l=="object"||typeof l=="function")for(let o of U0(l))!E1.call(c,o)&&o!==i&&o1(c,o,{get:()=>l[o],enumerable:!(r=$0(l,o))||r.enumerable});return c};var p1=(c,l,i)=>(i=c!=null?I0(O0(c)):{},_1(l||!c||!c.__esModule?o1(i,"default",{value:c,enumerable:!0}):i,c)),N0=c=>_1(o1({},"__esModule",{value:!0}),c);var d2={};_0(d2,{Autocomplete:()=>D0,Checkbox:()=>h0,Creatable:()=>s0,DatePicker:()=>F0,Form:()=>W1,RadioButton:()=>m0,RadioGroup:()=>v0,Searchable:()=>a0,Select:()=>i0,Slider:()=>p0,Switch:()=>d0,TextField:()=>e0,TimePicker:()=>E0});module.exports=N0(d2);var N1=require("react"),u1=require("react-hook-form"),j1=require("@hookform/resolvers/zod");var G1=require("react/jsx-runtime");function j0(x){var h=x,{children:c,onSubmit:l,style:i,disableDefaultValuesUpdate:r}=h,o=g(h,["children","onSubmit","style","disableDefaultValuesUpdate"]);let s=(0,u1.useForm)(t(a({},o),{resolver:o.schema&&(0,j1.zodResolver)(o.schema)}));(0,N1.useEffect)(()=>{r||s.reset(o.defaultValues)},[o.defaultValues,s.reset]);let m=()=>typeof c=="function"?c(t(a({},s),{onSubmit:s.handleSubmit(n=>l(n,s))})):c;return(0,G1.jsx)(u1.FormProvider,t(a({},s),{children:(0,G1.jsx)("form",{onSubmit:n=>{n.preventDefault(),n.stopPropagation(),s.handleSubmit(d=>l(d,s))()},style:i,children:m()})}))}var W1=j0;var f1=require("react"),M1=require("react-hook-form"),j=require("@mui/material");var Y1={description:"M39 23.1a17 17 0 0 0-15-10c-6.5.1-12.4 4-15.2 10V25a17 17 0 0 0 15 10A17 17 0 0 0 39 25c.5-.7.5-1.3.2-1.8Zm-15 9a8 8 0 0 1-7.6-8.5c.2-4.2 3.5-7.8 7.6-7.8a8 8 0 0 1 7.6 8.4c-.1 4.3-3.5 7.9-7.6 7.9Zm0-13.5-1.3.1c.7 1.1.6 2.6-.3 3.7-1 .9-2.3.9-3.4.1-.4 2.2.3 4.7 2.1 6a4.9 4.9 0 0 0 6-.2c1.6-1.4 2.4-4 1.6-6.1a4.9 4.9 0 0 0-4.7-3.6Z",id:"line-eye-solid"},K1={description:"M24 31.7c-4 0-7.4-3.1-7.7-7.1l-5.6-4.4c-.8 1-1.4 2-2 3a1.7 1.7 0 0 0 0 1.6 17.2 17.2 0 0 0 19.5 9l-2.8-2.2-1.4.1ZM40.9 35l-6-4.6c1.8-1.5 3.3-3.4 4.4-5.5a1.7 1.7 0 0 0 0-1.6c-3-5.7-8.7-9.5-15.3-9.5-2.8 0-5.5.7-8 2l-6.8-5.3a.9.9 0 0 0-1.2.2L7 12a.9.9 0 0 0 .1 1.2l31.7 24.5a.9.9 0 0 0 1.2-.2l1-1.3a.9.9 0 0 0-.1-1.2Zm-10-7.7-2-1.6a5 5 0 0 0-6.3-6.6 2.5 2.5 0 0 1 .4 2l-3.9-3a7.7 7.7 0 0 1 10.4.5 7.7 7.7 0 0 1 1.5 8.7Z",id:"line-eye-slash-solid"};var N={description:"M24 8a16 16 0 0 0 0 32 16 16 0 0 0 0-32Zm0 7.1c1.5 0 2.7 1.2 2.7 2.7 0 1.6-1.2 2.7-2.7 2.7a2.6 2.6 0 0 1-2.7-2.7c0-1.5 1.2-2.7 2.7-2.7Zm3.6 16.4c0 .4-.4.8-.8.8h-5.6a.7.7 0 0 1-.8-.8v-1.6c0-.4.3-.7.8-.7h.7V25h-.7a.7.7 0 0 1-.8-.7v-1.6c0-.4.3-.8.8-.8h4c.5 0 .9.4.9.8v6.5h.7c.4 0 .8.3.8.7v1.6Z",id:"line-info-circle-solid"};var Q1={description:"m25.5 17 5.5 5.5-12 12-4.9.5a1 1 0 0 1-1-1.1l.5-5L25.5 17Zm8.9-.8-2.6-2.6a2 2 0 0 0-2.9 0L26.5 16l5.5 5.5 2.4-2.4a2 2 0 0 0 0-3Z",id:"line-pen-solid"};var D1={description:"M35.8 21.8h-9.6v-9.6c0-.6-.6-1.1-1.1-1.1h-2.2a1 1 0 0 0-1 1v9.7h-9.7c-.6 0-1.1.6-1.1 1.1v2.2c0 .6.5 1 1 1h9.7v9.7c0 .6.5 1.1 1.1 1.1h2.2c.5 0 1-.5 1-1v-9.7h9.7c.6 0 1.1-.5 1.1-1.1v-2.2c0-.5-.5-1-1-1Z",id:"line-plus-solid"};var X=p1(require("@s_mart/masks"));var B1=require("@mui/material"),J1=require("@s_mart/utils"),r1=require("react/jsx-runtime"),b=({label:c,required:l,regular:i})=>(0,r1.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:(0,J1.toRem)(2)},children:[(0,r1.jsx)(B1.Typography,{variant:"caption",fontWeight:i?400:700,style:{display:"flex",alignItems:"center"},children:c}),l&&(0,r1.jsx)(B1.Typography,{variant:"caption",fontWeight:900,color:"error",children:"*"})]});var X1=require("react-hook-form"),c0=require("@s_mart/core");var E=(c,l)=>{var i,r,o,x,h;if(c[l])return c[l];if(l.includes("[")){let[s,m]=l.split("["),[n,d]=m.split("].");return(r=(i=c[s])==null?void 0:i[n])==null?void 0:r[d]}if(l.includes(".")){let[s,m,n]=l.split(".");return n?(h=(x=c[s])==null?void 0:x[m])==null?void 0:h[n]:(o=c[s])==null?void 0:o[m]}};var l0=require("react/jsx-runtime"),w=({name:c})=>{var r;let l=(0,X1.useFormContext)(),i=E((r=l==null?void 0:l.formState)==null?void 0:r.errors,c);return i?(0,l0.jsx)(c0.Indicator,{severity:"error",children:i==null?void 0:i.message}):null};var n1=require("@s_mart/core");var D=require("react/jsx-runtime"),W0=C=>{var k=C,{name:c,rules:l,defaultValue:i,shouldUnregister:r,label:o,required:x,mask:h,variant:s="outlined",info:m,parse:n,format:d,onInputChange:f}=k,M=g(k,["name","rules","defaultValue","shouldUnregister","label","required","mask","variant","info","parse","format","onInputChange"]);let F=(0,M1.useFormContext)();if(!F)throw new Error("Para usar o <TextField /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let[v,u]=(0,f1.useState)(!1),P=H=>{var e;let V=H;return d&&(V=d(H)),h?(e=X==null?void 0:X[h])==null?void 0:e.format(V):V},Z=H=>{var e;let V=H;return n&&(V=n(H)),h?(e=X==null?void 0:X[h])==null?void 0:e.parse(V):V},S=H=>{if(!H||h!=="porcentagem")return;H==null||H.stopPropagation();let V=(H==null?void 0:H.target).value;if(V){let e=String(V);if(e.length>0){let T=e.indexOf("%");T>-1&&(H.currentTarget.selectionEnd=T)}}},G=E(F.formState.errors,c);return(0,D.jsx)(M1.Controller,{control:F.control,name:c,rules:l,defaultValue:i,shouldUnregister:r,render:({field:{value:H,onChange:V,ref:e}})=>(0,D.jsxs)(j.Grid,{display:"flex",flexDirection:"column",children:[(0,D.jsxs)("div",{style:{display:"flex"},children:[o&&(0,D.jsx)(j.Grid,{item:!0,children:(0,D.jsx)(b,{label:o,required:x})}),m&&(0,D.jsx)(j.Grid,{item:!0,children:(0,D.jsx)(n1.Tooltip,{title:m,placement:"top",children:(0,D.jsx)("div",{style:{width:"fit-content"},children:(0,D.jsx)(n1.LIcon,{icon:N,color:"#757575"})})})})]}),(0,D.jsx)(j.TextField,t(a({variant:s,defaultValue:i,value:P(H||""),onChange:T=>{var a1;let v1=Z((a1=T==null?void 0:T.target)==null?void 0:a1.value);V(v1),f==null||f(v1,F.watch())},error:!!G},M),{type:M.type==="password"?v?"text":"password":M.type,autoComplete:M.autoComplete||"off",InputProps:a({onKeyDown:S,inputRef:e,endAdornment:M.type==="password"&&(0,D.jsx)(j.InputAdornment,{position:"end",onClick:()=>u(!v),style:{cursor:"pointer"},children:(0,D.jsx)(n1.LIcon,{icon:v?Y1:K1,size:"24px",removeMargin:!0})})},M.InputProps)}),c),(0,D.jsx)(w,{name:c})]})})},e0=(0,f1.memo)(W0);var H1=require("react"),V1=require("react-hook-form"),c1=require("@s_mart/core"),B=require("@mui/material");var L=require("react/jsx-runtime"),Y0=k=>{var F=k,{name:c,rules:l,defaultValue:i,shouldUnregister:r,label:o,required:x,options:h,placeholder:s,disableOnChangeForm:m=!1,multiple:n,info:d,footer:f,onChange:M}=F,C=g(F,["name","rules","defaultValue","shouldUnregister","label","required","options","placeholder","disableOnChangeForm","multiple","info","footer","onChange"]);let v=(0,V1.useFormContext)(),{palette:u}=(0,B.useTheme)(),[P,Z]=(0,H1.useState)(!1);if(!v)throw new Error("Para usar o <Select /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let S=E(v.formState.errors,c);return console.warn=()=>{},(0,L.jsx)(V1.Controller,{control:v.control,name:c,rules:l,defaultValue:i,shouldUnregister:r,render:({field:{value:G,onChange:H,ref:V}})=>(0,L.jsxs)(B.Grid,{display:"flex",flexDirection:"column",children:[(0,L.jsxs)("div",{style:{display:"flex"},children:[o&&(0,L.jsx)(B.Grid,{item:!0,children:(0,L.jsx)(b,{label:o,required:x})}),d&&(0,L.jsx)(B.Grid,{item:!0,children:(0,L.jsx)(c1.Tooltip,{title:d,placement:"top",children:(0,L.jsx)("div",{style:{width:"fit-content"},children:(0,L.jsx)(c1.LIcon,{icon:N,color:"#757575"})})})})]}),(0,L.jsxs)(B.Select,t(a({open:P,onOpen:()=>Z(!0),onClose:()=>Z(!1),displayEmpty:!!s,variant:"outlined",autoComplete:"off",value:G?G||"":n?[]:"",renderValue:e=>{if(e.label)return e.label;if(s)return(0,L.jsx)("p",{style:{color:u.grey[400]},children:s})},multiple:n,onChange:e=>{!m&&H(e.target.value),M&&M(e.target.value,v.watch())},error:!!S,size:C.size||"medium",inputRef:V},C),{children:[s&&(0,L.jsx)(B.MenuItem,{disabled:!0,value:"",children:(0,L.jsx)("p",{style:{color:u.grey[400]},children:s})}),h==null?void 0:h.map((e,T)=>(0,L.jsx)(B.MenuItem,{value:e,children:(0,L.jsxs)(B.Grid,{container:!0,direction:"column",children:[(0,L.jsx)(B.Grid,{item:!0,children:e.label}),e.afterLabel&&(0,L.jsx)(B.Grid,{item:!0,children:e.afterLabel})]})},T)),f&&[(0,L.jsx)(B.Grid,{px:2,py:1,children:(0,L.jsx)(c1.Divider,{})},"footer-divider"),(0,L.jsx)("div",{children:f({closeSelect:()=>Z(!1)})},"footer-content")]]}),c),(0,L.jsx)(w,{name:c})]})})},i0=(0,H1.memo)(Y0);var y1=require("react"),x1=require("react-hook-form"),Q=require("@s_mart/core");var I=require("@mui/material");var p=require("react/jsx-runtime"),R1=require("react"),K0=v=>{var u=v,{name:c,rules:l,defaultValue:i,shouldUnregister:r,label:o,required:x,options:h,textFieldProps:s,noOptionsText:m,footer:n,multiple:d,info:f,placeholder:M,onChange:C,onInputChange:k}=u,F=g(u,["name","rules","defaultValue","shouldUnregister","label","required","options","textFieldProps","noOptionsText","footer","multiple","info","placeholder","onChange","onInputChange"]);let P=(0,x1.useFormContext)();if(!P)throw new Error("Para usar o <Searchable /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let Z=E(P.formState.errors,c);return console.warn=()=>{},(0,p.jsx)(x1.Controller,{control:P.control,name:c,rules:l,defaultValue:i,shouldUnregister:r,render:({field:{onChange:S,value:G,ref:H}})=>(0,p.jsxs)(I.Grid,{display:"flex",flexDirection:"column",children:[(0,p.jsxs)("div",{style:{display:"flex"},children:[o&&(0,p.jsx)(I.Grid,{item:!0,children:(0,p.jsx)(b,{label:o,required:x})}),f&&(0,p.jsx)(I.Grid,{item:!0,children:(0,p.jsx)(Q.Tooltip,{title:f,placement:"top",children:(0,p.jsx)("div",{style:{width:"fit-content"},children:(0,p.jsx)(Q.LIcon,{icon:N,color:"#757575"})})})})]}),(0,p.jsx)(I.Autocomplete,t(a({onChange:(V,e)=>{S(e),C==null||C(e,P.watch())},onInputChange:(V,e,T)=>{T==="input"&&setTimeout(()=>{k==null||k(e,P.watch())},0)},value:G||(d?[]:null),options:h,multiple:d,noOptionsText:(0,p.jsxs)(p.Fragment,{children:[m||"Nenhum resultado encontrado",n?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(I.Grid,{py:1,children:(0,p.jsx)(Q.Divider,{})}),n]}):null]}),isOptionEqualToValue:(V,e)=>typeof V=="string"&&typeof e=="string"?V===e:typeof V=="object"&&typeof e=="object"?V.value===e.value:!1,renderOption:(V,e)=>typeof e=="object"?(0,R1.createElement)("li",t(a({},V),{key:e.key||e.value}),(0,p.jsxs)(I.Grid,{container:!0,direction:"column",children:[(0,p.jsx)(I.Grid,{item:!0,children:e.label}),e.afterLabel&&(0,p.jsx)(I.Grid,{item:!0,children:e.afterLabel})]})):(0,R1.createElement)("li",t(a({},V),{key:e}),e),ListboxComponent:(0,y1.forwardRef)(function(e,T){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("ul",t(a({},e),{ref:T})),!!n&&(0,p.jsx)("div",t(a({},e),{children:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(I.Grid,{px:2,py:1,children:(0,p.jsx)(Q.Divider,{})}),n]})}),"searchable-footer")]})})},F),{renderInput:V=>(0,p.jsx)(I.TextField,t(a(a({error:!!Z,placeholder:M},V),s),{inputRef:H}))}),c),(0,p.jsx)(w,{name:c})]})})},a0=(0,y1.memo)(K0);var t0=require("react"),g1=require("react-hook-form"),q=require("@mui/material");var t1=require("@s_mart/utils"),o0=p1(require("@emotion/styled")),I1=require("@emotion/react"),r0=I1.css`
|
|
1
|
+
"use strict";var z0=Object.create;var o1=Object.defineProperty,O0=Object.defineProperties,_0=Object.getOwnPropertyDescriptor,N0=Object.getOwnPropertyDescriptors,W0=Object.getOwnPropertyNames,Z1=Object.getOwnPropertySymbols,j0=Object.getPrototypeOf,G1=Object.prototype.hasOwnProperty,_1=Object.prototype.propertyIsEnumerable;var O1=(c,e,l)=>e in c?o1(c,e,{enumerable:!0,configurable:!0,writable:!0,value:l}):c[e]=l,a=(c,e)=>{for(var l in e||(e={}))G1.call(e,l)&&O1(c,l,e[l]);if(Z1)for(var l of Z1(e))_1.call(e,l)&&O1(c,l,e[l]);return c},n=(c,e)=>O0(c,N0(e));var H=(c,e)=>{var l={};for(var r in c)G1.call(c,r)&&e.indexOf(r)<0&&(l[r]=c[r]);if(c!=null&&Z1)for(var r of Z1(c))e.indexOf(r)<0&&_1.call(c,r)&&(l[r]=c[r]);return l};var Y0=(c,e)=>{for(var l in e)o1(c,l,{get:e[l],enumerable:!0})},N1=(c,e,l,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of W0(e))!G1.call(c,o)&&o!==l&&o1(c,o,{get:()=>e[o],enumerable:!(r=_0(e,o))||r.enumerable});return c};var p1=(c,e,l)=>(l=c!=null?z0(j0(c)):{},N1(e||!c||!c.__esModule?o1(l,"default",{value:c,enumerable:!0}):l,c)),K0=c=>N1(o1({},"__esModule",{value:!0}),c);var f2={};Y0(f2,{Autocomplete:()=>U0,Checkbox:()=>Z0,Creatable:()=>v0,DatePicker:()=>P0,Form:()=>Q1,FormProvider:()=>u1,RadioButton:()=>u0,RadioGroup:()=>f0,Searchable:()=>t0,Select:()=>n0,Slider:()=>H0,Switch:()=>p0,TextField:()=>r0,TimePicker:()=>B0,useForm:()=>f1});module.exports=K0(f2);var W1=require("react-hook-form");var D1=require("react/jsx-runtime"),Q0=o=>{var s=o,{children:c,style:e,onSubmit:l}=s,r=H(s,["children","style","onSubmit"]);return(0,D1.jsx)(W1.FormProvider,n(a({},r),{children:(0,D1.jsx)("form",{onSubmit:t=>{t.preventDefault(),t.stopPropagation(),l(t)},style:e,children:c})}))},u1=Q0;var j1=require("react"),Y1=require("react-hook-form"),K1=require("@hookform/resolvers/zod");var J0=r=>{var o=r,{disableDefaultValuesUpdate:c,onSubmit:e}=o,l=H(o,["disableDefaultValuesUpdate","onSubmit"]);let s=(0,Y1.useForm)(n(a({},l),{resolver:l.schema&&(0,K1.zodResolver)(l.schema)}));return(0,j1.useEffect)(()=>{c||s.reset(l.defaultValues)},[l.defaultValues,s.reset]),n(a({},s),{onSubmit:s.handleSubmit(t=>e(t,s))})},f1=J0;var J1=require("react/jsx-runtime");function X0(r){var o=r,{children:c,style:e}=o,l=H(o,["children","style"]);let s=f1(l);return(0,J1.jsx)(u1,n(a({},s),{style:e,children:typeof c=="function"?c(s):c}))}var Q1=X0;var M1=require("react"),H1=require("react-hook-form"),W=require("@mui/material");var X1={description:"M39 23.1a17 17 0 0 0-15-10c-6.5.1-12.4 4-15.2 10V25a17 17 0 0 0 15 10A17 17 0 0 0 39 25c.5-.7.5-1.3.2-1.8Zm-15 9a8 8 0 0 1-7.6-8.5c.2-4.2 3.5-7.8 7.6-7.8a8 8 0 0 1 7.6 8.4c-.1 4.3-3.5 7.9-7.6 7.9Zm0-13.5-1.3.1c.7 1.1.6 2.6-.3 3.7-1 .9-2.3.9-3.4.1-.4 2.2.3 4.7 2.1 6a4.9 4.9 0 0 0 6-.2c1.6-1.4 2.4-4 1.6-6.1a4.9 4.9 0 0 0-4.7-3.6Z",id:"line-eye-solid"},c0={description:"M24 31.7c-4 0-7.4-3.1-7.7-7.1l-5.6-4.4c-.8 1-1.4 2-2 3a1.7 1.7 0 0 0 0 1.6 17.2 17.2 0 0 0 19.5 9l-2.8-2.2-1.4.1ZM40.9 35l-6-4.6c1.8-1.5 3.3-3.4 4.4-5.5a1.7 1.7 0 0 0 0-1.6c-3-5.7-8.7-9.5-15.3-9.5-2.8 0-5.5.7-8 2l-6.8-5.3a.9.9 0 0 0-1.2.2L7 12a.9.9 0 0 0 .1 1.2l31.7 24.5a.9.9 0 0 0 1.2-.2l1-1.3a.9.9 0 0 0-.1-1.2Zm-10-7.7-2-1.6a5 5 0 0 0-6.3-6.6 2.5 2.5 0 0 1 .4 2l-3.9-3a7.7 7.7 0 0 1 10.4.5 7.7 7.7 0 0 1 1.5 8.7Z",id:"line-eye-slash-solid"};var N={description:"M24 8a16 16 0 0 0 0 32 16 16 0 0 0 0-32Zm0 7.1c1.5 0 2.7 1.2 2.7 2.7 0 1.6-1.2 2.7-2.7 2.7a2.6 2.6 0 0 1-2.7-2.7c0-1.5 1.2-2.7 2.7-2.7Zm3.6 16.4c0 .4-.4.8-.8.8h-5.6a.7.7 0 0 1-.8-.8v-1.6c0-.4.3-.7.8-.7h.7V25h-.7a.7.7 0 0 1-.8-.7v-1.6c0-.4.3-.8.8-.8h4c.5 0 .9.4.9.8v6.5h.7c.4 0 .8.3.8.7v1.6Z",id:"line-info-circle-solid"};var e0={description:"m25.5 17 5.5 5.5-12 12-4.9.5a1 1 0 0 1-1-1.1l.5-5L25.5 17Zm8.9-.8-2.6-2.6a2 2 0 0 0-2.9 0L26.5 16l5.5 5.5 2.4-2.4a2 2 0 0 0 0-3Z",id:"line-pen-solid"};var I1={description:"M35.8 21.8h-9.6v-9.6c0-.6-.6-1.1-1.1-1.1h-2.2a1 1 0 0 0-1 1v9.7h-9.7c-.6 0-1.1.6-1.1 1.1v2.2c0 .6.5 1 1 1h9.7v9.7c0 .6.5 1.1 1.1 1.1h2.2c.5 0 1-.5 1-1v-9.7h9.7c.6 0 1.1-.5 1.1-1.1v-2.2c0-.5-.5-1-1-1Z",id:"line-plus-solid"};var X=p1(require("@s_mart/masks"));var B1=require("@mui/material"),l0=require("@s_mart/utils"),r1=require("react/jsx-runtime"),b=({label:c,required:e,regular:l})=>(0,r1.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:(0,l0.toRem)(2)},children:[(0,r1.jsx)(B1.Typography,{variant:"caption",fontWeight:l?400:700,style:{display:"flex",alignItems:"center"},children:c}),e&&(0,r1.jsx)(B1.Typography,{variant:"caption",fontWeight:900,color:"error",children:"*"})]});var i0=require("react-hook-form"),a0=require("@s_mart/core");var E=(c,e)=>{var l,r,o,s,t;if(c[e])return c[e];if(e.includes("[")){let[u,f]=e.split("["),[h,d]=f.split("].");return(r=(l=c[u])==null?void 0:l[h])==null?void 0:r[d]}if(e.includes(".")){let[u,f,h]=e.split(".");return h?(t=(s=c[u])==null?void 0:s[f])==null?void 0:t[h]:(o=c[u])==null?void 0:o[f]}};var o0=require("react/jsx-runtime"),w=({name:c})=>{var r;let e=(0,i0.useFormContext)(),l=E((r=e==null?void 0:e.formState)==null?void 0:r.errors,c);return l?(0,o0.jsx)(a0.Indicator,{severity:"error",children:l==null?void 0:l.message}):null};var n1=require("@s_mart/core");var D=require("react/jsx-runtime"),c2=C=>{var P=C,{name:c,rules:e,defaultValue:l,shouldUnregister:r,label:o,required:s,mask:t,variant:u="outlined",info:f,parse:h,format:d,onInputChange:M}=P,V=H(P,["name","rules","defaultValue","shouldUnregister","label","required","mask","variant","info","parse","format","onInputChange"]);let g=(0,H1.useFormContext)();if(!g)throw new Error("Para usar o <TextField /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let[m,p]=(0,M1.useState)(!1),k=y=>{var i;let x=y;return d&&(x=d(y)),t?(i=X==null?void 0:X[t])==null?void 0:i.format(x):x},v=y=>{var i;let x=y;return h&&(x=h(y)),t?(i=X==null?void 0:X[t])==null?void 0:i.parse(x):x},S=y=>{if(!y||t!=="porcentagem")return;y==null||y.stopPropagation();let x=(y==null?void 0:y.target).value;if(x){let i=String(x);if(i.length>0){let T=i.indexOf("%");T>-1&&(y.currentTarget.selectionEnd=T)}}},G=E(g.formState.errors,c);return(0,D.jsx)(H1.Controller,{control:g.control,name:c,rules:e,defaultValue:l,shouldUnregister:r,render:({field:{value:y,onChange:x,ref:i}})=>(0,D.jsxs)(W.Grid,{display:"flex",flexDirection:"column",children:[(0,D.jsxs)("div",{style:{display:"flex"},children:[o&&(0,D.jsx)(W.Grid,{item:!0,children:(0,D.jsx)(b,{label:o,required:s})}),f&&(0,D.jsx)(W.Grid,{item:!0,children:(0,D.jsx)(n1.Tooltip,{title:f,placement:"top",children:(0,D.jsx)("div",{style:{width:"fit-content"},children:(0,D.jsx)(n1.LIcon,{icon:N,color:"#757575"})})})})]}),(0,D.jsx)(W.TextField,n(a({variant:u,defaultValue:l,value:k(y||""),onChange:T=>{var a1;let v1=v((a1=T==null?void 0:T.target)==null?void 0:a1.value);x(v1),M==null||M(v1,g.watch())},error:!!G},V),{type:V.type==="password"?m?"text":"password":V.type,autoComplete:V.autoComplete||"off",InputProps:a({onKeyDown:S,inputRef:i,endAdornment:V.type==="password"&&(0,D.jsx)(W.InputAdornment,{position:"end",onClick:()=>p(!m),style:{cursor:"pointer"},children:(0,D.jsx)(n1.LIcon,{icon:m?X1:c0,size:"24px",removeMargin:!0})})},V.InputProps)}),c),(0,D.jsx)(w,{name:c})]})})},r0=(0,M1.memo)(c2);var V1=require("react"),y1=require("react-hook-form"),c1=require("@s_mart/core"),I=require("@mui/material");var L=require("react/jsx-runtime"),e2=P=>{var g=P,{name:c,rules:e,defaultValue:l,shouldUnregister:r,label:o,required:s,options:t,placeholder:u,disableOnChangeForm:f=!1,multiple:h,info:d,footer:M,onChange:V}=g,C=H(g,["name","rules","defaultValue","shouldUnregister","label","required","options","placeholder","disableOnChangeForm","multiple","info","footer","onChange"]);let m=(0,y1.useFormContext)(),{palette:p}=(0,I.useTheme)(),[k,v]=(0,V1.useState)(!1);if(!m)throw new Error("Para usar o <Select /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let S=E(m.formState.errors,c);return console.warn=()=>{},(0,L.jsx)(y1.Controller,{control:m.control,name:c,rules:e,defaultValue:l,shouldUnregister:r,render:({field:{value:G,onChange:y,ref:x}})=>(0,L.jsxs)(I.Grid,{display:"flex",flexDirection:"column",children:[(0,L.jsxs)("div",{style:{display:"flex"},children:[o&&(0,L.jsx)(I.Grid,{item:!0,children:(0,L.jsx)(b,{label:o,required:s})}),d&&(0,L.jsx)(I.Grid,{item:!0,children:(0,L.jsx)(c1.Tooltip,{title:d,placement:"top",children:(0,L.jsx)("div",{style:{width:"fit-content"},children:(0,L.jsx)(c1.LIcon,{icon:N,color:"#757575"})})})})]}),(0,L.jsxs)(I.Select,n(a({open:k,onOpen:()=>v(!0),onClose:()=>v(!1),displayEmpty:!!u,variant:"outlined",autoComplete:"off",value:G?G||"":h?[]:"",renderValue:i=>{if(i.label)return i.label;if(u)return(0,L.jsx)("p",{style:{color:p.grey[400]},children:u})},multiple:h,onChange:i=>{!f&&y(i.target.value),V&&V(i.target.value,m.watch())},error:!!S,size:C.size||"medium",inputRef:x},C),{children:[u&&(0,L.jsx)(I.MenuItem,{disabled:!0,value:"",children:(0,L.jsx)("p",{style:{color:p.grey[400]},children:u})}),t==null?void 0:t.map((i,T)=>(0,L.jsx)(I.MenuItem,{value:i,children:(0,L.jsxs)(I.Grid,{container:!0,direction:"column",children:[(0,L.jsx)(I.Grid,{item:!0,children:i.label}),i.afterLabel&&(0,L.jsx)(I.Grid,{item:!0,children:i.afterLabel})]})},T)),M&&[(0,L.jsx)(I.Grid,{px:2,py:1,children:(0,L.jsx)(c1.Divider,{})},"footer-divider"),(0,L.jsx)("div",{children:M({closeSelect:()=>v(!1)})},"footer-content")]]}),c),(0,L.jsx)(w,{name:c})]})})},n0=(0,V1.memo)(e2);var x1=require("react"),F1=require("react-hook-form"),Q=require("@s_mart/core");var R=require("@mui/material");var Z=require("react/jsx-runtime"),R1=require("react"),l2=m=>{var p=m,{name:c,rules:e,defaultValue:l,shouldUnregister:r,label:o,required:s,options:t,textFieldProps:u,noOptionsText:f,footer:h,multiple:d,info:M,placeholder:V,onChange:C,onInputChange:P}=p,g=H(p,["name","rules","defaultValue","shouldUnregister","label","required","options","textFieldProps","noOptionsText","footer","multiple","info","placeholder","onChange","onInputChange"]);let k=(0,F1.useFormContext)();if(!k)throw new Error("Para usar o <Searchable /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let v=E(k.formState.errors,c);return console.warn=()=>{},(0,Z.jsx)(F1.Controller,{control:k.control,name:c,rules:e,defaultValue:l,shouldUnregister:r,render:({field:{onChange:S,value:G,ref:y}})=>(0,Z.jsxs)(R.Grid,{display:"flex",flexDirection:"column",children:[(0,Z.jsxs)("div",{style:{display:"flex"},children:[o&&(0,Z.jsx)(R.Grid,{item:!0,children:(0,Z.jsx)(b,{label:o,required:s})}),M&&(0,Z.jsx)(R.Grid,{item:!0,children:(0,Z.jsx)(Q.Tooltip,{title:M,placement:"top",children:(0,Z.jsx)("div",{style:{width:"fit-content"},children:(0,Z.jsx)(Q.LIcon,{icon:N,color:"#757575"})})})})]}),(0,Z.jsx)(R.Autocomplete,n(a({onChange:(x,i)=>{S(i),C==null||C(i,k.watch())},onInputChange:(x,i,T)=>{T==="input"&&setTimeout(()=>{P==null||P(i,k.watch())},0)},value:G||(d?[]:null),options:t,multiple:d,noOptionsText:(0,Z.jsxs)(Z.Fragment,{children:[f||"Nenhum resultado encontrado",h?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(R.Grid,{py:1,children:(0,Z.jsx)(Q.Divider,{})}),h]}):null]}),isOptionEqualToValue:(x,i)=>typeof x=="string"&&typeof i=="string"?x===i:typeof x=="object"&&typeof i=="object"?x.value===i.value:!1,renderOption:(x,i)=>typeof i=="object"?(0,R1.createElement)("li",n(a({},x),{key:i.key||i.value}),(0,Z.jsxs)(R.Grid,{container:!0,direction:"column",children:[(0,Z.jsx)(R.Grid,{item:!0,children:i.label}),i.afterLabel&&(0,Z.jsx)(R.Grid,{item:!0,children:i.afterLabel})]})):(0,R1.createElement)("li",n(a({},x),{key:i}),i),ListboxComponent:(0,x1.forwardRef)(function(i,T){return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)("ul",n(a({},i),{ref:T})),!!h&&(0,Z.jsx)("div",n(a({},i),{children:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(R.Grid,{px:2,py:1,children:(0,Z.jsx)(Q.Divider,{})}),h]})}),"searchable-footer")]})})},g),{renderInput:x=>(0,Z.jsx)(R.TextField,n(a(a({error:!!v,placeholder:V},x),u),{inputRef:y}))}),c),(0,Z.jsx)(w,{name:c})]})})},t0=(0,x1.memo)(l2);var m0=require("react"),g1=require("react-hook-form"),U=require("@mui/material");var t1=require("@s_mart/utils"),s0=p1(require("@emotion/styled")),U1=require("@emotion/react"),h0=U1.css`
|
|
2
2
|
display: flex;
|
|
3
3
|
align-items: center;
|
|
4
4
|
justify-content: center;
|
|
5
|
-
`,
|
|
5
|
+
`,i2=c=>U1.css`
|
|
6
6
|
.MuiAutocomplete-endAdornment {
|
|
7
7
|
position: relative;
|
|
8
8
|
right: 0;
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
.creatable,
|
|
12
12
|
.editable {
|
|
13
|
-
${
|
|
13
|
+
${h0}
|
|
14
14
|
|
|
15
15
|
.divider {
|
|
16
16
|
width: 1px;
|
|
@@ -36,37 +36,37 @@
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
`,
|
|
39
|
+
`,d0=s0.default.div`
|
|
40
40
|
display: flex;
|
|
41
41
|
|
|
42
42
|
div.endAdornments {
|
|
43
43
|
position: absolute;
|
|
44
44
|
right: 0;
|
|
45
45
|
|
|
46
|
-
${
|
|
46
|
+
${h0}
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
${({hideAddButton:c,theme:
|
|
50
|
-
`;var O=require("@s_mart/core");var
|
|
49
|
+
${({hideAddButton:c,theme:e})=>!c&&i2(e)}
|
|
50
|
+
`;var O=require("@s_mart/core");var L1=require("lodash"),q1=require("@s_mart/utils");var F=require("react/jsx-runtime"),$1=require("react"),a2=k=>{var v=k,{name:c,rules:e,defaultValue:l,shouldUnregister:r,label:o,required:s,options:t,editable:u,onEditOption:f,onCreateOption:h,textFieldProps:d,hideAddButton:M,multiple:V,info:C,onChange:P,onInputChange:g,placeholder:m}=v,p=H(v,["name","rules","defaultValue","shouldUnregister","label","required","options","editable","onEditOption","onCreateOption","textFieldProps","hideAddButton","multiple","info","onChange","onInputChange","placeholder"]);let S=(0,g1.useFormContext)();if(!S)throw new Error("Para usar o <Creatable /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let G=E(S.formState.errors,c);console.warn=()=>{};let y=i=>{h?h(i):console.error("onCreateOption n\xE3o foi definido")},x=i=>{f?f(i):console.error("onEditOption n\xE3o foi definido")};return(0,F.jsx)(g1.Controller,{control:S.control,name:c,rules:e,defaultValue:l,shouldUnregister:r,render:({field:{value:i,onChange:T,ref:v1}})=>{let a1=(i==null?void 0:i.label)||(i==null?void 0:i.value)||i;return(0,F.jsxs)(U.Grid,{display:"flex",flexDirection:"column",children:[(0,F.jsxs)("div",{style:{display:"flex"},children:[o&&(0,F.jsx)(U.Grid,{item:!0,children:(0,F.jsx)(b,{label:o,required:s})}),C&&(0,F.jsx)(U.Grid,{item:!0,children:(0,F.jsx)(O.Tooltip,{title:C,placement:"top",children:(0,F.jsx)("div",{style:{width:"fit-content"},children:(0,F.jsx)(O.LIcon,{icon:N,color:"#757575"})})})})]}),(0,F.jsx)(d0,{hideAddButton:M,children:(0,F.jsx)(U.Autocomplete,n(a({fullWidth:!0,onChange:(B,A)=>{T(A),P==null||P(A,S.watch())},onInputChange:(B,A,$0)=>{$0==="input"&&(T(A),setTimeout(()=>{g==null||g(A,S.watch())},0))},options:t,value:i||(V?[]:null),multiple:V,noOptionsText:(0,F.jsxs)(O.Button,{sx:{justifyContent:"flex-start",padding:`${(0,q1.toRem)(6)} ${(0,q1.toRem)(-16)}`,margin:0},fullWidth:!0,onClick:()=>y(i),variant:"text",startIcon:(0,F.jsx)(O.LIcon,{icon:I1}),children:["Adicionar ",a1&&`"${a1}"`]}),isOptionEqualToValue:(B,A)=>A?typeof B=="string"&&typeof A=="string"?B===A:typeof B=="object"&&typeof A=="object"?B.value===A.value:typeof B=="object"&&typeof A=="string":!1,renderOption:(B,A)=>typeof A=="object"?(0,$1.createElement)("li",n(a({},B),{key:A.key||A.value}),(0,F.jsxs)(U.Grid,{container:!0,direction:"column",children:[(0,F.jsx)(U.Grid,{item:!0,children:A.label}),A.afterLabel&&(0,F.jsx)(U.Grid,{item:!0,children:A.afterLabel})]})):(0,$1.createElement)("li",n(a({},B),{key:A}),A)},p),{renderInput:B=>(0,F.jsx)(U.TextField,a(n(a({placeholder:m},B),{error:!!G,onChange:T,InputProps:n(a({},B.InputProps),{inputRef:v1,endAdornment:M?void 0:(0,F.jsxs)("div",{className:"endAdornments",children:[B.InputProps.endAdornment,u&&(0,L1.isObject)(i)&&!(0,L1.isEmpty)(i)?(0,F.jsxs)("div",{className:"editable",children:[(0,F.jsx)("div",{className:"divider"}),(0,F.jsx)("div",{className:"button",onClick:()=>x(i),children:(0,F.jsx)(O.LIcon,{icon:e0,size:"24px",removeMargin:!0})})]}):null,(0,F.jsxs)("div",{className:"creatable",children:[(0,F.jsx)("div",{className:"divider"}),(0,F.jsx)("div",{className:"button",onClick:()=>y(i),children:(0,F.jsx)(O.LIcon,{icon:I1,size:"24px",removeMargin:!0})})]})]})})}),d))}),c)}),(0,F.jsx)(w,{name:c})]})}})},v0=(0,m0.memo)(a2);var C1=require("react-hook-form"),e1=require("@mui/material");var j=require("react/jsx-runtime"),o2=f=>{var h=f,{name:c,rules:e,defaultValue:l,shouldUnregister:r,label:o,labelPlacement:s,required:t}=h,u=H(h,["name","rules","defaultValue","shouldUnregister","label","labelPlacement","required"]);let d=(0,C1.useFormContext)();if(!d)throw new Error("Para usar o <Checkbox /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return(0,j.jsx)(C1.Controller,{control:d.control,name:c,rules:e,defaultValue:l,shouldUnregister:r,render:({field:{value:M,onChange:V}})=>(0,j.jsxs)(e1.Grid,{display:"flex",flexDirection:"column",children:[(0,j.jsx)(e1.FormControlLabel,{control:(0,j.jsx)(e1.Checkbox,a({checked:!!M,value:M!=null?M:"",defaultValue:M,onChange:V},u),c),label:(0,j.jsx)(b,{label:o,required:t,regular:!0}),labelPlacement:s||"end"}),(0,j.jsx)(w,{name:c})]})})},Z0=o2;var b1=require("react-hook-form"),l1=require("@mui/material");var Y=require("react/jsx-runtime"),r2=u=>{var f=u,{name:c,rules:e,defaultValue:l,shouldUnregister:r,label:o,labelPlacement:s}=f,t=H(f,["name","rules","defaultValue","shouldUnregister","label","labelPlacement"]);let h=(0,b1.useFormContext)();if(!h)throw new Error("Para usar o <Switch /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return(0,Y.jsx)(b1.Controller,{control:h.control,name:c,rules:e,defaultValue:l,shouldUnregister:r,render:({field:{value:d,onChange:M}})=>(0,Y.jsxs)(l1.Grid,{display:"flex",flexDirection:"column",children:[(0,Y.jsx)(l1.FormControlLabel,{control:(0,Y.jsx)(l1.Switch,a({value:d!=null?d:"",checked:d!=null?d:!1,defaultValue:d,onChange:M},t),c),label:(0,Y.jsx)(b,{label:o}),labelPlacement:s||"end"}),(0,Y.jsx)(w,{name:c})]})})},p0=r2;var i1=require("@mui/material");var s1=require("react/jsx-runtime"),n2=r=>{var o=r,{label:c,labelPlacement:e}=o,l=H(o,["label","labelPlacement"]);return(0,s1.jsx)(i1.Grid,{display:"flex",flexDirection:"column",children:(0,s1.jsx)(i1.FormControlLabel,{control:(0,s1.jsx)(i1.Radio,a({},l)),label:(0,s1.jsx)(b,{label:c}),labelPlacement:e||"end"})})},u0=n2;var P1=require("react-hook-form"),k1=require("@mui/material");var J=require("react/jsx-runtime"),t2=h=>{var d=h,{name:c,rules:e,defaultValue:l,shouldUnregister:r,label:o,required:s,children:t,orientation:u="row"}=d,f=H(d,["name","rules","defaultValue","shouldUnregister","label","required","children","orientation"]);let M=(0,P1.useFormContext)();if(!M)throw new Error("Para usar o <RadioGroup /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return(0,J.jsx)(P1.Controller,{control:M.control,name:c,rules:e,defaultValue:l,shouldUnregister:r,render:({field:{value:V,onChange:C}})=>(0,J.jsxs)(k1.Grid,{display:"flex",flexDirection:"column",children:[o&&(0,J.jsx)(b,{label:o,required:s}),(0,J.jsx)(k1.RadioGroup,n(a({value:V||"",onChange:C,name:c},f),{style:{display:"flex",flexDirection:u},children:t}),c),(0,J.jsx)(w,{name:c})]})})},f0=t2;var A1=require("react-hook-form"),M0=require("@mui/material");var z1=require("react/jsx-runtime"),s2=s=>{var t=s,{name:c,rules:e,defaultValue:l,shouldUnregister:r}=t,o=H(t,["name","rules","defaultValue","shouldUnregister"]);let u=(0,A1.useFormContext)();if(!u)throw new Error("Para usar o <Slider /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return(0,z1.jsx)(A1.Controller,{control:u.control,name:c,rules:e,defaultValue:l,shouldUnregister:r,render:({field:{value:f,onChange:h}})=>(0,z1.jsx)(M0.Slider,a({value:f||(o==null?void 0:o.min)||0,onChange:h,valueLabelDisplay:"auto"},o),c)})},H0=s2;var x0=require("react"),w1=require("react-hook-form"),F0=require("@s_mart/core"),h1=require("@s_mart/rules"),g0=require("@mui/material"),L0=require("@mui/x-date-pickers/DatePicker"),C0=require("@mui/x-date-pickers/AdapterDayjs"),b0=require("@mui/x-date-pickers/LocalizationProvider");var q=require("@s_mart/utils"),V0=p1(require("@emotion/styled")),h2=c=>{switch(c){case"small":return(0,q.toRem)(16);default:case"medium":return(0,q.toRem)(20);case"large":return(0,q.toRem)(24)}},d2=c=>{switch(c){case"small":return`${(0,q.toRem)(2)} ${(0,q.toRem)(8)}`;default:case"medium":return`${(0,q.toRem)(6)} ${(0,q.toRem)(8)}`;case"large":return`${(0,q.toRem)(10)}`}},y0=V0.default.div`
|
|
51
51
|
> div > button {
|
|
52
|
-
padding: ${({size:c})=>
|
|
53
|
-
border-radius: 0 ${(0
|
|
52
|
+
padding: ${({size:c})=>d2(c)};
|
|
53
|
+
border-radius: 0 ${(0,q.toRem)(4)} ${(0,q.toRem)(4)} 0;
|
|
54
54
|
|
|
55
55
|
margin: 0px -13px 0px 0px;
|
|
56
56
|
|
|
57
57
|
svg {
|
|
58
|
-
width: ${({size:c})=>
|
|
58
|
+
width: ${({size:c})=>h2(c)};
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
`;var K=require("react/jsx-runtime"),
|
|
61
|
+
`;var K=require("react/jsx-runtime"),k0=require("react"),m2=d=>{var M=d,{rules:c,name:e,defaultValue:l,shouldUnregister:r,datePickerProps:o,label:s,required:t,placeholder:u,disabled:f}=M,h=H(M,["rules","name","defaultValue","shouldUnregister","datePickerProps","label","required","placeholder","disabled"]);let V=(0,w1.useFormContext)();if(!V)throw new Error("Para usar o <DataPicker /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let C=E(V.formState.errors,e),P=(o==null?void 0:o.format)||"DD/MM/YYYY",g=c?(0,h1.composeValidators)([(0,h1.date)(P),c]):(0,h1.date)(P);return(0,K.jsx)(b0.LocalizationProvider,{dateAdapter:C0.AdapterDayjs,children:(0,K.jsx)(w1.Controller,{control:V.control,name:e,rules:g,defaultValue:l,shouldUnregister:r,render:({field:{value:m,onChange:p,ref:k}})=>(0,K.jsxs)(F0.Grid,{display:"flex",flexDirection:"column",children:[s&&(0,K.jsx)(b,{label:s,required:t}),(0,k0.createElement)(L0.DatePicker,n(a({},o),{key:e,value:m!=null?m:null,format:P,onChange:p,disabled:f,slots:{textField:g0.TextField},slotProps:{textField:v=>{var S,G;return n(a(n(a({variant:"outlined"},v),{error:!!C}),h),{inputProps:n(a({},v.inputProps),{placeholder:u||((S=v.inputProps)==null?void 0:S.placeholder)}),InputProps:n(a({},v.InputProps),{inputRef(y){k(y),typeof v.inputRef=="function"&&v.inputRef(y)},endAdornment:(0,K.jsx)(y0,{size:h.size,children:(G=v.InputProps)==null?void 0:G.endAdornment})})})}}})),(0,K.jsx)(w,{name:e})]})})})},P0=(0,x0.memo)(m2);var S0=require("react"),S1=require("react-hook-form"),T0=require("@s_mart/core"),d1=require("@s_mart/rules"),E0=require("@mui/material"),G0=require("@mui/x-date-pickers/TimePicker"),D0=require("@mui/x-date-pickers/AdapterDayjs"),I0=require("@mui/x-date-pickers/LocalizationProvider");var $=require("@s_mart/utils"),A0=p1(require("@emotion/styled")),v2=c=>{switch(c){case"small":return(0,$.toRem)(16);default:case"medium":return(0,$.toRem)(20);case"large":return(0,$.toRem)(24)}},Z2=c=>{switch(c){case"small":return`${(0,$.toRem)(2)} ${(0,$.toRem)(8)}`;default:case"medium":return`${(0,$.toRem)(6)} ${(0,$.toRem)(8)}`;case"large":return`${(0,$.toRem)(10)}`}},w0=A0.default.div`
|
|
62
62
|
> div > button {
|
|
63
|
-
padding: ${({size:c})=>
|
|
64
|
-
border-radius: 0 ${(0
|
|
63
|
+
padding: ${({size:c})=>Z2(c)};
|
|
64
|
+
border-radius: 0 ${(0,$.toRem)(4)} ${(0,$.toRem)(4)} 0;
|
|
65
65
|
|
|
66
66
|
margin: 0px -13px 0px 0px;
|
|
67
67
|
|
|
68
68
|
svg {
|
|
69
|
-
width: ${({size:c})=>
|
|
69
|
+
width: ${({size:c})=>v2(c)};
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
`;var _=require("react/jsx-runtime"),
|
|
72
|
+
`;var _=require("react/jsx-runtime"),p2=d=>{var M=d,{rules:c,defaultValue:e,shouldUnregister:l,name:r,required:o,label:s,timePickerProps:t,placeholder:u,disabled:f}=M,h=H(M,["rules","defaultValue","shouldUnregister","name","required","label","timePickerProps","placeholder","disabled"]);let V=(0,S1.useFormContext)();if(!V)throw new Error("Para usar o <TimePicker /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let C=E(V.formState.errors,r),P=(t==null?void 0:t.format)||"HH:mm",g=c?(0,d1.composeValidators)([(0,d1.time)(P),c]):(0,d1.time)(P);return(0,_.jsx)(I0.LocalizationProvider,{dateAdapter:D0.AdapterDayjs,children:(0,_.jsx)(S1.Controller,{control:V.control,name:r,rules:g,defaultValue:e,shouldUnregister:l,render:({field:{value:m,onChange:p,ref:k}})=>(0,_.jsxs)(T0.Grid,{display:"flex",flexDirection:"column",children:[s&&(0,_.jsx)(b,{label:s,required:o}),(0,_.jsx)(G0.TimePicker,n(a({ampm:!1,format:P,value:m!=null?m:null,onChange:p,disabled:f},t),{slots:{textField:E0.TextField},slotProps:{textField:v=>{var S,G;return n(a(n(a({variant:"outlined"},v),{error:!!C}),h),{inputProps:n(a({},v.inputProps),{placeholder:u||((S=v.inputProps)==null?void 0:S.placeholder)}),InputProps:n(a({},v.InputProps),{inputRef(y){k(y),typeof v.inputRef=="function"&&v.inputRef(y)},endAdornment:(0,_.jsx)(w0,{size:h.size,children:(G=v.InputProps)==null?void 0:G.endAdornment})})})}}}),r),(0,_.jsx)(w,{name:r})]})})})},B0=(0,S0.memo)(p2);var R0=require("react"),T1=require("react-hook-form"),E1=require("@mui/material"),m1=require("@s_mart/core");var z=require("react/jsx-runtime"),q0=require("react"),u2=M=>{var V=M,{name:c,defaultValue:e,rules:l,shouldUnregister:r,label:o,required:s,noOptionsText:t,placeholder:u,onInputChange:f,onChange:h}=V,d=H(V,["name","defaultValue","rules","shouldUnregister","label","required","noOptionsText","placeholder","onInputChange","onChange"]);let C=(0,T1.useFormContext)();if(!C)throw new Error("Para usar o <Autocomplete /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let P=E(C.formState.errors,c);return console.warn=()=>{},(0,z.jsx)(T1.Controller,{name:c,control:C.control,defaultValue:e,rules:l,shouldUnregister:r,render:({field:g})=>(0,z.jsxs)(m1.Grid,{display:"flex",flexDirection:"column",children:[o&&(0,z.jsx)(b,{label:o,required:s}),(0,z.jsx)(E1.Autocomplete,n(a({onChange:(m,p)=>{g.onChange(p),h==null||h(p,C.watch())},onInputChange:(m,p,k)=>{k==="input"&&(g.onChange(p),setTimeout(()=>{f==null||f(p,C.watch())},0))},isOptionEqualToValue:(m,p)=>m.value===p.value,renderOption:(m,p)=>(0,q0.createElement)("li",n(a({},m),{key:p.key||p.value,onClick:k=>{var v;(v=m.onClick)==null||v.call(m,k),g.onChange(p)}}),(0,z.jsxs)(m1.Grid,{container:!0,direction:"column",children:[(0,z.jsx)(m1.Grid,{item:!0,children:p.label}),p.afterLabel&&(0,z.jsx)(m1.Grid,{item:!0,children:p.afterLabel})]})),value:g.value||null,noOptionsText:t||"Nenhuma op\xE7\xE3o encontrada"},d),{renderInput:m=>{var p,k,v;return(0,z.jsx)(E1.TextField,n(a(a({placeholder:u},m),d.textFieldProps),{error:!!P,InputProps:n(a(a({},m.InputProps),(p=d.textFieldProps)==null?void 0:p.InputProps),{inputRef:g.ref,inputProps:a(a({},m.inputProps),(v=(k=d.textFieldProps)==null?void 0:k.InputProps)==null?void 0:v.inputProps)})}))}}),c),(0,z.jsx)(w,{name:c})]})})},U0=(0,R0.memo)(u2);0&&(module.exports={Autocomplete,Checkbox,Creatable,DatePicker,Form,FormProvider,RadioButton,RadioGroup,Searchable,Select,Slider,Switch,TextField,TimePicker,useForm});
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var D1=Object.defineProperty,B1=Object.defineProperties;var R1=Object.getOwnPropertyDescriptors;var c1=Object.getOwnPropertySymbols;var d1=Object.prototype.hasOwnProperty,m1=Object.prototype.propertyIsEnumerable;var h1=(c,e,a)=>e in c?D1(c,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):c[e]=a,i=(c,e)=>{for(var a in e||(e={}))d1.call(e,a)&&h1(c,a,e[a]);if(c1)for(var a of c1(e))m1.call(e,a)&&h1(c,a,e[a]);return c},t=(c,e)=>B1(c,R1(e));var y=(c,e)=>{var a={};for(var r in c)d1.call(c,r)&&e.indexOf(r)<0&&(a[r]=c[r]);if(c!=null&&c1)for(var r of c1(c))e.indexOf(r)<0&&m1.call(c,r)&&(a[r]=c[r]);return a};import{useEffect as I1}from"react";import{FormProvider as q1,useForm as $1}from"react-hook-form";import{zodResolver as z1}from"@hookform/resolvers/zod";import{jsx as v1}from"react/jsx-runtime";function U1(V){var h=V,{children:c,onSubmit:e,style:a,disableDefaultValuesUpdate:r}=h,o=y(h,["children","onSubmit","style","disableDefaultValuesUpdate"]);let s=$1(t(i({},o),{resolver:o.schema&&z1(o.schema)}));I1(()=>{r||s.reset(o.defaultValues)},[o.defaultValues,s.reset]);let m=()=>typeof c=="function"?c(t(i({},s),{onSubmit:s.handleSubmit(n=>e(n,s))})):c;return v1(q1,t(i({},s),{children:v1("form",{onSubmit:n=>{n.preventDefault(),n.stopPropagation(),s.handleSubmit(d=>e(d,s))()},style:a,children:m()})}))}var O1=U1;import{memo as K1,useState as Q1}from"react";import{Controller as J1,useFormContext as X1}from"react-hook-form";import{Grid as s1,InputAdornment as c0,TextField as l0}from"@mui/material";var Z1={description:"M39 23.1a17 17 0 0 0-15-10c-6.5.1-12.4 4-15.2 10V25a17 17 0 0 0 15 10A17 17 0 0 0 39 25c.5-.7.5-1.3.2-1.8Zm-15 9a8 8 0 0 1-7.6-8.5c.2-4.2 3.5-7.8 7.6-7.8a8 8 0 0 1 7.6 8.4c-.1 4.3-3.5 7.9-7.6 7.9Zm0-13.5-1.3.1c.7 1.1.6 2.6-.3 3.7-1 .9-2.3.9-3.4.1-.4 2.2.3 4.7 2.1 6a4.9 4.9 0 0 0 6-.2c1.6-1.4 2.4-4 1.6-6.1a4.9 4.9 0 0 0-4.7-3.6Z",id:"line-eye-solid"},p1={description:"M24 31.7c-4 0-7.4-3.1-7.7-7.1l-5.6-4.4c-.8 1-1.4 2-2 3a1.7 1.7 0 0 0 0 1.6 17.2 17.2 0 0 0 19.5 9l-2.8-2.2-1.4.1ZM40.9 35l-6-4.6c1.8-1.5 3.3-3.4 4.4-5.5a1.7 1.7 0 0 0 0-1.6c-3-5.7-8.7-9.5-15.3-9.5-2.8 0-5.5.7-8 2l-6.8-5.3a.9.9 0 0 0-1.2.2L7 12a.9.9 0 0 0 .1 1.2l31.7 24.5a.9.9 0 0 0 1.2-.2l1-1.3a.9.9 0 0 0-.1-1.2Zm-10-7.7-2-1.6a5 5 0 0 0-6.3-6.6 2.5 2.5 0 0 1 .4 2l-3.9-3a7.7 7.7 0 0 1 10.4.5 7.7 7.7 0 0 1 1.5 8.7Z",id:"line-eye-slash-solid"};var q={description:"M24 8a16 16 0 0 0 0 32 16 16 0 0 0 0-32Zm0 7.1c1.5 0 2.7 1.2 2.7 2.7 0 1.6-1.2 2.7-2.7 2.7a2.6 2.6 0 0 1-2.7-2.7c0-1.5 1.2-2.7 2.7-2.7Zm3.6 16.4c0 .4-.4.8-.8.8h-5.6a.7.7 0 0 1-.8-.8v-1.6c0-.4.3-.7.8-.7h.7V25h-.7a.7.7 0 0 1-.8-.7v-1.6c0-.4.3-.8.8-.8h4c.5 0 .9.4.9.8v6.5h.7c.4 0 .8.3.8.7v1.6Z",id:"line-info-circle-solid"};var u1={description:"m25.5 17 5.5 5.5-12 12-4.9.5a1 1 0 0 1-1-1.1l.5-5L25.5 17Zm8.9-.8-2.6-2.6a2 2 0 0 0-2.9 0L26.5 16l5.5 5.5 2.4-2.4a2 2 0 0 0 0-3Z",id:"line-pen-solid"};var t1={description:"M35.8 21.8h-9.6v-9.6c0-.6-.6-1.1-1.1-1.1h-2.2a1 1 0 0 0-1 1v9.7h-9.7c-.6 0-1.1.6-1.1 1.1v2.2c0 .6.5 1 1 1h9.7v9.7c0 .6.5 1.1 1.1 1.1h2.2c.5 0 1-.5 1-1v-9.7h9.7c.6 0 1.1-.5 1.1-1.1v-2.2c0-.5-.5-1-1-1Z",id:"line-plus-solid"};import*as N from"@s_mart/masks";import{Typography as f1}from"@mui/material";import{toRem as _1}from"@s_mart/utils";import{jsx as M1,jsxs as N1}from"react/jsx-runtime";var F=({label:c,required:e,regular:a})=>N1("span",{style:{display:"flex",alignItems:"center",gap:_1(2)},children:[M1(f1,{variant:"caption",fontWeight:a?400:700,style:{display:"flex",alignItems:"center"},children:c}),e&&M1(f1,{variant:"caption",fontWeight:900,color:"error",children:"*"})]});import{useFormContext as j1}from"react-hook-form";import{Indicator as W1}from"@s_mart/core";var E=(c,e)=>{var a,r,o,V,h;if(c[e])return c[e];if(e.includes("[")){let[s,m]=e.split("["),[n,d]=m.split("].");return(r=(a=c[s])==null?void 0:a[n])==null?void 0:r[d]}if(e.includes(".")){let[s,m,n]=e.split(".");return n?(h=(V=c[s])==null?void 0:V[m])==null?void 0:h[n]:(o=c[s])==null?void 0:o[m]}};import{jsx as Y1}from"react/jsx-runtime";var k=({name:c})=>{var r;let e=j1(),a=E((r=e==null?void 0:e.formState)==null?void 0:r.errors,c);return a?Y1(W1,{severity:"error",children:a==null?void 0:a.message}):null};import{LIcon as H1,Tooltip as e0}from"@s_mart/core";import{jsx as B,jsxs as V1}from"react/jsx-runtime";var i0=g=>{var L=g,{name:c,rules:e,defaultValue:a,shouldUnregister:r,label:o,required:V,mask:h,variant:s="outlined",info:m,parse:n,format:d,onInputChange:u}=L,f=y(L,["name","rules","defaultValue","shouldUnregister","label","required","mask","variant","info","parse","format","onInputChange"]);let x=X1();if(!x)throw new Error("Para usar o <TextField /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let[v,p]=Q1(!1),C=M=>{var l;let H=M;return d&&(H=d(M)),h?(l=N==null?void 0:N[h])==null?void 0:l.format(H):H},Z=M=>{var l;let H=M;return n&&(H=n(M)),h?(l=N==null?void 0:N[h])==null?void 0:l.parse(H):H},w=M=>{if(!M||h!=="porcentagem")return;M==null||M.stopPropagation();let H=(M==null?void 0:M.target).value;if(H){let l=String(H);if(l.length>0){let T=l.indexOf("%");T>-1&&(M.currentTarget.selectionEnd=T)}}},G=E(x.formState.errors,c);return B(J1,{control:x.control,name:c,rules:e,defaultValue:a,shouldUnregister:r,render:({field:{value:M,onChange:H,ref:l}})=>V1(s1,{display:"flex",flexDirection:"column",children:[V1("div",{style:{display:"flex"},children:[o&&B(s1,{item:!0,children:B(F,{label:o,required:V})}),m&&B(s1,{item:!0,children:B(e0,{title:m,placement:"top",children:B("div",{style:{width:"fit-content"},children:B(H1,{icon:q,color:"#757575"})})})})]}),B(l0,t(i({variant:s,defaultValue:a,value:C(M||""),onChange:T=>{var Y;let X=Z((Y=T==null?void 0:T.target)==null?void 0:Y.value);H(X),u==null||u(X,x.watch())},error:!!G},f),{type:f.type==="password"?v?"text":"password":f.type,autoComplete:f.autoComplete||"off",InputProps:i({onKeyDown:w,inputRef:l,endAdornment:f.type==="password"&&B(c0,{position:"end",onClick:()=>p(!v),style:{cursor:"pointer"},children:B(H1,{icon:v?Z1:p1,size:"24px",removeMargin:!0})})},f.InputProps)}),c),B(k,{name:c})]})})},a0=K1(i0);import{memo as o0,useState as r0}from"react";import{Controller as n0,useFormContext as t0}from"react-hook-form";import{Divider as s0,LIcon as h0,Tooltip as d0}from"@s_mart/core";import{Grid as z,Select as m0,MenuItem as y1,useTheme as v0}from"@mui/material";import{jsx as S,jsxs as l1}from"react/jsx-runtime";var Z0=L=>{var x=L,{name:c,rules:e,defaultValue:a,shouldUnregister:r,label:o,required:V,options:h,placeholder:s,disableOnChangeForm:m=!1,multiple:n,info:d,footer:u,onChange:f}=x,g=y(x,["name","rules","defaultValue","shouldUnregister","label","required","options","placeholder","disableOnChangeForm","multiple","info","footer","onChange"]);let v=t0(),{palette:p}=v0(),[C,Z]=r0(!1);if(!v)throw new Error("Para usar o <Select /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let w=E(v.formState.errors,c);return console.warn=()=>{},S(n0,{control:v.control,name:c,rules:e,defaultValue:a,shouldUnregister:r,render:({field:{value:G,onChange:M,ref:H}})=>l1(z,{display:"flex",flexDirection:"column",children:[l1("div",{style:{display:"flex"},children:[o&&S(z,{item:!0,children:S(F,{label:o,required:V})}),d&&S(z,{item:!0,children:S(d0,{title:d,placement:"top",children:S("div",{style:{width:"fit-content"},children:S(h0,{icon:q,color:"#757575"})})})})]}),l1(m0,t(i({open:C,onOpen:()=>Z(!0),onClose:()=>Z(!1),displayEmpty:!!s,variant:"outlined",autoComplete:"off",value:G?G||"":n?[]:"",renderValue:l=>{if(l.label)return l.label;if(s)return S("p",{style:{color:p.grey[400]},children:s})},multiple:n,onChange:l=>{!m&&M(l.target.value),f&&f(l.target.value,v.watch())},error:!!w,size:g.size||"medium",inputRef:H},g),{children:[s&&S(y1,{disabled:!0,value:"",children:S("p",{style:{color:p.grey[400]},children:s})}),h==null?void 0:h.map((l,T)=>S(y1,{value:l,children:l1(z,{container:!0,direction:"column",children:[S(z,{item:!0,children:l.label}),l.afterLabel&&S(z,{item:!0,children:l.afterLabel})]})},T)),u&&[S(z,{px:2,py:1,children:S(s0,{})},"footer-divider"),S("div",{children:u({closeSelect:()=>Z(!1)})},"footer-content")]]}),c),S(k,{name:c})]})})},p0=o0(Z0);import{forwardRef as u0,memo as f0}from"react";import{Controller as M0,useFormContext as H0}from"react-hook-form";import{Divider as x1,LIcon as V0,Tooltip as y0}from"@s_mart/core";import{Grid as $,Autocomplete as x0,TextField as g0}from"@mui/material";import{Fragment as e1,jsx as A,jsxs as U}from"react/jsx-runtime";import{createElement as g1}from"react";var F0=v=>{var p=v,{name:c,rules:e,defaultValue:a,shouldUnregister:r,label:o,required:V,options:h,textFieldProps:s,noOptionsText:m,footer:n,multiple:d,info:u,placeholder:f,onChange:g,onInputChange:L}=p,x=y(p,["name","rules","defaultValue","shouldUnregister","label","required","options","textFieldProps","noOptionsText","footer","multiple","info","placeholder","onChange","onInputChange"]);let C=H0();if(!C)throw new Error("Para usar o <Searchable /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let Z=E(C.formState.errors,c);return console.warn=()=>{},A(M0,{control:C.control,name:c,rules:e,defaultValue:a,shouldUnregister:r,render:({field:{onChange:w,value:G,ref:M}})=>U($,{display:"flex",flexDirection:"column",children:[U("div",{style:{display:"flex"},children:[o&&A($,{item:!0,children:A(F,{label:o,required:V})}),u&&A($,{item:!0,children:A(y0,{title:u,placement:"top",children:A("div",{style:{width:"fit-content"},children:A(V0,{icon:q,color:"#757575"})})})})]}),A(x0,t(i({onChange:(H,l)=>{w(l),g==null||g(l,C.watch())},onInputChange:(H,l,T)=>{T==="input"&&setTimeout(()=>{L==null||L(l,C.watch())},0)},value:G||(d?[]:null),options:h,multiple:d,noOptionsText:U(e1,{children:[m||"Nenhum resultado encontrado",n?U(e1,{children:[A($,{py:1,children:A(x1,{})}),n]}):null]}),isOptionEqualToValue:(H,l)=>typeof H=="string"&&typeof l=="string"?H===l:typeof H=="object"&&typeof l=="object"?H.value===l.value:!1,renderOption:(H,l)=>typeof l=="object"?g1("li",t(i({},H),{key:l.key||l.value}),U($,{container:!0,direction:"column",children:[A($,{item:!0,children:l.label}),l.afterLabel&&A($,{item:!0,children:l.afterLabel})]})):g1("li",t(i({},H),{key:l}),l),ListboxComponent:u0(function(l,T){return U(e1,{children:[A("ul",t(i({},l),{ref:T})),!!n&&A("div",t(i({},l),{children:U(e1,{children:[A($,{px:2,py:1,children:A(x1,{})}),n]})}),"searchable-footer")]})})},x),{renderInput:H=>A(g0,t(i(i({error:!!Z,placeholder:f},H),s),{inputRef:M}))}),c),A(k,{name:c})]})})},L0=f0(F0);import{memo as k0}from"react";import{Controller as P0,useFormContext as A0}from"react-hook-form";import{Grid as j,Autocomplete as w0,TextField as S0}from"@mui/material";import{toRem as i1}from"@s_mart/utils";import C0 from"@emotion/styled";import{css as F1}from"@emotion/react";var L1=F1`
|
|
1
|
+
var B1=Object.defineProperty,R1=Object.defineProperties;var U1=Object.getOwnPropertyDescriptors;var c1=Object.getOwnPropertySymbols;var v1=Object.prototype.hasOwnProperty,Z1=Object.prototype.propertyIsEnumerable;var m1=(c,e,i)=>e in c?B1(c,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):c[e]=i,a=(c,e)=>{for(var i in e||(e={}))v1.call(e,i)&&m1(c,i,e[i]);if(c1)for(var i of c1(e))Z1.call(e,i)&&m1(c,i,e[i]);return c},n=(c,e)=>R1(c,U1(e));var M=(c,e)=>{var i={};for(var r in c)v1.call(c,r)&&e.indexOf(r)<0&&(i[r]=c[r]);if(c!=null&&c1)for(var r of c1(c))e.indexOf(r)<0&&Z1.call(c,r)&&(i[r]=c[r]);return i};import{FormProvider as q1}from"react-hook-form";import{jsx as p1}from"react/jsx-runtime";var $1=o=>{var s=o,{children:c,style:e,onSubmit:i}=s,r=M(s,["children","style","onSubmit"]);return p1(q1,n(a({},r),{children:p1("form",{onSubmit:t=>{t.preventDefault(),t.stopPropagation(),i(t)},style:e,children:c})}))},t1=$1;import{useEffect as z1}from"react";import{useForm as O1}from"react-hook-form";import{zodResolver as _1}from"@hookform/resolvers/zod";var N1=r=>{var o=r,{disableDefaultValuesUpdate:c,onSubmit:e}=o,i=M(o,["disableDefaultValuesUpdate","onSubmit"]);let s=O1(n(a({},i),{resolver:i.schema&&_1(i.schema)}));return z1(()=>{c||s.reset(i.defaultValues)},[i.defaultValues,s.reset]),n(a({},s),{onSubmit:s.handleSubmit(t=>e(t,s))})},s1=N1;import{jsx as Y1}from"react/jsx-runtime";function W1(r){var o=r,{children:c,style:e}=o,i=M(o,["children","style"]);let s=s1(i);return Y1(t1,n(a({},s),{style:e,children:typeof c=="function"?c(s):c}))}var j1=W1;import{memo as e0,useState as l0}from"react";import{Controller as i0,useFormContext as a0}from"react-hook-form";import{Grid as d1,InputAdornment as o0,TextField as r0}from"@mui/material";var u1={description:"M39 23.1a17 17 0 0 0-15-10c-6.5.1-12.4 4-15.2 10V25a17 17 0 0 0 15 10A17 17 0 0 0 39 25c.5-.7.5-1.3.2-1.8Zm-15 9a8 8 0 0 1-7.6-8.5c.2-4.2 3.5-7.8 7.6-7.8a8 8 0 0 1 7.6 8.4c-.1 4.3-3.5 7.9-7.6 7.9Zm0-13.5-1.3.1c.7 1.1.6 2.6-.3 3.7-1 .9-2.3.9-3.4.1-.4 2.2.3 4.7 2.1 6a4.9 4.9 0 0 0 6-.2c1.6-1.4 2.4-4 1.6-6.1a4.9 4.9 0 0 0-4.7-3.6Z",id:"line-eye-solid"},f1={description:"M24 31.7c-4 0-7.4-3.1-7.7-7.1l-5.6-4.4c-.8 1-1.4 2-2 3a1.7 1.7 0 0 0 0 1.6 17.2 17.2 0 0 0 19.5 9l-2.8-2.2-1.4.1ZM40.9 35l-6-4.6c1.8-1.5 3.3-3.4 4.4-5.5a1.7 1.7 0 0 0 0-1.6c-3-5.7-8.7-9.5-15.3-9.5-2.8 0-5.5.7-8 2l-6.8-5.3a.9.9 0 0 0-1.2.2L7 12a.9.9 0 0 0 .1 1.2l31.7 24.5a.9.9 0 0 0 1.2-.2l1-1.3a.9.9 0 0 0-.1-1.2Zm-10-7.7-2-1.6a5 5 0 0 0-6.3-6.6 2.5 2.5 0 0 1 .4 2l-3.9-3a7.7 7.7 0 0 1 10.4.5 7.7 7.7 0 0 1 1.5 8.7Z",id:"line-eye-slash-solid"};var U={description:"M24 8a16 16 0 0 0 0 32 16 16 0 0 0 0-32Zm0 7.1c1.5 0 2.7 1.2 2.7 2.7 0 1.6-1.2 2.7-2.7 2.7a2.6 2.6 0 0 1-2.7-2.7c0-1.5 1.2-2.7 2.7-2.7Zm3.6 16.4c0 .4-.4.8-.8.8h-5.6a.7.7 0 0 1-.8-.8v-1.6c0-.4.3-.7.8-.7h.7V25h-.7a.7.7 0 0 1-.8-.7v-1.6c0-.4.3-.8.8-.8h4c.5 0 .9.4.9.8v6.5h.7c.4 0 .8.3.8.7v1.6Z",id:"line-info-circle-solid"};var M1={description:"m25.5 17 5.5 5.5-12 12-4.9.5a1 1 0 0 1-1-1.1l.5-5L25.5 17Zm8.9-.8-2.6-2.6a2 2 0 0 0-2.9 0L26.5 16l5.5 5.5 2.4-2.4a2 2 0 0 0 0-3Z",id:"line-pen-solid"};var h1={description:"M35.8 21.8h-9.6v-9.6c0-.6-.6-1.1-1.1-1.1h-2.2a1 1 0 0 0-1 1v9.7h-9.7c-.6 0-1.1.6-1.1 1.1v2.2c0 .6.5 1 1 1h9.7v9.7c0 .6.5 1.1 1.1 1.1h2.2c.5 0 1-.5 1-1v-9.7h9.7c.6 0 1.1-.5 1.1-1.1v-2.2c0-.5-.5-1-1-1Z",id:"line-plus-solid"};import*as N from"@s_mart/masks";import{Typography as H1}from"@mui/material";import{toRem as K1}from"@s_mart/utils";import{jsx as V1,jsxs as Q1}from"react/jsx-runtime";var g=({label:c,required:e,regular:i})=>Q1("span",{style:{display:"flex",alignItems:"center",gap:K1(2)},children:[V1(H1,{variant:"caption",fontWeight:i?400:700,style:{display:"flex",alignItems:"center"},children:c}),e&&V1(H1,{variant:"caption",fontWeight:900,color:"error",children:"*"})]});import{useFormContext as J1}from"react-hook-form";import{Indicator as X1}from"@s_mart/core";var E=(c,e)=>{var i,r,o,s,t;if(c[e])return c[e];if(e.includes("[")){let[p,u]=e.split("["),[h,d]=u.split("].");return(r=(i=c[p])==null?void 0:i[h])==null?void 0:r[d]}if(e.includes(".")){let[p,u,h]=e.split(".");return h?(t=(s=c[p])==null?void 0:s[u])==null?void 0:t[h]:(o=c[p])==null?void 0:o[u]}};import{jsx as c0}from"react/jsx-runtime";var P=({name:c})=>{var r;let e=J1(),i=E((r=e==null?void 0:e.formState)==null?void 0:r.errors,c);return i?c0(X1,{severity:"error",children:i==null?void 0:i.message}):null};import{LIcon as y1,Tooltip as n0}from"@s_mart/core";import{jsx as I,jsxs as x1}from"react/jsx-runtime";var t0=F=>{var L=F,{name:c,rules:e,defaultValue:i,shouldUnregister:r,label:o,required:s,mask:t,variant:p="outlined",info:u,parse:h,format:d,onInputChange:f}=L,H=M(L,["name","rules","defaultValue","shouldUnregister","label","required","mask","variant","info","parse","format","onInputChange"]);let x=a0();if(!x)throw new Error("Para usar o <TextField /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let[m,Z]=l0(!1),C=V=>{var l;let y=V;return d&&(y=d(V)),t?(l=N==null?void 0:N[t])==null?void 0:l.format(y):y},v=V=>{var l;let y=V;return h&&(y=h(V)),t?(l=N==null?void 0:N[t])==null?void 0:l.parse(y):y},w=V=>{if(!V||t!=="porcentagem")return;V==null||V.stopPropagation();let y=(V==null?void 0:V.target).value;if(y){let l=String(y);if(l.length>0){let T=l.indexOf("%");T>-1&&(V.currentTarget.selectionEnd=T)}}},G=E(x.formState.errors,c);return I(i0,{control:x.control,name:c,rules:e,defaultValue:i,shouldUnregister:r,render:({field:{value:V,onChange:y,ref:l}})=>x1(d1,{display:"flex",flexDirection:"column",children:[x1("div",{style:{display:"flex"},children:[o&&I(d1,{item:!0,children:I(g,{label:o,required:s})}),u&&I(d1,{item:!0,children:I(n0,{title:u,placement:"top",children:I("div",{style:{width:"fit-content"},children:I(y1,{icon:U,color:"#757575"})})})})]}),I(r0,n(a({variant:p,defaultValue:i,value:C(V||""),onChange:T=>{var Y;let X=v((Y=T==null?void 0:T.target)==null?void 0:Y.value);y(X),f==null||f(X,x.watch())},error:!!G},H),{type:H.type==="password"?m?"text":"password":H.type,autoComplete:H.autoComplete||"off",InputProps:a({onKeyDown:w,inputRef:l,endAdornment:H.type==="password"&&I(o0,{position:"end",onClick:()=>Z(!m),style:{cursor:"pointer"},children:I(y1,{icon:m?u1:f1,size:"24px",removeMargin:!0})})},H.InputProps)}),c),I(P,{name:c})]})})},s0=e0(t0);import{memo as h0,useState as d0}from"react";import{Controller as m0,useFormContext as v0}from"react-hook-form";import{Divider as Z0,LIcon as p0,Tooltip as u0}from"@s_mart/core";import{Grid as $,Select as f0,MenuItem as F1,useTheme as M0}from"@mui/material";import{jsx as S,jsxs as e1}from"react/jsx-runtime";var H0=L=>{var x=L,{name:c,rules:e,defaultValue:i,shouldUnregister:r,label:o,required:s,options:t,placeholder:p,disableOnChangeForm:u=!1,multiple:h,info:d,footer:f,onChange:H}=x,F=M(x,["name","rules","defaultValue","shouldUnregister","label","required","options","placeholder","disableOnChangeForm","multiple","info","footer","onChange"]);let m=v0(),{palette:Z}=M0(),[C,v]=d0(!1);if(!m)throw new Error("Para usar o <Select /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let w=E(m.formState.errors,c);return console.warn=()=>{},S(m0,{control:m.control,name:c,rules:e,defaultValue:i,shouldUnregister:r,render:({field:{value:G,onChange:V,ref:y}})=>e1($,{display:"flex",flexDirection:"column",children:[e1("div",{style:{display:"flex"},children:[o&&S($,{item:!0,children:S(g,{label:o,required:s})}),d&&S($,{item:!0,children:S(u0,{title:d,placement:"top",children:S("div",{style:{width:"fit-content"},children:S(p0,{icon:U,color:"#757575"})})})})]}),e1(f0,n(a({open:C,onOpen:()=>v(!0),onClose:()=>v(!1),displayEmpty:!!p,variant:"outlined",autoComplete:"off",value:G?G||"":h?[]:"",renderValue:l=>{if(l.label)return l.label;if(p)return S("p",{style:{color:Z.grey[400]},children:p})},multiple:h,onChange:l=>{!u&&V(l.target.value),H&&H(l.target.value,m.watch())},error:!!w,size:F.size||"medium",inputRef:y},F),{children:[p&&S(F1,{disabled:!0,value:"",children:S("p",{style:{color:Z.grey[400]},children:p})}),t==null?void 0:t.map((l,T)=>S(F1,{value:l,children:e1($,{container:!0,direction:"column",children:[S($,{item:!0,children:l.label}),l.afterLabel&&S($,{item:!0,children:l.afterLabel})]})},T)),f&&[S($,{px:2,py:1,children:S(Z0,{})},"footer-divider"),S("div",{children:f({closeSelect:()=>v(!1)})},"footer-content")]]}),c),S(P,{name:c})]})})},V0=h0(H0);import{forwardRef as y0,memo as x0}from"react";import{Controller as F0,useFormContext as g0}from"react-hook-form";import{Divider as g1,LIcon as L0,Tooltip as C0}from"@s_mart/core";import{Grid as q,Autocomplete as b0,TextField as P0}from"@mui/material";import{Fragment as l1,jsx as A,jsxs as z}from"react/jsx-runtime";import{createElement as L1}from"react";var k0=m=>{var Z=m,{name:c,rules:e,defaultValue:i,shouldUnregister:r,label:o,required:s,options:t,textFieldProps:p,noOptionsText:u,footer:h,multiple:d,info:f,placeholder:H,onChange:F,onInputChange:L}=Z,x=M(Z,["name","rules","defaultValue","shouldUnregister","label","required","options","textFieldProps","noOptionsText","footer","multiple","info","placeholder","onChange","onInputChange"]);let C=g0();if(!C)throw new Error("Para usar o <Searchable /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let v=E(C.formState.errors,c);return console.warn=()=>{},A(F0,{control:C.control,name:c,rules:e,defaultValue:i,shouldUnregister:r,render:({field:{onChange:w,value:G,ref:V}})=>z(q,{display:"flex",flexDirection:"column",children:[z("div",{style:{display:"flex"},children:[o&&A(q,{item:!0,children:A(g,{label:o,required:s})}),f&&A(q,{item:!0,children:A(C0,{title:f,placement:"top",children:A("div",{style:{width:"fit-content"},children:A(L0,{icon:U,color:"#757575"})})})})]}),A(b0,n(a({onChange:(y,l)=>{w(l),F==null||F(l,C.watch())},onInputChange:(y,l,T)=>{T==="input"&&setTimeout(()=>{L==null||L(l,C.watch())},0)},value:G||(d?[]:null),options:t,multiple:d,noOptionsText:z(l1,{children:[u||"Nenhum resultado encontrado",h?z(l1,{children:[A(q,{py:1,children:A(g1,{})}),h]}):null]}),isOptionEqualToValue:(y,l)=>typeof y=="string"&&typeof l=="string"?y===l:typeof y=="object"&&typeof l=="object"?y.value===l.value:!1,renderOption:(y,l)=>typeof l=="object"?L1("li",n(a({},y),{key:l.key||l.value}),z(q,{container:!0,direction:"column",children:[A(q,{item:!0,children:l.label}),l.afterLabel&&A(q,{item:!0,children:l.afterLabel})]})):L1("li",n(a({},y),{key:l}),l),ListboxComponent:y0(function(l,T){return z(l1,{children:[A("ul",n(a({},l),{ref:T})),!!h&&A("div",n(a({},l),{children:z(l1,{children:[A(q,{px:2,py:1,children:A(g1,{})}),h]})}),"searchable-footer")]})})},x),{renderInput:y=>A(P0,n(a(a({error:!!v,placeholder:H},y),p),{inputRef:V}))}),c),A(P,{name:c})]})})},A0=x0(k0);import{memo as T0}from"react";import{Controller as E0,useFormContext as G0}from"react-hook-form";import{Grid as W,Autocomplete as D0,TextField as I0}from"@mui/material";import{toRem as i1}from"@s_mart/utils";import w0 from"@emotion/styled";import{css as C1}from"@emotion/react";var b1=C1`
|
|
2
2
|
display: flex;
|
|
3
3
|
align-items: center;
|
|
4
4
|
justify-content: center;
|
|
5
|
-
`,
|
|
5
|
+
`,S0=c=>C1`
|
|
6
6
|
.MuiAutocomplete-endAdornment {
|
|
7
7
|
position: relative;
|
|
8
8
|
right: 0;
|
|
@@ -10,7 +10,7 @@ var D1=Object.defineProperty,B1=Object.defineProperties;var R1=Object.getOwnProp
|
|
|
10
10
|
|
|
11
11
|
.creatable,
|
|
12
12
|
.editable {
|
|
13
|
-
${
|
|
13
|
+
${b1}
|
|
14
14
|
|
|
15
15
|
.divider {
|
|
16
16
|
width: 1px;
|
|
@@ -36,37 +36,37 @@ var D1=Object.defineProperty,B1=Object.defineProperties;var R1=Object.getOwnProp
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
`,
|
|
39
|
+
`,P1=w0.div`
|
|
40
40
|
display: flex;
|
|
41
41
|
|
|
42
42
|
div.endAdornments {
|
|
43
43
|
position: absolute;
|
|
44
44
|
right: 0;
|
|
45
45
|
|
|
46
|
-
${
|
|
46
|
+
${b1}
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
${({hideAddButton:c,theme:e})=>!c&&
|
|
50
|
-
`;import{LIcon as a1,Tooltip as
|
|
49
|
+
${({hideAddButton:c,theme:e})=>!c&&S0(e)}
|
|
50
|
+
`;import{LIcon as a1,Tooltip as B0,Button as R0}from"@s_mart/core";import{isObject as U0,isEmpty as q0}from"lodash";import{toRem as k1}from"@s_mart/utils";import{jsx as k,jsxs as O}from"react/jsx-runtime";import{createElement as A1}from"react";var $0=C=>{var v=C,{name:c,rules:e,defaultValue:i,shouldUnregister:r,label:o,required:s,options:t,editable:p,onEditOption:u,onCreateOption:h,textFieldProps:d,hideAddButton:f,multiple:H,info:F,onChange:L,onInputChange:x,placeholder:m}=v,Z=M(v,["name","rules","defaultValue","shouldUnregister","label","required","options","editable","onEditOption","onCreateOption","textFieldProps","hideAddButton","multiple","info","onChange","onInputChange","placeholder"]);let w=G0();if(!w)throw new Error("Para usar o <Creatable /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let G=E(w.formState.errors,c);console.warn=()=>{};let V=l=>{h?h(l):console.error("onCreateOption n\xE3o foi definido")},y=l=>{u?u(l):console.error("onEditOption n\xE3o foi definido")};return k(E0,{control:w.control,name:c,rules:e,defaultValue:i,shouldUnregister:r,render:({field:{value:l,onChange:T,ref:X}})=>{let Y=(l==null?void 0:l.label)||(l==null?void 0:l.value)||l;return O(W,{display:"flex",flexDirection:"column",children:[O("div",{style:{display:"flex"},children:[o&&k(W,{item:!0,children:k(g,{label:o,required:s})}),F&&k(W,{item:!0,children:k(B0,{title:F,placement:"top",children:k("div",{style:{width:"fit-content"},children:k(a1,{icon:U,color:"#757575"})})})})]}),k(P1,{hideAddButton:f,children:k(D0,n(a({fullWidth:!0,onChange:(D,b)=>{T(b),L==null||L(b,w.watch())},onInputChange:(D,b,I1)=>{I1==="input"&&(T(b),setTimeout(()=>{x==null||x(b,w.watch())},0))},options:t,value:l||(H?[]:null),multiple:H,noOptionsText:O(R0,{sx:{justifyContent:"flex-start",padding:`${k1(6)} ${k1(-16)}`,margin:0},fullWidth:!0,onClick:()=>V(l),variant:"text",startIcon:k(a1,{icon:h1}),children:["Adicionar ",Y&&`"${Y}"`]}),isOptionEqualToValue:(D,b)=>b?typeof D=="string"&&typeof b=="string"?D===b:typeof D=="object"&&typeof b=="object"?D.value===b.value:typeof D=="object"&&typeof b=="string":!1,renderOption:(D,b)=>typeof b=="object"?A1("li",n(a({},D),{key:b.key||b.value}),O(W,{container:!0,direction:"column",children:[k(W,{item:!0,children:b.label}),b.afterLabel&&k(W,{item:!0,children:b.afterLabel})]})):A1("li",n(a({},D),{key:b}),b)},Z),{renderInput:D=>k(I0,a(n(a({placeholder:m},D),{error:!!G,onChange:T,InputProps:n(a({},D.InputProps),{inputRef:X,endAdornment:f?void 0:O("div",{className:"endAdornments",children:[D.InputProps.endAdornment,p&&U0(l)&&!q0(l)?O("div",{className:"editable",children:[k("div",{className:"divider"}),k("div",{className:"button",onClick:()=>y(l),children:k(a1,{icon:M1,size:"24px",removeMargin:!0})})]}):null,O("div",{className:"creatable",children:[k("div",{className:"divider"}),k("div",{className:"button",onClick:()=>V(l),children:k(a1,{icon:h1,size:"24px",removeMargin:!0})})]})]})})}),d))}),c)}),k(P,{name:c})]})}})},z0=T0($0);import{Controller as O0,useFormContext as _0}from"react-hook-form";import{Grid as N0,Checkbox as W0,FormControlLabel as j0}from"@mui/material";import{jsx as K,jsxs as Q0}from"react/jsx-runtime";var Y0=u=>{var h=u,{name:c,rules:e,defaultValue:i,shouldUnregister:r,label:o,labelPlacement:s,required:t}=h,p=M(h,["name","rules","defaultValue","shouldUnregister","label","labelPlacement","required"]);let d=_0();if(!d)throw new Error("Para usar o <Checkbox /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return K(O0,{control:d.control,name:c,rules:e,defaultValue:i,shouldUnregister:r,render:({field:{value:f,onChange:H}})=>Q0(N0,{display:"flex",flexDirection:"column",children:[K(j0,{control:K(W0,a({checked:!!f,value:f!=null?f:"",defaultValue:f,onChange:H},p),c),label:K(g,{label:o,required:t,regular:!0}),labelPlacement:s||"end"}),K(P,{name:c})]})})},K0=Y0;import{Controller as J0,useFormContext as X0}from"react-hook-form";import{Grid as c2,Switch as e2,FormControlLabel as l2}from"@mui/material";import{jsx as Q,jsxs as o2}from"react/jsx-runtime";var i2=p=>{var u=p,{name:c,rules:e,defaultValue:i,shouldUnregister:r,label:o,labelPlacement:s}=u,t=M(u,["name","rules","defaultValue","shouldUnregister","label","labelPlacement"]);let h=X0();if(!h)throw new Error("Para usar o <Switch /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return Q(J0,{control:h.control,name:c,rules:e,defaultValue:i,shouldUnregister:r,render:({field:{value:d,onChange:f}})=>o2(c2,{display:"flex",flexDirection:"column",children:[Q(l2,{control:Q(e2,a({value:d!=null?d:"",checked:d!=null?d:!1,defaultValue:d,onChange:f},t),c),label:Q(g,{label:o}),labelPlacement:s||"end"}),Q(P,{name:c})]})})},a2=i2;import{Grid as r2,Radio as n2,FormControlLabel as t2}from"@mui/material";import{jsx as o1}from"react/jsx-runtime";var s2=r=>{var o=r,{label:c,labelPlacement:e}=o,i=M(o,["label","labelPlacement"]);return o1(r2,{display:"flex",flexDirection:"column",children:o1(t2,{control:o1(n2,a({},i)),label:o1(g,{label:c}),labelPlacement:e||"end"})})},h2=s2;import{Controller as d2,useFormContext as m2}from"react-hook-form";import{Grid as v2,RadioGroup as Z2}from"@mui/material";import{jsx as r1,jsxs as f2}from"react/jsx-runtime";var p2=h=>{var d=h,{name:c,rules:e,defaultValue:i,shouldUnregister:r,label:o,required:s,children:t,orientation:p="row"}=d,u=M(d,["name","rules","defaultValue","shouldUnregister","label","required","children","orientation"]);let f=m2();if(!f)throw new Error("Para usar o <RadioGroup /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return r1(d2,{control:f.control,name:c,rules:e,defaultValue:i,shouldUnregister:r,render:({field:{value:H,onChange:F}})=>f2(v2,{display:"flex",flexDirection:"column",children:[o&&r1(g,{label:o,required:s}),r1(Z2,n(a({value:H||"",onChange:F,name:c},u),{style:{display:"flex",flexDirection:p},children:t}),c),r1(P,{name:c})]})})},u2=p2;import{Controller as M2,useFormContext as H2}from"react-hook-form";import{Slider as V2}from"@mui/material";import{jsx as w1}from"react/jsx-runtime";var y2=s=>{var t=s,{name:c,rules:e,defaultValue:i,shouldUnregister:r}=t,o=M(t,["name","rules","defaultValue","shouldUnregister"]);let p=H2();if(!p)throw new Error("Para usar o <Slider /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");return w1(M2,{control:p.control,name:c,rules:e,defaultValue:i,shouldUnregister:r,render:({field:{value:u,onChange:h}})=>w1(V2,a({value:u||(o==null?void 0:o.min)||0,onChange:h,valueLabelDisplay:"auto"},o),c)})},x2=y2;import{memo as C2}from"react";import{Controller as b2,useFormContext as P2}from"react-hook-form";import{Grid as k2}from"@s_mart/core";import{composeValidators as A2,date as T1}from"@s_mart/rules";import{TextField as w2}from"@mui/material";import{DatePicker as S2}from"@mui/x-date-pickers/DatePicker";import{AdapterDayjs as T2}from"@mui/x-date-pickers/AdapterDayjs";import{LocalizationProvider as E2}from"@mui/x-date-pickers/LocalizationProvider";import{toRem as B}from"@s_mart/utils";import F2 from"@emotion/styled";var g2=c=>{switch(c){case"small":return B(16);default:case"medium":return B(20);case"large":return B(24)}},L2=c=>{switch(c){case"small":return`${B(2)} ${B(8)}`;default:case"medium":return`${B(6)} ${B(8)}`;case"large":return`${B(10)}`}},S1=F2.div`
|
|
51
51
|
> div > button {
|
|
52
|
-
padding: ${({size:c})=>
|
|
53
|
-
border-radius: 0 ${
|
|
52
|
+
padding: ${({size:c})=>L2(c)};
|
|
53
|
+
border-radius: 0 ${B(4)} ${B(4)} 0;
|
|
54
54
|
|
|
55
55
|
margin: 0px -13px 0px 0px;
|
|
56
56
|
|
|
57
57
|
svg {
|
|
58
|
-
width: ${({size:c})=>
|
|
58
|
+
width: ${({size:c})=>g2(c)};
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
`;import{jsx as J,jsxs as
|
|
61
|
+
`;import{jsx as J,jsxs as B2}from"react/jsx-runtime";import{createElement as I2}from"react";var G2=d=>{var f=d,{rules:c,name:e,defaultValue:i,shouldUnregister:r,datePickerProps:o,label:s,required:t,placeholder:p,disabled:u}=f,h=M(f,["rules","name","defaultValue","shouldUnregister","datePickerProps","label","required","placeholder","disabled"]);let H=P2();if(!H)throw new Error("Para usar o <DataPicker /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let F=E(H.formState.errors,e),L=(o==null?void 0:o.format)||"DD/MM/YYYY",x=c?A2([T1(L),c]):T1(L);return J(E2,{dateAdapter:T2,children:J(b2,{control:H.control,name:e,rules:x,defaultValue:i,shouldUnregister:r,render:({field:{value:m,onChange:Z,ref:C}})=>B2(k2,{display:"flex",flexDirection:"column",children:[s&&J(g,{label:s,required:t}),I2(S2,n(a({},o),{key:e,value:m!=null?m:null,format:L,onChange:Z,disabled:u,slots:{textField:w2},slotProps:{textField:v=>{var w,G;return n(a(n(a({variant:"outlined"},v),{error:!!F}),h),{inputProps:n(a({},v.inputProps),{placeholder:p||((w=v.inputProps)==null?void 0:w.placeholder)}),InputProps:n(a({},v.InputProps),{inputRef(V){C(V),typeof v.inputRef=="function"&&v.inputRef(V)},endAdornment:J(S1,{size:h.size,children:(G=v.InputProps)==null?void 0:G.endAdornment})})})}}})),J(P,{name:e})]})})})},D2=C2(G2);import{memo as $2}from"react";import{Controller as z2,useFormContext as O2}from"react-hook-form";import{Grid as _2}from"@s_mart/core";import{composeValidators as N2,time as G1}from"@s_mart/rules";import{TextField as W2}from"@mui/material";import{TimePicker as j2}from"@mui/x-date-pickers/TimePicker";import{AdapterDayjs as Y2}from"@mui/x-date-pickers/AdapterDayjs";import{LocalizationProvider as K2}from"@mui/x-date-pickers/LocalizationProvider";import{toRem as R}from"@s_mart/utils";import R2 from"@emotion/styled";var U2=c=>{switch(c){case"small":return R(16);default:case"medium":return R(20);case"large":return R(24)}},q2=c=>{switch(c){case"small":return`${R(2)} ${R(8)}`;default:case"medium":return`${R(6)} ${R(8)}`;case"large":return`${R(10)}`}},E1=R2.div`
|
|
62
62
|
> div > button {
|
|
63
|
-
padding: ${({size:c})=>
|
|
64
|
-
border-radius: 0 ${
|
|
63
|
+
padding: ${({size:c})=>q2(c)};
|
|
64
|
+
border-radius: 0 ${R(4)} ${R(4)} 0;
|
|
65
65
|
|
|
66
66
|
margin: 0px -13px 0px 0px;
|
|
67
67
|
|
|
68
68
|
svg {
|
|
69
|
-
width: ${({size:c})=>
|
|
69
|
+
width: ${({size:c})=>U2(c)};
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
`;import{jsx as
|
|
72
|
+
`;import{jsx as j,jsxs as X2}from"react/jsx-runtime";var Q2=d=>{var f=d,{rules:c,defaultValue:e,shouldUnregister:i,name:r,required:o,label:s,timePickerProps:t,placeholder:p,disabled:u}=f,h=M(f,["rules","defaultValue","shouldUnregister","name","required","label","timePickerProps","placeholder","disabled"]);let H=O2();if(!H)throw new Error("Para usar o <TimePicker /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let F=E(H.formState.errors,r),L=(t==null?void 0:t.format)||"HH:mm",x=c?N2([G1(L),c]):G1(L);return j(K2,{dateAdapter:Y2,children:j(z2,{control:H.control,name:r,rules:x,defaultValue:e,shouldUnregister:i,render:({field:{value:m,onChange:Z,ref:C}})=>X2(_2,{display:"flex",flexDirection:"column",children:[s&&j(g,{label:s,required:o}),j(j2,n(a({ampm:!1,format:L,value:m!=null?m:null,onChange:Z,disabled:u},t),{slots:{textField:W2},slotProps:{textField:v=>{var w,G;return n(a(n(a({variant:"outlined"},v),{error:!!F}),h),{inputProps:n(a({},v.inputProps),{placeholder:p||((w=v.inputProps)==null?void 0:w.placeholder)}),InputProps:n(a({},v.InputProps),{inputRef(V){C(V),typeof v.inputRef=="function"&&v.inputRef(V)},endAdornment:j(E1,{size:h.size,children:(G=v.InputProps)==null?void 0:G.endAdornment})})})}}}),r),j(P,{name:r})]})})})},J2=$2(Q2);import{memo as c3}from"react";import{Controller as e3,useFormContext as l3}from"react-hook-form";import{Autocomplete as i3,TextField as a3}from"@mui/material";import{Grid as n1}from"@s_mart/core";import{jsx as _,jsxs as D1}from"react/jsx-runtime";import{createElement as n3}from"react";var o3=f=>{var H=f,{name:c,defaultValue:e,rules:i,shouldUnregister:r,label:o,required:s,noOptionsText:t,placeholder:p,onInputChange:u,onChange:h}=H,d=M(H,["name","defaultValue","rules","shouldUnregister","label","required","noOptionsText","placeholder","onInputChange","onChange"]);let F=l3();if(!F)throw new Error("Para usar o <Autocomplete /> \xE9 necess\xE1rio que ele esteja dentro de um <Form />");let L=E(F.formState.errors,c);return console.warn=()=>{},_(e3,{name:c,control:F.control,defaultValue:e,rules:i,shouldUnregister:r,render:({field:x})=>D1(n1,{display:"flex",flexDirection:"column",children:[o&&_(g,{label:o,required:s}),_(i3,n(a({onChange:(m,Z)=>{x.onChange(Z),h==null||h(Z,F.watch())},onInputChange:(m,Z,C)=>{C==="input"&&(x.onChange(Z),setTimeout(()=>{u==null||u(Z,F.watch())},0))},isOptionEqualToValue:(m,Z)=>m.value===Z.value,renderOption:(m,Z)=>n3("li",n(a({},m),{key:Z.key||Z.value,onClick:C=>{var v;(v=m.onClick)==null||v.call(m,C),x.onChange(Z)}}),D1(n1,{container:!0,direction:"column",children:[_(n1,{item:!0,children:Z.label}),Z.afterLabel&&_(n1,{item:!0,children:Z.afterLabel})]})),value:x.value||null,noOptionsText:t||"Nenhuma op\xE7\xE3o encontrada"},d),{renderInput:m=>{var Z,C,v;return _(a3,n(a(a({placeholder:p},m),d.textFieldProps),{error:!!L,InputProps:n(a(a({},m.InputProps),(Z=d.textFieldProps)==null?void 0:Z.InputProps),{inputRef:x.ref,inputProps:a(a({},m.inputProps),(v=(C=d.textFieldProps)==null?void 0:C.InputProps)==null?void 0:v.inputProps)})}))}}),c),_(P,{name:c})]})})},r3=c3(o3);export{r3 as Autocomplete,K0 as Checkbox,z0 as Creatable,D2 as DatePicker,j1 as Form,t1 as FormProvider,h2 as RadioButton,u2 as RadioGroup,A0 as Searchable,V0 as Select,x2 as Slider,a2 as Switch,s0 as TextField,J2 as TimePicker,s1 as useForm};
|