asma-ui-core 3.45.2 → 3.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/asma-ui-core.css +1 -1
- package/dist/src/table/helpers/injectColumns.d.ts +1 -1
- package/dist/src/table/hooks/useColumnSizingPersistence.d.ts +3 -0
- package/dist/table/components/StyledTable.module.js +52 -52
- package/dist/table/components/StyledTableIndex.js +31 -27
- package/dist/table/components/TableRow.js +69 -61
- package/dist/table/components/columns/expandColumn.js +14 -10
- package/dist/table/components/columns/showTextColumn.js +20 -16
- package/dist/table/components/table-header/TableHeaderCell.js +34 -53
- package/dist/table/helpers/injectColumns.js +7 -7
- package/dist/table/hooks/useColumnSizingPersistence.js +36 -0
- package/dist/table/hooks/useColumnVirtualizer.js +4 -3
- package/dist/table/hooks/useStyledTable.js +48 -40
- package/package.json +1 -1
|
@@ -1,61 +1,55 @@
|
|
|
1
|
-
import { ACTIONS_COLUMN_ID as
|
|
1
|
+
import { ACTIONS_COLUMN_ID as S, INTERNAL_COLUMN_IDS as y } from "../../types.js";
|
|
2
2
|
import { useRootContext as G } from "../../context/RootContext.js";
|
|
3
3
|
import n from "../StyledTable.module.js";
|
|
4
|
-
import { DropUpIcon as
|
|
5
|
-
import { DropDownIcon as
|
|
6
|
-
import { getTableHeaderStyle as
|
|
7
|
-
import
|
|
8
|
-
import { useMemo as
|
|
9
|
-
import { jsx as
|
|
10
|
-
import { flexRender as
|
|
11
|
-
function
|
|
12
|
-
const { hideHeader:
|
|
13
|
-
return /* @__PURE__ */
|
|
4
|
+
import { DropUpIcon as A } from "../../shared-components/DropUpIcon.js";
|
|
5
|
+
import { DropDownIcon as k } from "../../shared-components/DropDownIcon.js";
|
|
6
|
+
import { getTableHeaderStyle as w } from "../../helpers/getTableHeaderStyle.js";
|
|
7
|
+
import _ from "clsx";
|
|
8
|
+
import { useMemo as c } from "react";
|
|
9
|
+
import { jsx as i, jsxs as F } from "react/jsx-runtime";
|
|
10
|
+
import { flexRender as B } from "@tanstack/react-table";
|
|
11
|
+
function J({ styledTableProps: C, header: o, tableCanResize: D = !1, left: b, right: N, tableWidth: z }) {
|
|
12
|
+
const { hideHeader: r = !1, enableResizing: a = !1, actions: I, customActionsNode: h } = C, { isResizing: m, enableResizingFlag: u, disableResizingFlag: d } = G(), g = o.column.columnDef.fixedLeft, f = !!o.column.columnDef.fixedRight, l = o.column.id === S, p = !!I || !!h, x = c(() => o.headerGroup.headers.some((e) => e.id === S), [o.headerGroup.headers]), H = c(() => o.headerGroup.headers.some((e) => !!e.column.columnDef.fixedRight), [o.headerGroup.headers]), T = c(() => o.headerGroup.headers[o.headerGroup.headers.length - (x ? 2 : 1)], [o.headerGroup.headers, x]), t = o.column.getCanSort(), R = o.column.getIsSorted(), v = t ? R === "asc" ? "ascending" : R === "desc" ? "descending" : "none" : void 0;
|
|
13
|
+
return /* @__PURE__ */ i("th", {
|
|
14
14
|
colSpan: o.colSpan,
|
|
15
|
-
"aria-sort":
|
|
16
|
-
className:
|
|
15
|
+
"aria-sort": v,
|
|
16
|
+
className: _(n["t-cell"], r && n["hide-header"], l && n["t-cell__actions"], l && !p && n["t-cell__actions--not-fixed"], l && p && H && n["t-cell__actions--no-shadow"], g && n["t-cell__fixed"], f && n["t-cell__fixed-right"]),
|
|
17
17
|
style: {
|
|
18
|
-
...
|
|
19
|
-
enableResizing:
|
|
18
|
+
...w({
|
|
19
|
+
enableResizing: a,
|
|
20
20
|
header: o,
|
|
21
|
-
tableWidth:
|
|
21
|
+
tableWidth: z
|
|
22
22
|
}),
|
|
23
|
-
...
|
|
24
|
-
...
|
|
23
|
+
...g && { left: b },
|
|
24
|
+
...f && { right: N }
|
|
25
25
|
},
|
|
26
|
-
children: /* @__PURE__ */
|
|
27
|
-
className:
|
|
28
|
-
role:
|
|
29
|
-
tabIndex:
|
|
26
|
+
children: /* @__PURE__ */ F("div", {
|
|
27
|
+
className: _("flex items-center justify-start", r ? n["hide-table-header"] : n["show-table-header"], t && n["sortable-column"], o.column.columnDef.className),
|
|
28
|
+
role: t ? "button" : void 0,
|
|
29
|
+
tabIndex: t ? 0 : void 0,
|
|
30
30
|
onClick: (e) => {
|
|
31
|
-
const
|
|
32
|
-
!
|
|
31
|
+
const s = o.column.getToggleSortingHandler();
|
|
32
|
+
!m && s && s(e), d();
|
|
33
33
|
},
|
|
34
|
-
onKeyDown:
|
|
34
|
+
onKeyDown: t ? (e) => {
|
|
35
35
|
if (e.key !== "Enter" && e.key !== " ") return;
|
|
36
36
|
e.preventDefault();
|
|
37
|
-
const
|
|
38
|
-
!
|
|
37
|
+
const s = o.column.getToggleSortingHandler();
|
|
38
|
+
!m && s && s(e), d();
|
|
39
39
|
} : void 0,
|
|
40
40
|
children: [
|
|
41
|
-
|
|
41
|
+
B(o.column.columnDef.header, o.getContext()),
|
|
42
42
|
{
|
|
43
|
-
asc: /* @__PURE__ */
|
|
44
|
-
desc: /* @__PURE__ */
|
|
43
|
+
asc: /* @__PURE__ */ i(A, { className: n["sort-icon"] }),
|
|
44
|
+
desc: /* @__PURE__ */ i(k, { className: n["sort-icon"] })
|
|
45
45
|
}[o.column.getIsSorted()] ?? null,
|
|
46
|
-
|
|
46
|
+
D && (a ? !0 : o.id !== T?.id) && o.column.getCanResize() && !y.includes(o.column.id) && /* @__PURE__ */ i("div", {
|
|
47
47
|
onDoubleClick: () => o.column.resetSize(),
|
|
48
48
|
onMouseDown: (e) => {
|
|
49
|
-
e.stopPropagation(),
|
|
50
|
-
styledTableProps: t,
|
|
51
|
-
header: o
|
|
52
|
-
}));
|
|
49
|
+
e.stopPropagation(), u(), o.getResizeHandler()(e);
|
|
53
50
|
},
|
|
54
51
|
onTouchStart: (e) => {
|
|
55
|
-
e.stopPropagation(),
|
|
56
|
-
styledTableProps: t,
|
|
57
|
-
header: o
|
|
58
|
-
}));
|
|
52
|
+
e.stopPropagation(), u(), o.getResizeHandler()(e);
|
|
59
53
|
},
|
|
60
54
|
className: `${n.resizer} ${o.column.getIsResizing() ? n.isResizing : ""}`
|
|
61
55
|
})
|
|
@@ -63,19 +57,6 @@ function V({ styledTableProps: t, header: o, tableCanResize: r = !1, left: a, ri
|
|
|
63
57
|
})
|
|
64
58
|
}, o.id);
|
|
65
59
|
}
|
|
66
|
-
function z({ styledTableProps: t, header: o }) {
|
|
67
|
-
if (t.uniqueKey) {
|
|
68
|
-
const r = t.uniqueKey, a = localStorage.getItem(r);
|
|
69
|
-
let i = {};
|
|
70
|
-
if (a) try {
|
|
71
|
-
const s = JSON.parse(a);
|
|
72
|
-
s && typeof s == "object" && !Array.isArray(s) && (i = Object.fromEntries(Object.entries(s).filter((m) => typeof m[1] == "number")));
|
|
73
|
-
} catch {
|
|
74
|
-
console.warn("Failed to parse stored dimensions. Resetting."), i = {};
|
|
75
|
-
}
|
|
76
|
-
i[o.column.id] = o.column.getSize(), localStorage.setItem(r, JSON.stringify(i));
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
60
|
export {
|
|
80
|
-
|
|
61
|
+
J as TableHeaderCell
|
|
81
62
|
};
|
|
@@ -4,17 +4,17 @@ import { generateExpandColumn as h } from "../components/columns/expandColumn.js
|
|
|
4
4
|
import { generateActionsColumn as x } from "../components/columns/action-column/actionColumn.js";
|
|
5
5
|
import { generateDndHandleColumn as _ } from "../components/columns/dndHandleColumn.js";
|
|
6
6
|
import { generateShowFullTextColumn as A } from "../components/columns/showTextColumn.js";
|
|
7
|
-
var T = (
|
|
8
|
-
const {
|
|
9
|
-
!
|
|
7
|
+
var T = (i) => {
|
|
8
|
+
const { actions: r, customActionsNode: m, headerPin: d = !0, enableRowSelection: u, expandArrow: f, enableDnd: c, customDndColumnProps: a, rowHeight: e, textExpandArrow: s, customActionsColumnProps: p, rowActionsState: C, locale: l } = i, n = [...i.columns], t = n.some((o) => o.fixedLeft === !0);
|
|
9
|
+
return !n.find((o) => o.id === "actions") && (r || m || d) && n.push(x({
|
|
10
10
|
headerPin: d,
|
|
11
|
-
actions:
|
|
12
|
-
customActionsNode:
|
|
11
|
+
actions: r,
|
|
12
|
+
customActionsNode: m,
|
|
13
13
|
rowHeight: e,
|
|
14
14
|
customActionsColumnProps: p,
|
|
15
15
|
rowActionsState: C,
|
|
16
|
-
locale:
|
|
17
|
-
})),
|
|
16
|
+
locale: l
|
|
17
|
+
})), s && !n.find((o) => o.id === "show-full-text") && n.unshift(A(t, e)), f && !s && !n.find((o) => o.id === "expand-column-id") && n.unshift(h(t, e)), c && !n.find((o) => o.id === "dnd-handle") && n.unshift(_(a, e)), u && !n.find((o) => o.id === "select") && n.unshift(D(t, e, l)), n;
|
|
18
18
|
};
|
|
19
19
|
export {
|
|
20
20
|
T as injectColumns
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useEffect as a, useMemo as c } from "react";
|
|
2
|
+
var g = ":column-sizing", n = (t) => {
|
|
3
|
+
if (t)
|
|
4
|
+
try {
|
|
5
|
+
const r = JSON.parse(t);
|
|
6
|
+
return !r || typeof r != "object" || Array.isArray(r) ? void 0 : Object.fromEntries(Object.entries(r).filter((e) => typeof e[1] == "number" && Number.isFinite(e[1]) && e[1] > 0));
|
|
7
|
+
} catch {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
}, s = (t) => t ? `${t}${g}` : void 0, l = (t) => c(() => {
|
|
11
|
+
const r = s(t);
|
|
12
|
+
if (!(!r || !t))
|
|
13
|
+
try {
|
|
14
|
+
return n(localStorage.getItem(r)) ?? n(localStorage.getItem(t));
|
|
15
|
+
} catch {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
}, [t]), u = (t, r) => {
|
|
19
|
+
const e = s(r), i = t.getState().columnSizing, o = !!t.getState().columnSizingInfo.isResizingColumn;
|
|
20
|
+
a(() => {
|
|
21
|
+
if (!(!e || o))
|
|
22
|
+
try {
|
|
23
|
+
localStorage.setItem(e, JSON.stringify(i));
|
|
24
|
+
} catch {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
}, [
|
|
28
|
+
i,
|
|
29
|
+
o,
|
|
30
|
+
e
|
|
31
|
+
]);
|
|
32
|
+
};
|
|
33
|
+
export {
|
|
34
|
+
u as usePersistColumnSizing,
|
|
35
|
+
l as usePersistedColumnSizing
|
|
36
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import "../types.js";
|
|
2
2
|
import { useVirtualizer as d } from "@tanstack/react-virtual";
|
|
3
|
-
|
|
3
|
+
var m = 20;
|
|
4
|
+
function f({ table: o, scrollRef: r, isMobileView: l }) {
|
|
4
5
|
const i = o.getVisibleLeafColumns().filter((e) => !e.columnDef.fixedLeft && !e.columnDef.fixedRight && e.id !== "actions"), n = d({
|
|
5
6
|
count: i.length,
|
|
6
7
|
getScrollElement: () => r?.current ?? null,
|
|
@@ -8,7 +9,7 @@ function c({ table: o, scrollRef: r, isMobileView: l }) {
|
|
|
8
9
|
horizontal: !0,
|
|
9
10
|
overscan: 2
|
|
10
11
|
});
|
|
11
|
-
if (l) return { columnWindow: {
|
|
12
|
+
if (l || i.length <= m) return { columnWindow: {
|
|
12
13
|
indexes: i.map((e, u) => u),
|
|
13
14
|
paddingLeft: 0,
|
|
14
15
|
paddingRight: 0
|
|
@@ -21,5 +22,5 @@ function c({ table: o, scrollRef: r, isMobileView: l }) {
|
|
|
21
22
|
} };
|
|
22
23
|
}
|
|
23
24
|
export {
|
|
24
|
-
|
|
25
|
+
f as useColumnVirtualizer
|
|
25
26
|
};
|
|
@@ -1,59 +1,67 @@
|
|
|
1
|
-
import { SELECT_COLUMN_ID as
|
|
2
|
-
import { ExpandedRowsFeature as
|
|
3
|
-
import { FocusedRowsFeature as
|
|
4
|
-
import { OrderColumnsFeature as
|
|
5
|
-
import { usePersistColumnOrder as
|
|
6
|
-
import { usePersistedColumnOrder as
|
|
7
|
-
import { getPersistedPageSizeKey as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { SELECT_COLUMN_ID as y } from "../types.js";
|
|
2
|
+
import { ExpandedRowsFeature as E } from "../custom-features/expand-rows/ExpandRowsFeature.js";
|
|
3
|
+
import { FocusedRowsFeature as I } from "../custom-features/focus-rows/FocusRowsFeature.js";
|
|
4
|
+
import { OrderColumnsFeature as b } from "../custom-features/order-columns/OrderColumnsFeature.js";
|
|
5
|
+
import { usePersistColumnOrder as F } from "../custom-features/order-columns/usePersistColumnOrder.js";
|
|
6
|
+
import { usePersistedColumnOrder as O } from "../custom-features/order-columns/usePersistedColumnOrder.js";
|
|
7
|
+
import { getPersistedPageSizeKey as _, usePersistedPageSize as x } from "./usePersistedPageSize.js";
|
|
8
|
+
import { usePersistColumnSizing as v, usePersistedColumnSizing as K } from "./useColumnSizingPersistence.js";
|
|
9
|
+
import { RowSelectionTooltipFeature as L } from "../custom-features/row-selection-tooltip/RowSelectionTooltipFeature.js";
|
|
10
|
+
import { useEffect as R, useRef as T } from "react";
|
|
11
|
+
import { getCoreRowModel as N, getExpandedRowModel as U, getFilteredRowModel as h, getPaginationRowModel as A, getSortedRowModel as D, useReactTable as V } from "@tanstack/react-table";
|
|
12
|
+
var Z = 100, ee = (n) => {
|
|
13
|
+
const { columns: p, data: z, initialState: a, pageSize: C, enableRowSelection: w, tableInstanceRef: d, locale: M, persistColumnOrderKey: u, uniqueKey: l, defaultColumn: g, ...m } = n, P = O(u), S = n.enableColumnResizing ? l : void 0, c = K(S), t = x(l) ?? C ?? 50, e = V({
|
|
13
14
|
_features: [
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
E,
|
|
16
|
+
I,
|
|
17
|
+
b,
|
|
18
|
+
L
|
|
18
19
|
],
|
|
19
|
-
columns:
|
|
20
|
-
data:
|
|
21
|
-
meta: { locale:
|
|
20
|
+
columns: p,
|
|
21
|
+
data: z,
|
|
22
|
+
meta: { locale: M ?? "en" },
|
|
22
23
|
initialState: {
|
|
23
24
|
pagination: {
|
|
24
25
|
pageIndex: 0,
|
|
25
26
|
pageSize: t
|
|
26
27
|
},
|
|
27
28
|
columnVisibility: {
|
|
28
|
-
...
|
|
29
|
-
[
|
|
29
|
+
...a?.columnVisibility,
|
|
30
|
+
[y]: !1
|
|
30
31
|
},
|
|
31
|
-
columnOrder:
|
|
32
|
-
...
|
|
32
|
+
columnOrder: P,
|
|
33
|
+
...a,
|
|
34
|
+
...c && { columnSizing: {
|
|
35
|
+
...a?.columnSizing,
|
|
36
|
+
...c
|
|
37
|
+
} }
|
|
33
38
|
},
|
|
34
|
-
enableRowSelection:
|
|
35
|
-
getCoreRowModel:
|
|
36
|
-
getExpandedRowModel:
|
|
37
|
-
getFilteredRowModel:
|
|
38
|
-
getSortedRowModel:
|
|
39
|
-
getPaginationRowModel:
|
|
40
|
-
getRowId:
|
|
41
|
-
defaultColumn: n.
|
|
42
|
-
|
|
39
|
+
enableRowSelection: w,
|
|
40
|
+
getCoreRowModel: N(),
|
|
41
|
+
getExpandedRowModel: U(),
|
|
42
|
+
getFilteredRowModel: h(),
|
|
43
|
+
getSortedRowModel: D(),
|
|
44
|
+
getPaginationRowModel: A(),
|
|
45
|
+
getRowId: m.getRowId ?? ((r, j, f) => f ? [f.id, r.id].join(".") : r.id.toString()),
|
|
46
|
+
defaultColumn: n.enableColumnResizing ? {
|
|
47
|
+
minSize: Z,
|
|
48
|
+
...g
|
|
49
|
+
} : g,
|
|
50
|
+
...m
|
|
43
51
|
});
|
|
44
|
-
|
|
45
|
-
const o =
|
|
46
|
-
return
|
|
47
|
-
|
|
52
|
+
d && (d.current = e), F(e, u), v(e, S);
|
|
53
|
+
const o = _(l), i = e.getState().pagination?.pageSize, s = T(void 0);
|
|
54
|
+
return R(() => {
|
|
55
|
+
s.current = void 0, e.getState().pagination?.pageSize !== t && (e.setPageIndex(0), e.setPageSize(t));
|
|
48
56
|
}, [
|
|
49
57
|
t,
|
|
50
58
|
o,
|
|
51
59
|
e
|
|
52
|
-
]),
|
|
60
|
+
]), R(() => {
|
|
53
61
|
if (!(!o || i == null)) {
|
|
54
|
-
if (
|
|
62
|
+
if (s.current !== o) {
|
|
55
63
|
if (i !== t) return;
|
|
56
|
-
|
|
64
|
+
s.current = o;
|
|
57
65
|
}
|
|
58
66
|
try {
|
|
59
67
|
localStorage.setItem(o, JSON.stringify(i));
|
|
@@ -68,5 +76,5 @@ var H = (n) => {
|
|
|
68
76
|
]), { table: e };
|
|
69
77
|
};
|
|
70
78
|
export {
|
|
71
|
-
|
|
79
|
+
ee as useStyledTable
|
|
72
80
|
};
|