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