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