diefra_ecm_ui 1.1.0 → 1.2.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 CHANGED
@@ -1,431 +1,477 @@
1
- import { jsxs as w, jsx as t, Fragment as ae } from "react/jsx-runtime";
2
- import { memo as W, useMemo as j, useCallback as C, useState as U, useRef as q, useEffect as H, forwardRef as re, createElement as Q } from "react";
3
- import { useFormContext as F, useController as z, useFormState as ne } from "react-hook-form";
4
- import { IMaskInput as ue } from "react-imask";
5
- import { useSection as Y, useFluigRuntime as P } from "@fluig-kit/ecm";
6
- import { isValid as le, eachDayOfInterval as fe, endOfWeek as he, endOfMonth as me, startOfWeek as pe, startOfMonth as ve, getYear as ye, subMonths as ge, setMonth as be, setYear as Ne, addMonths as ke, isSameMonth as we, isSameDay as _e, format as ce, isToday as Se, parse as Re } from "date-fns";
7
- const Oe = {
1
+ import { jsx as e, jsxs as h, Fragment as ce } from "react/jsx-runtime";
2
+ import { useCallback as j, useEffect as T, memo as q, useState as P, useMemo as z, useRef as X, forwardRef as de, createElement as K } from "react";
3
+ import { useFormContext as U, useController as W, useFormState as oe } from "react-hook-form";
4
+ import { IMaskInput as pe } from "react-imask";
5
+ import { useSection as G, useFluigRuntime as Y } from "@fluig-kit/ecm";
6
+ import { isValid as ae, eachDayOfInterval as ve, endOfWeek as ye, endOfMonth as be, startOfWeek as ge, startOfMonth as Ne, getYear as ke, subMonths as we, setMonth as _e, setYear as Oe, addMonths as Se, isSameMonth as Re, isSameDay as $e, format as ue, isToday as xe, parse as Ae } from "date-fns";
7
+ function Ie({ title: t, isOpen: l, onOpen: a, onClose: f, content: c, footer: o, width: m }) {
8
+ const d = j(
9
+ (p) => {
10
+ p.key === "Escape" && f();
11
+ },
12
+ [f]
13
+ );
14
+ return T(() => (l && (document.addEventListener("keydown", d), a == null || a(), document.body.style.overflow = "hidden"), () => {
15
+ document.removeEventListener("keydown", d), document.body.style.overflow = "auto";
16
+ }), [l, d, a]), l ? /* @__PURE__ */ e("div", { className: "modal-overlay", onClick: f, "aria-modal": "true", role: "dialog", children: /* @__PURE__ */ h("div", { style: { maxWidth: m }, className: "modal-container", onClick: (p) => p.stopPropagation(), children: [
17
+ /* @__PURE__ */ h("div", { className: "modal-header", children: [
18
+ /* @__PURE__ */ e("h3", { children: t }),
19
+ /* @__PURE__ */ e("div", { className: "btn-close-modal", onClick: f, role: "button", "aria-label": "Fechar modal", children: /* @__PURE__ */ e("i", { className: "flaticon flaticon-close icon-sm", "aria-hidden": "true" }) })
20
+ ] }),
21
+ /* @__PURE__ */ e("div", { className: "modal-content", children: c }),
22
+ o && /* @__PURE__ */ e("div", { className: "modal-footer", children: o })
23
+ ] }) }) : null;
24
+ }
25
+ function Ve({ text: t, title: l = "Ajuda & Informações", width: a = "500px", className: f = "" }) {
26
+ const [c, o] = P(!1), m = (d) => {
27
+ d.preventDefault(), d.stopPropagation(), o(!0);
28
+ };
29
+ return /* @__PURE__ */ h(ce, { children: [
30
+ /* @__PURE__ */ e(
31
+ "div",
32
+ {
33
+ className: `dfe-help-indicator ${f}`,
34
+ onClick: m,
35
+ role: "button",
36
+ tabIndex: 0,
37
+ "aria-label": "Botão de ajuda",
38
+ title: "Clique para obter ajuda",
39
+ children: /* @__PURE__ */ e("span", { children: "?" })
40
+ }
41
+ ),
42
+ /* @__PURE__ */ e(
43
+ Ie,
44
+ {
45
+ title: l,
46
+ isOpen: c,
47
+ onClose: () => o(!1),
48
+ width: a,
49
+ content: /* @__PURE__ */ e("div", { className: "dfe-help-modal-body", children: t }),
50
+ footer: /* @__PURE__ */ e("div", { className: "dfe-help-modal-footer", children: /* @__PURE__ */ e("button", { type: "button", className: "btn btn-info dfe-help-btn", onClick: () => o(!1), children: "Entendido" }) })
51
+ }
52
+ )
53
+ ] });
54
+ }
55
+ const Z = q(Ve), Ee = {
8
56
  cpf: "000.000.000-00",
9
57
  cnpj: "00.000.000/0000-00",
10
58
  telefone: "(00) 00000-0000",
11
59
  cep: "00000-000"
12
60
  };
13
- function xe({
14
- name: e,
15
- label: r = "",
16
- placeholder: u = "",
17
- type: h = "text",
61
+ function De({
62
+ name: t,
63
+ label: l = "",
64
+ placeholder: a = "",
65
+ type: f = "text",
18
66
  mask: c,
19
- className: d = "",
67
+ className: o = "",
20
68
  forceReadOnly: m = !1,
21
- forceHidden: i = !1,
22
- valueManual: b,
23
- onChangeManual: s,
24
- errorManual: _
69
+ forceHidden: d = !1,
70
+ helpText: p,
71
+ helpTitle: i,
72
+ helpWidth: v,
73
+ valueManual: x,
74
+ onChangeManual: S,
75
+ errorManual: C
25
76
  }) {
26
- var $, V;
27
- const y = b !== void 0 && !!s, { isReadOnly: A, isHidden: I } = Y(), E = m || !!A(e), N = i || !!I(e), { isView: T } = P();
28
- let f = null;
77
+ var E, L;
78
+ const y = x !== void 0 && !!S, { isReadOnly: R, isHidden: D } = G(), _ = m || !!R(t), g = d || !!D(t), { isView: r } = Y();
79
+ let n = null;
29
80
  try {
30
- f = F();
81
+ n = U();
31
82
  } catch {
32
83
  }
33
- const p = !y && f ? z({ name: e, control: f.control }) : null, n = !y && f ? ne({ name: e }) : null, a = y ? b : p == null ? void 0 : p.field.value, l = y ? _ : (V = ($ = n == null ? void 0 : n.errors) == null ? void 0 : $[e]) == null ? void 0 : V.message, o = j(
34
- () => c ? Oe[c] ?? c : null,
35
- [c]
36
- ), g = C((S) => {
37
- if (!S) return "";
38
- const k = S.replace(/\D/g, "");
39
- return (Number(k) / 100).toLocaleString("pt-BR", {
84
+ const s = !y && n ? W({ name: t, control: n.control }) : null, u = !y && n ? oe({ name: t }) : null, k = y ? x : s == null ? void 0 : s.field.value, I = y ? C : (L = (E = u == null ? void 0 : u.errors) == null ? void 0 : E[t]) == null ? void 0 : L.message, B = z(() => c ? Ee[c] ?? c : null, [c]), V = j((H) => {
85
+ if (!H) return "";
86
+ const J = H.replace(/\D/g, "");
87
+ return (Number(J) / 100).toLocaleString("pt-BR", {
40
88
  style: "currency",
41
89
  currency: "BRL"
42
90
  });
43
- }, []), D = C(
44
- (S) => h === "monetary" ? g(S) : S,
45
- [h, g]
46
- ), O = (S) => {
47
- const k = D(S);
48
- y ? s == null || s(k) : p == null || p.field.onChange(k);
49
- }, x = () => {
50
- y || p == null || p.field.onBlur();
91
+ }, []), O = j(
92
+ (H) => f === "monetary" ? V(H) : H,
93
+ [f, V]
94
+ ), w = (H) => {
95
+ const J = O(H);
96
+ y ? S == null || S(J) : s == null || s.field.onChange(J);
97
+ }, N = () => {
98
+ y || s == null || s.field.onBlur();
51
99
  };
52
- if (T)
53
- return /* @__PURE__ */ w("div", { className: "form-group", children: [
54
- /* @__PURE__ */ t("label", { children: r }),
55
- /* @__PURE__ */ t("span", { className: "form-control", children: a || "-" })
56
- ] });
57
- const v = `form-control ${E ? "readOnly" : ""} ${l ? "border-red" : ""} ${d}`;
58
- return /* @__PURE__ */ w("div", { className: `form-group ${N ? "hidden" : ""}`, children: [
59
- r && /* @__PURE__ */ t("label", { children: r }),
60
- o ? /* @__PURE__ */ t(
61
- ue,
62
- {
63
- name: e,
64
- mask: o,
65
- value: String(a ?? ""),
66
- unmask: !1,
67
- onAccept: (S) => O(S),
68
- placeholder: u,
69
- readOnly: E,
70
- className: v,
71
- inputRef: y || p == null ? void 0 : p.field.ref,
72
- onBlur: x
73
- }
74
- ) : /* @__PURE__ */ t(
75
- "input",
76
- {
77
- type: "text",
78
- name: e,
79
- value: a ?? "",
80
- onChange: (S) => O(S.target.value),
81
- onBlur: x,
82
- placeholder: u,
83
- readOnly: E,
84
- className: v
85
- }
86
- ),
87
- l && /* @__PURE__ */ t("p", { className: "text-danger", children: String(l) })
100
+ if (g) return null;
101
+ const A = `form-control ${_ ? "readOnly" : ""} ${I ? "border-red" : ""} ${o}`, b = () => B ? /* @__PURE__ */ e(
102
+ pe,
103
+ {
104
+ name: t,
105
+ mask: B,
106
+ value: String(k ?? ""),
107
+ unmask: !1,
108
+ onAccept: (H) => w(H),
109
+ placeholder: a,
110
+ readOnly: _,
111
+ className: A,
112
+ inputRef: y || s == null ? void 0 : s.field.ref,
113
+ onBlur: N
114
+ }
115
+ ) : /* @__PURE__ */ e(
116
+ "input",
117
+ {
118
+ type: f === "number" ? "number" : "text",
119
+ name: t,
120
+ value: k ?? "",
121
+ onChange: (H) => w(H.target.value),
122
+ onBlur: N,
123
+ placeholder: a,
124
+ readOnly: _,
125
+ className: A
126
+ }
127
+ );
128
+ return r ? /* @__PURE__ */ h("div", { className: "form-group", children: [
129
+ l && /* @__PURE__ */ e("label", { children: l }),
130
+ /* @__PURE__ */ h("div", { className: p ? "dfe-flex-input-wrapper" : "", children: [
131
+ /* @__PURE__ */ e("span", { className: A, children: k || "-" }),
132
+ p && /* @__PURE__ */ e(Z, { text: p, title: i, width: v })
133
+ ] })
134
+ ] }) : /* @__PURE__ */ h("div", { className: `form-group ${g ? "hidden" : ""}`, children: [
135
+ l && /* @__PURE__ */ e("label", { children: l }),
136
+ /* @__PURE__ */ h("div", { className: p ? "dfe-flex-input-wrapper" : "", children: [
137
+ b(),
138
+ p && /* @__PURE__ */ e(Z, { text: p, title: i, width: v })
139
+ ] }),
140
+ I && /* @__PURE__ */ e("p", { className: "text-danger", children: String(I) })
88
141
  ] });
89
142
  }
90
- const rt = W(xe);
91
- function $e({
92
- name: e,
93
- label: r = "",
94
- options: u = [],
95
- placeholder: h = "",
143
+ const ot = q(De);
144
+ function Be({
145
+ name: t,
146
+ label: l = "",
147
+ options: a = [],
148
+ placeholder: f = "",
96
149
  labelKey: c = "label",
97
- valueKey: d = "value",
150
+ valueKey: o = "value",
98
151
  enableSearch: m = !1,
99
- searchPlaceholder: i = "Buscar...",
100
- loading: b = !1,
101
- onSearchChange: s,
102
- debounceTime: _ = 300,
103
- onSelect: y,
104
- forceReadOnly: A = !1,
105
- forceHidden: I = !1,
106
- valueManual: E,
107
- onChangeManual: N,
108
- errorManual: T
152
+ searchPlaceholder: d = "Buscar...",
153
+ loading: p = !1,
154
+ onSearchChange: i,
155
+ debounceTime: v = 300,
156
+ onSelect: x,
157
+ forceReadOnly: S = !1,
158
+ forceHidden: C = !1,
159
+ helpText: y,
160
+ helpTitle: R,
161
+ helpWidth: D,
162
+ valueManual: _,
163
+ onChangeManual: g,
164
+ errorManual: r
109
165
  }) {
110
- var K;
111
- const f = E !== void 0 && !!N, { isReadOnly: p, isHidden: n } = Y(), a = A || !!p(e), l = I || !!n(e), { isView: o } = P();
112
- let g = "", D = () => {
113
- }, O, x = null, v = () => {
166
+ var se;
167
+ const n = _ !== void 0 && !!g, { isReadOnly: s, isHidden: u } = G(), k = S || !!s(t), I = C || !!u(t), { isView: B } = Y();
168
+ let V = "", O = () => {
169
+ }, w, N = null, A = () => {
114
170
  };
115
- if (f)
116
- g = E;
171
+ if (n)
172
+ V = _;
117
173
  else
118
174
  try {
119
- const R = F(), B = z({ name: e, control: R.control });
120
- g = B.field.value, D = B.field.onChange, O = B.field.ref, x = (K = B.fieldState) == null ? void 0 : K.error, v = R.clearErrors;
175
+ const $ = U(), F = W({ name: t, control: $.control });
176
+ V = F.field.value, O = F.field.onChange, w = F.field.ref, N = (se = F.fieldState) == null ? void 0 : se.error, A = $.clearErrors;
121
177
  } catch {
122
178
  }
123
- const [$, V] = U(!1), [S, k] = U(""), L = q(null), J = q(s);
124
- H(() => {
125
- J.current = s;
126
- }, [s]), H(() => {
127
- const R = (B) => {
128
- L.current && !L.current.contains(B.target) && V(!1);
179
+ const [b, E] = P(!1), [L, H] = P(""), J = X(null), Q = X(i);
180
+ T(() => {
181
+ Q.current = i;
182
+ }, [i]), T(() => {
183
+ const $ = (F) => {
184
+ J.current && !J.current.contains(F.target) && E(!1);
129
185
  };
130
- return document.addEventListener("mousedown", R), () => document.removeEventListener("mousedown", R);
131
- }, []), H(() => {
132
- $ || k("");
133
- }, [$]), H(() => {
186
+ return document.addEventListener("mousedown", $), () => document.removeEventListener("mousedown", $);
187
+ }, []), T(() => {
188
+ b || H("");
189
+ }, [b]), T(() => {
134
190
  if (!m) return;
135
- const R = setTimeout(() => {
136
- var B;
137
- (B = J.current) == null || B.call(J, S);
138
- }, _);
139
- return () => clearTimeout(R);
140
- }, [S, m, _]);
141
- const G = j(() => m && !s && S.trim() ? u.filter(
142
- (R) => String((R == null ? void 0 : R[c]) ?? "").toLowerCase().includes(S.toLowerCase())
143
- ) : u ?? [], [u, m, s, S, c]), X = j(() => {
144
- if (g == null) return "";
145
- if (typeof g == "object")
146
- return String(g[d] ?? "");
147
- const R = (u || []).find(
148
- (B) => String(B == null ? void 0 : B[d]) === String(g)
149
- );
150
- return String(R ? (R == null ? void 0 : R[c]) ?? "" : g);
151
- }, [g, u, d, c]), de = (R) => {
152
- a || (f ? N == null || N(R[d]) : (D(R[d]), v == null || v(e)), y == null || y(R), V(!1));
191
+ const $ = setTimeout(() => {
192
+ var F;
193
+ (F = Q.current) == null || F.call(Q, L);
194
+ }, v);
195
+ return () => clearTimeout($);
196
+ }, [L, m, v]);
197
+ const ee = z(() => m && !i && L.trim() ? a.filter(
198
+ ($) => String(($ == null ? void 0 : $[c]) ?? "").toLowerCase().includes(L.toLowerCase())
199
+ ) : a ?? [], [a, m, i, L, c]), te = z(() => {
200
+ if (V == null) return "";
201
+ if (typeof V == "object")
202
+ return String(V[o] ?? "");
203
+ const $ = (a || []).find((F) => String(F == null ? void 0 : F[o]) === String(V));
204
+ return String($ ? ($ == null ? void 0 : $[c]) ?? "" : V);
205
+ }, [V, a, o, c]), he = ($) => {
206
+ k || (n ? g == null || g($[o]) : (O($[o]), A == null || A(t)), x == null || x($), E(!1));
153
207
  };
154
- return /* @__PURE__ */ w(
155
- "div",
156
- {
157
- className: `select-wrapper form-group ${l ? "hidden" : ""}`,
158
- ref: L,
159
- children: [
160
- /* @__PURE__ */ t("label", { className: "control-label", children: r }),
161
- o ? /* @__PURE__ */ t("span", { className: "form-control", children: X || "-" }) : /* @__PURE__ */ w(ae, { children: [
162
- /* @__PURE__ */ w(
163
- "div",
164
- {
165
- className: `select-control ${x ? "border-red" : ""} ${a ? "readOnly" : ""}`,
166
- onClick: () => !a && V((R) => !R),
167
- ref: O,
168
- children: [
169
- /* @__PURE__ */ t("span", { className: `select-display ${a ? "readOnly" : ""}`, children: X || h }),
170
- /* @__PURE__ */ t("i", { className: "flaticon flaticon-chevron-down select-icon" })
171
- ]
172
- }
173
- ),
174
- $ && !a && /* @__PURE__ */ w("div", { className: "select-dropdown", children: [
175
- m && /* @__PURE__ */ t("div", { className: "select-search", children: /* @__PURE__ */ t(
176
- "input",
177
- {
178
- type: "text",
179
- className: "select-search-input",
180
- value: S,
181
- onChange: (R) => k(R.target.value),
182
- placeholder: b ? "Carregando..." : i,
183
- autoFocus: !0,
184
- onClick: (R) => R.stopPropagation()
185
- }
186
- ) }),
187
- /* @__PURE__ */ t("ul", { className: "select-options", children: b ? /* @__PURE__ */ t("li", { className: "select-option readOnly", children: "Carregando..." }) : G.length > 0 ? G.map((R) => /* @__PURE__ */ t(
188
- "li",
189
- {
190
- onClick: () => de(R),
191
- className: "select-option handleHover",
192
- children: R[c]
193
- },
194
- R[d]
195
- )) : /* @__PURE__ */ t("li", { className: "select-option readOnly", children: "Sem resultados" }) })
196
- ] })
197
- ] }),
198
- !f && /* @__PURE__ */ t("input", { type: "hidden", name: e, value: g || "" }),
199
- (x || T) && /* @__PURE__ */ t("p", { className: "text-danger", children: String((x == null ? void 0 : x.message) ?? T) })
200
- ]
201
- }
202
- );
208
+ return I ? null : /* @__PURE__ */ h("div", { className: `select-wrapper form-group ${I ? "hidden" : ""}`, ref: J, children: [
209
+ /* @__PURE__ */ e("label", { className: "control-label", children: l }),
210
+ B ? /* @__PURE__ */ h("div", { className: y ? "dfe-flex-input-wrapper" : "", children: [
211
+ /* @__PURE__ */ e("span", { className: "form-control", style: y ? { flex: 1 } : void 0, children: te || "-" }),
212
+ y && /* @__PURE__ */ e(Z, { text: y, title: R, width: D })
213
+ ] }) : /* @__PURE__ */ h(ce, { children: [
214
+ /* @__PURE__ */ h("div", { className: y ? "dfe-flex-input-wrapper" : "", children: [
215
+ /* @__PURE__ */ h(
216
+ "div",
217
+ {
218
+ className: `select-control ${N ? "border-red" : ""} ${k ? "readOnly" : ""}`,
219
+ onClick: () => !k && E(($) => !$),
220
+ ref: w,
221
+ style: y ? { flex: 1 } : void 0,
222
+ children: [
223
+ /* @__PURE__ */ e("span", { className: `select-display ${k ? "readOnly" : ""}`, children: te || f }),
224
+ /* @__PURE__ */ e("i", { className: "flaticon flaticon-chevron-down select-icon" })
225
+ ]
226
+ }
227
+ ),
228
+ y && /* @__PURE__ */ e(Z, { text: y, title: R, width: D })
229
+ ] }),
230
+ b && !k && /* @__PURE__ */ h("div", { className: "select-dropdown", children: [
231
+ m && /* @__PURE__ */ e("div", { className: "select-search", children: /* @__PURE__ */ e(
232
+ "input",
233
+ {
234
+ type: "text",
235
+ className: "select-search-input",
236
+ value: L,
237
+ onChange: ($) => H($.target.value),
238
+ placeholder: p ? "Carregando..." : d,
239
+ autoFocus: !0,
240
+ onClick: ($) => $.stopPropagation()
241
+ }
242
+ ) }),
243
+ /* @__PURE__ */ e("ul", { className: "select-options", children: p ? /* @__PURE__ */ e("li", { className: "select-option readOnly", children: "Carregando..." }) : ee.length > 0 ? ee.map(($) => /* @__PURE__ */ e("li", { onClick: () => he($), className: "select-option handleHover", children: $[c] }, $[o])) : /* @__PURE__ */ e("li", { className: "select-option readOnly", children: "Sem resultados" }) })
244
+ ] })
245
+ ] }),
246
+ !n && /* @__PURE__ */ e("input", { type: "hidden", name: t, value: V || "" }),
247
+ (N || r) && /* @__PURE__ */ e("p", { className: "text-danger", children: String((N == null ? void 0 : N.message) ?? r) })
248
+ ] });
203
249
  }
204
- const M = W($e);
205
- function nt({
206
- name: e,
207
- options: r = [],
208
- label: u = "",
209
- valueKey: h = "value",
250
+ const re = q(Be);
251
+ function at({
252
+ name: t,
253
+ options: l = [],
254
+ label: a = "",
255
+ valueKey: f = "value",
210
256
  labelKey: c = "label",
211
- forceReadOnly: d = !1,
257
+ forceReadOnly: o = !1,
212
258
  forceHidden: m = !1,
213
- valueManual: i,
214
- onChangeManual: b
259
+ valueManual: d,
260
+ onChangeManual: p
215
261
  }) {
216
- var O, x;
217
- let s = null;
262
+ var B, V;
263
+ let i = null;
218
264
  try {
219
- s = F();
265
+ i = U();
220
266
  } catch {
221
267
  }
222
- const _ = i !== void 0 && !!b, { isView: y, isReadOnly: A } = P(), { isReadOnly: I, isHidden: E } = Y(), N = I ? I(e) : !1, T = E ? E(e) : !1, f = d || N, p = m || T, n = f || A || y, a = () => r ? r.reduce(
223
- (v, $) => {
224
- const V = String($[h]);
225
- if (_)
226
- v[V] = !!(i != null && i[V]);
227
- else if (s) {
228
- const S = s.getValues(V);
229
- v[V] = S === "on";
268
+ const v = d !== void 0 && !!p, { isView: x, isReadOnly: S } = Y(), { isReadOnly: C, isHidden: y } = G(), R = C ? C(t) : !1, D = y ? y(t) : !1, _ = o || R, g = m || D, r = _ || S || x, n = () => l ? l.reduce(
269
+ (O, w) => {
270
+ const N = String(w[f]);
271
+ if (v)
272
+ O[N] = !!(d != null && d[N]);
273
+ else if (i) {
274
+ const A = i.getValues(N);
275
+ O[N] = A === "on";
230
276
  } else
231
- v[V] = !1;
232
- return v;
277
+ O[N] = !1;
278
+ return O;
233
279
  },
234
280
  {}
235
- ) : {}, l = !_ && s ? s.watch(e) : void 0, o = j(() => _ && i ? i : l && typeof l == "object" ? l : a(), [l, i, r]);
236
- H(() => {
237
- if (_ || !s) return;
238
- const v = s.getValues(e);
239
- (!v || typeof v != "object") && s.setValue(e, o, {
281
+ ) : {}, s = !v && i ? i.watch(t) : void 0, u = z(() => v && d ? d : s && typeof s == "object" ? s : n(), [s, d, l]);
282
+ T(() => {
283
+ if (v || !i) return;
284
+ const O = i.getValues(t);
285
+ (!O || typeof O != "object") && i.setValue(t, u, {
240
286
  shouldDirty: !1,
241
287
  shouldValidate: !1
242
288
  });
243
- }, [o, e, s, _]);
244
- const g = (v, $) => {
245
- if (n) return;
246
- const V = { ...o, [v]: $ };
247
- if (_) {
248
- b && b(V);
289
+ }, [u, t, i, v]);
290
+ const k = (O, w) => {
291
+ if (r) return;
292
+ const N = { ...u, [O]: w };
293
+ if (v) {
294
+ p && p(N);
249
295
  return;
250
296
  }
251
- s && (s.setValue(e, V, {
297
+ i && (i.setValue(t, N, {
252
298
  shouldDirty: !0,
253
299
  shouldValidate: !0
254
- }), s.setValue(v, $ ? "on" : "", { shouldValidate: !1 }));
255
- }, D = _ ? null : (x = (O = s == null ? void 0 : s.formState) == null ? void 0 : O.errors) == null ? void 0 : x[e];
256
- return /* @__PURE__ */ w("div", { className: `form-group ${p ? "hidden" : ""}`, children: [
257
- u && /* @__PURE__ */ t("label", { children: u }),
258
- /* @__PURE__ */ t(
300
+ }), i.setValue(O, w ? "on" : "", { shouldValidate: !1 }));
301
+ }, I = v ? null : (V = (B = i == null ? void 0 : i.formState) == null ? void 0 : B.errors) == null ? void 0 : V[t];
302
+ return /* @__PURE__ */ h("div", { className: `form-group ${g ? "hidden" : ""}`, children: [
303
+ a && /* @__PURE__ */ e("label", { children: a }),
304
+ /* @__PURE__ */ e(
259
305
  "div",
260
306
  {
261
- className: `checkbox-group-custom ${n ? "readOnly" : ""}`,
262
- children: r.map((v) => {
263
- const $ = String(v[h]), V = o[$] === !0;
264
- return /* @__PURE__ */ w("div", { children: [
265
- !_ && s && /* @__PURE__ */ t("input", { type: "hidden", ...s.register($) }),
266
- /* @__PURE__ */ w(
307
+ className: `checkbox-group-custom ${r ? "readOnly" : ""}`,
308
+ children: l.map((O) => {
309
+ const w = String(O[f]), N = u[w] === !0;
310
+ return /* @__PURE__ */ h("div", { children: [
311
+ !v && i && /* @__PURE__ */ e("input", { type: "hidden", ...i.register(w) }),
312
+ /* @__PURE__ */ h(
267
313
  "label",
268
314
  {
269
- className: `custom-checkbox ${V ? "checked" : ""} ${n ? "readOnly" : ""}`,
315
+ className: `custom-checkbox ${N ? "checked" : ""} ${r ? "readOnly" : ""}`,
270
316
  children: [
271
- /* @__PURE__ */ t(
317
+ /* @__PURE__ */ e(
272
318
  "input",
273
319
  {
274
320
  type: "checkbox",
275
- checked: V,
276
- disabled: n,
277
- onChange: (S) => g($, S.target.checked)
321
+ checked: N,
322
+ disabled: r,
323
+ onChange: (A) => k(w, A.target.checked)
278
324
  }
279
325
  ),
280
- /* @__PURE__ */ t("span", { className: "checkmark" }),
281
- /* @__PURE__ */ t("span", { children: v[c] })
326
+ /* @__PURE__ */ e("span", { className: "checkmark" }),
327
+ /* @__PURE__ */ e("span", { children: O[c] })
282
328
  ]
283
329
  }
284
330
  )
285
- ] }, $);
331
+ ] }, w);
286
332
  })
287
333
  }
288
334
  ),
289
- D && /* @__PURE__ */ t("p", { className: "text-danger", children: String(D.message) })
335
+ I && /* @__PURE__ */ e("p", { className: "text-danger", children: String(I.message) })
290
336
  ] });
291
337
  }
292
- function Ae({
293
- name: e,
294
- label: r = "",
295
- options: u = [],
296
- valueKey: h = "value",
338
+ function Ce({
339
+ name: t,
340
+ label: l = "",
341
+ options: a = [],
342
+ valueKey: f = "value",
297
343
  labelKey: c = "label",
298
- iconKey: d = "icon",
344
+ iconKey: o = "icon",
299
345
  forceReadOnly: m = !1,
300
- forceHidden: i = !1,
301
- valueManual: b,
302
- onChangeManual: s,
303
- errorManual: _
346
+ forceHidden: d = !1,
347
+ valueManual: p,
348
+ onChangeManual: i,
349
+ errorManual: v
304
350
  }) {
305
- var O, x;
306
- const y = b !== void 0 && !!s, { isReadOnly: A, isHidden: I } = Y(), E = m || !!A(e), N = i || !!I(e), { isView: T, isReadOnly: f } = P();
307
- let p = null;
351
+ var B, V;
352
+ const x = p !== void 0 && !!i, { isReadOnly: S, isHidden: C } = G(), y = m || !!S(t), R = d || !!C(t), { isView: D, isReadOnly: _ } = Y();
353
+ let g = null;
308
354
  try {
309
- p = F();
355
+ g = U();
310
356
  } catch {
311
357
  }
312
- const n = !y && p ? z({ name: e, control: p.control, defaultValue: "" }) : null, a = !y && p ? ne({ name: e }) : null, l = y ? _ : (x = (O = a == null ? void 0 : a.errors) == null ? void 0 : O[e]) == null ? void 0 : x.message, o = E || f || T, g = y ? b : (n == null ? void 0 : n.field.value) ?? "", D = C(
313
- (v) => {
314
- o || (y ? s == null || s(v) : (n == null || n.field.onChange(v), n == null || n.field.onBlur()));
358
+ const r = !x && g ? W({ name: t, control: g.control, defaultValue: "" }) : null, n = !x && g ? oe({ name: t }) : null, s = x ? v : (V = (B = n == null ? void 0 : n.errors) == null ? void 0 : B[t]) == null ? void 0 : V.message, u = y || _ || D, k = x ? p : (r == null ? void 0 : r.field.value) ?? "", I = j(
359
+ (O) => {
360
+ u || (x ? i == null || i(O) : (r == null || r.field.onChange(O), r == null || r.field.onBlur()));
315
361
  },
316
- [o, y, s, n]
362
+ [u, x, i, r]
317
363
  );
318
- return /* @__PURE__ */ w("div", { className: `form-group column ${N ? "hidden" : ""}`, children: [
319
- r && /* @__PURE__ */ t("label", { className: "control-label", children: r }),
320
- /* @__PURE__ */ t("div", { className: `btn-group ${o ? "view-mode" : ""}`, "data-field-name": e, children: u.map((v) => {
321
- const $ = v[h], V = g === $, S = v.color ? { "--customColor": v.color } : void 0;
364
+ return /* @__PURE__ */ h("div", { className: `form-group column ${R ? "hidden" : ""}`, children: [
365
+ l && /* @__PURE__ */ e("label", { className: "control-label", children: l }),
366
+ /* @__PURE__ */ e("div", { className: `btn-group ${u ? "view-mode" : ""}`, "data-field-name": t, children: a.map((O) => {
367
+ const w = O[f], N = k === w, A = O.color ? { "--customColor": O.color } : void 0;
322
368
  return (
323
369
  // Trocado de <label> para <div> para evitar comportamentos nativos de clique do HTML
324
- /* @__PURE__ */ w(
370
+ /* @__PURE__ */ h(
325
371
  "div",
326
372
  {
327
- style: S,
328
- className: `btn fs-ellipsis ${V ? "active" : ""}`,
329
- onClick: () => D($),
373
+ style: A,
374
+ className: `btn fs-ellipsis ${N ? "active" : ""}`,
375
+ onClick: () => I(w),
330
376
  children: [
331
- v[d] && /* @__PURE__ */ t("i", { className: `${v[d]} icon-sm` }),
377
+ O[o] && /* @__PURE__ */ e("i", { className: `${O[o]} icon-sm` }),
332
378
  " ",
333
- v[c]
379
+ O[c]
334
380
  ]
335
381
  },
336
- $
382
+ w
337
383
  )
338
384
  );
339
385
  }) }),
340
- !y && /* @__PURE__ */ t("input", { type: "hidden", name: e, value: g || "", ref: n == null ? void 0 : n.field.ref }),
341
- (l || _) && /* @__PURE__ */ t("p", { className: "text-danger", children: String(l ?? _) })
386
+ !x && /* @__PURE__ */ e("input", { type: "hidden", name: t, value: k || "", ref: r == null ? void 0 : r.field.ref }),
387
+ (s || v) && /* @__PURE__ */ e("p", { className: "text-danger", children: String(s ?? v) })
342
388
  ] });
343
389
  }
344
- const lt = W(Ae), Te = ({
345
- name: e,
346
- label: r = "",
347
- placeholder: u = "",
348
- className: h = "",
390
+ const ut = q(Ce), He = ({
391
+ name: t,
392
+ label: l = "",
393
+ placeholder: a = "",
394
+ className: f = "",
349
395
  rows: c = 4,
350
- maxLength: d,
396
+ maxLength: o,
351
397
  forceReadOnly: m = !1,
352
- forceHidden: i = !1,
353
- valueManual: b,
354
- onChangeManual: s,
355
- errorManual: _
398
+ forceHidden: d = !1,
399
+ valueManual: p,
400
+ onChangeManual: i,
401
+ errorManual: v
356
402
  }) => {
357
- var o;
358
- const y = b !== void 0 && !!s, { isReadOnly: A, isHidden: I } = Y(), E = m || !!A(e), N = i || !!I(e), { isView: T } = P(), f = q(null);
359
- let p = {
360
- value: b ?? "",
361
- onChange: (g) => s == null ? void 0 : s(g)
362
- }, n = null;
363
- if (!y)
403
+ var u;
404
+ const x = p !== void 0 && !!i, { isReadOnly: S, isHidden: C } = G(), y = m || !!S(t), R = d || !!C(t), { isView: D } = Y(), _ = X(null);
405
+ let g = {
406
+ value: p ?? "",
407
+ onChange: (k) => i == null ? void 0 : i(k)
408
+ }, r = null;
409
+ if (!x)
364
410
  try {
365
- const { control: g } = F(), D = z({ name: e, control: g });
366
- p = D.field, n = (o = D.fieldState) == null ? void 0 : o.error;
411
+ const { control: k } = U(), I = W({ name: t, control: k });
412
+ g = I.field, r = (u = I.fieldState) == null ? void 0 : u.error;
367
413
  } catch {
368
414
  }
369
- const a = () => {
370
- f.current && (f.current.style.height = "auto", f.current.style.height = `${f.current.scrollHeight}px`);
415
+ const n = () => {
416
+ _.current && (_.current.style.height = "auto", _.current.style.height = `${_.current.scrollHeight}px`);
371
417
  };
372
- if (H(() => {
373
- a();
374
- }, [p.value]), T)
375
- return /* @__PURE__ */ w("div", { className: `form-group ${N ? "hidden" : ""}`, children: [
376
- /* @__PURE__ */ t("label", { children: r }),
377
- /* @__PURE__ */ t("span", { className: "form-control", children: p.value || "-" })
418
+ if (T(() => {
419
+ n();
420
+ }, [g.value]), D)
421
+ return /* @__PURE__ */ h("div", { className: `form-group ${R ? "hidden" : ""}`, children: [
422
+ /* @__PURE__ */ e("label", { children: l }),
423
+ /* @__PURE__ */ e("span", { className: "form-control", children: g.value || "-" })
378
424
  ] });
379
- const l = `form-control ${E ? "readOnly" : ""} ${n || _ ? "border-red" : ""} ${h}`;
380
- return /* @__PURE__ */ w("div", { className: `form-group ${N ? "hidden" : ""}`, children: [
381
- r && /* @__PURE__ */ t("label", { children: r }),
382
- /* @__PURE__ */ t(
425
+ const s = `form-control ${y ? "readOnly" : ""} ${r || v ? "border-red" : ""} ${f}`;
426
+ return /* @__PURE__ */ h("div", { className: `form-group ${R ? "hidden" : ""}`, children: [
427
+ l && /* @__PURE__ */ e("label", { children: l }),
428
+ /* @__PURE__ */ e(
383
429
  "textarea",
384
430
  {
385
- ref: f,
431
+ ref: _,
386
432
  rows: c,
387
- maxLength: d,
388
- value: p.value || "",
389
- placeholder: u,
390
- readOnly: E,
391
- className: l,
433
+ maxLength: o,
434
+ value: g.value || "",
435
+ placeholder: a,
436
+ readOnly: y,
437
+ className: s,
392
438
  style: {
393
439
  resize: "none",
394
440
  maxHeight: "400px",
395
441
  overflowY: "auto"
396
442
  },
397
- onChange: (g) => {
398
- y ? s == null || s(g.target.value) : p.onChange(g);
443
+ onChange: (k) => {
444
+ x ? i == null || i(k.target.value) : g.onChange(k);
399
445
  },
400
- onInput: a
446
+ onInput: n
401
447
  }
402
448
  ),
403
- (n || _) && /* @__PURE__ */ t("p", { className: "text-danger", children: String((n == null ? void 0 : n.message) ?? _) })
449
+ (r || v) && /* @__PURE__ */ e("p", { className: "text-danger", children: String((r == null ? void 0 : r.message) ?? v) })
404
450
  ] });
405
- }, ct = W(Te);
451
+ }, ft = q(He);
406
452
  /**
407
453
  * @license lucide-react v0.575.0 - ISC
408
454
  *
409
455
  * This source code is licensed under the ISC license.
410
456
  * See the LICENSE file in the root directory of this source tree.
411
457
  */
412
- const ie = (...e) => e.filter((r, u, h) => !!r && r.trim() !== "" && h.indexOf(r) === u).join(" ").trim();
458
+ const fe = (...t) => t.filter((l, a, f) => !!l && l.trim() !== "" && f.indexOf(l) === a).join(" ").trim();
413
459
  /**
414
460
  * @license lucide-react v0.575.0 - ISC
415
461
  *
416
462
  * This source code is licensed under the ISC license.
417
463
  * See the LICENSE file in the root directory of this source tree.
418
464
  */
419
- const Ve = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
465
+ const Le = (t) => t.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
420
466
  /**
421
467
  * @license lucide-react v0.575.0 - ISC
422
468
  *
423
469
  * This source code is licensed under the ISC license.
424
470
  * See the LICENSE file in the root directory of this source tree.
425
471
  */
426
- const Ee = (e) => e.replace(
472
+ const Fe = (t) => t.replace(
427
473
  /^([A-Z])|[\s-_]+(\w)/g,
428
- (r, u, h) => h ? h.toUpperCase() : u.toLowerCase()
474
+ (l, a, f) => f ? f.toUpperCase() : a.toLowerCase()
429
475
  );
430
476
  /**
431
477
  * @license lucide-react v0.575.0 - ISC
@@ -433,9 +479,9 @@ const Ee = (e) => e.replace(
433
479
  * This source code is licensed under the ISC license.
434
480
  * See the LICENSE file in the root directory of this source tree.
435
481
  */
436
- const ee = (e) => {
437
- const r = Ee(e);
438
- return r.charAt(0).toUpperCase() + r.slice(1);
482
+ const ne = (t) => {
483
+ const l = Fe(t);
484
+ return l.charAt(0).toUpperCase() + l.slice(1);
439
485
  };
440
486
  /**
441
487
  * @license lucide-react v0.575.0 - ISC
@@ -443,7 +489,7 @@ const ee = (e) => {
443
489
  * This source code is licensed under the ISC license.
444
490
  * See the LICENSE file in the root directory of this source tree.
445
491
  */
446
- var De = {
492
+ var Te = {
447
493
  xmlns: "http://www.w3.org/2000/svg",
448
494
  width: 24,
449
495
  height: 24,
@@ -460,9 +506,9 @@ var De = {
460
506
  * This source code is licensed under the ISC license.
461
507
  * See the LICENSE file in the root directory of this source tree.
462
508
  */
463
- const Ie = (e) => {
464
- for (const r in e)
465
- if (r.startsWith("aria-") || r === "role" || r === "title")
509
+ const je = (t) => {
510
+ for (const l in t)
511
+ if (l.startsWith("aria-") || l === "role" || l === "title")
466
512
  return !0;
467
513
  return !1;
468
514
  };
@@ -472,32 +518,32 @@ const Ie = (e) => {
472
518
  * This source code is licensed under the ISC license.
473
519
  * See the LICENSE file in the root directory of this source tree.
474
520
  */
475
- const Le = re(
521
+ const Pe = de(
476
522
  ({
477
- color: e = "currentColor",
478
- size: r = 24,
479
- strokeWidth: u = 2,
480
- absoluteStrokeWidth: h,
523
+ color: t = "currentColor",
524
+ size: l = 24,
525
+ strokeWidth: a = 2,
526
+ absoluteStrokeWidth: f,
481
527
  className: c = "",
482
- children: d,
528
+ children: o,
483
529
  iconNode: m,
484
- ...i
485
- }, b) => Q(
530
+ ...d
531
+ }, p) => K(
486
532
  "svg",
487
533
  {
488
- ref: b,
489
- ...De,
490
- width: r,
491
- height: r,
492
- stroke: e,
493
- strokeWidth: h ? Number(u) * 24 / Number(r) : u,
494
- className: ie("lucide", c),
495
- ...!d && !Ie(i) && { "aria-hidden": "true" },
496
- ...i
534
+ ref: p,
535
+ ...Te,
536
+ width: l,
537
+ height: l,
538
+ stroke: t,
539
+ strokeWidth: f ? Number(a) * 24 / Number(l) : a,
540
+ className: fe("lucide", c),
541
+ ...!o && !je(d) && { "aria-hidden": "true" },
542
+ ...d
497
543
  },
498
544
  [
499
- ...m.map(([s, _]) => Q(s, _)),
500
- ...Array.isArray(d) ? d : [d]
545
+ ...m.map(([i, v]) => K(i, v)),
546
+ ...Array.isArray(o) ? o : [o]
501
547
  ]
502
548
  )
503
549
  );
@@ -507,20 +553,20 @@ const Le = re(
507
553
  * This source code is licensed under the ISC license.
508
554
  * See the LICENSE file in the root directory of this source tree.
509
555
  */
510
- const Z = (e, r) => {
511
- const u = re(
512
- ({ className: h, ...c }, d) => Q(Le, {
513
- ref: d,
514
- iconNode: r,
515
- className: ie(
516
- `lucide-${Ve(ee(e))}`,
517
- `lucide-${e}`,
518
- h
556
+ const M = (t, l) => {
557
+ const a = de(
558
+ ({ className: f, ...c }, o) => K(Pe, {
559
+ ref: o,
560
+ iconNode: l,
561
+ className: fe(
562
+ `lucide-${Le(ne(t))}`,
563
+ `lucide-${t}`,
564
+ f
519
565
  ),
520
566
  ...c
521
567
  })
522
568
  );
523
- return u.displayName = ee(e), u;
569
+ return a.displayName = ne(t), a;
524
570
  };
525
571
  /**
526
572
  * @license lucide-react v0.575.0 - ISC
@@ -528,30 +574,30 @@ const Z = (e, r) => {
528
574
  * This source code is licensed under the ISC license.
529
575
  * See the LICENSE file in the root directory of this source tree.
530
576
  */
531
- const Be = [
577
+ const Ue = [
532
578
  ["path", { d: "M8 2v4", key: "1cmpym" }],
533
579
  ["path", { d: "M16 2v4", key: "4m81vk" }],
534
580
  ["rect", { width: "18", height: "18", x: "3", y: "4", rx: "2", key: "1hopcy" }],
535
581
  ["path", { d: "M3 10h18", key: "8toen8" }]
536
- ], He = Z("calendar", Be);
582
+ ], Ye = M("calendar", Ue);
537
583
  /**
538
584
  * @license lucide-react v0.575.0 - ISC
539
585
  *
540
586
  * This source code is licensed under the ISC license.
541
587
  * See the LICENSE file in the root directory of this source tree.
542
588
  */
543
- const Ce = [["path", { d: "m15 18-6-6 6-6", key: "1wnfg3" }]], Fe = Z("chevron-left", Ce);
589
+ const Je = [["path", { d: "m15 18-6-6 6-6", key: "1wnfg3" }]], ze = M("chevron-left", Je);
544
590
  /**
545
591
  * @license lucide-react v0.575.0 - ISC
546
592
  *
547
593
  * This source code is licensed under the ISC license.
548
594
  * See the LICENSE file in the root directory of this source tree.
549
595
  */
550
- const Pe = [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]], je = Z("chevron-right", Pe), oe = "dd/MM/yyyy", te = (e) => {
551
- if (!e) return null;
552
- const r = Re(e, oe, /* @__PURE__ */ new Date());
553
- return le(r) ? r : null;
554
- }, Ue = (e) => e ? ce(e, oe) : "", Ye = [
596
+ const qe = [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]], Ge = M("chevron-right", qe), me = "dd/MM/yyyy", le = (t) => {
597
+ if (!t) return null;
598
+ const l = Ae(t, me, /* @__PURE__ */ new Date());
599
+ return ae(l) ? l : null;
600
+ }, We = (t) => t ? ue(t, me) : "", Qe = [
555
601
  { value: 0, label: "Janeiro" },
556
602
  { value: 1, label: "Fevereiro" },
557
603
  { value: 2, label: "Março" },
@@ -564,527 +610,477 @@ const Pe = [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]], je = Z("chevron-ri
564
610
  { value: 9, label: "Outubro" },
565
611
  { value: 10, label: "Novembro" },
566
612
  { value: 11, label: "Dezembro" }
567
- ], se = 1940, Je = 2100, We = Array.from({ length: Je - se + 1 }, (e, r) => {
568
- const u = se + r;
569
- return { value: u, label: String(u) };
613
+ ], ie = 1940, Ze = 2100, Xe = Array.from({ length: Ze - ie + 1 }, (t, l) => {
614
+ const a = ie + l;
615
+ return { value: a, label: String(a) };
570
616
  });
571
- function ze({
572
- name: e,
573
- label: r = "",
574
- placeholder: u = "dd/mm/aaaa",
575
- className: h = "",
617
+ function Ke({
618
+ name: t,
619
+ label: l = "",
620
+ placeholder: a = "dd/mm/aaaa",
621
+ className: f = "",
576
622
  forceReadOnly: c = !1,
577
- forceHidden: d = !1,
623
+ forceHidden: o = !1,
578
624
  valueManual: m,
579
- onChangeManual: i,
580
- errorManual: b
625
+ onChangeManual: d,
626
+ errorManual: p
581
627
  }) {
582
- var S;
583
- const s = m !== void 0 && !!i, { isReadOnly: _, isHidden: y } = Y(), A = c || !!_(e), I = d || !!y(e), { isView: E } = P();
584
- let N = "", T = () => {
585
- }, f, p = null, n = () => {
628
+ var A;
629
+ const i = m !== void 0 && !!d, { isReadOnly: v, isHidden: x } = G(), S = c || !!v(t), C = o || !!x(t), { isView: y } = Y();
630
+ let R = "", D = () => {
631
+ }, _, g = null, r = () => {
586
632
  };
587
- if (s)
588
- N = m;
633
+ if (i)
634
+ R = m;
589
635
  else
590
636
  try {
591
- const k = F(), L = z({ name: e, control: k.control });
592
- N = L.field.value, T = L.field.onChange, f = L.field.ref, p = (S = L.fieldState) == null ? void 0 : S.error, n = k.clearErrors;
637
+ const b = U(), E = W({ name: t, control: b.control });
638
+ R = E.field.value, D = E.field.onChange, _ = E.field.ref, g = (A = E.fieldState) == null ? void 0 : A.error, r = b.clearErrors;
593
639
  } catch {
594
640
  }
595
- const [a, l] = U(!1), [o, g] = U(/* @__PURE__ */ new Date()), D = q(null);
596
- H(() => {
597
- if (a) {
598
- const k = te(N);
599
- g(k && le(k) ? k : /* @__PURE__ */ new Date());
641
+ const [n, s] = P(!1), [u, k] = P(/* @__PURE__ */ new Date()), I = X(null);
642
+ T(() => {
643
+ if (n) {
644
+ const b = le(R);
645
+ k(b && ae(b) ? b : /* @__PURE__ */ new Date());
600
646
  }
601
- }, [a, N]), H(() => {
602
- const k = (L) => {
603
- D.current && !D.current.contains(L.target) && l(!1);
647
+ }, [n, R]), T(() => {
648
+ const b = (E) => {
649
+ I.current && !I.current.contains(E.target) && s(!1);
604
650
  };
605
- return document.addEventListener("mousedown", k), () => document.removeEventListener("mousedown", k);
651
+ return document.addEventListener("mousedown", b), () => document.removeEventListener("mousedown", b);
606
652
  }, []);
607
- const O = j(() => te(N), [N]), x = (k) => {
608
- if (A) return;
609
- const L = Ue(k);
610
- s ? i == null || i(L) : (T(L), n == null || n(e)), l(!1);
611
- }, v = j(() => fe({
612
- start: pe(ve(o)),
613
- end: he(me(o))
614
- }), [o]), $ = o.getMonth(), V = ye(o);
615
- return /* @__PURE__ */ w("div", { className: `dfe-datepicker-wrapper form-group ${I ? "hidden" : ""} ${h}`, ref: D, children: [
616
- /* @__PURE__ */ t("label", { className: "control-label", children: r }),
617
- E ? /* @__PURE__ */ t("span", { className: "form-control", children: N || "-" }) : (
653
+ const B = z(() => le(R), [R]), V = (b) => {
654
+ if (S) return;
655
+ const E = We(b);
656
+ i ? d == null || d(E) : (D(E), r == null || r(t)), s(!1);
657
+ }, O = z(() => ve({
658
+ start: ge(Ne(u)),
659
+ end: ye(be(u))
660
+ }), [u]), w = u.getMonth(), N = ke(u);
661
+ return /* @__PURE__ */ h("div", { className: `dfe-datepicker-wrapper form-group ${C ? "hidden" : ""} ${f}`, ref: I, children: [
662
+ /* @__PURE__ */ e("label", { className: "control-label", children: l }),
663
+ y ? /* @__PURE__ */ e("span", { className: "form-control", children: R || "-" }) : (
618
664
  /* Container isolador de contexto posicional */
619
- /* @__PURE__ */ w("div", { className: "dfe-datepicker-inner-container", children: [
620
- /* @__PURE__ */ w(
665
+ /* @__PURE__ */ h("div", { className: "dfe-datepicker-inner-container", children: [
666
+ /* @__PURE__ */ h(
621
667
  "div",
622
668
  {
623
- className: `dfe-datepicker-control ${p ? "border-red" : ""} ${A ? "readOnly" : ""}`,
624
- onClick: () => !A && l((k) => !k),
625
- ref: f,
669
+ className: `dfe-datepicker-control ${g ? "border-red" : ""} ${S ? "readOnly" : ""}`,
670
+ onClick: () => !S && s((b) => !b),
671
+ ref: _,
626
672
  children: [
627
- /* @__PURE__ */ t("span", { className: `dfe-datepicker-display ${A ? "readOnly" : ""}`, children: N || u }),
628
- /* @__PURE__ */ t(He, { size: 16, className: "dfe-datepicker-icon" })
673
+ /* @__PURE__ */ e("span", { className: `dfe-datepicker-display ${S ? "readOnly" : ""}`, children: R || a }),
674
+ /* @__PURE__ */ e(Ye, { size: 16, className: "dfe-datepicker-icon" })
629
675
  ]
630
676
  }
631
677
  ),
632
- a && !A && /* @__PURE__ */ w("div", { className: "dfe-datepicker-dropdown", onClick: (k) => k.stopPropagation(), children: [
633
- /* @__PURE__ */ w("div", { className: "dfe-datepicker-header", children: [
634
- /* @__PURE__ */ t(
678
+ n && !S && /* @__PURE__ */ h("div", { className: "dfe-datepicker-dropdown", onClick: (b) => b.stopPropagation(), children: [
679
+ /* @__PURE__ */ h("div", { className: "dfe-datepicker-header", children: [
680
+ /* @__PURE__ */ e(
635
681
  "button",
636
682
  {
637
683
  type: "button",
638
- onClick: () => g(ge(o, 1)),
684
+ onClick: () => k(we(u, 1)),
639
685
  className: "dfe-datepicker-nav-btn",
640
- children: /* @__PURE__ */ t(Fe, { size: 16 })
686
+ children: /* @__PURE__ */ e(ze, { size: 16 })
641
687
  }
642
688
  ),
643
- /* @__PURE__ */ w("div", { className: "dfe-datepicker-selectors", children: [
644
- /* @__PURE__ */ t(
645
- M,
689
+ /* @__PURE__ */ h("div", { className: "dfe-datepicker-selectors", children: [
690
+ /* @__PURE__ */ e(
691
+ re,
646
692
  {
647
693
  name: "datepicker_internal_month",
648
- valueManual: $,
649
- onChangeManual: (k) => g(be(o, Number(k))),
650
- options: Ye,
694
+ valueManual: w,
695
+ onChangeManual: (b) => k(_e(u, Number(b))),
696
+ options: Qe,
651
697
  placeholder: "Mês"
652
698
  }
653
699
  ),
654
- /* @__PURE__ */ t(
655
- M,
700
+ /* @__PURE__ */ e(
701
+ re,
656
702
  {
657
703
  name: "datepicker_internal_year",
658
- valueManual: V,
659
- onChangeManual: (k) => g(Ne(o, Number(k))),
660
- options: We,
704
+ valueManual: N,
705
+ onChangeManual: (b) => k(Oe(u, Number(b))),
706
+ options: Xe,
661
707
  enableSearch: !0,
662
708
  searchPlaceholder: "Buscar ano...",
663
709
  placeholder: "Ano"
664
710
  }
665
711
  )
666
712
  ] }),
667
- /* @__PURE__ */ t(
713
+ /* @__PURE__ */ e(
668
714
  "button",
669
715
  {
670
716
  type: "button",
671
- onClick: () => g(ke(o, 1)),
717
+ onClick: () => k(Se(u, 1)),
672
718
  className: "dfe-datepicker-nav-btn",
673
- children: /* @__PURE__ */ t(je, { size: 16 })
719
+ children: /* @__PURE__ */ e(Ge, { size: 16 })
674
720
  }
675
721
  )
676
722
  ] }),
677
- /* @__PURE__ */ t("div", { className: "dfe-datepicker-grid-header", children: ["D", "S", "T", "Q", "Q", "S", "S"].map((k, L) => /* @__PURE__ */ t("span", { children: k }, L)) }),
678
- /* @__PURE__ */ t("div", { className: "dfe-datepicker-grid", children: v.map((k, L) => {
679
- const J = !we(k, o), G = O && _e(k, O);
680
- return /* @__PURE__ */ t(
723
+ /* @__PURE__ */ e("div", { className: "dfe-datepicker-grid-header", children: ["D", "S", "T", "Q", "Q", "S", "S"].map((b, E) => /* @__PURE__ */ e("span", { children: b }, E)) }),
724
+ /* @__PURE__ */ e("div", { className: "dfe-datepicker-grid", children: O.map((b, E) => {
725
+ const L = !Re(b, u), H = B && $e(b, B);
726
+ return /* @__PURE__ */ e(
681
727
  "div",
682
728
  {
683
- onClick: () => !J && x(k),
729
+ onClick: () => !L && V(b),
684
730
  className: `dfe-datepicker-day
685
- ${G ? "selected" : "handleHover"}
686
- ${J ? "outside" : ""}
687
- ${Se(k) ? "today" : ""}`,
688
- children: ce(k, "d")
731
+ ${H ? "selected" : "handleHover"}
732
+ ${L ? "outside" : ""}
733
+ ${xe(b) ? "today" : ""}`,
734
+ children: ue(b, "d")
689
735
  },
690
- L
736
+ E
691
737
  );
692
738
  }) })
693
739
  ] })
694
740
  ] })
695
741
  ),
696
- !s && /* @__PURE__ */ t("input", { type: "hidden", name: e, value: N || "" }),
697
- (p || b) && /* @__PURE__ */ t("p", { className: "text-danger", children: String((p == null ? void 0 : p.message) ?? b) })
742
+ !i && /* @__PURE__ */ e("input", { type: "hidden", name: t, value: R || "" }),
743
+ (g || p) && /* @__PURE__ */ e("p", { className: "text-danger", children: String((g == null ? void 0 : g.message) ?? p) })
698
744
  ] });
699
745
  }
700
- const it = W(ze);
701
- function Ge({
702
- mapping: e = {},
703
- defaultLabel: r = "Não reconhecido",
704
- className: u = "",
705
- hidden: h = !1,
746
+ const mt = q(Ke);
747
+ function Me({
748
+ mapping: t = {},
749
+ defaultLabel: l = "Não reconhecido",
750
+ className: a = "",
751
+ hidden: f = !1,
706
752
  label: c
707
753
  }) {
708
- const { activityId: d } = P(), m = j(() => !e || d === null || d === void 0 ? null : e[d], [d, e]);
754
+ const { activityId: o } = Y(), m = z(() => !t || o === null || o === void 0 ? null : t[o], [o, t]);
709
755
  if (!m)
710
- return /* @__PURE__ */ w("div", { className: `form-group ${h ? "hidden" : ""}`, children: [
711
- c && /* @__PURE__ */ t("label", { children: c }),
712
- /* @__PURE__ */ t("div", { className: `status-badge default ${u}`, children: r })
756
+ return /* @__PURE__ */ h("div", { className: `form-group ${f ? "hidden" : ""}`, children: [
757
+ c && /* @__PURE__ */ e("label", { children: c }),
758
+ /* @__PURE__ */ e("div", { className: `status-badge default ${a}`, children: l })
713
759
  ] });
714
- const i = {
760
+ const d = {
715
761
  "--customColor": m.color
716
762
  };
717
- return /* @__PURE__ */ w("div", { className: `form-group ${h ? "hidden" : ""}`, children: [
718
- c && /* @__PURE__ */ t("label", { children: c }),
719
- /* @__PURE__ */ w("div", { className: `status-badge ${u}`, style: i, children: [
720
- m.icon && /* @__PURE__ */ t("i", { className: m.icon }),
721
- /* @__PURE__ */ t("span", { children: m.label })
763
+ return /* @__PURE__ */ h("div", { className: `form-group ${f ? "hidden" : ""}`, children: [
764
+ c && /* @__PURE__ */ e("label", { children: c }),
765
+ /* @__PURE__ */ h("div", { className: `status-badge ${a}`, style: d, children: [
766
+ m.icon && /* @__PURE__ */ e("i", { className: m.icon }),
767
+ /* @__PURE__ */ e("span", { children: m.label })
722
768
  ] })
723
769
  ] });
724
770
  }
725
- const ot = W(Ge);
726
- function qe({
727
- name: e,
728
- control: r,
729
- defaultRowValue: u,
730
- isView: h,
771
+ const ht = q(Me);
772
+ function et({
773
+ name: t,
774
+ control: l,
775
+ defaultRowValue: a,
776
+ isView: f,
731
777
  isReadOnly: c,
732
- filters: d = []
778
+ filters: o = []
733
779
  }) {
734
- const { field: m } = z({ name: e, control: r }), [i, b] = U([]), [s, _] = U([]), y = () => Date.now() + Math.random(), A = (a) => {
780
+ const { field: m } = W({ name: t, control: l }), [d, p] = P([]), [i, v] = P([]), x = () => Date.now() + Math.random(), S = (n) => {
735
781
  try {
736
- const l = JSON.parse(a);
737
- return Array.isArray(l) ? l.map((o) => ({
738
- ...o,
739
- _uid: o._uid || y()
782
+ const s = JSON.parse(n);
783
+ return Array.isArray(s) ? s.map((u) => ({
784
+ ...u,
785
+ _uid: u._uid || x()
740
786
  })) : [];
741
- } catch (l) {
742
- return console.error(`Erro ao ler dados da tabela "${e}":`, l), [];
787
+ } catch (s) {
788
+ return console.error(`Erro ao ler dados da tabela "${t}":`, s), [];
743
789
  }
744
790
  };
745
- H(() => {
746
- if (!(i.length > 0 && !h) && m.value && typeof m.value == "string") {
747
- const a = JSON.stringify(i);
748
- if (m.value === a) return;
749
- const l = A(m.value);
750
- b(l);
791
+ T(() => {
792
+ if (!(d.length > 0 && !f) && m.value && typeof m.value == "string") {
793
+ const n = JSON.stringify(d);
794
+ if (m.value === n) return;
795
+ const s = S(m.value);
796
+ p(s);
751
797
  }
752
- }, [m.value, h]), H(() => {
798
+ }, [m.value, f]), T(() => {
753
799
  if (c) return;
754
- const a = JSON.stringify(i);
755
- m.value !== a && m.onChange(a);
756
- }, [i, m, c]);
757
- const I = C(() => {
758
- const a = { _uid: y(), ...u };
759
- b((l) => [...l, a]);
760
- }, [u]), E = C(() => {
761
- b((a) => a.filter((l) => !s.includes(l._uid))), _([]);
762
- }, [s]), N = C((a, l, o) => {
763
- b((g) => g.map((D) => D._uid === a ? { ...D, [l]: o } : D));
764
- }, []), T = C((a) => {
765
- _((l) => l.includes(a) ? l.filter((o) => o !== a) : [...l, a]);
766
- }, []), f = C(
767
- (a) => {
768
- _(a ? i.map((l) => l._uid) : []);
800
+ const n = JSON.stringify(d);
801
+ m.value !== n && m.onChange(n);
802
+ }, [d, m, c]);
803
+ const C = j(() => {
804
+ const n = { _uid: x(), ...a };
805
+ p((s) => [...s, n]);
806
+ }, [a]), y = j(() => {
807
+ p((n) => n.filter((s) => !i.includes(s._uid))), v([]);
808
+ }, [i]), R = j((n, s, u) => {
809
+ p((k) => k.map((I) => I._uid === n ? { ...I, [s]: u } : I));
810
+ }, []), D = j((n) => {
811
+ v((s) => s.includes(n) ? s.filter((u) => u !== n) : [...s, n]);
812
+ }, []), _ = j(
813
+ (n) => {
814
+ v(n ? d.map((s) => s._uid) : []);
769
815
  },
770
- [i]
771
- ), p = i.length > 0 && s.length === i.length, n = j(() => !d || d.length === 0 ? i : i.filter(
772
- (a) => d.every((l) => {
773
- if ("custom" in l)
774
- return l.custom(a);
775
- const o = a[l.field];
776
- switch (l.operator) {
816
+ [d]
817
+ ), g = d.length > 0 && i.length === d.length, r = z(() => !o || o.length === 0 ? d : d.filter(
818
+ (n) => o.every((s) => {
819
+ if ("custom" in s)
820
+ return s.custom(n);
821
+ const u = n[s.field];
822
+ switch (s.operator) {
777
823
  case "===":
778
- return o === l.value;
824
+ return u === s.value;
779
825
  case "!==":
780
- return o !== l.value;
826
+ return u !== s.value;
781
827
  case ">":
782
- return o > l.value;
828
+ return u > s.value;
783
829
  case "<":
784
- return o < l.value;
830
+ return u < s.value;
785
831
  case ">=":
786
- return o >= l.value;
832
+ return u >= s.value;
787
833
  case "<=":
788
- return o <= l.value;
834
+ return u <= s.value;
789
835
  default:
790
836
  return !0;
791
837
  }
792
838
  })
793
- ), [i, d]);
839
+ ), [d, o]);
794
840
  return {
795
841
  field: m,
796
- tableRows: i,
797
- visibleRows: n,
798
- selectedRowIds: s,
799
- isAllSelected: p,
842
+ tableRows: d,
843
+ visibleRows: r,
844
+ selectedRowIds: i,
845
+ isAllSelected: g,
800
846
  handle: {
801
- addRow: I,
802
- removeRows: E,
803
- updateCellValue: N,
804
- toggleSelection: T,
805
- toggleSelectAll: f
847
+ addRow: C,
848
+ removeRows: y,
849
+ updateCellValue: R,
850
+ toggleSelection: D,
851
+ toggleSelectAll: _
806
852
  }
807
853
  };
808
854
  }
809
- const dt = ({
810
- name: e,
811
- title: r = "Tabela Dinâmica",
812
- columns: u,
813
- defaultRowValue: h = {},
855
+ const pt = ({
856
+ name: t,
857
+ title: l = "Tabela Dinâmica",
858
+ columns: a,
859
+ defaultRowValue: f = {},
814
860
  forceReadOnly: c = !1,
815
- layout: d = "fluid",
861
+ layout: o = "fluid",
816
862
  actions: m = !0,
817
- filters: i = []
863
+ filters: d = []
818
864
  }) => {
819
- const { control: b } = F(), { isView: s, isReadOnly: _ } = P(), { isReadOnly: y } = Y(), A = c || s || _ || y && y(e), { field: I, visibleRows: E, selectedRowIds: N, isAllSelected: T, handle: f } = qe({
820
- name: e,
821
- control: b,
822
- defaultRowValue: h,
823
- isView: s,
824
- isReadOnly: !!A,
825
- filters: i
826
- }), p = d === "fixed";
827
- return /* @__PURE__ */ w("div", { className: `table-wrapper ${p ? "table-fixed" : "table-fluid"}`, children: [
828
- /* @__PURE__ */ t("input", { type: "hidden", ...I }),
829
- /* @__PURE__ */ w("div", { className: "header-handle", children: [
830
- /* @__PURE__ */ t("h3", { children: r }),
831
- !A && m && /* @__PURE__ */ w("div", { className: "handle-actions", children: [
832
- /* @__PURE__ */ w(
865
+ const { control: p } = U(), { isView: i, isReadOnly: v } = Y(), { isReadOnly: x } = G(), S = c || i || v || x && x(t), { field: C, visibleRows: y, selectedRowIds: R, isAllSelected: D, handle: _ } = et({
866
+ name: t,
867
+ control: p,
868
+ defaultRowValue: f,
869
+ isView: i,
870
+ isReadOnly: !!S,
871
+ filters: d
872
+ }), g = o === "fixed";
873
+ return /* @__PURE__ */ h("div", { className: `table-wrapper ${g ? "table-fixed" : "table-fluid"}`, children: [
874
+ /* @__PURE__ */ e("input", { type: "hidden", ...C }),
875
+ /* @__PURE__ */ h("div", { className: "header-handle", children: [
876
+ /* @__PURE__ */ e("h3", { children: l }),
877
+ !S && m && /* @__PURE__ */ h("div", { className: "handle-actions", children: [
878
+ /* @__PURE__ */ h(
833
879
  "button",
834
880
  {
835
881
  type: "button",
836
- className: `btn ${N.length > 0 ? "btn-danger" : "btn-primary"}`,
837
- disabled: N.length === 0,
838
- onClick: f.removeRows,
882
+ className: `btn ${R.length > 0 ? "btn-danger" : "btn-primary"}`,
883
+ disabled: R.length === 0,
884
+ onClick: _.removeRows,
839
885
  children: [
840
886
  "Remover (",
841
- N.length,
887
+ R.length,
842
888
  ")"
843
889
  ]
844
890
  }
845
891
  ),
846
- /* @__PURE__ */ t("button", { type: "button", className: "btn-add", onClick: f.addRow, children: "Adicionar" })
892
+ /* @__PURE__ */ e("button", { type: "button", className: "btn-add", onClick: _.addRow, children: "Adicionar" })
847
893
  ] })
848
894
  ] }),
849
- /* @__PURE__ */ t("div", { className: "table-scroll", children: /* @__PURE__ */ w("table", { className: "table-custom", children: [
850
- /* @__PURE__ */ t("thead", { children: /* @__PURE__ */ w("tr", { children: [
851
- !A && /* @__PURE__ */ t("th", { style: { width: "50px" }, children: /* @__PURE__ */ t(
895
+ /* @__PURE__ */ e("div", { className: "table-scroll", children: /* @__PURE__ */ h("table", { className: "table-custom", children: [
896
+ /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ h("tr", { children: [
897
+ !S && /* @__PURE__ */ e("th", { style: { width: "50px" }, children: /* @__PURE__ */ e(
852
898
  "input",
853
899
  {
854
900
  type: "checkbox",
855
- checked: T,
856
- onChange: (n) => f.toggleSelectAll(n.target.checked)
901
+ checked: D,
902
+ onChange: (r) => _.toggleSelectAll(r.target.checked)
857
903
  }
858
904
  ) }),
859
- u.map((n) => /* @__PURE__ */ t(
905
+ a.map((r) => /* @__PURE__ */ e(
860
906
  "th",
861
907
  {
862
- style: n.width ? { minWidth: p ? n.width : "100%" } : { width: "max-content" },
863
- children: n.label
908
+ style: r.width ? { minWidth: g ? r.width : "100%" } : { width: "max-content" },
909
+ children: r.label
864
910
  },
865
- String(n.key)
911
+ String(r.key)
866
912
  ))
867
913
  ] }) }),
868
- /* @__PURE__ */ w("tbody", { children: [
869
- E.map((n, a) => /* @__PURE__ */ w("tr", { children: [
870
- !A && /* @__PURE__ */ t("td", { children: /* @__PURE__ */ t(
914
+ /* @__PURE__ */ h("tbody", { children: [
915
+ y.map((r, n) => /* @__PURE__ */ h("tr", { children: [
916
+ !S && /* @__PURE__ */ e("td", { children: /* @__PURE__ */ e(
871
917
  "input",
872
918
  {
873
919
  type: "checkbox",
874
- checked: N.includes(n._uid),
875
- onChange: () => f.toggleSelection(n._uid)
920
+ checked: R.includes(r._uid),
921
+ onChange: () => _.toggleSelection(r._uid)
876
922
  }
877
923
  ) }),
878
- u.map((l) => /* @__PURE__ */ t("td", { children: l.render ? l.render.length <= 1 ? l.render({
879
- row: n,
880
- index: a,
881
- updateRow: (o, g) => f.updateCellValue(n._uid, String(o), g),
882
- isLocked: !!A,
883
- isView: !!s
884
- }) : l.render(
924
+ a.map((s) => /* @__PURE__ */ e("td", { children: s.render ? s.render.length <= 1 ? s.render({
925
+ row: r,
926
+ index: n,
927
+ updateRow: (u, k) => _.updateCellValue(r._uid, String(u), k),
928
+ isLocked: !!S,
929
+ isView: !!i
930
+ }) : s.render(
931
+ r,
885
932
  n,
886
- a,
887
- (o, g) => f.updateCellValue(n._uid, o, g),
888
- !!A,
889
- !!s
890
- ) : n[l.key] }, `${n._uid}-${String(l.key)}`))
891
- ] }, n._uid)),
892
- E.length === 0 && /* @__PURE__ */ t("tr", { className: "empty-row", children: /* @__PURE__ */ t("td", { colSpan: 100, className: "text-center", children: A ? "Nenhum registro encontrado." : "Nenhum registro." }) })
933
+ (u, k) => _.updateCellValue(r._uid, u, k),
934
+ !!S,
935
+ !!i
936
+ ) : r[s.key] }, `${r._uid}-${String(s.key)}`))
937
+ ] }, r._uid)),
938
+ y.length === 0 && /* @__PURE__ */ e("tr", { className: "empty-row", children: /* @__PURE__ */ e("td", { colSpan: 100, className: "text-center", children: S ? "Nenhum registro encontrado." : "Nenhum registro." }) })
893
939
  ] })
894
940
  ] }) })
895
941
  ] });
896
- }, Qe = (e, r) => {
897
- const [u, h] = U(null);
942
+ }, tt = (t, l) => {
943
+ const [a, f] = P(null);
898
944
  let c = null;
899
945
  try {
900
- c = F().watch;
946
+ c = U().watch;
901
947
  } catch {
902
948
  }
903
- const d = r !== void 0 ? r : c ? c(e) : void 0, m = C(() => {
949
+ const o = l !== void 0 ? l : c ? c(t) : void 0, m = j(() => {
904
950
  try {
905
- const b = window.top.__REACT_ATTACHMENT_BRIDGE__;
906
- if (b) {
907
- const s = b.getAttachment(e, d);
908
- h(s || (d ? { name: d, documentId: 0 } : null));
951
+ const p = window.top.__REACT_ATTACHMENT_BRIDGE__;
952
+ if (p) {
953
+ const i = p.getAttachment(t, o);
954
+ f(i || (o ? { name: o, documentId: 0 } : null));
909
955
  } else
910
- h(d ? { name: d, documentId: 0 } : null);
956
+ f(o ? { name: o, documentId: 0 } : null);
911
957
  } catch {
912
- h(d ? { name: d, documentId: 0 } : null);
958
+ f(o ? { name: o, documentId: 0 } : null);
913
959
  }
914
- }, [e, d, r]);
915
- return H(() => {
960
+ }, [t, o, l]);
961
+ return T(() => {
916
962
  m();
917
- const i = setInterval(m, 2e3);
918
- return () => clearInterval(i);
919
- }, [m]), { attachment: u, sync: m };
920
- }, Ze = ({
921
- name: e,
922
- label: r,
923
- help: u,
924
- valueManual: h,
963
+ const d = setInterval(m, 2e3);
964
+ return () => clearInterval(d);
965
+ }, [m]), { attachment: a, sync: m };
966
+ }, st = ({
967
+ name: t,
968
+ label: l,
969
+ help: a,
970
+ valueManual: f,
925
971
  onChangeManual: c,
926
- forceReadOnly: d = !1,
927
- forceHidden: m = !1
972
+ forceReadOnly: o = !1,
973
+ forceHidden: m = !1,
974
+ helpText: d,
975
+ helpTitle: p,
976
+ helpWidth: i
928
977
  }) => {
929
- const i = !!c, { isReadOnly: b, isHidden: s } = Y(), { isView: _ } = P(), y = d || _ || !!b(e), A = m || !!s(e), [I, E] = U(!1);
930
- let N = null;
978
+ const v = !!c, { isReadOnly: x, isHidden: S } = G(), { isView: C } = Y(), y = o || C || !!x(t), R = m || !!S(t), [D, _] = P(!1);
979
+ let g = null;
931
980
  try {
932
- N = F().control;
981
+ g = U().control;
933
982
  } catch {
934
983
  }
935
- const T = N && !i ? z({ name: e, control: N }).field : {
936
- value: h,
937
- onChange: (O) => c == null ? void 0 : c(O)
938
- }, { attachment: f, sync: p } = Qe(e, h), n = () => {
939
- var O;
984
+ const r = g && !v ? W({ name: t, control: g }).field : {
985
+ value: f,
986
+ onChange: (w) => c == null ? void 0 : c(w)
987
+ }, { attachment: n, sync: s } = tt(t, f), u = () => {
988
+ var w;
940
989
  try {
941
- const x = window.top;
990
+ const N = window.top;
942
991
  return {
943
- bridge: x.__REACT_ATTACHMENT_BRIDGE__,
944
- toast: (O = x.FLUIGC) == null ? void 0 : O.toast
992
+ bridge: N.__REACT_ATTACHMENT_BRIDGE__,
993
+ toast: (w = N.FLUIGC) == null ? void 0 : w.toast
945
994
  };
946
995
  } catch {
947
996
  return { bridge: null, toast: null };
948
997
  }
949
- }, a = C(() => {
998
+ }, k = j(() => {
950
999
  if (y) return;
951
- const O = document.createElement("input");
952
- O.type = "file", O.onchange = (x) => {
953
- const v = x.target.files[0];
954
- if (!v) return;
955
- const { bridge: $, toast: V } = n();
956
- E(!0), $ ? $.upload(v, e, (S) => {
957
- i ? c == null || c(S.name) : T.onChange(S.name), setTimeout(() => {
958
- E(!1), p();
959
- }, 1e3), V && V({
1000
+ const w = document.createElement("input");
1001
+ w.type = "file", w.onchange = (N) => {
1002
+ const A = N.target.files[0];
1003
+ if (!A) return;
1004
+ const { bridge: b, toast: E } = u();
1005
+ _(!0), b ? b.upload(A, t, (L) => {
1006
+ v ? c == null || c(L.name) : r.onChange(L.name), setTimeout(() => {
1007
+ _(!1), s();
1008
+ }, 1e3), E && E({
960
1009
  title: "Sucesso",
961
1010
  message: "Arquivo enviado",
962
1011
  type: "success"
963
1012
  });
964
- }) : (i ? c == null || c(v.name) : T.onChange(v.name), E(!1));
965
- }, O.click();
966
- }, [e, T, p, c, y, i]), l = (O) => {
967
- if (O.stopPropagation(), y) return;
968
- const x = (f == null ? void 0 : f.name) || h || T.value;
969
- if (!x) return;
970
- const { bridge: v, toast: $ } = n();
971
- v ? v.removeByFileName(x) ? (i ? c == null || c("") : T.onChange(""), p()) : $ && $({
1013
+ }) : (v ? c == null || c(A.name) : r.onChange(A.name), _(!1));
1014
+ }, w.click();
1015
+ }, [t, r, s, c, y, v]), I = (w) => {
1016
+ if (w.stopPropagation(), y) return;
1017
+ const N = (n == null ? void 0 : n.name) || f || r.value;
1018
+ if (!N) return;
1019
+ const { bridge: A, toast: b } = u();
1020
+ A ? A.removeByFileName(N) ? (v ? c == null || c("") : r.onChange(""), s()) : b && b({
972
1021
  title: "Erro",
973
1022
  message: "Erro ao remover anexo",
974
1023
  type: "danger"
975
- }) : (i ? c == null || c("") : T.onChange(""), p());
976
- }, o = !!f && !I, g = (f == null ? void 0 : f.name) || h || T.value, D = [
1024
+ }) : (v ? c == null || c("") : r.onChange(""), s());
1025
+ }, B = !!n && !D, V = (n == null ? void 0 : n.name) || f || r.value, O = [
977
1026
  "fluig-attachment__box",
978
- o ? "fluig-attachment__box--has-file" : "",
979
- I ? "fluig-attachment__box--uploading" : "",
980
- y && !o ? "readOnly" : "",
981
- y && o ? "fluig-attachment__box--readonly-view" : ""
1027
+ B ? "fluig-attachment__box--has-file" : "",
1028
+ D ? "fluig-attachment__box--uploading" : "",
1029
+ y && !B ? "readOnly" : "",
1030
+ y && B ? "fluig-attachment__box--readonly-view" : ""
982
1031
  ].join(" ");
983
- return A ? null : /* @__PURE__ */ w("div", { className: "form-group fluig-attachment", children: [
984
- r && /* @__PURE__ */ t("label", { className: "fluig-attachment__label", children: r }),
985
- /* @__PURE__ */ w(
986
- "div",
987
- {
988
- className: D,
989
- onClick: () => {
990
- if (o) {
991
- const O = n(), x = (f == null ? void 0 : f.physicalFileName) || (f == null ? void 0 : f.description) || (f == null ? void 0 : f.name) || g;
992
- O.bridge && x && O.bridge.view(x);
993
- } else
994
- a();
995
- },
996
- children: [
997
- /* @__PURE__ */ w("span", { className: "fluig-attachment__content", children: [
998
- /* @__PURE__ */ t(
999
- "i",
1000
- {
1001
- className: `flaticon icon-sm ${I ? "flaticon-loading" : o ? "flaticon-file" : "flaticon-paperclip"} fluig-attachment__icon`
1002
- }
1003
- ),
1004
- /* @__PURE__ */ t("span", { className: "fluig-attachment__filename", children: I ? " Enviando..." : o ? g : y ? "Nenhum arquivo" : u || "Anexar" })
1005
- ] }),
1006
- o && !y && /* @__PURE__ */ t(
1007
- "button",
1008
- {
1009
- type: "button",
1010
- className: "fluig-attachment__btn-remove btn btn-link text-danger",
1011
- onClick: l,
1012
- children: /* @__PURE__ */ t("i", { className: "flaticon flaticon-trash icon-sm" })
1013
- }
1014
- )
1015
- ]
1016
- }
1017
- ),
1018
- !i && N && /* @__PURE__ */ t("input", { type: "hidden", name: e, value: T.value || "" })
1019
- ] });
1020
- }, at = W(Ze);
1021
- function ut({
1022
- title: e,
1023
- isOpen: r,
1024
- onOpen: u,
1025
- onClose: h,
1026
- content: c,
1027
- footer: d,
1028
- width: m
1029
- }) {
1030
- const i = C(
1031
- (b) => {
1032
- b.key === "Escape" && h();
1033
- },
1034
- [h]
1035
- );
1036
- return H(() => (r && (document.addEventListener("keydown", i), u == null || u(), document.body.style.overflow = "hidden"), () => {
1037
- document.removeEventListener("keydown", i), document.body.style.overflow = "auto";
1038
- }), [r, i, u]), r ? /* @__PURE__ */ t(
1039
- "div",
1040
- {
1041
- className: "modal-overlay",
1042
- onClick: h,
1043
- "aria-modal": "true",
1044
- role: "dialog",
1045
- children: /* @__PURE__ */ w(
1032
+ return R ? null : /* @__PURE__ */ h("div", { className: "form-group fluig-attachment", children: [
1033
+ l && /* @__PURE__ */ e("label", { className: "fluig-attachment__label", children: l }),
1034
+ /* @__PURE__ */ h("div", { className: d ? "dfe-flex-input-wrapper" : "", children: [
1035
+ /* @__PURE__ */ h(
1046
1036
  "div",
1047
1037
  {
1048
- style: { maxWidth: m },
1049
- className: "modal-container",
1050
- onClick: (b) => b.stopPropagation(),
1038
+ className: O,
1039
+ style: d ? { flex: 1 } : void 0,
1040
+ onClick: () => {
1041
+ if (B) {
1042
+ const w = u(), N = (n == null ? void 0 : n.physicalFileName) || (n == null ? void 0 : n.description) || (n == null ? void 0 : n.name) || V;
1043
+ w.bridge && N && w.bridge.view(N);
1044
+ } else
1045
+ k();
1046
+ },
1051
1047
  children: [
1052
- /* @__PURE__ */ w("div", { className: "modal-header", children: [
1053
- /* @__PURE__ */ t("h3", { children: e }),
1054
- /* @__PURE__ */ t(
1055
- "div",
1048
+ /* @__PURE__ */ h("span", { className: "fluig-attachment__content", children: [
1049
+ /* @__PURE__ */ e(
1050
+ "i",
1056
1051
  {
1057
- className: "btn-close-modal",
1058
- onClick: h,
1059
- role: "button",
1060
- "aria-label": "Fechar modal",
1061
- children: /* @__PURE__ */ t(
1062
- "i",
1063
- {
1064
- className: "flaticon flaticon-close icon-md",
1065
- "aria-hidden": "true"
1066
- }
1067
- )
1052
+ className: `flaticon icon-sm ${D ? "flaticon-loading" : B ? "flaticon-file" : "flaticon-paperclip"} fluig-attachment__icon`
1068
1053
  }
1069
- )
1054
+ ),
1055
+ /* @__PURE__ */ e("span", { className: "fluig-attachment__filename", children: D ? " Enviando..." : B ? V : y ? "Nenhum arquivo" : a || "Anexar" })
1070
1056
  ] }),
1071
- /* @__PURE__ */ t("div", { className: "modal-content", children: c }),
1072
- d && /* @__PURE__ */ t("div", { className: "modal-footer", children: d })
1057
+ B && !y && /* @__PURE__ */ e(
1058
+ "button",
1059
+ {
1060
+ type: "button",
1061
+ className: "fluig-attachment__btn-remove btn btn-link text-danger",
1062
+ onClick: I,
1063
+ children: /* @__PURE__ */ e("i", { className: "flaticon flaticon-trash icon-sm" })
1064
+ }
1065
+ )
1073
1066
  ]
1074
1067
  }
1075
- )
1076
- }
1077
- ) : null;
1078
- }
1068
+ ),
1069
+ d && /* @__PURE__ */ e(Z, { text: d, title: p, width: i })
1070
+ ] }),
1071
+ !v && g && /* @__PURE__ */ e("input", { type: "hidden", name: t, value: r.value || "" })
1072
+ ] });
1073
+ }, vt = q(st);
1079
1074
  export {
1080
- at as Attachment,
1081
- nt as Checkbox,
1082
- it as DatePicker,
1083
- rt as Input,
1084
- ut as Modal,
1085
- lt as RadioBtn,
1086
- M as Select,
1087
- dt as SimpleTable,
1088
- ot as StatusBadge,
1089
- ct as TextArea
1075
+ vt as Attachment,
1076
+ at as Checkbox,
1077
+ mt as DatePicker,
1078
+ Z as Help,
1079
+ ot as Input,
1080
+ Ie as Modal,
1081
+ ut as RadioBtn,
1082
+ re as Select,
1083
+ pt as SimpleTable,
1084
+ ht as StatusBadge,
1085
+ ft as TextArea
1090
1086
  };