diefra_ecm_ui 1.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.
package/dist/index.js ADDED
@@ -0,0 +1,1540 @@
1
+ import { jsxs as N, jsx as r, Fragment as ce } from "react/jsx-runtime";
2
+ import { memo as z, useMemo as B, useCallback as C, useState as L, useRef as G, useEffect as E, forwardRef as se, createElement as Z } from "react";
3
+ import { useFormContext as H, useController as X, useFormState as de } from "react-hook-form";
4
+ import { IMaskInput as le } from "react-imask";
5
+ import { useSection as F, useFluigRuntime as I } from "@fluig-kit/ecm";
6
+ import { parse as ue, isValid as me, eachDayOfInterval as he, endOfWeek as fe, endOfMonth as pe, startOfWeek as ye, startOfMonth as ve, subMonths as ge, format as K, addMonths as be, isSameMonth as we, isSameDay as Ne, isToday as ke } from "date-fns";
7
+ const xe = {
8
+ cpf: "000.000.000-00",
9
+ cnpj: "00.000.000/0000-00",
10
+ telefone: "(00) 00000-0000",
11
+ cep: "00000-000"
12
+ };
13
+ function Re({
14
+ name: e,
15
+ label: t = "",
16
+ placeholder: n = "",
17
+ type: i = "text",
18
+ mask: s,
19
+ className: d = "",
20
+ forceReadOnly: l = !1,
21
+ forceHidden: o = !1,
22
+ valueManual: v,
23
+ onChangeManual: a,
24
+ errorManual: p
25
+ }) {
26
+ var S, O;
27
+ const g = v !== void 0 && !!a, { isReadOnly: $, isHidden: V } = F(), A = l || !!$(e), _ = o || !!V(e), { isView: W } = I();
28
+ let w = null;
29
+ try {
30
+ w = H();
31
+ } catch {
32
+ }
33
+ const f = !g && w ? X({ name: e, control: w.control }) : null, u = !g && w ? de({ name: e }) : null, m = g ? v : f == null ? void 0 : f.field.value, c = g ? p : (O = (S = u == null ? void 0 : u.errors) == null ? void 0 : S[e]) == null ? void 0 : O.message, h = B(
34
+ () => s ? xe[s] ?? s : null,
35
+ [s]
36
+ ), y = C((b) => {
37
+ if (!b) return "";
38
+ const T = b.replace(/\D/g, "");
39
+ return (Number(T) / 100).toLocaleString("pt-BR", {
40
+ style: "currency",
41
+ currency: "BRL"
42
+ });
43
+ }, []), x = C(
44
+ (b) => i === "monetary" ? y(b) : b,
45
+ [i, y]
46
+ ), D = (b) => {
47
+ const T = x(b);
48
+ g ? a == null || a(T) : f == null || f.field.onChange(T);
49
+ }, R = () => {
50
+ g || f == null || f.field.onBlur();
51
+ };
52
+ if (W)
53
+ return /* @__PURE__ */ N("div", { className: "form-group", children: [
54
+ /* @__PURE__ */ r("label", { children: t }),
55
+ /* @__PURE__ */ r("span", { className: "form-control", children: m || "-" })
56
+ ] });
57
+ const k = `form-control ${A ? "readOnly" : ""} ${c ? "border-red" : ""} ${d}`;
58
+ return /* @__PURE__ */ N("div", { className: `form-group ${_ ? "hidden" : ""}`, children: [
59
+ t && /* @__PURE__ */ r("label", { children: t }),
60
+ h ? /* @__PURE__ */ r(
61
+ le,
62
+ {
63
+ name: e,
64
+ mask: h,
65
+ value: String(m ?? ""),
66
+ unmask: !1,
67
+ onAccept: (b) => D(b),
68
+ placeholder: n,
69
+ readOnly: A,
70
+ className: k,
71
+ inputRef: g || f == null ? void 0 : f.field.ref,
72
+ onBlur: R
73
+ }
74
+ ) : /* @__PURE__ */ r(
75
+ "input",
76
+ {
77
+ type: "text",
78
+ name: e,
79
+ value: m ?? "",
80
+ onChange: (b) => D(b.target.value),
81
+ onBlur: R,
82
+ placeholder: n,
83
+ readOnly: A,
84
+ className: k
85
+ }
86
+ ),
87
+ c && /* @__PURE__ */ r("p", { className: "text-danger", children: String(c) })
88
+ ] });
89
+ }
90
+ const Dt = z(Re);
91
+ function Se({
92
+ name: e,
93
+ label: t = "",
94
+ options: n = [],
95
+ placeholder: i = "",
96
+ labelKey: s = "label",
97
+ valueKey: d = "value",
98
+ enableSearch: l = !1,
99
+ searchPlaceholder: o = "Buscar...",
100
+ loading: v = !1,
101
+ onSearchChange: a,
102
+ debounceTime: p = 300,
103
+ onSelect: g,
104
+ forceReadOnly: $ = !1,
105
+ forceHidden: V = !1,
106
+ valueManual: A,
107
+ onChangeManual: _,
108
+ errorManual: W
109
+ }) {
110
+ var ne;
111
+ const w = A !== void 0 && !!_, { isReadOnly: f, isHidden: u } = F(), m = $ || !!f(e), c = V || !!u(e), { isView: h } = I();
112
+ let y = "", x = () => {
113
+ }, D, R = null, k = () => {
114
+ };
115
+ if (w)
116
+ y = A;
117
+ else
118
+ try {
119
+ const P = H(), j = X({ name: e, control: P.control });
120
+ y = j.field.value, x = j.field.onChange, D = j.field.ref, R = (ne = j.fieldState) == null ? void 0 : ne.error, k = P.clearErrors;
121
+ } catch {
122
+ }
123
+ const [S, O] = L(!1), [b, T] = L(""), q = G(null), U = G(a);
124
+ E(() => {
125
+ U.current = a;
126
+ }, [a]), E(() => {
127
+ const P = (j) => {
128
+ q.current && !q.current.contains(j.target) && O(!1);
129
+ };
130
+ return document.addEventListener("mousedown", P), () => document.removeEventListener("mousedown", P);
131
+ }, []), E(() => {
132
+ S || T("");
133
+ }, [S]), E(() => {
134
+ if (!l) return;
135
+ const P = setTimeout(() => {
136
+ var j;
137
+ (j = U.current) == null || j.call(U, b);
138
+ }, p);
139
+ return () => clearTimeout(P);
140
+ }, [b, l, p]);
141
+ const ee = B(() => l && !a && b.trim() ? n.filter(
142
+ (P) => String((P == null ? void 0 : P[s]) ?? "").toLowerCase().includes(b.toLowerCase())
143
+ ) : n ?? [], [n, l, a, b, s]), te = B(() => {
144
+ if (y == null) return "";
145
+ if (typeof y == "object")
146
+ return String(y[d] ?? "");
147
+ const P = (n || []).find(
148
+ (j) => String(j == null ? void 0 : j[d]) === String(y)
149
+ );
150
+ return String(P ? (P == null ? void 0 : P[s]) ?? "" : y);
151
+ }, [y, n, d, s]), oe = (P) => {
152
+ m || (w ? _ == null || _(P[d]) : (x(P[d]), k == null || k(e)), g == null || g(P), O(!1));
153
+ };
154
+ return /* @__PURE__ */ N(
155
+ "div",
156
+ {
157
+ className: `select-wrapper form-group ${c ? "hidden" : ""}`,
158
+ ref: q,
159
+ children: [
160
+ /* @__PURE__ */ r("label", { className: "control-label", children: t }),
161
+ h ? /* @__PURE__ */ r("span", { className: "form-control", children: te || "-" }) : /* @__PURE__ */ N(ce, { children: [
162
+ /* @__PURE__ */ N(
163
+ "div",
164
+ {
165
+ className: `select-control ${R ? "border-red" : ""} ${m ? "readOnly" : ""}`,
166
+ onClick: () => !m && O((P) => !P),
167
+ ref: D,
168
+ children: [
169
+ /* @__PURE__ */ r("span", { className: `select-display ${m ? "readOnly" : ""}`, children: te || i }),
170
+ /* @__PURE__ */ r("i", { className: "flaticon flaticon-chevron-down select-icon" })
171
+ ]
172
+ }
173
+ ),
174
+ S && !m && /* @__PURE__ */ N("div", { className: "select-dropdown", children: [
175
+ l && /* @__PURE__ */ r("div", { className: "select-search", children: /* @__PURE__ */ r(
176
+ "input",
177
+ {
178
+ type: "text",
179
+ className: "select-search-input",
180
+ value: b,
181
+ onChange: (P) => T(P.target.value),
182
+ placeholder: v ? "Carregando..." : o,
183
+ autoFocus: !0,
184
+ onClick: (P) => P.stopPropagation()
185
+ }
186
+ ) }),
187
+ /* @__PURE__ */ r("ul", { className: "select-options", children: v ? /* @__PURE__ */ r("li", { className: "select-option readOnly", children: "Carregando..." }) : ee.length > 0 ? ee.map((P) => /* @__PURE__ */ r(
188
+ "li",
189
+ {
190
+ onClick: () => oe(P),
191
+ className: "select-option handleHover",
192
+ children: P[s]
193
+ },
194
+ P[d]
195
+ )) : /* @__PURE__ */ r("li", { className: "select-option readOnly", children: "Sem resultados" }) })
196
+ ] })
197
+ ] }),
198
+ !w && /* @__PURE__ */ r("input", { type: "hidden", name: e, value: y || "" }),
199
+ (R || W) && /* @__PURE__ */ r("p", { className: "text-danger", children: String((R == null ? void 0 : R.message) ?? W) })
200
+ ]
201
+ }
202
+ );
203
+ }
204
+ const Vt = z(Se);
205
+ function Tt({
206
+ name: e,
207
+ options: t = [],
208
+ label: n = "",
209
+ valueKey: i = "value",
210
+ labelKey: s = "label",
211
+ forceReadOnly: d = !1,
212
+ forceHidden: l = !1,
213
+ valueManual: o,
214
+ onChangeManual: v
215
+ }) {
216
+ var D, R;
217
+ let a = null;
218
+ try {
219
+ a = H();
220
+ } catch {
221
+ }
222
+ const p = o !== void 0 && !!v, { isView: g, isReadOnly: $ } = I(), { isReadOnly: V, isHidden: A } = F(), _ = V ? V(e) : !1, W = A ? A(e) : !1, w = d || _, f = l || W, u = w || $ || g, m = () => t ? t.reduce(
223
+ (k, S) => {
224
+ const O = String(S[i]);
225
+ if (p)
226
+ k[O] = !!(o != null && o[O]);
227
+ else if (a) {
228
+ const b = a.getValues(O);
229
+ k[O] = b === "on";
230
+ } else
231
+ k[O] = !1;
232
+ return k;
233
+ },
234
+ {}
235
+ ) : {}, c = !p && a ? a.watch(e) : void 0, h = B(() => p && o ? o : c && typeof c == "object" ? c : m(), [c, o, t]);
236
+ E(() => {
237
+ if (p || !a) return;
238
+ const k = a.getValues(e);
239
+ (!k || typeof k != "object") && a.setValue(e, h, {
240
+ shouldDirty: !1,
241
+ shouldValidate: !1
242
+ });
243
+ }, [h, e, a, p]);
244
+ const y = (k, S) => {
245
+ if (u) return;
246
+ const O = { ...h, [k]: S };
247
+ if (p) {
248
+ v && v(O);
249
+ return;
250
+ }
251
+ a && (a.setValue(e, O, {
252
+ shouldDirty: !0,
253
+ shouldValidate: !0
254
+ }), a.setValue(k, S ? "on" : "", { shouldValidate: !1 }));
255
+ }, x = p ? null : (R = (D = a == null ? void 0 : a.formState) == null ? void 0 : D.errors) == null ? void 0 : R[e];
256
+ return /* @__PURE__ */ N("div", { className: `form-group ${f ? "hidden" : ""}`, children: [
257
+ n && /* @__PURE__ */ r("label", { children: n }),
258
+ /* @__PURE__ */ r(
259
+ "div",
260
+ {
261
+ className: `checkbox-group-custom ${u ? "readOnly" : ""}`,
262
+ children: t.map((k) => {
263
+ const S = String(k[i]), O = h[S] === !0;
264
+ return /* @__PURE__ */ N("div", { children: [
265
+ !p && a && /* @__PURE__ */ r("input", { type: "hidden", ...a.register(S) }),
266
+ /* @__PURE__ */ N(
267
+ "label",
268
+ {
269
+ className: `custom-checkbox ${O ? "checked" : ""} ${u ? "readOnly" : ""}`,
270
+ children: [
271
+ /* @__PURE__ */ r(
272
+ "input",
273
+ {
274
+ type: "checkbox",
275
+ checked: O,
276
+ disabled: u,
277
+ onChange: (b) => y(S, b.target.checked)
278
+ }
279
+ ),
280
+ /* @__PURE__ */ r("span", { className: "checkmark" }),
281
+ /* @__PURE__ */ r("span", { children: k[s] })
282
+ ]
283
+ }
284
+ )
285
+ ] }, S);
286
+ })
287
+ }
288
+ ),
289
+ x && /* @__PURE__ */ r("p", { className: "text-danger", children: String(x.message) })
290
+ ] });
291
+ }
292
+ function Pe({
293
+ name: e,
294
+ label: t = "",
295
+ options: n = [],
296
+ valueKey: i = "value",
297
+ labelKey: s = "label",
298
+ iconKey: d = "icon",
299
+ forceReadOnly: l = !1,
300
+ forceHidden: o = !1,
301
+ valueManual: v,
302
+ onChangeManual: a,
303
+ errorManual: p
304
+ }) {
305
+ var y;
306
+ const g = v !== void 0 && !!a, { isReadOnly: $, isHidden: V } = F(), A = l || !!$(e), _ = o || !!V(e), { isView: W, isReadOnly: w } = I();
307
+ let f = null, u = null;
308
+ if (!g)
309
+ try {
310
+ const { control: x } = H(), D = X({ name: e, control: x });
311
+ f = D.field, u = (y = D.fieldState) == null ? void 0 : y.error;
312
+ } catch {
313
+ }
314
+ const m = A || w || W, c = g ? v : (f == null ? void 0 : f.value) ?? "", h = C(
315
+ (x) => {
316
+ m || (g ? a == null || a(x) : f == null || f.onChange(x));
317
+ },
318
+ [m, g, a, f]
319
+ );
320
+ return /* @__PURE__ */ N("div", { className: `form-group column ${_ ? "hidden" : ""}`, children: [
321
+ t && /* @__PURE__ */ r("label", { className: "control-label", children: t }),
322
+ /* @__PURE__ */ r(
323
+ "div",
324
+ {
325
+ className: `btn-group ${m ? "view-mode" : ""}`,
326
+ "data-field-name": e,
327
+ children: n.map((x) => {
328
+ const D = x[i], R = c === D, k = x.color ? { "--customColor": x.color } : void 0;
329
+ return /* @__PURE__ */ N(
330
+ "label",
331
+ {
332
+ htmlFor: `${e}_${D}`,
333
+ style: k,
334
+ className: `btn fs-ellipsis ${R ? "active" : ""}`,
335
+ children: [
336
+ /* @__PURE__ */ r(
337
+ "input",
338
+ {
339
+ type: "radio",
340
+ id: `${e}_${D}`,
341
+ name: e,
342
+ value: D,
343
+ checked: R,
344
+ className: "hidden",
345
+ onChange: () => h(D),
346
+ disabled: m
347
+ }
348
+ ),
349
+ x[d] && /* @__PURE__ */ r("i", { className: `${x[d]} icon-sm` }),
350
+ " ",
351
+ x[s]
352
+ ]
353
+ },
354
+ D
355
+ );
356
+ })
357
+ }
358
+ ),
359
+ (u || p) && /* @__PURE__ */ r("p", { className: "text-danger", children: String((u == null ? void 0 : u.message) ?? p) })
360
+ ] });
361
+ }
362
+ const jt = z(Pe), $e = ({
363
+ name: e,
364
+ label: t = "",
365
+ placeholder: n = "",
366
+ className: i = "",
367
+ rows: s = 4,
368
+ maxLength: d,
369
+ forceReadOnly: l = !1,
370
+ forceHidden: o = !1,
371
+ valueManual: v,
372
+ onChangeManual: a,
373
+ errorManual: p
374
+ }) => {
375
+ var h;
376
+ const g = v !== void 0 && !!a, { isReadOnly: $, isHidden: V } = F(), A = l || !!$(e), _ = o || !!V(e), { isView: W } = I(), w = G(null);
377
+ let f = {
378
+ value: v ?? "",
379
+ onChange: (y) => a == null ? void 0 : a(y)
380
+ }, u = null;
381
+ if (!g)
382
+ try {
383
+ const { control: y } = H(), x = X({ name: e, control: y });
384
+ f = x.field, u = (h = x.fieldState) == null ? void 0 : h.error;
385
+ } catch {
386
+ }
387
+ const m = () => {
388
+ w.current && (w.current.style.height = "auto", w.current.style.height = `${w.current.scrollHeight}px`);
389
+ };
390
+ if (E(() => {
391
+ m();
392
+ }, [f.value]), W)
393
+ return /* @__PURE__ */ N("div", { className: `form-group ${_ ? "hidden" : ""}`, children: [
394
+ /* @__PURE__ */ r("label", { children: t }),
395
+ /* @__PURE__ */ r("span", { className: "form-control", children: f.value || "-" })
396
+ ] });
397
+ const c = `form-control ${A ? "readOnly" : ""} ${u || p ? "border-red" : ""} ${i}`;
398
+ return /* @__PURE__ */ N("div", { className: `form-group ${_ ? "hidden" : ""}`, children: [
399
+ t && /* @__PURE__ */ r("label", { children: t }),
400
+ /* @__PURE__ */ r(
401
+ "textarea",
402
+ {
403
+ ref: w,
404
+ rows: s,
405
+ maxLength: d,
406
+ value: f.value || "",
407
+ placeholder: n,
408
+ readOnly: A,
409
+ className: c,
410
+ style: {
411
+ resize: "none",
412
+ maxHeight: "400px",
413
+ overflowY: "auto"
414
+ },
415
+ onChange: (y) => {
416
+ g ? a == null || a(y.target.value) : f.onChange(y);
417
+ },
418
+ onInput: m
419
+ }
420
+ ),
421
+ (u || p) && /* @__PURE__ */ r("p", { className: "text-danger", children: String((u == null ? void 0 : u.message) ?? p) })
422
+ ] });
423
+ }, Ct = z($e);
424
+ function J(e) {
425
+ return (t = {}) => {
426
+ const n = t.width ? String(t.width) : e.defaultWidth;
427
+ return e.formats[n] || e.formats[e.defaultWidth];
428
+ };
429
+ }
430
+ function Q(e) {
431
+ return (t, n) => {
432
+ const i = n != null && n.context ? String(n.context) : "standalone";
433
+ let s;
434
+ if (i === "formatting" && e.formattingValues) {
435
+ const l = e.defaultFormattingWidth || e.defaultWidth, o = n != null && n.width ? String(n.width) : l;
436
+ s = e.formattingValues[o] || e.formattingValues[l];
437
+ } else {
438
+ const l = e.defaultWidth, o = n != null && n.width ? String(n.width) : e.defaultWidth;
439
+ s = e.values[o] || e.values[l];
440
+ }
441
+ const d = e.argumentCallback ? e.argumentCallback(t) : t;
442
+ return s[d];
443
+ };
444
+ }
445
+ function Y(e) {
446
+ return (t, n = {}) => {
447
+ const i = n.width, s = i && e.matchPatterns[i] || e.matchPatterns[e.defaultMatchWidth], d = t.match(s);
448
+ if (!d)
449
+ return null;
450
+ const l = d[0], o = i && e.parsePatterns[i] || e.parsePatterns[e.defaultParseWidth], v = Array.isArray(o) ? Oe(o, (g) => g.test(l)) : (
451
+ // [TODO] -- I challenge you to fix the type
452
+ _e(o, (g) => g.test(l))
453
+ );
454
+ let a;
455
+ a = e.valueCallback ? e.valueCallback(v) : v, a = n.valueCallback ? (
456
+ // [TODO] -- I challenge you to fix the type
457
+ n.valueCallback(a)
458
+ ) : a;
459
+ const p = t.slice(l.length);
460
+ return { value: a, rest: p };
461
+ };
462
+ }
463
+ function _e(e, t) {
464
+ for (const n in e)
465
+ if (Object.prototype.hasOwnProperty.call(e, n) && t(e[n]))
466
+ return n;
467
+ }
468
+ function Oe(e, t) {
469
+ for (let n = 0; n < e.length; n++)
470
+ if (t(e[n]))
471
+ return n;
472
+ }
473
+ function Ae(e) {
474
+ return (t, n = {}) => {
475
+ const i = t.match(e.matchPattern);
476
+ if (!i) return null;
477
+ const s = i[0], d = t.match(e.parsePattern);
478
+ if (!d) return null;
479
+ let l = e.valueCallback ? e.valueCallback(d[0]) : d[0];
480
+ l = n.valueCallback ? n.valueCallback(l) : l;
481
+ const o = t.slice(s.length);
482
+ return { value: l, rest: o };
483
+ };
484
+ }
485
+ const We = {
486
+ lessThanXSeconds: {
487
+ one: "menos de um segundo",
488
+ other: "menos de {{count}} segundos"
489
+ },
490
+ xSeconds: {
491
+ one: "1 segundo",
492
+ other: "{{count}} segundos"
493
+ },
494
+ halfAMinute: "meio minuto",
495
+ lessThanXMinutes: {
496
+ one: "menos de um minuto",
497
+ other: "menos de {{count}} minutos"
498
+ },
499
+ xMinutes: {
500
+ one: "1 minuto",
501
+ other: "{{count}} minutos"
502
+ },
503
+ aboutXHours: {
504
+ one: "cerca de 1 hora",
505
+ other: "cerca de {{count}} horas"
506
+ },
507
+ xHours: {
508
+ one: "1 hora",
509
+ other: "{{count}} horas"
510
+ },
511
+ xDays: {
512
+ one: "1 dia",
513
+ other: "{{count}} dias"
514
+ },
515
+ aboutXWeeks: {
516
+ one: "cerca de 1 semana",
517
+ other: "cerca de {{count}} semanas"
518
+ },
519
+ xWeeks: {
520
+ one: "1 semana",
521
+ other: "{{count}} semanas"
522
+ },
523
+ aboutXMonths: {
524
+ one: "cerca de 1 mês",
525
+ other: "cerca de {{count}} meses"
526
+ },
527
+ xMonths: {
528
+ one: "1 mês",
529
+ other: "{{count}} meses"
530
+ },
531
+ aboutXYears: {
532
+ one: "cerca de 1 ano",
533
+ other: "cerca de {{count}} anos"
534
+ },
535
+ xYears: {
536
+ one: "1 ano",
537
+ other: "{{count}} anos"
538
+ },
539
+ overXYears: {
540
+ one: "mais de 1 ano",
541
+ other: "mais de {{count}} anos"
542
+ },
543
+ almostXYears: {
544
+ one: "quase 1 ano",
545
+ other: "quase {{count}} anos"
546
+ }
547
+ }, De = (e, t, n) => {
548
+ let i;
549
+ const s = We[e];
550
+ return typeof s == "string" ? i = s : t === 1 ? i = s.one : i = s.other.replace("{{count}}", String(t)), n != null && n.addSuffix ? n.comparison && n.comparison > 0 ? "em " + i : "há " + i : i;
551
+ }, Ve = {
552
+ full: "EEEE, d 'de' MMMM 'de' y",
553
+ long: "d 'de' MMMM 'de' y",
554
+ medium: "d MMM y",
555
+ short: "dd/MM/yyyy"
556
+ }, Te = {
557
+ full: "HH:mm:ss zzzz",
558
+ long: "HH:mm:ss z",
559
+ medium: "HH:mm:ss",
560
+ short: "HH:mm"
561
+ }, je = {
562
+ full: "{{date}} 'às' {{time}}",
563
+ long: "{{date}} 'às' {{time}}",
564
+ medium: "{{date}}, {{time}}",
565
+ short: "{{date}}, {{time}}"
566
+ }, Ce = {
567
+ date: J({
568
+ formats: Ve,
569
+ defaultWidth: "full"
570
+ }),
571
+ time: J({
572
+ formats: Te,
573
+ defaultWidth: "full"
574
+ }),
575
+ dateTime: J({
576
+ formats: je,
577
+ defaultWidth: "full"
578
+ })
579
+ }, Ee = {
580
+ lastWeek: (e) => {
581
+ const t = e.getDay();
582
+ return "'" + (t === 0 || t === 6 ? "último" : "última") + "' eeee 'às' p";
583
+ },
584
+ yesterday: "'ontem às' p",
585
+ today: "'hoje às' p",
586
+ tomorrow: "'amanhã às' p",
587
+ nextWeek: "eeee 'às' p",
588
+ other: "P"
589
+ }, He = (e, t, n, i) => {
590
+ const s = Ee[e];
591
+ return typeof s == "function" ? s(t) : s;
592
+ }, Ie = {
593
+ narrow: ["AC", "DC"],
594
+ abbreviated: ["AC", "DC"],
595
+ wide: ["antes de cristo", "depois de cristo"]
596
+ }, Le = {
597
+ narrow: ["1", "2", "3", "4"],
598
+ abbreviated: ["T1", "T2", "T3", "T4"],
599
+ wide: ["1º trimestre", "2º trimestre", "3º trimestre", "4º trimestre"]
600
+ }, Fe = {
601
+ narrow: ["j", "f", "m", "a", "m", "j", "j", "a", "s", "o", "n", "d"],
602
+ abbreviated: [
603
+ "jan",
604
+ "fev",
605
+ "mar",
606
+ "abr",
607
+ "mai",
608
+ "jun",
609
+ "jul",
610
+ "ago",
611
+ "set",
612
+ "out",
613
+ "nov",
614
+ "dez"
615
+ ],
616
+ wide: [
617
+ "janeiro",
618
+ "fevereiro",
619
+ "março",
620
+ "abril",
621
+ "maio",
622
+ "junho",
623
+ "julho",
624
+ "agosto",
625
+ "setembro",
626
+ "outubro",
627
+ "novembro",
628
+ "dezembro"
629
+ ]
630
+ }, qe = {
631
+ narrow: ["D", "S", "T", "Q", "Q", "S", "S"],
632
+ short: ["dom", "seg", "ter", "qua", "qui", "sex", "sab"],
633
+ abbreviated: [
634
+ "domingo",
635
+ "segunda",
636
+ "terça",
637
+ "quarta",
638
+ "quinta",
639
+ "sexta",
640
+ "sábado"
641
+ ],
642
+ wide: [
643
+ "domingo",
644
+ "segunda-feira",
645
+ "terça-feira",
646
+ "quarta-feira",
647
+ "quinta-feira",
648
+ "sexta-feira",
649
+ "sábado"
650
+ ]
651
+ }, Be = {
652
+ narrow: {
653
+ am: "a",
654
+ pm: "p",
655
+ midnight: "mn",
656
+ noon: "md",
657
+ morning: "manhã",
658
+ afternoon: "tarde",
659
+ evening: "tarde",
660
+ night: "noite"
661
+ },
662
+ abbreviated: {
663
+ am: "AM",
664
+ pm: "PM",
665
+ midnight: "meia-noite",
666
+ noon: "meio-dia",
667
+ morning: "manhã",
668
+ afternoon: "tarde",
669
+ evening: "tarde",
670
+ night: "noite"
671
+ },
672
+ wide: {
673
+ am: "a.m.",
674
+ pm: "p.m.",
675
+ midnight: "meia-noite",
676
+ noon: "meio-dia",
677
+ morning: "manhã",
678
+ afternoon: "tarde",
679
+ evening: "tarde",
680
+ night: "noite"
681
+ }
682
+ }, ze = {
683
+ narrow: {
684
+ am: "a",
685
+ pm: "p",
686
+ midnight: "mn",
687
+ noon: "md",
688
+ morning: "da manhã",
689
+ afternoon: "da tarde",
690
+ evening: "da tarde",
691
+ night: "da noite"
692
+ },
693
+ abbreviated: {
694
+ am: "AM",
695
+ pm: "PM",
696
+ midnight: "meia-noite",
697
+ noon: "meio-dia",
698
+ morning: "da manhã",
699
+ afternoon: "da tarde",
700
+ evening: "da tarde",
701
+ night: "da noite"
702
+ },
703
+ wide: {
704
+ am: "a.m.",
705
+ pm: "p.m.",
706
+ midnight: "meia-noite",
707
+ noon: "meio-dia",
708
+ morning: "da manhã",
709
+ afternoon: "da tarde",
710
+ evening: "da tarde",
711
+ night: "da noite"
712
+ }
713
+ }, Xe = (e, t) => {
714
+ const n = Number(e);
715
+ return (t == null ? void 0 : t.unit) === "week" ? n + "ª" : n + "º";
716
+ }, Ue = {
717
+ ordinalNumber: Xe,
718
+ era: Q({
719
+ values: Ie,
720
+ defaultWidth: "wide"
721
+ }),
722
+ quarter: Q({
723
+ values: Le,
724
+ defaultWidth: "wide",
725
+ argumentCallback: (e) => e - 1
726
+ }),
727
+ month: Q({
728
+ values: Fe,
729
+ defaultWidth: "wide"
730
+ }),
731
+ day: Q({
732
+ values: qe,
733
+ defaultWidth: "wide"
734
+ }),
735
+ dayPeriod: Q({
736
+ values: Be,
737
+ defaultWidth: "wide",
738
+ formattingValues: ze,
739
+ defaultFormattingWidth: "wide"
740
+ })
741
+ }, Qe = /^(\d+)[ºªo]?/i, Ye = /\d+/i, Ge = {
742
+ narrow: /^(ac|dc|a|d)/i,
743
+ abbreviated: /^(a\.?\s?c\.?|d\.?\s?c\.?)/i,
744
+ wide: /^(antes de cristo|depois de cristo)/i
745
+ }, Je = {
746
+ any: [/^ac/i, /^dc/i],
747
+ wide: [/^antes de cristo/i, /^depois de cristo/i]
748
+ }, Ze = {
749
+ narrow: /^[1234]/i,
750
+ abbreviated: /^T[1234]/i,
751
+ wide: /^[1234](º)? trimestre/i
752
+ }, Ke = {
753
+ any: [/1/i, /2/i, /3/i, /4/i]
754
+ }, Me = {
755
+ narrow: /^[jfmajsond]/i,
756
+ abbreviated: /^(jan|fev|mar|abr|mai|jun|jul|ago|set|out|nov|dez)/i,
757
+ wide: /^(janeiro|fevereiro|março|abril|maio|junho|julho|agosto|setembro|outubro|novembro|dezembro)/i
758
+ }, et = {
759
+ narrow: [
760
+ /^j/i,
761
+ /^f/i,
762
+ /^m/i,
763
+ /^a/i,
764
+ /^m/i,
765
+ /^j/i,
766
+ /^j/i,
767
+ /^a/i,
768
+ /^s/i,
769
+ /^o/i,
770
+ /^n/i,
771
+ /^d/i
772
+ ],
773
+ any: [
774
+ /^ja/i,
775
+ /^fev/i,
776
+ /^mar/i,
777
+ /^abr/i,
778
+ /^mai/i,
779
+ /^jun/i,
780
+ /^jul/i,
781
+ /^ago/i,
782
+ /^set/i,
783
+ /^out/i,
784
+ /^nov/i,
785
+ /^dez/i
786
+ ]
787
+ }, tt = {
788
+ narrow: /^(dom|[23456]ª?|s[aá]b)/i,
789
+ short: /^(dom|[23456]ª?|s[aá]b)/i,
790
+ abbreviated: /^(dom|seg|ter|qua|qui|sex|s[aá]b)/i,
791
+ wide: /^(domingo|(segunda|ter[cç]a|quarta|quinta|sexta)([- ]feira)?|s[aá]bado)/i
792
+ }, nt = {
793
+ short: [/^d/i, /^2/i, /^3/i, /^4/i, /^5/i, /^6/i, /^s[aá]/i],
794
+ narrow: [/^d/i, /^2/i, /^3/i, /^4/i, /^5/i, /^6/i, /^s[aá]/i],
795
+ any: [/^d/i, /^seg/i, /^t/i, /^qua/i, /^qui/i, /^sex/i, /^s[aá]b/i]
796
+ }, rt = {
797
+ narrow: /^(a|p|mn|md|(da) (manhã|tarde|noite))/i,
798
+ any: /^([ap]\.?\s?m\.?|meia[-\s]noite|meio[-\s]dia|(da) (manhã|tarde|noite))/i
799
+ }, st = {
800
+ any: {
801
+ am: /^a/i,
802
+ pm: /^p/i,
803
+ midnight: /^mn|^meia[-\s]noite/i,
804
+ noon: /^md|^meio[-\s]dia/i,
805
+ morning: /manhã/i,
806
+ afternoon: /tarde/i,
807
+ evening: /tarde/i,
808
+ night: /noite/i
809
+ }
810
+ }, it = {
811
+ ordinalNumber: Ae({
812
+ matchPattern: Qe,
813
+ parsePattern: Ye,
814
+ valueCallback: (e) => parseInt(e, 10)
815
+ }),
816
+ era: Y({
817
+ matchPatterns: Ge,
818
+ defaultMatchWidth: "wide",
819
+ parsePatterns: Je,
820
+ defaultParseWidth: "any"
821
+ }),
822
+ quarter: Y({
823
+ matchPatterns: Ze,
824
+ defaultMatchWidth: "wide",
825
+ parsePatterns: Ke,
826
+ defaultParseWidth: "any",
827
+ valueCallback: (e) => e + 1
828
+ }),
829
+ month: Y({
830
+ matchPatterns: Me,
831
+ defaultMatchWidth: "wide",
832
+ parsePatterns: et,
833
+ defaultParseWidth: "any"
834
+ }),
835
+ day: Y({
836
+ matchPatterns: tt,
837
+ defaultMatchWidth: "wide",
838
+ parsePatterns: nt,
839
+ defaultParseWidth: "any"
840
+ }),
841
+ dayPeriod: Y({
842
+ matchPatterns: rt,
843
+ defaultMatchWidth: "any",
844
+ parsePatterns: st,
845
+ defaultParseWidth: "any"
846
+ })
847
+ }, at = {
848
+ code: "pt-BR",
849
+ formatDistance: De,
850
+ formatLong: Ce,
851
+ formatRelative: He,
852
+ localize: Ue,
853
+ match: it,
854
+ options: {
855
+ weekStartsOn: 0,
856
+ firstWeekContainsDate: 1
857
+ }
858
+ };
859
+ /**
860
+ * @license lucide-react v0.575.0 - ISC
861
+ *
862
+ * This source code is licensed under the ISC license.
863
+ * See the LICENSE file in the root directory of this source tree.
864
+ */
865
+ const ie = (...e) => e.filter((t, n, i) => !!t && t.trim() !== "" && i.indexOf(t) === n).join(" ").trim();
866
+ /**
867
+ * @license lucide-react v0.575.0 - ISC
868
+ *
869
+ * This source code is licensed under the ISC license.
870
+ * See the LICENSE file in the root directory of this source tree.
871
+ */
872
+ const ot = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
873
+ /**
874
+ * @license lucide-react v0.575.0 - ISC
875
+ *
876
+ * This source code is licensed under the ISC license.
877
+ * See the LICENSE file in the root directory of this source tree.
878
+ */
879
+ const ct = (e) => e.replace(
880
+ /^([A-Z])|[\s-_]+(\w)/g,
881
+ (t, n, i) => i ? i.toUpperCase() : n.toLowerCase()
882
+ );
883
+ /**
884
+ * @license lucide-react v0.575.0 - ISC
885
+ *
886
+ * This source code is licensed under the ISC license.
887
+ * See the LICENSE file in the root directory of this source tree.
888
+ */
889
+ const re = (e) => {
890
+ const t = ct(e);
891
+ return t.charAt(0).toUpperCase() + t.slice(1);
892
+ };
893
+ /**
894
+ * @license lucide-react v0.575.0 - ISC
895
+ *
896
+ * This source code is licensed under the ISC license.
897
+ * See the LICENSE file in the root directory of this source tree.
898
+ */
899
+ var dt = {
900
+ xmlns: "http://www.w3.org/2000/svg",
901
+ width: 24,
902
+ height: 24,
903
+ viewBox: "0 0 24 24",
904
+ fill: "none",
905
+ stroke: "currentColor",
906
+ strokeWidth: 2,
907
+ strokeLinecap: "round",
908
+ strokeLinejoin: "round"
909
+ };
910
+ /**
911
+ * @license lucide-react v0.575.0 - ISC
912
+ *
913
+ * This source code is licensed under the ISC license.
914
+ * See the LICENSE file in the root directory of this source tree.
915
+ */
916
+ const lt = (e) => {
917
+ for (const t in e)
918
+ if (t.startsWith("aria-") || t === "role" || t === "title")
919
+ return !0;
920
+ return !1;
921
+ };
922
+ /**
923
+ * @license lucide-react v0.575.0 - ISC
924
+ *
925
+ * This source code is licensed under the ISC license.
926
+ * See the LICENSE file in the root directory of this source tree.
927
+ */
928
+ const ut = se(
929
+ ({
930
+ color: e = "currentColor",
931
+ size: t = 24,
932
+ strokeWidth: n = 2,
933
+ absoluteStrokeWidth: i,
934
+ className: s = "",
935
+ children: d,
936
+ iconNode: l,
937
+ ...o
938
+ }, v) => Z(
939
+ "svg",
940
+ {
941
+ ref: v,
942
+ ...dt,
943
+ width: t,
944
+ height: t,
945
+ stroke: e,
946
+ strokeWidth: i ? Number(n) * 24 / Number(t) : n,
947
+ className: ie("lucide", s),
948
+ ...!d && !lt(o) && { "aria-hidden": "true" },
949
+ ...o
950
+ },
951
+ [
952
+ ...l.map(([a, p]) => Z(a, p)),
953
+ ...Array.isArray(d) ? d : [d]
954
+ ]
955
+ )
956
+ );
957
+ /**
958
+ * @license lucide-react v0.575.0 - ISC
959
+ *
960
+ * This source code is licensed under the ISC license.
961
+ * See the LICENSE file in the root directory of this source tree.
962
+ */
963
+ const M = (e, t) => {
964
+ const n = se(
965
+ ({ className: i, ...s }, d) => Z(ut, {
966
+ ref: d,
967
+ iconNode: t,
968
+ className: ie(
969
+ `lucide-${ot(re(e))}`,
970
+ `lucide-${e}`,
971
+ i
972
+ ),
973
+ ...s
974
+ })
975
+ );
976
+ return n.displayName = re(e), n;
977
+ };
978
+ /**
979
+ * @license lucide-react v0.575.0 - ISC
980
+ *
981
+ * This source code is licensed under the ISC license.
982
+ * See the LICENSE file in the root directory of this source tree.
983
+ */
984
+ const mt = [
985
+ ["path", { d: "M8 2v4", key: "1cmpym" }],
986
+ ["path", { d: "M16 2v4", key: "4m81vk" }],
987
+ ["rect", { width: "18", height: "18", x: "3", y: "4", rx: "2", key: "1hopcy" }],
988
+ ["path", { d: "M3 10h18", key: "8toen8" }]
989
+ ], ht = M("calendar", mt);
990
+ /**
991
+ * @license lucide-react v0.575.0 - ISC
992
+ *
993
+ * This source code is licensed under the ISC license.
994
+ * See the LICENSE file in the root directory of this source tree.
995
+ */
996
+ const ft = [["path", { d: "m15 18-6-6 6-6", key: "1wnfg3" }]], pt = M("chevron-left", ft);
997
+ /**
998
+ * @license lucide-react v0.575.0 - ISC
999
+ *
1000
+ * This source code is licensed under the ISC license.
1001
+ * See the LICENSE file in the root directory of this source tree.
1002
+ */
1003
+ const yt = [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]], vt = M("chevron-right", yt);
1004
+ function gt(e) {
1005
+ const t = G(null);
1006
+ return E(() => {
1007
+ function n(i) {
1008
+ t.current && !t.current.contains(i.target) && e();
1009
+ }
1010
+ return document.addEventListener("mousedown", n), () => {
1011
+ document.removeEventListener("mousedown", n);
1012
+ };
1013
+ }, [e]), t;
1014
+ }
1015
+ const ae = "dd/MM/yyyy", bt = (e) => {
1016
+ if (!e) return null;
1017
+ const t = ue(e, ae, /* @__PURE__ */ new Date());
1018
+ return me(t) ? t : null;
1019
+ }, wt = (e) => e ? K(e, ae) : "", Nt = ({
1020
+ name: e,
1021
+ label: t = "",
1022
+ placeholder: n = "dd/mm/aaaa",
1023
+ className: i = "",
1024
+ forceReadOnly: s = !1,
1025
+ forceHidden: d = !1,
1026
+ valueManual: l,
1027
+ onChangeManual: o,
1028
+ errorManual: v
1029
+ }) => {
1030
+ var k;
1031
+ const [a, p] = L(!1), [g, $] = L(/* @__PURE__ */ new Date()), V = gt(() => p(!1)), A = l !== void 0 && !!o;
1032
+ let _ = null;
1033
+ try {
1034
+ _ = H();
1035
+ } catch {
1036
+ }
1037
+ const { isView: W } = I(), { isReadOnly: w, isHidden: f } = F(), u = s || !!w(e), m = d || !!f(e), c = !A && _ ? X({ name: e, control: _.control }) : null, h = A ? l : c == null ? void 0 : c.field.value, y = A ? v : (k = c == null ? void 0 : c.fieldState.error) == null ? void 0 : k.message, x = B(() => bt(h), [h]), D = (S) => {
1038
+ if (u) return;
1039
+ const O = wt(S);
1040
+ A ? o == null || o(O) : c == null || c.field.onChange(O), p(!1);
1041
+ }, R = (S) => {
1042
+ const O = he({
1043
+ start: ye(ve(S)),
1044
+ end: fe(pe(S))
1045
+ });
1046
+ return /* @__PURE__ */ N("div", { className: "dfe-calendar-pane", children: [
1047
+ /* @__PURE__ */ N("div", { className: "dfe-calendar-header", children: [
1048
+ /* @__PURE__ */ r(
1049
+ "button",
1050
+ {
1051
+ type: "button",
1052
+ onClick: (b) => {
1053
+ b.stopPropagation(), $(ge(g, 1));
1054
+ },
1055
+ className: "dfe-nav-btn",
1056
+ children: /* @__PURE__ */ r(pt, { size: 16 })
1057
+ }
1058
+ ),
1059
+ /* @__PURE__ */ r("span", { className: "dfe-month-label", children: K(S, "MMMM yyyy", { locale: at }) }),
1060
+ /* @__PURE__ */ r(
1061
+ "button",
1062
+ {
1063
+ type: "button",
1064
+ onClick: (b) => {
1065
+ b.stopPropagation(), $(be(g, 1));
1066
+ },
1067
+ className: "dfe-nav-btn",
1068
+ children: /* @__PURE__ */ r(vt, { size: 16 })
1069
+ }
1070
+ )
1071
+ ] }),
1072
+ /* @__PURE__ */ r("div", { className: "dfe-calendar-grid-header", children: ["D", "S", "T", "Q", "Q", "S", "S"].map((b, T) => /* @__PURE__ */ r("span", { children: b }, T)) }),
1073
+ /* @__PURE__ */ r("div", { className: "dfe-calendar-grid", children: O.map((b, T) => {
1074
+ const q = !we(b, S), U = x && Ne(b, x);
1075
+ return /* @__PURE__ */ r(
1076
+ "div",
1077
+ {
1078
+ onClick: () => !q && D(b),
1079
+ className: `dfe-calendar-day
1080
+ ${U ? "selected" : ""}
1081
+ ${q ? "outside" : ""}
1082
+ ${ke(b) ? "today" : ""}`,
1083
+ children: K(b, "d")
1084
+ },
1085
+ T
1086
+ );
1087
+ }) })
1088
+ ] });
1089
+ };
1090
+ return m ? null : W ? /* @__PURE__ */ N("div", { className: `form-group ${i}`, children: [
1091
+ t && /* @__PURE__ */ r("label", { children: t }),
1092
+ /* @__PURE__ */ r(
1093
+ "span",
1094
+ {
1095
+ className: "form-control readOnly",
1096
+ style: { display: "block", height: "auto" },
1097
+ children: h || "-"
1098
+ }
1099
+ )
1100
+ ] }) : /* @__PURE__ */ N(
1101
+ "div",
1102
+ {
1103
+ ref: V,
1104
+ className: `form-group dfe-datepicker-container ${i}`,
1105
+ style: { position: "relative" },
1106
+ children: [
1107
+ t && /* @__PURE__ */ r("label", { children: t }),
1108
+ /* @__PURE__ */ N(
1109
+ "div",
1110
+ {
1111
+ className: `form-control dfe-datepicker-trigger ${y ? "border-red" : ""} ${u ? "disabled" : ""}`,
1112
+ onClick: () => !u && p(!a),
1113
+ style: {
1114
+ display: "flex",
1115
+ alignItems: "center",
1116
+ cursor: u ? "default" : "pointer"
1117
+ },
1118
+ children: [
1119
+ /* @__PURE__ */ r(
1120
+ ht,
1121
+ {
1122
+ size: 16,
1123
+ className: "dfe-calendar-icon",
1124
+ style: { marginRight: "8px", opacity: 0.5 }
1125
+ }
1126
+ ),
1127
+ /* @__PURE__ */ r("span", { children: h || n })
1128
+ ]
1129
+ }
1130
+ ),
1131
+ a && !u && /* @__PURE__ */ r("div", { className: "dfe-popover-content", children: /* @__PURE__ */ r("div", { className: "dfe-calendars-wrapper", children: R(g) }) }),
1132
+ y && /* @__PURE__ */ r("p", { className: "text-danger", children: String(y) })
1133
+ ]
1134
+ }
1135
+ );
1136
+ }, Et = z(Nt);
1137
+ function kt({
1138
+ mapping: e = {},
1139
+ defaultLabel: t = "Não reconhecido",
1140
+ className: n = "",
1141
+ hidden: i = !1,
1142
+ label: s
1143
+ }) {
1144
+ const { activityId: d } = I(), l = B(() => !e || d === null || d === void 0 ? null : e[d], [d, e]);
1145
+ if (!l)
1146
+ return /* @__PURE__ */ N("div", { className: `form-group ${i ? "hidden" : ""}`, children: [
1147
+ s && /* @__PURE__ */ r("label", { children: s }),
1148
+ /* @__PURE__ */ r("div", { className: `status-badge default ${n}`, children: t })
1149
+ ] });
1150
+ const o = {
1151
+ "--customColor": l.color
1152
+ };
1153
+ return /* @__PURE__ */ N("div", { className: `form-group ${i ? "hidden" : ""}`, children: [
1154
+ s && /* @__PURE__ */ r("label", { children: s }),
1155
+ /* @__PURE__ */ N("div", { className: `status-badge ${n}`, style: o, children: [
1156
+ l.icon && /* @__PURE__ */ r("i", { className: l.icon }),
1157
+ /* @__PURE__ */ r("span", { children: l.label })
1158
+ ] })
1159
+ ] });
1160
+ }
1161
+ const Ht = z(kt);
1162
+ function xt({
1163
+ name: e,
1164
+ control: t,
1165
+ defaultRowValue: n,
1166
+ isView: i,
1167
+ isReadOnly: s,
1168
+ filters: d = []
1169
+ }) {
1170
+ const { field: l } = X({ name: e, control: t }), [o, v] = L([]), [a, p] = L([]), g = () => Date.now() + Math.random(), $ = (m) => {
1171
+ try {
1172
+ const c = JSON.parse(m);
1173
+ return Array.isArray(c) ? c.map((h) => ({
1174
+ ...h,
1175
+ _uid: h._uid || g()
1176
+ })) : [];
1177
+ } catch (c) {
1178
+ return console.error(`Erro ao ler dados da tabela "${e}":`, c), [];
1179
+ }
1180
+ };
1181
+ E(() => {
1182
+ if (!(o.length > 0 && !i) && l.value && typeof l.value == "string") {
1183
+ const m = JSON.stringify(o);
1184
+ if (l.value === m) return;
1185
+ const c = $(l.value);
1186
+ v(c);
1187
+ }
1188
+ }, [l.value, i]), E(() => {
1189
+ if (s) return;
1190
+ const m = JSON.stringify(o);
1191
+ l.value !== m && l.onChange(m);
1192
+ }, [o, l, s]);
1193
+ const V = C(() => {
1194
+ const m = { _uid: g(), ...n };
1195
+ v((c) => [...c, m]);
1196
+ }, [n]), A = C(() => {
1197
+ v(
1198
+ (m) => m.filter((c) => !a.includes(c._uid))
1199
+ ), p([]);
1200
+ }, [a]), _ = C(
1201
+ (m, c, h) => {
1202
+ v(
1203
+ (y) => y.map(
1204
+ (x) => x._uid === m ? { ...x, [c]: h } : x
1205
+ )
1206
+ );
1207
+ },
1208
+ []
1209
+ ), W = C((m) => {
1210
+ p(
1211
+ (c) => c.includes(m) ? c.filter((h) => h !== m) : [...c, m]
1212
+ );
1213
+ }, []), w = C(
1214
+ (m) => {
1215
+ p(m ? o.map((c) => c._uid) : []);
1216
+ },
1217
+ [o]
1218
+ ), f = o.length > 0 && a.length === o.length, u = B(() => !d || d.length === 0 ? o : o.filter(
1219
+ (m) => d.every((c) => {
1220
+ if ("custom" in c)
1221
+ return c.custom(m);
1222
+ const h = m[c.field];
1223
+ switch (c.operator) {
1224
+ case "===":
1225
+ return h === c.value;
1226
+ case "!==":
1227
+ return h !== c.value;
1228
+ case ">":
1229
+ return h > c.value;
1230
+ case "<":
1231
+ return h < c.value;
1232
+ case ">=":
1233
+ return h >= c.value;
1234
+ case "<=":
1235
+ return h <= c.value;
1236
+ default:
1237
+ return !0;
1238
+ }
1239
+ })
1240
+ ), [o, d]);
1241
+ return {
1242
+ field: l,
1243
+ tableRows: o,
1244
+ visibleRows: u,
1245
+ selectedRowIds: a,
1246
+ isAllSelected: f,
1247
+ handle: {
1248
+ addRow: V,
1249
+ removeRows: A,
1250
+ updateCellValue: _,
1251
+ toggleSelection: W,
1252
+ toggleSelectAll: w
1253
+ }
1254
+ };
1255
+ }
1256
+ const It = ({
1257
+ name: e,
1258
+ title: t = "Tabela Dinâmica",
1259
+ columns: n,
1260
+ defaultRowValue: i = {},
1261
+ forceReadOnly: s = !1,
1262
+ layout: d = "fluid",
1263
+ actions: l = !0,
1264
+ filters: o = []
1265
+ }) => {
1266
+ const { control: v } = H(), { isView: a, isReadOnly: p } = I(), { isReadOnly: g } = F(), $ = s || a || p || g && g(e), { field: V, visibleRows: A, selectedRowIds: _, isAllSelected: W, handle: w } = xt({
1267
+ name: e,
1268
+ control: v,
1269
+ defaultRowValue: i,
1270
+ isView: a,
1271
+ isReadOnly: !!$,
1272
+ filters: o
1273
+ }), f = d === "fixed";
1274
+ return /* @__PURE__ */ N("div", { className: `table-wrapper ${f ? "table-fixed" : "table-fluid"}`, children: [
1275
+ /* @__PURE__ */ r("input", { type: "hidden", ...V }),
1276
+ /* @__PURE__ */ N("div", { className: "header-handle", children: [
1277
+ /* @__PURE__ */ r("h3", { children: t }),
1278
+ !$ && l && /* @__PURE__ */ N("div", { className: "handle-actions", children: [
1279
+ /* @__PURE__ */ N(
1280
+ "button",
1281
+ {
1282
+ type: "button",
1283
+ className: `btn ${_.length > 0 ? "btn-danger" : "btn-primary"}`,
1284
+ disabled: _.length === 0,
1285
+ onClick: w.removeRows,
1286
+ children: [
1287
+ "Remover (",
1288
+ _.length,
1289
+ ")"
1290
+ ]
1291
+ }
1292
+ ),
1293
+ /* @__PURE__ */ r("button", { type: "button", className: "btn-add", onClick: w.addRow, children: "Adicionar" })
1294
+ ] })
1295
+ ] }),
1296
+ /* @__PURE__ */ r("div", { className: "table-scroll", children: /* @__PURE__ */ N("table", { className: "table-custom", children: [
1297
+ /* @__PURE__ */ r("thead", { children: /* @__PURE__ */ N("tr", { children: [
1298
+ !$ && /* @__PURE__ */ r("th", { style: { width: "50px" }, children: /* @__PURE__ */ r(
1299
+ "input",
1300
+ {
1301
+ type: "checkbox",
1302
+ checked: W,
1303
+ onChange: (u) => w.toggleSelectAll(u.target.checked)
1304
+ }
1305
+ ) }),
1306
+ n.map((u) => /* @__PURE__ */ r(
1307
+ "th",
1308
+ {
1309
+ style: u.width ? { minWidth: f ? u.width : "100%" } : { width: "max-content" },
1310
+ children: u.label
1311
+ },
1312
+ u.key
1313
+ ))
1314
+ ] }) }),
1315
+ /* @__PURE__ */ N("tbody", { children: [
1316
+ A.map((u, m) => /* @__PURE__ */ N("tr", { children: [
1317
+ !$ && /* @__PURE__ */ r("td", { children: /* @__PURE__ */ r(
1318
+ "input",
1319
+ {
1320
+ type: "checkbox",
1321
+ checked: _.includes(u._uid),
1322
+ onChange: () => w.toggleSelection(u._uid)
1323
+ }
1324
+ ) }),
1325
+ n.map((c) => /* @__PURE__ */ r("td", { children: c.render ? c.render.length <= 1 ? c.render({
1326
+ row: u,
1327
+ index: m,
1328
+ updateRow: (h, y) => w.updateCellValue(u._uid, h, y),
1329
+ isLocked: !!$,
1330
+ isView: !!a
1331
+ }) : c.render(
1332
+ u,
1333
+ m,
1334
+ (h, y) => w.updateCellValue(u._uid, h, y),
1335
+ !!$,
1336
+ !!a
1337
+ ) : u[c.key] }, `${u._uid}-${c.key}`))
1338
+ ] }, u._uid)),
1339
+ A.length === 0 && /* @__PURE__ */ r("tr", { className: "empty-row", children: /* @__PURE__ */ r("td", { colSpan: 100, className: "text-center", children: $ ? "Nenhum registro encontrado." : "Nenhum registro." }) })
1340
+ ] })
1341
+ ] }) })
1342
+ ] });
1343
+ }, Rt = (e, t) => {
1344
+ const [n, i] = L(null);
1345
+ let s = null;
1346
+ try {
1347
+ s = H().watch;
1348
+ } catch {
1349
+ }
1350
+ const d = t !== void 0 ? t : s ? s(e) : void 0, l = C(() => {
1351
+ try {
1352
+ const v = window.top.__REACT_ATTACHMENT_BRIDGE__;
1353
+ if (v) {
1354
+ const a = v.getAttachment(e, d);
1355
+ i(a || (d ? { name: d, documentId: 0 } : null));
1356
+ } else
1357
+ i(d ? { name: d, documentId: 0 } : null);
1358
+ } catch {
1359
+ i(d ? { name: d, documentId: 0 } : null);
1360
+ }
1361
+ }, [e, d, t]);
1362
+ return E(() => {
1363
+ l();
1364
+ const o = setInterval(l, 2e3);
1365
+ return () => clearInterval(o);
1366
+ }, [l]), { attachment: n, sync: l };
1367
+ }, St = ({
1368
+ name: e,
1369
+ label: t,
1370
+ help: n,
1371
+ valueManual: i,
1372
+ onChangeManual: s,
1373
+ forceReadOnly: d = !1,
1374
+ forceHidden: l = !1
1375
+ }) => {
1376
+ const o = i !== void 0 && !!s, { isReadOnly: v, isHidden: a } = F(), p = d || !!v(e), g = l || !!a(e), { isView: $ } = I(), [V, A] = L(!1);
1377
+ let _ = null;
1378
+ try {
1379
+ _ = H().control;
1380
+ } catch {
1381
+ }
1382
+ const W = _ && !o ? X({ name: e, control: _ }).field : {
1383
+ value: i,
1384
+ onChange: (R) => s == null ? void 0 : s(R)
1385
+ }, { attachment: w, sync: f } = Rt(e, i), u = () => {
1386
+ var R;
1387
+ try {
1388
+ const k = window.top;
1389
+ return {
1390
+ bridge: k.__REACT_ATTACHMENT_BRIDGE__,
1391
+ toast: (R = k.FLUIGC) == null ? void 0 : R.toast
1392
+ };
1393
+ } catch {
1394
+ return { bridge: null, toast: null };
1395
+ }
1396
+ }, m = C(() => {
1397
+ if (p || $) return;
1398
+ const R = document.createElement("input");
1399
+ R.type = "file", R.onchange = (k) => {
1400
+ const S = k.target.files[0];
1401
+ if (!S) return;
1402
+ const { bridge: O, toast: b } = u();
1403
+ A(!0), O ? O.upload(S, e, (T) => {
1404
+ o ? s == null || s(T.name) : W.onChange(T.name), setTimeout(() => {
1405
+ A(!1), f();
1406
+ }, 1e3), b && b({
1407
+ title: "Sucesso",
1408
+ message: "Arquivo enviado",
1409
+ type: "success"
1410
+ });
1411
+ }) : (o ? s == null || s(S.name) : W.onChange(S.name), A(!1));
1412
+ }, R.click();
1413
+ }, [e, W, f, s, p, o, $]), c = (R) => {
1414
+ if (R.stopPropagation(), p || $) return;
1415
+ const k = (w == null ? void 0 : w.name) || i || W.value;
1416
+ if (!k) return;
1417
+ const { bridge: S, toast: O } = u();
1418
+ S ? S.removeByFileName(k) ? (o ? s == null || s("") : W.onChange(""), f()) : O && O({
1419
+ title: "Erro",
1420
+ message: "Erro ao remover anexo",
1421
+ type: "danger"
1422
+ }) : (o ? s == null || s("") : W.onChange(""), f());
1423
+ }, h = !!w && !V, y = (w == null ? void 0 : w.name) || i || W.value, x = [
1424
+ "fluig-attachment__box",
1425
+ h ? "fluig-attachment__box--has-file" : "",
1426
+ V ? "fluig-attachment__box--uploading" : "",
1427
+ p ? "readOnly" : ""
1428
+ ].join(" "), D = (p || $) && !h;
1429
+ return $ ? /* @__PURE__ */ N("div", { className: `form-group fluig-attachment ${g ? "hidden" : ""}`, children: [
1430
+ t && /* @__PURE__ */ r("label", { className: "fluig-attachment__label", children: t }),
1431
+ /* @__PURE__ */ r("span", { className: "fluig-attachment__box readOnly", children: y || "-" })
1432
+ ] }) : /* @__PURE__ */ N("div", { className: `form-group fluig-attachment ${g ? "hidden" : ""}`, children: [
1433
+ t && /* @__PURE__ */ r("label", { className: "fluig-attachment__label", children: t }),
1434
+ /* @__PURE__ */ N(
1435
+ "div",
1436
+ {
1437
+ className: x,
1438
+ style: D ? { pointerEvents: "none", opacity: 0.6, cursor: "not-allowed" } : {},
1439
+ onClick: () => {
1440
+ if (h) {
1441
+ const R = u();
1442
+ R.bridge && y && R.bridge.view(y);
1443
+ } else
1444
+ m();
1445
+ },
1446
+ children: [
1447
+ /* @__PURE__ */ N("span", { className: "fluig-attachment__content", children: [
1448
+ /* @__PURE__ */ r(
1449
+ "i",
1450
+ {
1451
+ className: `fluigicon icon-sm ${V ? "fluigicon-loop-test" : h ? "fluigicon-file-pdf" : "fluigicon-paperclip"} fluig-attachment__icon`
1452
+ }
1453
+ ),
1454
+ /* @__PURE__ */ r("span", { className: "fluig-attachment__filename", children: V ? " Enviando..." : h ? y : p ? "Nenhum arquivo" : n || "Anexar" })
1455
+ ] }),
1456
+ h && !p && !$ && /* @__PURE__ */ r(
1457
+ "button",
1458
+ {
1459
+ type: "button",
1460
+ className: "fluig-attachment__btn-remove btn btn-link text-danger",
1461
+ onClick: c,
1462
+ children: /* @__PURE__ */ r("i", { className: "flaticon flaticon-trash icon-sm" })
1463
+ }
1464
+ )
1465
+ ]
1466
+ }
1467
+ ),
1468
+ !o && _ && /* @__PURE__ */ r("input", { type: "hidden", name: e, value: W.value || "" })
1469
+ ] });
1470
+ }, Lt = z(St);
1471
+ function Ft({
1472
+ title: e,
1473
+ isOpen: t,
1474
+ onOpen: n,
1475
+ onClose: i,
1476
+ content: s,
1477
+ footer: d,
1478
+ width: l
1479
+ }) {
1480
+ const o = C(
1481
+ (v) => {
1482
+ v.key === "Escape" && i();
1483
+ },
1484
+ [i]
1485
+ );
1486
+ return E(() => (t && (document.addEventListener("keydown", o), n == null || n(), document.body.style.overflow = "hidden"), () => {
1487
+ document.removeEventListener("keydown", o), document.body.style.overflow = "auto";
1488
+ }), [t, o, n]), t ? /* @__PURE__ */ r(
1489
+ "div",
1490
+ {
1491
+ className: "modal-overlay",
1492
+ onClick: i,
1493
+ "aria-modal": "true",
1494
+ role: "dialog",
1495
+ children: /* @__PURE__ */ N(
1496
+ "div",
1497
+ {
1498
+ style: { maxWidth: l },
1499
+ className: "modal-container",
1500
+ onClick: (v) => v.stopPropagation(),
1501
+ children: [
1502
+ /* @__PURE__ */ N("div", { className: "modal-header", children: [
1503
+ /* @__PURE__ */ r("h3", { children: e }),
1504
+ /* @__PURE__ */ r(
1505
+ "div",
1506
+ {
1507
+ className: "btn-close-modal",
1508
+ onClick: i,
1509
+ role: "button",
1510
+ "aria-label": "Fechar modal",
1511
+ children: /* @__PURE__ */ r(
1512
+ "i",
1513
+ {
1514
+ className: "flaticon flaticon-close icon-md",
1515
+ "aria-hidden": "true"
1516
+ }
1517
+ )
1518
+ }
1519
+ )
1520
+ ] }),
1521
+ /* @__PURE__ */ r("div", { className: "modal-content", children: s }),
1522
+ d && /* @__PURE__ */ r("div", { className: "modal-footer", children: d })
1523
+ ]
1524
+ }
1525
+ )
1526
+ }
1527
+ ) : null;
1528
+ }
1529
+ export {
1530
+ Lt as Attachment,
1531
+ Tt as Checkbox,
1532
+ Et as DatePicker,
1533
+ Dt as Input,
1534
+ Ft as Modal,
1535
+ jt as RadioBtn,
1536
+ Vt as Select,
1537
+ It as SimpleTable,
1538
+ Ht as StatusBadge,
1539
+ Ct as TextArea
1540
+ };