asma-ui-core 3.130.5 → 3.131.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.
@@ -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
+ };
@@ -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,110 +1,121 @@
1
- import { SELECT_COLUMN_ID as N } from "../types.js";
2
- import { ExpandedRowsFeature as L } from "../custom-features/expand-rows/ExpandRowsFeature.js";
3
- import { FocusedRowsFeature as T } from "../custom-features/focus-rows/FocusRowsFeature.js";
4
- import { OrderColumnsFeature as U } from "../custom-features/order-columns/OrderColumnsFeature.js";
1
+ import { SELECT_COLUMN_ID as L } from "../types.js";
2
+ import { ExpandedRowsFeature as V } 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 V } from "../custom-features/order-columns/usePersistColumnOrder.js";
7
- import { usePersistedColumnOrder as D } from "../custom-features/order-columns/usePersistedColumnOrder.js";
8
- import { getPersistedPageSizeKey as Z, usePersistedPageSize as A } from "./usePersistedPageSize.js";
9
- import { columnSizingSignature as G, getColumnSizingStorageKey as h, serializeColumnSizing as j, usePersistedColumnSizing as q } from "./useColumnSizingPersistence.js";
10
- import { getSortingStorageKey as B, readSortingFromStorage as J, serializeSorting as W, sortingSignature as k } from "./usePersistedSorting.js";
11
- import { usePersistedStateWriter as I } from "./usePersistedStateWriter.js";
12
- import { RowSelectionTooltipFeature as H } from "../custom-features/row-selection-tooltip/RowSelectionTooltipFeature.js";
13
- import { getLeafColumnInfos as Q } from "../helpers/columnIds.js";
14
- import { useEffect as K, useMemo as X, useRef as Y } from "react";
15
- import { getCoreRowModel as $, getExpandedRowModel as ee, getFilteredRowModel as te, getPaginationRowModel as oe, getSortedRowModel as ie, useReactTable as ne } from "@tanstack/react-table";
16
- var re = 100, ae = [], le = {}, we = (g) => {
17
- const { columns: c, data: O, initialState: l, pageSize: P, enableRowSelection: _, tableInstanceRef: C, locale: E, persistColumnOrderKey: u, uniqueKey: r, persistSorting: x, defaultColumn: p, ...o } = g, z = l?.sorting ?? ae, S = l?.columnSizing ?? le, R = g.enableColumnResizing ? {
18
- minSize: re,
19
- ...p
20
- } : p, F = Q(c, {
21
- defaultColumn: R,
6
+ import { usePersistColumnOrder as H } from "../custom-features/order-columns/usePersistColumnOrder.js";
7
+ import { usePersistedColumnOrder as U } from "../custom-features/order-columns/usePersistedColumnOrder.js";
8
+ import { getPersistedPageSizeKey as W, usePersistedPageSize as j } from "./usePersistedPageSize.js";
9
+ import { columnSizingSignature as q, getColumnSizingStorageKey as B, serializeColumnSizing as J, usePersistedColumnSizing as Z } from "./useColumnSizingPersistence.js";
10
+ import { getSortingStorageKey as k, readSortingFromStorage as A, 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
+ ]), h = $(S, {
28
+ defaultColumn: l,
22
29
  enableSorting: o.enableSorting,
23
30
  enableMultiSort: o.enableMultiSort
24
- }), y = D(u), M = g.enableColumnResizing ? r : void 0, v = h(M), m = q(M, S), a = x ? B(r) : void 0, d = X(() => a ? J(r, {
25
- sortableColumns: F.filter((t) => t.canSort),
31
+ }), y = U(m), b = E ? r : void 0, M = B(b), f = Z(b, d), a = _ ? k(r) : void 0, p = O(() => a ? A(r, {
32
+ sortableColumns: h.filter((t) => t.canSort),
26
33
  maxMultiSortColCount: o.maxMultiSortColCount
27
- }) : void 0, [a]), i = A(r) ?? P ?? 50, e = ne({
34
+ }) : void 0, [a]), i = j(r) ?? x ?? 50, e = se({
28
35
  _features: [
29
- L,
30
- T,
31
- U,
32
- H
36
+ V,
37
+ D,
38
+ G,
39
+ Y
33
40
  ],
34
- columns: c,
35
- data: O,
36
- meta: { locale: E ?? "en" },
41
+ columns: T,
42
+ data: I,
43
+ meta: {
44
+ locale: N ?? "en",
45
+ hideHeader: !!o.hideHeader
46
+ },
37
47
  initialState: {
38
48
  pagination: {
39
49
  pageIndex: 0,
40
50
  pageSize: i
41
51
  },
42
52
  columnVisibility: {
43
- ...l?.columnVisibility,
44
- [N]: !1
53
+ ...s?.columnVisibility,
54
+ [L]: !1
45
55
  },
46
56
  ...y && { columnOrder: y },
47
- ...l,
48
- ...m && { columnSizing: m },
49
- ...d !== void 0 && { sorting: d }
57
+ ...s,
58
+ ...f && { columnSizing: f },
59
+ ...p !== void 0 && { sorting: p }
50
60
  },
51
- enableRowSelection: _,
52
- getCoreRowModel: $(),
53
- getExpandedRowModel: ee(),
54
- getFilteredRowModel: te(),
55
- getSortedRowModel: ie(),
56
- getPaginationRowModel: oe(),
57
- getRowId: o.getRowId ?? ((t, se, b) => b ? [b.id, t.id].join(".") : t.id.toString()),
58
- defaultColumn: R,
59
- ...o
61
+ enableRowSelection: F,
62
+ getCoreRowModel: oe(),
63
+ getExpandedRowModel: ie(),
64
+ getFilteredRowModel: ne(),
65
+ getSortedRowModel: ae(),
66
+ getPaginationRowModel: re(),
67
+ getRowId: o.getRowId ?? ((t, ue, v) => v ? [v.id, t.id].join(".") : t.id.toString()),
68
+ defaultColumn: l,
69
+ ...o,
70
+ enableColumnResizing: c
60
71
  });
61
- C && (C.current = e), V(e, u), I({
72
+ C && (C.current = e), H(e, m), K({
62
73
  storageKey: a,
63
74
  state: e.getState().sorting,
64
- defaultValue: z,
65
- saved: d,
75
+ defaultValue: R,
76
+ saved: p,
66
77
  controlled: o.state?.sorting !== void 0,
67
- toSignature: k,
68
- toStorage: W,
78
+ toSignature: X,
79
+ toStorage: Q,
69
80
  applyState: (t) => e.setSorting(t)
70
- }), I({
71
- storageKey: v,
81
+ }), K({
82
+ storageKey: M,
72
83
  state: e.getState().columnSizing,
73
- defaultValue: S,
74
- saved: m,
84
+ defaultValue: d,
85
+ saved: f,
75
86
  settled: !e.getState().columnSizingInfo.isResizingColumn,
76
- toSignature: G,
77
- toStorage: j,
87
+ toSignature: q,
88
+ toStorage: J,
78
89
  applyState: (t) => e.setColumnSizing(t)
79
90
  }), e.resetColumnSettings = () => {
80
- e.setColumnOrder([]), e.setColumnSizing(S), a && e.setSorting(z);
91
+ e.setColumnOrder([]), e.setColumnSizing(d), a && e.setSorting(R);
81
92
  for (const t of [
82
93
  a,
83
- v,
84
- u
94
+ M,
95
+ m
85
96
  ]) t && w.remove(t);
86
97
  };
87
- const n = Z(r), s = e.getState().pagination?.pageSize, f = Y(void 0);
88
- return K(() => {
89
- f.current = void 0, e.getState().pagination?.pageSize !== i && (e.setPageIndex(0), e.setPageSize(i));
98
+ const n = W(r), g = e.getState().pagination?.pageSize, z = te(void 0);
99
+ return P(() => {
100
+ z.current = void 0, e.getState().pagination?.pageSize !== i && (e.setPageIndex(0), e.setPageSize(i));
90
101
  }, [
91
102
  i,
92
103
  n,
93
104
  e
94
- ]), K(() => {
95
- if (!(!n || s == null)) {
96
- if (f.current !== n) {
97
- if (s !== i) return;
98
- f.current = n;
105
+ ]), P(() => {
106
+ if (!(!n || g == null)) {
107
+ if (z.current !== n) {
108
+ if (g !== i) return;
109
+ z.current = n;
99
110
  }
100
- w.set(n, JSON.stringify(s));
111
+ w.set(n, JSON.stringify(g));
101
112
  }
102
113
  }, [
103
- s,
114
+ g,
104
115
  i,
105
116
  n
106
117
  ]), { table: e };
107
118
  };
108
119
  export {
109
- we as useStyledTable
120
+ Oe as useStyledTable
110
121
  };
@@ -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.130.5",
6
+ "version": "3.131.1",
7
7
  "type": "module",
8
8
  "sideEffects": [
9
9
  "**/*.css",