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.
- package/dist/asma-ui-core.css +1 -1
- package/dist/src/table/helpers/columnSizingDefaults.d.ts +41 -0
- package/dist/src/table/helpers/columnSizingDefaults.test.d.ts +1 -0
- package/dist/src/table/helpers/headerControls.d.ts +15 -0
- package/dist/src/table/hooks/useToggleMenuVisibility.hook.d.ts +2 -2
- package/dist/src/table/types.d.ts +28 -0
- package/dist/table/components/StyledTableIndex.js +1 -1
- package/dist/table/components/TableRow.js +36 -35
- package/dist/table/components/columns/action-column/components/HeaderActionMenu.js +6 -5
- package/dist/table/components/columns/selectColumn.js +8 -8
- package/dist/table/components/table-footer/TableRowCountSelect.js +6 -6
- package/dist/table/components/table-header/TableHeader.js +33 -30
- package/dist/table/components/table-header/TableHeaderCell.js +18 -17
- package/dist/table/helpers/columnSizingDefaults.js +29 -0
- package/dist/table/helpers/headerControls.js +8 -0
- package/dist/table/hooks/useStyledTable.js +80 -69
- package/dist/table/hooks/useToggleMenuVisibility.hook.js +24 -23
- package/package.json +1 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ColumnDefLike } from './columnIds';
|
|
2
|
+
/** UX round 4 (D16): the room a sortable column's triangle needs, in px. */
|
|
3
|
+
export declare const SORTABLE_EXTRA_WIDTH = 20;
|
|
4
|
+
/** ui-core's own minimum width of a resizable column. It does not grow with D16. */
|
|
5
|
+
export declare const RESIZABLE_MIN_SIZE = 100;
|
|
6
|
+
/** The parts of a column definition that decide its default width. */
|
|
7
|
+
export interface SizableColumnDef extends ColumnDefLike {
|
|
8
|
+
size?: number;
|
|
9
|
+
minSize?: number;
|
|
10
|
+
maxSize?: number;
|
|
11
|
+
}
|
|
12
|
+
interface ColumnSizingDefaultsOptions {
|
|
13
|
+
/** The table's own `defaultColumn`, which each column definition is merged over. */
|
|
14
|
+
defaultColumn?: SizableColumnDef;
|
|
15
|
+
/** The table's `enableSorting`. */
|
|
16
|
+
enableSorting?: boolean;
|
|
17
|
+
/** Whether the table can resize its columns (D15): only then does a column get ui-core's minimum width. */
|
|
18
|
+
canResize: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Resolves the default `size`, `minSize` and `maxSize` of every leaf column before TanStack sees the definitions
|
|
22
|
+
* (ASMA-8597, UX round 4, P2e). It changes defaults only: a width the user saved, an app's `initialState.columnSizing`
|
|
23
|
+
* and a controlled `state.columnSizing` are applied on top by TanStack as given (DEC-D16).
|
|
24
|
+
*
|
|
25
|
+
* - **D16, +20 px for a sortable column.** A data column that can sort (the rule `getLeafColumnInfos` already uses, which is
|
|
26
|
+
* TanStack's `getCanSort()` for a leaf) gets `size` + 20, where `size` is its own, else the table's `defaultColumn.size`,
|
|
27
|
+
* else TanStack's 150. Its `minSize` and `maxSize` grow by 20 when the column or `defaultColumn` sets them. A sortable
|
|
28
|
+
* column that opts out of resizing grows too (DEC-D16-OPTOUTS): it keeps no handle, and a `minSize === maxSize` column
|
|
29
|
+
* stays fixed, at the new width. Columns that cannot sort, group headers and ui-core's own columns are left as they are.
|
|
30
|
+
* - **DEC-NARROW, the minimum of a resizable column.** A column that sets no `minSize` gets the smaller of 100 px and its
|
|
31
|
+
* default width (its `size` after D16) as its minimum, so turning resizing on never widens a column past its default
|
|
32
|
+
* width. A column with no `size` at all keeps the 100 px minimum. A column that sets its own `minSize` keeps it.
|
|
33
|
+
* ui-core's own columns keep the 100 px minimum they have always had.
|
|
34
|
+
*/
|
|
35
|
+
export declare const resolveColumnSizingDefaults: <TDef extends SizableColumnDef>(columns: readonly TDef[], options: ColumnSizingDefaultsOptions) => TDef[];
|
|
36
|
+
/**
|
|
37
|
+
* Whether a column has a fixed width: it sets `maxSize` equal to `minSize`. Such a column has no resize handle (OQ-15,
|
|
38
|
+
* the apps' own decision), however resizing came to be on. Reads the resolved definition (`column.columnDef`).
|
|
39
|
+
*/
|
|
40
|
+
export declare const hasFixedWidth: (columnDef: Pick<SizableColumnDef, "minSize" | "maxSize">) => boolean;
|
|
41
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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
|
-
|
|
17
|
+
focusTableOnShiftTab?: boolean;
|
|
18
18
|
}
|
|
19
19
|
export declare const useToggleMenuVisibility: () => ToggleMenuVisibility;
|
|
20
|
-
export declare const useKeyboardSelectMenu: ({ optionCount, selectedIndex, onSelect,
|
|
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;
|
|
@@ -139,6 +151,22 @@ export type StyledTableProps<TData, TCustomData> = {
|
|
|
139
151
|
* makes `uniqueKey` alone enough and retires this prop (follow-up ASMA-8698).
|
|
140
152
|
*/
|
|
141
153
|
persistSorting?: boolean;
|
|
154
|
+
/**
|
|
155
|
+
* Whether the table's columns can be resized with the pointer. **On by default** (ASMA-8597, UX round 4, D15): every data
|
|
156
|
+
* column has a handle, except ui-core's own columns (select, expand, actions, drag handle, show full text), a column that
|
|
157
|
+
* opts out with `enableResizing: false` or has a fixed width (`minSize` equal to `maxSize`), and the last data column,
|
|
158
|
+
* which keeps filling the remaining width (unless the table sets `enableResizing`). `enableColumnResizing={false}` turns
|
|
159
|
+
* resizing off for the table.
|
|
160
|
+
*
|
|
161
|
+
* Saving the widths is a separate opt-in (D17): widths are read and written under `${uniqueKey}:column-sizing` only when
|
|
162
|
+
* a table sets `enableColumnResizing` itself, as `true`. A table that gets resizing from the default resizes in memory only.
|
|
163
|
+
* Give it a per-user `uniqueKey` (`getTableSettingsKey` of asma-core-helpers) and write `enableColumnResizing` to save.
|
|
164
|
+
*
|
|
165
|
+
* A column without a `minSize` gets the smaller of 100 px and its default width as its minimum. Every sortable data column
|
|
166
|
+
* is 20 px wider by default (so its sort triangle fits), and so are its `minSize` and `maxSize` when set; widths a user
|
|
167
|
+
* saved and the app's `initialState.columnSizing` are applied as given.
|
|
168
|
+
*/
|
|
169
|
+
enableColumnResizing?: boolean;
|
|
142
170
|
} & Omit<TTableOptions<TData>, 'getCoreRowModel' | 'getExpandedRowModel' | 'getFilteredRowModel' | 'getSortedRowModel'> & TFooter<TData>;
|
|
143
171
|
export declare const SELECT_COLUMN_ID = "select";
|
|
144
172
|
export declare const EXPAND_COLUMN_ID = "expand-column-id";
|
|
@@ -106,7 +106,7 @@ var Ve = (l) => {
|
|
|
106
106
|
children: [/* @__PURE__ */ t(se, {
|
|
107
107
|
table: a,
|
|
108
108
|
styledTableProps: o,
|
|
109
|
-
tableCanResize:
|
|
109
|
+
tableCanResize: o.enableColumnResizing ?? !0,
|
|
110
110
|
tableWidth: null,
|
|
111
111
|
columnWindow: j
|
|
112
112
|
}), /* @__PURE__ */ t(ie, {
|
|
@@ -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 {
|
|
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
|
|
7
|
-
import { Fragment as
|
|
8
|
-
import { useSortable as
|
|
9
|
-
import { flexRender as
|
|
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((
|
|
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
|
|
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 } =
|
|
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 =
|
|
28
|
-
|
|
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
|
-
|
|
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")
|
|
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),
|
|
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]),
|
|
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 ===
|
|
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"],
|
|
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 + (
|
|
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 &&
|
|
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(
|
|
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:
|
|
100
|
+
children: Le(e.column.columnDef.cell, e.getContext())
|
|
100
101
|
})]
|
|
101
102
|
})
|
|
102
103
|
}, e.id);
|
|
103
104
|
}, [
|
|
104
|
-
|
|
105
|
+
L,
|
|
105
106
|
E,
|
|
106
107
|
$,
|
|
107
108
|
a,
|
|
108
|
-
|
|
109
|
-
|
|
109
|
+
A,
|
|
110
|
+
K,
|
|
110
111
|
k,
|
|
111
112
|
u,
|
|
112
|
-
|
|
113
|
+
p,
|
|
113
114
|
t,
|
|
114
115
|
T,
|
|
115
116
|
d,
|
|
116
117
|
F,
|
|
117
118
|
H
|
|
118
119
|
]);
|
|
119
|
-
return /* @__PURE__ */ S(
|
|
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:
|
|
136
|
+
onMouseUp: pe,
|
|
136
137
|
onMouseDown: (e) => {
|
|
137
|
-
e.detail > 1 && !
|
|
138
|
+
e.detail > 1 && !A && z && e.preventDefault();
|
|
138
139
|
},
|
|
139
|
-
onKeyDownCapture:
|
|
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
|
-
|
|
166
|
-
|
|
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(
|
|
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
|
|
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
|
-
|
|
186
|
+
Ke as TableRow
|
|
186
187
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { cn as
|
|
2
|
-
import { StyledBadge as
|
|
3
|
-
import { PinIcon as
|
|
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(
|
|
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:
|
|
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
|
|
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
|
|
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":
|
|
26
|
+
tabIndex: e.options.meta?.hideHeader ? -1 : 0,
|
|
27
|
+
"aria-label": c.selectAll,
|
|
28
28
|
"aria-checked": e.getIsSomeRowsSelected() ? "mixed" : e.getIsAllRowsSelected(),
|
|
29
|
-
className:
|
|
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":
|
|
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:
|
|
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 ?
|
|
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
|
|
17
|
-
const e = l.getState().pagination.pageSize, c =
|
|
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]),
|
|
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:
|
|
33
|
+
selectedIndex: w,
|
|
34
34
|
onSelect: (o) => f(r[o]),
|
|
35
|
-
|
|
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
|
-
|
|
98
|
+
B as TableRowCountSelect
|
|
99
99
|
};
|
|
@@ -1,41 +1,44 @@
|
|
|
1
|
-
import { cn as
|
|
2
|
-
import { ACTIONS_COLUMN_ID as
|
|
3
|
-
import
|
|
1
|
+
import { cn as A } from "../../../helpers/cn.js";
|
|
2
|
+
import { ACTIONS_COLUMN_ID as O } from "../../types.js";
|
|
3
|
+
import p from "../StyledTable.module.js";
|
|
4
|
+
import { getActiveBodyRow as T, getLastHeaderControl as j } from "../../helpers/headerControls.js";
|
|
4
5
|
import { TableHeaderCell as u } from "./TableHeaderCell.js";
|
|
5
6
|
import "react";
|
|
6
|
-
import { jsx as o, jsxs as
|
|
7
|
+
import { jsx as o, jsxs as B } from "react/jsx-runtime";
|
|
7
8
|
import "@tanstack/react-table";
|
|
8
|
-
function
|
|
9
|
-
const { stickyHeader: S = !1, tableHeaderRef:
|
|
9
|
+
function v({ table: x, styledTableProps: n, tableCanResize: d, tableWidth: a, columnWindow: { paddingLeft: i, paddingRight: c, indexes: H } }) {
|
|
10
|
+
const { stickyHeader: g = !1, hideHeader: S = !1, tableHeaderRef: y, tableHeaderStyle: D = {} } = n, w = x.getHeaderGroups(), b = { ...D };
|
|
10
11
|
return /* @__PURE__ */ o("thead", {
|
|
11
|
-
className:
|
|
12
|
-
style:
|
|
13
|
-
ref:
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
className: A(p["table-header"], g && p["table-header--sticky"], n.tableHeaderClassName),
|
|
13
|
+
style: b,
|
|
14
|
+
ref: y,
|
|
15
|
+
"data-header-hidden": S ? "true" : void 0,
|
|
16
|
+
children: w.map((f) => {
|
|
17
|
+
const s = f.headers.map((e, t, r) => ({
|
|
16
18
|
header: e,
|
|
17
|
-
left: r.slice(0, t).reduce((
|
|
18
|
-
})),
|
|
19
|
+
left: r.slice(0, t).reduce((l, m) => l + (m.column.getSize() ?? 0), 0)
|
|
20
|
+
})), C = s.filter(({ header: e }) => e.column.columnDef.fixedLeft), N = s.filter(({ header: e }) => !e.column.columnDef.fixedLeft && !e.column.columnDef.fixedRight && e.column.id !== "actions"), h = s.filter(({ header: e }) => !!e.column.columnDef.fixedRight || e.column.id === "actions"), W = h.some(({ header: e }) => e.column.id === O), _ = h.map((e, t, r) => ({
|
|
19
21
|
...e,
|
|
20
|
-
right: r.slice(t + 1).reduce((
|
|
21
|
-
})),
|
|
22
|
+
right: r.slice(t + 1).reduce((l, m) => l + (m.header.column.getSize() ?? 0), 0) + (W ? -1 : 0)
|
|
23
|
+
})), k = H.reduce((e, t) => {
|
|
22
24
|
const r = N[t];
|
|
23
25
|
return r && e.push(r), e;
|
|
24
26
|
}, []);
|
|
25
|
-
return /* @__PURE__ */
|
|
26
|
-
tabIndex: 0,
|
|
27
|
+
return /* @__PURE__ */ B("tr", {
|
|
27
28
|
onKeyDown: (e) => {
|
|
28
|
-
if (e.key !== "Tab" || e.shiftKey || e.defaultPrevented
|
|
29
|
-
const t = e.currentTarget.closest("table")
|
|
30
|
-
|
|
29
|
+
if (e.key !== "Tab" || e.shiftKey || e.defaultPrevented) return;
|
|
30
|
+
const t = e.currentTarget.closest("table");
|
|
31
|
+
if (e.target !== j(t)) return;
|
|
32
|
+
const r = T(t);
|
|
33
|
+
r && (e.preventDefault(), r.focus());
|
|
31
34
|
},
|
|
32
35
|
children: [
|
|
33
|
-
|
|
36
|
+
C.map(({ header: e, left: t }) => /* @__PURE__ */ o(u, {
|
|
34
37
|
styledTableProps: n,
|
|
35
38
|
header: e,
|
|
36
|
-
tableCanResize:
|
|
39
|
+
tableCanResize: d,
|
|
37
40
|
left: t,
|
|
38
|
-
tableWidth:
|
|
41
|
+
tableWidth: a
|
|
39
42
|
}, e.id)),
|
|
40
43
|
i > 0 && /* @__PURE__ */ o("th", {
|
|
41
44
|
"aria-hidden": !0,
|
|
@@ -47,15 +50,15 @@ function M({ table: p, styledTableProps: n, tableCanResize: l, tableWidth: s, co
|
|
|
47
50
|
border: "none"
|
|
48
51
|
}
|
|
49
52
|
}),
|
|
50
|
-
|
|
53
|
+
k.map((e) => {
|
|
51
54
|
if (!e) return null;
|
|
52
55
|
const { header: t, left: r } = e;
|
|
53
56
|
return /* @__PURE__ */ o(u, {
|
|
54
57
|
styledTableProps: n,
|
|
55
58
|
header: t,
|
|
56
|
-
tableCanResize:
|
|
59
|
+
tableCanResize: d,
|
|
57
60
|
left: r,
|
|
58
|
-
tableWidth:
|
|
61
|
+
tableWidth: a
|
|
59
62
|
}, t.id);
|
|
60
63
|
}),
|
|
61
64
|
c > 0 && /* @__PURE__ */ o("th", {
|
|
@@ -68,13 +71,13 @@ function M({ table: p, styledTableProps: n, tableCanResize: l, tableWidth: s, co
|
|
|
68
71
|
border: "none"
|
|
69
72
|
}
|
|
70
73
|
}),
|
|
71
|
-
|
|
74
|
+
_.map(({ header: e, left: t, right: r }) => /* @__PURE__ */ o(u, {
|
|
72
75
|
styledTableProps: n,
|
|
73
76
|
header: e,
|
|
74
|
-
tableCanResize:
|
|
77
|
+
tableCanResize: d,
|
|
75
78
|
left: t,
|
|
76
79
|
right: r,
|
|
77
|
-
tableWidth:
|
|
80
|
+
tableWidth: a
|
|
78
81
|
}, e.id))
|
|
79
82
|
]
|
|
80
83
|
}, f.id);
|
|
@@ -82,5 +85,5 @@ function M({ table: p, styledTableProps: n, tableCanResize: l, tableWidth: s, co
|
|
|
82
85
|
});
|
|
83
86
|
}
|
|
84
87
|
export {
|
|
85
|
-
|
|
88
|
+
v as TableHeader
|
|
86
89
|
};
|
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
import { ACTIONS_COLUMN_ID as D, INTERNAL_COLUMN_IDS as R } from "../../types.js";
|
|
2
2
|
import { useRootContext as L } from "../../context/RootContext.js";
|
|
3
|
+
import { hasFixedWidth as A } from "../../helpers/columnSizingDefaults.js";
|
|
3
4
|
import e from "../StyledTable.module.js";
|
|
4
|
-
import { SortIndicator as
|
|
5
|
-
import { getTableHeaderStyle as
|
|
6
|
-
import { getSortPreview as
|
|
5
|
+
import { SortIndicator as O } from "./SortIndicator.js";
|
|
6
|
+
import { getTableHeaderStyle as E } from "../../helpers/getTableHeaderStyle.js";
|
|
7
|
+
import { getSortPreview as M } from "../../helpers/sortPreview.js";
|
|
7
8
|
import _ from "clsx";
|
|
8
|
-
import { useMemo as
|
|
9
|
-
import { jsx as l, jsxs as
|
|
10
|
-
import { flexRender as
|
|
11
|
-
function
|
|
12
|
-
const { hideHeader:
|
|
9
|
+
import { useMemo as r } from "react";
|
|
10
|
+
import { jsx as l, jsxs as k } from "react/jsx-runtime";
|
|
11
|
+
import { flexRender as B } from "@tanstack/react-table";
|
|
12
|
+
function Z({ styledTableProps: z, header: o, tableCanResize: b = !1, left: N, right: v, tableWidth: H }) {
|
|
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({
|
|
13
14
|
sorted: s,
|
|
14
15
|
firstDirection: o.column.getFirstSortDir(),
|
|
15
16
|
nextOrder: o.column.getNextSortingOrder(),
|
|
16
17
|
isLastSortEntry: x[x.length - 1]?.id === o.column.id
|
|
17
|
-
}), G = n ? s === "asc" ? "ascending" : s === "desc" ? "descending" : "none" : void 0, C = b && (m ? !0 : o.id !==
|
|
18
|
+
}), G = n ? s === "asc" ? "ascending" : s === "desc" ? "descending" : "none" : void 0, C = b && (m ? !0 : o.id !== y?.id) && o.column.getCanResize() && !A(o.column.columnDef) && !R.includes(o.column.id);
|
|
18
19
|
return /* @__PURE__ */ l("th", {
|
|
19
20
|
colSpan: o.colSpan,
|
|
20
21
|
"aria-sort": G,
|
|
21
|
-
className: _(e["t-cell"], !R.includes(o.column.id) && o.column.getSize() > 64 && e["data-cell"], o.column.id === "select" && e["select-cell"],
|
|
22
|
+
className: _(e["t-cell"], !R.includes(o.column.id) && o.column.getSize() > 64 && e["data-cell"], o.column.id === "select" && e["select-cell"], c && e["hide-header"], p && e["t-cell__actions"], p && (!h || w) && e["t-cell__actions--no-shadow"], g && e["t-cell__fixed"], f && e["t-cell__fixed-right"]),
|
|
22
23
|
style: {
|
|
23
|
-
...
|
|
24
|
+
...E({
|
|
24
25
|
enableResizing: m,
|
|
25
26
|
header: o,
|
|
26
27
|
tableWidth: H
|
|
@@ -28,10 +29,10 @@ function X({ styledTableProps: z, header: o, tableCanResize: b = !1, left: N, ri
|
|
|
28
29
|
...g && { left: N },
|
|
29
30
|
...f && { right: v }
|
|
30
31
|
},
|
|
31
|
-
children: /* @__PURE__ */
|
|
32
|
-
className: _("flex items-center justify-start",
|
|
32
|
+
children: /* @__PURE__ */ k("div", {
|
|
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),
|
|
33
34
|
role: n ? "button" : void 0,
|
|
34
|
-
tabIndex: n ? 0 : void 0,
|
|
35
|
+
tabIndex: n && !c ? 0 : void 0,
|
|
35
36
|
onClick: (t) => {
|
|
36
37
|
const i = o.column.getToggleSortingHandler();
|
|
37
38
|
!a && i && i(t), d();
|
|
@@ -45,9 +46,9 @@ function X({ styledTableProps: z, header: o, tableCanResize: b = !1, left: N, ri
|
|
|
45
46
|
children: [
|
|
46
47
|
/* @__PURE__ */ l("div", {
|
|
47
48
|
className: e["header-content"],
|
|
48
|
-
children:
|
|
49
|
+
children: B(o.column.columnDef.header, o.getContext())
|
|
49
50
|
}),
|
|
50
|
-
n && /* @__PURE__ */ l(
|
|
51
|
+
n && /* @__PURE__ */ l(O, {
|
|
51
52
|
sorted: s,
|
|
52
53
|
firstDirection: o.column.getFirstSortDir(),
|
|
53
54
|
preview: F
|
|
@@ -67,5 +68,5 @@ function X({ styledTableProps: z, header: o, tableCanResize: b = !1, left: N, ri
|
|
|
67
68
|
}, o.id);
|
|
68
69
|
}
|
|
69
70
|
export {
|
|
70
|
-
|
|
71
|
+
Z as TableHeaderCell
|
|
71
72
|
};
|