asma-ui-core 3.131.1 → 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/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/types.d.ts +30 -0
- package/dist/table/custom-features/order-columns/columnLayout.js +26 -7
- package/dist/table/helpers/columnIds.js +12 -11
- package/dist/table/helpers/tableStorage.js +11 -10
- package/dist/table/hooks/useColumnLayoutPersistence.js +139 -0
- package/dist/table/hooks/useStyledTable.js +132 -95
- package/package.json +1 -1
|
@@ -1,121 +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:
|
|
52
|
+
columns: j,
|
|
53
|
+
data: h,
|
|
43
54
|
meta: {
|
|
44
|
-
locale:
|
|
45
|
-
hideHeader: !!
|
|
55
|
+
locale: H ?? "en",
|
|
56
|
+
hideHeader: !!t.hideHeader
|
|
46
57
|
},
|
|
47
58
|
initialState: {
|
|
48
59
|
pagination: {
|
|
49
60
|
pageIndex: 0,
|
|
50
|
-
pageSize:
|
|
61
|
+
pageSize: s
|
|
51
62
|
},
|
|
52
63
|
columnVisibility: {
|
|
53
|
-
...
|
|
54
|
-
[
|
|
64
|
+
...l?.columnVisibility,
|
|
65
|
+
[T]: !1
|
|
55
66
|
},
|
|
56
|
-
...
|
|
57
|
-
...
|
|
58
|
-
...
|
|
59
|
-
...
|
|
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 }
|
|
60
74
|
},
|
|
61
|
-
enableRowSelection:
|
|
62
|
-
getCoreRowModel:
|
|
63
|
-
getExpandedRowModel:
|
|
64
|
-
getFilteredRowModel:
|
|
65
|
-
getSortedRowModel:
|
|
66
|
-
getPaginationRowModel:
|
|
67
|
-
getRowId:
|
|
68
|
-
defaultColumn:
|
|
69
|
-
...
|
|
70
|
-
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
|
|
71
85
|
});
|
|
72
|
-
|
|
73
|
-
|
|
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,
|
|
74
101
|
state: e.getState().sorting,
|
|
75
|
-
defaultValue:
|
|
76
|
-
saved:
|
|
77
|
-
controlled:
|
|
78
|
-
toSignature:
|
|
79
|
-
toStorage:
|
|
80
|
-
applyState: (
|
|
81
|
-
}),
|
|
82
|
-
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: _,
|
|
83
110
|
state: e.getState().columnSizing,
|
|
84
|
-
defaultValue:
|
|
85
|
-
saved:
|
|
111
|
+
defaultValue: b,
|
|
112
|
+
saved: z,
|
|
86
113
|
settled: !e.getState().columnSizingInfo.isResizingColumn,
|
|
87
|
-
toSignature:
|
|
88
|
-
toStorage:
|
|
89
|
-
applyState: (
|
|
90
|
-
}), e.
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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);
|
|
97
134
|
};
|
|
98
|
-
const
|
|
99
|
-
return
|
|
100
|
-
|
|
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));
|
|
101
138
|
}, [
|
|
102
|
-
|
|
103
|
-
|
|
139
|
+
s,
|
|
140
|
+
u,
|
|
104
141
|
e
|
|
105
|
-
]),
|
|
106
|
-
if (!(!
|
|
107
|
-
if (
|
|
108
|
-
if (
|
|
109
|
-
|
|
142
|
+
]), K(() => {
|
|
143
|
+
if (!(!u || f == null)) {
|
|
144
|
+
if (O.current !== u) {
|
|
145
|
+
if (f !== s) return;
|
|
146
|
+
O.current = u;
|
|
110
147
|
}
|
|
111
|
-
|
|
148
|
+
x.set(u, JSON.stringify(f));
|
|
112
149
|
}
|
|
113
150
|
}, [
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
151
|
+
f,
|
|
152
|
+
s,
|
|
153
|
+
u
|
|
117
154
|
]), { table: e };
|
|
118
155
|
};
|
|
119
156
|
export {
|
|
120
|
-
|
|
157
|
+
Be as useStyledTable
|
|
121
158
|
};
|