asma-ui-core 3.130.4 → 3.131.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/components/inputs/full-screen-picker/FullScreenPicker.js +8 -8
- package/dist/components/utils/bottom-sheet/StyledBottomSheet.js +74 -68
- package/dist/components/utils/popover/PopoverSheet.js +69 -67
- package/dist/src/components/utils/bottom-sheet/StyledBottomSheet.d.ts +7 -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/types.d.ts +16 -0
- package/dist/table/components/StyledTableIndex.js +1 -1
- package/dist/table/components/table-header/TableHeaderCell.js +15 -14
- package/dist/table/helpers/columnSizingDefaults.js +29 -0
- package/dist/table/hooks/useStyledTable.js +77 -69
- package/package.json +1 -1
|
@@ -139,6 +139,22 @@ export type StyledTableProps<TData, TCustomData> = {
|
|
|
139
139
|
* makes `uniqueKey` alone enough and retires this prop (follow-up ASMA-8698).
|
|
140
140
|
*/
|
|
141
141
|
persistSorting?: boolean;
|
|
142
|
+
/**
|
|
143
|
+
* Whether the table's columns can be resized with the pointer. **On by default** (ASMA-8597, UX round 4, D15): every data
|
|
144
|
+
* column has a handle, except ui-core's own columns (select, expand, actions, drag handle, show full text), a column that
|
|
145
|
+
* opts out with `enableResizing: false` or has a fixed width (`minSize` equal to `maxSize`), and the last data column,
|
|
146
|
+
* which keeps filling the remaining width (unless the table sets `enableResizing`). `enableColumnResizing={false}` turns
|
|
147
|
+
* resizing off for the table.
|
|
148
|
+
*
|
|
149
|
+
* Saving the widths is a separate opt-in (D17): widths are read and written under `${uniqueKey}:column-sizing` only when
|
|
150
|
+
* a table sets `enableColumnResizing` itself, as `true`. A table that gets resizing from the default resizes in memory only.
|
|
151
|
+
* Give it a per-user `uniqueKey` (`getTableSettingsKey` of asma-core-helpers) and write `enableColumnResizing` to save.
|
|
152
|
+
*
|
|
153
|
+
* A column without a `minSize` gets the smaller of 100 px and its default width as its minimum. Every sortable data column
|
|
154
|
+
* is 20 px wider by default (so its sort triangle fits), and so are its `minSize` and `maxSize` when set; widths a user
|
|
155
|
+
* saved and the app's `initialState.columnSizing` are applied as given.
|
|
156
|
+
*/
|
|
157
|
+
enableColumnResizing?: boolean;
|
|
142
158
|
} & Omit<TTableOptions<TData>, 'getCoreRowModel' | 'getExpandedRowModel' | 'getFilteredRowModel' | 'getSortedRowModel'> & TFooter<TData>;
|
|
143
159
|
export declare const SELECT_COLUMN_ID = "select";
|
|
144
160
|
export declare const EXPAND_COLUMN_ID = "expand-column-id";
|
|
@@ -106,7 +106,7 @@ var Ve = (l) => {
|
|
|
106
106
|
children: [/* @__PURE__ */ t(se, {
|
|
107
107
|
table: a,
|
|
108
108
|
styledTableProps: o,
|
|
109
|
-
tableCanResize:
|
|
109
|
+
tableCanResize: o.enableColumnResizing ?? !0,
|
|
110
110
|
tableWidth: null,
|
|
111
111
|
columnWindow: j
|
|
112
112
|
}), /* @__PURE__ */ t(ie, {
|
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
import { ACTIONS_COLUMN_ID as D, INTERNAL_COLUMN_IDS as R } from "../../types.js";
|
|
2
2
|
import { useRootContext as L } from "../../context/RootContext.js";
|
|
3
|
+
import { hasFixedWidth as A } from "../../helpers/columnSizingDefaults.js";
|
|
3
4
|
import e from "../StyledTable.module.js";
|
|
4
|
-
import { SortIndicator as
|
|
5
|
-
import { getTableHeaderStyle as
|
|
6
|
-
import { getSortPreview as
|
|
5
|
+
import { SortIndicator as O } from "./SortIndicator.js";
|
|
6
|
+
import { getTableHeaderStyle as E } from "../../helpers/getTableHeaderStyle.js";
|
|
7
|
+
import { getSortPreview as M } from "../../helpers/sortPreview.js";
|
|
7
8
|
import _ from "clsx";
|
|
8
9
|
import { useMemo as c } from "react";
|
|
9
|
-
import { jsx as l, jsxs as
|
|
10
|
-
import { flexRender as
|
|
11
|
-
function
|
|
12
|
-
const { hideHeader: r = !1, enableResizing: m = !1, actions: I, customActionsNode: T } = z, { isResizing: a, enableResizingFlag: u, disableResizingFlag: d } = L(), g = o.column.columnDef.fixedLeft, f = !!o.column.columnDef.fixedRight, p = o.column.id === D,
|
|
10
|
+
import { jsx as l, jsxs as k } from "react/jsx-runtime";
|
|
11
|
+
import { flexRender as B } from "@tanstack/react-table";
|
|
12
|
+
function Z({ styledTableProps: z, header: o, tableCanResize: b = !1, left: N, right: v, tableWidth: H }) {
|
|
13
|
+
const { hideHeader: r = !1, enableResizing: m = !1, actions: I, customActionsNode: T } = z, { isResizing: a, enableResizingFlag: u, disableResizingFlag: d } = L(), g = o.column.columnDef.fixedLeft, f = !!o.column.columnDef.fixedRight, p = o.column.id === D, h = !!I || !!T, S = c(() => o.headerGroup.headers.some((t) => t.id === D), [o.headerGroup.headers]), w = c(() => o.headerGroup.headers.some((t) => !!t.column.columnDef.fixedRight), [o.headerGroup.headers]), y = c(() => o.headerGroup.headers[o.headerGroup.headers.length - (S ? 2 : 1)], [o.headerGroup.headers, S]), n = o.column.getCanSort(), s = o.column.getIsSorted(), x = o.getContext().table.getState().sorting, F = M({
|
|
13
14
|
sorted: s,
|
|
14
15
|
firstDirection: o.column.getFirstSortDir(),
|
|
15
16
|
nextOrder: o.column.getNextSortingOrder(),
|
|
16
17
|
isLastSortEntry: x[x.length - 1]?.id === o.column.id
|
|
17
|
-
}), G = n ? s === "asc" ? "ascending" : s === "desc" ? "descending" : "none" : void 0, C = b && (m ? !0 : o.id !==
|
|
18
|
+
}), G = n ? s === "asc" ? "ascending" : s === "desc" ? "descending" : "none" : void 0, C = b && (m ? !0 : o.id !== y?.id) && o.column.getCanResize() && !A(o.column.columnDef) && !R.includes(o.column.id);
|
|
18
19
|
return /* @__PURE__ */ l("th", {
|
|
19
20
|
colSpan: o.colSpan,
|
|
20
21
|
"aria-sort": G,
|
|
21
|
-
className: _(e["t-cell"], !R.includes(o.column.id) && o.column.getSize() > 64 && e["data-cell"], o.column.id === "select" && e["select-cell"], r && e["hide-header"], p && e["t-cell__actions"], p && (!
|
|
22
|
+
className: _(e["t-cell"], !R.includes(o.column.id) && o.column.getSize() > 64 && e["data-cell"], o.column.id === "select" && e["select-cell"], r && e["hide-header"], p && e["t-cell__actions"], p && (!h || w) && e["t-cell__actions--no-shadow"], g && e["t-cell__fixed"], f && e["t-cell__fixed-right"]),
|
|
22
23
|
style: {
|
|
23
|
-
...
|
|
24
|
+
...E({
|
|
24
25
|
enableResizing: m,
|
|
25
26
|
header: o,
|
|
26
27
|
tableWidth: H
|
|
@@ -28,7 +29,7 @@ function X({ styledTableProps: z, header: o, tableCanResize: b = !1, left: N, ri
|
|
|
28
29
|
...g && { left: N },
|
|
29
30
|
...f && { right: v }
|
|
30
31
|
},
|
|
31
|
-
children: /* @__PURE__ */
|
|
32
|
+
children: /* @__PURE__ */ k("div", {
|
|
32
33
|
className: _("flex items-center justify-start", r ? e["hide-table-header"] : e["show-table-header"], n && e["sortable-column"], C && e["has-resize-zone"], o.column.columnDef.className),
|
|
33
34
|
role: n ? "button" : void 0,
|
|
34
35
|
tabIndex: n ? 0 : void 0,
|
|
@@ -45,9 +46,9 @@ function X({ styledTableProps: z, header: o, tableCanResize: b = !1, left: N, ri
|
|
|
45
46
|
children: [
|
|
46
47
|
/* @__PURE__ */ l("div", {
|
|
47
48
|
className: e["header-content"],
|
|
48
|
-
children:
|
|
49
|
+
children: B(o.column.columnDef.header, o.getContext())
|
|
49
50
|
}),
|
|
50
|
-
n && /* @__PURE__ */ l(
|
|
51
|
+
n && /* @__PURE__ */ l(O, {
|
|
51
52
|
sorted: s,
|
|
52
53
|
firstDirection: o.column.getFirstSortDir(),
|
|
53
54
|
preview: F
|
|
@@ -67,5 +68,5 @@ function X({ styledTableProps: z, header: o, tableCanResize: b = !1, left: N, ri
|
|
|
67
68
|
}, o.id);
|
|
68
69
|
}
|
|
69
70
|
export {
|
|
70
|
-
|
|
71
|
+
Z as TableHeaderCell
|
|
71
72
|
};
|
|
@@ -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
|
+
};
|
|
@@ -1,110 +1,118 @@
|
|
|
1
|
-
import { SELECT_COLUMN_ID as
|
|
2
|
-
import { ExpandedRowsFeature as
|
|
3
|
-
import { FocusedRowsFeature as
|
|
4
|
-
import { OrderColumnsFeature as
|
|
1
|
+
import { SELECT_COLUMN_ID as V } from "../types.js";
|
|
2
|
+
import { ExpandedRowsFeature as h } 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 B, readSortingFromStorage 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 U } from "../custom-features/order-columns/usePersistColumnOrder.js";
|
|
7
|
+
import { usePersistedColumnOrder as W } from "../custom-features/order-columns/usePersistedColumnOrder.js";
|
|
8
|
+
import { getPersistedPageSizeKey as j, usePersistedPageSize as q } from "./usePersistedPageSize.js";
|
|
9
|
+
import { columnSizingSignature as J, getColumnSizingStorageKey as Z, serializeColumnSizing as k, usePersistedColumnSizing as A } from "./useColumnSizingPersistence.js";
|
|
10
|
+
import { getSortingStorageKey as B, readSortingFromStorage as H, 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
|
+
]), L = $(S, {
|
|
28
|
+
defaultColumn: l,
|
|
22
29
|
enableSorting: o.enableSorting,
|
|
23
30
|
enableMultiSort: o.enableMultiSort
|
|
24
|
-
}), y =
|
|
25
|
-
sortableColumns:
|
|
31
|
+
}), y = W(m), b = E ? r : void 0, M = Z(b), f = A(b, d), a = _ ? B(r) : void 0, p = O(() => a ? H(r, {
|
|
32
|
+
sortableColumns: L.filter((t) => t.canSort),
|
|
26
33
|
maxMultiSortColCount: o.maxMultiSortColCount
|
|
27
|
-
}) : void 0, [a]), i =
|
|
34
|
+
}) : void 0, [a]), i = q(r) ?? x ?? 50, e = se({
|
|
28
35
|
_features: [
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
36
|
+
h,
|
|
37
|
+
D,
|
|
38
|
+
G,
|
|
39
|
+
Y
|
|
33
40
|
],
|
|
34
|
-
columns:
|
|
35
|
-
data:
|
|
36
|
-
meta: { locale:
|
|
41
|
+
columns: T,
|
|
42
|
+
data: I,
|
|
43
|
+
meta: { locale: N ?? "en" },
|
|
37
44
|
initialState: {
|
|
38
45
|
pagination: {
|
|
39
46
|
pageIndex: 0,
|
|
40
47
|
pageSize: i
|
|
41
48
|
},
|
|
42
49
|
columnVisibility: {
|
|
43
|
-
...
|
|
44
|
-
[
|
|
50
|
+
...s?.columnVisibility,
|
|
51
|
+
[V]: !1
|
|
45
52
|
},
|
|
46
53
|
...y && { columnOrder: y },
|
|
47
|
-
...
|
|
48
|
-
...
|
|
49
|
-
...
|
|
54
|
+
...s,
|
|
55
|
+
...f && { columnSizing: f },
|
|
56
|
+
...p !== void 0 && { sorting: p }
|
|
50
57
|
},
|
|
51
|
-
enableRowSelection:
|
|
52
|
-
getCoreRowModel:
|
|
53
|
-
getExpandedRowModel:
|
|
54
|
-
getFilteredRowModel:
|
|
55
|
-
getSortedRowModel:
|
|
56
|
-
getPaginationRowModel:
|
|
57
|
-
getRowId: o.getRowId ?? ((t,
|
|
58
|
-
defaultColumn:
|
|
59
|
-
...o
|
|
58
|
+
enableRowSelection: F,
|
|
59
|
+
getCoreRowModel: oe(),
|
|
60
|
+
getExpandedRowModel: ie(),
|
|
61
|
+
getFilteredRowModel: ne(),
|
|
62
|
+
getSortedRowModel: ae(),
|
|
63
|
+
getPaginationRowModel: re(),
|
|
64
|
+
getRowId: o.getRowId ?? ((t, ue, v) => v ? [v.id, t.id].join(".") : t.id.toString()),
|
|
65
|
+
defaultColumn: l,
|
|
66
|
+
...o,
|
|
67
|
+
enableColumnResizing: c
|
|
60
68
|
});
|
|
61
|
-
C && (C.current = e),
|
|
69
|
+
C && (C.current = e), U(e, m), K({
|
|
62
70
|
storageKey: a,
|
|
63
71
|
state: e.getState().sorting,
|
|
64
|
-
defaultValue:
|
|
65
|
-
saved:
|
|
72
|
+
defaultValue: R,
|
|
73
|
+
saved: p,
|
|
66
74
|
controlled: o.state?.sorting !== void 0,
|
|
67
|
-
toSignature:
|
|
68
|
-
toStorage:
|
|
75
|
+
toSignature: X,
|
|
76
|
+
toStorage: Q,
|
|
69
77
|
applyState: (t) => e.setSorting(t)
|
|
70
|
-
}),
|
|
71
|
-
storageKey:
|
|
78
|
+
}), K({
|
|
79
|
+
storageKey: M,
|
|
72
80
|
state: e.getState().columnSizing,
|
|
73
|
-
defaultValue:
|
|
74
|
-
saved:
|
|
81
|
+
defaultValue: d,
|
|
82
|
+
saved: f,
|
|
75
83
|
settled: !e.getState().columnSizingInfo.isResizingColumn,
|
|
76
|
-
toSignature:
|
|
77
|
-
toStorage:
|
|
84
|
+
toSignature: J,
|
|
85
|
+
toStorage: k,
|
|
78
86
|
applyState: (t) => e.setColumnSizing(t)
|
|
79
87
|
}), e.resetColumnSettings = () => {
|
|
80
|
-
e.setColumnOrder([]), e.setColumnSizing(
|
|
88
|
+
e.setColumnOrder([]), e.setColumnSizing(d), a && e.setSorting(R);
|
|
81
89
|
for (const t of [
|
|
82
90
|
a,
|
|
83
|
-
|
|
84
|
-
|
|
91
|
+
M,
|
|
92
|
+
m
|
|
85
93
|
]) t && w.remove(t);
|
|
86
94
|
};
|
|
87
|
-
const n =
|
|
88
|
-
return
|
|
89
|
-
|
|
95
|
+
const n = j(r), g = e.getState().pagination?.pageSize, z = te(void 0);
|
|
96
|
+
return P(() => {
|
|
97
|
+
z.current = void 0, e.getState().pagination?.pageSize !== i && (e.setPageIndex(0), e.setPageSize(i));
|
|
90
98
|
}, [
|
|
91
99
|
i,
|
|
92
100
|
n,
|
|
93
101
|
e
|
|
94
|
-
]),
|
|
95
|
-
if (!(!n ||
|
|
96
|
-
if (
|
|
97
|
-
if (
|
|
98
|
-
|
|
102
|
+
]), P(() => {
|
|
103
|
+
if (!(!n || g == null)) {
|
|
104
|
+
if (z.current !== n) {
|
|
105
|
+
if (g !== i) return;
|
|
106
|
+
z.current = n;
|
|
99
107
|
}
|
|
100
|
-
w.set(n, JSON.stringify(
|
|
108
|
+
w.set(n, JSON.stringify(g));
|
|
101
109
|
}
|
|
102
110
|
}, [
|
|
103
|
-
|
|
111
|
+
g,
|
|
104
112
|
i,
|
|
105
113
|
n
|
|
106
114
|
]), { table: e };
|
|
107
115
|
};
|
|
108
116
|
export {
|
|
109
|
-
|
|
117
|
+
Oe as useStyledTable
|
|
110
118
|
};
|