@s_mart/form 11.0.1 → 16.0.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.
Files changed (47) hide show
  1. package/dist/checkbox/checkbox.d.ts +3 -0
  2. package/dist/checkbox/checkbox.types.d.ts +28 -0
  3. package/dist/components/fieldError/fieldError.d.ts +4 -0
  4. package/dist/components/fieldError/fieldError.types.d.ts +6 -0
  5. package/dist/components/fieldError/index.d.ts +2 -0
  6. package/dist/components/fieldInfo/fieldInfo.d.ts +3 -0
  7. package/dist/components/fieldInfo/fieldInfo.types.d.ts +3 -0
  8. package/dist/components/fieldInfo/index.d.ts +2 -0
  9. package/dist/components/fieldLabel/fieldLabel.d.ts +3 -0
  10. package/dist/components/fieldLabel/fieldLabel.types.d.ts +5 -0
  11. package/dist/components/fieldLabel/index.d.ts +2 -0
  12. package/dist/creatableV2/creatableV2.d.ts +4 -0
  13. package/dist/creatableV2/creatableV2.styles.d.ts +1 -0
  14. package/dist/creatableV2/creatableV2.types.d.ts +71 -0
  15. package/dist/datePicker/datePicker.d.ts +3 -0
  16. package/dist/datePicker/datePicker.styles.d.ts +1 -0
  17. package/dist/datePicker/datePicker.types.d.ts +33 -0
  18. package/dist/form/form.d.ts +22 -0
  19. package/dist/form/form.types.d.ts +20 -0
  20. package/dist/form/formProvider.d.ts +4 -0
  21. package/dist/form/useForm.d.ts +6 -0
  22. package/dist/formComponentPrecisaDeControl.d.ts +3 -0
  23. package/dist/index.d.ts +32 -0
  24. package/dist/index.mjs +828 -15
  25. package/dist/index.mjs.map +1 -0
  26. package/dist/radio/radioButton/radioButton.d.ts +3 -0
  27. package/dist/radio/radioButton/radioButton.types.d.ts +19 -0
  28. package/dist/radio/radioGroup/radioGroup.d.ts +3 -0
  29. package/dist/radio/radioGroup/radioGroup.types.d.ts +44 -0
  30. package/dist/searchableV2/searchableV2.d.ts +3 -0
  31. package/dist/searchableV2/searchableV2.types.d.ts +51 -0
  32. package/dist/selectV2/selectV2.d.ts +4 -0
  33. package/dist/selectV2/selectV2.types.d.ts +68 -0
  34. package/dist/selectV2/selectV2RenderValue.d.ts +3 -0
  35. package/dist/slider/slider.d.ts +3 -0
  36. package/dist/slider/slider.types.d.ts +20 -0
  37. package/dist/switch/switch.d.ts +3 -0
  38. package/dist/switch/switch.types.d.ts +28 -0
  39. package/dist/textField/textField.d.ts +3 -0
  40. package/dist/textField/textField.types.d.ts +43 -0
  41. package/dist/timePicker/timePicker.d.ts +3 -0
  42. package/dist/timePicker/timePicker.styles.d.ts +1 -0
  43. package/dist/timePicker/timePicker.types.d.ts +33 -0
  44. package/dist/utils/erroFieldFormatado.d.ts +2 -0
  45. package/dist/utils/typedMemo.d.ts +1 -0
  46. package/package.json +48 -48
  47. package/dist/index.d.mts +0 -523
package/dist/index.mjs CHANGED
@@ -1,15 +1,102 @@
1
- import{useController as Ke,useFormContext as We}from"react-hook-form";import{Checkbox as Ye,FormControlLabel as Je}from"@mui/material";import{Indicator as $e}from"@s_mart/core";import{useFormState as ze}from"react-hook-form";var w=(e,o)=>o.replace(/[[\]]/g,"").split(".").reduce((r,i)=>r?.[i],e);import{jsx as He}from"react/jsx-runtime";var qe=({name:e,disableIcon:o,control:t})=>{let r=ze({control:t,name:e}),i=w(r?.errors,e);return i?He($e,{severity:"error",icon:o?!1:void 0,children:i?.message}):null},v=qe;import{Typography as ue}from"@mui/material";import{toRem as Ge}from"@s_mart/utils";import{jsx as fe,jsxs as Ue}from"react/jsx-runtime";var Ne=({label:e,required:o,regular:t})=>Ue("span",{style:{display:"flex",alignItems:"center",gap:Ge(2)},children:[fe(ue,{variant:"caption",style:{display:"flex",alignItems:"center"},sx:{fontWeight:t?400:700},children:e}),o&&fe(ue,{variant:"caption",color:"error",sx:{fontWeight:900},children:"*"})]}),x=Ne;var P=class extends Error{constructor(o){super(`O componente ${o} precisa de um control para funcionar. Passe o control como prop ou coloque o componente dentro de um <Form />`),this.name="FormComponentPrecisaDeControl"}};import{memo as _e}from"react";var R=_e;import{jsx as Z,jsxs as Ze}from"react/jsx-runtime";var Xe=({name:e,rules:o,defaultValue:t,shouldUnregister:r,control:i,label:F,labelPlacement:y,required:u,disableIconError:h,onChange:l,...V})=>{let s=We()?.control,d=i??s;if(!d)throw new P("Checkbox");let{field:a}=Ke({control:d,name:e,rules:o,defaultValue:t,shouldUnregister:r});return Ze("span",{children:[Z(Je,{control:Z(Ye,{checked:!!a.value,value:a.value??"",defaultValue:a.value,onChange:(n,I)=>{a.onChange(n,I),l?.(n,I)},...V},e),label:Z(x,{label:F,required:u,regular:!0}),labelPlacement:y||"end"}),Z(v,{name:e,disableIcon:h,control:d})]})},Qe=R(Xe);import{forwardRef as io,useCallback as Q,useState as ao}from"react";import{useController as so,useFormContext as po,useFormState as mo}from"react-hook-form";import uo from"lodash-es/isObject";import fo from"lodash-es/isEmpty";import co from"lodash-es/isEqual";import{Autocomplete as Fo,TextField as yo,Divider as ye,Button as xo,IconButton as xe}from"@mui/material";import{LIcon as re}from"@s_mart/core";import{linePlus as Pe,linePen as Po}from"@s_mart/solid-icons";import{toRem as he}from"@s_mart/utils";import{css as je,styled as eo}from"@mui/material";import{toRem as oo}from"@s_mart/utils";var ce=je`
1
+ import { FormProvider as e, useController as t, useForm as n, useFormContext as r, useFormState as i } from "react-hook-form";
2
+ import { Autocomplete as a, Button as o, Checkbox as s, Divider as c, FormControlLabel as l, Grid as u, IconButton as d, InputAdornment as f, MenuItem as p, Radio as m, RadioGroup as h, Select as g, Slider as _, Stack as v, Switch as y, TextField as b, Tooltip as x, Typography as S, css as C, styled as w } from "@mui/material";
3
+ import { IconButton as T, Indicator as E, LIcon as D } from "@s_mart/core";
4
+ import { Fragment as O, jsx as k, jsxs as A } from "react/jsx-runtime";
5
+ import { toRem as j } from "@s_mart/utils";
6
+ import { createElement as M, forwardRef as N, memo as P, useCallback as F, useEffect as I, useRef as L, useState as R } from "react";
7
+ import ee from "lodash-es/isObject";
8
+ import te from "lodash-es/isEmpty";
9
+ import ne from "lodash-es/isEqual";
10
+ import { colorPalette as z } from "@s_mart/tokens";
11
+ import { lineEye as re, lineEyeSlash as B, lineInfoCircle as V, linePen as ie, linePlus as ae } from "@s_mart/solid-icons";
12
+ import { composeValidators as H, date as U, time as W } from "@s_mart/rules";
13
+ import { DatePicker as oe } from "@mui/x-date-pickers";
14
+ import { AdapterDayjs as G } from "@mui/x-date-pickers/AdapterDayjs";
15
+ import { LocalizationProvider as K } from "@mui/x-date-pickers/LocalizationProvider";
16
+ import { ptBR as se } from "@mui/x-date-pickers/locales";
17
+ import "dayjs/locale/pt-br";
18
+ import { zodResolver as ce } from "@hookform/resolvers/zod";
19
+ import { lineTimes as le } from "@s_mart/regular-icons";
20
+ import * as q from "@s_mart/masks";
21
+ import { TimePicker as ue } from "@mui/x-date-pickers/TimePicker";
22
+ //#region src/utils/erroFieldFormatado.ts
23
+ var J = (e, t) => t.replace(/[[\]]/g, "").split(".").reduce((e, t) => e?.[t], e), Y = ({ name: e, disableIcon: t, control: n }) => {
24
+ let r = J(i({
25
+ control: n,
26
+ name: e
27
+ })?.errors, e);
28
+ return r ? /* @__PURE__ */ k(E, {
29
+ severity: "error",
30
+ icon: !t && void 0,
31
+ children: r?.message
32
+ }) : null;
33
+ }, X = ({ label: e, required: t, regular: n }) => /* @__PURE__ */ A("span", {
34
+ style: {
35
+ display: "flex",
36
+ alignItems: "center",
37
+ gap: j(2)
38
+ },
39
+ children: [/* @__PURE__ */ k(S, {
40
+ variant: "caption",
41
+ style: {
42
+ display: "flex",
43
+ alignItems: "center"
44
+ },
45
+ sx: { fontWeight: n ? 400 : 700 },
46
+ children: e
47
+ }), t && /* @__PURE__ */ k(S, {
48
+ variant: "caption",
49
+ color: "error",
50
+ sx: { fontWeight: 900 },
51
+ children: "*"
52
+ })]
53
+ }), Z = class extends Error {
54
+ constructor(e) {
55
+ super(`O componente ${e} precisa de um control para funcionar. Passe o control como prop ou coloque o componente dentro de um <Form />`), this.name = "FormComponentPrecisaDeControl";
56
+ }
57
+ }, Q = P, de = Q(({ name: e, rules: n, defaultValue: i, shouldUnregister: a, control: o, label: c, labelPlacement: u, required: d, disableIconError: f, onChange: p, ...m }) => {
58
+ let h = r()?.control, g = o ?? h;
59
+ if (!g) throw new Z("Checkbox");
60
+ let { field: _ } = t({
61
+ control: g,
62
+ name: e,
63
+ rules: n,
64
+ defaultValue: i,
65
+ shouldUnregister: a
66
+ });
67
+ return /* @__PURE__ */ A("span", { children: [/* @__PURE__ */ k(l, {
68
+ control: /* @__PURE__ */ k(s, {
69
+ checked: !!_.value,
70
+ value: _.value ?? "",
71
+ defaultValue: _.value,
72
+ onChange: (e, t) => {
73
+ _.onChange(e, t), p?.(e, t);
74
+ },
75
+ ...m
76
+ }, e),
77
+ label: /* @__PURE__ */ k(X, {
78
+ label: c,
79
+ required: d,
80
+ regular: !0
81
+ }),
82
+ labelPlacement: u || "end"
83
+ }), /* @__PURE__ */ k(Y, {
84
+ name: e,
85
+ disableIcon: f,
86
+ control: g
87
+ })] });
88
+ }), fe = C`
2
89
  display: flex;
3
90
  align-items: center;
4
91
  justify-content: center;
5
- `,Fe=eo("div")`
92
+ `, pe = w("div")`
6
93
  display: flex;
7
94
 
8
95
  div.endAdornments {
9
96
  position: absolute;
10
97
  right: 0;
11
98
 
12
- ${ce}
99
+ ${fe}
13
100
  }
14
101
 
15
102
  .MuiAutocomplete-endAdornment {
@@ -23,30 +110,756 @@ import{useController as Ke,useFormContext as We}from"react-hook-form";import{Che
23
110
 
24
111
  .creatable,
25
112
  .editable {
26
- ${ce}
113
+ ${fe}
27
114
 
28
115
  .divider {
29
116
  width: 1px;
30
- height: ${oo(20)};
31
- background-color: ${({theme:e})=>e.palette.grey[400]};
117
+ height: ${j(20)};
118
+ background-color: ${({ theme: e }) => e.palette.grey[400]};
32
119
  }
33
120
  }
34
- `;import{Tooltip as to}from"@mui/material";import{LIcon as ro}from"@s_mart/core";import{lineInfoCircle as lo}from"@s_mart/solid-icons";import{jsx as te}from"react/jsx-runtime";var no=({title:e})=>te(to,{title:e,placement:"top",children:te("div",{style:{width:"fit-content"},children:te(ro,{icon:lo,color:"#757575"})})}),K=no;import{Fragment as le,jsx as C,jsxs as A}from"react/jsx-runtime";import{createElement as go}from"react";function ho(e){let{name:o,rules:t,defaultValue:r,shouldUnregister:i,control:F,label:y,required:u,options:h,footer:l,showCreatableButton:V=!0,showEditableButton:s,onEditOption:d,onCreateOption:a,getOptionKey:n,getOptionLabel:I,getOptionAfterLabel:f,getInputValueLabel:k,multiple:T,info:_,noOptionsText:$="Nenhuma op\xE7\xE3o encontrada",onChange:z,onInputChange:D,placeholder:L,...S}=e,[N,m]=ao(""),c=po()?.control,p=F??c;if(!p)throw new P("CreatableV2");let b=mo({control:p,name:o}),B=w(b.errors,o),W=!V||S.disabled,{field:U}=so({name:o,control:p,rules:t,defaultValue:r,shouldUnregister:i}),Le=E=>{let g=0;return e.slotProps?.textField?.slotProps?.input||(g+=2.5),W||(g+=2.56,de(E)&&(g+=2.56)),!S.disableClearable&&!S.disabled&&(g+=1.3),`${g}rem`},de=E=>S.disabled?!1:s&&uo(E)&&!fo(E),we=()=>S.disabled?!1:V,me=Q(()=>{typeof a<"u"&&(a(N),m(""))},[N,a]),Re=Q(()=>{d?.(U.value)},[U.value,d]),Be=Q((E,g,Y)=>{Y==="input"&&(m(g),D?.(g))},[D]),Me=Q((E,g)=>{m(""),U.onChange(g),z?.(g)},[U.onChange,z]),De=Q(E=>{S?.onBlur?.(E),m("")},[S?.onBlur]),Ae=U.value?U.value:T?[]:null;return A("div",{style:{display:"flex",flexDirection:"column"},children:[A("div",{style:{display:"flex"},children:[y&&C(x,{label:y,required:u}),_&&C(K,{title:_})]}),C(Fe,{children:C(Fo,{fullWidth:!0,onChange:Me,onInputChange:Be,onBlur:De,slotProps:{...S.slotProps,listbox:{component:io(function(g,Y){return A(le,{children:[C("ul",{...g,ref:Y}),typeof l<"u"?A("div",{...g,children:[C("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:C(ye,{})}),l()]},"creatable-footer"):null]})})}},value:Ae,options:h,multiple:T,readOnly:S.disabled,noOptionsText:A(le,{children:[$,!W&&A(xo,{sx:{justifyContent:"flex-start",padding:`${he(6)} ${he(-16)}`,margin:0},fullWidth:!0,onClick:me,variant:"text",startIcon:C(re,{icon:Pe}),children:["Adicionar ",`"${N}"`]}),typeof l<"u"&&A(le,{children:[C("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:C(ye,{})}),l()]})]}),isOptionEqualToValue:(E,g)=>co(E,g),getOptionLabel:f&&k||I,getOptionKey:n,renderOption:typeof f=="function"?(E,g)=>{let Y=f(g),Oe=n(g);return go("li",{...E,key:Oe},A("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[C("span",{children:I(g)}),typeof Y=="string"?C("span",{children:Y}):Y]}))}:void 0,...S,sx:{"& div.MuiInputBase-root":{paddingRight:`${Le(U.value)} !important`},...S.sx},renderInput:E=>C(yo,{placeholder:L,...E,error:!!B,...e.slotProps?.textField,slotProps:{input:{...E.InputProps,...e.slotProps?.textField?.slotProps?.input,inputRef:U.ref,endAdornment:A("div",{className:"endAdornments",children:[E.InputProps.endAdornment,e.slotProps?.textField?.slotProps?.input?.endAdornment??null,de(U.value)?A("div",{className:"editable",children:[C("div",{className:"divider"}),C(xe,{size:"small",onClick:Re,sx:{mx:"3px"},tabIndex:-1,children:C(re,{icon:Po,size:"24px",removeMargin:!0})})]}):null,we()&&A("div",{className:"creatable",children:[C("div",{className:"divider"}),C(xe,{size:"small",onClick:me,sx:{mx:"3px"},tabIndex:-1,children:C(re,{icon:Pe,size:"24px",removeMargin:!0})})]})]})}}})},o)}),C(v,{name:o,control:p})]})}var bo=R(ho);import{Stack as Io}from"@mui/material";import{AdapterDayjs as To}from"@mui/x-date-pickers/AdapterDayjs";import{DatePicker as ko}from"@mui/x-date-pickers";import{LocalizationProvider as Eo}from"@mui/x-date-pickers/LocalizationProvider";import{ptBR as Lo}from"@mui/x-date-pickers/locales";import{composeValidators as wo,date as ge}from"@s_mart/rules";import{useController as Ro,useFormContext as Bo,useFormState as Mo}from"react-hook-form";import{IconButton as vo,styled as Co}from"@mui/material";import{toRem as q}from"@s_mart/utils";var Vo=e=>{switch(e){case"small":return q(16);case"large":return q(24);default:return q(20)}},So=e=>{switch(e){case"small":return`${q(2)} ${q(8)}`;case"large":return`${q(10)}`;default:return`${q(6)} ${q(8)}`}},be=Co(vo)`
121
+ `, $ = ({ title: e }) => /* @__PURE__ */ k(x, {
122
+ title: e,
123
+ placement: "top",
124
+ children: /* @__PURE__ */ k("div", {
125
+ style: { width: "fit-content" },
126
+ children: /* @__PURE__ */ k(D, {
127
+ icon: V,
128
+ color: "#757575"
129
+ })
130
+ })
131
+ });
132
+ //#endregion
133
+ //#region src/creatableV2/creatableV2.tsx
134
+ function me(e) {
135
+ let { name: n, rules: s, defaultValue: l, shouldUnregister: u, control: f, label: p, required: m, options: h, footer: g, showCreatableButton: _ = !0, showEditableButton: v, onEditOption: y, onCreateOption: x, getOptionKey: S, getOptionLabel: C, getOptionAfterLabel: w, getInputValueLabel: T, multiple: E, info: P, noOptionsText: I = "Nenhuma opção encontrada", onChange: L, onInputChange: z, placeholder: re, ...B } = e, [V, H] = R(""), U = r()?.control, W = f ?? U;
136
+ if (!W) throw new Z("CreatableV2");
137
+ let oe = J(i({
138
+ control: W,
139
+ name: n
140
+ }).errors, n), G = !_ || B.disabled, { field: K } = t({
141
+ name: n,
142
+ control: W,
143
+ rules: s,
144
+ defaultValue: l,
145
+ shouldUnregister: u
146
+ }), se = (t) => {
147
+ let n = 0;
148
+ return e.slotProps?.textField?.slotProps?.input || (n += 2.5), G || (n += 2.56, ce(t) && (n += 2.56)), !B.disableClearable && !B.disabled && (n += 1.3), `${n}rem`;
149
+ }, ce = (e) => !B.disabled && v && ee(e) && !te(e), le = () => !B.disabled && _, q = F(() => {
150
+ x !== void 0 && (x(V), H(""));
151
+ }, [V, x]), ue = F(() => {
152
+ y?.(K.value);
153
+ }, [K.value, y]), Q = F((e, t, n) => {
154
+ n === "input" && (H(t), z?.(t));
155
+ }, [z]), de = F((e, t) => {
156
+ H(""), K.onChange(t), L?.(t);
157
+ }, [K.onChange, L]), fe = F((e) => {
158
+ B?.onBlur?.(e), H("");
159
+ }, [B?.onBlur]), me = K.value ? K.value : E ? [] : null;
160
+ return /* @__PURE__ */ A("div", {
161
+ style: {
162
+ display: "flex",
163
+ flexDirection: "column"
164
+ },
165
+ children: [
166
+ /* @__PURE__ */ A("div", {
167
+ style: { display: "flex" },
168
+ children: [p && /* @__PURE__ */ k(X, {
169
+ label: p,
170
+ required: m
171
+ }), P && /* @__PURE__ */ k($, { title: P })]
172
+ }),
173
+ /* @__PURE__ */ k(pe, { children: /* @__PURE__ */ k(a, {
174
+ fullWidth: !0,
175
+ onChange: de,
176
+ onInputChange: Q,
177
+ onBlur: fe,
178
+ slotProps: {
179
+ ...B.slotProps,
180
+ listbox: { component: N(function(e, t) {
181
+ return /* @__PURE__ */ A(O, { children: [/* @__PURE__ */ k("ul", {
182
+ ...e,
183
+ ref: t
184
+ }), g === void 0 ? null : /* @__PURE__ */ A("div", {
185
+ ...e,
186
+ children: [/* @__PURE__ */ k("div", {
187
+ style: {
188
+ paddingTop: "0.5rem",
189
+ paddingBottom: "0.5rem"
190
+ },
191
+ children: /* @__PURE__ */ k(c, {})
192
+ }), g()]
193
+ }, "creatable-footer")] });
194
+ }) }
195
+ },
196
+ value: me,
197
+ options: h,
198
+ multiple: E,
199
+ readOnly: B.disabled,
200
+ noOptionsText: /* @__PURE__ */ A(O, { children: [
201
+ I,
202
+ !G && /* @__PURE__ */ A(o, {
203
+ sx: {
204
+ justifyContent: "flex-start",
205
+ padding: `${j(6)} ${j(-16)}`,
206
+ margin: 0
207
+ },
208
+ fullWidth: !0,
209
+ onClick: q,
210
+ variant: "text",
211
+ startIcon: /* @__PURE__ */ k(D, { icon: ae }),
212
+ children: ["Adicionar ", `"${V}"`]
213
+ }),
214
+ g !== void 0 && /* @__PURE__ */ A(O, { children: [/* @__PURE__ */ k("div", {
215
+ style: {
216
+ paddingTop: "0.5rem",
217
+ paddingBottom: "0.5rem"
218
+ },
219
+ children: /* @__PURE__ */ k(c, {})
220
+ }), g()] })
221
+ ] }),
222
+ isOptionEqualToValue: (e, t) => ne(e, t),
223
+ getOptionLabel: w && T || C,
224
+ getOptionKey: S,
225
+ renderOption: typeof w == "function" ? (e, t) => {
226
+ let n = w(t), r = S(t);
227
+ return /* @__PURE__ */ M("li", {
228
+ ...e,
229
+ key: r
230
+ }, /* @__PURE__ */ A("div", {
231
+ style: {
232
+ display: "flex",
233
+ flexDirection: "column",
234
+ flex: 1
235
+ },
236
+ children: [/* @__PURE__ */ k("span", { children: C(t) }), typeof n == "string" ? /* @__PURE__ */ k("span", { children: n }) : n]
237
+ }));
238
+ } : void 0,
239
+ ...B,
240
+ sx: {
241
+ "& div.MuiInputBase-root": { paddingRight: `${se(K.value)} !important` },
242
+ ...B.sx
243
+ },
244
+ renderInput: (t) => /* @__PURE__ */ k(b, {
245
+ placeholder: re,
246
+ ...t,
247
+ error: !!oe,
248
+ ...e.slotProps?.textField,
249
+ slotProps: {
250
+ ...t.slotProps,
251
+ input: {
252
+ ...t.slotProps.input,
253
+ ...e.slotProps?.textField?.slotProps?.input,
254
+ inputRef: K.ref,
255
+ endAdornment: /* @__PURE__ */ A("div", {
256
+ className: "endAdornments",
257
+ children: [
258
+ t.slotProps.input.endAdornment,
259
+ e.slotProps?.textField?.slotProps?.input?.endAdornment ?? null,
260
+ ce(K.value) ? /* @__PURE__ */ A("div", {
261
+ className: "editable",
262
+ children: [/* @__PURE__ */ k("div", { className: "divider" }), /* @__PURE__ */ k(d, {
263
+ size: "small",
264
+ onClick: ue,
265
+ sx: { mx: "3px" },
266
+ tabIndex: -1,
267
+ children: /* @__PURE__ */ k(D, {
268
+ icon: ie,
269
+ size: "24px",
270
+ removeMargin: !0
271
+ })
272
+ })]
273
+ }) : null,
274
+ le() && /* @__PURE__ */ A("div", {
275
+ className: "creatable",
276
+ children: [/* @__PURE__ */ k("div", { className: "divider" }), /* @__PURE__ */ k(d, {
277
+ size: "small",
278
+ onClick: q,
279
+ sx: { mx: "3px" },
280
+ tabIndex: -1,
281
+ children: /* @__PURE__ */ k(D, {
282
+ icon: ae,
283
+ size: "24px",
284
+ removeMargin: !0
285
+ })
286
+ })]
287
+ })
288
+ ]
289
+ })
290
+ }
291
+ }
292
+ })
293
+ }, n) }),
294
+ /* @__PURE__ */ k(Y, {
295
+ name: n,
296
+ control: W
297
+ })
298
+ ]
299
+ });
300
+ }
301
+ var he = Q(me), ge = (e) => {
302
+ switch (e) {
303
+ case "small": return j(16);
304
+ case "large": return j(24);
305
+ default: return j(20);
306
+ }
307
+ }, _e = (e) => {
308
+ switch (e) {
309
+ case "small": return `${j(2)} ${j(8)}`;
310
+ case "large": return `${j(10)}`;
311
+ default: return `${j(6)} ${j(8)}`;
312
+ }
313
+ }, ve = w(d)`
35
314
  margin: 0px;
36
315
 
37
- padding: ${({size:e})=>So(e)};
38
- border-radius: 0 ${q(4)} ${q(4)} 0;
316
+ padding: ${({ size: e }) => _e(e)};
317
+ border-radius: 0 ${j(4)} ${j(4)} 0;
39
318
 
40
319
  svg {
41
- width: ${({size:e})=>Vo(e)} !important;
320
+ width: ${({ size: e }) => ge(e)} !important;
42
321
  }
43
- `;import"dayjs/locale/pt-br";import{jsx as ne,jsxs as $o}from"react/jsx-runtime";import{createElement as Oo}from"react";var Do=({rules:e,name:o,defaultValue:t,shouldUnregister:r,control:i,label:F,required:y,disabled:u,disableIconError:h,...l})=>{let V=Bo()?.control,s=i??V;if(!s)throw new P("DatePicker");let d=Mo({control:s,name:o}),a=w(d.errors,o),n=l?.format||"DD/MM/YYYY",I=e?wo([ge(n),e]):ge(n),{field:f}=Ro({control:s,name:o,rules:I,defaultValue:t,shouldUnregister:r});return ne(Eo,{dateAdapter:To,localeText:Lo.components.MuiLocalizationProvider.defaultProps.localeText,children:$o(Io,{children:[F&&ne(x,{label:F,required:y}),Oo(ko,{...l,key:o,value:f.value??null,format:n,onChange:(k,T)=>{f.onChange(k,T),l?.onChange?.(k,T)},disabled:u,enableAccessibleFieldDOMStructure:!1,slots:{openPickerButton:be},slotProps:{...l?.slotProps,textField:{error:!!a,...l.slotProps?.textField,inputRef:f.ref}}}),ne(v,{name:o,disableIcon:h,control:s})]})})},Ao=R(Do);import{FormProvider as zo}from"react-hook-form";import{jsx as ve}from"react/jsx-runtime";function qo({children:e,style:o,onSubmit:t,...r}){return ve(zo,{...r,children:ve("form",{onSubmit:i=>{i.preventDefault(),i.stopPropagation(),t(i)},style:o,children:e})})}var ie=qo;import{useEffect as Ho}from"react";import{useForm as Go}from"react-hook-form";import{zodResolver as No}from"@hookform/resolvers/zod";var Uo=({disableDefaultValuesUpdate:e,onSubmit:o,...t})=>{let r=Go({...t,resolver:t.schema&&No(t.schema)});return Ho(()=>{e||r.reset(t.defaultValues)},[t.defaultValues,r.reset]),{...r,onSubmit:r.handleSubmit(i=>o(i,r))}},ae=Uo;import{jsx as Wo}from"react/jsx-runtime";function _o({children:e,style:o,...t}){let r=ae(t);return Wo(ie,{...r,style:o,children:typeof e=="function"?e(r):e})}var Ko=_o;import{RadioGroup as Yo,Stack as Jo}from"@mui/material";import{useController as Xo,useFormContext as Qo}from"react-hook-form";import{jsx as se,jsxs as et}from"react/jsx-runtime";var Zo=({name:e,rules:o,defaultValue:t,shouldUnregister:r,control:i,label:F,required:y,children:u,orientation:h="row",disableIconError:l,...V})=>{let s=Qo()?.control,d=i??s;if(!d)throw new P("RadioGroup");let{field:a}=Xo({control:d,name:e,rules:o,defaultValue:t,shouldUnregister:r});return et(Jo,{children:[F&&se(x,{label:F,required:y}),se(Yo,{value:a.value||"",name:e,...V,onChange:n=>{V?.onChange?.(n,n.target?.value),a.onChange(n)},style:{display:"flex",flexDirection:h},children:u},e),se(v,{name:e,disableIcon:l,control:d})]})},jo=Zo;import{FormControlLabel as ot,Grid as tt,Radio as rt}from"@mui/material";import{jsx as j}from"react/jsx-runtime";var lt=({label:e,labelPlacement:o,...t})=>j(tt,{sx:{display:"flex",flexDirection:"column"},children:j(ot,{control:j(rt,{...t}),label:j(x,{label:e}),labelPlacement:o||"end"})}),nt=lt;import{Autocomplete as it,Divider as Ce,TextField as at}from"@mui/material";import st from"lodash-es/isEqual";import{forwardRef as pt}from"react";import{useController as dt,useFormContext as mt,useFormState as ut}from"react-hook-form";import{Fragment as pe,jsx as M,jsxs as J}from"react/jsx-runtime";import{createElement as Ft}from"react";var ft=e=>{let{name:o,rules:t,defaultValue:r,shouldUnregister:i,control:F,label:y,required:u,options:h,textFieldProps:l,noOptionsText:V,footer:s,multiple:d,info:a,placeholder:n,onChange:I,onInputChange:f,getOptionAfterLabel:k,getOptionLabel:T,getInputValueLabel:_,getOptionKey:$,...z}=e,D=mt()?.control,L=F??D;if(!L)throw new P("SearchableV2");let S=ut({control:L,name:o}),N=w(S.errors,o),{field:m}=dt({name:o,control:L,rules:t,defaultValue:r,shouldUnregister:i}),c=m.value?m.value:d?[]:null;return J("div",{style:{display:"flex",flexDirection:"column"},children:[J("div",{style:{display:"flex"},children:[y&&M(x,{label:y,required:u}),a&&M(K,{title:a})]}),M(it,{onChange:(p,b)=>{m.onChange(b),I?.(b)},onInputChange:(p,b,B)=>{B==="input"&&f?.(b)},value:c,options:h,multiple:d,readOnly:z.disabled,slotProps:{...z.slotProps,listbox:{component:pt(function(b,B){return J(pe,{children:[M("ul",{...b,ref:B}),typeof s<"u"?J("div",{...b,children:[M("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:M(Ce,{})}),s()]},"searchable-footer"):null]})})}},noOptionsText:J(pe,{children:[V||"Nenhuma op\xE7\xE3o encontrada",typeof s<"u"?J(pe,{children:[M("div",{style:{paddingTop:"0.5rem",paddingBottom:"0.5rem"},children:M(Ce,{})}),s()]}):null]}),isOptionEqualToValue:(p,b)=>st(p,b),getOptionLabel:k&&_||T,getOptionKey:$,renderOption:typeof k=="function"?(p,b)=>{let B=k(b),W=$(b);return Ft("li",{...p,key:W},J("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[M("span",{children:T(b)}),typeof B=="string"?M("span",{children:B}):B]}))}:void 0,...z,renderInput:p=>M(at,{error:!!N,placeholder:n,...p,...l,inputRef:m.ref})},o),M(v,{name:o,control:L})]})},ct=R(ft);import{useState as Pt}from"react";import{useController as ht,useFormContext as bt,useFormState as gt}from"react-hook-form";import{IconButton as vt,LIcon as Ct}from"@s_mart/core";import{lineTimes as Vt}from"@s_mart/regular-icons";import{colorPalette as St}from"@s_mart/tokens";import{Select as It,MenuItem as Tt,Divider as kt}from"@mui/material";import{colorPalette as yt}from"@s_mart/tokens";import{jsx as xt}from"react/jsx-runtime";var Ve=({value:e,placeholder:o,getOptionLabel:t})=>e===null||e?.length===0?xt("p",{style:{color:yt.neutral[100]},children:o}):t(e);import{Fragment as wt,jsx as O,jsxs as X}from"react/jsx-runtime";var Et=e=>{let{name:o,rules:t,defaultValue:r,shouldUnregister:i,control:F,label:y,required:u,options:h,placeholder:l,clearable:V,info:s,footer:d,onChange:a,variant:n="outlined",getOptionKey:I,getOptionLabel:f,getOptionAfterLabel:k,getInputValueLabel:T,getOptionIcon:_,...$}=e,z=bt()?.control,D=F??z,[L,S]=Pt(!1);if(!D)throw new P("SelectV2");let N=gt({control:D,name:o}),m=w(N.errors,o),{field:c}=ht({control:D,name:o,rules:t,defaultValue:r,shouldUnregister:i});return X("div",{style:{display:"flex",flexDirection:"column"},children:[X("div",{style:{display:"flex"},children:[y&&O(x,{label:y,required:u}),s&&O(K,{title:s})]}),X(It,{open:L,onOpen:()=>S(!0),onClose:()=>S(!1),displayEmpty:!!l,variant:n,autoComplete:"off",value:c.value||null,renderValue:p=>O(Ve,{getOptionLabel:k&&T||f,placeholder:l,value:p}),onChange:p=>{c.onChange(p.target.value),a?.(p.target.value)},error:!!m,size:$.size||"medium",inputRef:c.ref,...$,endAdornment:X(wt,{children:[$.endAdornment,!!(V&&c.value)&&O(vt,{variant:"text",color:"neutral",size:"small",sx:{borderRadius:"50%",position:"absolute",right:"2rem"},style:{padding:0},"aria-label":"Limpar",title:"Limpar",onClick:()=>{c.onChange(null),a?.(null)},children:O(Ct,{icon:Vt,color:St.neutral[100],size:"25px",removeMargin:!0})})]}),children:[h.map(p=>{let b=I(p),B=f(p),W=_?.(p);return O(Tt,{value:p,children:X("div",{style:{display:"flex",flexDirection:"column",flex:1},children:[W!==void 0?X("div",{style:{display:"flex",alignItems:"center"},children:[W,B]}):B,O("span",{children:k?.(p)??null})]})},b)}),d!==void 0&&X("div",{children:[O("div",{style:{padding:"8px 16px"},children:O(kt,{})},"footer-divider"),O("div",{children:d({closeSelect:()=>S(!1)})},"footer-content")]},"footer")]},o),O(v,{name:o,control:D})]})},Lt=R(Et);import{useController as Rt,useFormContext as Bt}from"react-hook-form";import{Slider as Mt}from"@mui/material";import{jsx as Ot}from"react/jsx-runtime";var Dt=({name:e,rules:o,defaultValue:t,shouldUnregister:r,control:i,...F})=>{let y=Bt()?.control,u=i??y;if(!u)throw new P("Slider");let{field:h}=Rt({control:u,name:e,rules:o,defaultValue:t,shouldUnregister:r});return Ot(Mt,{value:h.value||F?.min||0,onChange:h.onChange,valueLabelDisplay:"auto",...F},e)},At=Dt;import{FormControlLabel as $t,Stack as zt,Switch as qt}from"@mui/material";import{useController as Ht,useFormContext as Gt}from"react-hook-form";import{useCallback as Nt}from"react";import{jsx as ee,jsxs as Kt}from"react/jsx-runtime";var Ut=({name:e,rules:o,defaultValue:t,defaultChecked:r,shouldUnregister:i,control:F,label:y,labelPlacement:u="end",disableIconError:h,onChange:l,...V})=>{let s=Gt()?.control,d=F??s;if(!d)throw new P("Switch");let{field:a}=Ht({control:d,name:e,rules:o,defaultValue:r??t??!1,shouldUnregister:i}),n=Nt((I,f)=>{a.onChange(f),l?.(I,f)},[a,l]);return Kt(zt,{children:[ee($t,{control:ee(qt,{...V,...a,checked:!!a.value,onChange:n}),label:ee(x,{label:y}),labelPlacement:u}),ee(v,{name:e,disableIcon:h,control:d})]})},_t=Ut;import{InputAdornment as Wt,Stack as Yt,TextField as Jt,Tooltip as Xt}from"@mui/material";import{LIcon as Se}from"@s_mart/core";import*as Ie from"@s_mart/masks";import{lineEye as Qt,lineEyeSlash as Zt,lineInfoCircle as jt}from"@s_mart/solid-icons";import{useRef as er,useState as or}from"react";import{useController as tr,useFormContext as rr,useFormState as lr}from"react-hook-form";import{jsx as H,jsxs as Te}from"react/jsx-runtime";var nr=({name:e,rules:o,defaultValue:t,shouldUnregister:r,control:i,label:F,required:y,mask:u,variant:h="outlined",info:l,parse:V,format:s,onInputChange:d,disableIconError:a,...n})=>{let I=rr()?.control,f=i??I,k=er(t||void 0);if(!f)throw new P("TextField");let[T,_]=or(!1),$=m=>{let c=m;return c=s?.(m)??m,u?Ie?.[u]?.format(c):c},z=m=>{let c=m;return c=V?.(m)??c,u?Ie?.[u]?.parse(c,k.current):c},D=m=>{if(!m||u!=="porcentagem"&&u!=="porcentagem0")return;m?.stopPropagation();let c=(m?.target).value;if(c){let p=String(c);if(p.length>0){let b=p.indexOf("%");b>-1&&(m.currentTarget.selectionEnd=b)}}},{field:L}=tr({control:f,name:e,rules:o,defaultValue:t,shouldUnregister:r}),S=lr({control:f,name:e}),N=w(S.errors,e);return Te(Yt,{children:[Te("div",{style:{display:"flex"},children:[F&&H("div",{children:H(x,{label:F,required:y})}),l&&H("div",{children:H(Xt,{title:l,placement:"top",children:H("div",{style:{width:"fit-content"},children:H(Se,{icon:jt,color:"#757575"})})})})]}),H(Jt,{variant:h,defaultValue:t,value:$(L.value||(L.value!=0?"":L.value)),onChange:m=>{let c=z(m?.target?.value);L.onChange(c),d?.(c),k.current=m.target.value},error:!!N,...n,type:n.type==="password"?T?"text":"password":n.type,autoComplete:n.autoComplete||"off",slotProps:{...n.slotProps,input:{onKeyDown:D,inputRef:L.ref,endAdornment:n.type==="password"&&H(Wt,{position:"start",onClick:()=>_(!T),style:{cursor:"pointer"},children:H(Se,{icon:T?Qt:Zt,size:"24px",removeMargin:!0})}),...n.slotProps?.input}}},e),H(v,{name:e,disableIcon:a,control:f})]})},ir=R(nr);import{Stack as mr}from"@mui/material";import{AdapterDayjs as ur}from"@mui/x-date-pickers/AdapterDayjs";import{LocalizationProvider as fr}from"@mui/x-date-pickers/LocalizationProvider";import{TimePicker as cr}from"@mui/x-date-pickers/TimePicker";import{composeValidators as Fr,time as Ee}from"@s_mart/rules";import{useController as yr,useFormContext as xr,useFormState as Pr}from"react-hook-form";import{styled as ar}from"@mui/material";import{IconButton as sr}from"@mui/material";import{toRem as G}from"@s_mart/utils";var pr=e=>{switch(e){case"small":return G(16);case"large":return G(24);default:return G(20)}},dr=e=>{switch(e){case"small":return`${G(2)} ${G(8)}`;case"large":return G(10);default:return`${G(6)} ${G(8)}`}},ke=ar(sr)`
322
+ `, ye = Q(({ rules: e, name: n, defaultValue: a, shouldUnregister: o, control: s, label: c, required: l, disabled: u, disableIconError: d, size: f, ...p }) => {
323
+ let m = r()?.control, h = s ?? m;
324
+ if (!h) throw new Z("DatePicker");
325
+ let g = J(i({
326
+ control: h,
327
+ name: n
328
+ }).errors, n), _ = p?.format || "DD/MM/YYYY", y = e ? H([U(_), e]) : U(_), { field: b } = t({
329
+ control: h,
330
+ name: n,
331
+ rules: y,
332
+ defaultValue: a,
333
+ shouldUnregister: o
334
+ });
335
+ return /* @__PURE__ */ k(K, {
336
+ dateAdapter: G,
337
+ localeText: se.components.MuiLocalizationProvider.defaultProps.localeText,
338
+ children: /* @__PURE__ */ A(v, { children: [
339
+ c && /* @__PURE__ */ k(X, {
340
+ label: c,
341
+ required: l
342
+ }),
343
+ /* @__PURE__ */ M(oe, {
344
+ ...p,
345
+ key: n,
346
+ value: b.value ?? null,
347
+ format: _,
348
+ onChange: (e, t) => {
349
+ b.onChange(e, t), p?.onChange?.(e, t);
350
+ },
351
+ disabled: u,
352
+ slots: { openPickerButton: ve },
353
+ slotProps: {
354
+ ...p?.slotProps,
355
+ textField: {
356
+ error: !!g,
357
+ size: f,
358
+ ...p.slotProps?.textField,
359
+ slotProps: {
360
+ ...p.slotProps?.textField?.slotProps,
361
+ input: {
362
+ ...(p.slotProps?.textField)?.slotProps?.input,
363
+ inputRef: b.ref
364
+ }
365
+ }
366
+ }
367
+ }
368
+ }),
369
+ /* @__PURE__ */ k(Y, {
370
+ name: n,
371
+ disableIcon: d,
372
+ control: h
373
+ })
374
+ ] })
375
+ });
376
+ });
377
+ //#endregion
378
+ //#region src/form/formProvider.tsx
379
+ function be({ children: t, style: n, onSubmit: r, ...i }) {
380
+ return /* @__PURE__ */ k(e, {
381
+ ...i,
382
+ children: /* @__PURE__ */ k("form", {
383
+ onSubmit: (e) => {
384
+ e.preventDefault(), e.stopPropagation(), r(e);
385
+ },
386
+ style: n,
387
+ children: t
388
+ })
389
+ });
390
+ }
391
+ //#endregion
392
+ //#region src/form/useForm.ts
393
+ var xe = ({ disableDefaultValuesUpdate: e, onSubmit: t, ...r }) => {
394
+ let i = n({
395
+ ...r,
396
+ resolver: r.schema && ce(r.schema)
397
+ });
398
+ return I(() => {
399
+ e || i.reset(r.defaultValues);
400
+ }, [r.defaultValues, i.reset]), {
401
+ ...i,
402
+ onSubmit: i.handleSubmit((e) => t(e, i))
403
+ };
404
+ };
405
+ //#endregion
406
+ //#region src/form/form.tsx
407
+ function Se({ children: e, style: t, ...n }) {
408
+ let r = xe(n);
409
+ return /* @__PURE__ */ k(be, {
410
+ ...r,
411
+ style: t,
412
+ children: typeof e == "function" ? e(r) : e
413
+ });
414
+ }
415
+ //#endregion
416
+ //#region src/radio/radioGroup/radioGroup.tsx
417
+ var Ce = ({ name: e, rules: n, defaultValue: i, shouldUnregister: a, control: o, label: s, required: c, children: l, orientation: u = "row", disableIconError: d, ...f }) => {
418
+ let p = r()?.control, m = o ?? p;
419
+ if (!m) throw new Z("RadioGroup");
420
+ let { field: g } = t({
421
+ control: m,
422
+ name: e,
423
+ rules: n,
424
+ defaultValue: i,
425
+ shouldUnregister: a
426
+ });
427
+ return /* @__PURE__ */ A(v, { children: [
428
+ s && /* @__PURE__ */ k(X, {
429
+ label: s,
430
+ required: c
431
+ }),
432
+ /* @__PURE__ */ k(h, {
433
+ value: g.value || "",
434
+ name: e,
435
+ ...f,
436
+ onChange: (e) => {
437
+ f?.onChange?.(e, e.target?.value), g.onChange(e);
438
+ },
439
+ style: {
440
+ display: "flex",
441
+ flexDirection: u
442
+ },
443
+ children: l
444
+ }, e),
445
+ /* @__PURE__ */ k(Y, {
446
+ name: e,
447
+ disableIcon: d,
448
+ control: m
449
+ })
450
+ ] });
451
+ }, we = ({ label: e, labelPlacement: t, ...n }) => /* @__PURE__ */ k(u, {
452
+ sx: {
453
+ display: "flex",
454
+ flexDirection: "column"
455
+ },
456
+ children: /* @__PURE__ */ k(l, {
457
+ control: /* @__PURE__ */ k(m, { ...n }),
458
+ label: /* @__PURE__ */ k(X, { label: e }),
459
+ labelPlacement: t || "end"
460
+ })
461
+ }), Te = Q((e) => {
462
+ let { name: n, rules: o, defaultValue: s, shouldUnregister: l, control: u, label: d, required: f, options: p, textFieldProps: m, noOptionsText: h, footer: g, multiple: _, info: v, placeholder: y, onChange: x, onInputChange: S, getOptionAfterLabel: C, getOptionLabel: w, getInputValueLabel: T, getOptionKey: E, ...D } = e, j = r()?.control, P = u ?? j;
463
+ if (!P) throw new Z("SearchableV2");
464
+ let F = J(i({
465
+ control: P,
466
+ name: n
467
+ }).errors, n), { field: I } = t({
468
+ name: n,
469
+ control: P,
470
+ rules: o,
471
+ defaultValue: s,
472
+ shouldUnregister: l
473
+ }), L = I.value ? I.value : _ ? [] : null;
474
+ return /* @__PURE__ */ A("div", {
475
+ style: {
476
+ display: "flex",
477
+ flexDirection: "column"
478
+ },
479
+ children: [
480
+ /* @__PURE__ */ A("div", {
481
+ style: { display: "flex" },
482
+ children: [d && /* @__PURE__ */ k(X, {
483
+ label: d,
484
+ required: f
485
+ }), v && /* @__PURE__ */ k($, { title: v })]
486
+ }),
487
+ /* @__PURE__ */ k(a, {
488
+ onChange: (e, t) => {
489
+ I.onChange(t), x?.(t);
490
+ },
491
+ onInputChange: (e, t, n) => {
492
+ n === "input" && S?.(t);
493
+ },
494
+ value: L,
495
+ options: p,
496
+ multiple: _,
497
+ readOnly: D.disabled,
498
+ slotProps: {
499
+ ...D.slotProps,
500
+ listbox: { component: N(function(e, t) {
501
+ return /* @__PURE__ */ A(O, { children: [/* @__PURE__ */ k("ul", {
502
+ ...e,
503
+ ref: t
504
+ }), g === void 0 ? null : /* @__PURE__ */ A("div", {
505
+ ...e,
506
+ children: [/* @__PURE__ */ k("div", {
507
+ style: {
508
+ paddingTop: "0.5rem",
509
+ paddingBottom: "0.5rem"
510
+ },
511
+ children: /* @__PURE__ */ k(c, {})
512
+ }), g()]
513
+ }, "searchable-footer")] });
514
+ }) }
515
+ },
516
+ noOptionsText: /* @__PURE__ */ A(O, { children: [h || "Nenhuma opção encontrada", g === void 0 ? null : /* @__PURE__ */ A(O, { children: [/* @__PURE__ */ k("div", {
517
+ style: {
518
+ paddingTop: "0.5rem",
519
+ paddingBottom: "0.5rem"
520
+ },
521
+ children: /* @__PURE__ */ k(c, {})
522
+ }), g()] })] }),
523
+ isOptionEqualToValue: (e, t) => ne(e, t),
524
+ getOptionLabel: C && T || w,
525
+ getOptionKey: E,
526
+ renderOption: typeof C == "function" ? (e, t) => {
527
+ let n = C(t), r = E(t);
528
+ return /* @__PURE__ */ M("li", {
529
+ ...e,
530
+ key: r
531
+ }, /* @__PURE__ */ A("div", {
532
+ style: {
533
+ display: "flex",
534
+ flexDirection: "column",
535
+ flex: 1
536
+ },
537
+ children: [/* @__PURE__ */ k("span", { children: w(t) }), typeof n == "string" ? /* @__PURE__ */ k("span", { children: n }) : n]
538
+ }));
539
+ } : void 0,
540
+ ...D,
541
+ renderInput: (e) => /* @__PURE__ */ k(b, {
542
+ error: !!F,
543
+ placeholder: y,
544
+ ...e,
545
+ ...m,
546
+ inputRef: I.ref
547
+ })
548
+ }, n),
549
+ /* @__PURE__ */ k(Y, {
550
+ name: n,
551
+ control: P
552
+ })
553
+ ]
554
+ });
555
+ }), Ee = ({ value: e, placeholder: t, getOptionLabel: n }) => e === null || e?.length === 0 ? /* @__PURE__ */ k("p", {
556
+ style: { color: z.neutral[100] },
557
+ children: t
558
+ }) : n(e), De = Q((e) => {
559
+ let { name: n, rules: a, defaultValue: o, shouldUnregister: s, control: l, label: u, required: d, options: f, placeholder: m, clearable: h, info: _, footer: v, onChange: y, variant: b = "outlined", getOptionKey: x, getOptionLabel: S, getOptionAfterLabel: C, getInputValueLabel: w, getOptionIcon: E, ...j } = e, M = r()?.control, N = l ?? M, [P, F] = R(!1);
560
+ if (!N) throw new Z("SelectV2");
561
+ let I = J(i({
562
+ control: N,
563
+ name: n
564
+ }).errors, n), { field: L } = t({
565
+ control: N,
566
+ name: n,
567
+ rules: a,
568
+ defaultValue: o,
569
+ shouldUnregister: s
570
+ });
571
+ return /* @__PURE__ */ A("div", {
572
+ style: {
573
+ display: "flex",
574
+ flexDirection: "column"
575
+ },
576
+ children: [
577
+ /* @__PURE__ */ A("div", {
578
+ style: { display: "flex" },
579
+ children: [u && /* @__PURE__ */ k(X, {
580
+ label: u,
581
+ required: d
582
+ }), _ && /* @__PURE__ */ k($, { title: _ })]
583
+ }),
584
+ /* @__PURE__ */ A(g, {
585
+ open: P,
586
+ onOpen: () => F(!0),
587
+ onClose: () => F(!1),
588
+ displayEmpty: !!m,
589
+ variant: b,
590
+ autoComplete: "off",
591
+ value: L.value || null,
592
+ renderValue: (e) => /* @__PURE__ */ k(Ee, {
593
+ getOptionLabel: C && w || S,
594
+ placeholder: m,
595
+ value: e
596
+ }),
597
+ onChange: (e) => {
598
+ L.onChange(e.target.value), y?.(e.target.value);
599
+ },
600
+ error: !!I,
601
+ size: j.size || "medium",
602
+ inputRef: L.ref,
603
+ ...j,
604
+ endAdornment: /* @__PURE__ */ A(O, { children: [j.endAdornment, !!(h && L.value) && /* @__PURE__ */ k(T, {
605
+ variant: "text",
606
+ color: "neutral",
607
+ size: "small",
608
+ sx: {
609
+ borderRadius: "50%",
610
+ position: "absolute",
611
+ right: "2rem"
612
+ },
613
+ style: { padding: 0 },
614
+ "aria-label": "Limpar",
615
+ title: "Limpar",
616
+ onClick: () => {
617
+ L.onChange(null), y?.(null);
618
+ },
619
+ children: /* @__PURE__ */ k(D, {
620
+ icon: le,
621
+ color: z.neutral[100],
622
+ size: "25px",
623
+ removeMargin: !0
624
+ })
625
+ })] }),
626
+ children: [f.map((e) => {
627
+ let t = x(e), n = S(e), r = E?.(e);
628
+ return /* @__PURE__ */ k(p, {
629
+ value: e,
630
+ children: /* @__PURE__ */ A("div", {
631
+ style: {
632
+ display: "flex",
633
+ flexDirection: "column",
634
+ flex: 1
635
+ },
636
+ children: [r === void 0 ? n : /* @__PURE__ */ A("div", {
637
+ style: {
638
+ display: "flex",
639
+ alignItems: "center"
640
+ },
641
+ children: [r, n]
642
+ }), /* @__PURE__ */ k("span", { children: C?.(e) ?? null })]
643
+ })
644
+ }, t);
645
+ }), v !== void 0 && /* @__PURE__ */ A("div", { children: [/* @__PURE__ */ k("div", {
646
+ style: { padding: "8px 16px" },
647
+ children: /* @__PURE__ */ k(c, {})
648
+ }, "footer-divider"), /* @__PURE__ */ k("div", { children: v({ closeSelect: () => F(!1) }) }, "footer-content")] }, "footer")]
649
+ }, n),
650
+ /* @__PURE__ */ k(Y, {
651
+ name: n,
652
+ control: N
653
+ })
654
+ ]
655
+ });
656
+ }), Oe = ({ name: e, rules: n, defaultValue: i, shouldUnregister: a, control: o, ...s }) => {
657
+ let c = r()?.control, l = o ?? c;
658
+ if (!l) throw new Z("Slider");
659
+ let { field: u } = t({
660
+ control: l,
661
+ name: e,
662
+ rules: n,
663
+ defaultValue: i,
664
+ shouldUnregister: a
665
+ });
666
+ return /* @__PURE__ */ k(_, {
667
+ value: u.value || s?.min || 0,
668
+ onChange: u.onChange,
669
+ valueLabelDisplay: "auto",
670
+ ...s
671
+ }, e);
672
+ }, ke = ({ name: e, rules: n, defaultValue: i, defaultChecked: a, shouldUnregister: o, control: s, label: c, labelPlacement: u = "end", disableIconError: d, onChange: f, ...p }) => {
673
+ let m = r()?.control, h = s ?? m;
674
+ if (!h) throw new Z("Switch");
675
+ let { field: g } = t({
676
+ control: h,
677
+ name: e,
678
+ rules: n,
679
+ defaultValue: a ?? i ?? !1,
680
+ shouldUnregister: o
681
+ }), _ = F((e, t) => {
682
+ g.onChange(t), f?.(e, t);
683
+ }, [g, f]);
684
+ return /* @__PURE__ */ A(v, { children: [/* @__PURE__ */ k(l, {
685
+ control: /* @__PURE__ */ k(y, {
686
+ ...p,
687
+ ...g,
688
+ checked: !!g.value,
689
+ onChange: _
690
+ }),
691
+ label: /* @__PURE__ */ k(X, { label: c }),
692
+ labelPlacement: u
693
+ }), /* @__PURE__ */ k(Y, {
694
+ name: e,
695
+ disableIcon: d,
696
+ control: h
697
+ })] });
698
+ }, Ae = Q(({ name: e, rules: n, defaultValue: a, shouldUnregister: o, control: s, label: c, required: l, mask: u, variant: d = "outlined", info: p, parse: m, format: h, onInputChange: g, disableIconError: _, ...y }) => {
699
+ let S = r()?.control, C = s ?? S, w = L(a || void 0);
700
+ if (!C) throw new Z("TextField");
701
+ let [T, E] = R(!1), O = (e) => {
702
+ let t = e;
703
+ return t = h?.(e) ?? e, u ? q?.[u]?.format(t) : t;
704
+ }, j = (e) => {
705
+ let t = e;
706
+ return t = m?.(e) ?? t, u ? q?.[u]?.parse(t, w.current) : t;
707
+ }, M = (e) => {
708
+ if (!e || u !== "porcentagem" && u !== "porcentagem0") return;
709
+ e?.stopPropagation();
710
+ let t = (e?.target).value;
711
+ if (t) {
712
+ let n = String(t);
713
+ if (n.length > 0) {
714
+ let t = n.indexOf("%");
715
+ t > -1 && (e.currentTarget.selectionEnd = t);
716
+ }
717
+ }
718
+ }, { field: N } = t({
719
+ control: C,
720
+ name: e,
721
+ rules: n,
722
+ defaultValue: a,
723
+ shouldUnregister: o
724
+ }), P = J(i({
725
+ control: C,
726
+ name: e
727
+ }).errors, e);
728
+ return /* @__PURE__ */ A(v, { children: [
729
+ /* @__PURE__ */ A("div", {
730
+ style: { display: "flex" },
731
+ children: [c && /* @__PURE__ */ k("div", { children: /* @__PURE__ */ k(X, {
732
+ label: c,
733
+ required: l
734
+ }) }), p && /* @__PURE__ */ k("div", { children: /* @__PURE__ */ k(x, {
735
+ title: p,
736
+ placement: "top",
737
+ children: /* @__PURE__ */ k("div", {
738
+ style: { width: "fit-content" },
739
+ children: /* @__PURE__ */ k(D, {
740
+ icon: V,
741
+ color: "#757575"
742
+ })
743
+ })
744
+ }) })]
745
+ }),
746
+ /* @__PURE__ */ k(b, {
747
+ variant: d,
748
+ defaultValue: a,
749
+ value: O(N.value || (N.value == 0 ? N.value : "")),
750
+ onChange: (e) => {
751
+ let t = j(e?.target?.value);
752
+ N.onChange(t), g?.(t), w.current = e.target.value;
753
+ },
754
+ error: !!P,
755
+ ...y,
756
+ type: y.type === "password" ? T ? "text" : "password" : y.type,
757
+ autoComplete: y.autoComplete || "off",
758
+ slotProps: {
759
+ ...y.slotProps,
760
+ input: {
761
+ onKeyDown: M,
762
+ inputRef: N.ref,
763
+ endAdornment: y.type === "password" && /* @__PURE__ */ k(f, {
764
+ position: "start",
765
+ onClick: () => E(!T),
766
+ style: { cursor: "pointer" },
767
+ children: /* @__PURE__ */ k(D, {
768
+ icon: T ? re : B,
769
+ size: "24px",
770
+ removeMargin: !0
771
+ })
772
+ }),
773
+ ...y.slotProps?.input
774
+ }
775
+ }
776
+ }, e),
777
+ /* @__PURE__ */ k(Y, {
778
+ name: e,
779
+ disableIcon: _,
780
+ control: C
781
+ })
782
+ ] });
783
+ }), je = (e) => {
784
+ switch (e) {
785
+ case "small": return j(16);
786
+ case "large": return j(24);
787
+ default: return j(20);
788
+ }
789
+ }, Me = (e) => {
790
+ switch (e) {
791
+ case "small": return `${j(2)} ${j(8)}`;
792
+ case "large": return j(10);
793
+ default: return `${j(6)} ${j(8)}`;
794
+ }
795
+ }, Ne = w(d)`
44
796
  margin: 0px;
45
797
 
46
- padding: ${({size:e})=>dr(e)};
47
- border-radius: 0 ${G(4)} ${G(4)} 0;
798
+ padding: ${({ size: e }) => Me(e)};
799
+ border-radius: 0 ${j(4)} ${j(4)} 0;
48
800
 
49
801
  svg {
50
- width: ${({size:e})=>pr(e)} !important;
802
+ width: ${({ size: e }) => je(e)} !important;
51
803
  }
52
- `;import"dayjs/locale/pt-br";import{jsx as oe,jsxs as gr}from"react/jsx-runtime";var hr=({rules:e,defaultValue:o,shouldUnregister:t,name:r,control:i,required:F,label:y,disabled:u,disableIconError:h,...l})=>{let V=xr()?.control,s=i??V;if(!s)throw new P("TimePicker");let d=Pr({control:s,name:r}),a=w(d.errors,r),n=l.format||"HH:mm",I=e?Fr([Ee(n),e]):Ee(n),{field:f}=yr({control:s,name:r,rules:I,defaultValue:o,shouldUnregister:t});return oe(fr,{dateAdapter:ur,children:gr(mr,{children:[y&&oe(x,{label:y,required:F}),oe(cr,{ampm:!1,format:n,value:f.value??null,disabled:u,...l,enableAccessibleFieldDOMStructure:!1,onChange:(k,T)=>{f.onChange(k,T),l?.onChange?.(k,T)},slots:{openPickerButton:ke},slotProps:{...l.slotProps,textField:{error:!!a,...l.slotProps?.textField,inputRef:f.ref},actionBar:{actions:[],...l.slotProps?.actionBar}}},r),oe(v,{name:r,disableIcon:h,control:s})]})})},br=R(hr);export{Qe as Checkbox,bo as CreatableV2,Ao as DatePicker,v as FieldError,K as FieldInfo,x as FieldLabel,Ko as Form,ie as FormProvider,nt as RadioButton,jo as RadioGroup,ct as SearchableV2,Lt as SelectV2,At as Slider,_t as Switch,ir as TextField,br as TimePicker,ae as useForm};
804
+ `, Pe = Q(({ rules: e, defaultValue: n, shouldUnregister: a, name: o, control: s, required: c, label: l, disabled: u, disableIconError: d, size: f, ...p }) => {
805
+ let m = r()?.control, h = s ?? m;
806
+ if (!h) throw new Z("TimePicker");
807
+ let g = J(i({
808
+ control: h,
809
+ name: o
810
+ }).errors, o), _ = p.format || "HH:mm", y = e ? H([W(_), e]) : W(_), { field: b } = t({
811
+ control: h,
812
+ name: o,
813
+ rules: y,
814
+ defaultValue: n,
815
+ shouldUnregister: a
816
+ });
817
+ return /* @__PURE__ */ k(K, {
818
+ dateAdapter: G,
819
+ children: /* @__PURE__ */ A(v, { children: [
820
+ l && /* @__PURE__ */ k(X, {
821
+ label: l,
822
+ required: c
823
+ }),
824
+ /* @__PURE__ */ k(ue, {
825
+ ampm: !1,
826
+ format: _,
827
+ value: b.value ?? null,
828
+ disabled: u,
829
+ ...p,
830
+ onChange: (e, t) => {
831
+ b.onChange(e, t), p?.onChange?.(e, t);
832
+ },
833
+ slots: { openPickerButton: Ne },
834
+ slotProps: {
835
+ ...p.slotProps,
836
+ textField: {
837
+ error: !!g,
838
+ size: f,
839
+ ...p.slotProps?.textField,
840
+ slotProps: {
841
+ ...p.slotProps?.textField?.slotProps,
842
+ input: {
843
+ ...(p.slotProps?.textField)?.slotProps?.input,
844
+ inputRef: b.ref
845
+ }
846
+ }
847
+ },
848
+ actionBar: {
849
+ actions: [],
850
+ ...p.slotProps?.actionBar
851
+ }
852
+ }
853
+ }, o),
854
+ /* @__PURE__ */ k(Y, {
855
+ name: o,
856
+ disableIcon: d,
857
+ control: h
858
+ })
859
+ ] })
860
+ });
861
+ });
862
+ //#endregion
863
+ export { de as Checkbox, he as CreatableV2, ye as DatePicker, Y as FieldError, $ as FieldInfo, X as FieldLabel, Se as Form, be as FormProvider, we as RadioButton, Ce as RadioGroup, Te as SearchableV2, De as SelectV2, Oe as Slider, ke as Switch, Ae as TextField, Pe as TimePicker, xe as useForm };
864
+
865
+ //# sourceMappingURL=index.mjs.map