@sito/dashboard 0.0.67 → 0.0.69

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/README.md +7 -0
  2. package/dist/{Dropdown-CAxauIXt.cjs → Dropdown-CR8mco5s.cjs} +1 -1
  3. package/dist/{Dropdown-CbaxuMbk.js → Dropdown-D-fYEGo2.js} +13 -14
  4. package/dist/Dropdown.cjs +1 -1
  5. package/dist/Dropdown.css +1 -1
  6. package/dist/Dropdown.js +1 -1
  7. package/dist/FileInput-CqzVk1gQ.cjs +1 -0
  8. package/dist/{FileInput-DCR_Pyqe.js → FileInput-Cr4TxWUg.js} +34 -32
  9. package/dist/FiltersProvider-BoCTMqk8.js +60 -0
  10. package/dist/FiltersProvider-Bxge43VS.cjs +1 -0
  11. package/dist/FiltersProvider.cjs +1 -1
  12. package/dist/FiltersProvider.js +1 -1
  13. package/dist/Form.cjs +1 -1
  14. package/dist/Form.js +2 -2
  15. package/dist/Table-BLhy0EYJ.cjs +1 -0
  16. package/dist/Table-CeD0yXGZ.js +1113 -0
  17. package/dist/Table.cjs +1 -1
  18. package/dist/Table.css +1 -1
  19. package/dist/Table.js +1 -1
  20. package/dist/TableOptions.cjs +1 -1
  21. package/dist/TableOptions.js +1 -1
  22. package/dist/TableOptionsProvider-BJdeNIQj.cjs +1 -0
  23. package/dist/TableOptionsProvider-DBr-FW53.js +106 -0
  24. package/dist/TextInput-C27RFuya.cjs +1 -0
  25. package/dist/TextInput-DPYxzgm3.js +335 -0
  26. package/dist/TextInput.css +1 -1
  27. package/dist/Translation.cjs +1 -1
  28. package/dist/Translation.js +1 -1
  29. package/dist/{TranslationProvider-COebIyxr.js → TranslationProvider-BR4s--Vu.js} +2 -2
  30. package/dist/TranslationProvider-Czr0WIDH.cjs +1 -0
  31. package/dist/components/Dropdown/Dropdown.d.ts +1 -1
  32. package/dist/components/Form/FileInput/types.d.ts +1 -1
  33. package/dist/components/Table/components/types.d.ts +1 -1
  34. package/dist/components/Table/types.d.ts +1 -1
  35. package/dist/index.cjs +1 -1
  36. package/dist/index.css +1 -1
  37. package/dist/index.js +7 -7
  38. package/dist/providers/Translation/TranslationProvider.d.ts +5 -4
  39. package/package.json +1 -1
  40. package/dist/FileInput-Ch-GCxrS.cjs +0 -1
  41. package/dist/FiltersProvider-CY2fsw_F.js +0 -57
  42. package/dist/FiltersProvider-CYqLFEI9.cjs +0 -1
  43. package/dist/Table-BtZGG0d7.js +0 -1056
  44. package/dist/Table-DjIhOMXQ.cjs +0 -1
  45. package/dist/TableOptionsProvider-BchUDA3B.cjs +0 -1
  46. package/dist/TableOptionsProvider-BfQS8l1N.js +0 -50
  47. package/dist/TextInput-BqW5YX-3.js +0 -320
  48. package/dist/TextInput-CY1fh4mf.cjs +0 -1
  49. package/dist/TranslationProvider-51Pc9Xrr.cjs +0 -1
  50. package/dist/components/Actions/Actions.stories.d.ts +0 -20
  51. package/dist/components/Actions/Actions.test.d.ts +0 -1
  52. package/dist/components/Actions/ActionsDropdown.stories.d.ts +0 -17
  53. package/dist/components/Actions/ActionsDropdown.test.d.ts +0 -1
  54. package/dist/components/Badge/Badge.stories.d.ts +0 -8
  55. package/dist/components/Button/Button.stories.d.ts +0 -29
  56. package/dist/components/Chip/Chip.stories.d.ts +0 -9
  57. package/dist/components/Dropdown/Dropdown.stories.d.ts +0 -8
  58. package/dist/components/Dropdown/Dropdown.test.d.ts +0 -1
  59. package/dist/components/Form/AutocompleteInput/AutocompleteInput.stories.d.ts +0 -8
  60. package/dist/components/Form/CheckInput/CheckInput.stories.d.ts +0 -6
  61. package/dist/components/Form/FileInput/FileInput.stories.d.ts +0 -7
  62. package/dist/components/Form/FileInput/FileInput.test.d.ts +0 -1
  63. package/dist/components/Form/FileInput/utils.test.d.ts +0 -1
  64. package/dist/components/Form/SelectInput/SelectInput.stories.d.ts +0 -7
  65. package/dist/components/Form/TextInput/TextInput.stories.d.ts +0 -10
  66. package/dist/components/Form/TextInput/TextInput.test.d.ts +0 -1
  67. package/dist/components/Form/utils.test.d.ts +0 -1
  68. package/dist/components/IconButton/IconButton.stories.d.ts +0 -30
  69. package/dist/components/Loading/Loading.stories.d.ts +0 -7
  70. package/dist/components/Table/Table.expandable.test.d.ts +0 -1
  71. package/dist/components/Table/Table.selection.test.d.ts +0 -1
  72. package/dist/components/Table/Table.stories.d.ts +0 -18
  73. package/dist/components/Table/components/Filters/FilterDropdown/FilterDropdown.test.d.ts +0 -1
  74. package/dist/components/Table/components/TableSelectionBar.test.d.ts +0 -1
  75. package/dist/components/Table/utils.test.d.ts +0 -1
  76. package/dist/components/Tooltip/Tooltip.stories.d.ts +0 -6
  77. package/dist/providers/FiltersProvider/utils.test.d.ts +0 -1
  78. package/dist/providers/TableOptions/TableOptionsProvider.test.d.ts +0 -1
@@ -1,1056 +0,0 @@
1
- import "./Table.css";
2
- import { jsxs as g, jsx as e, Fragment as G } from "react/jsx-runtime";
3
- import { useState as _, useRef as j, useEffect as P, useMemo as w, useCallback as v, Fragment as ae } from "react";
4
- import { u as H, a as V, F as re } from "./FiltersProvider-CY2fsw_F.js";
5
- import { B as ie } from "./Badge-CIeYthEy.js";
6
- import { E as oe, c as ce, C as de, a as ue, b as pe, F as me } from "./Filters-DL5jd8ps.js";
7
- import { FilterTypes as W } from "./lib.js";
8
- import { u as k } from "./TranslationProvider-COebIyxr.js";
9
- import { A as he, C as fe, S as Z, T as Y } from "./TextInput-BqW5YX-3.js";
10
- import { u as D } from "./TableOptionsProvider-BfQS8l1N.js";
11
- import { C as ee } from "./Chip-C5ogKbFn.js";
12
- import { I as q } from "./IconButton-BpsTEj0z.js";
13
- import { T as ne } from "./Tooltip-B4E-FRwY.js";
14
- import { S as be } from "./query-CwuehjY1.js";
15
- import { B as ge } from "./Button-D73-swfo.js";
16
- import { D as Ne } from "./Dropdown-CbaxuMbk.js";
17
- import { L as Ce } from "./Loading-B_c_4XLr.js";
18
- function we(n) {
19
- const {
20
- id: t,
21
- icon: r,
22
- tooltip: s,
23
- onClick: l,
24
- children: a,
25
- hidden: u = !1,
26
- disabled: i = !1,
27
- showText: d = !1,
28
- showTooltips: o = !0,
29
- className: m = ""
30
- } = n;
31
- return u ? null : /* @__PURE__ */ g(
32
- "button",
33
- {
34
- id: t,
35
- className: `action ${d ? "text-action" : "icon-action"} ${m}`,
36
- disabled: i,
37
- onClick: () => l?.(),
38
- "aria-disabled": i,
39
- "data-tooltip-id": "tooltip",
40
- "data-tooltip-content": o ? s : "",
41
- children: [
42
- r,
43
- " ",
44
- d && s,
45
- a
46
- ]
47
- }
48
- );
49
- }
50
- function xe(n) {
51
- const {
52
- actions: t = [],
53
- className: r = "",
54
- itemClassName: s = "",
55
- actionClassName: l = "",
56
- showTooltips: a = !0,
57
- showActionTexts: u = !1
58
- } = n;
59
- return /* @__PURE__ */ e("ul", { className: `actions-container ${r}`, children: t.map((i) => /* @__PURE__ */ e(
60
- "li",
61
- {
62
- className: `actions-container-item ${s}`,
63
- children: /* @__PURE__ */ e(
64
- we,
65
- {
66
- showTooltips: a,
67
- showText: u,
68
- className: l,
69
- ...i
70
- }
71
- )
72
- },
73
- i.id
74
- )) });
75
- }
76
- const ve = (n) => {
77
- const { actions: t = [], className: r = "" } = n, { t: s } = k(), [l, a] = _(!1), [u, i] = _(null);
78
- return /* @__PURE__ */ g("div", { className: `actions-dropdown ${r}`, children: [
79
- /* @__PURE__ */ e(
80
- q,
81
- {
82
- icon: /* @__PURE__ */ e(oe, {}),
83
- onClick: (d) => {
84
- i(d.currentTarget), a((o) => !o);
85
- },
86
- className: "actions-dropdown-trigger",
87
- "data-tooltip-id": "tooltip",
88
- "data-tooltip-content": s("_accessibility:buttons.openActions")
89
- }
90
- ),
91
- /* @__PURE__ */ e(
92
- Ne,
93
- {
94
- open: l,
95
- onClose: () => a(!1),
96
- anchorEl: u,
97
- children: /* @__PURE__ */ e(
98
- xe,
99
- {
100
- showActionTexts: !0,
101
- actions: t,
102
- itemClassName: "w-full",
103
- actionClassName: "action-dropdown-item",
104
- className: "actions-dropdown-list",
105
- showTooltips: !1
106
- }
107
- )
108
- }
109
- )
110
- ] });
111
- };
112
- function se(n) {
113
- return [...n].sort((t, r) => (r.pos ?? 0) - (t.pos ?? 0)).filter((t) => t.display !== "none");
114
- }
115
- function ye(n) {
116
- const { t } = k(), {
117
- entity: r = "",
118
- columns: s = [],
119
- hasAction: l = !0,
120
- onSortCallback: a,
121
- selectionState: u,
122
- onToggleAllRows: i
123
- } = n, d = j(null);
124
- P(() => {
125
- d.current && (d.current.indeterminate = !!(u?.hasSomeSelected && !u?.allSelected));
126
- }, [u]);
127
- const { onSort: o, sortingOrder: m, sortingBy: h } = D(), f = w(() => se(s).map((c) => ({
128
- id: c.key,
129
- label: c.label,
130
- className: c.className ?? "",
131
- sortable: c.sortable ?? !0,
132
- sortOptions: c.sortOptions
133
- })), [s, r, t]);
134
- return /* @__PURE__ */ e("thead", { className: "table-headers-row", children: /* @__PURE__ */ g("tr", { children: [
135
- /* @__PURE__ */ e("th", { scope: "col", className: "table-headers-column table-headers-checkbox", children: i ? /* @__PURE__ */ e(
136
- "input",
137
- {
138
- type: "checkbox",
139
- ref: d,
140
- checked: u?.allSelected ?? !1,
141
- onChange: i,
142
- "aria-label": t("_accessibility:components.table.selectAllRows")
143
- }
144
- ) : null }),
145
- l && /* @__PURE__ */ e("th", { scope: "col", className: "table-headers-action", children: /* @__PURE__ */ e("span", { children: t("_accessibility:labels.actions") }) }),
146
- f.map((c) => /* @__PURE__ */ e(
147
- "th",
148
- {
149
- scope: "col",
150
- className: `table-headers-column ${c.className}`,
151
- children: /* @__PURE__ */ g(
152
- ge,
153
- {
154
- disabled: !c.sortable,
155
- onClick: () => o(c.id, a),
156
- className: "table-headers-cell",
157
- children: [
158
- /* @__PURE__ */ e("span", { className: "table-headers-label", children: c.label }),
159
- c.sortable && h === c.id && /* @__PURE__ */ e("span", { children: m === be.ASC ? c.sortOptions?.icons?.asc ?? /* @__PURE__ */ e(
160
- ce,
161
- {
162
- className: c.sortOptions?.icons?.className ?? "table-headers-sort-indicator"
163
- }
164
- ) : c.sortOptions?.icons?.desc ?? /* @__PURE__ */ e(
165
- de,
166
- {
167
- className: c.sortOptions?.icons?.className ?? "table-headers-sort-indicator"
168
- }
169
- ) })
170
- ]
171
- }
172
- )
173
- },
174
- c.id
175
- ))
176
- ] }) });
177
- }
178
- const Se = (n) => {
179
- const { items: t, text: r, id: s, onClearFilter: l } = n;
180
- return /* @__PURE__ */ e(
181
- ee,
182
- {
183
- text: `${r}: ${t.map((a) => a.value ?? a.name).join(", ")}`,
184
- onDelete: () => l(s)
185
- }
186
- );
187
- }, Re = (n) => {
188
- const { end: t, start: r, text: s, id: l, onClearFilter: a } = n;
189
- return /* @__PURE__ */ e(
190
- ee,
191
- {
192
- text: `${s}: ${r || "♾️"} - ${t || "♾️"}`,
193
- onDelete: () => a(l)
194
- }
195
- );
196
- }, Te = (n) => {
197
- const { filtersDefinition: t } = n, r = w(() => {
198
- const i = {};
199
- return t.forEach((d) => {
200
- i[d.propertyName] = d.label ?? d.propertyName;
201
- }), i;
202
- }, [t]), { filters: s, clearFilters: l } = D(), a = w(() => Object.keys(s), [s]), u = v(
203
- (i) => s[i]?.end || s[i]?.start ? /* @__PURE__ */ e(
204
- Re,
205
- {
206
- id: i,
207
- text: r[i],
208
- start: s[i].start,
209
- end: s[i].end,
210
- onClearFilter: l
211
- }
212
- ) : Array.isArray(s[i]) ? /* @__PURE__ */ e(
213
- Se,
214
- {
215
- id: i,
216
- text: r[i],
217
- items: s[i],
218
- onClearFilter: l
219
- }
220
- ) : /* @__PURE__ */ e(
221
- ee,
222
- {
223
- text: `${r[i]}: ${s[i]?.value ?? s[i]?.name ?? s[i]}`,
224
- onDelete: () => l(i)
225
- }
226
- ),
227
- [s, r]
228
- );
229
- return /* @__PURE__ */ e("ul", { className: "active-filters-main", children: a?.map((i) => /* @__PURE__ */ e("li", { children: u(i) }, i)) });
230
- };
231
- function Ae(n) {
232
- const { propertyName: t, label: r, placeholder: s, options: l, multiple: a = !0 } = n, { currentFilters: u, setCurrentFilters: i } = H(), d = w(() => u[t] ?? l[0], [u]), o = v(
233
- (m) => {
234
- i({
235
- type: V.update,
236
- toUpdate: {
237
- [t]: {
238
- value: m
239
- }
240
- }
241
- });
242
- },
243
- [a]
244
- );
245
- return /* @__PURE__ */ e(
246
- he,
247
- {
248
- value: d?.value,
249
- label: r,
250
- options: l,
251
- multiple: a,
252
- helperTextClassName: "hidden",
253
- containerClassName: "options-widget-container",
254
- onChange: o,
255
- placeholder: s
256
- }
257
- );
258
- }
259
- const Ee = (n) => {
260
- const { propertyName: t, label: r } = n, { currentFilters: s, setCurrentFilters: l } = H(), a = w(() => s[t]?.value ?? "", [s]), u = v((i) => {
261
- l({
262
- type: V.update,
263
- toUpdate: { [t]: { value: i.target.checked } }
264
- });
265
- }, []);
266
- return /* @__PURE__ */ e(fe, { label: r, checked: a ?? !1, onChange: u });
267
- };
268
- function Fe(n) {
269
- const { propertyName: t, options: r, label: s, placeholder: l } = n, { currentFilters: a, setCurrentFilters: u } = H(), i = w(() => a[t]?.value ?? r[0], [a]), d = v((o) => {
270
- u({
271
- type: V.update,
272
- toUpdate: { [t]: { value: o.target.value } }
273
- });
274
- }, []);
275
- return /* @__PURE__ */ e(
276
- Z,
277
- {
278
- value: i,
279
- label: s,
280
- options: r,
281
- helperTextClassName: "hidden",
282
- containerClassName: "options-widget-container",
283
- onChange: d,
284
- placeholder: l
285
- }
286
- );
287
- }
288
- const ke = (n) => {
289
- const { propertyName: t, label: r, placeholder: s } = n, { currentFilters: l, setCurrentFilters: a } = H(), u = w(() => l[t]?.value ?? "", [l]), i = v((d) => {
290
- a({
291
- type: V.update,
292
- toUpdate: { [t]: { value: d.target.value } }
293
- });
294
- }, []);
295
- return /* @__PURE__ */ e(
296
- Y,
297
- {
298
- value: u ?? "",
299
- label: r,
300
- onChange: i,
301
- containerClassName: "input-widget-container",
302
- helperTextClassName: "",
303
- placeholder: s
304
- }
305
- );
306
- }, te = (n) => {
307
- const { propertyName: t, label: r, inputType: s } = n, { t: l } = k(), { currentFilters: a, setCurrentFilters: u } = H(), i = j(null), d = j(null), o = v((h) => {
308
- u({
309
- type: V.update,
310
- toUpdate: {
311
- [t]: {
312
- value: { end: d?.current?.value ?? null, start: h.target.value }
313
- }
314
- }
315
- });
316
- }, []), m = v((h) => {
317
- u({
318
- type: V.update,
319
- toUpdate: {
320
- [t]: {
321
- value: {
322
- start: i?.current?.value ?? null,
323
- end: h.target.value
324
- }
325
- }
326
- }
327
- });
328
- }, []);
329
- return /* @__PURE__ */ g("div", { className: "range-widget-container", children: [
330
- /* @__PURE__ */ e("p", { className: "text-input-label input-widget-label input-label-normal", children: r }),
331
- /* @__PURE__ */ g("div", { className: "range-widget-row", children: [
332
- /* @__PURE__ */ e(
333
- Y,
334
- {
335
- value: a[t]?.value?.start ?? "",
336
- placeholder: l("_accessibility:components.table.filters.range.start"),
337
- type: s,
338
- ref: i,
339
- onChange: o,
340
- containerClassName: "input-widget-container",
341
- helperTextClassName: ""
342
- }
343
- ),
344
- /* @__PURE__ */ e(
345
- Y,
346
- {
347
- value: a[t]?.value?.end ?? "",
348
- placeholder: l("_accessibility:components.table.filters.range.end"),
349
- type: s,
350
- ref: d,
351
- onChange: m,
352
- containerClassName: "input-widget-container",
353
- helperTextClassName: ""
354
- }
355
- )
356
- ] })
357
- ] });
358
- }, $e = (n) => {
359
- switch (n.type) {
360
- case W.text:
361
- return /* @__PURE__ */ e(ke, { ...n });
362
- case W.number:
363
- return /* @__PURE__ */ e(
364
- te,
365
- {
366
- ...n,
367
- inputType: "number"
368
- }
369
- );
370
- case W.date:
371
- return /* @__PURE__ */ e(
372
- te,
373
- {
374
- ...n,
375
- inputType: "date"
376
- }
377
- );
378
- case W.select:
379
- return /* @__PURE__ */ e(Fe, { ...n });
380
- case W.autocomplete:
381
- return /* @__PURE__ */ e(Ae, { ...n });
382
- case W.check:
383
- return /* @__PURE__ */ e(Ee, { ...n });
384
- }
385
- return /* @__PURE__ */ e(G, {});
386
- }, Oe = (n) => {
387
- const { filters: t = [], show: r, handleShow: s } = n, { onFilterApply: l } = D(), { currentFilters: a, setCurrentFilters: u } = H(), { t: i } = k(), d = j(null);
388
- return P(() => {
389
- const o = ({ target: h }) => {
390
- d.current && (h?.closest(".filter-dropdown-trigger") || !r || d.current.contains(h) || s(!1));
391
- }, m = ({ code: h }) => {
392
- !r || h !== "Escape" || s(!1);
393
- };
394
- return document.addEventListener("click", o), document.addEventListener("keydown", m), () => {
395
- document.removeEventListener("click", o), document.removeEventListener("keydown", m);
396
- };
397
- }, [s, r]), /* @__PURE__ */ e("div", { className: `filter-dropdown-backdrop ${r ? "opened" : "closed"}`, children: /* @__PURE__ */ g("div", { className: "filter-popup", ref: d, children: [
398
- /* @__PURE__ */ e("div", { className: "filter-title", children: i("_accessibility:buttons.filters") }),
399
- /* @__PURE__ */ e("ul", { className: "filter-container", children: t.map((o) => /* @__PURE__ */ e("li", { className: "filter-container-item", children: $e(o) }, o.propertyName)) }),
400
- /* @__PURE__ */ e("div", { className: "filter-footer", children: /* @__PURE__ */ g("ul", { className: "filter-buttons-row", children: [
401
- /* @__PURE__ */ e("li", { children: /* @__PURE__ */ e(
402
- "button",
403
- {
404
- onClick: () => u({
405
- type: V.reset,
406
- filters: t
407
- }),
408
- className: "filter-dropdown-button small filter-dropdown-cancel",
409
- children: i("_accessibility:buttons.clear")
410
- }
411
- ) }),
412
- /* @__PURE__ */ e("li", { children: /* @__PURE__ */ e(
413
- "button",
414
- {
415
- className: "filter-dropdown-button small filter-dropdown-submit",
416
- onClick: () => {
417
- s(!1), l(a);
418
- },
419
- children: i("_accessibility:buttons.applyFilters")
420
- }
421
- ) })
422
- ] }) })
423
- ] }) });
424
- }, _e = () => {
425
- const { t: n } = k(), { total: t, pageSize: r, pageSizes: s, currentPage: l } = D(), a = (l + 1) * r > t ? t : (l + 1) * r;
426
- return /* @__PURE__ */ g("div", { className: "table-navigation-sizes", children: [
427
- s[0] < t && /* @__PURE__ */ e(G, { children: /* @__PURE__ */ g("p", { children: [
428
- l * r + 1,
429
- " - ",
430
- a,
431
- " ",
432
- n("_accessibility:components.table.of")
433
- ] }) }),
434
- /* @__PURE__ */ e("p", { children: t })
435
- ] });
436
- };
437
- function Me() {
438
- const { t: n } = k(), { total: t, pageSize: r, currentPage: s, setCurrentPage: l } = D(), a = w(() => {
439
- const u = Math.ceil(t / r);
440
- return Array.from({ length: u }, (i, d) => ({
441
- id: d,
442
- value: d + 1
443
- }));
444
- }, [t, r]);
445
- return /* @__PURE__ */ g("div", { className: "jump-to-page", children: [
446
- /* @__PURE__ */ e("p", { children: n("_accessibility:components.table.jumpToPage") }),
447
- /* @__PURE__ */ e(
448
- Z,
449
- {
450
- value: s,
451
- options: a,
452
- inputClassName: "jump-to-page-input",
453
- containerClassName: "jump-to-page-input-container",
454
- helperTextClassName: "hidden",
455
- onChange: (u) => l(Number(u.target.value))
456
- }
457
- )
458
- ] });
459
- }
460
- const Pe = () => {
461
- const { t: n } = k(), { total: t, pageSize: r, currentPage: s, setCurrentPage: l } = D();
462
- return /* @__PURE__ */ g("div", { className: "table-navigation-pages", children: [
463
- /* @__PURE__ */ e(
464
- q,
465
- {
466
- icon: /* @__PURE__ */ e(ue, { className: "table-navigation-icon" }),
467
- className: "table-navigation-buttons",
468
- disabled: s === 0,
469
- "aria-label": n("_accessibility:buttons.previous"),
470
- name: n("_accessibility:buttons.previous"),
471
- onClick: () => l(s - 1)
472
- }
473
- ),
474
- /* @__PURE__ */ e(
475
- q,
476
- {
477
- icon: /* @__PURE__ */ e(pe, { className: "table-navigation-icon" }),
478
- disabled: Math.floor(t / ((s + 1) * r)) === 0,
479
- className: "table-navigation-buttons",
480
- name: n("_accessibility:buttons.next"),
481
- "aria-label": n("_accessibility:buttons.next"),
482
- onClick: () => l(s + 1)
483
- }
484
- )
485
- ] });
486
- };
487
- function Ie() {
488
- const { t: n } = k(), { pageSizes: t, pageSize: r, setPageSize: s } = D(), l = w(
489
- () => t?.map((a) => ({ id: a, value: a })),
490
- [t]
491
- );
492
- return /* @__PURE__ */ g("div", { className: "page-size", children: [
493
- /* @__PURE__ */ e("p", { children: n("_accessibility:components.table.pageSizes") }),
494
- /* @__PURE__ */ e(
495
- Z,
496
- {
497
- value: r,
498
- options: l,
499
- inputClassName: "page-size-input",
500
- containerClassName: "page-size-input-container",
501
- helperTextClassName: "hidden",
502
- onChange: (a) => s(Number(a.target.value))
503
- }
504
- )
505
- ] });
506
- }
507
- function ze() {
508
- return /* @__PURE__ */ g("div", { className: "table-footer", children: [
509
- /* @__PURE__ */ e(Me, {}),
510
- /* @__PURE__ */ e(Ie, {}),
511
- /* @__PURE__ */ e(_e, {}),
512
- /* @__PURE__ */ e(Pe, {})
513
- ] });
514
- }
515
- const De = (n) => n, Le = (n) => {
516
- const { t } = k(), {
517
- columns: r,
518
- softDeleteProperty: s = "deletedAt",
519
- data: l,
520
- actions: a,
521
- selectedRows: u,
522
- expandedRows: i = [],
523
- onRowSelectionChange: d,
524
- onRowExpand: o
525
- } = n, m = w(
526
- () => se(r),
527
- [r]
528
- ), h = w(
529
- () => new Map(
530
- i.map((f) => [f.rowId, f])
531
- ),
532
- [i]
533
- );
534
- return l?.map((f) => {
535
- const c = u.has(f.id), S = h.get(f.id), A = !!S, U = m.length + 1 + (a ? 1 : 0);
536
- return /* @__PURE__ */ g(ae, { children: [
537
- /* @__PURE__ */ g(
538
- "tr",
539
- {
540
- className: `table-row ${o ? "expandable" : ""} ${f[s] ? "deleted-class" : ""} ${c ? "selected" : ""} ${A ? "expanded" : ""}`,
541
- onClick: () => o?.(f),
542
- children: [
543
- /* @__PURE__ */ e("td", { className: "table-row-cell table-row-checkbox", children: /* @__PURE__ */ e(
544
- "input",
545
- {
546
- type: "checkbox",
547
- checked: c,
548
- onClick: (x) => x.stopPropagation(),
549
- onChange: () => d(f),
550
- "aria-label": t("_accessibility:components.table.selectRow")
551
- }
552
- ) }),
553
- a ? /* @__PURE__ */ e("td", { className: "w-px", children: /* @__PURE__ */ e("div", { className: "table-row-cell-action", children: (() => {
554
- const x = a(f).filter(
555
- (N) => !N.hidden
556
- ), I = x.filter(
557
- (N) => N.sticky
558
- ), $ = x.filter(
559
- (N) => !N.sticky
560
- );
561
- return /* @__PURE__ */ g(G, { children: [
562
- I.map((N) => /* @__PURE__ */ e(ne, { content: N.tooltip, children: /* @__PURE__ */ e(
563
- q,
564
- {
565
- icon: N.icon,
566
- className: "row-table-action",
567
- onClick: (O) => {
568
- O.stopPropagation(), N.onClick(f);
569
- }
570
- }
571
- ) }, N.id)),
572
- $.length > 0 && /* @__PURE__ */ e(ve, { actions: $ })
573
- ] });
574
- })() }) }) : null,
575
- m?.map((x, I) => /* @__PURE__ */ e(
576
- "td",
577
- {
578
- className: `table-row-cell ${I === 0 ? "basic" : ""} ${x.className ?? ""}`,
579
- children: x.renderBody ? x.renderBody(f[x.key], f) : De(f[x.key])
580
- },
581
- x.key
582
- ))
583
- ]
584
- }
585
- ),
586
- A && S?.content !== null && typeof S?.content < "u" && /* @__PURE__ */ e("tr", { className: "table-row-expanded", children: /* @__PURE__ */ e("td", { className: "table-row-expanded-cell", colSpan: U, children: /* @__PURE__ */ e(
587
- "div",
588
- {
589
- className: `table-row-expanded-content ${S.isVisible ? "open" : "closed"}`,
590
- children: /* @__PURE__ */ e("div", { className: "table-row-expanded-inner", children: S.content })
591
- }
592
- ) }) })
593
- ] }, f.id);
594
- });
595
- };
596
- function je() {
597
- const { t: n } = k();
598
- return /* @__PURE__ */ e("div", { className: "table-empty", children: /* @__PURE__ */ e("p", { children: n("_accessibility:components.table.empty") }) });
599
- }
600
- const Ve = (n) => {
601
- const { columns: t, title: r, isLoading: s, toolbar: l, filterOptions: a } = n, { countOfFilters: u } = D(), { t: i } = k(), d = w(() => t ? t.sort((c, S) => (S.pos ?? 0) - (c.pos ?? 0)).filter((c) => !!c.filterOptions).map((c) => ({
602
- ...c.filterOptions,
603
- label: c.filterOptions?.label ?? c.label,
604
- propertyName: c.key
605
- })) : [], [t]), [o, m] = _(!1), h = v(
606
- (c) => {
607
- a?.dropdown?.setOpened ? a.dropdown.setOpened(c ?? !1) : m(c ?? !1);
608
- },
609
- [a]
610
- ), f = w(
611
- () => a?.dropdown?.opened ?? o,
612
- [a, o]
613
- );
614
- return /* @__PURE__ */ g("div", { className: `table-header ${f ? "showing-filters" : ""}`, children: [
615
- /* @__PURE__ */ g("div", { children: [
616
- r && /* @__PURE__ */ e("h1", { className: "table-header-title", children: r }),
617
- s ? null : /* @__PURE__ */ g("div", { className: "table-header-content", children: [
618
- l,
619
- a?.button?.hide !== !0 && /* @__PURE__ */ g(
620
- q,
621
- {
622
- icon: a?.button?.icon ?? /* @__PURE__ */ e(me, { className: "filter-dropdown-trigger-icon" }),
623
- className: "filter-dropdown-button normal filter-dropdown-trigger",
624
- "aria-haspopup": "true",
625
- onClick: () => h(!f),
626
- "aria-expanded": f,
627
- children: [
628
- /* @__PURE__ */ e(
629
- ie,
630
- {
631
- count: u,
632
- className: `${u > 0 ? "show" : "hide"} `
633
- }
634
- ),
635
- /* @__PURE__ */ e("span", { className: "table-header-sr", children: i("_accessibility:buttons.filters") }),
636
- /* @__PURE__ */ e("wbr", {})
637
- ]
638
- }
639
- )
640
- ] })
641
- ] }),
642
- !!d && !!d.length && /* @__PURE__ */ e(
643
- Oe,
644
- {
645
- filters: d,
646
- show: f,
647
- handleShow: h,
648
- options: a
649
- }
650
- ),
651
- /* @__PURE__ */ e(Te, { filtersDefinition: d })
652
- ] });
653
- };
654
- function Ue({
655
- count: n,
656
- multiActions: t,
657
- onActionClick: r
658
- }) {
659
- const { t: s } = k();
660
- return /* @__PURE__ */ g("div", { className: "table-selection-bar", children: [
661
- /* @__PURE__ */ e("p", { className: "table-selection-bar-count", children: s("_accessibility:components.table.selectedCount", { count: n }) }),
662
- t.length > 0 && /* @__PURE__ */ e("div", { className: "table-selection-bar-actions", children: t.map((l) => /* @__PURE__ */ e(ne, { content: l.tooltip, children: /* @__PURE__ */ e(
663
- q,
664
- {
665
- icon: l.icon,
666
- className: "multi-table-action",
667
- onClick: () => r(l),
668
- disabled: l.disabled
669
- }
670
- ) }, l.id)) })
671
- ] });
672
- }
673
- const Q = 220;
674
- function Be({
675
- data: n,
676
- allowMultipleExpandedRows: t,
677
- controlledExpandedRowId: r,
678
- onExpandedRowChange: s,
679
- onRowExpand: l,
680
- findRowById: a
681
- }) {
682
- const [u, i] = _(null), [d, o] = _(null), [m, h] = _(null), [f, c] = _(null), [S, A] = _(!1), [U, x] = _(/* @__PURE__ */ new Set()), [I, $] = _([]), N = j(null), O = j(null), z = j(/* @__PURE__ */ new Map()), E = typeof r < "u", F = t && !E, y = E ? r ?? null : u, B = v(() => {
683
- O.current && (clearTimeout(O.current), O.current = null);
684
- }, []), T = v(
685
- (p) => {
686
- if (typeof p < "u") {
687
- const b = z.current.get(p);
688
- if (!b) return;
689
- clearTimeout(b), z.current.delete(p);
690
- return;
691
- }
692
- z.current.forEach(
693
- (b) => clearTimeout(b)
694
- ), z.current.clear();
695
- },
696
- []
697
- ), J = v(
698
- (p) => {
699
- T(p), $((b) => b.some(
700
- (R) => R.rowId === p
701
- ) ? b.map(
702
- (R) => R.rowId === p ? { ...R, isVisible: !1 } : R
703
- ) : b), z.current.set(
704
- p,
705
- setTimeout(() => {
706
- $(
707
- (b) => b.filter((C) => C.rowId !== p)
708
- ), z.current.delete(p);
709
- }, Q)
710
- );
711
- },
712
- [T]
713
- ), K = v(
714
- (p, b) => {
715
- T(p), $((C) => C.some(
716
- (M) => M.rowId === p
717
- ) ? C.map(
718
- (M) => M.rowId === p ? { ...M, content: b, isVisible: !1 } : M
719
- ) : [...C, { rowId: p, content: b, isVisible: !1 }]), requestAnimationFrame(() => {
720
- $(
721
- (C) => C.map(
722
- (R) => R.rowId === p ? { ...R, isVisible: !0 } : R
723
- )
724
- );
725
- });
726
- },
727
- [T]
728
- );
729
- P(() => {
730
- if (!F) return;
731
- const p = new Set(n.map((b) => b.id));
732
- x((b) => {
733
- const C = /* @__PURE__ */ new Set();
734
- return b.forEach((R) => {
735
- if (p.has(R)) {
736
- C.add(R);
737
- return;
738
- }
739
- T(R);
740
- }), C;
741
- }), $((b) => (b.forEach((C) => {
742
- p.has(C.rowId) || T(C.rowId);
743
- }), b.filter(
744
- (C) => p.has(C.rowId)
745
- )));
746
- }, [n, F, T]), P(() => {
747
- if (F) return;
748
- if (y === null) {
749
- o(null), E && (N.current = null);
750
- return;
751
- }
752
- a(y) || (E || i(null), o(null), E && (N.current = null));
753
- }, [
754
- n,
755
- y,
756
- a,
757
- E,
758
- F
759
- ]), P(() => {
760
- if (!F) {
761
- if (B(), y === null || d === null) {
762
- if (m === null) {
763
- A(!1), c(null);
764
- return;
765
- }
766
- A(!1), O.current = setTimeout(() => {
767
- h(null), c(null), O.current = null;
768
- }, Q);
769
- return;
770
- }
771
- if (m === null) {
772
- h(y), c(d), requestAnimationFrame(() => A(!0));
773
- return;
774
- }
775
- if (m === y) {
776
- c(d), requestAnimationFrame(() => A(!0));
777
- return;
778
- }
779
- A(!1), O.current = setTimeout(() => {
780
- h(y), c(d), requestAnimationFrame(() => A(!0)), O.current = null;
781
- }, Q);
782
- }
783
- }, [
784
- B,
785
- d,
786
- y,
787
- F,
788
- m
789
- ]), P(
790
- () => () => {
791
- B(), T();
792
- },
793
- [B, T]
794
- ), P(() => {
795
- if (!E) return;
796
- if (y === null) {
797
- o(null), N.current = null;
798
- return;
799
- }
800
- const p = a(y);
801
- if (!p) {
802
- o(null), N.current = null;
803
- return;
804
- }
805
- const b = N.current;
806
- o(l?.(p, b) ?? null), N.current = p;
807
- }, [y, a, E, l]);
808
- const le = v(
809
- (p) => {
810
- if (F) {
811
- if (U.has(p.id)) {
812
- x((X) => {
813
- const L = new Set(X);
814
- return L.delete(p.id), L;
815
- }), J(p.id), s?.(null, p);
816
- return;
817
- }
818
- x((X) => {
819
- const L = new Set(X);
820
- return L.add(p.id), L;
821
- });
822
- const M = l?.(p, null) ?? null;
823
- M !== null && typeof M < "u" ? K(p.id, M) : (T(p.id), $(
824
- (X) => X.filter((L) => L.rowId !== p.id)
825
- )), s?.(p, null);
826
- return;
827
- }
828
- const b = y === p.id, C = b ? p : a(y);
829
- if (E) {
830
- s?.(b ? null : p, C);
831
- return;
832
- }
833
- if (b) {
834
- i(null), o(null), s?.(null, p);
835
- return;
836
- }
837
- i(p.id), o(l?.(p, C) ?? null), s?.(p, C);
838
- },
839
- [
840
- y,
841
- J,
842
- T,
843
- K,
844
- a,
845
- U,
846
- E,
847
- F,
848
- s,
849
- l
850
- ]
851
- );
852
- return { expandedRowsToRender: w(() => F ? I : m === null || f === null || typeof f > "u" ? [] : [
853
- {
854
- rowId: m,
855
- content: f,
856
- isVisible: S
857
- }
858
- ], [
859
- S,
860
- F,
861
- f,
862
- m,
863
- I
864
- ]), onRowExpandChange: le };
865
- }
866
- function We({
867
- actions: n,
868
- selectedRowsData: t
869
- }) {
870
- const r = w(() => !n || !t.length ? [] : t.reduce(
871
- (l, a, u) => {
872
- const i = n(a).filter(
873
- (o) => o.multiple && !o.hidden
874
- );
875
- if (u === 0) return i;
876
- const d = new Map(
877
- l.map((o) => [o.id, o])
878
- );
879
- return i.reduce((o, m) => {
880
- const h = d.get(m.id);
881
- return h && o.push({
882
- ...h,
883
- ...m,
884
- disabled: m.disabled || h.disabled
885
- }), o;
886
- }, []);
887
- },
888
- []
889
- ), [n, t]), s = v(
890
- (l) => {
891
- if (t.length) {
892
- if (l.onMultipleClick) {
893
- l.onMultipleClick(t);
894
- return;
895
- }
896
- t.forEach((a) => l.onClick(a));
897
- }
898
- },
899
- [t]
900
- );
901
- return { multiActions: r, handleMultipleActionClick: s };
902
- }
903
- function qe({
904
- data: n,
905
- onRowSelect: t,
906
- onSelectedRowsChange: r
907
- }) {
908
- const [s, l] = _(/* @__PURE__ */ new Set()), a = w(
909
- () => n?.filter((o) => s.has(o.id)) ?? [],
910
- [n, s]
911
- );
912
- P(() => {
913
- if (!n?.length) {
914
- l(/* @__PURE__ */ new Set());
915
- return;
916
- }
917
- l((o) => {
918
- const m = /* @__PURE__ */ new Set(), h = new Set(n.map((f) => f.id));
919
- return o.forEach((f) => {
920
- h.has(f) && m.add(f);
921
- }), m;
922
- });
923
- }, [n]), P(() => {
924
- r && r(a);
925
- }, [a, r]);
926
- const u = v(
927
- (o) => {
928
- l((m) => {
929
- const h = new Set(m);
930
- return h.has(o.id) ? (h.delete(o.id), t?.(o, !1)) : (h.add(o.id), t?.(o, !0)), h;
931
- });
932
- },
933
- [t]
934
- ), i = v(() => {
935
- l((o) => {
936
- const m = new Set(o), h = n ?? [], f = h.every(
937
- (c) => m.has(c.id)
938
- );
939
- return h.forEach((c) => {
940
- const S = m.has(c.id);
941
- f ? S && (m.delete(c.id), t?.(c, !1)) : S || (m.add(c.id), t?.(c, !0));
942
- }), m;
943
- });
944
- }, [n, t]), d = w(() => {
945
- if (!n?.length)
946
- return { allSelected: !1, hasSomeSelected: !1 };
947
- const o = n.every((h) => s.has(h.id)), m = n.some((h) => s.has(h.id));
948
- return { allSelected: o, hasSomeSelected: m };
949
- }, [n, s]);
950
- return {
951
- selectedRows: s,
952
- selectedRowsData: a,
953
- selectionState: d,
954
- onRowSelectionChange: u,
955
- onToggleAllRows: i
956
- };
957
- }
958
- function dt(n) {
959
- const {
960
- data: t,
961
- onSort: r,
962
- entity: s = "",
963
- isLoading: l = !1,
964
- actions: a,
965
- columns: u = [],
966
- contentClassName: i = "",
967
- className: d = "",
968
- softDeleteProperty: o = "deletedAt",
969
- onRowSelect: m,
970
- onSelectedRowsChange: h,
971
- allowMultipleExpandedRows: f = !1,
972
- expandedRowId: c,
973
- onExpandedRowChange: S,
974
- onRowExpand: A,
975
- ...U
976
- } = n, x = w(() => !t?.length, [t]), I = v(
977
- (J) => J === null ? null : t.find((K) => K.id === J) ?? null,
978
- [t]
979
- ), {
980
- selectedRows: $,
981
- selectedRowsData: N,
982
- selectionState: O,
983
- onRowSelectionChange: z,
984
- onToggleAllRows: E
985
- } = qe({ data: t, onRowSelect: m, onSelectedRowsChange: h }), { expandedRowsToRender: F, onRowExpandChange: y } = Be({
986
- data: t,
987
- allowMultipleExpandedRows: f,
988
- controlledExpandedRowId: c,
989
- onExpandedRowChange: S,
990
- onRowExpand: A,
991
- findRowById: I
992
- }), { multiActions: B, handleMultipleActionClick: T } = We({
993
- actions: a,
994
- selectedRowsData: N
995
- });
996
- return /* @__PURE__ */ e(re, { children: /* @__PURE__ */ g("div", { className: `${d} table-main`, children: [
997
- /* @__PURE__ */ e(Ve, { columns: u, isLoading: l, ...U }),
998
- l ? /* @__PURE__ */ e(Ce, { className: "table-loading" }) : /* @__PURE__ */ e(G, { children: x ? /* @__PURE__ */ e(je, {}) : /* @__PURE__ */ g(G, { children: [
999
- !!N.length && /* @__PURE__ */ e(
1000
- Ue,
1001
- {
1002
- count: N.length,
1003
- multiActions: B,
1004
- onActionClick: T
1005
- }
1006
- ),
1007
- /* @__PURE__ */ e("div", { className: `${i} table-body`, children: /* @__PURE__ */ g("table", { className: "table-content", children: [
1008
- /* @__PURE__ */ e(
1009
- ye,
1010
- {
1011
- entity: s,
1012
- columns: u,
1013
- onSortCallback: r,
1014
- hasAction: !!a,
1015
- selectionState: O,
1016
- onToggleAllRows: E
1017
- }
1018
- ),
1019
- /* @__PURE__ */ e("tbody", { children: /* @__PURE__ */ e(
1020
- Le,
1021
- {
1022
- data: t,
1023
- actions: a,
1024
- columns: u,
1025
- softDeleteProperty: o,
1026
- selectedRows: $,
1027
- expandedRows: F,
1028
- onRowSelectionChange: z,
1029
- onRowExpand: A ? y : void 0
1030
- }
1031
- ) })
1032
- ] }) }),
1033
- /* @__PURE__ */ e(ze, {})
1034
- ] }) })
1035
- ] }) });
1036
- }
1037
- export {
1038
- Te as A,
1039
- ye as C,
1040
- Oe as F,
1041
- Pe as N,
1042
- Ie as P,
1043
- Re as R,
1044
- je as T,
1045
- Se as a,
1046
- _e as b,
1047
- ze as c,
1048
- Le as d,
1049
- Ve as e,
1050
- Ue as f,
1051
- dt as g,
1052
- we as h,
1053
- xe as i,
1054
- ve as j,
1055
- $e as r
1056
- };