@memobit/libs 3.13.0 → 3.13.2
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,5 +1,5 @@
|
|
|
1
1
|
import './DataView.css';
|
|
2
|
-
import { Icon as
|
|
2
|
+
import { Icon as O } from "../Icon/Icon2.js";
|
|
3
3
|
import { Button as ft } from "../Button/Button2.js";
|
|
4
4
|
import { Tooltip as Ee } from "../Tooltip/Tooltip2.js";
|
|
5
5
|
import { Checkbox as re } from "../Checkbox/Checkbox2.js";
|
|
@@ -20,10 +20,10 @@ import { Fragment as Pt, jsx as t, jsxs as c } from "react/jsx-runtime";
|
|
|
20
20
|
function $t({ state: h }) {
|
|
21
21
|
return /* @__PURE__ */ t("span", {
|
|
22
22
|
className: `data-view__sort-icon data-view__sort-icon--${h}`,
|
|
23
|
-
children: /* @__PURE__ */ t(
|
|
23
|
+
children: /* @__PURE__ */ t(O, { name: h === "asc" ? "arrow-up" : h === "desc" ? "arrow-down" : "arrow-bidirectional-vertical" })
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
function Xt({ columns: h, data:
|
|
26
|
+
function Xt({ columns: h, data: R, rowKey: le, pinnedIds: y, selectable: w = !1, onSelectionChange: xe, selectedIds: ce, pageSizeOptions: de = Le, initialPageSize: Be = Le[1], showPageSize: $ = !0, card: Fe, actions: C, actionsWidth: z, timeline: N, onRowClick: K, rowHref: he, rowClassName: ue, rowDetail: Ie, empty: S, initialSortKey: Re = null, initialSortDirection: ze = "asc", sortKey: X, sortDirection: me, onSortChange: Ke, miniSort: U, showCardSortControls: Ue = !0, desktopView: fe = "table", cardMaxWidth: We, className: D, onPageChange: je, onPageSizeChange: pe, currentPage: ve, totalItems: _e, group: o, showResultsCount: Oe = !0, totalCount: Xe, itemNoun: Ze, columnSelector: Z }) {
|
|
27
27
|
const { isMobile: we } = vt(), [qe, Je] = P(Re), [Qe, Ye] = P(ze), [He, et] = P([]), f = ce ?? He, [tt, at] = P(1), nt = ve ?? tt, [T, ge] = P(Be), [M, it] = P(() => h.reduce((e, a) => (a.width && (e[a.key] = a.width), e), {})), [be, st] = P(/* @__PURE__ */ new Set()), ke = (e) => {
|
|
28
28
|
st((a) => {
|
|
29
29
|
const s = new Set(a);
|
|
@@ -31,30 +31,30 @@ function Xt({ columns: h, data: I, rowKey: le, pinnedIds: y, selectable: w = !1,
|
|
|
31
31
|
});
|
|
32
32
|
}, g = Mt((e, a) => le?.(e, a) ?? a, [le]), V = (e) => {
|
|
33
33
|
ve === void 0 && at(e), je?.(e);
|
|
34
|
-
}, p =
|
|
35
|
-
|
|
34
|
+
}, p = X !== void 0 ? X : qe, v = me ?? Qe, A = (e, a) => {
|
|
35
|
+
X === void 0 && Je(e), me === void 0 && Ye(a), Ke?.({
|
|
36
36
|
key: e,
|
|
37
37
|
direction: a
|
|
38
38
|
}), V(1);
|
|
39
|
-
},
|
|
40
|
-
let e =
|
|
39
|
+
}, W = L(() => new Set(y ?? []), [y]), q = L(() => {
|
|
40
|
+
let e = R;
|
|
41
41
|
if (p) {
|
|
42
42
|
const n = h.find((i) => i.key === p);
|
|
43
43
|
if (n) {
|
|
44
44
|
const i = n.sortAccessor || n.accessor || ((m) => {
|
|
45
45
|
const u = m[n.key];
|
|
46
46
|
return typeof u == "string" || typeof u == "number" ? u : "";
|
|
47
|
-
}), r = [...
|
|
47
|
+
}), r = [...R].sort((m, u) => {
|
|
48
48
|
const _ = i(m), d = i(u);
|
|
49
49
|
return typeof _ == "number" && typeof d == "number" ? _ - d : String(_).localeCompare(String(d));
|
|
50
50
|
});
|
|
51
51
|
e = v === "asc" ? r : r.reverse();
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
if (
|
|
54
|
+
if (W.size === 0) return e;
|
|
55
55
|
const a = [], s = [];
|
|
56
56
|
if (e.forEach((n, i) => {
|
|
57
|
-
|
|
57
|
+
W.has(g(n, i)) ? a.push(n) : s.push(n);
|
|
58
58
|
}), y && y.length > 1 && a.length > 1) {
|
|
59
59
|
const n = new Map(y.map((i, r) => [i, r]));
|
|
60
60
|
a.sort((i, r) => (n.get(g(i, 0)) ?? 0) - (n.get(g(r, 0)) ?? 0));
|
|
@@ -62,16 +62,16 @@ function Xt({ columns: h, data: I, rowKey: le, pinnedIds: y, selectable: w = !1,
|
|
|
62
62
|
return [...a, ...s];
|
|
63
63
|
}, [
|
|
64
64
|
h,
|
|
65
|
-
|
|
65
|
+
R,
|
|
66
66
|
v,
|
|
67
67
|
p,
|
|
68
|
-
|
|
68
|
+
W,
|
|
69
69
|
y,
|
|
70
70
|
g
|
|
71
71
|
]), j = _e !== void 0, x = L(() => {
|
|
72
|
-
if (!o || j) return
|
|
72
|
+
if (!o || j) return q;
|
|
73
73
|
const e = /* @__PURE__ */ new Map(), a = [];
|
|
74
|
-
|
|
74
|
+
q.forEach((n) => {
|
|
75
75
|
const i = o.groupBy(n), r = e.get(i);
|
|
76
76
|
r ? r.push(n) : (e.set(i, [n]), a.push(i));
|
|
77
77
|
});
|
|
@@ -88,8 +88,8 @@ function Xt({ columns: h, data: I, rowKey: le, pinnedIds: y, selectable: w = !1,
|
|
|
88
88
|
}, [
|
|
89
89
|
o,
|
|
90
90
|
j,
|
|
91
|
-
|
|
92
|
-
]),
|
|
91
|
+
q
|
|
92
|
+
]), B = j ? _e : x.length, J = Math.max(1, Math.ceil(B / T)), F = Math.min(nt, J), b = j ? x : x.slice((F - 1) * T, F * T), Q = Oe ? _t(T, B, Xe ?? B, F, Ze) : null, Y = L(() => {
|
|
93
93
|
if (!o) return null;
|
|
94
94
|
const e = /* @__PURE__ */ new Map();
|
|
95
95
|
return x.forEach((a) => {
|
|
@@ -122,7 +122,7 @@ function Xt({ columns: h, data: I, rowKey: le, pinnedIds: y, selectable: w = !1,
|
|
|
122
122
|
}));
|
|
123
123
|
return wt(e, N.granularity);
|
|
124
124
|
}, [b, N]), E = (e) => {
|
|
125
|
-
ce === void 0 && et(e), xe?.(
|
|
125
|
+
ce === void 0 && et(e), xe?.(R.filter((a, s) => e.includes(g(a, s))));
|
|
126
126
|
}, rt = (e) => {
|
|
127
127
|
e.sortable && (p === e.key ? A(e.key, v === "asc" ? "desc" : "asc") : A(e.key, "asc"));
|
|
128
128
|
}, ot = (e, a) => {
|
|
@@ -140,13 +140,13 @@ function Xt({ columns: h, data: I, rowKey: le, pinnedIds: y, selectable: w = !1,
|
|
|
140
140
|
}, Ce = h.some((e) => e.filter), ee = h.filter((e) => e.sortable), lt = ee.map((e) => ({
|
|
141
141
|
label: bt(e),
|
|
142
142
|
value: e.key
|
|
143
|
-
})), ct = ee.length > 0, te = p ? ee.find((e) => e.key === p) : void 0, dt =
|
|
143
|
+
})), ct = ee.length > 0, te = p ? ee.find((e) => e.key === p) : void 0, dt = U?.align ?? "left", Ne = (U?.columns ?? U?.column ?? []).length > 0 ? /* @__PURE__ */ t(St, {
|
|
144
144
|
columns: h,
|
|
145
|
-
config:
|
|
145
|
+
config: U,
|
|
146
146
|
sortKey: p,
|
|
147
147
|
sortDirection: v,
|
|
148
148
|
onSort: A
|
|
149
|
-
}) : null, Se =
|
|
149
|
+
}) : null, Se = Z && Z.options.length > 0 ? /* @__PURE__ */ t(Nt, { config: Z }) : null, k = b.map(g), ae = k.filter((e) => f.includes(e)).length, ne = !!w && k.length > 0 && ae === k.length, Me = !!w && ae > 0 && ae < k.length, Pe = (e) => {
|
|
150
150
|
E(e ? [...f, ...k.filter((a) => !f.includes(a))] : f.filter((a) => !k.includes(a)));
|
|
151
151
|
}, ht = w && k.length > 0 ? /* @__PURE__ */ c("label", {
|
|
152
152
|
className: "data-view__select-all",
|
|
@@ -211,7 +211,7 @@ function Xt({ columns: h, data: I, rowKey: le, pinnedIds: y, selectable: w = !1,
|
|
|
211
211
|
te && A(te.key, v === "asc" ? "desc" : "asc");
|
|
212
212
|
},
|
|
213
213
|
variant: "ghost",
|
|
214
|
-
children: /* @__PURE__ */ t(
|
|
214
|
+
children: /* @__PURE__ */ t(O, { name: v === "asc" ? "arrow-up" : "arrow-down" })
|
|
215
215
|
})
|
|
216
216
|
})]
|
|
217
217
|
}),
|
|
@@ -229,7 +229,7 @@ function Xt({ columns: h, data: I, rowKey: le, pinnedIds: y, selectable: w = !1,
|
|
|
229
229
|
card: Fe,
|
|
230
230
|
actions: C,
|
|
231
231
|
timeline: N,
|
|
232
|
-
onRowClick:
|
|
232
|
+
onRowClick: K,
|
|
233
233
|
rowHref: he,
|
|
234
234
|
rowClassName: ue,
|
|
235
235
|
empty: S,
|
|
@@ -248,9 +248,9 @@ function Xt({ columns: h, data: I, rowKey: le, pinnedIds: y, selectable: w = !1,
|
|
|
248
248
|
}
|
|
249
249
|
}),
|
|
250
250
|
/* @__PURE__ */ t(Ge, {
|
|
251
|
-
currentPage:
|
|
251
|
+
currentPage: F,
|
|
252
252
|
totalPages: J,
|
|
253
|
-
totalItems:
|
|
253
|
+
totalItems: B,
|
|
254
254
|
onPageChange: V,
|
|
255
255
|
pageSizeOptions: $ ? de : void 0,
|
|
256
256
|
pageSize: $ ? T : void 0,
|
|
@@ -260,7 +260,7 @@ function Xt({ columns: h, data: I, rowKey: le, pinnedIds: y, selectable: w = !1,
|
|
|
260
260
|
})
|
|
261
261
|
]
|
|
262
262
|
});
|
|
263
|
-
const
|
|
263
|
+
const I = h.filter((e) => !e.hideInTable && !(we && e.hideInMobile)), G = N && ye.size > 0, Te = /* @__PURE__ */ c(Pt, { children: [
|
|
264
264
|
De,
|
|
265
265
|
/* @__PURE__ */ t("div", {
|
|
266
266
|
className: "data-view__wrapper",
|
|
@@ -274,7 +274,7 @@ function Xt({ columns: h, data: I, rowKey: le, pinnedIds: y, selectable: w = !1,
|
|
|
274
274
|
onChange: Pe
|
|
275
275
|
})
|
|
276
276
|
}),
|
|
277
|
-
|
|
277
|
+
I.map((e) => {
|
|
278
278
|
const a = {};
|
|
279
279
|
return M[e.key] && (a.width = M[e.key]), e.minWidth && (a.minWidth = e.minWidth), /* @__PURE__ */ c("th", {
|
|
280
280
|
style: Object.keys(a).length > 0 ? a : void 0,
|
|
@@ -292,7 +292,7 @@ function Xt({ columns: h, data: I, rowKey: le, pinnedIds: y, selectable: w = !1,
|
|
|
292
292
|
}),
|
|
293
293
|
C && /* @__PURE__ */ t("th", {
|
|
294
294
|
className: "data-view__actions-header",
|
|
295
|
-
style:
|
|
295
|
+
style: z ? { width: z } : void 0,
|
|
296
296
|
children: "Actions"
|
|
297
297
|
})
|
|
298
298
|
] }), Ce && /* @__PURE__ */ c("tr", {
|
|
@@ -300,7 +300,7 @@ function Xt({ columns: h, data: I, rowKey: le, pinnedIds: y, selectable: w = !1,
|
|
|
300
300
|
children: [
|
|
301
301
|
G && /* @__PURE__ */ t("td", { className: "data-view__filter-cell data-view__filter-cell--spacer" }),
|
|
302
302
|
w && /* @__PURE__ */ t("td", { className: "data-view__filter-cell data-view__filter-cell--spacer" }),
|
|
303
|
-
|
|
303
|
+
I.map((e) => /* @__PURE__ */ t("td", {
|
|
304
304
|
className: "data-view__filter-cell",
|
|
305
305
|
style: M[e.key] ? { width: M[e.key] } : void 0,
|
|
306
306
|
children: e.filter ?? null
|
|
@@ -309,7 +309,7 @@ function Xt({ columns: h, data: I, rowKey: le, pinnedIds: y, selectable: w = !1,
|
|
|
309
309
|
]
|
|
310
310
|
})] }), /* @__PURE__ */ t("tbody", { children: (() => {
|
|
311
311
|
if (b.length === 0) return /* @__PURE__ */ t("tr", { children: /* @__PURE__ */ t("td", {
|
|
312
|
-
colSpan:
|
|
312
|
+
colSpan: I.length + (G ? 1 : 0) + (w ? 1 : 0) + (C ? 1 : 0),
|
|
313
313
|
className: "data-view__empty",
|
|
314
314
|
children: S ? /* @__PURE__ */ t(oe, {
|
|
315
315
|
title: S.title,
|
|
@@ -319,14 +319,14 @@ function Xt({ columns: h, data: I, rowKey: le, pinnedIds: y, selectable: w = !1,
|
|
|
319
319
|
secondary: S.secondary
|
|
320
320
|
}) : /* @__PURE__ */ t(oe, { title: "No data available" })
|
|
321
321
|
}) });
|
|
322
|
-
const e =
|
|
323
|
-
const r = g(n, i), m = f.includes(r), u =
|
|
322
|
+
const e = I.length + (G ? 1 : 0) + (w ? 1 : 0) + (C ? 1 : 0), a = o?.showCount !== !1, s = (n, i) => {
|
|
323
|
+
const r = g(n, i), m = f.includes(r), u = W.has(r), _ = ye.get(i), d = he?.(n), Ae = !!K || !!d, ut = (l) => {
|
|
324
324
|
if (d && (l.metaKey || l.ctrlKey || l.shiftKey)) {
|
|
325
325
|
window.open(d, "_blank", "noopener,noreferrer");
|
|
326
326
|
return;
|
|
327
327
|
}
|
|
328
|
-
if (
|
|
329
|
-
|
|
328
|
+
if (K) {
|
|
329
|
+
K(n, l);
|
|
330
330
|
return;
|
|
331
331
|
}
|
|
332
332
|
d && window.location.assign(d);
|
|
@@ -344,6 +344,7 @@ function Xt({ columns: h, data: I, rowKey: le, pinnedIds: y, selectable: w = !1,
|
|
|
344
344
|
}),
|
|
345
345
|
w && /* @__PURE__ */ t("td", {
|
|
346
346
|
className: "data-view__checkbox",
|
|
347
|
+
onClick: (l) => l.stopPropagation(),
|
|
347
348
|
children: /* @__PURE__ */ t(re, {
|
|
348
349
|
checked: m,
|
|
349
350
|
onChange: (l) => {
|
|
@@ -351,11 +352,11 @@ function Xt({ columns: h, data: I, rowKey: le, pinnedIds: y, selectable: w = !1,
|
|
|
351
352
|
}
|
|
352
353
|
})
|
|
353
354
|
}),
|
|
354
|
-
|
|
355
|
+
I.map((l, se) => /* @__PURE__ */ c("td", {
|
|
355
356
|
style: M[l.key] ? { width: M[l.key] } : void 0,
|
|
356
357
|
children: [se === 0 && u && /* @__PURE__ */ t(Ee, {
|
|
357
358
|
title: "Pinned",
|
|
358
|
-
children: /* @__PURE__ */ t(
|
|
359
|
+
children: /* @__PURE__ */ t(O, {
|
|
359
360
|
className: "data-view__pin-indicator",
|
|
360
361
|
name: "pin",
|
|
361
362
|
size: "sm"
|
|
@@ -364,7 +365,7 @@ function Xt({ columns: h, data: I, rowKey: le, pinnedIds: y, selectable: w = !1,
|
|
|
364
365
|
}, l.key)),
|
|
365
366
|
C && /* @__PURE__ */ t("td", {
|
|
366
367
|
className: "data-view__actions-cell",
|
|
367
|
-
style:
|
|
368
|
+
style: z ? { width: z } : void 0,
|
|
368
369
|
children: /* @__PURE__ */ t("div", {
|
|
369
370
|
className: "data-view__table-actions",
|
|
370
371
|
onClick: (l) => l.stopPropagation(),
|
|
@@ -402,7 +403,7 @@ function Xt({ columns: h, data: I, rowKey: le, pinnedIds: y, selectable: w = !1,
|
|
|
402
403
|
className: "data-view__group-count",
|
|
403
404
|
children: i.items.length === i.totalCount ? i.totalCount : `${i.items.length} of ${i.totalCount}`
|
|
404
405
|
}),
|
|
405
|
-
o?.collapsible && /* @__PURE__ */ t(
|
|
406
|
+
o?.collapsible && /* @__PURE__ */ t(O, {
|
|
406
407
|
className: "data-view__group-chevron",
|
|
407
408
|
name: m ? "caret-down" : "caret-up",
|
|
408
409
|
size: "sm"
|
|
@@ -416,9 +417,9 @@ function Xt({ columns: h, data: I, rowKey: le, pinnedIds: y, selectable: w = !1,
|
|
|
416
417
|
})() })] })
|
|
417
418
|
}),
|
|
418
419
|
/* @__PURE__ */ t(Ge, {
|
|
419
|
-
currentPage:
|
|
420
|
+
currentPage: F,
|
|
420
421
|
totalPages: J,
|
|
421
|
-
totalItems:
|
|
422
|
+
totalItems: B,
|
|
422
423
|
onPageChange: V,
|
|
423
424
|
pageSizeOptions: $ ? de : void 0,
|
|
424
425
|
pageSize: $ ? T : void 0,
|
package/dist/version.js
CHANGED
package/dist/version.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memobit/libs",
|
|
3
|
-
"version": "3.13.
|
|
3
|
+
"version": "3.13.2",
|
|
4
4
|
"description": "React component library powering the Memobit apps — 100+ components, helpers and hooks. Icons ship as @memobit/icons and themes as @memobit/themes. TypeScript-first, ESM-only, React 19.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
"terser": "5.51.2",
|
|
122
122
|
"typescript": "6.0.3",
|
|
123
123
|
"typescript-eslint": "8.70.1",
|
|
124
|
-
"vite": "8.3.
|
|
124
|
+
"vite": "8.3.3",
|
|
125
125
|
"vite-plugin-dts": "5.1.1",
|
|
126
126
|
"vite-plugin-static-copy": "4.1.1"
|
|
127
127
|
},
|