@memobit/libs 3.13.1 → 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);
|
|
@@ -352,11 +352,11 @@ function Xt({ columns: h, data: I, rowKey: le, pinnedIds: y, selectable: w = !1,
|
|
|
352
352
|
}
|
|
353
353
|
})
|
|
354
354
|
}),
|
|
355
|
-
|
|
355
|
+
I.map((l, se) => /* @__PURE__ */ c("td", {
|
|
356
356
|
style: M[l.key] ? { width: M[l.key] } : void 0,
|
|
357
357
|
children: [se === 0 && u && /* @__PURE__ */ t(Ee, {
|
|
358
358
|
title: "Pinned",
|
|
359
|
-
children: /* @__PURE__ */ t(
|
|
359
|
+
children: /* @__PURE__ */ t(O, {
|
|
360
360
|
className: "data-view__pin-indicator",
|
|
361
361
|
name: "pin",
|
|
362
362
|
size: "sm"
|
|
@@ -365,7 +365,7 @@ function Xt({ columns: h, data: I, rowKey: le, pinnedIds: y, selectable: w = !1,
|
|
|
365
365
|
}, l.key)),
|
|
366
366
|
C && /* @__PURE__ */ t("td", {
|
|
367
367
|
className: "data-view__actions-cell",
|
|
368
|
-
style:
|
|
368
|
+
style: z ? { width: z } : void 0,
|
|
369
369
|
children: /* @__PURE__ */ t("div", {
|
|
370
370
|
className: "data-view__table-actions",
|
|
371
371
|
onClick: (l) => l.stopPropagation(),
|
|
@@ -403,7 +403,7 @@ function Xt({ columns: h, data: I, rowKey: le, pinnedIds: y, selectable: w = !1,
|
|
|
403
403
|
className: "data-view__group-count",
|
|
404
404
|
children: i.items.length === i.totalCount ? i.totalCount : `${i.items.length} of ${i.totalCount}`
|
|
405
405
|
}),
|
|
406
|
-
o?.collapsible && /* @__PURE__ */ t(
|
|
406
|
+
o?.collapsible && /* @__PURE__ */ t(O, {
|
|
407
407
|
className: "data-view__group-chevron",
|
|
408
408
|
name: m ? "caret-down" : "caret-up",
|
|
409
409
|
size: "sm"
|
|
@@ -417,9 +417,9 @@ function Xt({ columns: h, data: I, rowKey: le, pinnedIds: y, selectable: w = !1,
|
|
|
417
417
|
})() })] })
|
|
418
418
|
}),
|
|
419
419
|
/* @__PURE__ */ t(Ge, {
|
|
420
|
-
currentPage:
|
|
420
|
+
currentPage: F,
|
|
421
421
|
totalPages: J,
|
|
422
|
-
totalItems:
|
|
422
|
+
totalItems: B,
|
|
423
423
|
onPageChange: V,
|
|
424
424
|
pageSizeOptions: $ ? de : void 0,
|
|
425
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",
|