mig-schema-table 4.4.32 → 5.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.
@@ -1,11 +1,1723 @@
1
- import { D as s, a as E, E as e, M, R as _, e as D, b as A, d as I } from "./index-CduHmUwk.js";
1
+ import { jsx as t, jsxs as O, Fragment as yt } from "react/jsx-runtime";
2
+ import * as Ft from "react";
3
+ import e from "react";
4
+ import { createPortal as jt } from "react-dom";
5
+ import { VariableSizeGrid as lt, VariableSizeList as Bt } from "react-window";
6
+ import { format as Qt, endOfDay as zt, differenceInSeconds as Ut } from "date-fns";
7
+ import { nl as Vt } from "date-fns/locale";
8
+ import { unCamel as Pt, emptyFn as we, timeZone as Te, localeFormatInTimeZone as vt, parseLocationHash as ct, serializeLocationHash as ze } from "mig-data-tools";
9
+ import { range as Jt, debounce as Zt, isEqual as et, isFinite as qt, sum as Gt } from "lodash";
10
+ import ut from "react-datepicker";
11
+ import { nl as dt } from "date-fns/locale/nl";
12
+ import { TZDate as Ue } from "@date-fns/tz";
13
+ import { useFloating as mt, flip as ht } from "@floating-ui/react-dom";
14
+ import Xt from "react-window-infinite-loader";
15
+ const tt = (r, o) => (
16
+ // replace jan. with jan
17
+ Qt(r, o, { locale: Vt }).replace(".", "")
18
+ ), Ht = {
19
+ "Europe/Amsterdam": "AMS",
20
+ "Europe/Berlin": "AMS",
21
+ "Asia/Jakarta": "JKT",
22
+ "Asia/Bangkok": "JKT",
23
+ showingFilteredCountOfTotalCount: "Showing {0} of {1}"
24
+ };
25
+ function ft(r, ...o) {
26
+ let g = Ht[r] || Pt(r);
27
+ return o.forEach((b, p) => {
28
+ g = g.replace(`{${p}}`, `${b}`);
29
+ }), g;
30
+ }
31
+ const K = "SELECT_ALL_COLUMN_NAME", gt = 40, wt = "dd MMM yyyy", Ve = "dd MMM yyyy HH:mm", kt = 25, bt = 50, Yt = 3;
32
+ var ge = /* @__PURE__ */ ((r) => (r.GT = "GT", r.LT = "LT", r.EQ = "EQ", r))(ge || {}), Se = /* @__PURE__ */ ((r) => (r.UNAVAILABLE = "UNAVAILABLE", r.AVAILABLE = "AVAILABLE", r.ACTIVE = "ACTIVE", r))(Se || {});
33
+ const Me = Ft.createContext({
34
+ checkedIndexes: [],
35
+ columnNames: [],
36
+ columnWidths: new Uint16Array(),
37
+ config: {},
38
+ disabledCheckedIndexes: [],
39
+ dropTargetIndex: -1,
40
+ isColumnFilterable: !1,
41
+ isItemLoaded: () => !1,
42
+ isSortable: !1,
43
+ properties: {},
44
+ required: [],
45
+ setCustomColumnNames: we,
46
+ setCustomColumnWidths: we,
47
+ setDropTargetIndex: we,
48
+ setFilterSortColumn: we,
49
+ setLastCheckChangedRowIndex: we,
50
+ setMenuConfig: we,
51
+ tableDataState: {
52
+ searchQuery: "",
53
+ columnFilterMap: {},
54
+ sortColumn: "",
55
+ sortAsc: !1
56
+ },
57
+ translate: we
58
+ }), Kt = { type: "boolean" }, en = ({ columnIndex: r, rowIndex: o, style: g }) => {
59
+ const {
60
+ checkedIndexes: b,
61
+ columnNames: p,
62
+ config: u,
63
+ disabledCheckedIndexes: S,
64
+ displayTimezone: _,
65
+ getRowClassName: R,
66
+ getRowSelected: W,
67
+ isItemLoaded: T,
68
+ lastCheckChangedRowIndex: N,
69
+ onRowClick: M,
70
+ onRowDoubleClick: v,
71
+ properties: $,
72
+ setCheckedIndexes: q,
73
+ setLastCheckChangedRowIndex: ee,
74
+ sortedRenderData: x,
75
+ sourceData: s,
76
+ translate: d
77
+ } = e.useContext(Me), h = p[r], y = h === K ? Kt : $[h], U = u ? u[h] : void 0, te = e.useCallback(
78
+ (w) => {
79
+ q && q((E) => E && E.includes(w) ? E.filter((A) => A !== w) : E ? [...E, w] : [w]);
80
+ },
81
+ [q]
82
+ ), le = T(o), ne = e.useCallback(
83
+ (w) => {
84
+ if (!s || !x || !M || !le)
85
+ return;
86
+ const { rowIndex: E } = w.currentTarget.dataset;
87
+ if (!E)
88
+ return;
89
+ const k = x[parseInt(E, 10)];
90
+ M(s[k._index], k._index, w);
91
+ },
92
+ [le, M, x, s]
93
+ ), C = e.useCallback(
94
+ (w) => {
95
+ if (!s || !x || !v || !T)
96
+ return;
97
+ const { rowIndex: E } = w.currentTarget.dataset;
98
+ if (!E)
99
+ return;
100
+ const k = x[parseInt(E, 10)];
101
+ v(s[k._index], k._index, w);
102
+ },
103
+ [T, v, x, s]
104
+ ), L = x ? x[o] : void 0, { showTimezones: oe, TdBody: G } = U || {}, re = e.useMemo(() => _ ? null : Te.startsWith("Europe/") ? "Asia/Jakarta" : "Europe/Amsterdam", [_]), B = e.useMemo(() => {
105
+ if (!L || !x)
106
+ return;
107
+ let w = h === K ? void 0 : L[h];
108
+ if (y?.format && y.format === "date-time" && oe !== !1) {
109
+ const k = s ? s[L._index] : void 0, A = k ? k[h] : void 0, ce = A ? new Date(A) : void 0;
110
+ ce && re && (w = `${vt(
111
+ ce,
112
+ re,
113
+ Ve
114
+ )} (${d(re)})`);
115
+ }
116
+ const E = [
117
+ "mig-schema-table__td",
118
+ `mig-schema-table__td--${o % 2 ? "odd" : "even"}`,
119
+ `mig-schema-table__td--prop-${h}`
120
+ ];
121
+ switch (s && W && W(s[L._index], L._index) && E.push("mig-schema-table__td--selected"), s && R && E.push(
122
+ R(s[L._index], L._index, x)
123
+ ), y?.type) {
124
+ case "boolean":
125
+ E.push(`text-${U?.align || "center"}`);
126
+ break;
127
+ case "number":
128
+ case "integer":
129
+ E.push(`text-${U?.align || "end"}`);
130
+ break;
131
+ default:
132
+ U?.align && E.push(`text-${U.align}`);
133
+ }
134
+ return {
135
+ "data-row-index": o,
136
+ "data-column-index": r,
137
+ style: g,
138
+ className: E.join(" "),
139
+ title: w,
140
+ onClick: h === K ? void 0 : ne,
141
+ onDoubleClick: h === K ? void 0 : C
142
+ };
143
+ }, [
144
+ L,
145
+ x,
146
+ h,
147
+ y,
148
+ oe,
149
+ o,
150
+ s,
151
+ W,
152
+ R,
153
+ r,
154
+ g,
155
+ ne,
156
+ C,
157
+ re,
158
+ d,
159
+ U
160
+ ]), P = e.useCallback(
161
+ (w) => {
162
+ if (!te || !L)
163
+ return;
164
+ const E = parseInt(w.currentTarget.dataset.rowIndex);
165
+ if (w.shiftKey && N !== void 0) {
166
+ const k = b?.includes(N) ? N : void 0;
167
+ if (k !== void 0 && x) {
168
+ const A = o;
169
+ for (const ce of Jt(
170
+ A > k ? k + 1 : A,
171
+ A > k ? A + 1 : k
172
+ )) {
173
+ const me = x[ce]._index;
174
+ (!S || !S.includes(me)) && te(me);
175
+ }
176
+ }
177
+ } else
178
+ te(L._index);
179
+ ee(E), pe.current?.focus();
180
+ },
181
+ [
182
+ b,
183
+ S,
184
+ N,
185
+ te,
186
+ L,
187
+ o,
188
+ ee,
189
+ x
190
+ ]
191
+ ), pe = e.useRef(null);
192
+ if (!L || !B)
193
+ return null;
194
+ if (!T || s && !s[L._index])
195
+ return /* @__PURE__ */ t("div", { ...B, children: "loading" });
196
+ if (h === K)
197
+ return /* @__PURE__ */ t("div", { ...B, onMouseDown: P, children: /* @__PURE__ */ t("div", { style: { textAlign: "center" }, children: /* @__PURE__ */ t(
198
+ "input",
199
+ {
200
+ ref: pe,
201
+ type: "checkbox",
202
+ readOnly: !0,
203
+ checked: b?.includes(L._index),
204
+ disabled: S?.includes(L._index)
205
+ }
206
+ ) }) });
207
+ if (G && s)
208
+ return /* @__PURE__ */ t("div", { ...B, children: /* @__PURE__ */ t(
209
+ G,
210
+ {
211
+ dataIndex: L._index,
212
+ rowData: s[L._index],
213
+ rowIndex: o,
214
+ ...U?.tdBodyProps
215
+ }
216
+ ) });
217
+ const Z = L[h];
218
+ return y?.format === "url" && Z ? /* @__PURE__ */ t(
219
+ "a",
220
+ {
221
+ href: Z,
222
+ target: "_blank",
223
+ rel: "noopener noreferrer",
224
+ ...B,
225
+ children: Z
226
+ }
227
+ ) : /* @__PURE__ */ t("div", { ...B, children: Z });
228
+ }, pt = e.memo(en);
229
+ function tn() {
230
+ const { checkedIndexes: r, disabledCheckedIndexes: o, sortedRenderData: g } = e.useContext(Me);
231
+ return e.useMemo(() => {
232
+ const b = [...g || []].filter(
233
+ (p) => (r ? r.includes(p._index) : !0) || (o ? !o.includes(p._index) : !0)
234
+ );
235
+ return r?.length !== 0 && b.length === r?.length;
236
+ }, [r, o, g]);
237
+ }
238
+ function Dt(r, o, g) {
239
+ return !!(r && g?.isSortable !== !1 && (o || g?.renderData || g?.sort));
240
+ }
241
+ function xt() {
242
+ const { setCustomColumnWidths: r, settingsStorageKey: o } = e.useContext(Me);
243
+ return e.useCallback(
244
+ (g) => {
245
+ o && localStorage.setItem(
246
+ `${o}.columnWidths`,
247
+ JSON.stringify(Array.from(g))
248
+ ), r(g);
249
+ },
250
+ [r, o]
251
+ );
252
+ }
253
+ const nn = ({ index: r, style: o }) => {
254
+ const {
255
+ checkedIndexes: g,
256
+ columnNames: b,
257
+ columnWidths: p,
258
+ config: u,
259
+ disabledCheckedIndexes: S,
260
+ dropTargetIndex: _,
261
+ isColumnFilterable: R,
262
+ isSortable: W,
263
+ setCheckedIndexes: T,
264
+ properties: N,
265
+ required: M,
266
+ setCustomColumnNames: v,
267
+ setDropTargetIndex: $,
268
+ setFilterSortColumn: q,
269
+ setMenuConfig: ee,
270
+ settingsStorageKey: x,
271
+ tableDataState: s,
272
+ sortedRenderData: d,
273
+ translate: h,
274
+ displayTimezone: y
275
+ } = e.useContext(Me), [U, te] = e.useState(!1), le = r === _, ne = xt(), C = b[r], L = C === K ? { type: "boolean" } : N[C], oe = s.sortColumn === C ? s.sortAsc : void 0, G = u ? u[C] : void 0;
276
+ let re = R && (L || G?.FilterMenu) && G?.isFilterable !== !1 ? Se.AVAILABLE : Se.UNAVAILABLE;
277
+ s.columnFilterMap && s.columnFilterMap[C] !== void 0 && (re = Se.ACTIVE);
278
+ const B = Dt(
279
+ W,
280
+ L,
281
+ G
282
+ ), P = [
283
+ "mig-schema-table__th",
284
+ `mig-schema-table__th--filter-${re}`,
285
+ `mig-schema-table__th--prop-${C}`
286
+ ];
287
+ P.push(
288
+ B ? "mig-schema-table__th--sortable" : "mig-schema-table__th--unsortable"
289
+ ), oe !== void 0 && P.push("mig-schema-table__th--sorted"), U && P.push("mig-schema-table__th--dragging"), le && P.push("mig-schema-table__th--drop-target");
290
+ const { format: pe } = L || {}, {
291
+ align: Z,
292
+ defaultSortDesc: w,
293
+ showTimezones: E = !y,
294
+ title: k
295
+ } = G || {}, A = e.useCallback(() => {
296
+ if (B) {
297
+ if (oe === void 0) {
298
+ q(C, !w);
299
+ return;
300
+ }
301
+ q(C, !oe);
302
+ }
303
+ }, [
304
+ B,
305
+ w,
306
+ C,
307
+ q,
308
+ oe
309
+ ]), ce = M.includes(C), me = e.useCallback(
310
+ (j) => {
311
+ const he = j.currentTarget;
312
+ ee((Ce) => {
313
+ if (Ce?.propName !== C)
314
+ return {
315
+ propConfig: G,
316
+ propIsRequired: ce,
317
+ propName: C,
318
+ referenceElement: he
319
+ };
320
+ });
321
+ },
322
+ [G, ce, C, ee]
323
+ ), _e = e.useMemo(() => k !== void 0 ? k : pe === "date-time" && E ? `${h(C)} (${h(y || Te)})` : h(C), [k, pe, E, h, C, y]), se = e.useCallback(
324
+ (j, he) => {
325
+ if (!b || !p)
326
+ return;
327
+ const Ce = b.indexOf(j), V = [...b];
328
+ V.splice(Ce, 1);
329
+ const D = V.indexOf(he);
330
+ V.splice(D + 1, 0, j), v(V);
331
+ const be = [...p], fe = be[Ce];
332
+ be.splice(Ce, 1), be.splice(D + 1, 0, fe), ne(new Uint16Array(be)), x && localStorage.setItem(
333
+ `${x}.columnNames`,
334
+ JSON.stringify(V)
335
+ );
336
+ },
337
+ [
338
+ b,
339
+ p,
340
+ ne,
341
+ x,
342
+ v
343
+ ]
344
+ ), Ae = e.useCallback(
345
+ (j) => {
346
+ se && (te(!0), j.dataTransfer.effectAllowed = "move", j.dataTransfer.dropEffect = "move", j.dataTransfer.setData("text/plain", C));
347
+ },
348
+ [se, C]
349
+ ), Re = e.useCallback(() => {
350
+ se && (te(!1), $(-1));
351
+ }, [se, $]), Pe = e.useCallback(
352
+ (j) => {
353
+ se && (j.preventDefault(), $(r));
354
+ },
355
+ [r, se, $]
356
+ ), Je = e.useCallback(
357
+ (j) => {
358
+ if ($(-1), !se || !C)
359
+ return;
360
+ const he = j.dataTransfer.getData("text/plain");
361
+ !he || he === C || se(he, C);
362
+ },
363
+ [se, C, $]
364
+ ), Le = tn(), Ze = e.useCallback(() => {
365
+ !T || !d || T(
366
+ Le ? [] : d.map((j) => j._index).filter((j) => !S?.includes(j))
367
+ );
368
+ }, [
369
+ T,
370
+ d,
371
+ Le,
372
+ S
373
+ ]);
374
+ if (C === K)
375
+ return /* @__PURE__ */ t("div", { style: o, className: P.join(" "), children: /* @__PURE__ */ t(
376
+ "div",
377
+ {
378
+ style: {
379
+ width: "100%",
380
+ textAlign: "center"
381
+ },
382
+ title: `${g?.length || 0} selected`,
383
+ children: /* @__PURE__ */ t(
384
+ "input",
385
+ {
386
+ type: "checkbox",
387
+ name: "selectAll",
388
+ checked: Le,
389
+ onChange: Ze
390
+ }
391
+ )
392
+ }
393
+ ) });
394
+ switch (L?.type) {
395
+ case "boolean":
396
+ P.push(
397
+ `text-${Z || "center"}`,
398
+ `justify-content-${Z || "center"}`
399
+ );
400
+ break;
401
+ case "integer":
402
+ case "number":
403
+ P.push(
404
+ `text-${Z || "end"}`,
405
+ `justify-content-${Z || "end"}`
406
+ );
407
+ break;
408
+ default:
409
+ Z && P.push(`text-${Z}`);
410
+ }
411
+ let Q = G?.hoverTitle;
412
+ return !Q && typeof _e == "string" && (Q = _e), /* @__PURE__ */ O(
413
+ "div",
414
+ {
415
+ className: P.join(" "),
416
+ style: o,
417
+ title: Q,
418
+ draggable: !0,
419
+ onDragStart: Ae,
420
+ onDragEnd: Re,
421
+ onDragOver: Pe,
422
+ onDrop: Je,
423
+ children: [
424
+ /* @__PURE__ */ O(
425
+ "div",
426
+ {
427
+ className: "mig-schema-table__th__label-body",
428
+ style: { lineHeight: "44px" },
429
+ onClick: A,
430
+ children: [
431
+ /* @__PURE__ */ t("span", { className: "mig-schema-table__th__label-body-text", children: _e }),
432
+ oe === void 0 ? null : /* @__PURE__ */ t("span", { className: "mig-schema-table__th__sort-icon", children: oe ? "↓" : "↑" })
433
+ ]
434
+ }
435
+ ),
436
+ B || re !== Se.UNAVAILABLE ? /* @__PURE__ */ t(
437
+ "button",
438
+ {
439
+ className: "mig-schema-table__th__trigger-el",
440
+ onClick: me,
441
+ children: /* @__PURE__ */ t(
442
+ "svg",
443
+ {
444
+ xmlns: "http://www.w3.org/2000/svg",
445
+ width: "24",
446
+ height: "24",
447
+ viewBox: "0 0 24 24",
448
+ fill: "none",
449
+ stroke: "#404040",
450
+ strokeWidth: "2",
451
+ strokeLinecap: "round",
452
+ strokeLinejoin: "round",
453
+ children: /* @__PURE__ */ t("polyline", { points: "6 9 12 15 18 9" })
454
+ }
455
+ )
456
+ }
457
+ ) : null
458
+ ]
459
+ }
460
+ );
461
+ }, rn = e.memo(nn), sn = {
462
+ [ge.GT]: ">",
463
+ [ge.LT]: "<",
464
+ [ge.EQ]: "="
465
+ }, on = e.memo(
466
+ ({
467
+ columnFilterValue: r,
468
+ onChange: o,
469
+ onInputKeyDown: g,
470
+ propIsRequired: b,
471
+ propName: p,
472
+ propSchema: u,
473
+ translate: S
474
+ }) => {
475
+ const { displayTimezone: _ } = e.useContext(Me), { type: R, format: W, minimum: T, maximum: N } = u || {}, M = r, v = W === "date-time";
476
+ switch (R) {
477
+ case "number":
478
+ case "integer":
479
+ const $ = M || {}, q = (s, d, h) => {
480
+ const y = {
481
+ ...$,
482
+ [s]: d.value === "" ? void 0 : parseInt(d.value)
483
+ }, U = Object.values(y).find(
484
+ (te) => isFinite(te)
485
+ );
486
+ o(
487
+ U !== void 0 && (T === void 0 || U >= T) ? y : void 0,
488
+ h
489
+ );
490
+ };
491
+ return /* @__PURE__ */ O("ol", { className: "mig-schema-table-menu mig-schema-table__th-menu__filter-menu-component", children: [
492
+ b ? null : /* @__PURE__ */ O("li", { style: { padding: 8 }, children: [
493
+ /* @__PURE__ */ O("label", { className: "d-flex", children: [
494
+ /* @__PURE__ */ t(
495
+ "input",
496
+ {
497
+ type: "checkbox",
498
+ style: { marginRight: 14 },
499
+ checked: !!$.filterEmpty,
500
+ onChange: () => {
501
+ const { filterEmpty: s, ...d } = $;
502
+ s || (d.filterEmpty = !0), o(
503
+ Object.keys(d).length ? d : void 0,
504
+ !0
505
+ );
506
+ }
507
+ }
508
+ ),
509
+ "Hide empty values"
510
+ ] }),
511
+ /* @__PURE__ */ t("hr", {})
512
+ ] }),
513
+ Object.keys(ge).map((s) => {
514
+ const d = $[s];
515
+ return /* @__PURE__ */ O("li", { children: [
516
+ /* @__PURE__ */ t("label", { style: { width: 40, paddingLeft: 16 }, children: sn[s] }),
517
+ /* @__PURE__ */ t(
518
+ "input",
519
+ {
520
+ className: "form-control",
521
+ style: { width: 120 },
522
+ type: "number",
523
+ value: d !== void 0 ? d : "",
524
+ "data-prop-name": p,
525
+ onChange: (h) => {
526
+ q(
527
+ s,
528
+ h.currentTarget,
529
+ !1
530
+ );
531
+ },
532
+ onBlur: (h) => {
533
+ q(
534
+ s,
535
+ h.currentTarget,
536
+ !0
537
+ );
538
+ },
539
+ onKeyDown: g,
540
+ min: T,
541
+ max: N
542
+ }
543
+ )
544
+ ] }, s);
545
+ })
546
+ ] });
547
+ case "boolean":
548
+ const ee = ["✓", "✕"];
549
+ b || ee.push("?");
550
+ let x = M ? "✓" : "✕";
551
+ return M === null && (x = "?"), M === void 0 && (x = ""), /* @__PURE__ */ t("ol", { className: "mig-schema-table-menu mig-schema-table__th-menu__filter-menu-component", children: /* @__PURE__ */ t("li", { children: /* @__PURE__ */ O(
552
+ "select",
553
+ {
554
+ autoFocus: !0,
555
+ className: "form-select",
556
+ value: x,
557
+ "data-prop-name": p,
558
+ onChange: (s) => {
559
+ switch (s.currentTarget.value) {
560
+ case "✓":
561
+ o(!0, !0);
562
+ break;
563
+ case "✕":
564
+ o(!1, !0);
565
+ break;
566
+ case "?":
567
+ o(null, !0);
568
+ break;
569
+ default:
570
+ o(void 0, !0);
571
+ }
572
+ },
573
+ children: [
574
+ /* @__PURE__ */ t("option", { value: "", children: "All" }, "all"),
575
+ ee.map((s) => /* @__PURE__ */ t(
576
+ "option",
577
+ {
578
+ value: s,
579
+ children: s
580
+ },
581
+ `column-filter-select-${s}`
582
+ ))
583
+ ]
584
+ }
585
+ ) }) });
586
+ // @ts-expect-error falls through
587
+ case "string":
588
+ if (u?.enum)
589
+ return /* @__PURE__ */ t("ol", { className: "mig-schema-table-menu mig-schema-table__th-menu__filter-menu-component", children: /* @__PURE__ */ t("li", { children: /* @__PURE__ */ O(
590
+ "select",
591
+ {
592
+ autoFocus: !0,
593
+ className: "form-select",
594
+ value: M,
595
+ "data-prop-name": p,
596
+ onChange: (s) => {
597
+ o(s.currentTarget.value || void 0, !0);
598
+ },
599
+ children: [
600
+ /* @__PURE__ */ t("option", { value: "", children: "All" }, "all"),
601
+ u.enum.map((s) => /* @__PURE__ */ t(
602
+ "option",
603
+ {
604
+ value: s,
605
+ children: S(s)
606
+ },
607
+ `column-filter-select-${s}`
608
+ ))
609
+ ]
610
+ }
611
+ ) }) });
612
+ if (v || W === "date") {
613
+ const s = v ? Ve : wt, d = r || {
614
+ from: void 0,
615
+ to: void 0,
616
+ filterEmpty: void 0
617
+ };
618
+ return /* @__PURE__ */ O("ol", { className: "mig-schema-table-menu mig-schema-table__th-menu__filter-menu-component", children: [
619
+ b ? null : /* @__PURE__ */ O("li", { style: { padding: 8 }, children: [
620
+ /* @__PURE__ */ O("label", { className: "d-flex", children: [
621
+ /* @__PURE__ */ t(
622
+ "input",
623
+ {
624
+ type: "checkbox",
625
+ checked: !!d.filterEmpty,
626
+ onChange: () => {
627
+ const { filterEmpty: h, ...y } = d;
628
+ h || (y.filterEmpty = !0), o(
629
+ Object.keys(y).length ? y : void 0,
630
+ !0
631
+ );
632
+ }
633
+ }
634
+ ),
635
+ "Hide empty values"
636
+ ] }),
637
+ /* @__PURE__ */ t("hr", {})
638
+ ] }),
639
+ /* @__PURE__ */ O("li", { style: { padding: 8 }, children: [
640
+ /* @__PURE__ */ t("label", { style: { width: 120, paddingLeft: 4 }, children: "After" }),
641
+ /* @__PURE__ */ t(
642
+ ut,
643
+ {
644
+ dateFormat: s,
645
+ "data-prop-name": p,
646
+ locale: dt,
647
+ selected: d.from ? new Ue(d.from).withTimeZone(
648
+ _ || Te
649
+ ) : null,
650
+ onChange: (h) => {
651
+ if (!h && !d.to) {
652
+ o(void 0, !0);
653
+ return;
654
+ }
655
+ if (d.to && h && h > d.to)
656
+ return;
657
+ const y = h ? Ue.tz(_ || Te, h) : void 0;
658
+ o(
659
+ {
660
+ ...r,
661
+ from: y
662
+ },
663
+ !0
664
+ );
665
+ },
666
+ placeholderText: s,
667
+ isClearable: !0,
668
+ selectsStart: !0,
669
+ showTimeSelect: v,
670
+ showTimeInput: v,
671
+ showMonthDropdown: !0,
672
+ showYearDropdown: !0,
673
+ timeIntervals: 15,
674
+ shouldCloseOnSelect: !v
675
+ }
676
+ )
677
+ ] }),
678
+ /* @__PURE__ */ O("li", { style: { padding: 8 }, children: [
679
+ /* @__PURE__ */ t("label", { style: { width: 120, paddingLeft: 4 }, children: "Before" }),
680
+ /* @__PURE__ */ t(
681
+ ut,
682
+ {
683
+ id: "filter-date",
684
+ dateFormat: s,
685
+ "data-prop-name": p,
686
+ locale: dt,
687
+ selectsEnd: !0,
688
+ selected: d.to ? new Ue(d.to).withTimeZone(
689
+ _ || Te
690
+ ) : null,
691
+ showMonthDropdown: !0,
692
+ showYearDropdown: !0,
693
+ onChange: (h) => {
694
+ if (!h && !d.from) {
695
+ o(void 0, !0);
696
+ return;
697
+ }
698
+ const y = h ? v ? Ue.tz(_ || Te, h) : zt(h) : void 0;
699
+ d.from && y && y < d.from || o(
700
+ {
701
+ ...r,
702
+ to: y
703
+ },
704
+ !0
705
+ );
706
+ },
707
+ placeholderText: s,
708
+ isClearable: !0,
709
+ startDate: d.from,
710
+ endDate: d.to,
711
+ showTimeInput: v,
712
+ showTimeSelect: v,
713
+ timeIntervals: 15,
714
+ shouldCloseOnSelect: !v
715
+ }
716
+ )
717
+ ] })
718
+ ] });
719
+ }
720
+ // falls through
721
+ default:
722
+ return /* @__PURE__ */ t("ol", { className: "mig-schema-table-menu mig-schema-table__th-menu__filter-menu-component", children: /* @__PURE__ */ t("li", { children: /* @__PURE__ */ t(
723
+ "input",
724
+ {
725
+ autoFocus: !0,
726
+ type: "search",
727
+ className: "form-control",
728
+ placeholder: `Search ${p}`,
729
+ "aria-label": `Search ${p}`,
730
+ value: M || "",
731
+ "data-prop-name": p,
732
+ onChange: (s) => {
733
+ o(s.currentTarget.value || void 0, !1);
734
+ },
735
+ onKeyDown: g,
736
+ onBlur: (s) => {
737
+ o(s.currentTarget.value || void 0, !0);
738
+ }
739
+ }
740
+ ) }) });
741
+ }
742
+ }
743
+ ), an = ({
744
+ isSortable: r,
745
+ isFilterable: o,
746
+ onChange: g,
747
+ onClose: b,
748
+ onInputKeyDown: p,
749
+ propConfig: u,
750
+ propIsRequired: S,
751
+ propName: _,
752
+ propSchema: R,
753
+ referenceElement: W,
754
+ setFilterSortColumn: T,
755
+ translate: N,
756
+ value: M
757
+ }) => {
758
+ const v = mt({
759
+ placement: "bottom-start",
760
+ elements: {
761
+ reference: W
762
+ },
763
+ middleware: [ht()]
764
+ }), $ = mt({
765
+ placement: "right-start",
766
+ middleware: [ht()]
767
+ });
768
+ e.useEffect(() => {
769
+ const d = (h) => {
770
+ if (!v.elements.floating)
771
+ return;
772
+ let y = h.target;
773
+ for (; y && v.elements.floating; ) {
774
+ if (y === v.elements.floating || y === $.elements.floating)
775
+ return;
776
+ y = y.parentNode === window.document ? null : y.parentNode;
777
+ }
778
+ b(h);
779
+ };
780
+ return window.addEventListener("click", d, { capture: !0 }), () => {
781
+ window.removeEventListener("click", d, { capture: !0 });
782
+ };
783
+ }, [
784
+ v.elements.floating,
785
+ b,
786
+ $.elements.floating
787
+ ]);
788
+ const q = u?.FilterMenu || on, ee = e.useCallback(
789
+ (d) => {
790
+ T(_, !0), b(d);
791
+ },
792
+ [b, _, T]
793
+ ), x = e.useCallback(
794
+ (d) => {
795
+ T(_, !1), b(d);
796
+ },
797
+ [b, _, T]
798
+ ), s = e.useCallback(() => {
799
+ g(void 0, !0);
800
+ }, [g]);
801
+ return !r && !o ? null : /* @__PURE__ */ O(yt, { children: [
802
+ /* @__PURE__ */ t(
803
+ "div",
804
+ {
805
+ className: "mig-schema-table mig-schema-table__th-menu",
806
+ ref: v.refs.setFloating,
807
+ style: v.floatingStyles,
808
+ children: /* @__PURE__ */ O("ol", { className: "mig-schema-table-menu", children: [
809
+ r ? /* @__PURE__ */ O("li", { onClick: ee, style: { padding: 8 }, children: [
810
+ /* @__PURE__ */ t("span", { className: "mig-schema-table__th-menu__icon", children: "↓" }),
811
+ " ",
812
+ N("sortAscending")
813
+ ] }) : null,
814
+ r ? /* @__PURE__ */ O("li", { onClick: x, style: { padding: 8 }, children: [
815
+ /* @__PURE__ */ t("span", { className: "mig-schema-table__th-menu__icon", children: "↑" }),
816
+ " ",
817
+ N("sortDescending")
818
+ ] }) : null,
819
+ o ? /* @__PURE__ */ O(
820
+ "li",
821
+ {
822
+ style: { padding: 8 },
823
+ onMouseOver: (d) => {
824
+ $.refs.setReference(d.currentTarget);
825
+ },
826
+ children: [
827
+ /* @__PURE__ */ t("span", { className: "mig-schema-table__th-menu__icon", children: /* @__PURE__ */ t(
828
+ "input",
829
+ {
830
+ type: "checkbox",
831
+ id: "mig-schema-table__th-menu__filters",
832
+ checked: M !== void 0,
833
+ disabled: M === void 0,
834
+ onChange: s
835
+ }
836
+ ) }),
837
+ /* @__PURE__ */ t("label", { htmlFor: "mig-schema-table__th-menu__filters", children: N("filters") }),
838
+ /* @__PURE__ */ t("div", { className: "mig-schema-table__th-menu__sub-menu-indicator" })
839
+ ]
840
+ }
841
+ ) : null
842
+ ] })
843
+ }
844
+ ),
845
+ $.elements.reference ? /* @__PURE__ */ t(
846
+ "div",
847
+ {
848
+ className: "mig-schema-table mig-schema-table__th-menu__sub-menu",
849
+ ref: $.refs.setFloating,
850
+ style: $.floatingStyles,
851
+ children: /* @__PURE__ */ t(
852
+ q,
853
+ {
854
+ columnFilterValue: M,
855
+ onChange: g,
856
+ onInputKeyDown: p,
857
+ propIsRequired: S,
858
+ propName: _,
859
+ propSchema: R,
860
+ translate: N
861
+ }
862
+ )
863
+ }
864
+ ) : null
865
+ ] });
866
+ }, ln = e.memo(an), cn = ({
867
+ columnWidths: r,
868
+ resizeColumnIndex: o,
869
+ setResizeColumnIndex: g,
870
+ tableBodyHeight: b
871
+ }) => {
872
+ const [p, u] = e.useState(0), S = xt(), _ = e.useCallback(
873
+ (N) => {
874
+ const M = r.map(
875
+ (v, $) => $ === o ? Math.max(v + N, kt) : v
876
+ );
877
+ S(M);
878
+ },
879
+ [r, o, S]
880
+ );
881
+ let R = 0;
882
+ const W = e.useCallback(
883
+ (N) => {
884
+ g(parseInt(N.currentTarget.dataset.columnIndex)), u(N.clientX);
885
+ },
886
+ [g]
887
+ ), T = e.useCallback(
888
+ (N) => {
889
+ _(N.clientX - p), u(0), g(-1);
890
+ },
891
+ [p, _, g]
892
+ );
893
+ return /* @__PURE__ */ t("div", { children: [...r].map((N, M) => {
894
+ R += N;
895
+ const v = ["mig-schema-table__column_resizer"];
896
+ return M === o && v.push("mig-schema-table__column_resizer--dragged"), /* @__PURE__ */ t(
897
+ "div",
898
+ {
899
+ style: { left: R - Yt, bottom: b },
900
+ className: v.join(" "),
901
+ draggable: "true",
902
+ "data-column-index": M,
903
+ onDragStart: W,
904
+ onDragEnd: T
905
+ },
906
+ M
907
+ );
908
+ }) });
909
+ }, _t = (r) => {
910
+ const [o, g] = e.useState({ width: 0, height: 0 }), b = e.useMemo(
911
+ () => Zt(g, 100),
912
+ []
913
+ );
914
+ return e.useEffect(() => {
915
+ if (!r)
916
+ return;
917
+ const p = new ResizeObserver((u) => {
918
+ for (const S of u) {
919
+ const { blockSize: _, inlineSize: R } = S.borderBoxSize[0];
920
+ R && _ && b({ width: R, height: _ });
921
+ }
922
+ });
923
+ return p.observe(r), () => {
924
+ p.disconnect();
925
+ };
926
+ }, [b, r]), o;
927
+ }, Ct = /* @__PURE__ */ new Date("1000-01-01 00:00:00Z"), un = new Intl.NumberFormat("nl-NL"), dn = new Intl.NumberFormat("nl-NL", {
928
+ style: "currency",
929
+ currency: "EUR"
930
+ });
931
+ function mn(r, o) {
932
+ const { TdBody: g, sortByValue: b } = o || {};
933
+ if (b !== void 0)
934
+ return b;
935
+ if (!r)
936
+ return !1;
937
+ const { format: p, type: u } = r;
938
+ return p?.startsWith("date") || u === "boolean" || u === "integer" || u === "number" || !!g;
939
+ }
940
+ const hn = ({
941
+ CustomElement: r,
942
+ CustomSearchInput: o,
943
+ Heading: g = Bt,
944
+ autoRender: b,
945
+ checkedIndexes: p,
946
+ config: u,
947
+ customElementProps: S,
948
+ data: _,
949
+ defaultColumnFilters: R,
950
+ defaultSortAsc: W = !1,
951
+ defaultSortColumn: T,
952
+ disabledCheckedIndexes: N,
953
+ displayTimezone: M,
954
+ enableAutoFocus: v = !0,
955
+ enableRowCounter: $ = !0,
956
+ getRowClassName: q,
957
+ getRowSelected: ee,
958
+ getSearchQueryFilterResult: x,
959
+ infiniteLoaderRef: s,
960
+ isColumnFilterable: d = !0,
961
+ isExportable: h = !0,
962
+ isResizable: y = !0,
963
+ isSearchable: U = !0,
964
+ isSortable: te = !0,
965
+ itemCount: le,
966
+ loadMoreItems: ne,
967
+ maxHeight: C,
968
+ onRowClick: L,
969
+ onRowDoubleClick: oe,
970
+ onSearchEnter: G,
971
+ onTableDataStateChange: re,
972
+ rowHeight: B = 36,
973
+ schema: P,
974
+ searchPlaceholder: pe,
975
+ setCheckedIndexes: Z,
976
+ settingsStorageKey: w,
977
+ style: E,
978
+ translate: k = ft,
979
+ useFilterStateHash: A,
980
+ variableSizeGridRef: ce,
981
+ width: me
982
+ }) => {
983
+ const [_e, se] = e.useState(), [Ae, Re] = e.useState(), [Pe, Je] = e.useState(-1), [Le, Ze] = e.useState(-1), [Q, j] = e.useState(), [he, Ce] = e.useState(), V = _ instanceof Function, [D, be] = e.useState(
984
+ V ? void 0 : _
985
+ ), [fe, qe] = e.useState(), [a, ke] = e.useState({
986
+ searchQuery: "",
987
+ columnFilterMap: R || {},
988
+ sortColumn: T,
989
+ sortAsc: W
990
+ }), [z, Tt] = e.useState(
991
+ A ? ct(window.location.hash) : null
992
+ );
993
+ e.useEffect(() => {
994
+ V || be(_);
995
+ }, [_, V]), e.useEffect(() => {
996
+ !V || D !== void 0 || _(
997
+ z && Object.keys(z).length !== 0 ? {
998
+ ...z,
999
+ columnFilterMap: z.columnFilterMap || {}
1000
+ } : a
1001
+ ).then(be);
1002
+ }, [_, V, z, D, a]), e.useEffect(() => {
1003
+ fe || qe(a);
1004
+ }, [a, fe]), e.useEffect(() => {
1005
+ if (!A)
1006
+ return;
1007
+ const n = () => {
1008
+ Tt(ct(window.location.hash));
1009
+ };
1010
+ return window.addEventListener("hashchange", n), () => {
1011
+ window.removeEventListener("hashchange", n);
1012
+ };
1013
+ }, [A]), e.useEffect(() => {
1014
+ if (!A)
1015
+ return;
1016
+ const { columnFilterMap: n, searchQuery: l, sortAsc: c, sortColumn: i } = z || {}, m = {
1017
+ searchQuery: l || "",
1018
+ columnFilterMap: n || R || {},
1019
+ sortAsc: c === void 0 ? W : c,
1020
+ sortColumn: i === void 0 ? T : i
1021
+ };
1022
+ ke(
1023
+ (I) => et(m, I) ? I : m
1024
+ );
1025
+ }, [
1026
+ z,
1027
+ A,
1028
+ R,
1029
+ W,
1030
+ T
1031
+ ]), e.useEffect(() => {
1032
+ re && re(a);
1033
+ }, [re, a]);
1034
+ const nt = e.useRef(null), rt = e.useRef(null), Oe = _t(nt.current), st = _t(
1035
+ rt.current
1036
+ ), Ee = e.useMemo(
1037
+ () => me || Math.floor(Oe.width || 0),
1038
+ [Oe.width, me]
1039
+ ), Ie = e.useMemo(() => !et(a, fe) && V, [a, fe, V]), { properties: ae, required: Mt } = e.useMemo(
1040
+ () => ({
1041
+ properties: {},
1042
+ required: [],
1043
+ ...P
1044
+ }),
1045
+ [P]
1046
+ ), We = w ? localStorage.getItem(`${w}.columnNames`) : null, Fe = w ? localStorage.getItem(`${w}.columnWidths`) : null, Y = e.useMemo(() => {
1047
+ if (_e)
1048
+ return _e;
1049
+ const n = We ? JSON.parse(We) : void 0;
1050
+ let l = Object.keys(ae);
1051
+ if (Z && l.unshift(K), u) {
1052
+ Object.keys(u).forEach((i) => {
1053
+ l.includes(i) || l.push(i);
1054
+ });
1055
+ const c = Object.entries(u).reduce(
1056
+ (i, [m, I]) => (I.hidden && i.push(m), i),
1057
+ []
1058
+ );
1059
+ l = l.filter((i) => !c.includes(i)).sort((i, m) => {
1060
+ let I = u[i] ? u[i].order : void 0;
1061
+ I === void 0 && (I = Object.keys(ae).findIndex(
1062
+ (H) => H === i
1063
+ ));
1064
+ let f = u[m] ? u[m].order : void 0;
1065
+ return f === void 0 && (f = Object.keys(ae).findIndex(
1066
+ (H) => H === m
1067
+ )), m === K || i === K ? 0 : I === -1 ? 1 : f === -1 ? -1 : I - f;
1068
+ });
1069
+ }
1070
+ return n?.length === l.length ? n : l;
1071
+ }, [
1072
+ u,
1073
+ _e,
1074
+ Z,
1075
+ ae,
1076
+ We
1077
+ ]), je = e.useMemo(
1078
+ () => D && Y ? D.map(
1079
+ (n, l) => Y.reduce(
1080
+ (c, i) => {
1081
+ const m = ae[i], I = u ? u[i] : void 0;
1082
+ if (I?.renderData)
1083
+ return c[i] = I.renderData(n, l), c;
1084
+ if (!m || i === K)
1085
+ return c[i] = "", c;
1086
+ const f = n ? n[i] : "";
1087
+ switch (m.type) {
1088
+ case "array":
1089
+ return c[i] = m.items?.type === "string" && f ? f.map((H) => k(H)).join(", ") : JSON.stringify(f), c;
1090
+ case "boolean":
1091
+ return c[i] = f === void 0 ? "?" : f ? "✓" : "✕", c;
1092
+ case "number":
1093
+ case "integer":
1094
+ return f === void 0 ? (c[i] = "", c) : (c[i] = m.format === "currency" ? dn.format(f) : un.format(f), c);
1095
+ // @ts-expect-error investigate
1096
+ case "string":
1097
+ if (m.format === "date" && f)
1098
+ return c[i] = ["2999-12-31", "1970-01-01"].includes(
1099
+ f
1100
+ ) ? "-" : tt(
1101
+ new Date(f),
1102
+ I?.dateFormat || wt
1103
+ ), c;
1104
+ if (m.format === "date-time" && f)
1105
+ return c[i] = M ? vt(
1106
+ new Date(f),
1107
+ M,
1108
+ Ve
1109
+ ) : tt(
1110
+ new Date(f),
1111
+ I?.dateFormat || Ve
1112
+ ), c;
1113
+ if (m.enum)
1114
+ return c[i] = f ? k(f) : "", c;
1115
+ // fallthrough
1116
+ default:
1117
+ return c[i] = f ? `${f}` : "", c;
1118
+ }
1119
+ },
1120
+ { _index: l }
1121
+ )
1122
+ ) : void 0,
1123
+ [D, Y, ae, u, k, M]
1124
+ ), De = Y ? Y.length : 0, { dynamicWidthColumnCount: Ge, fixedWidthColumnsWidth: Xe } = e.useMemo(() => {
1125
+ let n = 0, l = 0;
1126
+ return (Y || []).forEach((c) => {
1127
+ if (c === K) {
1128
+ n += gt;
1129
+ return;
1130
+ }
1131
+ const i = u ? u[c] : void 0;
1132
+ i?.width ? n += i.width : l += 1;
1133
+ }, 0), { dynamicWidthColumnCount: l, fixedWidthColumnsWidth: n };
1134
+ }, [Y, u]), ie = e.useMemo(() => {
1135
+ if (Ae)
1136
+ return new Uint16Array(Ae);
1137
+ const n = Fe ? new Uint16Array(JSON.parse(Fe)) : void 0, l = Math.max(
1138
+ Math.floor(
1139
+ (Ee - Xe) / Ge
1140
+ ),
1141
+ kt
1142
+ );
1143
+ let c = (Ee - Xe) % Ge;
1144
+ const i = new Uint16Array(
1145
+ Y.map((m) => {
1146
+ if (m === K)
1147
+ return gt;
1148
+ const I = u ? u[m] : void 0;
1149
+ return I?.width ? I?.width : c ? (c -= 1, l + 1) : l;
1150
+ })
1151
+ );
1152
+ return n?.length === i.length ? n : i;
1153
+ }, [
1154
+ Y,
1155
+ u,
1156
+ Ae,
1157
+ Ge,
1158
+ Xe,
1159
+ Fe,
1160
+ Ee
1161
+ ]), Be = e.useCallback(
1162
+ (n) => ie ? ie[n] : 1,
1163
+ [ie]
1164
+ ), Ne = e.useMemo(() => {
1165
+ if (!je || !d && !U || V)
1166
+ return je;
1167
+ const { searchQuery: n } = a, l = n.toLowerCase() || "", c = (i) => D && x ? x(D[i._index], n) : !(Y && !Y.find(
1168
+ (m) => `${i[m]}`.toLowerCase().includes(l)
1169
+ ));
1170
+ return je.filter((i) => {
1171
+ let m = c(i);
1172
+ return !m || !a.columnFilterMap ? !1 : (Object.entries(a.columnFilterMap).forEach(
1173
+ ([I, f]) => {
1174
+ if (!m || f === void 0)
1175
+ return;
1176
+ const H = u ? u[I] : void 0;
1177
+ if (D && H?.filter) {
1178
+ m = H.filter(
1179
+ D[i._index],
1180
+ f
1181
+ );
1182
+ return;
1183
+ }
1184
+ const de = ae[I], F = D[i._index]?.[I];
1185
+ switch (de?.type) {
1186
+ case "boolean":
1187
+ case "number":
1188
+ case "integer":
1189
+ if (f && typeof f == "object") {
1190
+ f.filterEmpty && F === void 0 && (m = !1);
1191
+ for (const J of Object.keys(
1192
+ ge
1193
+ )) {
1194
+ const ve = f[J];
1195
+ if (m && qt(ve))
1196
+ switch (J) {
1197
+ case ge.EQ:
1198
+ F !== ve && (m = !1);
1199
+ break;
1200
+ case ge.GT:
1201
+ F <= ve && (m = !1);
1202
+ break;
1203
+ case ge.LT:
1204
+ F >= ve && (m = !1);
1205
+ break;
1206
+ }
1207
+ }
1208
+ } else {
1209
+ if (F === void 0 && f === null)
1210
+ return !0;
1211
+ m = F === f;
1212
+ }
1213
+ break;
1214
+ // @ts-expect-error investigate
1215
+ case "string":
1216
+ if (typeof f == "object" && (de.format === "date" || de.format === "date-time")) {
1217
+ const { from: J, to: ve, filterEmpty: it } = f;
1218
+ if (!F)
1219
+ m = !it;
1220
+ else {
1221
+ const Qe = F ? new Date(F) : void 0;
1222
+ (it === !1 || J && (!Qe || Qe < J) || ve && (!Qe || Qe > ve)) && (m = !1);
1223
+ }
1224
+ return;
1225
+ }
1226
+ // fall through
1227
+ default:
1228
+ if (de?.enum) {
1229
+ m = F === f;
1230
+ return;
1231
+ }
1232
+ m = `${i[I]}`.toLowerCase().includes(`${f}`.toLowerCase());
1233
+ }
1234
+ }
1235
+ ), m);
1236
+ });
1237
+ }, [
1238
+ je,
1239
+ d,
1240
+ U,
1241
+ V,
1242
+ a,
1243
+ x,
1244
+ Y,
1245
+ u,
1246
+ D,
1247
+ ae
1248
+ ]), X = e.useMemo(() => {
1249
+ const { sortAsc: n, sortColumn: l } = a;
1250
+ if (!l || !Ne || !D || V)
1251
+ return Ne;
1252
+ const c = ae[l], i = u ? u[l] : void 0, m = i?.sort;
1253
+ if (m)
1254
+ return Ne.sort((H, de) => {
1255
+ const F = D[H._index], J = D[de._index];
1256
+ return F ? J ? m(
1257
+ F,
1258
+ J,
1259
+ n === void 0 ? W : n
1260
+ ) : -1 : 1;
1261
+ });
1262
+ const I = c && c.format?.startsWith("date"), f = mn(c, i);
1263
+ return Ne.sort((H, de) => {
1264
+ let F = f && D[H._index] ? D[H._index][l] : `${H[l]}`.toLowerCase(), J = f && D[de._index] ? D[de._index][l] : `${de[l]}`.toLowerCase();
1265
+ return f && I && (F = new Date(F), isNaN(F.getTime()) && (F = Ct), J = new Date(J), isNaN(J.getTime()) && (J = Ct)), F === J ? 0 : F ? J ? (F < J ? 1 : -1) * (n ? -1 : 1) : n ? 1 : -1 : n ? -1 : 1;
1266
+ });
1267
+ }, [
1268
+ u,
1269
+ W,
1270
+ Ne,
1271
+ V,
1272
+ ae,
1273
+ D,
1274
+ a
1275
+ ]), ot = e.useCallback(
1276
+ (n) => {
1277
+ const l = { ...a.columnFilterMap };
1278
+ delete l[n], ke({
1279
+ ...a,
1280
+ columnFilterMap: l
1281
+ });
1282
+ },
1283
+ [a]
1284
+ ), He = e.useCallback(
1285
+ (n, l) => {
1286
+ if (A) {
1287
+ window.location.hash = ze({
1288
+ ...z,
1289
+ sortColumn: n,
1290
+ sortAsc: l
1291
+ });
1292
+ return;
1293
+ }
1294
+ ke({ ...a, sortColumn: n, sortAsc: l });
1295
+ },
1296
+ [a, z, A]
1297
+ ), At = e.useCallback(
1298
+ (n) => {
1299
+ ke({
1300
+ ...a,
1301
+ searchQuery: n.currentTarget.value
1302
+ });
1303
+ },
1304
+ [a]
1305
+ ), xe = e.useCallback(() => {
1306
+ qe(a), be(void 0);
1307
+ }, [a]);
1308
+ e.useEffect(() => {
1309
+ if (!b || !z || !fe || !A)
1310
+ return;
1311
+ const n = Object.keys(z);
1312
+ let l = !1;
1313
+ for (const c of n) {
1314
+ const i = z[c], m = fe[c];
1315
+ if (typeof i == "string" && i !== m) {
1316
+ l = !0;
1317
+ break;
1318
+ }
1319
+ if (typeof i == "object" && !et(i, m)) {
1320
+ l = !0;
1321
+ break;
1322
+ }
1323
+ }
1324
+ l && xe();
1325
+ }, [
1326
+ b,
1327
+ z,
1328
+ fe,
1329
+ xe,
1330
+ A
1331
+ ]);
1332
+ const at = e.useCallback(
1333
+ (n) => {
1334
+ n.key === "Enter" && (j(void 0), Ie && xe(), G && n.currentTarget.className === "mig-schema-table__search" && G(a.searchQuery || ""));
1335
+ },
1336
+ [Ie, a.searchQuery, G, xe]
1337
+ ), Ye = e.useCallback(() => B, [B]), ue = e.useMemo(() => Gt(ie), [ie]), $e = e.useMemo(
1338
+ () => X ? X.length : 0,
1339
+ [X]
1340
+ ), ye = e.useMemo(() => {
1341
+ const n = B * $e;
1342
+ let l;
1343
+ C && (l = C === "100%" ? Oe.height : C);
1344
+ const c = l ? l - st.height - bt : 0;
1345
+ return c && c < n ? c : n;
1346
+ }, [
1347
+ B,
1348
+ $e,
1349
+ C,
1350
+ st,
1351
+ Oe.height
1352
+ ]), Lt = e.useCallback(
1353
+ (n) => {
1354
+ j(void 0), n.preventDefault(), n.stopPropagation();
1355
+ },
1356
+ []
1357
+ ), Et = e.useCallback(
1358
+ (n, l) => {
1359
+ if (!Q)
1360
+ return;
1361
+ if (A && l !== !1) {
1362
+ window.location.hash = ze({
1363
+ ...z,
1364
+ columnFilterMap: {
1365
+ ...a.columnFilterMap,
1366
+ [Q.propName]: n
1367
+ }
1368
+ });
1369
+ return;
1370
+ }
1371
+ if (n === void 0) {
1372
+ ot(Q.propName);
1373
+ return;
1374
+ }
1375
+ const c = {
1376
+ ...a.columnFilterMap,
1377
+ [Q.propName]: n
1378
+ };
1379
+ ke({
1380
+ ...a,
1381
+ columnFilterMap: c
1382
+ });
1383
+ },
1384
+ [
1385
+ ot,
1386
+ a,
1387
+ z,
1388
+ Q,
1389
+ A
1390
+ ]
1391
+ ), It = e.useCallback(() => {
1392
+ const n = {
1393
+ searchQuery: "",
1394
+ columnFilterMap: {},
1395
+ // Clear button should clear _ALL_ filters, do _NOT_ revert to defaultColumnFilters
1396
+ sortColumn: T,
1397
+ sortAsc: W
1398
+ };
1399
+ A && (window.location.hash = ze(n)), qe(n), ke(n);
1400
+ }, [A, W, T]), Nt = e.useCallback(() => {
1401
+ const n = z?.searchQuery || "";
1402
+ A && // prevent hash change for undefined vs empty string compare
1403
+ (a.searchQuery || n) && a.searchQuery !== n && (window.location.hash = ze({
1404
+ ...z,
1405
+ searchQuery: a.searchQuery
1406
+ }));
1407
+ }, [z, a.searchQuery, A]), $t = e.useCallback(
1408
+ async (n) => {
1409
+ if (n.preventDefault(), n.stopPropagation(), !X)
1410
+ return;
1411
+ const { renderDataToExcel: l } = await import("./index-DAu7y5UJ.js");
1412
+ l(X);
1413
+ },
1414
+ [X]
1415
+ ), St = e.useCallback(() => {
1416
+ w && (localStorage.removeItem(`${w}.columnNames`), localStorage.removeItem(`${w}.columnWidths`), se(void 0), Re(void 0));
1417
+ }, [w]), Ke = e.useCallback(
1418
+ (n) => !X || !D || !ne || !le ? !0 : D[X[n]._index] !== void 0,
1419
+ [le, ne, X, D]
1420
+ ), Rt = e.useMemo(() => !(D && !Ie) && !ne ? /* @__PURE__ */ t(
1421
+ "div",
1422
+ {
1423
+ style: {
1424
+ width: ue,
1425
+ height: Math.max(50, ye),
1426
+ border: "1px solid #BBB",
1427
+ textAlign: "center",
1428
+ display: "flex",
1429
+ backgroundColor: "#CCC",
1430
+ alignItems: "center",
1431
+ justifyContent: "center"
1432
+ },
1433
+ children: Ie ? /* @__PURE__ */ t("button", { onClick: xe, className: "btn border", children: "Refresh data" }) : /* @__PURE__ */ t("div", { children: "⌛ Loading..." })
1434
+ }
1435
+ ) : ne && le ? /* @__PURE__ */ t(
1436
+ Xt,
1437
+ {
1438
+ ref: s,
1439
+ isItemLoaded: Ke,
1440
+ itemCount: le,
1441
+ loadMoreItems: ne,
1442
+ children: ({ onItemsRendered: l, ref: c }) => /* @__PURE__ */ t(
1443
+ lt,
1444
+ {
1445
+ className: "mig-schema-table__tbody",
1446
+ estimatedRowHeight: B,
1447
+ height: ye,
1448
+ width: ue,
1449
+ columnWidth: Be,
1450
+ rowHeight: Ye,
1451
+ columnCount: De,
1452
+ rowCount: $e,
1453
+ ref: c,
1454
+ onItemsRendered: ({
1455
+ overscanRowStartIndex: i,
1456
+ overscanRowStopIndex: m,
1457
+ visibleRowStartIndex: I,
1458
+ visibleRowStopIndex: f
1459
+ }) => l({
1460
+ overscanStartIndex: i,
1461
+ overscanStopIndex: m,
1462
+ visibleStartIndex: I,
1463
+ visibleStopIndex: f
1464
+ }),
1465
+ children: pt
1466
+ },
1467
+ `tbody_${ye}_${ue}_${a.sortColumn}_${a.sortAsc}_${a.searchQuery}_${De}_${ie.join(
1468
+ " "
1469
+ )}`
1470
+ )
1471
+ }
1472
+ ) : /* @__PURE__ */ t(
1473
+ lt,
1474
+ {
1475
+ className: "mig-schema-table__tbody",
1476
+ estimatedRowHeight: B,
1477
+ height: ye,
1478
+ width: ue,
1479
+ columnWidth: Be,
1480
+ rowHeight: Ye,
1481
+ columnCount: De,
1482
+ rowCount: $e,
1483
+ ref: ce,
1484
+ children: pt
1485
+ },
1486
+ `tbody_${ye}_${ue}_${a.sortColumn}_${a.sortAsc}_${a.searchQuery}_${De}_${ie.join(
1487
+ " "
1488
+ )}`
1489
+ ), [
1490
+ De,
1491
+ ie,
1492
+ Be,
1493
+ Ye,
1494
+ s,
1495
+ Ie,
1496
+ Ke,
1497
+ le,
1498
+ ne,
1499
+ xe,
1500
+ $e,
1501
+ B,
1502
+ ue,
1503
+ a.searchQuery,
1504
+ a.sortAsc,
1505
+ a.sortColumn,
1506
+ D,
1507
+ ye,
1508
+ ce
1509
+ ]), Ot = e.useMemo(
1510
+ () => ({
1511
+ ...E,
1512
+ width: me ? Math.min(ue, Ee) : void 0,
1513
+ height: C === "100%" ? "100%" : void 0,
1514
+ maxHeight: C === "100%" ? "100%" : void 0
1515
+ }),
1516
+ [C, ue, E, Ee, me]
1517
+ ), Wt = o || "input";
1518
+ return /* @__PURE__ */ t(
1519
+ Me.Provider,
1520
+ {
1521
+ value: {
1522
+ checkedIndexes: p,
1523
+ columnNames: Y,
1524
+ columnWidths: ie,
1525
+ config: u,
1526
+ disabledCheckedIndexes: N,
1527
+ displayTimezone: M,
1528
+ dropTargetIndex: Le,
1529
+ getRowClassName: q,
1530
+ getRowSelected: ee,
1531
+ isColumnFilterable: d,
1532
+ isItemLoaded: Ke,
1533
+ isSortable: te,
1534
+ lastCheckChangedRowIndex: he,
1535
+ onRowClick: L,
1536
+ onRowDoubleClick: oe,
1537
+ properties: ae,
1538
+ required: Mt,
1539
+ setCheckedIndexes: Z,
1540
+ setCustomColumnNames: se,
1541
+ setCustomColumnWidths: Re,
1542
+ setDropTargetIndex: Ze,
1543
+ setFilterSortColumn: He,
1544
+ setLastCheckChangedRowIndex: Ce,
1545
+ setMenuConfig: j,
1546
+ settingsStorageKey: w,
1547
+ sortedRenderData: X,
1548
+ sourceData: D,
1549
+ tableDataState: a,
1550
+ translate: k || ft
1551
+ },
1552
+ children: /* @__PURE__ */ O(
1553
+ "div",
1554
+ {
1555
+ className: `mig-schema-table${L ? " mig-schema-table--clickable-rows" : ""}`,
1556
+ ref: nt,
1557
+ style: Ot,
1558
+ role: "table",
1559
+ children: [
1560
+ /* @__PURE__ */ O(
1561
+ "div",
1562
+ {
1563
+ className: "mig-schema-table__action-container",
1564
+ ref: rt,
1565
+ children: [
1566
+ /* @__PURE__ */ t("div", { children: U ? /* @__PURE__ */ t(
1567
+ Wt,
1568
+ {
1569
+ className: "mig-schema-table__search",
1570
+ type: "search",
1571
+ name: "search",
1572
+ autoComplete: "off",
1573
+ placeholder: pe || k("search..."),
1574
+ value: a.searchQuery,
1575
+ onChange: At,
1576
+ onKeyDown: at,
1577
+ autoFocus: v,
1578
+ onBlur: Nt
1579
+ }
1580
+ ) : null }),
1581
+ r ? /* @__PURE__ */ t(
1582
+ r,
1583
+ {
1584
+ ...S,
1585
+ renderData: X
1586
+ }
1587
+ ) : /* @__PURE__ */ t("div", { className: "mig-schema-table__custom_element_placeholder" }),
1588
+ $ && Array.isArray(_) ? /* @__PURE__ */ t("span", { className: "mig-schema-table__row_counter", children: k(
1589
+ "showingFilteredCountOfTotalCount",
1590
+ X?.length || 0,
1591
+ _.length
1592
+ ) }) : null,
1593
+ h ? /* @__PURE__ */ t(
1594
+ "button",
1595
+ {
1596
+ onClick: $t,
1597
+ style: { marginLeft: 8 },
1598
+ disabled: !X?.length,
1599
+ children: k("exportData")
1600
+ }
1601
+ ) : null,
1602
+ U || d ? /* @__PURE__ */ t(
1603
+ "button",
1604
+ {
1605
+ onClick: It,
1606
+ style: { marginLeft: 8 },
1607
+ disabled: a.columnFilterMap && a.searchQuery ? Object.keys(a.columnFilterMap).length + a.searchQuery.length === 0 : !1,
1608
+ children: k("clearFilters")
1609
+ }
1610
+ ) : null,
1611
+ w ? /* @__PURE__ */ t(
1612
+ "button",
1613
+ {
1614
+ onClick: St,
1615
+ style: { marginLeft: 8 },
1616
+ disabled: !We && !Fe,
1617
+ children: k("clearSettings")
1618
+ }
1619
+ ) : null
1620
+ ]
1621
+ }
1622
+ ),
1623
+ /* @__PURE__ */ O("div", { className: "mig-schema-table__column_resize_container", children: [
1624
+ /* @__PURE__ */ t(
1625
+ g,
1626
+ {
1627
+ height: bt,
1628
+ itemCount: De,
1629
+ itemSize: Be,
1630
+ layout: "horizontal",
1631
+ width: ue,
1632
+ sortAsc: a.sortAsc,
1633
+ setFilterSortColumn: He,
1634
+ sortColumn: a.sortColumn,
1635
+ sortedRenderData: X,
1636
+ className: "mig-schema-table__th-row",
1637
+ children: rn
1638
+ },
1639
+ `thead_${ue}_${a.sortColumn}_${a.sortAsc}_${a.searchQuery}_${ie.join(
1640
+ " "
1641
+ )}`
1642
+ ),
1643
+ Rt,
1644
+ y ? /* @__PURE__ */ t(
1645
+ cn,
1646
+ {
1647
+ columnWidths: ie,
1648
+ resizeColumnIndex: Pe,
1649
+ setResizeColumnIndex: Je,
1650
+ tableBodyHeight: ye
1651
+ }
1652
+ ) : null
1653
+ ] }),
1654
+ D ? D.length > 0 ? /* @__PURE__ */ t(yt, { children: jt(
1655
+ Q ? /* @__PURE__ */ t(
1656
+ ln,
1657
+ {
1658
+ isFilterable: d && Q.propConfig?.isFilterable !== !1,
1659
+ isSortable: Dt(
1660
+ !!te,
1661
+ P.properties[Q.propName],
1662
+ Q.propConfig
1663
+ ),
1664
+ onChange: Et,
1665
+ onClose: Lt,
1666
+ onInputKeyDown: at,
1667
+ propConfig: Q.propConfig,
1668
+ propIsRequired: Q.propIsRequired,
1669
+ propName: Q.propName,
1670
+ propSchema: P.properties[Q.propName],
1671
+ referenceElement: Q.referenceElement,
1672
+ setFilterSortColumn: He,
1673
+ translate: k,
1674
+ value: a.columnFilterMap ? a.columnFilterMap[Q.propName] : null
1675
+ }
1676
+ ) : null,
1677
+ document.body
1678
+ ) }) : /* @__PURE__ */ t("div", { className: "mig-schema-table__no_data", children: "No data found" }) : null
1679
+ ]
1680
+ }
1681
+ )
1682
+ }
1683
+ );
1684
+ }, Mn = e.memo(hn), An = e.memo(({ refresh: r, period: o = 60 }) => {
1685
+ const [g, b] = e.useState(/* @__PURE__ */ new Date()), [p, u] = e.useState(/* @__PURE__ */ new Date()), S = e.useCallback(() => {
1686
+ u(/* @__PURE__ */ new Date()), r();
1687
+ }, [r]), _ = e.useMemo(
1688
+ () => Ut(g, p),
1689
+ [g, p]
1690
+ );
1691
+ e.useEffect(() => {
1692
+ _ > o && S();
1693
+ }, [_, g, p, o, S]), e.useEffect(() => {
1694
+ const T = setInterval(() => {
1695
+ b(/* @__PURE__ */ new Date());
1696
+ }, 1e3);
1697
+ return () => {
1698
+ clearInterval(T);
1699
+ };
1700
+ }, []);
1701
+ const R = o - _;
1702
+ return /* @__PURE__ */ O(
1703
+ "div",
1704
+ {
1705
+ className: "mx-auto",
1706
+ title: `Refresh ${R > 0 ? `in ${R} seconds` : "NOW"}`,
1707
+ children: [
1708
+ "Last update ",
1709
+ tt(p, "HH:mm")
1710
+ ]
1711
+ }
1712
+ );
1713
+ });
2
1714
  export {
3
- s as DEFAULT_DATE_FORMAT,
4
- E as DEFAULT_DATE_TIME_FORMAT,
5
- e as EColumnFilterStatus,
6
- M as MINIMUM_COLUMN_WIDTH,
7
- _ as RESIZER_WIDTH,
8
- D as Refresher,
9
- A as SchemaTable,
10
- I as Th
1715
+ wt as DEFAULT_DATE_FORMAT,
1716
+ Ve as DEFAULT_DATE_TIME_FORMAT,
1717
+ Se as EColumnFilterStatus,
1718
+ kt as MINIMUM_COLUMN_WIDTH,
1719
+ Yt as RESIZER_WIDTH,
1720
+ An as Refresher,
1721
+ Mn as SchemaTable,
1722
+ rn as Th
11
1723
  };