asma-ui-core 3.130.5 → 3.131.1
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/columnSizingDefaults.d.ts +41 -0
- package/dist/src/table/helpers/columnSizingDefaults.test.d.ts +1 -0
- package/dist/src/table/helpers/headerControls.d.ts +15 -0
- package/dist/src/table/hooks/useToggleMenuVisibility.hook.d.ts +2 -2
- package/dist/src/table/types.d.ts +28 -0
- package/dist/table/components/StyledTableIndex.js +1 -1
- package/dist/table/components/TableRow.js +36 -35
- package/dist/table/components/columns/action-column/components/HeaderActionMenu.js +6 -5
- package/dist/table/components/columns/selectColumn.js +8 -8
- package/dist/table/components/table-footer/TableRowCountSelect.js +6 -6
- package/dist/table/components/table-header/TableHeader.js +33 -30
- package/dist/table/components/table-header/TableHeaderCell.js +18 -17
- package/dist/table/helpers/columnSizingDefaults.js +29 -0
- package/dist/table/helpers/headerControls.js +8 -0
- package/dist/table/hooks/useStyledTable.js +80 -69
- package/dist/table/hooks/useToggleMenuVisibility.hook.js +24 -23
- package/package.json +1 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { INTERNAL_COLUMN_IDS as x } from "../types.js";
|
|
2
|
+
import { getLeafColumnInfos as I } from "./columnIds.js";
|
|
3
|
+
var E = 150;
|
|
4
|
+
var g = (n, m) => {
|
|
5
|
+
const { defaultColumn: S, canResize: v } = m, z = (e) => {
|
|
6
|
+
if (e.columns?.length) return {
|
|
7
|
+
...e,
|
|
8
|
+
columns: e.columns.map((u) => z(u))
|
|
9
|
+
};
|
|
10
|
+
const a = I([e], {
|
|
11
|
+
defaultColumn: S,
|
|
12
|
+
enableSorting: m.enableSorting
|
|
13
|
+
})[0];
|
|
14
|
+
if (!a) return e;
|
|
15
|
+
const i = {
|
|
16
|
+
...S,
|
|
17
|
+
...e
|
|
18
|
+
}, l = x.includes(a.id), t = a.canSort && !l, r = t ? (i.size ?? E) + 20 : i.size;
|
|
19
|
+
let o = i.minSize;
|
|
20
|
+
o !== void 0 ? t && (o += 20) : v && (o = l || r === void 0 ? 100 : Math.min(100, r));
|
|
21
|
+
const c = t && i.maxSize !== void 0 ? i.maxSize + 20 : i.maxSize, s = { ...e };
|
|
22
|
+
return r !== i.size && (s.size = r), o !== i.minSize && (s.minSize = o), c !== i.maxSize && (s.maxSize = c), s;
|
|
23
|
+
};
|
|
24
|
+
return n.map(z);
|
|
25
|
+
}, A = (n) => n.maxSize !== void 0 && n.minSize === n.maxSize;
|
|
26
|
+
export {
|
|
27
|
+
A as hasFixedWidth,
|
|
28
|
+
g as resolveColumnSizingDefaults
|
|
29
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
var r = "a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]", a = (t) => t.tabIndex >= 0 && !t.closest("[inert], [hidden]") && t.getClientRects().length > 0 && getComputedStyle(t).visibility !== "hidden", d = (t) => {
|
|
2
|
+
const e = t?.tHead;
|
|
3
|
+
return !e || e.hasAttribute("data-header-hidden") ? [] : Array.from(e.querySelectorAll(r)).filter(a);
|
|
4
|
+
}, i = (t) => d(t).at(-1), o = (t) => Array.from(t?.tBodies ?? []).flatMap((e) => Array.from(e.rows)).find((e) => e.tabIndex === 0);
|
|
5
|
+
export {
|
|
6
|
+
o as getActiveBodyRow,
|
|
7
|
+
i as getLastHeaderControl
|
|
8
|
+
};
|
|
@@ -1,110 +1,121 @@
|
|
|
1
|
-
import { SELECT_COLUMN_ID as
|
|
2
|
-
import { ExpandedRowsFeature as
|
|
3
|
-
import { FocusedRowsFeature as
|
|
4
|
-
import { OrderColumnsFeature as
|
|
1
|
+
import { SELECT_COLUMN_ID as L } from "../types.js";
|
|
2
|
+
import { ExpandedRowsFeature as V } from "../custom-features/expand-rows/ExpandRowsFeature.js";
|
|
3
|
+
import { FocusedRowsFeature as D } from "../custom-features/focus-rows/FocusRowsFeature.js";
|
|
4
|
+
import { OrderColumnsFeature as G } from "../custom-features/order-columns/OrderColumnsFeature.js";
|
|
5
5
|
import { tableStorage as w } from "../helpers/tableStorage.js";
|
|
6
|
-
import { usePersistColumnOrder as
|
|
7
|
-
import { usePersistedColumnOrder as
|
|
8
|
-
import { getPersistedPageSizeKey as
|
|
9
|
-
import { columnSizingSignature as
|
|
10
|
-
import { getSortingStorageKey as
|
|
11
|
-
import { usePersistedStateWriter as
|
|
12
|
-
import { RowSelectionTooltipFeature as
|
|
13
|
-
import { getLeafColumnInfos as
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
6
|
+
import { usePersistColumnOrder as H } from "../custom-features/order-columns/usePersistColumnOrder.js";
|
|
7
|
+
import { usePersistedColumnOrder as U } from "../custom-features/order-columns/usePersistedColumnOrder.js";
|
|
8
|
+
import { getPersistedPageSizeKey as W, usePersistedPageSize as j } from "./usePersistedPageSize.js";
|
|
9
|
+
import { columnSizingSignature as q, getColumnSizingStorageKey as B, serializeColumnSizing as J, usePersistedColumnSizing as Z } from "./useColumnSizingPersistence.js";
|
|
10
|
+
import { getSortingStorageKey as k, readSortingFromStorage as A, serializeSorting as Q, sortingSignature as X } from "./usePersistedSorting.js";
|
|
11
|
+
import { usePersistedStateWriter as K } from "./usePersistedStateWriter.js";
|
|
12
|
+
import { RowSelectionTooltipFeature as Y } from "../custom-features/row-selection-tooltip/RowSelectionTooltipFeature.js";
|
|
13
|
+
import { getLeafColumnInfos as $ } from "../helpers/columnIds.js";
|
|
14
|
+
import { resolveColumnSizingDefaults as ee } from "../helpers/columnSizingDefaults.js";
|
|
15
|
+
import { useEffect as P, useMemo as O, useRef as te } from "react";
|
|
16
|
+
import { getCoreRowModel as oe, getExpandedRowModel as ie, getFilteredRowModel as ne, getPaginationRowModel as re, getSortedRowModel as ae, useReactTable as se } from "@tanstack/react-table";
|
|
17
|
+
var le = [], ge = {}, Oe = (u) => {
|
|
18
|
+
const { columns: S, data: I, initialState: s, pageSize: x, enableRowSelection: F, tableInstanceRef: C, locale: N, persistColumnOrderKey: m, uniqueKey: r, persistSorting: _, defaultColumn: l, ...o } = u, R = s?.sorting ?? le, d = s?.columnSizing ?? ge, c = u.enableColumnResizing ?? !0, E = u.enableColumnResizing === !0, T = O(() => ee(S, {
|
|
19
|
+
defaultColumn: l,
|
|
20
|
+
enableSorting: o.enableSorting,
|
|
21
|
+
canResize: c
|
|
22
|
+
}), [
|
|
23
|
+
S,
|
|
24
|
+
l,
|
|
25
|
+
o.enableSorting,
|
|
26
|
+
c
|
|
27
|
+
]), h = $(S, {
|
|
28
|
+
defaultColumn: l,
|
|
22
29
|
enableSorting: o.enableSorting,
|
|
23
30
|
enableMultiSort: o.enableMultiSort
|
|
24
|
-
}), y =
|
|
25
|
-
sortableColumns:
|
|
31
|
+
}), y = U(m), b = E ? r : void 0, M = B(b), f = Z(b, d), a = _ ? k(r) : void 0, p = O(() => a ? A(r, {
|
|
32
|
+
sortableColumns: h.filter((t) => t.canSort),
|
|
26
33
|
maxMultiSortColCount: o.maxMultiSortColCount
|
|
27
|
-
}) : void 0, [a]), i =
|
|
34
|
+
}) : void 0, [a]), i = j(r) ?? x ?? 50, e = se({
|
|
28
35
|
_features: [
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
36
|
+
V,
|
|
37
|
+
D,
|
|
38
|
+
G,
|
|
39
|
+
Y
|
|
33
40
|
],
|
|
34
|
-
columns:
|
|
35
|
-
data:
|
|
36
|
-
meta: {
|
|
41
|
+
columns: T,
|
|
42
|
+
data: I,
|
|
43
|
+
meta: {
|
|
44
|
+
locale: N ?? "en",
|
|
45
|
+
hideHeader: !!o.hideHeader
|
|
46
|
+
},
|
|
37
47
|
initialState: {
|
|
38
48
|
pagination: {
|
|
39
49
|
pageIndex: 0,
|
|
40
50
|
pageSize: i
|
|
41
51
|
},
|
|
42
52
|
columnVisibility: {
|
|
43
|
-
...
|
|
44
|
-
[
|
|
53
|
+
...s?.columnVisibility,
|
|
54
|
+
[L]: !1
|
|
45
55
|
},
|
|
46
56
|
...y && { columnOrder: y },
|
|
47
|
-
...
|
|
48
|
-
...
|
|
49
|
-
...
|
|
57
|
+
...s,
|
|
58
|
+
...f && { columnSizing: f },
|
|
59
|
+
...p !== void 0 && { sorting: p }
|
|
50
60
|
},
|
|
51
|
-
enableRowSelection:
|
|
52
|
-
getCoreRowModel:
|
|
53
|
-
getExpandedRowModel:
|
|
54
|
-
getFilteredRowModel:
|
|
55
|
-
getSortedRowModel:
|
|
56
|
-
getPaginationRowModel:
|
|
57
|
-
getRowId: o.getRowId ?? ((t,
|
|
58
|
-
defaultColumn:
|
|
59
|
-
...o
|
|
61
|
+
enableRowSelection: F,
|
|
62
|
+
getCoreRowModel: oe(),
|
|
63
|
+
getExpandedRowModel: ie(),
|
|
64
|
+
getFilteredRowModel: ne(),
|
|
65
|
+
getSortedRowModel: ae(),
|
|
66
|
+
getPaginationRowModel: re(),
|
|
67
|
+
getRowId: o.getRowId ?? ((t, ue, v) => v ? [v.id, t.id].join(".") : t.id.toString()),
|
|
68
|
+
defaultColumn: l,
|
|
69
|
+
...o,
|
|
70
|
+
enableColumnResizing: c
|
|
60
71
|
});
|
|
61
|
-
C && (C.current = e),
|
|
72
|
+
C && (C.current = e), H(e, m), K({
|
|
62
73
|
storageKey: a,
|
|
63
74
|
state: e.getState().sorting,
|
|
64
|
-
defaultValue:
|
|
65
|
-
saved:
|
|
75
|
+
defaultValue: R,
|
|
76
|
+
saved: p,
|
|
66
77
|
controlled: o.state?.sorting !== void 0,
|
|
67
|
-
toSignature:
|
|
68
|
-
toStorage:
|
|
78
|
+
toSignature: X,
|
|
79
|
+
toStorage: Q,
|
|
69
80
|
applyState: (t) => e.setSorting(t)
|
|
70
|
-
}),
|
|
71
|
-
storageKey:
|
|
81
|
+
}), K({
|
|
82
|
+
storageKey: M,
|
|
72
83
|
state: e.getState().columnSizing,
|
|
73
|
-
defaultValue:
|
|
74
|
-
saved:
|
|
84
|
+
defaultValue: d,
|
|
85
|
+
saved: f,
|
|
75
86
|
settled: !e.getState().columnSizingInfo.isResizingColumn,
|
|
76
|
-
toSignature:
|
|
77
|
-
toStorage:
|
|
87
|
+
toSignature: q,
|
|
88
|
+
toStorage: J,
|
|
78
89
|
applyState: (t) => e.setColumnSizing(t)
|
|
79
90
|
}), e.resetColumnSettings = () => {
|
|
80
|
-
e.setColumnOrder([]), e.setColumnSizing(
|
|
91
|
+
e.setColumnOrder([]), e.setColumnSizing(d), a && e.setSorting(R);
|
|
81
92
|
for (const t of [
|
|
82
93
|
a,
|
|
83
|
-
|
|
84
|
-
|
|
94
|
+
M,
|
|
95
|
+
m
|
|
85
96
|
]) t && w.remove(t);
|
|
86
97
|
};
|
|
87
|
-
const n =
|
|
88
|
-
return
|
|
89
|
-
|
|
98
|
+
const n = W(r), g = e.getState().pagination?.pageSize, z = te(void 0);
|
|
99
|
+
return P(() => {
|
|
100
|
+
z.current = void 0, e.getState().pagination?.pageSize !== i && (e.setPageIndex(0), e.setPageSize(i));
|
|
90
101
|
}, [
|
|
91
102
|
i,
|
|
92
103
|
n,
|
|
93
104
|
e
|
|
94
|
-
]),
|
|
95
|
-
if (!(!n ||
|
|
96
|
-
if (
|
|
97
|
-
if (
|
|
98
|
-
|
|
105
|
+
]), P(() => {
|
|
106
|
+
if (!(!n || g == null)) {
|
|
107
|
+
if (z.current !== n) {
|
|
108
|
+
if (g !== i) return;
|
|
109
|
+
z.current = n;
|
|
99
110
|
}
|
|
100
|
-
w.set(n, JSON.stringify(
|
|
111
|
+
w.set(n, JSON.stringify(g));
|
|
101
112
|
}
|
|
102
113
|
}, [
|
|
103
|
-
|
|
114
|
+
g,
|
|
104
115
|
i,
|
|
105
116
|
n
|
|
106
117
|
]), { table: e };
|
|
107
118
|
};
|
|
108
119
|
export {
|
|
109
|
-
|
|
120
|
+
Oe as useStyledTable
|
|
110
121
|
};
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { getActiveBodyRow as m } from "../helpers/headerControls.js";
|
|
2
|
+
import { useCallback as c, useRef as D, useState as k } from "react";
|
|
3
|
+
var E = (r) => {
|
|
3
4
|
let a = r?.parentElement;
|
|
4
5
|
for (; a; ) {
|
|
5
|
-
const l = a.querySelector(
|
|
6
|
+
const l = m(a.querySelector("table"));
|
|
6
7
|
if (l)
|
|
7
8
|
return l.focus(), !0;
|
|
8
9
|
a = a.parentElement;
|
|
9
10
|
}
|
|
10
11
|
return !1;
|
|
11
|
-
},
|
|
12
|
-
const [r, a] =
|
|
13
|
-
a(
|
|
12
|
+
}, b = () => {
|
|
13
|
+
const [r, a] = k(null), [l, t] = k(!1), n = c((u) => {
|
|
14
|
+
a(u.currentTarget), t(!0);
|
|
14
15
|
}, []);
|
|
15
16
|
return {
|
|
16
17
|
open: l,
|
|
@@ -18,21 +19,21 @@ var d = (r) => {
|
|
|
18
19
|
handleOpen: n,
|
|
19
20
|
anchorEl: r
|
|
20
21
|
};
|
|
21
|
-
},
|
|
22
|
-
const { open: n, anchorEl:
|
|
23
|
-
|
|
24
|
-
}, [
|
|
25
|
-
r !== 0 &&
|
|
22
|
+
}, g = ({ optionCount: r, selectedIndex: a, onSelect: l, focusTableOnShiftTab: t = !1 }) => {
|
|
23
|
+
const { open: n, anchorEl: u, handleOpen: f, handleClose: y } = b(), i = D(null), [o, w] = k(null), s = c(() => {
|
|
24
|
+
y(), w(null);
|
|
25
|
+
}, [y]), p = c((e) => {
|
|
26
|
+
r !== 0 && w((h) => Math.min(Math.max((h ?? a) + e, 0), r - 1));
|
|
26
27
|
}, [r, a]);
|
|
27
28
|
return {
|
|
28
29
|
open: n,
|
|
29
30
|
handleClose: s,
|
|
30
31
|
handleOpen: f,
|
|
31
|
-
anchorEl:
|
|
32
|
+
anchorEl: u,
|
|
32
33
|
triggerRef: i,
|
|
33
|
-
activeIndex:
|
|
34
|
+
activeIndex: o,
|
|
34
35
|
handleKeyDown: c((e) => {
|
|
35
|
-
if (t && e.key === "Tab" && e.shiftKey &&
|
|
36
|
+
if (t && e.key === "Tab" && e.shiftKey && E(i.current)) {
|
|
36
37
|
e.preventDefault(), s();
|
|
37
38
|
return;
|
|
38
39
|
}
|
|
@@ -41,23 +42,23 @@ var d = (r) => {
|
|
|
41
42
|
"ArrowDown",
|
|
42
43
|
"ArrowUp"
|
|
43
44
|
].includes(e.key)) {
|
|
44
|
-
e.preventDefault(), f(e), e.key !== "Enter" &&
|
|
45
|
+
e.preventDefault(), f(e), e.key !== "Enter" && p(e.key === "ArrowDown" ? 1 : -1);
|
|
45
46
|
return;
|
|
46
47
|
}
|
|
47
48
|
if (n)
|
|
48
49
|
switch (e.key) {
|
|
49
50
|
case "ArrowDown":
|
|
50
51
|
case "ArrowUp":
|
|
51
|
-
e.preventDefault(),
|
|
52
|
+
e.preventDefault(), p(e.key === "ArrowDown" ? 1 : -1);
|
|
52
53
|
break;
|
|
53
54
|
case "Home":
|
|
54
55
|
case "End":
|
|
55
|
-
e.preventDefault(),
|
|
56
|
+
e.preventDefault(), w(e.key === "Home" ? 0 : r ? r - 1 : null);
|
|
56
57
|
break;
|
|
57
58
|
case " ":
|
|
58
59
|
case "Enter":
|
|
59
|
-
if (
|
|
60
|
-
e.preventDefault(), l(
|
|
60
|
+
if (o === null) break;
|
|
61
|
+
e.preventDefault(), l(o), e.key === "Enter" && s();
|
|
61
62
|
break;
|
|
62
63
|
case "Escape":
|
|
63
64
|
e.preventDefault(), s(), i.current?.focus();
|
|
@@ -66,11 +67,11 @@ var d = (r) => {
|
|
|
66
67
|
s();
|
|
67
68
|
}
|
|
68
69
|
}, [
|
|
69
|
-
|
|
70
|
+
o,
|
|
70
71
|
t,
|
|
71
72
|
s,
|
|
72
73
|
f,
|
|
73
|
-
|
|
74
|
+
p,
|
|
74
75
|
l,
|
|
75
76
|
n,
|
|
76
77
|
r
|
|
@@ -78,6 +79,6 @@ var d = (r) => {
|
|
|
78
79
|
};
|
|
79
80
|
};
|
|
80
81
|
export {
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
g as useKeyboardSelectMenu,
|
|
83
|
+
b as useToggleMenuVisibility
|
|
83
84
|
};
|