@archbase/template 3.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,1589 @@
1
+ import { jsx as e, Fragment as Fe, jsxs as C } from "react/jsx-runtime";
2
+ import { Button as Pe, Paper as Je, Box as Se, ScrollArea as it, LoadingOverlay as ot, Group as ge, useMantineColorScheme as He, Modal as lt, Flex as ce, px as vt, Text as bt, Grid as he, Pagination as st } from "@mantine/core";
3
+ import { useForceUpdate as at, useUncontrolled as wt, useHotkeys as At } from "@mantine/hooks";
4
+ import { IconBug as Ge, IconDeviceFloppy as yt, IconX as Te, IconCheck as ct, IconPlus as We, IconEdit as Ke, IconTrash as Qe, IconEye as Xe } from "@tabler/icons-react";
5
+ import { useArchbaseAppContext as xe, useValidationErrors as Ct, ValidationErrorsProvider as dt, getI18nextInstance as p, processErrorMessage as ae, useArchbaseTheme as Ye, emit as Ft, useArchbaseTranslation as Rt } from "@archbase/core";
6
+ import Ie, { useMemo as Ce, useState as te, forwardRef as Et, useRef as se, useImperativeHandle as It, useEffect as ut, Fragment as Tt, Profiler as Dt, createContext as Vt, useCallback as Be, useContext as ht } from "react";
7
+ import { useArchbaseV1V2Compatibility as De, useArchbaseDataSourceListener as Ze, DataSourceEventNames as fe } from "@archbase/data";
8
+ import { ArchbaseAlert as $e, ArchbaseDialog as ft, ArchbaseDataGrid as St, GridToolBarActions as Bt, ArchbaseDebugInspector as Nt, ArchbaseMasonryProvider as Pt, ArchbaseMasonryResponsive as Gt, ArchbaseMasonry as $t, ArchbaseActionButtons as mt } from "@archbase/components";
9
+ import { ArchbaseSpaceFixed as Oe, ArchbaseSpaceTop as pt, ArchbaseSpaceFill as et, ArchbaseForm as gt, ArchbaseSpaceBottom as tt } from "@archbase/layout";
10
+ import { ArchbaseQueryBuilder as rt, buildFrom as Ut, ArchbaseGlobalFilter as jt } from "@archbase/advanced";
11
+ import Ne from "@rehooks/component-size";
12
+ import { uniqueId as Lt } from "lodash";
13
+ const kt = {
14
+ isAvailable: !1,
15
+ hasPermission: () => !0,
16
+ // Default: sempre permite
17
+ registerAction: () => {
18
+ },
19
+ // Default: no-op
20
+ canCreate: !0,
21
+ canEdit: !0,
22
+ canDelete: !0,
23
+ canView: !0
24
+ }, me = (t) => Ce(() => kt, []), lr = () => !1, ie = ({
25
+ actionName: t,
26
+ actionDescription: r,
27
+ children: a,
28
+ fallback: d = null,
29
+ autoRegister: n = !0,
30
+ onClick: o,
31
+ ...h
32
+ }) => {
33
+ const m = me();
34
+ return Ie.useEffect(() => {
35
+ n && t && r && m.isAvailable && m.registerAction();
36
+ }, [t, r, n, m.isAvailable, m.registerAction]), !t || !m.isAvailable ? /* @__PURE__ */ e(Pe, { onClick: o, ...h, children: a }) : m.hasPermission() ? /* @__PURE__ */ e(Pe, { onClick: o, ...h, children: a }) : /* @__PURE__ */ e(Fe, { children: d });
37
+ }, sr = ({
38
+ actionName: t,
39
+ actionDescription: r,
40
+ children: a,
41
+ fallback: d = null,
42
+ onClick: n,
43
+ ...o
44
+ }) => {
45
+ const [h, m] = Ie.useState(null), [T, v] = Ie.useState(!1);
46
+ return Ie.useEffect(() => {
47
+ if (!t) {
48
+ m(/* @__PURE__ */ e(Pe, { onClick: n, ...o, children: a }));
49
+ return;
50
+ }
51
+ v(!1), m(/* @__PURE__ */ e(Pe, { onClick: n, ...o, children: a }));
52
+ }, [t, r, a, d, o]), /* @__PURE__ */ e(Fe, { children: h });
53
+ }, ve = ({
54
+ children: t
55
+ }) => /* @__PURE__ */ e(Fe, { children: t }), ar = (t) => Ce(() => ({
56
+ shouldWrap: !1,
57
+ isSecurityAvailable: !1,
58
+ hasResourceName: !!t
59
+ }), [t]);
60
+ function cr({
61
+ innerRef: t,
62
+ title: r,
63
+ isError: a = !1,
64
+ isCanceling: d = !1,
65
+ isSaving: n = !1,
66
+ error: o = "",
67
+ clearError: h = () => {
68
+ },
69
+ autoCloseAlertError: m = 15e3,
70
+ width: T = "100%",
71
+ height: v = "100%",
72
+ withBorder: O = !0,
73
+ children: l,
74
+ radius: c,
75
+ variant: q,
76
+ footerAlign: A = "left",
77
+ footerContent: D,
78
+ dataSource: f,
79
+ onSave: B,
80
+ onCancel: W,
81
+ onBeforeSave: N,
82
+ onAfterSave: Y,
83
+ onBeforeCancel: b,
84
+ onAfterCancel: x,
85
+ onError: y,
86
+ // Props de segurança (opcionais)
87
+ resourceName: Z,
88
+ resourceDescription: K,
89
+ requiredPermissions: P,
90
+ fallbackComponent: E,
91
+ securityOptions: F,
92
+ ...G
93
+ }) {
94
+ const w = xe(), [$, R] = te(a), [re, Q] = te(o), M = at();
95
+ me({
96
+ autoRegisterActions: F?.autoRegisterActions ?? !0
97
+ });
98
+ const V = De(
99
+ "ArchbaseFormTemplate",
100
+ f,
101
+ void 0,
102
+ void 0
103
+ );
104
+ Ze({
105
+ dataSource: f,
106
+ listener: (I) => {
107
+ I.type === fe.onError && (R(!0), Q(I.error)), (I.type === fe.afterEdit || I.type === fe.afterInsert) && (V.isDataSourceV2 || M());
108
+ }
109
+ });
110
+ const U = Ct(), _ = async (I) => {
111
+ try {
112
+ B ? B(I) : (N && await N(I), f.isBrowsing() || f.save().then(() => {
113
+ U?.clearAll(), Y && Y(I);
114
+ }).catch((ee) => {
115
+ y && y(ae(ee)), R(!0), Q(ae(ee));
116
+ }));
117
+ } catch (ee) {
118
+ y && y(ae(ee)), R(!0), Q(ae(ee));
119
+ }
120
+ }, J = () => {
121
+ try {
122
+ W ? W() : (b && b(), f.isBrowsing() || f.cancel(), U?.clearAll(), x && x());
123
+ } catch (I) {
124
+ y && y(ae(I)), R(!0), Q(ae(I));
125
+ }
126
+ }, X = () => {
127
+ h && h(), R(!1), Q("");
128
+ };
129
+ return /* @__PURE__ */ e(
130
+ ve,
131
+ {
132
+ resourceName: Z,
133
+ resourceDescription: K,
134
+ requiredPermissions: P,
135
+ fallbackComponent: E,
136
+ onSecurityReady: F?.onSecurityReady,
137
+ onAccessDenied: F?.onAccessDenied,
138
+ children: /* @__PURE__ */ e(dt, { children: /* @__PURE__ */ C(
139
+ Je,
140
+ {
141
+ ref: t,
142
+ withBorder: O,
143
+ radius: c,
144
+ style: {
145
+ width: T,
146
+ height: v,
147
+ display: "flex",
148
+ flexDirection: "column",
149
+ padding: 4
150
+ },
151
+ children: [
152
+ $ && /* @__PURE__ */ e(Se, { style: { flexShrink: 0 }, children: /* @__PURE__ */ e(
153
+ $e,
154
+ {
155
+ autoClose: m,
156
+ withCloseButton: !0,
157
+ withBorder: !0,
158
+ icon: /* @__PURE__ */ e(Ge, { size: "1.4rem" }),
159
+ title: p().t("WARNING"),
160
+ titleColor: "rgb(250, 82, 82)",
161
+ variant: q ?? w.variant,
162
+ onClose: X,
163
+ children: /* @__PURE__ */ e("span", { children: re })
164
+ }
165
+ ) }),
166
+ /* @__PURE__ */ C(
167
+ it,
168
+ {
169
+ style: {
170
+ flex: 1,
171
+ minHeight: 0,
172
+ // Importante para flex funcionar
173
+ padding: "calc(0.625rem / 2)"
174
+ },
175
+ children: [
176
+ /* @__PURE__ */ e(ot, { visible: d || n, opacity: 0.3 }),
177
+ l
178
+ ]
179
+ }
180
+ ),
181
+ /* @__PURE__ */ C(
182
+ Se,
183
+ {
184
+ style: {
185
+ flexShrink: 0,
186
+ padding: "calc(0.625rem / 2)",
187
+ display: "flex",
188
+ justifyContent: A === "center" ? "center" : "space-between",
189
+ alignItems: "center",
190
+ gap: "1rem"
191
+ },
192
+ children: [
193
+ A === "right" && D && /* @__PURE__ */ e(Se, { style: { flex: 1 }, children: D }),
194
+ f && !f.isBrowsing() ? /* @__PURE__ */ C(ge, { gap: "md", children: [
195
+ /* @__PURE__ */ e(
196
+ ie,
197
+ {
198
+ actionName: "save",
199
+ actionDescription: `Salvar ${K || "registro"}`,
200
+ leftSection: /* @__PURE__ */ e(yt, {}),
201
+ onClick: () => _(f.getCurrentRecord()),
202
+ disabled: f && f.isBrowsing(),
203
+ variant: q ?? w.variant,
204
+ color: "green",
205
+ children: `${p().t("Ok")}`
206
+ }
207
+ ),
208
+ /* @__PURE__ */ e(
209
+ ie,
210
+ {
211
+ actionName: "cancel",
212
+ actionDescription: "Cancelar operação",
213
+ leftSection: /* @__PURE__ */ e(Te, {}),
214
+ onClick: J,
215
+ disabled: f && f.isBrowsing(),
216
+ variant: q ?? w.variant,
217
+ color: "red",
218
+ children: `${p().t("Cancel")}`
219
+ }
220
+ )
221
+ ] }) : /* @__PURE__ */ e(ge, { gap: "md", children: /* @__PURE__ */ e(
222
+ ie,
223
+ {
224
+ actionName: "close",
225
+ actionDescription: "Fechar formulário",
226
+ leftSection: /* @__PURE__ */ e(Te, {}),
227
+ onClick: J,
228
+ variant: q ?? w.variant,
229
+ children: `${p().t("Close")}`
230
+ }
231
+ ) }),
232
+ (A === "left" || A === "center") && D && /* @__PURE__ */ e(Se, { style: { flex: A === "left" ? 1 : 0, textAlign: "right" }, children: D })
233
+ ]
234
+ }
235
+ )
236
+ ]
237
+ }
238
+ ) })
239
+ }
240
+ );
241
+ }
242
+ function dr({
243
+ title: t,
244
+ withOverlay: r = !0,
245
+ overlayProps: a,
246
+ children: d,
247
+ withCloseButton: n = !0,
248
+ closeButtonProps: o,
249
+ opened: h,
250
+ fullScreen: m,
251
+ centered: T,
252
+ variant: v,
253
+ closeOnEscape: O = !0,
254
+ size: l,
255
+ dataSource: c,
256
+ height: q,
257
+ userActions: A,
258
+ onAfterSave: D,
259
+ onClickOk: f,
260
+ onClickCancel: B,
261
+ onBeforeOk: W,
262
+ onCustomSave: N,
263
+ isError: Y,
264
+ error: b = "",
265
+ clearError: x = () => {
266
+ },
267
+ onError: y,
268
+ autoCloseAlertError: Z = 15e3,
269
+ loadingOverlayStyles: K,
270
+ // Props de segurança (opcionais)
271
+ resourceName: P,
272
+ resourceDescription: E,
273
+ requiredPermissions: F,
274
+ fallbackComponent: G,
275
+ securityOptions: w,
276
+ ...$
277
+ }) {
278
+ const R = xe(), re = Ye(), { colorScheme: Q } = He(), [M, V] = te(Y), [U, _] = te(b), [J, X] = te(!1), I = at();
279
+ me({
280
+ resourceDescription: E || t?.toString(),
281
+ autoRegisterActions: w?.autoRegisterActions ?? !0
282
+ });
283
+ const ee = De(
284
+ "ArchbaseFormModalTemplate",
285
+ c,
286
+ void 0,
287
+ void 0
288
+ );
289
+ Ze({
290
+ dataSource: c,
291
+ listener: (j) => {
292
+ j.type === fe.onError && (V(!0), _(j.error)), (j.type === fe.afterEdit || j.type === fe.afterInsert) && (ee.isDataSourceV2 || I());
293
+ }
294
+ });
295
+ const ue = async () => {
296
+ if (c && !c.isBrowsing())
297
+ try {
298
+ X(!0), await c.save(), D && D(c.getCurrentRecord());
299
+ } catch (j) {
300
+ return y && y(ae(j)), V(!0), _(ae(j)), X(!1), !1;
301
+ }
302
+ return X(!1), !0;
303
+ }, s = () => {
304
+ if (c && !c.isBrowsing())
305
+ try {
306
+ c.cancel();
307
+ } catch {
308
+ }
309
+ }, H = async () => {
310
+ if (N)
311
+ c && N(c.getCurrentRecord(), () => {
312
+ f && f();
313
+ });
314
+ else if (W) {
315
+ const j = W(c.getCurrentRecord());
316
+ j instanceof Promise && j.then(async () => {
317
+ await ue() && f && f();
318
+ }).catch((be) => {
319
+ y && y(ae(be)), V(!0), _(ae(be));
320
+ });
321
+ } else
322
+ await ue() && f && f();
323
+ }, S = () => {
324
+ s(), B && B();
325
+ }, oe = () => {
326
+ ft.showWarning(p().t("archbase:Click on Ok or Cancel to close"));
327
+ }, pe = () => {
328
+ x && x(), V(!1), _("");
329
+ };
330
+ return /* @__PURE__ */ e(
331
+ ve,
332
+ {
333
+ resourceName: P,
334
+ resourceDescription: E,
335
+ requiredPermissions: F,
336
+ fallbackComponent: G,
337
+ onSecurityReady: w?.onSecurityReady,
338
+ onAccessDenied: w?.onAccessDenied,
339
+ children: /* @__PURE__ */ e(
340
+ lt,
341
+ {
342
+ title: t,
343
+ withOverlay: r,
344
+ overlayProps: a || {
345
+ color: Q === "dark" ? re.colors.dark[7] : re.colors.gray[6],
346
+ opacity: 0.25
347
+ },
348
+ withCloseButton: n,
349
+ closeButtonProps: o,
350
+ onClose: oe,
351
+ opened: h,
352
+ fullScreen: m,
353
+ centered: T,
354
+ closeOnEscape: O,
355
+ size: l,
356
+ ...$,
357
+ children: /* @__PURE__ */ C(dt, { children: [
358
+ /* @__PURE__ */ e(ot, { styles: K, visible: J, opacity: 0.8 }),
359
+ /* @__PURE__ */ C(Oe, { height: q, children: [
360
+ M ? /* @__PURE__ */ e(pt, { size: "100px", children: /* @__PURE__ */ e(
361
+ $e,
362
+ {
363
+ autoClose: Z,
364
+ withCloseButton: !0,
365
+ withBorder: !0,
366
+ icon: /* @__PURE__ */ e(Ge, { size: "1.4rem" }),
367
+ title: p().t("WARNING"),
368
+ titleColor: "rgb(250, 82, 82)",
369
+ variant: v ?? R.variant,
370
+ onClose: pe,
371
+ children: /* @__PURE__ */ e("span", { children: U })
372
+ }
373
+ ) }) : null,
374
+ /* @__PURE__ */ e(et, { children: /* @__PURE__ */ e(gt, { children: d }) }),
375
+ /* @__PURE__ */ e(tt, { size: "40px", children: /* @__PURE__ */ C(ce, { justify: "space-between", align: "center", children: [
376
+ /* @__PURE__ */ e(ge, { children: A }),
377
+ c && !c.isBrowsing() ? /* @__PURE__ */ C(ge, { gap: "md", children: [
378
+ /* @__PURE__ */ e(
379
+ ie,
380
+ {
381
+ actionName: "save",
382
+ actionDescription: `Salvar ${E || t || "registro"}`,
383
+ leftSection: /* @__PURE__ */ e(ct, {}),
384
+ onClick: H,
385
+ disabled: c && c.isBrowsing(),
386
+ variant: v ?? R.variant,
387
+ color: "green",
388
+ children: `${p().t("Ok")}`
389
+ }
390
+ ),
391
+ /* @__PURE__ */ e(
392
+ ie,
393
+ {
394
+ actionName: "cancel",
395
+ actionDescription: "Cancelar operação",
396
+ leftSection: /* @__PURE__ */ e(Te, {}),
397
+ onClick: S,
398
+ disabled: c && c.isBrowsing(),
399
+ variant: v ?? R.variant,
400
+ color: "red",
401
+ children: `${p().t("Cancel")}`
402
+ }
403
+ )
404
+ ] }) : /* @__PURE__ */ e(ge, { gap: "md", children: /* @__PURE__ */ e(
405
+ ie,
406
+ {
407
+ actionName: "close",
408
+ actionDescription: "Fechar janela",
409
+ leftSection: /* @__PURE__ */ e(Te, {}),
410
+ onClick: S,
411
+ variant: v ?? R.variant,
412
+ children: `${p().t("Close")}`
413
+ }
414
+ ) })
415
+ ] }) })
416
+ ] })
417
+ ] })
418
+ }
419
+ )
420
+ }
421
+ );
422
+ }
423
+ function ur({
424
+ title: t,
425
+ withOverlay: r = !0,
426
+ overlayProps: a,
427
+ children: d,
428
+ withCloseButton: n = !0,
429
+ closeButtonProps: o,
430
+ opened: h,
431
+ fullScreen: m,
432
+ centered: T,
433
+ variant: v,
434
+ closeOnEscape: O = !0,
435
+ size: l,
436
+ height: c,
437
+ onlyOkButton: q = !1,
438
+ onClose: A,
439
+ onClickOk: D,
440
+ onClickCancel: f,
441
+ userActions: B,
442
+ // Props de segurança (opcionais)
443
+ resourceName: W,
444
+ resourceDescription: N,
445
+ requiredPermissions: Y,
446
+ fallbackComponent: b,
447
+ securityOptions: x
448
+ }) {
449
+ const y = xe(), Z = Ye(), { colorScheme: K } = He();
450
+ me({
451
+ autoRegisterActions: x?.autoRegisterActions ?? !0
452
+ });
453
+ const P = () => {
454
+ D && D(), A();
455
+ }, E = () => {
456
+ f && f(), A();
457
+ }, F = () => {
458
+ ft.showWarning(p().t("Click on Ok or Cancel to close"));
459
+ };
460
+ return /* @__PURE__ */ e(
461
+ ve,
462
+ {
463
+ resourceName: W,
464
+ resourceDescription: N,
465
+ requiredPermissions: Y,
466
+ fallbackComponent: b,
467
+ onSecurityReady: x?.onSecurityReady,
468
+ onAccessDenied: x?.onAccessDenied,
469
+ children: /* @__PURE__ */ e(
470
+ lt,
471
+ {
472
+ title: t,
473
+ withOverlay: r,
474
+ overlayProps: a || {
475
+ color: K === "dark" ? Z.colors.dark[7] : Z.colors.gray[6],
476
+ opacity: 0.25
477
+ },
478
+ withCloseButton: n,
479
+ closeButtonProps: o,
480
+ onClose: F,
481
+ opened: h,
482
+ fullScreen: m,
483
+ centered: T,
484
+ closeOnEscape: O,
485
+ size: l,
486
+ children: /* @__PURE__ */ C(Oe, { height: c, children: [
487
+ /* @__PURE__ */ e(et, { children: /* @__PURE__ */ e(gt, { children: d }) }),
488
+ /* @__PURE__ */ e(tt, { size: "40px", children: /* @__PURE__ */ C(ce, { justify: "space-between", align: "center", children: [
489
+ /* @__PURE__ */ e(ge, { children: B }),
490
+ /* @__PURE__ */ C(ge, { gap: "md", children: [
491
+ /* @__PURE__ */ e(
492
+ ie,
493
+ {
494
+ actionName: "save",
495
+ actionDescription: `Salvar ${N || "registro"}`,
496
+ leftSection: /* @__PURE__ */ e(ct, {}),
497
+ onClick: P,
498
+ variant: v ?? y.variant,
499
+ color: "green",
500
+ children: `${p().t("Ok")}`
501
+ }
502
+ ),
503
+ q ? null : /* @__PURE__ */ e(
504
+ ie,
505
+ {
506
+ actionName: "cancel",
507
+ actionDescription: "Cancelar operação",
508
+ leftSection: /* @__PURE__ */ e(Te, {}),
509
+ onClick: E,
510
+ variant: v ?? y.variant,
511
+ color: "red",
512
+ children: f ? `${p().t("Cancel")}` : `${p().t("Close")}`
513
+ }
514
+ )
515
+ ] })
516
+ ] }) })
517
+ ] })
518
+ }
519
+ )
520
+ }
521
+ );
522
+ }
523
+ const zt = (t, r, a) => {
524
+ if (!t || !r || !r.existsValue(`${t.viewName}_${t.componentName}`)) {
525
+ let d = -1, n;
526
+ return a && a.getFilters().length > 0 && (d = 0, n = JSON.parse(a.getFirstFilter()?.filter)), {
527
+ activeFilterIndex: d,
528
+ expandedFilter: !1,
529
+ currentFilter: n
530
+ };
531
+ }
532
+ return r.getValue(`${t.viewName}_${t.componentName}`);
533
+ };
534
+ function qt(t, r) {
535
+ const {
536
+ title: a,
537
+ printTitle: d,
538
+ dataSource: n,
539
+ filterOptions: o,
540
+ pageSize: h = 15,
541
+ pageIndex: m = 0,
542
+ columns: T,
543
+ filterFields: v,
544
+ logoPrint: O,
545
+ userActions: l,
546
+ userRowActions: c,
547
+ customRenderRowActions: q,
548
+ innerRef: A,
549
+ isLoading: D = !1,
550
+ isLoadingFilter: f = !1,
551
+ isError: B = !1,
552
+ enableTopToolbar: W = !0,
553
+ enableTopToolbarActions: N = !0,
554
+ error: Y = "",
555
+ clearError: b = () => {
556
+ },
557
+ filterType: x,
558
+ width: y = "100%",
559
+ height: Z = "100%",
560
+ onSearchByFilter: K,
561
+ getRowId: P,
562
+ withBorder: E = !0,
563
+ filterPersistenceDelegator: F,
564
+ variant: G,
565
+ store: w,
566
+ cellPadding: $,
567
+ bottomToolbarMinHeight: R,
568
+ enableRowSelection: re = !0,
569
+ enableRowNumbers: Q = !0,
570
+ enableRowActions: M = !0,
571
+ positionActionsColumn: V = "first",
572
+ tableHeadCellPadding: U,
573
+ renderDetailPanel: _,
574
+ renderTopToolbar: J,
575
+ toolbarAlignment: X = "right",
576
+ toolbarLeftContent: I,
577
+ onSelectedRowsChanged: ee,
578
+ onCellDoubleClick: ue,
579
+ paginationLabels: s,
580
+ // Props de segurança (opcionais)
581
+ resourceName: H,
582
+ resourceDescription: S,
583
+ requiredPermissions: oe,
584
+ fallbackComponent: pe,
585
+ securityOptions: j
586
+ } = t, be = se(null), L = se(null);
587
+ Ye();
588
+ const { colorScheme: Ve } = He();
589
+ me({
590
+ autoRegisterActions: j?.autoRegisterActions ?? !0
591
+ });
592
+ const we = De(
593
+ "ArchbaseGridTemplate",
594
+ n,
595
+ void 0,
596
+ void 0
597
+ );
598
+ It(r, () => ({
599
+ refreshData: () => {
600
+ L.current && L.current.refreshData();
601
+ },
602
+ getSelectedRows: () => L.current ? L.current.getSelectedRows() : [],
603
+ clearSelection: () => {
604
+ L.current && L.current.clearSelection();
605
+ },
606
+ exportData: () => {
607
+ L.current && L.current.exportData();
608
+ },
609
+ printData: () => {
610
+ L.current && L.current.printData();
611
+ },
612
+ getDataGridRef: () => L
613
+ }), [L]);
614
+ const [k, Ae] = te({
615
+ activeFilterIndex: -1,
616
+ currentFilter: void 0,
617
+ expandedFilter: !1
618
+ });
619
+ ut(() => {
620
+ const u = zt(o, w, F);
621
+ Ae(u);
622
+ }, [f]);
623
+ const Ue = (u) => {
624
+ if (q)
625
+ return q(u);
626
+ if (!c || !c.actions)
627
+ return;
628
+ const ne = c.actions;
629
+ return /* @__PURE__ */ e(
630
+ ne,
631
+ {
632
+ onEditRow: c.onEditRow ? (z) => c.onEditRow && c.onEditRow(z) : void 0,
633
+ onRemoveRow: c.onRemoveRow ? (z) => c.onRemoveRow && c.onRemoveRow(z) : void 0,
634
+ onViewRow: c.onViewRow ? (z) => c.onViewRow && c.onViewRow(z) : void 0,
635
+ row: u,
636
+ variant: G ?? de.variant
637
+ }
638
+ );
639
+ }, de = xe(), ye = se(null);
640
+ Ie.useEffect(() => {
641
+ A && A.current !== ye.current && A.current && ye.current && (A.current = ye.current);
642
+ }, [A]);
643
+ const je = (u, ne) => {
644
+ const z = { ...k, currentFilter: u, activeFilterIndex: ne };
645
+ Ae(z), w && o && w?.setValue(`${o.viewName}_${o.componentName}`, z);
646
+ }, Le = (u) => {
647
+ const ne = { ...k, expandedFilter: u };
648
+ Ae(ne), w && o && w?.setValue(`${o.viewName}_${o.componentName}`, ne);
649
+ }, ke = (u, ne) => {
650
+ const z = { ...k, currentFilter: u, activeFilterIndex: ne };
651
+ Ae(z), w && o && w?.setValue(`${o.viewName}_${o.componentName}`, z);
652
+ }, ze = () => {
653
+ if (k.currentFilter)
654
+ if (K)
655
+ K();
656
+ else if (k.currentFilter.filter.filterType === "quick") {
657
+ const u = n.getOptions();
658
+ k.currentFilter.filter.quickFilterText && k.currentFilter.filter.quickFilterText !== "" ? (u.filter = JSON.stringify({
659
+ search: k.currentFilter.filter.quickFilterText,
660
+ fields: k.currentFilter.filter.quickFilterFieldsText
661
+ }), u.sort = k.currentFilter.sort.quickFilterSort ? k.currentFilter.sort.quickFilterSort.split(",") : []) : (u.filter = void 0, u.sort = void 0), n.refreshData(u), we.isDataSourceV2 || we.v1State.forceUpdate();
662
+ } else {
663
+ const u = Ut(k.currentFilter);
664
+ if (u && u.expressionNode) {
665
+ const ne = Ft(u.expressionNode), z = n.getOptions();
666
+ z.filter = ne, z.sort = u?.sortStrings, n.refreshData(z), we.isDataSourceV2 || we.v1State.forceUpdate();
667
+ }
668
+ }
669
+ };
670
+ let Re, Ee;
671
+ const qe = (u) => {
672
+ Re = u;
673
+ }, Me = (u) => {
674
+ Ee = u;
675
+ }, i = () => {
676
+ Ee && Ee();
677
+ }, g = () => {
678
+ Re && Re();
679
+ }, le = () => x === "none" ? /* @__PURE__ */ e("div", {}) : x === "advanced" ? /* @__PURE__ */ e(
680
+ rt,
681
+ {
682
+ id: o?.componentName,
683
+ viewName: o?.viewName,
684
+ apiVersion: o?.apiVersion,
685
+ ref: be,
686
+ variant: G ?? de.variant,
687
+ expandedFilter: k.expandedFilter,
688
+ persistenceDelegator: F,
689
+ currentFilter: k.currentFilter,
690
+ activeFilterIndex: k.activeFilterIndex,
691
+ onSelectedFilter: ke,
692
+ onFilterChanged: je,
693
+ onSearchByFilter: ze,
694
+ onToggleExpandedFilter: Le,
695
+ onExport: i,
696
+ onPrint: g,
697
+ showExportButton: !0,
698
+ showPrintButton: !0,
699
+ width: "560px",
700
+ height: "170px",
701
+ children: v
702
+ }
703
+ ) : x === "normal" ? /* @__PURE__ */ e("div", {}) : /* @__PURE__ */ e("div", {});
704
+ return /* @__PURE__ */ e(
705
+ ve,
706
+ {
707
+ resourceName: H,
708
+ resourceDescription: S,
709
+ requiredPermissions: oe,
710
+ fallbackComponent: pe,
711
+ onSecurityReady: j?.onSecurityReady,
712
+ onAccessDenied: j?.onAccessDenied,
713
+ children: /* @__PURE__ */ C(Je, { withBorder: E, ref: ye, style: { overflow: "none", height: "calc(100% - 4px)" }, children: [
714
+ B ? /* @__PURE__ */ e(
715
+ $e,
716
+ {
717
+ autoClose: 2e4,
718
+ withCloseButton: !0,
719
+ withBorder: !0,
720
+ icon: /* @__PURE__ */ e(Ge, { size: "1.4rem" }),
721
+ title: p().t("archbase:WARNING"),
722
+ titleColor: "rgb(250, 82, 82)",
723
+ variant: G ?? de.variant,
724
+ onClose: () => b && b(),
725
+ children: /* @__PURE__ */ e("span", { children: Y })
726
+ }
727
+ ) : null,
728
+ /* @__PURE__ */ C(
729
+ St,
730
+ {
731
+ gridRef: L,
732
+ printTitle: d || a,
733
+ logoPrint: O,
734
+ width: y,
735
+ height: Z,
736
+ withBorder: E,
737
+ dataSource: n,
738
+ enableColumnResizing: !0,
739
+ enableRowNumbers: Q,
740
+ enableRowSelection: re,
741
+ enableRowActions: M,
742
+ enableTopToolbar: W,
743
+ enableTopToolbarActions: N,
744
+ manualPagination: !0,
745
+ manualSorting: !0,
746
+ isLoading: D,
747
+ pageSize: h,
748
+ pageIndex: m,
749
+ allowColumnFilters: x !== "none",
750
+ enableGlobalFilter: x !== "none",
751
+ renderToolbarInternalActions: x == "none" ? () => /* @__PURE__ */ e("div", {}) : void 0,
752
+ allowExportData: !0,
753
+ allowPrintData: !0,
754
+ onSelectedRowsChanged: ee,
755
+ onCellDoubleClick: ue,
756
+ renderRowActions: M ? Ue : void 0,
757
+ positionActionsColumn: V,
758
+ toolbarAlignment: X,
759
+ toolbarLeftContent: I,
760
+ renderToolbarActions: x === "advanced" || x === "none" ? le : void 0,
761
+ paginationLabels: s,
762
+ cellPadding: $,
763
+ bottomToolbarMinHeight: R,
764
+ tableHeadCellPadding: U,
765
+ getRowId: P,
766
+ renderDetailPanel: _ ? ({ row: u }) => _({ row: u }) : void 0,
767
+ renderTopToolbar: J,
768
+ onExport: Me,
769
+ onPrint: qe,
770
+ variant: G,
771
+ children: [
772
+ T,
773
+ l?.visible ? /* @__PURE__ */ e(Bt, { children: /* @__PURE__ */ C(Fe, { children: [
774
+ /* @__PURE__ */ e("h3", { className: "only-print", children: d || a }),
775
+ /* @__PURE__ */ e("div", { className: "no-print", children: /* @__PURE__ */ C(ce, { gap: "8px", rowGap: "8px", children: [
776
+ l.customUserActions && l.customUserActionsPosition === "left" ? l.customUserActions : null,
777
+ l.onAddExecute ? /* @__PURE__ */ e(
778
+ ie,
779
+ {
780
+ actionName: "add",
781
+ actionDescription: `Adicionar novo ${S || "registro"}`,
782
+ color: "green",
783
+ variant: G ?? de.variant,
784
+ leftSection: /* @__PURE__ */ e(We, {}),
785
+ onClick: () => l && l.onAddExecute && l.onAddExecute(),
786
+ children: l.labelAdd || p().t("archbase:New")
787
+ }
788
+ ) : null,
789
+ l.onEditExecute ? /* @__PURE__ */ e(
790
+ ie,
791
+ {
792
+ actionName: "edit",
793
+ actionDescription: `Editar ${S || "registro"}`,
794
+ color: "blue",
795
+ leftSection: /* @__PURE__ */ e(Ke, {}),
796
+ disabled: !n.isBrowsing() || n.isEmpty(),
797
+ variant: G ?? de.variant,
798
+ onClick: () => l && l.onEditExecute && l.onEditExecute(),
799
+ children: l.labelEdit || p().t("archbase:Edit")
800
+ }
801
+ ) : null,
802
+ l.onRemoveExecute ? /* @__PURE__ */ e(
803
+ ie,
804
+ {
805
+ actionName: "delete",
806
+ actionDescription: `Remover ${S || "registro"}`,
807
+ color: "red",
808
+ leftSection: /* @__PURE__ */ e(Qe, {}),
809
+ disabled: !l?.allowRemove || !n.isBrowsing() || n.isEmpty(),
810
+ variant: G ?? de.variant,
811
+ onClick: () => l && l.onRemoveExecute && l.onRemoveExecute(),
812
+ children: l.labelRemove || p().t("archbase:Remove")
813
+ }
814
+ ) : null,
815
+ l.onViewExecute ? /* @__PURE__ */ e(
816
+ ie,
817
+ {
818
+ actionName: "view",
819
+ actionDescription: `Visualizar ${S || "registro"}`,
820
+ color: "gray.7",
821
+ leftSection: /* @__PURE__ */ e(Xe, {}),
822
+ disabled: !n.isBrowsing() || n.isEmpty(),
823
+ variant: G ?? de.variant,
824
+ onClick: () => l && l.onViewExecute && l.onViewExecute(),
825
+ children: l.labelView || p().t("archbase:View")
826
+ }
827
+ ) : null,
828
+ l.customUserActions && l.customUserActionsPosition === "right" ? l.customUserActions : null
829
+ ] }) })
830
+ ] }) }) : null
831
+ ]
832
+ }
833
+ )
834
+ ] })
835
+ }
836
+ );
837
+ }
838
+ const hr = Et(qt);
839
+ function Mt(t, r, a, d) {
840
+ if (t && t.headerGridColumns) {
841
+ const n = t.headerGridColumns.left ? t.headerGridColumns.left : { xs: "auto", sm: "auto", md: "auto", lg: "auto" }, o = t.headerGridColumns.middle ? t.headerGridColumns.middle : { xs: "auto", sm: "auto", md: "auto", lg: "auto" }, h = t.headerGridColumns.right ? t.headerGridColumns.right : { xs: "auto", sm: "auto", md: "auto", lg: "auto" };
842
+ return /* @__PURE__ */ C(he, { m: 0, gutter: "xs", justify: "center", align: "center", grow: !0, children: [
843
+ /* @__PURE__ */ e(
844
+ he.Col,
845
+ {
846
+ span: {
847
+ xs: n.xs,
848
+ sm: n.sm,
849
+ md: n.md,
850
+ lg: n.lg
851
+ },
852
+ style: {
853
+ border: d ? "1px dashed" : "",
854
+ display: "flex",
855
+ justifyContent: "flex-start",
856
+ alignItems: "center"
857
+ },
858
+ children: r
859
+ }
860
+ ),
861
+ /* @__PURE__ */ e(
862
+ he.Col,
863
+ {
864
+ span: {
865
+ xs: o.xs,
866
+ sm: o.sm,
867
+ md: o.md,
868
+ lg: o.lg
869
+ },
870
+ style: {
871
+ border: d ? "1px dashed" : "",
872
+ display: "flex",
873
+ justifyContent: "center",
874
+ alignItems: "center"
875
+ }
876
+ }
877
+ ),
878
+ /* @__PURE__ */ e(
879
+ he.Col,
880
+ {
881
+ span: {
882
+ xs: h.xs,
883
+ sm: h.sm,
884
+ md: h.md,
885
+ lg: h.lg
886
+ },
887
+ style: {
888
+ border: d ? "1px dashed" : "",
889
+ display: "flex",
890
+ justifyContent: "flex-end",
891
+ alignItems: "center"
892
+ },
893
+ children: a
894
+ }
895
+ )
896
+ ] });
897
+ } else {
898
+ const n = t && t.headerFlexGrow ? t.headerFlexGrow : "even", o = t && t.headerFlexRightJustifyContent ? t.headerFlexRightJustifyContent : "flex-end", h = t && t.headerFlexLeftJustifyContent ? t.headerFlexLeftJustifyContent : "flex-start";
899
+ return /* @__PURE__ */ C(ce, { justify: "space-between", children: [
900
+ /* @__PURE__ */ e(
901
+ ce,
902
+ {
903
+ w: n === "left" || n === "even" ? "100%" : void 0,
904
+ maw: n === "left" || n === "even" ? void 0 : "100%",
905
+ align: "center",
906
+ justify: h,
907
+ style: {
908
+ border: d ? "1px dashed" : ""
909
+ },
910
+ children: r
911
+ }
912
+ ),
913
+ /* @__PURE__ */ e(
914
+ ce,
915
+ {
916
+ w: n === "right" || n === "even" ? "100%" : void 0,
917
+ maw: n === "right" || n === "even" ? void 0 : "100%",
918
+ align: "center",
919
+ justify: o,
920
+ style: {
921
+ border: d ? "1px dashed" : ""
922
+ },
923
+ children: a
924
+ }
925
+ )
926
+ ] });
927
+ }
928
+ }
929
+ function _t(t, r, a, d) {
930
+ if (t && t.footerGridColumns) {
931
+ const n = t.footerGridColumns.left ? t.footerGridColumns.left : { xs: "content", sm: "content", md: "content", lg: "content" }, o = t.footerGridColumns.middle ? t.footerGridColumns.middle : { xs: "auto", sm: "auto", md: "auto", lg: "auto" }, h = t.footerGridColumns.right ? t.footerGridColumns.right : { xs: "content", sm: "content", md: "content", lg: "content" };
932
+ return /* @__PURE__ */ C(he, { m: 0, gutter: "xs", justify: "center", align: "center", grow: !0, children: [
933
+ /* @__PURE__ */ e(
934
+ he.Col,
935
+ {
936
+ span: {
937
+ xs: n.xs,
938
+ sm: n.sm,
939
+ md: n.md,
940
+ lg: n.lg
941
+ },
942
+ style: {
943
+ border: d ? "1px dashed" : "",
944
+ display: "flex",
945
+ justifyContent: "flex-start",
946
+ alignItems: "center"
947
+ },
948
+ children: r
949
+ }
950
+ ),
951
+ /* @__PURE__ */ e(
952
+ he.Col,
953
+ {
954
+ span: {
955
+ xs: o.xs,
956
+ sm: o.sm,
957
+ md: o.md,
958
+ lg: o.lg
959
+ },
960
+ style: {
961
+ border: d ? "1px dashed" : "",
962
+ display: "flex",
963
+ justifyContent: "center",
964
+ alignItems: "center"
965
+ }
966
+ }
967
+ ),
968
+ /* @__PURE__ */ e(
969
+ he.Col,
970
+ {
971
+ span: {
972
+ xs: h.xs,
973
+ sm: h.sm,
974
+ md: h.md,
975
+ lg: h.lg
976
+ },
977
+ style: {
978
+ border: d ? "1px dashed" : "",
979
+ display: "flex",
980
+ justifyContent: "flex-end",
981
+ alignItems: "center"
982
+ },
983
+ children: a
984
+ }
985
+ )
986
+ ] });
987
+ } else {
988
+ const n = t && t.footerFlexGrow ? t.footerFlexGrow : "even", o = t && t.footerFlexRightJustifyContent ? t.footerFlexRightJustifyContent : "flex-end", h = t && t.footerFlexLeftJustifyContent ? t.footerFlexLeftJustifyContent : "flex-start";
989
+ return /* @__PURE__ */ C(ce, { justify: "space-between", children: [
990
+ /* @__PURE__ */ e(
991
+ ce,
992
+ {
993
+ w: n === "left" || n === "even" ? "100%" : void 0,
994
+ maw: n === "left" || n === "even" ? void 0 : "100%",
995
+ align: "center",
996
+ justify: h,
997
+ style: {
998
+ border: d ? "1px dashed" : "",
999
+ height: "auto",
1000
+ padding: r && "calc(0.625rem / 2)"
1001
+ },
1002
+ children: r
1003
+ }
1004
+ ),
1005
+ /* @__PURE__ */ e(
1006
+ ce,
1007
+ {
1008
+ w: n === "right" || n === "even" ? "100%" : void 0,
1009
+ maw: n === "right" || n === "even" ? void 0 : "100%",
1010
+ align: "center",
1011
+ justify: o,
1012
+ style: {
1013
+ border: d ? "1px dashed" : "",
1014
+ height: "auto",
1015
+ padding: a && "calc(0.625rem / 2)"
1016
+ },
1017
+ children: a
1018
+ }
1019
+ )
1020
+ ] });
1021
+ }
1022
+ }
1023
+ function xt({
1024
+ title: t,
1025
+ innerRef: r,
1026
+ isError: a = !1,
1027
+ error: d = "",
1028
+ clearError: n,
1029
+ width: o = "100%",
1030
+ height: h = "100%",
1031
+ withBorder: m = !0,
1032
+ children: T,
1033
+ radius: v,
1034
+ debug: O,
1035
+ defaultDebug: l,
1036
+ headerLeft: c,
1037
+ headerMiddle: q,
1038
+ headerRight: A,
1039
+ footerLeft: D,
1040
+ footerMiddle: f,
1041
+ footerRight: B,
1042
+ variant: W,
1043
+ options: N = {},
1044
+ style: Y,
1045
+ debugOptions: b = {
1046
+ debugLayoutHotKey: "ctrl+shift+S",
1047
+ debugObjectInspectorHotKey: "ctrl+shift+D",
1048
+ objectsToInspect: []
1049
+ },
1050
+ // Props de segurança (opcionais)
1051
+ resourceName: x,
1052
+ resourceDescription: y,
1053
+ requiredPermissions: Z,
1054
+ fallbackComponent: K,
1055
+ securityOptions: P
1056
+ }) {
1057
+ const [E, F] = wt({
1058
+ value: O,
1059
+ defaultValue: l,
1060
+ finalValue: !1
1061
+ });
1062
+ At([[b && b.debugLayoutHotKey, () => F(!E)]]);
1063
+ const G = xe(), { t: w } = Rt();
1064
+ me({
1065
+ autoRegisterActions: P?.autoRegisterActions ?? !0
1066
+ });
1067
+ const $ = se(null), R = r || $, re = se(null), Q = se(null), M = Ne(re), V = Ne(Q), U = Ne(R), _ = Ce(() => ({
1068
+ height: U.height - M.height - V.height - Number(vt("0.625rem")),
1069
+ width: U.width - M.width - V.width
1070
+ }), [U.height, U.width, M.height, M.width, V.height, V.width]), J = se(l);
1071
+ ut(() => {
1072
+ l !== J.current && (F(l), J.current = l);
1073
+ }, [l, F]);
1074
+ const X = /* @__PURE__ */ C(Fe, { children: [
1075
+ /* @__PURE__ */ e(
1076
+ Je,
1077
+ {
1078
+ ref: R,
1079
+ withBorder: m,
1080
+ radius: v,
1081
+ style: { width: o, height: h, padding: 4, ...Y },
1082
+ children: /* @__PURE__ */ C(Oe, { height: "100%", children: [
1083
+ /* @__PURE__ */ e(pt, { size: M.height, children: /* @__PURE__ */ e("div", { ref: re, children: Mt(N, c, A, E) }) }),
1084
+ /* @__PURE__ */ e(et, { children: /* @__PURE__ */ e(
1085
+ it,
1086
+ {
1087
+ h: _.height,
1088
+ style: {
1089
+ border: E ? "1px dashed" : "",
1090
+ padding: "calc(0.625rem / 2)"
1091
+ },
1092
+ children: T ? /* @__PURE__ */ C(Tt, { children: [
1093
+ a && /* @__PURE__ */ e(
1094
+ $e,
1095
+ {
1096
+ autoClose: 2e4,
1097
+ withCloseButton: !0,
1098
+ withBorder: !0,
1099
+ icon: /* @__PURE__ */ e(Ge, { size: "1.4rem" }),
1100
+ title: `${w("WARNING")}`,
1101
+ titleColor: "rgb(250, 82, 82)",
1102
+ variant: W ?? G.variant,
1103
+ onClose: () => n && n(),
1104
+ children: /* @__PURE__ */ e("span", { children: d })
1105
+ }
1106
+ ),
1107
+ T
1108
+ ] }) : E && /* @__PURE__ */ e(ce, { h: _.height + 80, justify: "center", align: "center", wrap: "wrap", children: /* @__PURE__ */ e(bt, { size: "lg", children: "INSIRA O CONTEÚDO DO PAINEL AQUI." }) })
1109
+ }
1110
+ ) }),
1111
+ /* @__PURE__ */ e(tt, { size: V.height, children: /* @__PURE__ */ e("div", { ref: Q, children: _t(N, D, B, E) }) })
1112
+ ] })
1113
+ }
1114
+ ),
1115
+ /* @__PURE__ */ e(
1116
+ Nt,
1117
+ {
1118
+ debugObjectInspectorHotKey: b && b.debugObjectInspectorHotKey,
1119
+ objectsToInspect: b && b.objectsToInspect
1120
+ }
1121
+ )
1122
+ ] });
1123
+ return /* @__PURE__ */ e(
1124
+ ve,
1125
+ {
1126
+ resourceName: x,
1127
+ resourceDescription: y,
1128
+ requiredPermissions: Z,
1129
+ fallbackComponent: K,
1130
+ onSecurityReady: P?.onSecurityReady,
1131
+ onAccessDenied: P?.onAccessDenied,
1132
+ children: X
1133
+ }
1134
+ );
1135
+ }
1136
+ const Jt = {
1137
+ visible: !0,
1138
+ allowAdd: !0,
1139
+ allowEdit: !0,
1140
+ allowView: !0,
1141
+ allowRemove: !0,
1142
+ positionCustomUserActions: "after"
1143
+ };
1144
+ function Ht(t, r, a, d, n, o) {
1145
+ console.log(`Render de "${t}" na fase "${r}": ${a}ms`);
1146
+ }
1147
+ function fr({
1148
+ title: t,
1149
+ dataSource: r,
1150
+ // dataSourceEdition,
1151
+ filterOptions: a,
1152
+ globalFilterFieldNames: d,
1153
+ //pageSize,
1154
+ filterFields: n,
1155
+ innerRef: o,
1156
+ //isLoading = false,
1157
+ debug: h = !1,
1158
+ filterType: m = "normal",
1159
+ isError: T = !1,
1160
+ error: v = "",
1161
+ clearError: O = () => {
1162
+ },
1163
+ width: l = "100%",
1164
+ height: c = "100%",
1165
+ withBorder: q = !0,
1166
+ filterPersistenceDelegator: A,
1167
+ withPagination: D = !0,
1168
+ radius: f,
1169
+ userActions: B,
1170
+ columnsCountBreakPoints: W,
1171
+ columnsCount: N,
1172
+ gutter: Y,
1173
+ component: b,
1174
+ activeIndex: x,
1175
+ activeBackgroundColor: y,
1176
+ activeColor: Z,
1177
+ onItemEnter: K,
1178
+ onItemLeave: P,
1179
+ style: E,
1180
+ actionsButtonsOptions: F,
1181
+ spaceOptions: G,
1182
+ variant: w,
1183
+ id: $ = Lt("masonry"),
1184
+ debugOptions: R,
1185
+ // Props de segurança (opcionais)
1186
+ resourceName: re,
1187
+ resourceDescription: Q,
1188
+ requiredPermissions: M,
1189
+ fallbackComponent: V,
1190
+ securityOptions: U
1191
+ }) {
1192
+ const _ = xe(), J = me({
1193
+ autoRegisterActions: U?.autoRegisterActions ?? !0
1194
+ }), [X] = te($), I = o || se(null), ee = se(null), [ue, s] = te(r.getCurrentPage()), [H, S] = te(
1195
+ x || (r && r.getTotalRecords() > 0 ? 0 : -1)
1196
+ );
1197
+ Ne(I);
1198
+ const [oe, pe] = te({
1199
+ activeFilterIndex: -1,
1200
+ expandedFilter: !1
1201
+ }), [j, be] = te(0), {
1202
+ isDataSourceV2: L,
1203
+ v1State: { forceUpdate: Ve }
1204
+ } = De(
1205
+ "ArchbaseMasonryTemplate",
1206
+ r
1207
+ );
1208
+ Ze({
1209
+ dataSource: r,
1210
+ listener: (i) => {
1211
+ (i.type === fe.afterRemove || i.type === fe.refreshData) && (be((g) => g + 1), L || Ve());
1212
+ }
1213
+ });
1214
+ const we = Ce(() => {
1215
+ const i = { ...Jt, ...B }, g = [], le = (u) => J.isAvailable ? (J.registerAction(), J.hasPermission()) : !0;
1216
+ return i.allowAdd && i.onAddExecute && le() && g.push({
1217
+ id: "actAdd",
1218
+ icon: /* @__PURE__ */ e(We, {}),
1219
+ color: "green",
1220
+ label: i.labelAdd ? i.labelAdd : p().t("archbase:New"),
1221
+ executeAction: () => {
1222
+ i && i.onAddExecute && i.onAddExecute();
1223
+ },
1224
+ enabled: !0,
1225
+ hint: `${p().t("archbase:Clique para criar um novo registro")}`
1226
+ }), i.allowEdit && i.onEditExecute && le() && g.push({
1227
+ id: "actEdit",
1228
+ icon: /* @__PURE__ */ e(Ke, {}),
1229
+ color: "blue",
1230
+ label: i.labelEdit ? i.labelEdit : p().t("archbase:Edit"),
1231
+ executeAction: () => {
1232
+ i && i.onEditExecute && i.onEditExecute();
1233
+ },
1234
+ enabled: !r.isEmpty() && r.isBrowsing(),
1235
+ hint: `${p().t("archbase:Clique para editar o registro")}`
1236
+ }), i.allowRemove && i.onRemoveExecute && le() && g.push({
1237
+ id: "actRemove",
1238
+ icon: /* @__PURE__ */ e(Qe, {}),
1239
+ color: "red",
1240
+ label: i.labelRemove ? i.labelRemove : p().t("archbase:Remove"),
1241
+ executeAction: () => {
1242
+ i && i.onRemoveExecute && i.onRemoveExecute();
1243
+ },
1244
+ enabled: !r.isEmpty() && r.isBrowsing(),
1245
+ hint: `${p().t("archbase:Clique para remover o registro")}`
1246
+ }), i.allowView && i.onViewExecute && le() && g.push({
1247
+ id: "actView",
1248
+ icon: /* @__PURE__ */ e(Xe, {}),
1249
+ label: i.labelView ? i.labelView : p().t("archbase:View"),
1250
+ executeAction: () => {
1251
+ i && i.onViewExecute && i.onViewExecute();
1252
+ },
1253
+ enabled: !r.isEmpty() && r.isBrowsing(),
1254
+ hint: `${p().t("archbase:Clique para visualizar o registro")}`
1255
+ }), i.customUserActions && i.positionCustomUserActions === "before" ? [...i.customUserActions, ...g] : i.customUserActions && i.positionCustomUserActions === "after" ? [...g, ...i.customUserActions] : g;
1256
+ }, [B, r, J]), k = Ce(() => {
1257
+ if (b) {
1258
+ const i = b.type;
1259
+ let g = {};
1260
+ return b.props && (g = b.props), r.browseRecords().map((le, u) => {
1261
+ const ne = `${X}_${u}`, z = `${X}_${u}`;
1262
+ let _e = le.active === void 0 ? !1 : le.active;
1263
+ return H >= 0 && (_e = !1, H === u && (_e = !0)), /* @__PURE__ */ e(
1264
+ i,
1265
+ {
1266
+ id: z,
1267
+ active: _e,
1268
+ index: u,
1269
+ dataSource: r,
1270
+ recordData: le,
1271
+ disabled: le.disabled,
1272
+ ...g
1273
+ },
1274
+ ne
1275
+ );
1276
+ });
1277
+ }
1278
+ return [];
1279
+ }, [H, b, X, r, j]), Ae = (i, g) => {
1280
+ pe({ ...oe, currentFilter: i, activeFilterIndex: g });
1281
+ }, Ue = (i) => {
1282
+ pe({ ...oe, expandedFilter: i });
1283
+ }, de = (i, g) => {
1284
+ pe({ ...oe, currentFilter: i, activeFilterIndex: g });
1285
+ }, ye = () => {
1286
+ }, je = (i, g) => {
1287
+ S(i), r && r.gotoRecordByData(g);
1288
+ }, Le = (i) => {
1289
+ if (r) {
1290
+ const g = r.getOptions();
1291
+ g.filter = i, g.currentPage = ue, r.refreshData(g), L || Ve();
1292
+ }
1293
+ }, ke = (i) => {
1294
+ if (r) {
1295
+ const g = r.getOptions();
1296
+ g.currentPage = i, r.refreshData(g), L || Ve();
1297
+ }
1298
+ }, ze = () => m === "normal" && d ? /* @__PURE__ */ e(
1299
+ jt,
1300
+ {
1301
+ searchableFields: d,
1302
+ onFilter: Le,
1303
+ minFilterValueLength: 1
1304
+ }
1305
+ ) : m === "advanced" ? /* @__PURE__ */ e(Dt, { id: `profile_${a.componentName}`, onRender: Ht, children: /* @__PURE__ */ e(
1306
+ rt,
1307
+ {
1308
+ id: a.componentName,
1309
+ viewName: a.viewName,
1310
+ apiVersion: a.apiVersion,
1311
+ ref: ee,
1312
+ variant: w || _.variant,
1313
+ expandedFilter: oe.expandedFilter,
1314
+ persistenceDelegator: A,
1315
+ currentFilter: oe.currentFilter,
1316
+ activeFilterIndex: oe.activeFilterIndex,
1317
+ onSelectedFilter: de,
1318
+ onFilterChanged: Ae,
1319
+ onSearchByFilter: ye,
1320
+ onToggleExpandedFilter: Ue,
1321
+ width: "660px",
1322
+ height: "170px",
1323
+ children: n
1324
+ }
1325
+ ) }) : /* @__PURE__ */ e(Fe, {}), Re = {
1326
+ menuButtonColor: "blue.5",
1327
+ menuPosition: "left"
1328
+ }, Ee = {
1329
+ headerFlexGrow: "left",
1330
+ footerGridColumns: {}
1331
+ }, qe = { ...Re, ...F }, Me = { ...Ee, ...G };
1332
+ return /* @__PURE__ */ e(
1333
+ ve,
1334
+ {
1335
+ resourceName: re,
1336
+ resourceDescription: Q,
1337
+ requiredPermissions: M,
1338
+ fallbackComponent: V,
1339
+ onSecurityReady: U?.onSecurityReady,
1340
+ onAccessDenied: U?.onAccessDenied,
1341
+ children: /* @__PURE__ */ e(
1342
+ xt,
1343
+ {
1344
+ innerRef: I,
1345
+ width: l,
1346
+ height: c,
1347
+ radius: f,
1348
+ withBorder: q,
1349
+ isError: T,
1350
+ error: v,
1351
+ clearError: O,
1352
+ title: t,
1353
+ defaultDebug: h,
1354
+ debugOptions: R,
1355
+ style: E,
1356
+ options: Me,
1357
+ headerLeft: /* @__PURE__ */ e(mt, { actions: we, options: qe }),
1358
+ headerRight: ze(),
1359
+ footerRight: D ? /* @__PURE__ */ e(st, { total: r.getTotalPages(), onChange: ke }) : void 0,
1360
+ children: /* @__PURE__ */ e(
1361
+ Pt,
1362
+ {
1363
+ value: {
1364
+ dataSource: r,
1365
+ ownerId: $,
1366
+ handleSelectItem: je,
1367
+ activeBackgroundColor: y,
1368
+ activeColor: Z,
1369
+ onItemEnter: K,
1370
+ onItemLeave: P
1371
+ },
1372
+ children: /* @__PURE__ */ e(Gt, { columnsCountBreakPoints: W, children: /* @__PURE__ */ e($t, { gutter: Y, columnsCount: N, children: k }) })
1373
+ }
1374
+ )
1375
+ }
1376
+ )
1377
+ }
1378
+ );
1379
+ }
1380
+ const Wt = {
1381
+ visible: !0,
1382
+ allowAdd: !0,
1383
+ allowEdit: !0,
1384
+ allowView: !0,
1385
+ allowRemove: !0,
1386
+ positionCustomUserActions: "after"
1387
+ };
1388
+ function mr({
1389
+ title: t,
1390
+ dataSource: r,
1391
+ // dataSourceEdition,
1392
+ filterOptions: a,
1393
+ //pageSize,
1394
+ filterFields: d,
1395
+ innerRef: n,
1396
+ //isLoading = false,
1397
+ isError: o = !1,
1398
+ error: h = "",
1399
+ clearError: m = () => {
1400
+ },
1401
+ width: T = "100%",
1402
+ height: v = "100%",
1403
+ withBorder: O = !0,
1404
+ filterPersistenceDelegator: l,
1405
+ withPagination: c = !0,
1406
+ children: q,
1407
+ radius: A,
1408
+ userActions: D,
1409
+ debug: f = !1,
1410
+ variant: B,
1411
+ actionsButtonsOptions: W,
1412
+ spaceOptions: N,
1413
+ style: Y,
1414
+ debugOptions: b,
1415
+ // Props de segurança (opcionais)
1416
+ resourceName: x,
1417
+ resourceDescription: y,
1418
+ requiredPermissions: Z,
1419
+ fallbackComponent: K,
1420
+ securityOptions: P
1421
+ }) {
1422
+ const E = xe(), F = me({
1423
+ autoRegisterActions: P?.autoRegisterActions ?? !0
1424
+ }), G = n || se(null), w = se(null), [$, R] = te({
1425
+ activeFilterIndex: -1,
1426
+ expandedFilter: !1
1427
+ }), {
1428
+ isDataSourceV2: re,
1429
+ v1State: { forceUpdate: Q }
1430
+ } = De(
1431
+ "ArchbasePanelTemplate",
1432
+ r
1433
+ ), M = Ce(() => {
1434
+ const s = { ...Wt, ...D }, H = (oe) => F.isAvailable ? (F.registerAction(), F.hasPermission()) : !0, S = [];
1435
+ return s.allowAdd && s.onAddExecute && H() && S.push({
1436
+ id: "1",
1437
+ icon: /* @__PURE__ */ e(We, {}),
1438
+ color: "green",
1439
+ label: s.labelAdd ? s.labelAdd : p().t("archbase:New"),
1440
+ executeAction: () => {
1441
+ s && s.onAddExecute && s.onAddExecute();
1442
+ },
1443
+ enabled: !0,
1444
+ hint: "Clique para criar."
1445
+ }), s.allowEdit && s.onEditExecute && H() && S.push({
1446
+ id: "2",
1447
+ icon: /* @__PURE__ */ e(Ke, {}),
1448
+ color: "blue",
1449
+ label: s.labelEdit ? s.labelEdit : p().t("archbase:Edit"),
1450
+ executeAction: () => {
1451
+ s && s.onEditExecute && s.onEditExecute();
1452
+ },
1453
+ enabled: !r.isEmpty() && r.isBrowsing(),
1454
+ hint: "Clique para editar."
1455
+ }), s.allowRemove && s.onRemoveExecute && H() && S.push({
1456
+ id: "3",
1457
+ icon: /* @__PURE__ */ e(Qe, {}),
1458
+ color: "red",
1459
+ label: s.labelRemove ? s.labelRemove : p().t("archbase:Remove"),
1460
+ executeAction: () => {
1461
+ s && s.onRemoveExecute && s.onRemoveExecute();
1462
+ },
1463
+ enabled: !r.isEmpty() && r.isBrowsing(),
1464
+ hint: "Clique para remover."
1465
+ }), s.allowView && s.onView && H() && S.push({
1466
+ id: "4",
1467
+ icon: /* @__PURE__ */ e(Xe, {}),
1468
+ color: "green",
1469
+ label: s.labelView ? s.labelView : p().t("archbase:View"),
1470
+ executeAction: () => {
1471
+ s && s.onView && s.onView();
1472
+ },
1473
+ enabled: !r.isEmpty() && r.isBrowsing(),
1474
+ hint: "Clique para visualizar."
1475
+ }), s.customUserActions && s.positionCustomUserActions === "before" ? [...s.customUserActions, ...S] : s.customUserActions && s.positionCustomUserActions === "after" ? [...S, ...s.customUserActions] : S;
1476
+ }, [D, r, F]), V = (s, H) => {
1477
+ R({ ...$, currentFilter: s, activeFilterIndex: H });
1478
+ }, U = (s) => {
1479
+ R({ ...$, expandedFilter: s });
1480
+ }, _ = (s, H) => {
1481
+ R({ ...$, currentFilter: s, activeFilterIndex: H });
1482
+ }, J = () => {
1483
+ }, X = {
1484
+ menuButtonColor: "blue.5",
1485
+ menuPosition: "left"
1486
+ }, I = {
1487
+ headerFlexGrow: "left",
1488
+ footerFlexGrow: "right"
1489
+ // footerGridColumns: {},
1490
+ }, ee = { ...X, ...W }, ue = { ...I, ...N };
1491
+ return /* @__PURE__ */ e(
1492
+ ve,
1493
+ {
1494
+ resourceName: x,
1495
+ resourceDescription: y,
1496
+ requiredPermissions: Z,
1497
+ fallbackComponent: K,
1498
+ onSecurityReady: P?.onSecurityReady,
1499
+ onAccessDenied: P?.onAccessDenied,
1500
+ children: /* @__PURE__ */ e(
1501
+ xt,
1502
+ {
1503
+ innerRef: G,
1504
+ width: T,
1505
+ height: v,
1506
+ radius: A,
1507
+ withBorder: O,
1508
+ isError: o,
1509
+ error: h,
1510
+ clearError: m,
1511
+ title: t,
1512
+ defaultDebug: f,
1513
+ debugOptions: b,
1514
+ style: Y,
1515
+ options: ue,
1516
+ headerLeft: /* @__PURE__ */ e(mt, { actions: M, options: ee }),
1517
+ headerRight: /* @__PURE__ */ e(
1518
+ rt,
1519
+ {
1520
+ id: a.componentName,
1521
+ viewName: a.viewName,
1522
+ apiVersion: a.apiVersion,
1523
+ ref: w,
1524
+ variant: B || E.variant,
1525
+ expandedFilter: $.expandedFilter,
1526
+ persistenceDelegator: l,
1527
+ currentFilter: $.currentFilter,
1528
+ activeFilterIndex: $.activeFilterIndex,
1529
+ onSelectedFilter: _,
1530
+ onFilterChanged: V,
1531
+ onSearchByFilter: J,
1532
+ onToggleExpandedFilter: U,
1533
+ width: "660px",
1534
+ height: "170px",
1535
+ children: d
1536
+ }
1537
+ ),
1538
+ footerRight: c && /* @__PURE__ */ e(st, { total: 10 }),
1539
+ children: q
1540
+ }
1541
+ )
1542
+ }
1543
+ );
1544
+ }
1545
+ function pr() {
1546
+ return /* @__PURE__ */ e("div", { children: "SEARCH TEMPLATE" });
1547
+ }
1548
+ const nt = Vt(void 0);
1549
+ function gr({ children: t }) {
1550
+ const [r, a] = te({}), d = Be((m, T) => {
1551
+ a((v) => ({ ...v, [m]: T }));
1552
+ }, []), n = Be((m) => {
1553
+ a((T) => {
1554
+ const v = { ...T };
1555
+ return delete v[m], v;
1556
+ });
1557
+ }, []), o = Be(() => {
1558
+ a({});
1559
+ }, []), h = Be((m) => r[m], [r]);
1560
+ return /* @__PURE__ */ e(nt.Provider, { value: { errors: r, setError: d, clearError: n, clearAll: o, getError: h }, children: t });
1561
+ }
1562
+ function xr() {
1563
+ return ht(nt);
1564
+ }
1565
+ function vr() {
1566
+ const t = ht(nt);
1567
+ if (!t)
1568
+ throw new Error("useRequiredValidationErrors must be used within ValidationErrorsProvider");
1569
+ return t;
1570
+ }
1571
+ export {
1572
+ sr as ArchbaseAdvancedSmartButton,
1573
+ ve as ArchbaseConditionalSecurityWrapper,
1574
+ dr as ArchbaseFormModalTemplate,
1575
+ cr as ArchbaseFormTemplate,
1576
+ hr as ArchbaseGridTemplate,
1577
+ fr as ArchbaseMasonryTemplate,
1578
+ ur as ArchbaseModalTemplate,
1579
+ mr as ArchbasePanelTemplate,
1580
+ pr as ArchbaseSearchTemplate,
1581
+ ie as ArchbaseSmartActionButton,
1582
+ xt as ArchbaseSpaceTemplate,
1583
+ gr as ValidationErrorsProvider,
1584
+ ar as useConditionalSecurity,
1585
+ me as useOptionalTemplateSecurity,
1586
+ vr as useRequiredValidationErrors,
1587
+ lr as useTemplateSecurityAvailable,
1588
+ xr as useValidationErrors
1589
+ };