@s_mart/form 16.1.1 → 16.1.3

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 (51) hide show
  1. package/dist/checkbox/checkbox.mjs +43 -0
  2. package/dist/checkbox/checkbox.mjs.map +1 -0
  3. package/dist/components/fieldError/fieldError.mjs +20 -0
  4. package/dist/components/fieldError/fieldError.mjs.map +1 -0
  5. package/dist/components/fieldInfo/fieldInfo.mjs +20 -0
  6. package/dist/components/fieldInfo/fieldInfo.mjs.map +1 -0
  7. package/dist/components/fieldLabel/fieldLabel.mjs +29 -0
  8. package/dist/components/fieldLabel/fieldLabel.mjs.map +1 -0
  9. package/dist/creatable/creatable.mjs +191 -0
  10. package/dist/creatable/creatable.mjs.map +1 -0
  11. package/dist/creatable/creatable.styles.mjs +41 -0
  12. package/dist/creatable/creatable.styles.mjs.map +1 -0
  13. package/dist/datePicker/datePicker.mjs +75 -0
  14. package/dist/datePicker/datePicker.mjs.map +1 -0
  15. package/dist/datePicker/datePicker.styles.mjs +29 -0
  16. package/dist/datePicker/datePicker.styles.mjs.map +1 -0
  17. package/dist/form/form.mjs +16 -0
  18. package/dist/form/form.mjs.map +1 -0
  19. package/dist/form/formProvider.mjs +19 -0
  20. package/dist/form/formProvider.mjs.map +1 -0
  21. package/dist/form/useForm.mjs +20 -0
  22. package/dist/form/useForm.mjs.map +1 -0
  23. package/dist/formComponentPrecisaDeControl.mjs +10 -0
  24. package/dist/formComponentPrecisaDeControl.mjs.map +1 -0
  25. package/dist/index.mjs +18 -865
  26. package/dist/radio/radioButton/radioButton.mjs +19 -0
  27. package/dist/radio/radioButton/radioButton.mjs.map +1 -0
  28. package/dist/radio/radioGroup/radioGroup.mjs +46 -0
  29. package/dist/radio/radioGroup/radioGroup.mjs.map +1 -0
  30. package/dist/searchable/searchable.mjs +111 -0
  31. package/dist/searchable/searchable.mjs.map +1 -0
  32. package/dist/select/select.mjs +117 -0
  33. package/dist/select/select.mjs.map +1 -0
  34. package/dist/select/selectRenderValue.mjs +11 -0
  35. package/dist/select/selectRenderValue.mjs.map +1 -0
  36. package/dist/slider/slider.mjs +26 -0
  37. package/dist/slider/slider.mjs.map +1 -0
  38. package/dist/switch/switch.mjs +39 -0
  39. package/dist/switch/switch.mjs.map +1 -0
  40. package/dist/textField/textField.mjs +102 -0
  41. package/dist/textField/textField.mjs.map +1 -0
  42. package/dist/timePicker/timePicker.mjs +76 -0
  43. package/dist/timePicker/timePicker.mjs.map +1 -0
  44. package/dist/timePicker/timePicker.styles.mjs +29 -0
  45. package/dist/timePicker/timePicker.styles.mjs.map +1 -0
  46. package/dist/utils/erroFieldFormatado.mjs +6 -0
  47. package/dist/utils/erroFieldFormatado.mjs.map +1 -0
  48. package/dist/utils/typedMemo.mjs +7 -0
  49. package/dist/utils/typedMemo.mjs.map +1 -0
  50. package/package.json +17 -17
  51. package/dist/index.mjs.map +0 -1
package/dist/index.mjs CHANGED
@@ -1,865 +1,18 @@
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`
99
- display: flex;
100
- align-items: center;
101
- justify-content: center;
102
- `, pe = w("div")`
103
- display: flex;
104
-
105
- div.endAdornments {
106
- position: absolute;
107
- right: 0;
108
-
109
- ${fe}
110
- }
111
-
112
- .MuiAutocomplete-endAdornment {
113
- position: relative;
114
- right: 0;
115
- }
116
-
117
- .endAdornments > .MuiAutocomplete-endAdornment {
118
- transform: translate(0, 0);
119
- }
120
-
121
- .creatable,
122
- .editable {
123
- ${fe}
124
-
125
- .divider {
126
- width: 1px;
127
- height: ${j(20)};
128
- background-color: ${({ theme: e }) => e.palette.grey[400]};
129
- }
130
- }
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)`
314
- margin: 0px;
315
-
316
- padding: ${({ size: e }) => _e(e)};
317
- border-radius: 0 ${j(4)} ${j(4)} 0;
318
-
319
- svg {
320
- width: ${({ size: e }) => ge(e)} !important;
321
- }
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)`
796
- margin: 0px;
797
-
798
- padding: ${({ size: e }) => Me(e)};
799
- border-radius: 0 ${j(4)} ${j(4)} 0;
800
-
801
- svg {
802
- width: ${({ size: e }) => je(e)} !important;
803
- }
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
1
+ import e from "./components/fieldError/fieldError.mjs";
2
+ import t from "./components/fieldLabel/fieldLabel.mjs";
3
+ import n from "./checkbox/checkbox.mjs";
4
+ import r from "./components/fieldInfo/fieldInfo.mjs";
5
+ import i from "./creatable/creatable.mjs";
6
+ import a from "./datePicker/datePicker.mjs";
7
+ import o from "./form/formProvider.mjs";
8
+ import s from "./form/useForm.mjs";
9
+ import c from "./form/form.mjs";
10
+ import l from "./radio/radioButton/radioButton.mjs";
11
+ import u from "./radio/radioGroup/radioGroup.mjs";
12
+ import d from "./searchable/searchable.mjs";
13
+ import f from "./select/select.mjs";
14
+ import p from "./slider/slider.mjs";
15
+ import m from "./switch/switch.mjs";
16
+ import h from "./textField/textField.mjs";
17
+ import g from "./timePicker/timePicker.mjs";
18
+ export { n as Checkbox, i as Creatable, a as DatePicker, e as FieldError, r as FieldInfo, t as FieldLabel, c as Form, o as FormProvider, l as RadioButton, u as RadioGroup, d as Searchable, f as Select, p as Slider, m as Switch, h as TextField, g as TimePicker, s as useForm };