asma-ui-core 3.137.1 → 3.138.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.
@@ -21,7 +21,7 @@ export interface ColumnLayoutDefaults {
21
21
  export interface ColumnSettingsInstance {
22
22
  /**
23
23
  * Reset columns (ASMA-8597): puts the column order and the widths back to the table's defaults, and the
24
- * sorting too when the table has `persistSorting`. It removes the saved entries of what it resets. On a table
24
+ * sorting too when the table saves it (a `uniqueKey`, unless `persistSorting={false}` or the app owns the sorting). It removes the saved entries of what it resets. On a table
25
25
  * with `persistColumnLayout` (ASMA-8695, OQ-02) it also puts the visibility back to the default, unhiding what
26
26
  * the user hid and hiding what is hidden by default; any other table never touches visibility. Set by
27
27
  * `StyledTable`, which knows the defaults.
@@ -2,6 +2,7 @@ import { Table } from '@tanstack/react-table';
2
2
  /**
3
3
  * Saves the column order under `key` when it changes. An order that is `[]` or that matches the live
4
4
  * definition order removes the entry instead (ASMA-8597, REQ-004), so a table the user has put back to its
5
- * defaults stores nothing. Mounting never writes.
5
+ * defaults stores nothing. Mounting never writes. A table with no key does no work per render (ASMA-8698), and whether the
6
+ * order is the default is worked out only when it is about to be saved.
6
7
  */
7
8
  export declare function usePersistColumnOrder<TData = unknown>(table: Table<TData>, key?: string | null): void;
@@ -1,5 +1,27 @@
1
1
  import { OnChangeFn, SortingState } from '@tanstack/react-table';
2
2
  export declare const getSortingStorageKey: (uniqueKey?: string) => string | undefined;
3
+ /** What decides whether `StyledTable` saves a table's sorting: the props that matter, read from the table's own. */
4
+ export interface SortingPersistenceInput {
5
+ uniqueKey?: string;
6
+ /** The `persistSorting` prop as the app wrote it; `undefined` when it did not. */
7
+ persistSorting?: boolean;
8
+ /**
9
+ * The app owns the sorting state: it passes `state.sorting`, or `onSortingChange`. TanStack hands every change to that
10
+ * handler instead of updating the table's own state, so a handler alone is as much the app's state as `state.sorting`.
11
+ */
12
+ controlled: boolean;
13
+ }
14
+ /**
15
+ * Whether `StyledTable` reads and writes the sorting under `${uniqueKey}:sorting` (ASMA-8698, DEC-8698-OPTOUT).
16
+ *
17
+ * - No `uniqueKey`: never.
18
+ * - `persistSorting={false}`: never, the opt-out for tables whose order is the user's own (drag and drop).
19
+ * - `persistSorting={true}`: yes, even when the app owns the sorting state. That is how such an app lets `StyledTable` be the
20
+ * only writer of the sort it reads back with `usePersistedSorting`.
21
+ * - Not written: yes, unless the app owns the sorting state. A saved sort could not be applied to a state the table does not
22
+ * own, and an app that persists its own sort would have two writers fighting over it.
23
+ */
24
+ export declare const savesSorting: ({ uniqueKey, persistSorting, controlled }: SortingPersistenceInput) => boolean;
3
25
  /** What a saved sort is checked against: the columns that can sort, and the multi-sort rules. */
4
26
  export interface SortingRules {
5
27
  sortableColumns: readonly {
@@ -27,7 +49,7 @@ export interface PersistedSortingOptions {
27
49
  maxMultiSortColCount?: number;
28
50
  }
29
51
  /**
30
- * Reads the sorting `StyledTable` saved for `uniqueKey` (with `persistSorting`), checked against the columns
52
+ * Reads the sorting `StyledTable` saved for `uniqueKey`, checked against the columns
31
53
  * the caller can sort by. Synchronous and pure, so a table that owns its sorting state (for example because
32
54
  * the server sorts) can use the saved sort for its first request. Returns `undefined` when nothing valid is
33
55
  * saved, and `[]` when the user turned sorting off.
@@ -36,8 +58,8 @@ export declare const readPersistedSorting: (uniqueKey: string | undefined, optio
36
58
  /**
37
59
  * Sorting state for a table that owns `state.sorting`: the saved sort on the first render (before the first
38
60
  * request), `defaultSorting` when nothing valid is saved, and the new key's sort after `uniqueKey` changes.
39
- * It never writes: `StyledTable` with `persistSorting` is the only writer, and it takes the same default
40
- * from `initialState.sorting`, which Reset columns restores.
61
+ * It never writes: `StyledTable` is the only writer, and it saves a sort the app owns only with `persistSorting` written
62
+ * on the table (see `savesSorting`). It takes the same default from `initialState.sorting`, which Reset columns restores.
41
63
  *
42
64
  * ```tsx
43
65
  * const { sorting, onSortingChange } = usePersistedSorting({ uniqueKey, defaultSorting, sortableColumnIds })
@@ -25,6 +25,10 @@ interface PersistedStateWriterOptions<T> {
25
25
  * entry is never touched, so the old value can't be copied over the new key.
26
26
  * - When the key goes away (`undefined`), the table goes back to the app's defaults and writes nothing, so
27
27
  * one user's values are not left on screen for whoever is shown next.
28
+ *
29
+ * It costs a table that does not save the setting nothing per render (ASMA-8698): the value's signature is computed only
30
+ * while there is a key (the render that loses the key reads it in the layout effect), and the default's only when a write
31
+ * or a reset needs it.
28
32
  */
29
33
  export declare const usePersistedStateWriter: <T>(options: PersistedStateWriterOptions<T>) => void;
30
34
  export {};
@@ -2,7 +2,7 @@ declare const translations: {
2
2
  en: {
3
3
  column_reorder: string;
4
4
  column_hidden: string;
5
- column_reorder_and_hidden: string;
5
+ column_unhideable: string;
6
6
  reset_columns: string;
7
7
  columns_reset: string;
8
8
  column_settings: string;
@@ -11,7 +11,7 @@ declare const translations: {
11
11
  no: {
12
12
  column_reorder: string;
13
13
  column_hidden: string;
14
- column_reorder_and_hidden: string;
14
+ column_unhideable: string;
15
15
  reset_columns: string;
16
16
  columns_reset: string;
17
17
  column_settings: string;
@@ -158,10 +158,21 @@ export type StyledTableProps<TData, TCustomData> = {
158
158
  */
159
159
  uniqueKey?: string;
160
160
  /**
161
- * Temporary opt-in (ASMA-8597, owner decision D1, 2026-10-27): save and restore this table's
162
- * sorting under `${uniqueKey}:sorting`, and let Reset columns reset it. Needs `uniqueKey`;
163
- * ignored without it. Off by default until UX and privacy approve the fleet rollout, which
164
- * makes `uniqueKey` alone enough and retires this prop (follow-up ASMA-8698).
161
+ * Whether the table saves and restores its sorting under `${uniqueKey}:sorting`, and lets Reset columns reset it
162
+ * (ASMA-8698). It does by default: a table with a `uniqueKey` remembers each user's sort, like their column widths. Without
163
+ * `uniqueKey` nothing is saved.
164
+ *
165
+ * - `false` is the opt-out, for a table whose order is the user's own (drag and drop rows) or that must always open as the
166
+ * app declares it. Nothing is read or written for sorting then.
167
+ * - Leaving it out, or `true`, saves a sort that `StyledTable` owns. `true` is the default spelled out: nothing changes
168
+ * for a table that has it (it will not be removed before the next major version).
169
+ * - A table whose app owns the sorting state (`state.sorting`, or `onSortingChange`, which TanStack calls instead of
170
+ * updating the table's own state) is **not** saved by default: the saved sort could not be applied to a state the table
171
+ * does not own, and an app with its own persistence would have two writers. Such a table that wants it saved writes
172
+ * `persistSorting` (`true`), makes `StyledTable` the only writer, and reads the sort back with `usePersistedSorting`.
173
+ *
174
+ * A saved sort of a column that is gone or cannot sort is ignored, and so is storage that is corrupt, full or blocked: the
175
+ * table opens with its `initialState.sorting`, which Reset columns also returns to.
165
176
  */
166
177
  persistSorting?: boolean;
167
178
  /**
@@ -1,157 +1,174 @@
1
- import { cn as v } from "../../../../../helpers/cn.js";
2
- import { StyledBadge as N } from "../../../../../components/data-display/badge/StyledBadge.js";
3
- import { PinIcon as _ } from "../../../../../components/icons/pin-icon/PinIcon.js";
4
- import { StyledPopover as T } from "../../../../../components/utils/popover/StyledPopover.js";
5
- import { message as D } from "../../../../../components/feedback/snack-bar/message.js";
6
- import { INTERNAL_COLUMN_IDS as L } from "../../../../types.js";
7
- import { hasChangedColumnLayout as k } from "../../../../custom-features/order-columns/columnLayout.js";
8
- import { StyledCheckbox as A } from "../../../../shared-components/StyledCheckbox.js";
9
- import { StyledTooltip as I } from "../../../../shared-components/tooltip/index.js";
10
- import { useToggleMenuVisibility as H } from "../../../../hooks/useToggleMenuVisibility.hook.js";
1
+ import { cn as k } from "../../../../../helpers/cn.js";
2
+ import { StyledBadge as R } from "../../../../../components/data-display/badge/StyledBadge.js";
3
+ import { PinIcon as w } from "../../../../../components/icons/pin-icon/PinIcon.js";
4
+ import { StyledPopover as A } from "../../../../../components/utils/popover/StyledPopover.js";
5
+ import { message as O } from "../../../../../components/feedback/snack-bar/message.js";
6
+ import { INTERNAL_COLUMN_IDS as H } from "../../../../types.js";
7
+ import { hasChangedColumnLayout as M } from "../../../../custom-features/order-columns/columnLayout.js";
8
+ import { StyledCheckbox as P } from "../../../../shared-components/StyledCheckbox.js";
9
+ import { StyledTooltip as y } from "../../../../shared-components/tooltip/index.js";
10
+ import { useToggleMenuVisibility as E } from "../../../../hooks/useToggleMenuVisibility.hook.js";
11
11
  import f from "./TableActions.module.js";
12
- import d from "./HeaderActionMenu.module.js";
13
- import { DotsHorizontalIcon as O } from "../../../../shared-components/DotsHorizontalIcon.js";
14
- import { headerLabelText as R } from "../../../../helpers/headerLabel.js";
15
- import { useTranslations as w } from "../../../../hooks/useTranslations.js";
16
- import { StyledButton as E } from "../../../../shared-components/button/StyledButton.js";
17
- import { compact as M } from "../../../../../helpers/arrays.js";
18
- import { jsx as i, jsxs as u } from "react/jsx-runtime";
19
- import { DndContext as P, PointerSensor as V, closestCenter as W, useSensor as z, useSensors as B } from "@dnd-kit/core";
20
- import { restrictToParentElement as j, restrictToVerticalAxis as U } from "@dnd-kit/modifiers";
21
- import { SortableContext as Y, arrayMove as $, useSortable as q, verticalListSortingStrategy as F } from "@dnd-kit/sortable";
22
- import { CSS as G } from "@dnd-kit/utilities";
23
- function J({ id: n, disabled: p, children: h }) {
24
- const { attributes: c, listeners: b, setNodeRef: g, transform: m, transition: l } = q({
25
- id: n,
12
+ import s from "./HeaderActionMenu.module.js";
13
+ import { DotsHorizontalIcon as V } from "../../../../shared-components/DotsHorizontalIcon.js";
14
+ import { headerLabelText as W } from "../../../../helpers/headerLabel.js";
15
+ import { useTranslations as z } from "../../../../hooks/useTranslations.js";
16
+ import { StyledButton as B } from "../../../../shared-components/button/StyledButton.js";
17
+ import { compact as $ } from "../../../../../helpers/arrays.js";
18
+ import { useId as j } from "react";
19
+ import { jsx as t, jsxs as u } from "react/jsx-runtime";
20
+ import { DndContext as U, PointerSensor as F, closestCenter as Y, useSensor as q, useSensors as G } from "@dnd-kit/core";
21
+ import { restrictToParentElement as J, restrictToVerticalAxis as K } from "@dnd-kit/modifiers";
22
+ import { SortableContext as Q, arrayMove as X, useSortable as Z, verticalListSortingStrategy as ee } from "@dnd-kit/sortable";
23
+ import { CSS as te } from "@dnd-kit/utilities";
24
+ function oe({ id: r, disabled: p, children: h }) {
25
+ const { attributes: d, listeners: b, setNodeRef: g, transform: x, transition: c } = Z({
26
+ id: r,
26
27
  disabled: p
27
28
  });
28
- return /* @__PURE__ */ i("div", {
29
+ return /* @__PURE__ */ t("div", {
29
30
  ref: g,
30
31
  style: {
31
- transform: G.Transform.toString(m),
32
- transition: l
32
+ transform: te.Transform.toString(x),
33
+ transition: c
33
34
  },
34
- className: d["drag-item"],
35
+ className: s["drag-item"],
35
36
  children: h({
36
- attributes: c,
37
+ attributes: d,
37
38
  listeners: b
38
39
  })
39
40
  });
40
41
  }
41
- function xe({ headerData: n, locale: p }) {
42
- const { anchorEl: h, open: c, handleClose: b, handleOpen: g } = H(), m = k(n.table), l = n.table.getAllLeafColumns(), S = (e) => {
43
- const { active: r, over: t } = e;
44
- !r || !t || r.id === t.id || l.find((o) => o.id === t.id)?.columnDef.fixedLeft || l.find((o) => o.id === t.id)?.columnDef.fixedRight || n.table.setColumnOrder((o) => {
45
- const a = M(o ?? []).length ? o : n.table.getAllLeafColumns().map((C) => C.id);
46
- return $(a, a.indexOf(r.id), a.indexOf(t.id));
42
+ var ie = (r) => {
43
+ r.target.closest('label, [role="button"]') || r.preventDefault();
44
+ };
45
+ function Ie({ headerData: r, locale: p }) {
46
+ const { anchorEl: h, open: d, handleClose: b, handleOpen: g } = E(), x = j(), c = M(r.table), C = r.table.getAllLeafColumns(), N = (e) => {
47
+ const { active: l, over: o } = e;
48
+ !l || !o || l.id === o.id || C.find((i) => i.id === o.id)?.columnDef.fixedLeft || C.find((i) => i.id === o.id)?.columnDef.fixedRight || r.table.setColumnOrder((i) => {
49
+ const a = $(i ?? []).length ? i : r.table.getAllLeafColumns().map((m) => m.id);
50
+ return X(a, a.indexOf(l.id), a.indexOf(o.id));
47
51
  });
48
- }, y = B(z(V, { activationConstraint: { distance: 8 } })), s = w(p), x = l.filter((e) => !L.includes(e.id) && !!e.columnDef.header);
52
+ }, _ = G(q(F, { activationConstraint: { distance: 8 } })), n = z(p), S = C.filter((e) => !H.includes(e.id) && !!e.columnDef.header);
49
53
  return /* @__PURE__ */ u("div", {
50
54
  className: f["actions-header-wrapper"],
51
55
  children: [/* @__PURE__ */ u("button", {
52
56
  type: "button",
53
- "aria-label": m ? s.column_settings_changed : s.column_settings,
57
+ "aria-label": c ? n.column_settings_changed : n.column_settings,
54
58
  "aria-haspopup": "true",
55
- "aria-expanded": c,
56
- tabIndex: n.table.options.meta?.hideHeader ? -1 : void 0,
59
+ "aria-expanded": d,
60
+ tabIndex: r.table.options.meta?.hideHeader ? -1 : void 0,
57
61
  className: f["actions-header"],
58
62
  onClick: g,
59
- children: [/* @__PURE__ */ i(_, { className: f["pin-icon"] }), m && /* @__PURE__ */ i(N, {
63
+ children: [/* @__PURE__ */ t(w, { className: f["pin-icon"] }), c && /* @__PURE__ */ t(R, {
60
64
  dataTest: "column-settings-dot",
61
65
  variant: "dot",
62
66
  purpose: "filter",
63
67
  className: f["pin-dot"]
64
68
  })]
65
- }), /* @__PURE__ */ u(T, {
69
+ }), /* @__PURE__ */ u(A, {
66
70
  anchorEl: h,
67
71
  anchorOrigin: {
68
72
  horizontal: "left",
69
73
  vertical: "bottom"
70
74
  },
71
- open: c,
75
+ open: d,
72
76
  onClose: b,
73
77
  slotProps: { paper: { sx: {
74
78
  maxHeight: "calc(7 * 40px)",
75
79
  overflowY: "auto",
76
80
  scrollbarWidth: "thin"
77
81
  } } },
78
- children: [/* @__PURE__ */ i(P, {
79
- modifiers: [U, j],
80
- onDragEnd: S,
81
- collisionDetection: (e) => W(e).filter((r) => {
82
- const t = x.find((o) => o.id === r.id);
83
- return !t?.columnDef.fixedLeft && !t?.columnDef.fixedRight;
82
+ children: [/* @__PURE__ */ t(U, {
83
+ modifiers: [K, J],
84
+ onDragEnd: N,
85
+ collisionDetection: (e) => Y(e).filter((l) => {
86
+ const o = S.find((i) => i.id === l.id);
87
+ return !o?.columnDef.fixedLeft && !o?.columnDef.fixedRight;
84
88
  }),
85
- sensors: y,
86
- children: /* @__PURE__ */ i(Y, {
87
- items: x.map((e) => e.id),
88
- strategy: F,
89
- children: x.map((e) => {
90
- const r = !!e.columnDef.fixedLeft || !!e.columnDef.fixedRight, t = e.columnDef.enableHiding === !1;
91
- let o = null;
92
- return r && t ? o = s.column_reorder_and_hidden : r ? o = s.column_reorder : t && (o = s.column_hidden), /* @__PURE__ */ i(J, {
89
+ sensors: _,
90
+ children: /* @__PURE__ */ t(Q, {
91
+ items: S.map((e) => e.id),
92
+ strategy: ee,
93
+ children: S.map((e, l) => {
94
+ const o = !!e.columnDef.fixedLeft || !!e.columnDef.fixedRight, i = e.columnDef.enableHiding === !1, a = o ? n.column_reorder : null;
95
+ let m = null;
96
+ i && (m = o ? n.column_hidden : n.column_unhideable);
97
+ const D = W(e.columnDef) ?? e.id, v = `${x}-column-${l}-name`;
98
+ return /* @__PURE__ */ t(oe, {
93
99
  id: e.id,
94
- disabled: r,
95
- children: ({ listeners: a, attributes: C }) => /* @__PURE__ */ i(I, {
96
- title: o,
97
- arrow: !0,
98
- children: /* @__PURE__ */ u("button", {
99
- type: "button",
100
- onClick: () => {
101
- t || e.toggleVisibility(!e.getIsVisible());
102
- },
103
- className: d["table-action-item"],
104
- children: [
105
- /* @__PURE__ */ i(O, {
106
- width: 20,
107
- height: 20,
108
- ...C,
109
- ...a,
110
- style: {
111
- touchAction: "none",
112
- WebkitUserSelect: "none",
113
- userSelect: "none",
114
- WebkitTouchCallout: "none"
115
- },
116
- className: v(d["drag-icon"], r ? d["drag-icon--disabled"] : d["drag-icon--enabled"])
117
- }),
118
- /* @__PURE__ */ i("span", {
119
- className: "px-2",
120
- children: /* @__PURE__ */ i(A, {
121
- readOnly: t,
100
+ disabled: o,
101
+ children: ({ listeners: L, attributes: T }) => /* @__PURE__ */ u("div", {
102
+ role: "presentation",
103
+ className: s["table-action-item"],
104
+ onMouseDown: ie,
105
+ children: [
106
+ /* @__PURE__ */ t(y, {
107
+ title: m,
108
+ arrow: !0,
109
+ children: /* @__PURE__ */ t("span", {
110
+ className: "px-1",
111
+ children: /* @__PURE__ */ t(P, {
112
+ readOnly: i,
122
113
  dataTest: `${e.id}-column-visibility-checkbox`,
123
114
  size: "small",
124
115
  disableRipple: !0,
125
116
  checked: e.getIsVisible(),
126
117
  hideWrapper: !0,
127
- className: "pointer-events-none"
118
+ className: s["column-checkbox"],
119
+ "aria-labelledby": v,
120
+ "aria-readonly": i || void 0,
121
+ onChange: (re, I) => {
122
+ i || e.toggleVisibility(I);
123
+ }
124
+ })
125
+ })
126
+ }),
127
+ /* @__PURE__ */ t(y, {
128
+ title: a,
129
+ arrow: !0,
130
+ children: /* @__PURE__ */ t("span", {
131
+ className: s["drag-slot"],
132
+ children: /* @__PURE__ */ t(V, {
133
+ width: 20,
134
+ height: 20,
135
+ ...T,
136
+ ...L,
137
+ style: {
138
+ touchAction: "none",
139
+ WebkitUserSelect: "none",
140
+ userSelect: "none",
141
+ WebkitTouchCallout: "none"
142
+ },
143
+ className: k(s["drag-icon"], o ? s["drag-icon--disabled"] : s["drag-icon--enabled"])
128
144
  })
129
- }),
130
- /* @__PURE__ */ i("span", {
131
- className: "font-roboto text-base text-delta-700",
132
- children: R(e.columnDef) ?? e.id
133
145
  })
134
- ]
135
- })
146
+ }),
147
+ /* @__PURE__ */ t("span", {
148
+ id: v,
149
+ className: "font-roboto text-base text-delta-700",
150
+ children: D
151
+ })
152
+ ]
136
153
  })
137
154
  }, e.id);
138
155
  })
139
156
  })
140
- }), /* @__PURE__ */ i("div", {
157
+ }), /* @__PURE__ */ t("div", {
141
158
  className: "pb-2 pl-2",
142
- children: /* @__PURE__ */ i(E, {
159
+ children: /* @__PURE__ */ t(B, {
143
160
  dataTest: "reset-order-button",
144
161
  variant: "text",
145
162
  className: "h-10",
146
163
  onClick: () => {
147
- n.table.resetColumnSettings(), D.info(s.columns_reset, { closeButton: !0 });
164
+ r.table.resetColumnSettings(), O.info(n.columns_reset, { closeButton: !0 });
148
165
  },
149
- children: s.reset_columns
166
+ children: n.reset_columns
150
167
  })
151
168
  })]
152
169
  })]
153
170
  });
154
171
  }
155
172
  export {
156
- xe as HeaderActionMenu
173
+ Ie as HeaderActionMenu
157
174
  };
@@ -1,9 +1,11 @@
1
1
  var a = {
2
- "table-action-item": "_table-action-item_qha7l_1",
3
- "drag-item": "_drag-item_qha7l_18",
4
- "drag-icon": "_drag-icon_qha7l_22",
5
- "drag-icon--disabled": "_drag-icon--disabled_qha7l_27",
6
- "drag-icon--enabled": "_drag-icon--enabled_qha7l_32"
2
+ "table-action-item": "_table-action-item_1u7jy_1",
3
+ "drag-item": "_drag-item_1u7jy_19",
4
+ "column-checkbox": "_column-checkbox_1u7jy_23",
5
+ "drag-slot": "_drag-slot_1u7jy_28",
6
+ "drag-icon": "_drag-icon_1u7jy_33",
7
+ "drag-icon--disabled": "_drag-icon--disabled_1u7jy_38",
8
+ "drag-icon--enabled": "_drag-icon--enabled_1u7jy_43"
7
9
  };
8
10
  export {
9
11
  a as default
@@ -1,16 +1,16 @@
1
- import { tableStorage as u } from "../../helpers/tableStorage.js";
2
- import { isDefaultColumnOrder as i } from "./columnLayout.js";
3
- import { useEffect as m, useRef as f } from "react";
4
- function d(n, r) {
5
- const o = n.getState().columnOrder, t = JSON.stringify(o ?? []), c = !o?.length || i(n), s = f(r), e = f(t);
6
- m(() => {
7
- if (s.current !== r) {
8
- s.current = r, e.current = t;
1
+ import { tableStorage as s } from "../../helpers/tableStorage.js";
2
+ import { isDefaultColumnOrder as c } from "./columnLayout.js";
3
+ import { useEffect as i, useRef as f } from "react";
4
+ function g(n, r) {
5
+ const o = n.getState().columnOrder, t = r ? JSON.stringify(o ?? []) : "", u = f(r), e = f(t);
6
+ i(() => {
7
+ if (u.current !== r) {
8
+ u.current = r, e.current = t;
9
9
  return;
10
10
  }
11
- !r || t === e.current || (e.current = t, c ? u.remove(r) : u.set(r, t));
11
+ !r || t === e.current || (e.current = t, !o?.length || c(n) ? s.remove(r) : s.set(r, t));
12
12
  }, [t, r]);
13
13
  }
14
14
  export {
15
- d as usePersistColumnOrder
15
+ g as usePersistColumnOrder
16
16
  };
@@ -16,30 +16,30 @@ var F = ":column-order", M = ":column-visibility", f = 1, k = (e) => e ? `${e}${
16
16
  const i = C(e);
17
17
  return i.length > 0 ? i : void 0;
18
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);
19
+ if (!S(e) || !Object.values(e).every((s) => typeof s == "boolean")) return;
20
+ const r = K(Object.fromEntries(Object.entries(e).filter(([s]) => p(s, i))), t);
21
21
  return Object.keys(r).length > 0 ? r : void 0;
22
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 = [];
23
+ const { enabled: i, uniqueKey: t, legacyOrderKey: r, legacyVisibilityKey: s, columns: o, defaultOrder: g, defaultVisibility: n } = e, d = i ? k(t) : void 0, a = i ? E(t) : void 0, l = o.map((y) => y.id), c = [];
24
24
  let b, u;
25
- if (n) {
26
- if (v.get(n) !== null) b = D(O(n));
25
+ if (d) {
26
+ if (v.get(d) !== null) b = D(O(d));
27
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({
28
+ const y = x(O(r)), I = y === void 0 || m(j(y, l), l).join() === m(g, l).join();
29
+ y && !I && (b = y), c.push({
30
30
  legacyKey: r,
31
- ...l && !I && { write: {
32
- key: n,
31
+ ...y && !I && { write: {
32
+ key: d,
33
33
  value: JSON.stringify({
34
34
  v: f,
35
- order: l
35
+ order: y
36
36
  })
37
37
  } }
38
38
  });
39
39
  }
40
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,
41
+ return a && (v.get(a) !== null ? u = $(O(a), o) : s && v.get(s) !== null && (u = T(O(s), o, n), c.push({
42
+ legacyKey: s,
43
43
  ...u && { write: {
44
44
  key: a,
45
45
  value: JSON.stringify({
@@ -48,18 +48,18 @@ var F = ":column-order", M = ":column-visibility", f = 1, k = (e) => e ? `${e}${
48
48
  })
49
49
  } }
50
50
  }))), {
51
- orderKey: n,
51
+ orderKey: d,
52
52
  visibilityKey: a,
53
53
  order: b,
54
54
  visibility: u,
55
55
  migration: c
56
56
  };
57
57
  }, W = (e, i, t) => {
58
- const r = e.visibility && Object.fromEntries(Object.entries(e.visibility).filter(([o]) => p(o, i)));
58
+ const r = e.visibility && Object.fromEntries(Object.entries(e.visibility).filter(([s]) => p(s, i)));
59
59
  return {
60
60
  orderKey: e.orderKey,
61
61
  visibilityKey: e.visibilityKey,
62
- order: e.order && j(e.order, i.map((o) => o.id)),
62
+ order: e.order && j(e.order, i.map((s) => s.id)),
63
63
  visibility: r && Object.keys(r).length > 0 ? {
64
64
  ...t,
65
65
  ...r
@@ -77,41 +77,41 @@ var F = ":column-order", M = ":column-visibility", f = 1, k = (e) => e ? `${e}${
77
77
  r && !v.set(r.key, r.value) || v.remove(t);
78
78
  }, [i]), W(i, e.columns, e.defaultVisibility);
79
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([
80
+ const { enabled: t, definitionIds: r, defaultOrder: s, defaultVisibility: o, controlledVisibility: g } = i, n = {
81
+ signature: t ? JSON.stringify([
82
82
  r,
83
- o,
84
- Object.entries(s).sort()
85
- ]),
83
+ s,
84
+ Object.entries(o).sort()
85
+ ]) : "",
86
86
  definitionIds: r,
87
- defaultOrder: o,
88
- defaultVisibility: s
89
- }, n = V.get(e) ?? d, a = t && n.signature !== d.signature;
87
+ defaultOrder: s,
88
+ defaultVisibility: o
89
+ }, d = V.get(e) ?? n, a = t && d.signature !== "" && d.signature !== n.signature;
90
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);
91
+ const l = V.get(e);
92
+ if (V.set(e, n), !t || !l || l.signature === "" || l.signature === n.signature) return;
93
+ const c = e.getState().columnOrder, b = m(c, l.definitionIds).join() === m(l.defaultOrder, l.definitionIds).join() ? s : j(c, r);
94
94
  if (e.setColumnOrder(b), !g) {
95
- const u = e.getState().columnVisibility, l = {
96
- ...s,
97
- ...K(u, y.defaultVisibility)
95
+ const u = e.getState().columnVisibility, y = {
96
+ ...o,
97
+ ...K(u, l.defaultVisibility)
98
98
  };
99
- Y(l, u) || e.setColumnVisibility(l);
99
+ Y(y, u) || e.setColumnVisibility(y);
100
100
  }
101
101
  }, [
102
102
  e,
103
103
  t,
104
- d.signature
104
+ n.signature
105
105
  ]), a;
106
106
  }, Q = (e, i) => {
107
- const { saved: t, reconciling: r, defaultOrder: o, defaultVisibility: s, controlledVisibility: g } = i, d = A(e);
107
+ const { saved: t, reconciling: r, defaultOrder: s, defaultVisibility: o, controlledVisibility: g } = i;
108
108
  L({
109
109
  storageKey: t.orderKey,
110
110
  state: e.getState().columnOrder,
111
- defaultValue: o,
111
+ defaultValue: s,
112
112
  saved: t.order,
113
113
  settled: !r,
114
- toSignature: (n) => JSON.stringify(m(n, d)),
114
+ toSignature: (n) => JSON.stringify(m(n, A(e))),
115
115
  toStorage: (n) => JSON.stringify({
116
116
  v: f,
117
117
  order: C(n)
@@ -120,14 +120,14 @@ var F = ":column-order", M = ":column-visibility", f = 1, k = (e) => e ? `${e}${
120
120
  }), L({
121
121
  storageKey: t.visibilityKey,
122
122
  state: e.getState().columnVisibility,
123
- defaultValue: s,
123
+ defaultValue: o,
124
124
  saved: t.visibility,
125
125
  settled: !r,
126
126
  controlled: g,
127
- toSignature: (n) => h(n, s),
127
+ toSignature: (n) => h(n, o),
128
128
  toStorage: (n) => JSON.stringify({
129
129
  v: f,
130
- visibility: K(n, s)
130
+ visibility: K(n, o)
131
131
  }),
132
132
  applyState: (n) => e.setColumnVisibility(n)
133
133
  });