asma-ui-core 3.131.0 → 3.132.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/custom-features/order-columns/columnLayout.d.ts +37 -4
- package/dist/src/table/custom-features/order-columns/types.d.ts +23 -3
- package/dist/src/table/helpers/columnIds.d.ts +4 -0
- package/dist/src/table/helpers/headerControls.d.ts +15 -0
- package/dist/src/table/helpers/tableStorage.d.ts +2 -1
- package/dist/src/table/hooks/useColumnLayoutPersistence.d.ts +77 -0
- package/dist/src/table/hooks/useColumnLayoutPersistence.test.d.ts +1 -0
- package/dist/src/table/hooks/useToggleMenuVisibility.hook.d.ts +2 -2
- package/dist/src/table/types.d.ts +42 -0
- 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 +5 -5
- package/dist/table/custom-features/order-columns/columnLayout.js +26 -7
- package/dist/table/helpers/columnIds.js +12 -11
- package/dist/table/helpers/headerControls.js +8 -0
- package/dist/table/helpers/tableStorage.js +11 -10
- package/dist/table/hooks/useColumnLayoutPersistence.js +139 -0
- package/dist/table/hooks/useStyledTable.js +134 -94
- package/dist/table/hooks/useToggleMenuVisibility.hook.js +24 -23
- package/package.json +1 -1
|
@@ -1,118 +1,158 @@
|
|
|
1
|
-
import { SELECT_COLUMN_ID as
|
|
2
|
-
import { ExpandedRowsFeature as
|
|
3
|
-
import { FocusedRowsFeature as
|
|
4
|
-
import { OrderColumnsFeature as
|
|
5
|
-
import { tableStorage as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
import { SELECT_COLUMN_ID as T } from "../types.js";
|
|
2
|
+
import { ExpandedRowsFeature as q } from "../custom-features/expand-rows/ExpandRowsFeature.js";
|
|
3
|
+
import { FocusedRowsFeature as A } from "../custom-features/focus-rows/FocusRowsFeature.js";
|
|
4
|
+
import { OrderColumnsFeature as J } from "../custom-features/order-columns/OrderColumnsFeature.js";
|
|
5
|
+
import { tableStorage as x } from "../helpers/tableStorage.js";
|
|
6
|
+
import { normalizeDefaultColumnOrder as Y } from "../custom-features/order-columns/columnLayout.js";
|
|
7
|
+
import { usePersistColumnOrder as Z } from "../custom-features/order-columns/usePersistColumnOrder.js";
|
|
8
|
+
import { usePersistedColumnOrder as k } from "../custom-features/order-columns/usePersistedColumnOrder.js";
|
|
9
|
+
import { getPersistedPageSizeKey as Q, usePersistedPageSize as X } from "./usePersistedPageSize.js";
|
|
10
|
+
import { columnSizingSignature as $, getColumnSizingStorageKey as ee, serializeColumnSizing as te, usePersistedColumnSizing as ie } from "./useColumnSizingPersistence.js";
|
|
11
|
+
import { getSortingStorageKey as oe, readSortingFromStorage as ne, serializeSorting as re, sortingSignature as le } from "./usePersistedSorting.js";
|
|
12
|
+
import { usePersistedStateWriter as F } from "./usePersistedStateWriter.js";
|
|
13
|
+
import { useColumnLayoutReconcile as ae, useColumnLayoutWriter as se, useSavedColumnLayout as ue } from "./useColumnLayoutPersistence.js";
|
|
14
|
+
import { RowSelectionTooltipFeature as de } from "../custom-features/row-selection-tooltip/RowSelectionTooltipFeature.js";
|
|
15
|
+
import { getLeafColumnInfos as ge } from "../helpers/columnIds.js";
|
|
16
|
+
import { resolveColumnSizingDefaults as me } from "../helpers/columnSizingDefaults.js";
|
|
17
|
+
import { useEffect as K, useMemo as E, useRef as Se } from "react";
|
|
18
|
+
import { getCoreRowModel as ce, getExpandedRowModel as fe, getFilteredRowModel as ye, getPaginationRowModel as Ce, getSortedRowModel as be, useReactTable as pe } from "@tanstack/react-table";
|
|
19
|
+
var ve = [], ze = {}, Re = [], Oe = { [T]: !1 }, Be = (y) => {
|
|
20
|
+
const { columns: C, data: h, initialState: l, pageSize: D, enableRowSelection: U, tableInstanceRef: V, locale: H, persistColumnOrderKey: d, uniqueKey: a, persistSorting: W, persistColumnLayout: B, legacyColumnVisibilityKey: M, defaultColumn: c, ...t } = y, I = l?.sorting ?? ve, b = l?.columnSizing ?? ze, p = y.enableColumnResizing ?? !0, G = y.enableColumnResizing === !0, j = E(() => me(C, {
|
|
21
|
+
defaultColumn: c,
|
|
22
|
+
enableSorting: t.enableSorting,
|
|
23
|
+
canResize: p
|
|
22
24
|
}), [
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
]),
|
|
28
|
-
defaultColumn:
|
|
29
|
-
enableSorting:
|
|
30
|
-
enableMultiSort:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
C,
|
|
26
|
+
c,
|
|
27
|
+
t.enableSorting,
|
|
28
|
+
p
|
|
29
|
+
]), v = ge(C, {
|
|
30
|
+
defaultColumn: c,
|
|
31
|
+
enableSorting: t.enableSorting,
|
|
32
|
+
enableMultiSort: t.enableMultiSort,
|
|
33
|
+
enableHiding: t.enableHiding
|
|
34
|
+
}), o = B === !0, w = v.map((i) => i.id), r = Y(l?.columnOrder ?? Re, w), g = l?.columnVisibility ?? Oe, n = ue({
|
|
35
|
+
enabled: o,
|
|
36
|
+
uniqueKey: a,
|
|
37
|
+
legacyOrderKey: d,
|
|
38
|
+
legacyVisibilityKey: M,
|
|
39
|
+
columns: v,
|
|
40
|
+
defaultOrder: r,
|
|
41
|
+
defaultVisibility: g
|
|
42
|
+
}), L = k(o ? void 0 : d), P = G ? a : void 0, _ = ee(P), z = ie(P, b), m = W ? oe(a) : void 0, R = E(() => m ? ne(a, {
|
|
43
|
+
sortableColumns: v.filter((i) => i.canSort),
|
|
44
|
+
maxMultiSortColCount: t.maxMultiSortColCount
|
|
45
|
+
}) : void 0, [m]), s = X(a) ?? D ?? 50, e = pe({
|
|
35
46
|
_features: [
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
47
|
+
q,
|
|
48
|
+
A,
|
|
49
|
+
J,
|
|
50
|
+
de
|
|
40
51
|
],
|
|
41
|
-
columns:
|
|
42
|
-
data:
|
|
43
|
-
meta: {
|
|
52
|
+
columns: j,
|
|
53
|
+
data: h,
|
|
54
|
+
meta: {
|
|
55
|
+
locale: H ?? "en",
|
|
56
|
+
hideHeader: !!t.hideHeader
|
|
57
|
+
},
|
|
44
58
|
initialState: {
|
|
45
59
|
pagination: {
|
|
46
60
|
pageIndex: 0,
|
|
47
|
-
pageSize:
|
|
61
|
+
pageSize: s
|
|
48
62
|
},
|
|
49
63
|
columnVisibility: {
|
|
50
|
-
...
|
|
51
|
-
[
|
|
64
|
+
...l?.columnVisibility,
|
|
65
|
+
[T]: !1
|
|
52
66
|
},
|
|
53
|
-
...
|
|
54
|
-
...
|
|
55
|
-
...
|
|
56
|
-
...
|
|
67
|
+
...L && { columnOrder: L },
|
|
68
|
+
...l,
|
|
69
|
+
...o && r.length > 0 && { columnOrder: r },
|
|
70
|
+
...n.order && { columnOrder: n.order },
|
|
71
|
+
...n.visibility && { columnVisibility: n.visibility },
|
|
72
|
+
...z && { columnSizing: z },
|
|
73
|
+
...R !== void 0 && { sorting: R }
|
|
57
74
|
},
|
|
58
|
-
enableRowSelection:
|
|
59
|
-
getCoreRowModel:
|
|
60
|
-
getExpandedRowModel:
|
|
61
|
-
getFilteredRowModel:
|
|
62
|
-
getSortedRowModel:
|
|
63
|
-
getPaginationRowModel:
|
|
64
|
-
getRowId:
|
|
65
|
-
defaultColumn:
|
|
66
|
-
...
|
|
67
|
-
enableColumnResizing:
|
|
75
|
+
enableRowSelection: U,
|
|
76
|
+
getCoreRowModel: ce(),
|
|
77
|
+
getExpandedRowModel: fe(),
|
|
78
|
+
getFilteredRowModel: ye(),
|
|
79
|
+
getSortedRowModel: be(),
|
|
80
|
+
getPaginationRowModel: Ce(),
|
|
81
|
+
getRowId: t.getRowId ?? ((i, N, S) => S ? [S.id, i.id].join(".") : i.id.toString()),
|
|
82
|
+
defaultColumn: c,
|
|
83
|
+
...t,
|
|
84
|
+
enableColumnResizing: p
|
|
68
85
|
});
|
|
69
|
-
|
|
70
|
-
|
|
86
|
+
V && (V.current = e), Z(e, o ? void 0 : d), se(e, {
|
|
87
|
+
saved: n,
|
|
88
|
+
reconciling: ae(e, {
|
|
89
|
+
enabled: o,
|
|
90
|
+
definitionIds: w,
|
|
91
|
+
defaultOrder: r,
|
|
92
|
+
defaultVisibility: g,
|
|
93
|
+
controlledVisibility: t.state?.columnVisibility !== void 0
|
|
94
|
+
}),
|
|
95
|
+
defaultOrder: r,
|
|
96
|
+
defaultVisibility: g,
|
|
97
|
+
controlledVisibility: t.state?.columnVisibility !== void 0
|
|
98
|
+
}), K(() => {
|
|
99
|
+
}, [o, t.state?.columnVisibility !== void 0 || t.onColumnVisibilityChange !== void 0]), F({
|
|
100
|
+
storageKey: m,
|
|
71
101
|
state: e.getState().sorting,
|
|
72
|
-
defaultValue:
|
|
73
|
-
saved:
|
|
74
|
-
controlled:
|
|
75
|
-
toSignature:
|
|
76
|
-
toStorage:
|
|
77
|
-
applyState: (
|
|
78
|
-
}),
|
|
79
|
-
storageKey:
|
|
102
|
+
defaultValue: I,
|
|
103
|
+
saved: R,
|
|
104
|
+
controlled: t.state?.sorting !== void 0,
|
|
105
|
+
toSignature: le,
|
|
106
|
+
toStorage: re,
|
|
107
|
+
applyState: (i) => e.setSorting(i)
|
|
108
|
+
}), F({
|
|
109
|
+
storageKey: _,
|
|
80
110
|
state: e.getState().columnSizing,
|
|
81
|
-
defaultValue:
|
|
82
|
-
saved:
|
|
111
|
+
defaultValue: b,
|
|
112
|
+
saved: z,
|
|
83
113
|
settled: !e.getState().columnSizingInfo.isResizingColumn,
|
|
84
|
-
toSignature:
|
|
85
|
-
toStorage:
|
|
86
|
-
applyState: (
|
|
87
|
-
}), e.
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
114
|
+
toSignature: $,
|
|
115
|
+
toStorage: te,
|
|
116
|
+
applyState: (i) => e.setColumnSizing(i)
|
|
117
|
+
}), e.columnLayoutDefaults = o ? {
|
|
118
|
+
order: r,
|
|
119
|
+
visibility: g
|
|
120
|
+
} : void 0, e.resetColumnSettings = () => {
|
|
121
|
+
e.setColumnOrder(o ? r : []), e.setColumnSizing(b), o && e.setColumnVisibility(g), m && e.setSorting(I);
|
|
122
|
+
const i = o && n.orderKey !== void 0 ? [
|
|
123
|
+
n.orderKey,
|
|
124
|
+
n.visibilityKey,
|
|
125
|
+
d,
|
|
126
|
+
M
|
|
127
|
+
] : [], N = o ? void 0 : d;
|
|
128
|
+
for (const S of [
|
|
129
|
+
m,
|
|
130
|
+
_,
|
|
131
|
+
N,
|
|
132
|
+
...i
|
|
133
|
+
]) S && x.remove(S);
|
|
94
134
|
};
|
|
95
|
-
const
|
|
96
|
-
return
|
|
97
|
-
|
|
135
|
+
const u = Q(a), f = e.getState().pagination?.pageSize, O = Se(void 0);
|
|
136
|
+
return K(() => {
|
|
137
|
+
O.current = void 0, e.getState().pagination?.pageSize !== s && (e.setPageIndex(0), e.setPageSize(s));
|
|
98
138
|
}, [
|
|
99
|
-
|
|
100
|
-
|
|
139
|
+
s,
|
|
140
|
+
u,
|
|
101
141
|
e
|
|
102
|
-
]),
|
|
103
|
-
if (!(!
|
|
104
|
-
if (
|
|
105
|
-
if (
|
|
106
|
-
|
|
142
|
+
]), K(() => {
|
|
143
|
+
if (!(!u || f == null)) {
|
|
144
|
+
if (O.current !== u) {
|
|
145
|
+
if (f !== s) return;
|
|
146
|
+
O.current = u;
|
|
107
147
|
}
|
|
108
|
-
|
|
148
|
+
x.set(u, JSON.stringify(f));
|
|
109
149
|
}
|
|
110
150
|
}, [
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
151
|
+
f,
|
|
152
|
+
s,
|
|
153
|
+
u
|
|
114
154
|
]), { table: e };
|
|
115
155
|
};
|
|
116
156
|
export {
|
|
117
|
-
|
|
157
|
+
Be as useStyledTable
|
|
118
158
|
};
|
|
@@ -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
|
};
|