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,41 +1,44 @@
|
|
|
1
|
-
import { cn as
|
|
2
|
-
import { ACTIONS_COLUMN_ID as
|
|
3
|
-
import
|
|
1
|
+
import { cn as A } from "../../../helpers/cn.js";
|
|
2
|
+
import { ACTIONS_COLUMN_ID as O } from "../../types.js";
|
|
3
|
+
import p from "../StyledTable.module.js";
|
|
4
|
+
import { getActiveBodyRow as T, getLastHeaderControl as j } from "../../helpers/headerControls.js";
|
|
4
5
|
import { TableHeaderCell as u } from "./TableHeaderCell.js";
|
|
5
6
|
import "react";
|
|
6
|
-
import { jsx as o, jsxs as
|
|
7
|
+
import { jsx as o, jsxs as B } from "react/jsx-runtime";
|
|
7
8
|
import "@tanstack/react-table";
|
|
8
|
-
function
|
|
9
|
-
const { stickyHeader: S = !1, tableHeaderRef:
|
|
9
|
+
function v({ table: x, styledTableProps: n, tableCanResize: d, tableWidth: a, columnWindow: { paddingLeft: i, paddingRight: c, indexes: H } }) {
|
|
10
|
+
const { stickyHeader: g = !1, hideHeader: S = !1, tableHeaderRef: y, tableHeaderStyle: D = {} } = n, w = x.getHeaderGroups(), b = { ...D };
|
|
10
11
|
return /* @__PURE__ */ o("thead", {
|
|
11
|
-
className:
|
|
12
|
-
style:
|
|
13
|
-
ref:
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
className: A(p["table-header"], g && p["table-header--sticky"], n.tableHeaderClassName),
|
|
13
|
+
style: b,
|
|
14
|
+
ref: y,
|
|
15
|
+
"data-header-hidden": S ? "true" : void 0,
|
|
16
|
+
children: w.map((f) => {
|
|
17
|
+
const s = f.headers.map((e, t, r) => ({
|
|
16
18
|
header: e,
|
|
17
|
-
left: r.slice(0, t).reduce((
|
|
18
|
-
})),
|
|
19
|
+
left: r.slice(0, t).reduce((l, m) => l + (m.column.getSize() ?? 0), 0)
|
|
20
|
+
})), C = s.filter(({ header: e }) => e.column.columnDef.fixedLeft), N = s.filter(({ header: e }) => !e.column.columnDef.fixedLeft && !e.column.columnDef.fixedRight && e.column.id !== "actions"), h = s.filter(({ header: e }) => !!e.column.columnDef.fixedRight || e.column.id === "actions"), W = h.some(({ header: e }) => e.column.id === O), _ = h.map((e, t, r) => ({
|
|
19
21
|
...e,
|
|
20
|
-
right: r.slice(t + 1).reduce((
|
|
21
|
-
})),
|
|
22
|
+
right: r.slice(t + 1).reduce((l, m) => l + (m.header.column.getSize() ?? 0), 0) + (W ? -1 : 0)
|
|
23
|
+
})), k = H.reduce((e, t) => {
|
|
22
24
|
const r = N[t];
|
|
23
25
|
return r && e.push(r), e;
|
|
24
26
|
}, []);
|
|
25
|
-
return /* @__PURE__ */
|
|
26
|
-
tabIndex: 0,
|
|
27
|
+
return /* @__PURE__ */ B("tr", {
|
|
27
28
|
onKeyDown: (e) => {
|
|
28
|
-
if (e.key !== "Tab" || e.shiftKey || e.defaultPrevented
|
|
29
|
-
const t = e.currentTarget.closest("table")
|
|
30
|
-
|
|
29
|
+
if (e.key !== "Tab" || e.shiftKey || e.defaultPrevented) return;
|
|
30
|
+
const t = e.currentTarget.closest("table");
|
|
31
|
+
if (e.target !== j(t)) return;
|
|
32
|
+
const r = T(t);
|
|
33
|
+
r && (e.preventDefault(), r.focus());
|
|
31
34
|
},
|
|
32
35
|
children: [
|
|
33
|
-
|
|
36
|
+
C.map(({ header: e, left: t }) => /* @__PURE__ */ o(u, {
|
|
34
37
|
styledTableProps: n,
|
|
35
38
|
header: e,
|
|
36
|
-
tableCanResize:
|
|
39
|
+
tableCanResize: d,
|
|
37
40
|
left: t,
|
|
38
|
-
tableWidth:
|
|
41
|
+
tableWidth: a
|
|
39
42
|
}, e.id)),
|
|
40
43
|
i > 0 && /* @__PURE__ */ o("th", {
|
|
41
44
|
"aria-hidden": !0,
|
|
@@ -47,15 +50,15 @@ function M({ table: p, styledTableProps: n, tableCanResize: l, tableWidth: s, co
|
|
|
47
50
|
border: "none"
|
|
48
51
|
}
|
|
49
52
|
}),
|
|
50
|
-
|
|
53
|
+
k.map((e) => {
|
|
51
54
|
if (!e) return null;
|
|
52
55
|
const { header: t, left: r } = e;
|
|
53
56
|
return /* @__PURE__ */ o(u, {
|
|
54
57
|
styledTableProps: n,
|
|
55
58
|
header: t,
|
|
56
|
-
tableCanResize:
|
|
59
|
+
tableCanResize: d,
|
|
57
60
|
left: r,
|
|
58
|
-
tableWidth:
|
|
61
|
+
tableWidth: a
|
|
59
62
|
}, t.id);
|
|
60
63
|
}),
|
|
61
64
|
c > 0 && /* @__PURE__ */ o("th", {
|
|
@@ -68,13 +71,13 @@ function M({ table: p, styledTableProps: n, tableCanResize: l, tableWidth: s, co
|
|
|
68
71
|
border: "none"
|
|
69
72
|
}
|
|
70
73
|
}),
|
|
71
|
-
|
|
74
|
+
_.map(({ header: e, left: t, right: r }) => /* @__PURE__ */ o(u, {
|
|
72
75
|
styledTableProps: n,
|
|
73
76
|
header: e,
|
|
74
|
-
tableCanResize:
|
|
77
|
+
tableCanResize: d,
|
|
75
78
|
left: t,
|
|
76
79
|
right: r,
|
|
77
|
-
tableWidth:
|
|
80
|
+
tableWidth: a
|
|
78
81
|
}, e.id))
|
|
79
82
|
]
|
|
80
83
|
}, f.id);
|
|
@@ -82,5 +85,5 @@ function M({ table: p, styledTableProps: n, tableCanResize: l, tableWidth: s, co
|
|
|
82
85
|
});
|
|
83
86
|
}
|
|
84
87
|
export {
|
|
85
|
-
|
|
88
|
+
v as TableHeader
|
|
86
89
|
};
|
|
@@ -6,11 +6,11 @@ import { SortIndicator as O } from "./SortIndicator.js";
|
|
|
6
6
|
import { getTableHeaderStyle as E } from "../../helpers/getTableHeaderStyle.js";
|
|
7
7
|
import { getSortPreview as M } from "../../helpers/sortPreview.js";
|
|
8
8
|
import _ from "clsx";
|
|
9
|
-
import { useMemo as
|
|
9
|
+
import { useMemo as r } from "react";
|
|
10
10
|
import { jsx as l, jsxs as k } from "react/jsx-runtime";
|
|
11
11
|
import { flexRender as B } from "@tanstack/react-table";
|
|
12
12
|
function Z({ styledTableProps: z, header: o, tableCanResize: b = !1, left: N, right: v, tableWidth: H }) {
|
|
13
|
-
const { hideHeader:
|
|
13
|
+
const { hideHeader: c = !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 = r(() => o.headerGroup.headers.some((t) => t.id === D), [o.headerGroup.headers]), w = r(() => o.headerGroup.headers.some((t) => !!t.column.columnDef.fixedRight), [o.headerGroup.headers]), y = r(() => 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({
|
|
14
14
|
sorted: s,
|
|
15
15
|
firstDirection: o.column.getFirstSortDir(),
|
|
16
16
|
nextOrder: o.column.getNextSortingOrder(),
|
|
@@ -19,7 +19,7 @@ function Z({ styledTableProps: z, header: o, tableCanResize: b = !1, left: N, ri
|
|
|
19
19
|
return /* @__PURE__ */ l("th", {
|
|
20
20
|
colSpan: o.colSpan,
|
|
21
21
|
"aria-sort": G,
|
|
22
|
-
className: _(e["t-cell"], !R.includes(o.column.id) && o.column.getSize() > 64 && e["data-cell"], o.column.id === "select" && e["select-cell"],
|
|
22
|
+
className: _(e["t-cell"], !R.includes(o.column.id) && o.column.getSize() > 64 && e["data-cell"], o.column.id === "select" && e["select-cell"], c && 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"]),
|
|
23
23
|
style: {
|
|
24
24
|
...E({
|
|
25
25
|
enableResizing: m,
|
|
@@ -30,9 +30,9 @@ function Z({ styledTableProps: z, header: o, tableCanResize: b = !1, left: N, ri
|
|
|
30
30
|
...f && { right: v }
|
|
31
31
|
},
|
|
32
32
|
children: /* @__PURE__ */ k("div", {
|
|
33
|
-
className: _("flex items-center justify-start",
|
|
33
|
+
className: _("flex items-center justify-start", c ? e["hide-table-header"] : e["show-table-header"], n && e["sortable-column"], C && e["has-resize-zone"], o.column.columnDef.className),
|
|
34
34
|
role: n ? "button" : void 0,
|
|
35
|
-
tabIndex: n ? 0 : void 0,
|
|
35
|
+
tabIndex: n && !c ? 0 : void 0,
|
|
36
36
|
onClick: (t) => {
|
|
37
37
|
const i = o.column.getToggleSortingHandler();
|
|
38
38
|
!a && i && i(t), d();
|
|
@@ -1,9 +1,28 @@
|
|
|
1
|
-
import { INTERNAL_COLUMN_IDS as
|
|
2
|
-
var
|
|
3
|
-
const r = new Set(e
|
|
4
|
-
return
|
|
5
|
-
},
|
|
1
|
+
import { INTERNAL_COLUMN_IDS as o } from "../../types.js";
|
|
2
|
+
var u = (e) => e.flatMap((s) => s.columns.length ? u(s.columns) : [s.id]), f = (e) => u(e.getAllColumns()), d = (e) => e.getAllLeafColumns().map((s) => s.id), c = (e, s) => e.length === s.length && e.every((r, t) => r === s[t]), m = (e, s) => {
|
|
3
|
+
const r = new Set(s), t = [...new Set(e)].filter((i) => r.has(i)), n = new Set(t);
|
|
4
|
+
return [...t, ...s.filter((i) => !n.has(i))];
|
|
5
|
+
}, C = (e, s) => {
|
|
6
|
+
const r = [...e];
|
|
7
|
+
return s.forEach((t, n) => {
|
|
8
|
+
if (r.includes(t)) return;
|
|
9
|
+
const i = s.slice(0, n).findLast((l) => r.includes(l)), a = s.slice(n + 1).find((l) => r.includes(l));
|
|
10
|
+
i !== void 0 ? r.splice(r.indexOf(i) + 1, 0, t) : a !== void 0 ? r.splice(r.indexOf(a), 0, t) : r.push(t);
|
|
11
|
+
}), r;
|
|
12
|
+
}, y = (e, s) => e.length > 0 ? C(e, s) : [], v = (e, s) => e[s] ?? !0, g = (e, s) => Object.fromEntries(Object.entries(e).filter(([r, t]) => !o.includes(r) && t !== v(s, r))), D = (e, s) => JSON.stringify(Object.entries(g(e, s)).sort(([r], [t]) => r < t ? -1 : 1)), S = (e) => c(d(e), f(e)), h = (e) => !o.includes(e.id) && !!e.columnDef.header, O = (e) => {
|
|
13
|
+
const s = new Set(e.getAllLeafColumns().filter(h).map((t) => t.id)), r = m(e.columnLayoutDefaults?.order ?? [], f(e));
|
|
14
|
+
return !c(d(e).filter((t) => s.has(t)), r.filter((t) => s.has(t)));
|
|
15
|
+
}, p = (e) => {
|
|
16
|
+
const s = e.columnLayoutDefaults?.visibility;
|
|
17
|
+
return e.getAllLeafColumns().some((r) => r.getCanHide() && !o.includes(r.id) && (s ? r.getIsVisible() !== v(s, r.id) : !r.getIsVisible()));
|
|
18
|
+
}, I = (e) => p(e) || O(e);
|
|
6
19
|
export {
|
|
7
|
-
|
|
8
|
-
|
|
20
|
+
D as columnVisibilitySignature,
|
|
21
|
+
g as diffColumnVisibility,
|
|
22
|
+
m as effectiveColumnOrder,
|
|
23
|
+
f as getDefinitionColumnOrder,
|
|
24
|
+
I as hasChangedColumnLayout,
|
|
25
|
+
C as insertMissingColumns,
|
|
26
|
+
S as isDefaultColumnOrder,
|
|
27
|
+
y as normalizeDefaultColumnOrder
|
|
9
28
|
};
|
|
@@ -1,27 +1,28 @@
|
|
|
1
|
-
var
|
|
1
|
+
var l = (e) => {
|
|
2
2
|
const o = e.id ?? (typeof e.accessorKey == "string" && e.accessorKey ? e.accessorKey.replaceAll(".", "_") : void 0) ?? (typeof e.header == "string" ? e.header : void 0);
|
|
3
3
|
return o === void 0 || o === "" ? void 0 : o;
|
|
4
4
|
}, u = (e, o = {}) => {
|
|
5
|
-
const t = [],
|
|
6
|
-
for (const r of
|
|
5
|
+
const t = [], c = (i) => {
|
|
6
|
+
for (const r of i) {
|
|
7
7
|
if (r.columns?.length) {
|
|
8
|
-
|
|
8
|
+
c(r.columns);
|
|
9
9
|
continue;
|
|
10
10
|
}
|
|
11
11
|
const n = {
|
|
12
12
|
...o.defaultColumn,
|
|
13
13
|
...r
|
|
14
|
-
},
|
|
15
|
-
if (
|
|
16
|
-
const
|
|
14
|
+
}, a = l(n);
|
|
15
|
+
if (a === void 0) continue;
|
|
16
|
+
const s = !!n.accessorFn || !!n.accessorKey;
|
|
17
17
|
t.push({
|
|
18
|
-
id:
|
|
19
|
-
canSort: (n.enableSorting ?? !0) && (o.enableSorting ?? !0) &&
|
|
20
|
-
canMultiSort: n.enableMultiSort ?? o.enableMultiSort ??
|
|
18
|
+
id: a,
|
|
19
|
+
canSort: (n.enableSorting ?? !0) && (o.enableSorting ?? !0) && s,
|
|
20
|
+
canMultiSort: n.enableMultiSort ?? o.enableMultiSort ?? s,
|
|
21
|
+
canHide: (n.enableHiding ?? !0) && (o.enableHiding ?? !0)
|
|
21
22
|
});
|
|
22
23
|
}
|
|
23
24
|
};
|
|
24
|
-
return
|
|
25
|
+
return c(e), t;
|
|
25
26
|
};
|
|
26
27
|
export {
|
|
27
28
|
u as getLeafColumnInfos
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
var r = "a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]", a = (t) => t.tabIndex >= 0 && !t.closest("[inert], [hidden]") && t.getClientRects().length > 0 && getComputedStyle(t).visibility !== "hidden", d = (t) => {
|
|
2
|
+
const e = t?.tHead;
|
|
3
|
+
return !e || e.hasAttribute("data-header-hidden") ? [] : Array.from(e.querySelectorAll(r)).filter(a);
|
|
4
|
+
}, i = (t) => d(t).at(-1), o = (t) => Array.from(t?.tBodies ?? []).flatMap((e) => Array.from(e.rows)).find((e) => e.tabIndex === 0);
|
|
5
|
+
export {
|
|
6
|
+
o as getActiveBodyRow,
|
|
7
|
+
i as getLastHeaderControl
|
|
8
|
+
};
|
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
var e = {
|
|
2
|
-
get(
|
|
2
|
+
get(r) {
|
|
3
3
|
try {
|
|
4
|
-
return localStorage.getItem(
|
|
4
|
+
return localStorage.getItem(r);
|
|
5
5
|
} catch {
|
|
6
6
|
return null;
|
|
7
7
|
}
|
|
8
8
|
},
|
|
9
|
-
set(
|
|
9
|
+
set(r, t) {
|
|
10
10
|
try {
|
|
11
|
-
localStorage.setItem(t,
|
|
11
|
+
return localStorage.setItem(r, t), !0;
|
|
12
12
|
} catch {
|
|
13
|
+
return !1;
|
|
13
14
|
}
|
|
14
15
|
},
|
|
15
|
-
remove(
|
|
16
|
+
remove(r) {
|
|
16
17
|
try {
|
|
17
|
-
localStorage.removeItem(
|
|
18
|
+
localStorage.removeItem(r);
|
|
18
19
|
} catch {
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
|
-
}, a = (
|
|
22
|
-
const
|
|
23
|
-
if (
|
|
22
|
+
}, a = (r) => {
|
|
23
|
+
const t = e.get(r);
|
|
24
|
+
if (t)
|
|
24
25
|
try {
|
|
25
|
-
return JSON.parse(
|
|
26
|
+
return JSON.parse(t);
|
|
26
27
|
} catch {
|
|
27
28
|
return;
|
|
28
29
|
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { INTERNAL_COLUMN_IDS as N } from "../types.js";
|
|
2
|
+
import { readJson as O, tableStorage as v } from "../helpers/tableStorage.js";
|
|
3
|
+
import { columnVisibilitySignature as h, diffColumnVisibility as K, effectiveColumnOrder as m, getDefinitionColumnOrder as A, insertMissingColumns as j } from "../custom-features/order-columns/columnLayout.js";
|
|
4
|
+
import { usePersistedStateWriter as L } from "./usePersistedStateWriter.js";
|
|
5
|
+
import { useEffect as J, useLayoutEffect as R, useMemo as _ } from "react";
|
|
6
|
+
var F = ":column-order", M = ":column-visibility", f = 1, k = (e) => e ? `${e}${F}` : void 0, E = (e) => e ? `${e}${M}` : void 0, S = (e) => typeof e == "object" && e !== null && !Array.isArray(e), C = (e) => [...new Set(e.filter((i) => typeof i == "string"))], D = (e) => {
|
|
7
|
+
if (!S(e) || e.v !== f || !Array.isArray(e.order)) return;
|
|
8
|
+
const i = C(e.order);
|
|
9
|
+
return i.length > 0 ? i : void 0;
|
|
10
|
+
}, p = (e, i) => !N.includes(e) && i.find((t) => t.id === e)?.canHide !== !1, $ = (e, i) => {
|
|
11
|
+
if (!S(e) || e.v !== f || !S(e.visibility)) return;
|
|
12
|
+
const t = Object.fromEntries(Object.entries(e.visibility).filter((r) => typeof r[1] == "boolean" && p(r[0], i)));
|
|
13
|
+
return Object.keys(t).length > 0 ? t : void 0;
|
|
14
|
+
}, x = (e) => {
|
|
15
|
+
if (!Array.isArray(e)) return;
|
|
16
|
+
const i = C(e);
|
|
17
|
+
return i.length > 0 ? i : void 0;
|
|
18
|
+
}, T = (e, i, t) => {
|
|
19
|
+
if (!S(e) || !Object.values(e).every((o) => typeof o == "boolean")) return;
|
|
20
|
+
const r = K(Object.fromEntries(Object.entries(e).filter(([o]) => p(o, i))), t);
|
|
21
|
+
return Object.keys(r).length > 0 ? r : void 0;
|
|
22
|
+
}, U = (e) => {
|
|
23
|
+
const { enabled: i, uniqueKey: t, legacyOrderKey: r, legacyVisibilityKey: o, columns: s, defaultOrder: g, defaultVisibility: d } = e, n = i ? k(t) : void 0, a = i ? E(t) : void 0, y = s.map((l) => l.id), c = [];
|
|
24
|
+
let b, u;
|
|
25
|
+
if (n) {
|
|
26
|
+
if (v.get(n) !== null) b = D(O(n));
|
|
27
|
+
else if (r && v.get(r) !== null) {
|
|
28
|
+
const l = x(O(r)), I = l === void 0 || m(j(l, y), y).join() === m(g, y).join();
|
|
29
|
+
l && !I && (b = l), c.push({
|
|
30
|
+
legacyKey: r,
|
|
31
|
+
...l && !I && { write: {
|
|
32
|
+
key: n,
|
|
33
|
+
value: JSON.stringify({
|
|
34
|
+
v: f,
|
|
35
|
+
order: l
|
|
36
|
+
})
|
|
37
|
+
} }
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return a && (v.get(a) !== null ? u = $(O(a), s) : o && v.get(o) !== null && (u = T(O(o), s, d), c.push({
|
|
42
|
+
legacyKey: o,
|
|
43
|
+
...u && { write: {
|
|
44
|
+
key: a,
|
|
45
|
+
value: JSON.stringify({
|
|
46
|
+
v: f,
|
|
47
|
+
visibility: u
|
|
48
|
+
})
|
|
49
|
+
} }
|
|
50
|
+
}))), {
|
|
51
|
+
orderKey: n,
|
|
52
|
+
visibilityKey: a,
|
|
53
|
+
order: b,
|
|
54
|
+
visibility: u,
|
|
55
|
+
migration: c
|
|
56
|
+
};
|
|
57
|
+
}, W = (e, i, t) => {
|
|
58
|
+
const r = e.visibility && Object.fromEntries(Object.entries(e.visibility).filter(([o]) => p(o, i)));
|
|
59
|
+
return {
|
|
60
|
+
orderKey: e.orderKey,
|
|
61
|
+
visibilityKey: e.visibilityKey,
|
|
62
|
+
order: e.order && j(e.order, i.map((o) => o.id)),
|
|
63
|
+
visibility: r && Object.keys(r).length > 0 ? {
|
|
64
|
+
...t,
|
|
65
|
+
...r
|
|
66
|
+
} : void 0
|
|
67
|
+
};
|
|
68
|
+
}, P = (e) => {
|
|
69
|
+
const i = _(() => U(e), [
|
|
70
|
+
e.enabled ? k(e.uniqueKey) : void 0,
|
|
71
|
+
e.enabled ? E(e.uniqueKey) : void 0,
|
|
72
|
+
e.legacyOrderKey,
|
|
73
|
+
e.legacyVisibilityKey
|
|
74
|
+
]);
|
|
75
|
+
return J(() => {
|
|
76
|
+
for (const { legacyKey: t, write: r } of i.migration)
|
|
77
|
+
r && !v.set(r.key, r.value) || v.remove(t);
|
|
78
|
+
}, [i]), W(i, e.columns, e.defaultVisibility);
|
|
79
|
+
}, V = /* @__PURE__ */ new WeakMap(), Y = (e, i) => [.../* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(i)])].every((t) => (e[t] ?? !0) === (i[t] ?? !0)), G = (e, i) => {
|
|
80
|
+
const { enabled: t, definitionIds: r, defaultOrder: o, defaultVisibility: s, controlledVisibility: g } = i, d = {
|
|
81
|
+
signature: JSON.stringify([
|
|
82
|
+
r,
|
|
83
|
+
o,
|
|
84
|
+
Object.entries(s).sort()
|
|
85
|
+
]),
|
|
86
|
+
definitionIds: r,
|
|
87
|
+
defaultOrder: o,
|
|
88
|
+
defaultVisibility: s
|
|
89
|
+
}, n = V.get(e) ?? d, a = t && n.signature !== d.signature;
|
|
90
|
+
return R(() => {
|
|
91
|
+
const y = V.get(e);
|
|
92
|
+
if (V.set(e, d), !t || !y || y.signature === d.signature) return;
|
|
93
|
+
const c = e.getState().columnOrder, b = m(c, y.definitionIds).join() === m(y.defaultOrder, y.definitionIds).join() ? o : j(c, r);
|
|
94
|
+
if (e.setColumnOrder(b), !g) {
|
|
95
|
+
const u = e.getState().columnVisibility, l = {
|
|
96
|
+
...s,
|
|
97
|
+
...K(u, y.defaultVisibility)
|
|
98
|
+
};
|
|
99
|
+
Y(l, u) || e.setColumnVisibility(l);
|
|
100
|
+
}
|
|
101
|
+
}, [
|
|
102
|
+
e,
|
|
103
|
+
t,
|
|
104
|
+
d.signature
|
|
105
|
+
]), a;
|
|
106
|
+
}, Q = (e, i) => {
|
|
107
|
+
const { saved: t, reconciling: r, defaultOrder: o, defaultVisibility: s, controlledVisibility: g } = i, d = A(e);
|
|
108
|
+
L({
|
|
109
|
+
storageKey: t.orderKey,
|
|
110
|
+
state: e.getState().columnOrder,
|
|
111
|
+
defaultValue: o,
|
|
112
|
+
saved: t.order,
|
|
113
|
+
settled: !r,
|
|
114
|
+
toSignature: (n) => JSON.stringify(m(n, d)),
|
|
115
|
+
toStorage: (n) => JSON.stringify({
|
|
116
|
+
v: f,
|
|
117
|
+
order: C(n)
|
|
118
|
+
}),
|
|
119
|
+
applyState: (n) => e.setColumnOrder(n)
|
|
120
|
+
}), L({
|
|
121
|
+
storageKey: t.visibilityKey,
|
|
122
|
+
state: e.getState().columnVisibility,
|
|
123
|
+
defaultValue: s,
|
|
124
|
+
saved: t.visibility,
|
|
125
|
+
settled: !r,
|
|
126
|
+
controlled: g,
|
|
127
|
+
toSignature: (n) => h(n, s),
|
|
128
|
+
toStorage: (n) => JSON.stringify({
|
|
129
|
+
v: f,
|
|
130
|
+
visibility: K(n, s)
|
|
131
|
+
}),
|
|
132
|
+
applyState: (n) => e.setColumnVisibility(n)
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
export {
|
|
136
|
+
G as useColumnLayoutReconcile,
|
|
137
|
+
Q as useColumnLayoutWriter,
|
|
138
|
+
P as useSavedColumnLayout
|
|
139
|
+
};
|