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