@s_mart/form 11.0.2 → 16.1.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/checkbox/checkbox.d.ts +3 -0
- package/dist/checkbox/checkbox.types.d.ts +28 -0
- package/dist/components/fieldError/fieldError.d.ts +4 -0
- package/dist/components/fieldError/fieldError.types.d.ts +6 -0
- package/dist/components/fieldError/index.d.ts +2 -0
- package/dist/components/fieldInfo/fieldInfo.d.ts +3 -0
- package/dist/components/fieldInfo/fieldInfo.types.d.ts +3 -0
- package/dist/components/fieldInfo/index.d.ts +2 -0
- package/dist/components/fieldLabel/fieldLabel.d.ts +3 -0
- package/dist/components/fieldLabel/fieldLabel.types.d.ts +5 -0
- package/dist/components/fieldLabel/index.d.ts +2 -0
- package/dist/creatable/creatable.d.ts +4 -0
- package/dist/creatable/creatable.styles.d.ts +1 -0
- package/dist/creatable/creatable.types.d.ts +71 -0
- package/dist/datePicker/datePicker.d.ts +3 -0
- package/dist/datePicker/datePicker.styles.d.ts +1 -0
- package/dist/datePicker/datePicker.types.d.ts +33 -0
- package/dist/form/form.d.ts +22 -0
- package/dist/form/form.types.d.ts +20 -0
- package/dist/form/formProvider.d.ts +4 -0
- package/dist/form/useForm.d.ts +6 -0
- package/dist/formComponentPrecisaDeControl.d.ts +3 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.mjs +828 -15
- package/dist/index.mjs.map +1 -0
- package/dist/radio/radioButton/radioButton.d.ts +3 -0
- package/dist/radio/radioButton/radioButton.types.d.ts +19 -0
- package/dist/radio/radioGroup/radioGroup.d.ts +3 -0
- package/dist/radio/radioGroup/radioGroup.types.d.ts +44 -0
- package/dist/searchable/searchable.d.ts +3 -0
- package/dist/searchable/searchable.types.d.ts +51 -0
- package/dist/select/select.d.ts +4 -0
- package/dist/select/select.types.d.ts +68 -0
- package/dist/select/selectRenderValue.d.ts +3 -0
- package/dist/slider/slider.d.ts +3 -0
- package/dist/slider/slider.types.d.ts +20 -0
- package/dist/switch/switch.d.ts +3 -0
- package/dist/switch/switch.types.d.ts +28 -0
- package/dist/textField/textField.d.ts +3 -0
- package/dist/textField/textField.types.d.ts +43 -0
- package/dist/timePicker/timePicker.d.ts +3 -0
- package/dist/timePicker/timePicker.styles.d.ts +1 -0
- package/dist/timePicker/timePicker.types.d.ts +33 -0
- package/dist/utils/erroFieldFormatado.d.ts +2 -0
- package/dist/utils/typedMemo.d.ts +1 -0
- package/package.json +48 -48
- package/dist/index.d.mts +0 -523
package/dist/index.mjs
CHANGED
|
@@ -1,15 +1,112 @@
|
|
|
1
|
-
import
|
|
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 ee } from "react";
|
|
7
|
+
import { lineEye as R, lineEyeSlash as te, lineInfoCircle as z, linePen as ne, linePlus as re } from "@s_mart/solid-icons";
|
|
8
|
+
import { colorPalette as B } from "@s_mart/tokens";
|
|
9
|
+
import ie from "lodash-es/isEmpty";
|
|
10
|
+
import ae from "lodash-es/isEqual";
|
|
11
|
+
import oe from "lodash-es/isObject";
|
|
12
|
+
import { composeValidators as V, date as H, time as U } from "@s_mart/rules";
|
|
13
|
+
import { DatePicker as se } from "@mui/x-date-pickers";
|
|
14
|
+
import { AdapterDayjs as W } from "@mui/x-date-pickers/AdapterDayjs";
|
|
15
|
+
import { LocalizationProvider as G } from "@mui/x-date-pickers/LocalizationProvider";
|
|
16
|
+
import { ptBR as ce } from "@mui/x-date-pickers/locales";
|
|
17
|
+
import "dayjs/locale/pt-br";
|
|
18
|
+
import { zodResolver as K } 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
|
+
}), $ = ({ title: e }) => /* @__PURE__ */ k(x, {
|
|
89
|
+
title: e,
|
|
90
|
+
placement: "top",
|
|
91
|
+
children: /* @__PURE__ */ k("div", {
|
|
92
|
+
style: { width: "fit-content" },
|
|
93
|
+
children: /* @__PURE__ */ k(D, {
|
|
94
|
+
icon: z,
|
|
95
|
+
color: "#757575"
|
|
96
|
+
})
|
|
97
|
+
})
|
|
98
|
+
}), fe = C`
|
|
2
99
|
display: flex;
|
|
3
100
|
align-items: center;
|
|
4
101
|
justify-content: center;
|
|
5
|
-
`,
|
|
102
|
+
`, pe = w("div")`
|
|
6
103
|
display: flex;
|
|
7
104
|
|
|
8
105
|
div.endAdornments {
|
|
9
106
|
position: absolute;
|
|
10
107
|
right: 0;
|
|
11
108
|
|
|
12
|
-
${
|
|
109
|
+
${fe}
|
|
13
110
|
}
|
|
14
111
|
|
|
15
112
|
.MuiAutocomplete-endAdornment {
|
|
@@ -23,30 +120,746 @@ import{useController as Ke,useFormContext as We}from"react-hook-form";import{Che
|
|
|
23
120
|
|
|
24
121
|
.creatable,
|
|
25
122
|
.editable {
|
|
26
|
-
${
|
|
123
|
+
${fe}
|
|
27
124
|
|
|
28
125
|
.divider {
|
|
29
126
|
width: 1px;
|
|
30
|
-
height: ${
|
|
31
|
-
background-color: ${({theme:e})=>e.palette.grey[400]};
|
|
127
|
+
height: ${j(20)};
|
|
128
|
+
background-color: ${({ theme: e }) => e.palette.grey[400]};
|
|
32
129
|
}
|
|
33
130
|
}
|
|
34
|
-
`;
|
|
131
|
+
`;
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region src/creatable/creatable.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: R, placeholder: te, ...z } = e, [B, V] = ee(""), H = r()?.control, U = f ?? H;
|
|
136
|
+
if (!U) throw new Z("Creatable");
|
|
137
|
+
let se = J(i({
|
|
138
|
+
control: U,
|
|
139
|
+
name: n
|
|
140
|
+
}).errors, n), W = !_ || z.disabled, { field: G } = t({
|
|
141
|
+
name: n,
|
|
142
|
+
control: U,
|
|
143
|
+
rules: s,
|
|
144
|
+
defaultValue: l,
|
|
145
|
+
shouldUnregister: u
|
|
146
|
+
}), ce = (t) => {
|
|
147
|
+
let n = 0;
|
|
148
|
+
return e.slotProps?.textField?.slotProps?.input || (n += 2.5), W || (n += 2.56, K(t) && (n += 2.56)), !z.disableClearable && !z.disabled && (n += 1.3), `${n}rem`;
|
|
149
|
+
}, K = (e) => !z.disabled && v && oe(e) && !ie(e), le = () => !z.disabled && _, q = F(() => {
|
|
150
|
+
x !== void 0 && (x(B), V(""));
|
|
151
|
+
}, [B, x]), ue = F(() => {
|
|
152
|
+
y?.(G.value);
|
|
153
|
+
}, [G.value, y]), Q = F((e, t, n) => {
|
|
154
|
+
n === "input" && (V(t), R?.(t));
|
|
155
|
+
}, [R]), de = F((e, t) => {
|
|
156
|
+
V(""), G.onChange(t), L?.(t);
|
|
157
|
+
}, [G.onChange, L]), fe = F((e) => {
|
|
158
|
+
z?.onBlur?.(e), V("");
|
|
159
|
+
}, [z?.onBlur]), me = G.value ? G.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
|
+
...z.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: z.disabled,
|
|
200
|
+
noOptionsText: /* @__PURE__ */ A(O, { children: [
|
|
201
|
+
I,
|
|
202
|
+
!W && /* @__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: re }),
|
|
212
|
+
children: ["Adicionar ", `"${B}"`]
|
|
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) => ae(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
|
+
...z,
|
|
240
|
+
sx: {
|
|
241
|
+
"& div.MuiInputBase-root": { paddingRight: `${ce(G.value)} !important` },
|
|
242
|
+
...z.sx
|
|
243
|
+
},
|
|
244
|
+
renderInput: (t) => /* @__PURE__ */ k(b, {
|
|
245
|
+
placeholder: te,
|
|
246
|
+
...t,
|
|
247
|
+
error: !!se,
|
|
248
|
+
...e.slotProps?.textField,
|
|
249
|
+
slotProps: {
|
|
250
|
+
...t.slotProps,
|
|
251
|
+
input: {
|
|
252
|
+
...t.slotProps.input,
|
|
253
|
+
...e.slotProps?.textField?.slotProps?.input,
|
|
254
|
+
inputRef: G.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
|
+
K(G.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: ne,
|
|
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: re,
|
|
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: U
|
|
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})=>
|
|
38
|
-
border-radius: 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})=>
|
|
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 ? V([H(_), e]) : H(_), { field: b } = t({
|
|
329
|
+
control: h,
|
|
330
|
+
name: n,
|
|
331
|
+
rules: y,
|
|
332
|
+
defaultValue: a,
|
|
333
|
+
shouldUnregister: o
|
|
334
|
+
});
|
|
335
|
+
return /* @__PURE__ */ k(G, {
|
|
336
|
+
dateAdapter: W,
|
|
337
|
+
localeText: ce.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(se, {
|
|
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 && K(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/radioButton/radioButton.tsx
|
|
417
|
+
var Ce = ({ label: e, labelPlacement: t, ...n }) => /* @__PURE__ */ k(u, {
|
|
418
|
+
sx: {
|
|
419
|
+
display: "flex",
|
|
420
|
+
flexDirection: "column"
|
|
421
|
+
},
|
|
422
|
+
children: /* @__PURE__ */ k(l, {
|
|
423
|
+
control: /* @__PURE__ */ k(m, { ...n }),
|
|
424
|
+
label: /* @__PURE__ */ k(X, { label: e }),
|
|
425
|
+
labelPlacement: t || "end"
|
|
426
|
+
})
|
|
427
|
+
}), we = ({ name: e, rules: n, defaultValue: i, shouldUnregister: a, control: o, label: s, required: c, children: l, orientation: u = "row", disableIconError: d, ...f }) => {
|
|
428
|
+
let p = r()?.control, m = o ?? p;
|
|
429
|
+
if (!m) throw new Z("RadioGroup");
|
|
430
|
+
let { field: g } = t({
|
|
431
|
+
control: m,
|
|
432
|
+
name: e,
|
|
433
|
+
rules: n,
|
|
434
|
+
defaultValue: i,
|
|
435
|
+
shouldUnregister: a
|
|
436
|
+
});
|
|
437
|
+
return /* @__PURE__ */ A(v, { children: [
|
|
438
|
+
s && /* @__PURE__ */ k(X, {
|
|
439
|
+
label: s,
|
|
440
|
+
required: c
|
|
441
|
+
}),
|
|
442
|
+
/* @__PURE__ */ k(h, {
|
|
443
|
+
value: g.value || "",
|
|
444
|
+
name: e,
|
|
445
|
+
...f,
|
|
446
|
+
onChange: (e) => {
|
|
447
|
+
f?.onChange?.(e, e.target?.value), g.onChange(e);
|
|
448
|
+
},
|
|
449
|
+
style: {
|
|
450
|
+
display: "flex",
|
|
451
|
+
flexDirection: u
|
|
452
|
+
},
|
|
453
|
+
children: l
|
|
454
|
+
}, e),
|
|
455
|
+
/* @__PURE__ */ k(Y, {
|
|
456
|
+
name: e,
|
|
457
|
+
disableIcon: d,
|
|
458
|
+
control: m
|
|
459
|
+
})
|
|
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("Searchable");
|
|
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) => ae(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: B.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] = ee(!1);
|
|
560
|
+
if (!N) throw new Z("Select");
|
|
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: B.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] = ee(!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: z,
|
|
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 ? R : te,
|
|
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})=>
|
|
47
|
-
border-radius: 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})=>
|
|
802
|
+
width: ${({ size: e }) => je(e)} !important;
|
|
51
803
|
}
|
|
52
|
-
|
|
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 ? V([U(_), e]) : U(_), { field: b } = t({
|
|
811
|
+
control: h,
|
|
812
|
+
name: o,
|
|
813
|
+
rules: y,
|
|
814
|
+
defaultValue: n,
|
|
815
|
+
shouldUnregister: a
|
|
816
|
+
});
|
|
817
|
+
return /* @__PURE__ */ k(G, {
|
|
818
|
+
dateAdapter: W,
|
|
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 Creatable, ye as DatePicker, Y as FieldError, $ as FieldInfo, X as FieldLabel, Se as Form, be as FormProvider, Ce as RadioButton, we as RadioGroup, Te as Searchable, De as Select, Oe as Slider, ke as Switch, Ae as TextField, Pe as TimePicker, xe as useForm };
|
|
864
|
+
|
|
865
|
+
//# sourceMappingURL=index.mjs.map
|