asma-ui-core 3.131.0 → 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,15 @@
1
+ /**
2
+ * The controls in a table's header that Tab reaches, in DOM order, which is visual order: the fixed-left headers
3
+ * render first and the fixed-right ones last, the pin included. `thead` belongs to this table only: a table nested in a
4
+ * row has its own. A hidden header (`hideHeader`, marked `data-header-hidden`) has none: its built-in controls are not
5
+ * tab stops, and the focus is never sent to a control a consumer puts in it. Such a control stays a tab stop the browser
6
+ * reaches (a hidden header must not contain consumer tab stops: they set `tabIndex={-1}`, see the `hideHeader` prop).
7
+ */
8
+ export declare const getHeaderControls: (table: HTMLTableElement | null | undefined) => HTMLElement[];
9
+ /** The control Tab leaves the header from, and Shift+Tab from the body returns to; `undefined` with no controls. */
10
+ export declare const getLastHeaderControl: (table: HTMLTableElement | null | undefined) => HTMLElement | undefined;
11
+ /**
12
+ * The body row that holds the roving tab stop: the row the user last worked with. Rows of a table nested in a row
13
+ * are not this table's, so only the direct rows of its own bodies are looked at.
14
+ */
15
+ export declare const getActiveBodyRow: (table: HTMLTableElement | null | undefined) => HTMLTableRowElement | undefined;
@@ -14,8 +14,8 @@ interface KeyboardSelectMenuOptions {
14
14
  optionCount: number;
15
15
  selectedIndex: number;
16
16
  onSelect: (index: number) => void;
17
- focusHeaderOnShiftTab?: boolean;
17
+ focusTableOnShiftTab?: boolean;
18
18
  }
19
19
  export declare const useToggleMenuVisibility: () => ToggleMenuVisibility;
20
- export declare const useKeyboardSelectMenu: ({ optionCount, selectedIndex, onSelect, focusHeaderOnShiftTab, }: KeyboardSelectMenuOptions) => KeyboardSelectMenu;
20
+ export declare const useKeyboardSelectMenu: ({ optionCount, selectedIndex, onSelect, focusTableOnShiftTab, }: KeyboardSelectMenuOptions) => KeyboardSelectMenu;
21
21
  export {};
@@ -26,6 +26,12 @@ declare module '@tanstack/react-table' {
26
26
  }
27
27
  interface TableMeta<TData extends RowData> {
28
28
  locale?: 'no' | 'en' | (TData extends never ? never : never);
29
+ /**
30
+ * @internal Set by `StyledTable` from its `hideHeader` prop, so that its own header controls (the sort header,
31
+ * the pin and the select-all checkbox) can drop their tab stops (ASMA-8702). Apps must not set it: the table
32
+ * writes it, and a `meta` an app passes replaces the table's. Use the `hideHeader` prop.
33
+ */
34
+ hideHeader?: boolean;
29
35
  }
30
36
  interface ColumnDefBase<TData extends RowData, TValue = unknown> extends ColumnDefExtensions<TData, TValue> {
31
37
  getUniqueValues?: AccessorFn<TData, unknown[]>;
@@ -114,6 +120,12 @@ export type StyledTableProps<TData, TCustomData> = {
114
120
  row: TData;
115
121
  }) => ReactElement | null;
116
122
  getRowSelectionIds?: (ids: string[]) => void;
123
+ /**
124
+ * Hides the header visually. It stays in the accessibility tree (column names and `aria-sort` are still announced)
125
+ * and its own controls (the sort header, the pin, the select-all checkbox) are not tab stops. **A hidden header must
126
+ * not contain tab stops of your own** (a button or link in a header cell): they stay tab stops with no visible focus.
127
+ * Give such a control `tabIndex={-1}`, or do not put one there (ASMA-8702).
128
+ */
117
129
  hideHeader?: boolean;
118
130
  pageSize?: number;
119
131
  enableResizing?: boolean;
@@ -1,21 +1,22 @@
1
1
  import { ACTIONS_COLUMN_ID as w, INTERNAL_COLUMN_IDS as Re } from "../types.js";
2
2
  import { useRootContext as Se } from "../context/RootContext.js";
3
3
  import n from "./StyledTable.module.js";
4
- import { compact as De } from "../../helpers/arrays.js";
4
+ import { getLastHeaderControl as De } from "../helpers/headerControls.js";
5
+ import { compact as Ne } from "../../helpers/arrays.js";
5
6
  import V from "clsx";
6
- import { Fragment as Ne, useCallback as Y, useEffect as ve, useLayoutEffect as Ee, useMemo as R, useRef as Ie, useState as ye } from "react";
7
- import { Fragment as Te, jsx as s, jsxs as S } from "react/jsx-runtime";
8
- import { useSortable as ke } from "@dnd-kit/sortable";
9
- import { flexRender as Fe } from "@tanstack/react-table";
7
+ import { Fragment as ve, useCallback as Y, useEffect as Ee, useLayoutEffect as Ie, useMemo as R, useRef as ye, useState as Te } from "react";
8
+ import { Fragment as ke, jsx as s, jsxs as S } from "react/jsx-runtime";
9
+ import { useSortable as Fe } from "@dnd-kit/sortable";
10
+ import { flexRender as Le } from "@tanstack/react-table";
10
11
  import { CSS as Ae } from "@dnd-kit/utilities";
11
12
  var J = (D, t) => {
12
13
  const g = D.closest("table");
13
14
  if (!g) return !1;
14
- const N = t === "next" ? Node.DOCUMENT_POSITION_FOLLOWING : Node.DOCUMENT_POSITION_PRECEDING, r = Array.from(document.querySelectorAll('a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])')).filter((p) => !g.contains(p) && !!(g.compareDocumentPosition(p) & N)), l = t === "next" ? r[0] : r.at(-1);
15
+ const N = t === "next" ? Node.DOCUMENT_POSITION_FOLLOWING : Node.DOCUMENT_POSITION_PRECEDING, r = Array.from(document.querySelectorAll('a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])')).filter((h) => !g.contains(h) && !!(g.compareDocumentPosition(h) & N)), l = t === "next" ? r[0] : r.at(-1);
15
16
  return l ? (l.focus(), document.activeElement === l) : !1;
16
17
  };
17
- function je({ styledTableProps: D, row: t, index: g, hasFocusedRow: N, columnWindow: { paddingLeft: r, paddingRight: l, indexes: p } }) {
18
- const { loading: Q, getRowClassName: a, activeRowId: _, rowHeight: x, onRowClick: v, expandArrow: X, enableDnd: B, disableDndForRow: Z, tdClassName: H, customSubRowData: U, renderSubRows: ee, defaultExpanded: te, actions: E, customActionsNode: ne, stickyActions: ie, textExpandArrow: z, enableMultiRowSelection: oe, enableRowSelection: se, singleSelectionRow: le } = D, I = Z?.(t), { transform: ae, transition: ce, setNodeRef: W, isDragging: P } = ke({
18
+ function Ke({ styledTableProps: D, row: t, index: g, hasFocusedRow: N, columnWindow: { paddingLeft: r, paddingRight: l, indexes: h } }) {
19
+ const { loading: Q, getRowClassName: a, activeRowId: _, rowHeight: x, onRowClick: v, expandArrow: X, enableDnd: B, disableDndForRow: Z, tdClassName: H, customSubRowData: U, renderSubRows: ee, defaultExpanded: te, actions: E, customActionsNode: ne, stickyActions: ie, textExpandArrow: z, enableMultiRowSelection: oe, enableRowSelection: se, singleSelectionRow: le } = D, I = Z?.(t), { transform: ae, transition: ce, setNodeRef: W, isDragging: P } = Fe({
19
20
  id: t.original.id,
20
21
  disabled: !B || I
21
22
  }), de = {
@@ -24,28 +25,28 @@ function je({ styledTableProps: D, row: t, index: g, hasFocusedRow: N, columnWin
24
25
  opacity: P ? 0.8 : 1,
25
26
  zIndex: P ? 1 : 0,
26
27
  position: "relative"
27
- }, { isResizing: re, disableResizingFlag: ue } = Se(), y = t.isExpanded(), C = Ie(null), [fe, me] = ye(void 0);
28
- Ee(() => {
28
+ }, { isResizing: re, disableResizingFlag: ue } = Se(), y = t.isExpanded(), C = ye(null), [fe, me] = Te(void 0);
29
+ Ie(() => {
29
30
  !y && C.current && me(C.current.cells[0]?.clientHeight ?? C.current.offsetHeight);
30
31
  }, [y]);
31
32
  const ge = Y((e) => {
32
33
  C.current = e, I || W(e);
33
34
  }, [I, W]), $ = y ? fe ?? x : x;
34
- ve(() => {
35
+ Ee(() => {
35
36
  te && t.getCanExpand() && !t.getIsExpanded() && t.toggleExpand();
36
37
  }, []);
37
38
  const j = (e) => {
38
39
  t.getCanExpand() && !X && t.getToggleExpandedHandler()(), document.getElementById(t.id)?.focus();
39
40
  const i = window.getSelection()?.type !== "Range" && !re, o = v instanceof Function;
40
41
  !o && z && i ? t.toggleExpand() : o && i && v(e, t), ue();
41
- }, he = (e) => {
42
- e.target.classList.contains("MuiModal-backdrop") || e.target.nodeName === "INPUT" || e.target.nodeName === "BUTTON" || e.target.nodeName === "LI" || e.target.closest("li") || j(e);
43
42
  }, pe = (e) => {
43
+ e.target.classList.contains("MuiModal-backdrop") || e.target.nodeName === "INPUT" || e.target.nodeName === "BUTTON" || e.target.nodeName === "LI" || e.target.closest("li") || j(e);
44
+ }, he = (e) => {
44
45
  if (e.target === e.currentTarget)
45
46
  switch (e.key) {
46
47
  case "Tab":
47
48
  if (e.shiftKey) {
48
- const i = e.currentTarget.closest("table")?.querySelector('thead tr[tabindex="0"]');
49
+ const i = De(e.currentTarget.closest("table"));
49
50
  i ? (e.preventDefault(), i.focus()) : J(e.currentTarget, "prev") && e.preventDefault();
50
51
  } else J(e.currentTarget, "next") && e.preventDefault();
51
52
  break;
@@ -62,16 +63,16 @@ function je({ styledTableProps: D, row: t, index: g, hasFocusedRow: N, columnWin
62
63
  }, c = t.getVisibleCells().map((e, i, o) => ({
63
64
  ...e,
64
65
  left: o.slice(0, i).reduce((f, m) => f + (m.column.getSize() ?? 0), 0)
65
- })), T = !!E || !!ne, k = c.some((e) => !!e.column.columnDef.fixedRight), d = ie ?? (T || k), q = R(() => c.filter((e) => !e.column.columnDef.fixedLeft && !e.column.columnDef.fixedRight && e.column.id !== "actions"), [c]), h = R(() => c.filter((e) => !!e.column.columnDef.fixedRight || e.column.id === "actions" && d).map((e, i, o) => ({
66
+ })), T = !!E || !!ne, k = c.some((e) => !!e.column.columnDef.fixedRight), d = ie ?? (T || k), G = R(() => c.filter((e) => !e.column.columnDef.fixedLeft && !e.column.columnDef.fixedRight && e.column.id !== "actions"), [c]), p = R(() => c.filter((e) => !!e.column.columnDef.fixedRight || e.column.id === "actions" && d).map((e, i, o) => ({
66
67
  ...e,
67
68
  right: o.slice(i + 1).reduce((f, m) => f + (m.column.getSize() ?? 0), 0)
68
- })), [c, d]), G = R(() => h.some((e) => e.column.id === w), [h]), K = d ? void 0 : c.find((e) => e.column.id === w), u = R(() => c.filter((e) => e.column.columnDef.fixedLeft), [c]), F = !oe && !se && le, A = t.getIsSelected() && F, L = v instanceof Function, M = p.length > 0 ? De(p.map((e) => q[e])) : q, b = Y((e, i) => {
69
- const o = e.column.id === w, f = e.column.columnDef.fixedLeft, m = !!e.column.columnDef.fixedRight, xe = e.id === u.at(-1)?.id, Ce = e.id === h.at(0)?.id && !o, be = t.isExpanded(), O = i === 0;
69
+ })), [c, d]), K = R(() => p.some((e) => e.column.id === w), [p]), q = d ? void 0 : c.find((e) => e.column.id === w), u = R(() => c.filter((e) => e.column.columnDef.fixedLeft), [c]), F = !oe && !se && le, L = t.getIsSelected() && F, A = v instanceof Function, M = h.length > 0 ? Ne(h.map((e) => G[e])) : G, b = Y((e, i) => {
70
+ const o = e.column.id === w, f = e.column.columnDef.fixedLeft, m = !!e.column.columnDef.fixedRight, xe = e.id === u.at(-1)?.id, Ce = e.id === p.at(0)?.id && !o, be = t.isExpanded(), O = i === 0;
70
71
  return /* @__PURE__ */ s("td", {
71
- className: V(n["t-cell"], !Re.includes(e.column.id) && e.column.getSize() > 64 && n["data-cell"], e.column.id === "select" && n["select-cell"], L && "cursor-pointer", H, o && d && n["action-cell"], o && d && (!T || k) && n["action-cell--no-shadow"], o && d && !!E && u.length && n.shadowed, o && d && (a?.(t) ? a?.(t) : n["action-cell-default-background"]), f && n["fixed-cell"], m && n["fixed-right-cell"], xe && n.shadowed, Ce && n["shadowed-right"], t.getIsSelected() && n.selected, f && (a?.(t) ? a?.(t) : n["fixed-cell-default-background"]), m && (a?.(t) ? a?.(t) : n["fixed-right-cell-default-background"]), be && n.expanded_row, !!A && n["single-selection"]),
72
+ className: V(n["t-cell"], !Re.includes(e.column.id) && e.column.getSize() > 64 && n["data-cell"], e.column.id === "select" && n["select-cell"], A && "cursor-pointer", H, o && d && n["action-cell"], o && d && (!T || k) && n["action-cell--no-shadow"], o && d && !!E && u.length && n.shadowed, o && d && (a?.(t) ? a?.(t) : n["action-cell-default-background"]), f && n["fixed-cell"], m && n["fixed-right-cell"], xe && n.shadowed, Ce && n["shadowed-right"], t.getIsSelected() && n.selected, f && (a?.(t) ? a?.(t) : n["fixed-cell-default-background"]), m && (a?.(t) ? a?.(t) : n["fixed-right-cell-default-background"]), be && n.expanded_row, !!L && n["single-selection"]),
72
73
  style: {
73
74
  left: f ? e.left : void 0,
74
- right: m ? e.right + (G ? -1 : 0) : void 0
75
+ right: m ? e.right + (K ? -1 : 0) : void 0
75
76
  },
76
77
  children: /* @__PURE__ */ S("div", {
77
78
  style: {
@@ -81,7 +82,7 @@ function je({ styledTableProps: D, row: t, index: g, hasFocusedRow: N, columnWin
81
82
  minHeight: $,
82
83
  position: "relative"
83
84
  },
84
- children: [O && A && /* @__PURE__ */ s("span", {
85
+ children: [O && L && /* @__PURE__ */ s("span", {
85
86
  style: {
86
87
  display: "inline-flex",
87
88
  alignItems: "center",
@@ -90,33 +91,33 @@ function je({ styledTableProps: D, row: t, index: g, hasFocusedRow: N, columnWin
90
91
  top: "50%",
91
92
  transform: "translateY(-50%)"
92
93
  },
93
- children: /* @__PURE__ */ s(Le, {})
94
+ children: /* @__PURE__ */ s(Me, {})
94
95
  }), /* @__PURE__ */ s("span", {
95
96
  style: {
96
97
  marginLeft: O && F ? 30 : 0,
97
98
  width: "100%"
98
99
  },
99
- children: Fe(e.column.columnDef.cell, e.getContext())
100
+ children: Le(e.column.columnDef.cell, e.getContext())
100
101
  })]
101
102
  })
102
103
  }, e.id);
103
104
  }, [
104
- A,
105
+ L,
105
106
  E,
106
107
  $,
107
108
  a,
108
- L,
109
- G,
109
+ A,
110
+ K,
110
111
  k,
111
112
  u,
112
- h,
113
+ p,
113
114
  t,
114
115
  T,
115
116
  d,
116
117
  F,
117
118
  H
118
119
  ]);
119
- return /* @__PURE__ */ S(Ne, { children: [/* @__PURE__ */ S("tr", {
120
+ return /* @__PURE__ */ S(ve, { children: [/* @__PURE__ */ S("tr", {
120
121
  "aria-selected": t.getIsSelected() || t.isFocused() ? "true" : "false",
121
122
  tabIndex: t.isFocused() || g === 0 && !N ? 0 : -1,
122
123
  "data-index": g,
@@ -132,11 +133,11 @@ function je({ styledTableProps: D, row: t, index: g, hasFocusedRow: N, columnWin
132
133
  onFocus: (e) => {
133
134
  e.target === e.currentTarget && !t.isFocused() && t.onChangeFocused(!0);
134
135
  },
135
- onMouseUp: he,
136
+ onMouseUp: pe,
136
137
  onMouseDown: (e) => {
137
- e.detail > 1 && !L && z && e.preventDefault();
138
+ e.detail > 1 && !A && z && e.preventDefault();
138
139
  },
139
- onKeyDownCapture: pe,
140
+ onKeyDownCapture: he,
140
141
  children: [
141
142
  u.map((e, i) => b(e, i)),
142
143
  r > 0 && /* @__PURE__ */ s("td", {
@@ -162,15 +163,15 @@ function je({ styledTableProps: D, row: t, index: g, hasFocusedRow: N, columnWin
162
163
  border: "none"
163
164
  }
164
165
  }),
165
- h.map((e, i) => b(e, u.length + M.length + i)),
166
- K && b(K, u.length + M.length + h.length)
166
+ p.map((e, i) => b(e, u.length + M.length + i)),
167
+ q && b(q, u.length + M.length + p.length)
167
168
  ]
168
- }), t.getIsExpanded() && /* @__PURE__ */ s(Te, { children: U && ee?.({
169
+ }), t.getIsExpanded() && /* @__PURE__ */ s(ke, { children: U && ee?.({
169
170
  rows: U.get(t.original.id.toString()) ?? [],
170
171
  row: t.original
171
172
  }) })] }, t.id);
172
173
  }
173
- var Le = () => /* @__PURE__ */ S("svg", {
174
+ var Me = () => /* @__PURE__ */ S("svg", {
174
175
  xmlns: "http://www.w3.org/2000/svg",
175
176
  width: "20",
176
177
  height: "20",
@@ -182,5 +183,5 @@ var Le = () => /* @__PURE__ */ S("svg", {
182
183
  })]
183
184
  });
184
185
  export {
185
- je as TableRow
186
+ Ke as TableRow
186
187
  };
@@ -1,6 +1,6 @@
1
- import { cn as N } from "../../../../../helpers/cn.js";
2
- import { StyledBadge as _ } from "../../../../../components/data-display/badge/StyledBadge.js";
3
- import { PinIcon as v } from "../../../../../components/icons/pin-icon/PinIcon.js";
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
4
  import { StyledPopover as D } from "../../../../../components/utils/popover/StyledPopover.js";
5
5
  import { message as T } from "../../../../../components/feedback/snack-bar/message.js";
6
6
  import { INTERNAL_COLUMN_IDS as L } from "../../../../types.js";
@@ -52,9 +52,10 @@ function be({ headerData: n, locale: p }) {
52
52
  "aria-label": m ? s.column_settings_changed : s.column_settings,
53
53
  "aria-haspopup": "true",
54
54
  "aria-expanded": c,
55
+ tabIndex: n.table.options.meta?.hideHeader ? -1 : void 0,
55
56
  className: f["actions-header"],
56
57
  onClick: g,
57
- children: [/* @__PURE__ */ o(v, { className: f["pin-icon"] }), m && /* @__PURE__ */ o(_, {
58
+ children: [/* @__PURE__ */ o(_, { className: f["pin-icon"] }), m && /* @__PURE__ */ o(N, {
58
59
  dataTest: "column-settings-dot",
59
60
  variant: "dot",
60
61
  purpose: "filter",
@@ -111,7 +112,7 @@ function be({ headerData: n, locale: p }) {
111
112
  userSelect: "none",
112
113
  WebkitTouchCallout: "none"
113
114
  },
114
- className: N(d["drag-icon"], r ? d["drag-icon--disabled"] : d["drag-icon--enabled"])
115
+ className: v(d["drag-icon"], r ? d["drag-icon--disabled"] : d["drag-icon--enabled"])
115
116
  }),
116
117
  /* @__PURE__ */ o("span", {
117
118
  className: "px-2",
@@ -1,5 +1,5 @@
1
1
  import { SELECT_COLUMN_ID as g } from "../../types.js";
2
- import c from "../StyledTable.module.js";
2
+ import n from "../StyledTable.module.js";
3
3
  import { StyledCheckbox as i } from "../../shared-components/StyledCheckbox.js";
4
4
  import { StyledTooltip as S } from "../../shared-components/tooltip/index.js";
5
5
  import { jsx as r } from "react/jsx-runtime";
@@ -15,7 +15,7 @@ var s = (o) => {
15
15
  selectRow: (l) => `Select row ${l}`
16
16
  };
17
17
  function v(o, l, m) {
18
- const n = h(m);
18
+ const c = h(m);
19
19
  return {
20
20
  id: g,
21
21
  minSize: 38,
@@ -23,10 +23,10 @@ function v(o, l, m) {
23
23
  size: 38,
24
24
  header: ({ table: e }) => /* @__PURE__ */ r("div", {
25
25
  role: "checkbox",
26
- tabIndex: 0,
27
- "aria-label": n.selectAll,
26
+ tabIndex: e.options.meta?.hideHeader ? -1 : 0,
27
+ "aria-label": c.selectAll,
28
28
  "aria-checked": e.getIsSomeRowsSelected() ? "mixed" : e.getIsAllRowsSelected(),
29
- className: c["select-control"],
29
+ className: n["select-control"],
30
30
  onClick: () => e.toggleAllRowsSelected(),
31
31
  onMouseDown: s,
32
32
  onMouseUp: s,
@@ -46,11 +46,11 @@ function v(o, l, m) {
46
46
  return /* @__PURE__ */ r("div", {
47
47
  role: "checkbox",
48
48
  tabIndex: t ? -1 : 0,
49
- "aria-label": n.selectRow(e.row.index + 1),
49
+ "aria-label": c.selectRow(e.row.index + 1),
50
50
  "aria-checked": e.row.getIsSelected(),
51
51
  "aria-disabled": t,
52
52
  style: { height: l ?? "auto" },
53
- className: c["select-control"],
53
+ className: n["select-control"],
54
54
  onClick: () => {
55
55
  t || e.row.toggleSelected();
56
56
  },
@@ -64,7 +64,7 @@ function v(o, l, m) {
64
64
  placement: "top-start",
65
65
  title: e.row.getRowSelectionTooltip(),
66
66
  children: /* @__PURE__ */ r("span", {
67
- className: t ? c["cursor-not-allowed"] : void 0,
67
+ className: t ? n["cursor-not-allowed"] : void 0,
68
68
  children: /* @__PURE__ */ r(i, {
69
69
  size: "small",
70
70
  dataTest: "cell-select",
@@ -13,8 +13,8 @@ var R = [
13
13
  50,
14
14
  100
15
15
  ];
16
- function A({ table: l, locale: w }) {
17
- const e = l.getState().pagination.pageSize, c = w === "no", t = N(), h = g(() => ({
16
+ function B({ table: l, locale: b }) {
17
+ const e = l.getState().pagination.pageSize, c = b === "no", t = N(), h = g(() => ({
18
18
  anchorOrigin: {
19
19
  vertical: -5,
20
20
  horizontal: "center"
@@ -28,11 +28,11 @@ function A({ table: l, locale: w }) {
28
28
  return Array.from(o).sort((a, i) => a - i);
29
29
  }, [e]), f = D((o) => {
30
30
  l.setPageSize(o);
31
- }, [l]), b = r.indexOf(e), { anchorEl: d, open: n, handleClose: u, handleOpen: v, triggerRef: S, activeIndex: p, handleKeyDown: x } = $({
31
+ }, [l]), w = r.indexOf(e), { anchorEl: d, open: n, handleClose: u, handleOpen: v, triggerRef: S, activeIndex: p, handleKeyDown: x } = $({
32
32
  optionCount: r.length,
33
- selectedIndex: b,
33
+ selectedIndex: w,
34
34
  onSelect: (o) => f(r[o]),
35
- focusHeaderOnShiftTab: !0
35
+ focusTableOnShiftTab: !0
36
36
  });
37
37
  return /* @__PURE__ */ m(P, { children: [/* @__PURE__ */ m(k, {
38
38
  dataTest: "table-rows-count-button",
@@ -95,5 +95,5 @@ function A({ table: l, locale: w }) {
95
95
  })] });
96
96
  }
97
97
  export {
98
- A as TableRowCountSelect
98
+ B as TableRowCountSelect
99
99
  };
@@ -1,41 +1,44 @@
1
- import { cn as k } from "../../../helpers/cn.js";
2
- import { ACTIONS_COLUMN_ID as C } from "../../types.js";
3
- import x from "../StyledTable.module.js";
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 I } from "react/jsx-runtime";
7
+ import { jsx as o, jsxs as B } from "react/jsx-runtime";
7
8
  import "@tanstack/react-table";
8
- function M({ table: p, styledTableProps: n, tableCanResize: l, tableWidth: s, columnWindow: { paddingLeft: i, paddingRight: c, indexes: H } }) {
9
- const { stickyHeader: S = !1, tableHeaderRef: g, tableHeaderStyle: y = {} } = n, b = p.getHeaderGroups(), D = { ...y };
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: k(x["table-header"], S && x["table-header--sticky"], n.tableHeaderClassName),
12
- style: D,
13
- ref: g,
14
- children: b.map((f) => {
15
- const a = f.headers.map((e, t, r) => ({
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((d, m) => d + (m.column.getSize() ?? 0), 0)
18
- })), w = a.filter(({ header: e }) => e.column.columnDef.fixedLeft), N = a.filter(({ header: e }) => !e.column.columnDef.fixedLeft && !e.column.columnDef.fixedRight && e.column.id !== "actions"), h = a.filter(({ header: e }) => !!e.column.columnDef.fixedRight || e.column.id === "actions"), T = h.some(({ header: e }) => e.column.id === C), W = h.map((e, t, r) => ({
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((d, m) => d + (m.header.column.getSize() ?? 0), 0) + (T ? -1 : 0)
21
- })), _ = H.reduce((e, t) => {
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__ */ I("tr", {
26
- tabIndex: 0,
27
+ return /* @__PURE__ */ B("tr", {
27
28
  onKeyDown: (e) => {
28
- if (e.key !== "Tab" || e.shiftKey || e.defaultPrevented || e.target !== e.currentTarget) return;
29
- const t = e.currentTarget.closest("table")?.querySelector('tbody tr[tabindex="0"]');
30
- t && (e.preventDefault(), t.focus());
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
- w.map(({ header: e, left: t }) => /* @__PURE__ */ o(u, {
36
+ C.map(({ header: e, left: t }) => /* @__PURE__ */ o(u, {
34
37
  styledTableProps: n,
35
38
  header: e,
36
- tableCanResize: l,
39
+ tableCanResize: d,
37
40
  left: t,
38
- tableWidth: s
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
- _.map((e) => {
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: l,
59
+ tableCanResize: d,
57
60
  left: r,
58
- tableWidth: s
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
- W.map(({ header: e, left: t, right: r }) => /* @__PURE__ */ o(u, {
74
+ _.map(({ header: e, left: t, right: r }) => /* @__PURE__ */ o(u, {
72
75
  styledTableProps: n,
73
76
  header: e,
74
- tableCanResize: l,
77
+ tableCanResize: d,
75
78
  left: t,
76
79
  right: r,
77
- tableWidth: s
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
- M as TableHeader
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 c } from "react";
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: 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
+ 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"], 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
+ 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", r ? e["hide-table-header"] : e["show-table-header"], n && e["sortable-column"], C && e["has-resize-zone"], o.column.columnDef.className),
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();
@@ -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,13 +1,13 @@
1
- import { SELECT_COLUMN_ID as V } from "../types.js";
2
- import { ExpandedRowsFeature as h } from "../custom-features/expand-rows/ExpandRowsFeature.js";
1
+ import { SELECT_COLUMN_ID as L } from "../types.js";
2
+ import { ExpandedRowsFeature as V } from "../custom-features/expand-rows/ExpandRowsFeature.js";
3
3
  import { FocusedRowsFeature as D } from "../custom-features/focus-rows/FocusRowsFeature.js";
4
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 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";
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
11
  import { usePersistedStateWriter as K } from "./usePersistedStateWriter.js";
12
12
  import { RowSelectionTooltipFeature as Y } from "../custom-features/row-selection-tooltip/RowSelectionTooltipFeature.js";
13
13
  import { getLeafColumnInfos as $ } from "../helpers/columnIds.js";
@@ -24,23 +24,26 @@ var le = [], ge = {}, Oe = (u) => {
24
24
  l,
25
25
  o.enableSorting,
26
26
  c
27
- ]), L = $(S, {
27
+ ]), h = $(S, {
28
28
  defaultColumn: l,
29
29
  enableSorting: o.enableSorting,
30
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),
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),
33
33
  maxMultiSortColCount: o.maxMultiSortColCount
34
- }) : void 0, [a]), i = q(r) ?? x ?? 50, e = se({
34
+ }) : void 0, [a]), i = j(r) ?? x ?? 50, e = se({
35
35
  _features: [
36
- h,
36
+ V,
37
37
  D,
38
38
  G,
39
39
  Y
40
40
  ],
41
41
  columns: T,
42
42
  data: I,
43
- meta: { locale: N ?? "en" },
43
+ meta: {
44
+ locale: N ?? "en",
45
+ hideHeader: !!o.hideHeader
46
+ },
44
47
  initialState: {
45
48
  pagination: {
46
49
  pageIndex: 0,
@@ -48,7 +51,7 @@ var le = [], ge = {}, Oe = (u) => {
48
51
  },
49
52
  columnVisibility: {
50
53
  ...s?.columnVisibility,
51
- [V]: !1
54
+ [L]: !1
52
55
  },
53
56
  ...y && { columnOrder: y },
54
57
  ...s,
@@ -66,7 +69,7 @@ var le = [], ge = {}, Oe = (u) => {
66
69
  ...o,
67
70
  enableColumnResizing: c
68
71
  });
69
- C && (C.current = e), U(e, m), K({
72
+ C && (C.current = e), H(e, m), K({
70
73
  storageKey: a,
71
74
  state: e.getState().sorting,
72
75
  defaultValue: R,
@@ -81,8 +84,8 @@ var le = [], ge = {}, Oe = (u) => {
81
84
  defaultValue: d,
82
85
  saved: f,
83
86
  settled: !e.getState().columnSizingInfo.isResizingColumn,
84
- toSignature: J,
85
- toStorage: k,
87
+ toSignature: q,
88
+ toStorage: J,
86
89
  applyState: (t) => e.setColumnSizing(t)
87
90
  }), e.resetColumnSettings = () => {
88
91
  e.setColumnOrder([]), e.setColumnSizing(d), a && e.setSorting(R);
@@ -92,7 +95,7 @@ var le = [], ge = {}, Oe = (u) => {
92
95
  m
93
96
  ]) t && w.remove(t);
94
97
  };
95
- const n = j(r), g = e.getState().pagination?.pageSize, z = te(void 0);
98
+ const n = W(r), g = e.getState().pagination?.pageSize, z = te(void 0);
96
99
  return P(() => {
97
100
  z.current = void 0, e.getState().pagination?.pageSize !== i && (e.setPageIndex(0), e.setPageSize(i));
98
101
  }, [
@@ -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.131.1",
7
7
  "type": "module",
8
8
  "sideEffects": [
9
9
  "**/*.css",