@eifi1/ui-kit 0.48.0 → 0.48.2
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/README.md +4 -3
- package/dist/components/data-table-fit.d.ts +8 -1
- package/dist/components/data-table-fit.js +7 -1
- package/dist/components/data-table-fit.js.map +1 -1
- package/dist/components/data-table-groups.d.ts +3 -1
- package/dist/components/data-table-groups.js +11 -5
- package/dist/components/data-table-groups.js.map +1 -1
- package/dist/components/data-table-head.d.ts +8 -1
- package/dist/components/data-table-head.js +11 -3
- package/dist/components/data-table-head.js.map +1 -1
- package/dist/components/data-table-leading-row.d.ts +3 -1
- package/dist/components/data-table-leading-row.js +2 -1
- package/dist/components/data-table-leading-row.js.map +1 -1
- package/dist/components/data-table-row-actions.js +2 -2
- package/dist/components/data-table-row-actions.js.map +1 -1
- package/dist/components/data-table-row.d.ts +84 -0
- package/dist/components/data-table-row.js +261 -0
- package/dist/components/data-table-row.js.map +1 -0
- package/dist/components/data-table-selection.d.ts +3 -0
- package/dist/components/data-table-selection.js +12 -1
- package/dist/components/data-table-selection.js.map +1 -1
- package/dist/components/data-table-virtual.d.ts +98 -0
- package/dist/components/data-table-virtual.js +369 -0
- package/dist/components/data-table-virtual.js.map +1 -0
- package/dist/components/data-table.d.ts +58 -2
- package/dist/components/data-table.js +227 -230
- package/dist/components/data-table.js.map +1 -1
- package/dist/data-table.d.ts +1 -0
- package/dist/data-table.js.map +1 -1
- package/dist/eslint/index.js +1 -1
- package/dist/hooks/use-anchored-panel.js +2 -1
- package/dist/hooks/use-anchored-panel.js.map +1 -1
- package/dist/shell/app-shell.js +7 -1
- package/dist/shell/app-shell.js.map +1 -1
- package/package.json +1 -1
- package/src/components/data-table-fit.ts +17 -2
- package/src/components/data-table-groups.tsx +15 -4
- package/src/components/data-table-head.tsx +25 -2
- package/src/components/data-table-leading-row.tsx +4 -1
- package/src/components/data-table-row-actions.tsx +3 -2
- package/src/components/data-table-row.tsx +483 -0
- package/src/components/data-table-selection.ts +17 -1
- package/src/components/data-table-virtual.ts +547 -0
- package/src/components/data-table.tsx +326 -327
- package/src/data-table.ts +2 -0
- package/src/hooks/use-anchored-panel.ts +9 -1
- package/src/shell/app-shell.tsx +7 -1
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { ReactNode, RefObject } from "react";
|
|
2
|
+
import { type MobileRowProps } from "./data-table-mobile.js";
|
|
3
|
+
import type { DataTableColumn, MobileSwipeActions } from "./data-table.js";
|
|
4
|
+
/** What a row's handlers read at event time — DataTable's latest props and helpers. */
|
|
5
|
+
export interface DataTableRowCtx<T> {
|
|
6
|
+
onRowClick: ((row: T) => void) | undefined;
|
|
7
|
+
onToggle: ((row: T, checked: boolean) => void) | undefined;
|
|
8
|
+
isSelected: (row: T) => boolean;
|
|
9
|
+
canSelect: (row: T) => boolean;
|
|
10
|
+
selectRange: (toIndex: number) => boolean;
|
|
11
|
+
/** Anchor the next Shift+click range on this row's key. */
|
|
12
|
+
setAnchor: (key: string | number) => void;
|
|
13
|
+
/** Remember the checkbox click that drew a range… */
|
|
14
|
+
markRangeClick: (e: Event) => void;
|
|
15
|
+
/** …and drop that click's own change event (true once for it). */
|
|
16
|
+
takeRangeClick: (e: Event) => boolean;
|
|
17
|
+
setFocusRowKey: (key: string | number) => void;
|
|
18
|
+
/** The phone card's long press: enter selection mode with this row selected. */
|
|
19
|
+
onLongPress: (row: T) => void;
|
|
20
|
+
/** Under `virtualize` (0.48.2): Arrow/Home/End over every row, rendered or not. True
|
|
21
|
+
* when the key was one of them. Without it the roving walks the rendered rows. */
|
|
22
|
+
moveFocus?: (fromIndex: number, key: string) => boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface DataTableRowProps<T> {
|
|
25
|
+
row: T;
|
|
26
|
+
rowIndex: number;
|
|
27
|
+
rowKey: string | number;
|
|
28
|
+
ctx: RefObject<DataTableRowCtx<T>>;
|
|
29
|
+
columns: DataTableColumn<T>[];
|
|
30
|
+
widths: Record<string, number>;
|
|
31
|
+
growDrawn: boolean;
|
|
32
|
+
linkColumn: DataTableColumn<T> | undefined;
|
|
33
|
+
href: string | undefined;
|
|
34
|
+
/** The selection column is drawn (DataTable's `selection`). */
|
|
35
|
+
selectionColumn: boolean;
|
|
36
|
+
selectable: boolean;
|
|
37
|
+
selected: boolean;
|
|
38
|
+
expanded: boolean;
|
|
39
|
+
/** The open row's detail; `null` on a closed row. */
|
|
40
|
+
expansion: ReactNode;
|
|
41
|
+
/** The row carries the visually hidden disclosure button (focusable rows that expand). */
|
|
42
|
+
disclosure: boolean;
|
|
43
|
+
detailId: string;
|
|
44
|
+
rowsFocusable: boolean;
|
|
45
|
+
rowInteractive: boolean;
|
|
46
|
+
tabbable: boolean;
|
|
47
|
+
className: string | undefined;
|
|
48
|
+
attrs: Record<string, string | undefined> | undefined;
|
|
49
|
+
compact: boolean;
|
|
50
|
+
totalColSpan: number;
|
|
51
|
+
rowDetailsLabel: string;
|
|
52
|
+
selectRowLabel: string;
|
|
53
|
+
/** Under `virtualize` (0.48.2): the row's `aria-rowindex` (its open detail row is the
|
|
54
|
+
* next), and the row is marked with its index for the window's measuring. */
|
|
55
|
+
ariaRowIndex?: number;
|
|
56
|
+
}
|
|
57
|
+
/** One desktop row (its `<tr>` and, while open, its detail row), memoised — see the
|
|
58
|
+
* file's note for what it compares. */
|
|
59
|
+
export declare const DataTableRow: <T>(props: DataTableRowProps<T> & {
|
|
60
|
+
key?: string | number;
|
|
61
|
+
}) => ReactNode;
|
|
62
|
+
export interface DataTableMobileRowProps<T> extends Pick<MobileRowProps<T>, "row" | "opensRow" | "mobileDir" | "mobileCardLinkable" | "mobileCard" | "mobilePrimaryCol" | "mobileSecondaryColumns" | "mobileExpandAsDialog" | "compact" | "large"> {
|
|
63
|
+
ctx: RefObject<DataTableRowCtx<T>>;
|
|
64
|
+
rowKey: string | number;
|
|
65
|
+
expanded: boolean;
|
|
66
|
+
/** The opened row's content (`openedRowContent`); `null` on a closed card. */
|
|
67
|
+
expansion: ReactNode;
|
|
68
|
+
className: string | undefined;
|
|
69
|
+
attrs: Record<string, string | undefined> | undefined;
|
|
70
|
+
/** The table has `onRowClick`. */
|
|
71
|
+
interactive: boolean;
|
|
72
|
+
href: string | undefined;
|
|
73
|
+
/** `mobileSwipeActions`, or the swipes derived from `rowActions` — by identity. */
|
|
74
|
+
swipeActionsFor: ((row: T) => MobileSwipeActions | null) | undefined;
|
|
75
|
+
/** The table has `selection`. */
|
|
76
|
+
selectionOn: boolean;
|
|
77
|
+
selectActive: boolean;
|
|
78
|
+
selectable: boolean;
|
|
79
|
+
selected: boolean;
|
|
80
|
+
}
|
|
81
|
+
/** One phone card, memoised like {@link DataTableRow}. */
|
|
82
|
+
export declare const DataTableMobileRow: <T>(props: DataTableMobileRowProps<T> & {
|
|
83
|
+
key?: string | number;
|
|
84
|
+
}) => ReactNode;
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { createElement } from "react";
|
|
4
|
+
import { Fragment, memo } from "react";
|
|
5
|
+
import { RowLink, cleanAttrs, fromOutside, fromOwnControl, logicalAlign, splitCellProps } from "./data-table-shared.js";
|
|
6
|
+
import { GROW_CELL_CLASS, GROW_PEER_CELL_CLASS } from "./data-table-fit.js";
|
|
7
|
+
import { MobileRow } from "./data-table-mobile.js";
|
|
8
|
+
import { cn } from "../lib/cn.js";
|
|
9
|
+
function sameAttrs(a, b) {
|
|
10
|
+
if (a === b) return true;
|
|
11
|
+
if (!a || !b) return false;
|
|
12
|
+
const ak = Object.keys(a);
|
|
13
|
+
if (ak.length !== Object.keys(b).length) return false;
|
|
14
|
+
for (const k of ak) if (a[k] !== b[k]) return false;
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
function sameProps(prev, next) {
|
|
18
|
+
for (const k of Object.keys(next)) {
|
|
19
|
+
if (k === "attrs") continue;
|
|
20
|
+
if (!Object.is(prev[k], next[k])) return false;
|
|
21
|
+
}
|
|
22
|
+
return sameAttrs(prev.attrs, next.attrs);
|
|
23
|
+
}
|
|
24
|
+
function moveRowFocus(from, key) {
|
|
25
|
+
if (!(key in ROW_NAV_KEYS)) return false;
|
|
26
|
+
const table = from.closest("table");
|
|
27
|
+
if (!table) return false;
|
|
28
|
+
const rows = Array.from(table.tBodies).flatMap(
|
|
29
|
+
(body) => Array.from(body.children).filter(
|
|
30
|
+
(el) => el instanceof HTMLElement && el.hasAttribute("data-row-nav")
|
|
31
|
+
)
|
|
32
|
+
);
|
|
33
|
+
const i = rows.indexOf(from);
|
|
34
|
+
const target = key === "ArrowDown" ? rows[i + 1] : key === "ArrowUp" ? rows[i - 1] : key === "Home" ? rows[0] : key === "End" ? rows[rows.length - 1] : void 0;
|
|
35
|
+
target?.focus();
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
const ROW_NAV_KEYS = { ArrowDown: 1, ArrowUp: 1, Home: 1, End: 1 };
|
|
39
|
+
function DataTableRowImpl({
|
|
40
|
+
row,
|
|
41
|
+
rowIndex,
|
|
42
|
+
rowKey: key,
|
|
43
|
+
ctx,
|
|
44
|
+
columns,
|
|
45
|
+
widths,
|
|
46
|
+
growDrawn,
|
|
47
|
+
linkColumn,
|
|
48
|
+
href,
|
|
49
|
+
selectionColumn,
|
|
50
|
+
selectable,
|
|
51
|
+
selected,
|
|
52
|
+
expanded,
|
|
53
|
+
expansion,
|
|
54
|
+
disclosure: hasDisclosure,
|
|
55
|
+
detailId,
|
|
56
|
+
rowsFocusable,
|
|
57
|
+
rowInteractive,
|
|
58
|
+
tabbable,
|
|
59
|
+
className,
|
|
60
|
+
attrs,
|
|
61
|
+
compact,
|
|
62
|
+
totalColSpan,
|
|
63
|
+
rowDetailsLabel,
|
|
64
|
+
selectRowLabel,
|
|
65
|
+
ariaRowIndex
|
|
66
|
+
}) {
|
|
67
|
+
const windowed = ariaRowIndex !== void 0;
|
|
68
|
+
const disclosure = hasDisclosure ? /* @__PURE__ */ jsx(
|
|
69
|
+
"button",
|
|
70
|
+
{
|
|
71
|
+
type: "button",
|
|
72
|
+
tabIndex: -1,
|
|
73
|
+
className: "sr-only-fixed",
|
|
74
|
+
"aria-label": rowDetailsLabel,
|
|
75
|
+
"aria-expanded": expanded,
|
|
76
|
+
"aria-controls": expansion ? detailId : void 0,
|
|
77
|
+
onClick: () => ctx.current.onRowClick(row)
|
|
78
|
+
}
|
|
79
|
+
) : null;
|
|
80
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
81
|
+
/* @__PURE__ */ jsxs(
|
|
82
|
+
"tr",
|
|
83
|
+
{
|
|
84
|
+
...cleanAttrs(attrs),
|
|
85
|
+
"aria-rowindex": ariaRowIndex,
|
|
86
|
+
"data-row-index": windowed ? rowIndex : void 0,
|
|
87
|
+
"data-row-nav": rowsFocusable ? "" : void 0,
|
|
88
|
+
tabIndex: rowsFocusable ? tabbable ? 0 : -1 : void 0,
|
|
89
|
+
onFocus: rowsFocusable ? (e) => {
|
|
90
|
+
if (e.target === e.currentTarget) ctx.current.setFocusRowKey(key);
|
|
91
|
+
} : void 0,
|
|
92
|
+
onKeyDown: rowsFocusable ? (e) => {
|
|
93
|
+
if (e.target !== e.currentTarget) return;
|
|
94
|
+
if (e.altKey || e.ctrlKey || e.metaKey) return;
|
|
95
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
96
|
+
e.preventDefault();
|
|
97
|
+
ctx.current.onRowClick(row);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (e.shiftKey) return;
|
|
101
|
+
const move = ctx.current.moveFocus;
|
|
102
|
+
if (move ? move(rowIndex, e.key) : moveRowFocus(e.currentTarget, e.key)) e.preventDefault();
|
|
103
|
+
} : void 0,
|
|
104
|
+
className: cn(
|
|
105
|
+
"border-t border-subtle",
|
|
106
|
+
rowInteractive && "cursor-pointer hover:bg-hover",
|
|
107
|
+
// The kit's focus frame width (§5, `--focus-ring-width`), drawn as an
|
|
108
|
+
// OUTLINE rather than FOCUS_RING's box-shadow: a shadow on a `<tr>`
|
|
109
|
+
// is not painted by every engine, an outline is.
|
|
110
|
+
rowsFocusable && "focus-visible:bg-hover focus-visible:outline-focus focus-visible:-outline-offset-2 focus-visible:outline-brand",
|
|
111
|
+
className
|
|
112
|
+
),
|
|
113
|
+
onClick: rowInteractive ? (e) => {
|
|
114
|
+
const c = ctx.current;
|
|
115
|
+
if (fromOwnControl(e.target, e.currentTarget)) return;
|
|
116
|
+
if (fromOutside(e.target, e.currentTarget)) return;
|
|
117
|
+
if (c.onToggle && c.canSelect(row)) {
|
|
118
|
+
if (e.shiftKey) {
|
|
119
|
+
window.getSelection?.()?.removeAllRanges();
|
|
120
|
+
if (c.selectRange(rowIndex)) return;
|
|
121
|
+
c.setAnchor(key);
|
|
122
|
+
c.onToggle(row, !c.isSelected(row));
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (e.metaKey || e.ctrlKey) {
|
|
126
|
+
c.setAnchor(key);
|
|
127
|
+
c.onToggle(row, !c.isSelected(row));
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
c.onRowClick?.(row);
|
|
132
|
+
} : void 0,
|
|
133
|
+
children: [
|
|
134
|
+
selectionColumn && /* @__PURE__ */ jsx(
|
|
135
|
+
"td",
|
|
136
|
+
{
|
|
137
|
+
className: cn("align-top", compact ? "w-8 px-2 py-1" : "w-10 px-3 py-2"),
|
|
138
|
+
onClick: (e) => e.stopPropagation(),
|
|
139
|
+
children: selectable && /* @__PURE__ */ jsx(
|
|
140
|
+
"input",
|
|
141
|
+
{
|
|
142
|
+
type: "checkbox",
|
|
143
|
+
className: cn("accent-indigo-600", compact ? "size-3.5" : "size-4"),
|
|
144
|
+
checked: selected,
|
|
145
|
+
onClick: (e) => {
|
|
146
|
+
if (e.shiftKey && ctx.current.selectRange(rowIndex)) {
|
|
147
|
+
e.preventDefault();
|
|
148
|
+
ctx.current.markRangeClick(e.nativeEvent);
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
onChange: (e) => {
|
|
152
|
+
const c = ctx.current;
|
|
153
|
+
if (c.takeRangeClick(e.nativeEvent)) return;
|
|
154
|
+
c.setAnchor(key);
|
|
155
|
+
c.onToggle?.(row, e.target.checked);
|
|
156
|
+
},
|
|
157
|
+
"aria-label": selectRowLabel
|
|
158
|
+
}
|
|
159
|
+
)
|
|
160
|
+
}
|
|
161
|
+
),
|
|
162
|
+
columns.map((col, colIndex) => {
|
|
163
|
+
const width = widths[col.key];
|
|
164
|
+
const own = splitCellProps(col.cellProps?.(row));
|
|
165
|
+
const pinned = width ? { width, minWidth: width, maxWidth: width } : void 0;
|
|
166
|
+
return /* @__PURE__ */ createElement(
|
|
167
|
+
"td",
|
|
168
|
+
{
|
|
169
|
+
...own.attrs,
|
|
170
|
+
key: col.key,
|
|
171
|
+
"data-col": col.key,
|
|
172
|
+
style: own.style || pinned ? { ...own.style, ...pinned } : void 0,
|
|
173
|
+
className: cn(
|
|
174
|
+
"align-top",
|
|
175
|
+
compact ? "px-2 py-1" : "px-3 py-2",
|
|
176
|
+
width && "overflow-hidden text-ellipsis",
|
|
177
|
+
col.grow ? GROW_CELL_CLASS : growDrawn && GROW_PEER_CELL_CLASS,
|
|
178
|
+
logicalAlign(own.className),
|
|
179
|
+
logicalAlign(col.className)
|
|
180
|
+
)
|
|
181
|
+
},
|
|
182
|
+
colIndex === 0 && disclosure,
|
|
183
|
+
col === linkColumn && href ? (
|
|
184
|
+
// No `onActivate`: the click is left to bubble to the
|
|
185
|
+
// <tr> handler above, which already owns expand-vs-select.
|
|
186
|
+
// Calling it here as well would toggle the row twice.
|
|
187
|
+
/* @__PURE__ */ jsx(RowLink, { href, className: "block", "data-row-link": "", children: col.cell(row) })
|
|
188
|
+
) : col.cell(row)
|
|
189
|
+
);
|
|
190
|
+
})
|
|
191
|
+
]
|
|
192
|
+
}
|
|
193
|
+
),
|
|
194
|
+
expansion && /* @__PURE__ */ jsx(
|
|
195
|
+
"tr",
|
|
196
|
+
{
|
|
197
|
+
id: hasDisclosure ? detailId : void 0,
|
|
198
|
+
"aria-rowindex": windowed ? ariaRowIndex + 1 : void 0,
|
|
199
|
+
"data-row-detail": windowed ? rowIndex : void 0,
|
|
200
|
+
className: "bg-surface-2 border-t border-subtle",
|
|
201
|
+
children: /* @__PURE__ */ jsx("td", { colSpan: totalColSpan, className: "p-0", children: /* @__PURE__ */ jsx("div", { className: "w-0 min-w-full", children: /* @__PURE__ */ jsx(
|
|
202
|
+
"div",
|
|
203
|
+
{
|
|
204
|
+
className: cn(
|
|
205
|
+
"sticky start-0 w-[var(--dt-visible-w,100%)] max-w-full",
|
|
206
|
+
compact ? "px-2 py-2" : "px-3 py-3"
|
|
207
|
+
),
|
|
208
|
+
children: expansion
|
|
209
|
+
}
|
|
210
|
+
) }) })
|
|
211
|
+
}
|
|
212
|
+
)
|
|
213
|
+
] });
|
|
214
|
+
}
|
|
215
|
+
const DataTableRow = memo(DataTableRowImpl, sameProps);
|
|
216
|
+
const yes = () => true;
|
|
217
|
+
function DataTableMobileRowImpl({
|
|
218
|
+
ctx,
|
|
219
|
+
rowKey: key,
|
|
220
|
+
expanded,
|
|
221
|
+
expansion,
|
|
222
|
+
className,
|
|
223
|
+
attrs,
|
|
224
|
+
interactive,
|
|
225
|
+
href,
|
|
226
|
+
selectionOn,
|
|
227
|
+
selectActive,
|
|
228
|
+
selectable,
|
|
229
|
+
selected,
|
|
230
|
+
...rest
|
|
231
|
+
}) {
|
|
232
|
+
const { row } = rest;
|
|
233
|
+
return /* @__PURE__ */ jsx(
|
|
234
|
+
MobileRow,
|
|
235
|
+
{
|
|
236
|
+
...rest,
|
|
237
|
+
isExpanded: expanded ? yes : void 0,
|
|
238
|
+
openedRowContent: () => expansion,
|
|
239
|
+
rowClassName: () => className,
|
|
240
|
+
rowAttributes: () => attrs,
|
|
241
|
+
onRowClick: interactive ? (r) => ctx.current.onRowClick(r) : void 0,
|
|
242
|
+
rowHref: href !== void 0 ? () => href : void 0,
|
|
243
|
+
select: selectionOn ? {
|
|
244
|
+
active: selectActive,
|
|
245
|
+
selectable,
|
|
246
|
+
selected,
|
|
247
|
+
onToggle: (checked) => {
|
|
248
|
+
ctx.current.setAnchor(key);
|
|
249
|
+
ctx.current.onToggle?.(row, checked);
|
|
250
|
+
},
|
|
251
|
+
onLongPress: () => ctx.current.onLongPress(row)
|
|
252
|
+
} : null
|
|
253
|
+
}
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
const DataTableMobileRow = memo(DataTableMobileRowImpl, sameProps);
|
|
257
|
+
export {
|
|
258
|
+
DataTableMobileRow,
|
|
259
|
+
DataTableRow
|
|
260
|
+
};
|
|
261
|
+
//# sourceMappingURL=data-table-row.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/data-table-row.tsx"],"sourcesContent":["import { Fragment, memo } from \"react\";\nimport type { MouseEvent as ReactMouseEvent, ReactNode, RefObject } from \"react\";\nimport { RowLink, cleanAttrs, fromOutside, fromOwnControl, logicalAlign, splitCellProps } from \"./data-table-shared\";\nimport { GROW_CELL_CLASS, GROW_PEER_CELL_CLASS } from \"./data-table-fit\";\nimport { MobileRow, type MobileRowProps } from \"./data-table-mobile\";\nimport type { DataTableColumn, MobileSwipeActions } from \"./data-table\";\nimport { cn } from \"../lib/cn\";\n\n// DataTable's rows as memoised components (0.48.2, keksdose K-052-2, dev #632 — Marcel:\n// \"The table is extremely slow. Is it virtualised or is everytime the whole table\n// rendered?\"). The owner's selection, expansion and the roving focus all live ABOVE the\n// rows, so every tick re-rendered the whole table: on keksdose's register one checkbox\n// cost 430–1200 ms of INP at 271 rows. A row now bails out unless one of its own inputs\n// changed.\n//\n// What a row compares, and so the contract a call site keeps:\n// * the row object, its index and its key;\n// * what the table derived for it from the caller's functions, as PRIMITIVES — selected,\n// selectable, expanded, its tab stop, its `rowClassName` string, its `rowHref`, and\n// its `rowAttributes` compared key by key. The functions themselves may be inline;\n// * the column definitions BY IDENTITY: a cell is the caller's render function, and\n// what it reads is the caller's to say. A page that memoises its columns (keksdose's\n// `useTransactionColumns`) gets the bail-out; one that writes them inline gets a new\n// array every render and the full re-render it always had — never a stale cell;\n// * an OPEN row's detail (`expandedRow`) is called on every render, so it re-renders\n// with the table as before, and an editor inside it keeps its live inputs.\n// The handlers do not take part: they read the table's latest props through `ctx`, a\n// ref the table refreshes each commit, so a row that bailed out still acts on the\n// current selection and the current `onRowClick`.\n\n/** What a row's handlers read at event time — DataTable's latest props and helpers. */\nexport interface DataTableRowCtx<T> {\n onRowClick: ((row: T) => void) | undefined;\n onToggle: ((row: T, checked: boolean) => void) | undefined;\n isSelected: (row: T) => boolean;\n canSelect: (row: T) => boolean;\n selectRange: (toIndex: number) => boolean;\n /** Anchor the next Shift+click range on this row's key. */\n setAnchor: (key: string | number) => void;\n /** Remember the checkbox click that drew a range… */\n markRangeClick: (e: Event) => void;\n /** …and drop that click's own change event (true once for it). */\n takeRangeClick: (e: Event) => boolean;\n setFocusRowKey: (key: string | number) => void;\n /** The phone card's long press: enter selection mode with this row selected. */\n onLongPress: (row: T) => void;\n /** Under `virtualize` (0.48.2): Arrow/Home/End over every row, rendered or not. True\n * when the key was one of them. Without it the roving walks the rendered rows. */\n moveFocus?: (fromIndex: number, key: string) => boolean;\n}\n\n/** `rowAttributes`' result compared key by key: a call site returns a fresh object (or\n * `undefined`) per call, and its values are strings. */\nfunction sameAttrs(\n a: Record<string, string | undefined> | undefined,\n b: Record<string, string | undefined> | undefined,\n): boolean {\n if (a === b) return true;\n if (!a || !b) return false;\n const ak = Object.keys(a);\n if (ak.length !== Object.keys(b).length) return false;\n for (const k of ak) if (a[k] !== b[k]) return false;\n return true;\n}\n\nfunction sameProps<P extends { attrs?: Record<string, string | undefined> }>(prev: P, next: P): boolean {\n for (const k of Object.keys(next) as (keyof P)[]) {\n if (k === \"attrs\") continue;\n if (!Object.is(prev[k], next[k])) return false;\n }\n return sameAttrs(prev.attrs, next.attrs);\n}\n\n/** Arrow/Home/End between the focusable rows of the table's bodies — the roving half of\n * the keyboard-activatable rows (see the row's `onKeyDown`). */\nfunction moveRowFocus(from: HTMLElement, key: string): boolean {\n if (!(key in ROW_NAV_KEYS)) return false;\n // Every body of the table: a grouped table (`groupBy`, 0.48) has one per group.\n const table = from.closest(\"table\");\n if (!table) return false;\n const rows = Array.from(table.tBodies).flatMap((body) =>\n Array.from(body.children).filter(\n (el): el is HTMLElement => el instanceof HTMLElement && el.hasAttribute(\"data-row-nav\"),\n ),\n );\n const i = rows.indexOf(from);\n const target =\n key === \"ArrowDown\"\n ? rows[i + 1]\n : key === \"ArrowUp\"\n ? rows[i - 1]\n : key === \"Home\"\n ? rows[0]\n : key === \"End\"\n ? rows[rows.length - 1]\n : undefined;\n // At either end the key is still consumed, or ArrowDown on the last row would\n // scroll the page out from under a focused row.\n target?.focus();\n return true;\n}\nconst ROW_NAV_KEYS = { ArrowDown: 1, ArrowUp: 1, Home: 1, End: 1 } as const;\n\n// ---------- Desktop row ----------\n\nexport interface DataTableRowProps<T> {\n row: T;\n rowIndex: number;\n rowKey: string | number;\n ctx: RefObject<DataTableRowCtx<T>>;\n columns: DataTableColumn<T>[];\n widths: Record<string, number>;\n growDrawn: boolean;\n linkColumn: DataTableColumn<T> | undefined;\n href: string | undefined;\n /** The selection column is drawn (DataTable's `selection`). */\n selectionColumn: boolean;\n selectable: boolean;\n selected: boolean;\n expanded: boolean;\n /** The open row's detail; `null` on a closed row. */\n expansion: ReactNode;\n /** The row carries the visually hidden disclosure button (focusable rows that expand). */\n disclosure: boolean;\n detailId: string;\n rowsFocusable: boolean;\n rowInteractive: boolean;\n tabbable: boolean;\n className: string | undefined;\n attrs: Record<string, string | undefined> | undefined;\n compact: boolean;\n totalColSpan: number;\n rowDetailsLabel: string;\n selectRowLabel: string;\n /** Under `virtualize` (0.48.2): the row's `aria-rowindex` (its open detail row is the\n * next), and the row is marked with its index for the window's measuring. */\n ariaRowIndex?: number;\n}\n\nfunction DataTableRowImpl<T>({\n row,\n rowIndex,\n rowKey: key,\n ctx,\n columns,\n widths,\n growDrawn,\n linkColumn,\n href,\n selectionColumn,\n selectable,\n selected,\n expanded,\n expansion,\n disclosure: hasDisclosure,\n detailId,\n rowsFocusable,\n rowInteractive,\n tabbable,\n className,\n attrs,\n compact,\n totalColSpan,\n rowDetailsLabel,\n selectRowLabel,\n ariaRowIndex,\n}: DataTableRowProps<T>) {\n const windowed = ariaRowIndex !== undefined;\n // Whether the row is open, said where ARIA allows it (round 0.34, the\n // showcase's axe check): `aria-expanded` belongs to a treegrid's row, not a\n // table's, and the <tr> wore it. A disclosure button in the first cell carries\n // it now, with `aria-controls` on the detail row while that is there.\n // Visually hidden and not a tab stop: the row stays the one roving stop, with\n // Enter/Space and the whole-row click — this is the screen reader cursor's\n // way in, and where it hears the state. Named by `aria-label`, so the cell's\n // text stays the cell's own.\n const disclosure = hasDisclosure ? (\n <button\n type=\"button\"\n tabIndex={-1}\n className=\"sr-only-fixed\"\n aria-label={rowDetailsLabel}\n aria-expanded={expanded}\n aria-controls={expansion ? detailId : undefined}\n // The row's own handler leaves a click on a control inside it alone.\n onClick={() => ctx.current.onRowClick!(row)}\n />\n ) : null;\n return (\n <Fragment>\n <tr\n {...cleanAttrs(attrs)}\n aria-rowindex={ariaRowIndex}\n data-row-index={windowed ? rowIndex : undefined}\n data-row-nav={rowsFocusable ? \"\" : undefined}\n tabIndex={rowsFocusable ? (tabbable ? 0 : -1) : undefined}\n onFocus={\n rowsFocusable\n ? (e) => {\n if (e.target === e.currentTarget) ctx.current.setFocusRowKey(key);\n }\n : undefined\n }\n onKeyDown={\n rowsFocusable\n ? (e) => {\n // Only the row's own key presses: Enter on a nested button\n // or link is that control's, and Space in a nested input\n // is a space.\n if (e.target !== e.currentTarget) return;\n if (e.altKey || e.ctrlKey || e.metaKey) return;\n if (e.key === \"Enter\" || e.key === \" \") {\n // Space would otherwise scroll the table.\n e.preventDefault();\n ctx.current.onRowClick!(row);\n return;\n }\n if (e.shiftKey) return;\n const move = ctx.current.moveFocus;\n if (move ? move(rowIndex, e.key) : moveRowFocus(e.currentTarget, e.key)) e.preventDefault();\n }\n : undefined\n }\n className={cn(\n \"border-t border-subtle\",\n rowInteractive && \"cursor-pointer hover:bg-hover\",\n // The kit's focus frame width (§5, `--focus-ring-width`), drawn as an\n // OUTLINE rather than FOCUS_RING's box-shadow: a shadow on a `<tr>`\n // is not painted by every engine, an outline is.\n rowsFocusable &&\n \"focus-visible:bg-hover focus-visible:outline-focus focus-visible:-outline-offset-2 focus-visible:outline-brand\",\n className,\n )}\n onClick={\n rowInteractive\n ? (e: ReactMouseEvent<HTMLTableRowElement>) => {\n const c = ctx.current;\n // A click on a control inside the row (a button, a link,\n // an input the cell renders) is that control's — it must\n // not also open the row. Cells no longer have to\n // `stopPropagation` to get that.\n if (fromOwnControl(e.target, e.currentTarget)) return;\n if (fromOutside(e.target, e.currentTarget)) return;\n // Modifier-clicks anywhere in the row drive\n // selection instead of expanding it (feedback #289):\n // Ctrl/Cmd toggles a single row, Shift selects the\n // range from the last-toggled row (inclusive of this\n // one) — the same as the checkbox, but for the whole\n // row, which is what the checkbox-only version was\n // missing.\n if (c.onToggle && c.canSelect(row)) {\n if (e.shiftKey) {\n // Drop the text selection a shift-click would\n // otherwise smear across the rows.\n window.getSelection?.()?.removeAllRanges();\n if (c.selectRange(rowIndex)) return;\n // No anchor yet: treat it as the first pick.\n c.setAnchor(key);\n c.onToggle(row, !c.isSelected(row));\n return;\n }\n if (e.metaKey || e.ctrlKey) {\n c.setAnchor(key);\n c.onToggle(row, !c.isSelected(row));\n return;\n }\n }\n c.onRowClick?.(row);\n }\n : undefined\n }\n >\n {selectionColumn && (\n <td\n className={cn(\"align-top\", compact ? \"w-8 px-2 py-1\" : \"w-10 px-3 py-2\")}\n // Don't let selecting a row also trigger the row click\n // (which expands/edits it).\n onClick={(e) => e.stopPropagation()}\n >\n {selectable && (\n <input\n type=\"checkbox\"\n className={cn(\"accent-indigo-600\", compact ? \"size-3.5\" : \"size-4\")}\n checked={selected}\n // Shift+click selects the range from the last toggled\n // row. `preventDefault` puts the box back, but it does NOT\n // stop React's `onChange`: React derives a checkbox's\n // change from the `click` itself, after the browser has\n // already flipped `checked` and before the cancellation\n // reverts it — so the same click also reported itself as\n // a single toggle, and the owner got `onToggleMany` and\n // then `onToggle` for the clicked row. The click is\n // remembered by identity and its change is dropped; a\n // boolean flag would outlive a click whose change never\n // came and swallow the user's next real one.\n onClick={(e) => {\n if (e.shiftKey && ctx.current.selectRange(rowIndex)) {\n e.preventDefault();\n ctx.current.markRangeClick(e.nativeEvent);\n }\n }}\n onChange={(e) => {\n const c = ctx.current;\n if (c.takeRangeClick(e.nativeEvent)) return;\n c.setAnchor(key);\n c.onToggle?.(row, e.target.checked);\n }}\n aria-label={selectRowLabel}\n />\n )}\n </td>\n )}\n {columns.map((col, colIndex) => {\n const width = widths[col.key];\n // The caller's first, the table's over it — see `cellProps`.\n const own = splitCellProps(col.cellProps?.(row));\n const pinned = width ? { width, minWidth: width, maxWidth: width } : undefined;\n return (\n <td\n {...own.attrs}\n key={col.key}\n data-col={col.key}\n style={own.style || pinned ? { ...own.style, ...pinned } : undefined}\n className={cn(\n \"align-top\",\n compact ? \"px-2 py-1\" : \"px-3 py-2\",\n width && \"overflow-hidden text-ellipsis\",\n col.grow ? GROW_CELL_CLASS : growDrawn && GROW_PEER_CELL_CLASS,\n logicalAlign(own.className),\n logicalAlign(col.className),\n )}\n >\n {colIndex === 0 && disclosure}\n {col === linkColumn && href ? (\n // No `onActivate`: the click is left to bubble to the\n // <tr> handler above, which already owns expand-vs-select.\n // Calling it here as well would toggle the row twice.\n <RowLink href={href} className=\"block\" data-row-link=\"\">\n {col.cell(row)}\n </RowLink>\n ) : (\n col.cell(row)\n )}\n </td>\n );\n })}\n </tr>\n {expansion && (\n <tr\n id={hasDisclosure ? detailId : undefined}\n aria-rowindex={windowed ? ariaRowIndex + 1 : undefined}\n data-row-detail={windowed ? rowIndex : undefined}\n className=\"bg-surface-2 border-t border-subtle\"\n >\n {/* The detail panel spans every column. In an `auto` table\n layout (the default here — columns only get fixed style\n widths once the user resizes/auto-sizes them) the cell's\n content preferred-width is redistributed across the\n spanned columns, so a long expansion visibly re-sizes the\n columns above it — and one-line content does not, since\n its preferred width is small (feedback #104). Wrapping the\n content in `w-0 min-w-full` pins the cell's preferred\n width to ~0 (the explicit width:0 child), so it can never\n perturb the columns; the div then fills to the full row\n width only at paint time, and long text wraps within it.\n Inside it the content is pinned to what the scroller SHOWS\n (0.47, keksdose S4): on a table wider than its scroller a\n table-wide panel put an inline editor's Save/Cancel off-screen.\n `sticky start-0` holds it at the scroller's start edge (the\n right one in RTL) as the row scrolls sideways, and\n `--dt-visible-w` (the scroller's clientWidth, measured above)\n sizes it; before the first measure, and in a table no wider\n than its scroller, it is the full width as before. */}\n <td colSpan={totalColSpan} className=\"p-0\">\n <div className=\"w-0 min-w-full\">\n <div\n className={cn(\n \"sticky start-0 w-[var(--dt-visible-w,100%)] max-w-full\",\n compact ? \"px-2 py-2\" : \"px-3 py-3\",\n )}\n >\n {expansion}\n </div>\n </div>\n </td>\n </tr>\n )}\n </Fragment>\n );\n}\n\n/** One desktop row (its `<tr>` and, while open, its detail row), memoised — see the\n * file's note for what it compares. */\nexport const DataTableRow = memo(DataTableRowImpl, sameProps) as <T>(\n props: DataTableRowProps<T> & { key?: string | number },\n) => ReactNode;\n\n// ---------- Phone card ----------\n\nexport interface DataTableMobileRowProps<T>\n extends Pick<\n MobileRowProps<T>,\n | \"row\"\n | \"opensRow\"\n | \"mobileDir\"\n | \"mobileCardLinkable\"\n | \"mobileCard\"\n | \"mobilePrimaryCol\"\n | \"mobileSecondaryColumns\"\n | \"mobileExpandAsDialog\"\n | \"compact\"\n | \"large\"\n > {\n ctx: RefObject<DataTableRowCtx<T>>;\n rowKey: string | number;\n expanded: boolean;\n /** The opened row's content (`openedRowContent`); `null` on a closed card. */\n expansion: ReactNode;\n className: string | undefined;\n attrs: Record<string, string | undefined> | undefined;\n /** The table has `onRowClick`. */\n interactive: boolean;\n href: string | undefined;\n /** `mobileSwipeActions`, or the swipes derived from `rowActions` — by identity. */\n swipeActionsFor: ((row: T) => MobileSwipeActions | null) | undefined;\n /** The table has `selection`. */\n selectionOn: boolean;\n selectActive: boolean;\n selectable: boolean;\n selected: boolean;\n}\n\nconst yes = () => true;\n\nfunction DataTableMobileRowImpl<T>({\n ctx,\n rowKey: key,\n expanded,\n expansion,\n className,\n attrs,\n interactive,\n href,\n selectionOn,\n selectActive,\n selectable,\n selected,\n ...rest\n}: DataTableMobileRowProps<T>) {\n const { row } = rest;\n // `MobileRow` keeps its own shape (functions of the row); these hand it the values the\n // table derived, and the handlers read the latest props through `ctx`.\n return (\n <MobileRow\n {...rest}\n isExpanded={expanded ? yes : undefined}\n openedRowContent={() => expansion}\n rowClassName={() => className}\n rowAttributes={() => attrs}\n onRowClick={interactive ? (r) => ctx.current.onRowClick!(r) : undefined}\n rowHref={href !== undefined ? () => href : undefined}\n select={\n selectionOn\n ? {\n active: selectActive,\n selectable,\n selected,\n onToggle: (checked) => {\n ctx.current.setAnchor(key);\n ctx.current.onToggle?.(row, checked);\n },\n onLongPress: () => ctx.current.onLongPress(row),\n }\n : null\n }\n />\n );\n}\n\n/** One phone card, memoised like {@link DataTableRow}. */\nexport const DataTableMobileRow = memo(DataTableMobileRowImpl, sameProps) as <T>(\n props: DataTableMobileRowProps<T> & { key?: string | number },\n) => ReactNode;\n"],"mappings":";AAiLI,cAaE,YAbF;AA6IQ;AA9TZ,SAAS,UAAU,YAAY;AAE/B,SAAS,SAAS,YAAY,aAAa,gBAAgB,cAAc,sBAAsB;AAC/F,SAAS,iBAAiB,4BAA4B;AACtD,SAAS,iBAAsC;AAE/C,SAAS,UAAU;AA+CnB,SAAS,UACP,GACA,GACS;AACT,MAAI,MAAM,EAAG,QAAO;AACpB,MAAI,CAAC,KAAK,CAAC,EAAG,QAAO;AACrB,QAAM,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J;AAEJ;AAIO,MAAM,eAAe,KAAK,kBAAkB,SAAS;AAuC5D,MAAM,MAAM,MAAM;AAElB,SAAS,uBAA0B;AAAA,EACjC;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAA+B;AAC7B,QAAM,EAAE,IAAI,IAAI;AAGhB,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,YAAY,WAAW,MAAM;AAAA,MAC7B,kBAAkB,MAAM;AAAA,MACxB,cAAc,MAAM;AAAA,MACpB,eAAe,MAAM;AAAA,MACrB,YAAY,cAAc,CAAC,MAAM,IAAI,QAAQ,WAAY,CAAC,IAAI;AAAA,MAC9D,SAAS,SAAS,SAAY,MAAM,OAAO;AAAA,MAC3C,QACE,cACI;AAAA,QACE,QAAQ;AAAA,QACR;AAAA,QACA;AAAA,QACA,UAAU,CAAC,YAAY;AACrB,cAAI,QAAQ,UAAU,GAAG;AACzB,cAAI,QAAQ,WAAW,KAAK,OAAO;AAAA,QACrC;AAAA,QACA,aAAa,MAAM,IAAI,QAAQ,YAAY,GAAG;AAAA,MAChD,IACA;AAAA;AAAA,EAER;AAEJ;AAGO,MAAM,qBAAqB,KAAK,wBAAwB,SAAS;","names":[]}
|
|
@@ -18,4 +18,7 @@ export declare function useRangeSelection<T>({ selection, slice, rowKey, }: {
|
|
|
18
18
|
rangeClick: import("react").RefObject<Event | null>;
|
|
19
19
|
canSelect: (row: T) => boolean;
|
|
20
20
|
selectRange: (toIndex: number) => boolean;
|
|
21
|
+
setAnchor: (key: string | number) => void;
|
|
22
|
+
markRangeClick: (e: Event) => void;
|
|
23
|
+
takeRangeClick: (e: Event) => boolean;
|
|
21
24
|
};
|
|
@@ -22,7 +22,18 @@ function useRangeSelection({
|
|
|
22
22
|
else for (const r of range) selection.onToggle(r, true);
|
|
23
23
|
return true;
|
|
24
24
|
};
|
|
25
|
-
|
|
25
|
+
const setAnchor = (key) => {
|
|
26
|
+
selectionAnchor.current = key;
|
|
27
|
+
};
|
|
28
|
+
const markRangeClick = (e) => {
|
|
29
|
+
rangeClick.current = e;
|
|
30
|
+
};
|
|
31
|
+
const takeRangeClick = (e) => {
|
|
32
|
+
if (!rangeClick.current || rangeClick.current !== e) return false;
|
|
33
|
+
rangeClick.current = null;
|
|
34
|
+
return true;
|
|
35
|
+
};
|
|
36
|
+
return { selectionAnchor, rangeClick, canSelect, selectRange, setAnchor, markRangeClick, takeRangeClick };
|
|
26
37
|
}
|
|
27
38
|
export {
|
|
28
39
|
useRangeSelection
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/data-table-selection.ts"],"sourcesContent":["import { useRef } from \"react\";\nimport type { DataTableProps } from \"./data-table\";\n\n// DataTable's Shift+click range selection (feedback #289). Moved out of data-table.tsx\n// whole (refactor audit 2026-10, MOD-3 step 3).\n\n/**\n * The anchor a Shift+click draws its range from, and the range itself.\n *\n * `selectionAnchor` is set by every single-row toggle (the checkbox, a Ctrl/⌘-click or\n * a first Shift-click on a row); `selectRange(i)` then selects from the anchor to the\n * `i`th row of `slice`, and answers false when there is no range on screen to draw.\n * `rangeClick` remembers the checkbox click that drew one, so that click's own\n * `onChange` can be told apart and dropped.\n */\nexport function useRangeSelection<T>({\n selection,\n slice,\n rowKey,\n}: {\n selection: DataTableProps<T>[\"selection\"];\n /** The rows on screen, in the order shown. */\n slice: T[];\n rowKey: (row: T) => string | number;\n}) {\n // The row whose selection was last toggled, so Shift+click can select the range up\n // to it (feedback #289). Held as its KEY, not as an index into `slice`: the slice is\n // re-derived from the current sort, filter and page, so an index taken before a\n // header was clicked addresses a different row afterwards — and the range then ran\n // from a row the user had never touched.\n const selectionAnchor = useRef<string | number | null>(null);\n /** The checkbox click that drew a range, so its `onChange` can be told apart. */\n const rangeClick = useRef<Event | null>(null);\n const canSelect = (row: T) => !!selection && (selection.isSelectable?.(row) ?? true);\n const selectRange = (toIndex: number) => {\n if (!selection || selectionAnchor.current === null) return false;\n const fromIndex = slice.findIndex((r) => rowKey(r) === selectionAnchor.current);\n // The anchor has been filtered, sorted or paged off the screen: there is no range\n // on display to draw, so the click falls through to the plain single-row toggle.\n if (fromIndex < 0) return false;\n const [lo, hi] = [fromIndex, toIndex].sort((a, b) => a - b);\n const range: T[] = [];\n for (let i = lo; i <= hi; i++) {\n const r = slice[i];\n if (r && canSelect(r)) range.push(r);\n }\n // One call where the owner can take one. See `selection.onToggleMany`: the row-by-\n // row loop below is the fallback for an owner that has not adopted it, not the\n // shape this should be in.\n if (selection.onToggleMany) selection.onToggleMany(range, true);\n else for (const r of range) selection.onToggle(r, true);\n return true;\n };\n return { selectionAnchor, rangeClick, canSelect, selectRange };\n}\n"],"mappings":";AAAA,SAAS,cAAc;AAehB,SAAS,kBAAqB;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AACF,GAKG;AAMD,QAAM,kBAAkB,OAA+B,IAAI;AAE3D,QAAM,aAAa,OAAqB,IAAI;AAC5C,QAAM,YAAY,CAAC,QAAW,CAAC,CAAC,cAAc,UAAU,eAAe,GAAG,KAAK;AAC/E,QAAM,cAAc,CAAC,YAAoB;AACvC,QAAI,CAAC,aAAa,gBAAgB,YAAY,KAAM,QAAO;AAC3D,UAAM,YAAY,MAAM,UAAU,CAAC,MAAM,OAAO,CAAC,MAAM,gBAAgB,OAAO;AAG9E,QAAI,YAAY,EAAG,QAAO;AAC1B,UAAM,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,OAAO,EAAE,KAAK,CAAC,GAAG,MAAM,IAAI,CAAC;AAC1D,UAAM,QAAa,CAAC;AACpB,aAAS,IAAI,IAAI,KAAK,IAAI,KAAK;AAC7B,YAAM,IAAI,MAAM,CAAC;AACjB,UAAI,KAAK,UAAU,CAAC,EAAG,OAAM,KAAK,CAAC;AAAA,IACrC;AAIA,QAAI,UAAU,aAAc,WAAU,aAAa,OAAO,IAAI;AAAA,QACzD,YAAW,KAAK,MAAO,WAAU,SAAS,GAAG,IAAI;AACtD,WAAO;AAAA,EACT;AACA,SAAO,EAAE,iBAAiB,YAAY,WAAW,
|
|
1
|
+
{"version":3,"sources":["../../src/components/data-table-selection.ts"],"sourcesContent":["import { useRef } from \"react\";\nimport type { DataTableProps } from \"./data-table\";\n\n// DataTable's Shift+click range selection (feedback #289). Moved out of data-table.tsx\n// whole (refactor audit 2026-10, MOD-3 step 3).\n\n/**\n * The anchor a Shift+click draws its range from, and the range itself.\n *\n * `selectionAnchor` is set by every single-row toggle (the checkbox, a Ctrl/⌘-click or\n * a first Shift-click on a row); `selectRange(i)` then selects from the anchor to the\n * `i`th row of `slice`, and answers false when there is no range on screen to draw.\n * `rangeClick` remembers the checkbox click that drew one, so that click's own\n * `onChange` can be told apart and dropped.\n */\nexport function useRangeSelection<T>({\n selection,\n slice,\n rowKey,\n}: {\n selection: DataTableProps<T>[\"selection\"];\n /** The rows on screen, in the order shown. */\n slice: T[];\n rowKey: (row: T) => string | number;\n}) {\n // The row whose selection was last toggled, so Shift+click can select the range up\n // to it (feedback #289). Held as its KEY, not as an index into `slice`: the slice is\n // re-derived from the current sort, filter and page, so an index taken before a\n // header was clicked addresses a different row afterwards — and the range then ran\n // from a row the user had never touched.\n const selectionAnchor = useRef<string | number | null>(null);\n /** The checkbox click that drew a range, so its `onChange` can be told apart. */\n const rangeClick = useRef<Event | null>(null);\n const canSelect = (row: T) => !!selection && (selection.isSelectable?.(row) ?? true);\n const selectRange = (toIndex: number) => {\n if (!selection || selectionAnchor.current === null) return false;\n const fromIndex = slice.findIndex((r) => rowKey(r) === selectionAnchor.current);\n // The anchor has been filtered, sorted or paged off the screen: there is no range\n // on display to draw, so the click falls through to the plain single-row toggle.\n if (fromIndex < 0) return false;\n const [lo, hi] = [fromIndex, toIndex].sort((a, b) => a - b);\n const range: T[] = [];\n for (let i = lo; i <= hi; i++) {\n const r = slice[i];\n if (r && canSelect(r)) range.push(r);\n }\n // One call where the owner can take one. See `selection.onToggleMany`: the row-by-\n // row loop below is the fallback for an owner that has not adopted it, not the\n // shape this should be in.\n if (selection.onToggleMany) selection.onToggleMany(range, true);\n else for (const r of range) selection.onToggle(r, true);\n return true;\n };\n // The ref writes as functions (0.48.2): the memoised rows (data-table-row.tsx) reach\n // them through DataTable's row context rather than holding the refs themselves.\n /** Every single-row toggle anchors the next Shift+click's range on its row. */\n const setAnchor = (key: string | number) => {\n selectionAnchor.current = key;\n };\n /** Remember the checkbox click that drew a range. */\n const markRangeClick = (e: Event) => {\n rangeClick.current = e;\n };\n /** True — once — for the change event of the click that drew a range. */\n const takeRangeClick = (e: Event) => {\n if (!rangeClick.current || rangeClick.current !== e) return false;\n rangeClick.current = null;\n return true;\n };\n return { selectionAnchor, rangeClick, canSelect, selectRange, setAnchor, markRangeClick, takeRangeClick };\n}\n"],"mappings":";AAAA,SAAS,cAAc;AAehB,SAAS,kBAAqB;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AACF,GAKG;AAMD,QAAM,kBAAkB,OAA+B,IAAI;AAE3D,QAAM,aAAa,OAAqB,IAAI;AAC5C,QAAM,YAAY,CAAC,QAAW,CAAC,CAAC,cAAc,UAAU,eAAe,GAAG,KAAK;AAC/E,QAAM,cAAc,CAAC,YAAoB;AACvC,QAAI,CAAC,aAAa,gBAAgB,YAAY,KAAM,QAAO;AAC3D,UAAM,YAAY,MAAM,UAAU,CAAC,MAAM,OAAO,CAAC,MAAM,gBAAgB,OAAO;AAG9E,QAAI,YAAY,EAAG,QAAO;AAC1B,UAAM,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,OAAO,EAAE,KAAK,CAAC,GAAG,MAAM,IAAI,CAAC;AAC1D,UAAM,QAAa,CAAC;AACpB,aAAS,IAAI,IAAI,KAAK,IAAI,KAAK;AAC7B,YAAM,IAAI,MAAM,CAAC;AACjB,UAAI,KAAK,UAAU,CAAC,EAAG,OAAM,KAAK,CAAC;AAAA,IACrC;AAIA,QAAI,UAAU,aAAc,WAAU,aAAa,OAAO,IAAI;AAAA,QACzD,YAAW,KAAK,MAAO,WAAU,SAAS,GAAG,IAAI;AACtD,WAAO;AAAA,EACT;AAIA,QAAM,YAAY,CAAC,QAAyB;AAC1C,oBAAgB,UAAU;AAAA,EAC5B;AAEA,QAAM,iBAAiB,CAAC,MAAa;AACnC,eAAW,UAAU;AAAA,EACvB;AAEA,QAAM,iBAAiB,CAAC,MAAa;AACnC,QAAI,CAAC,WAAW,WAAW,WAAW,YAAY,EAAG,QAAO;AAC5D,eAAW,UAAU;AACrB,WAAO;AAAA,EACT;AACA,SAAO,EAAE,iBAAiB,YAAY,WAAW,aAAa,WAAW,gBAAgB,eAAe;AAC1G;","names":[]}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { RefObject } from "react";
|
|
2
|
+
/** {@link DataTableProps.virtualize}'s options. */
|
|
3
|
+
export interface DataTableVirtualize {
|
|
4
|
+
/** Rows rendered beyond each edge of the visible part. Default 12. */
|
|
5
|
+
overscan?: number;
|
|
6
|
+
/** A row's height in px before it has been measured. Default: 37 (`comfortable`) /
|
|
7
|
+
* 29 (`compact`) — the kit's one-line rows. */
|
|
8
|
+
estimateRowHeight?: number;
|
|
9
|
+
}
|
|
10
|
+
/** One innermost group's run of rows, `[start, end)` in the rows on screen, with the
|
|
11
|
+
* band levels its `<tbody>` opens with. `first` is the index of the innermost group that
|
|
12
|
+
* opens its level-1 group (itself with one level). Ungrouped: one run with no bands. */
|
|
13
|
+
export interface VirtualGroup {
|
|
14
|
+
start: number;
|
|
15
|
+
end: number;
|
|
16
|
+
bands: readonly (1 | 2)[];
|
|
17
|
+
first: number;
|
|
18
|
+
}
|
|
19
|
+
/** A row, or a spacer standing in for the rows between two rendered ones. */
|
|
20
|
+
export type VirtualItem = {
|
|
21
|
+
kind: "row";
|
|
22
|
+
index: number;
|
|
23
|
+
} | {
|
|
24
|
+
kind: "gap";
|
|
25
|
+
key: string;
|
|
26
|
+
height: number;
|
|
27
|
+
};
|
|
28
|
+
/** A group's `<tbody>` with its rendered rows, or one spacer `<tbody>` for a run of
|
|
29
|
+
* groups of which nothing is rendered. */
|
|
30
|
+
export type VirtualBody = {
|
|
31
|
+
kind: "spacer";
|
|
32
|
+
key: string;
|
|
33
|
+
height: number;
|
|
34
|
+
} | {
|
|
35
|
+
kind: "group";
|
|
36
|
+
group: number;
|
|
37
|
+
items: VirtualItem[];
|
|
38
|
+
};
|
|
39
|
+
export interface RowWindow {
|
|
40
|
+
bodies: VirtualBody[];
|
|
41
|
+
/** `aria-rowcount`: every row of the table, header, bands, details and footer included. */
|
|
42
|
+
rowCount: number;
|
|
43
|
+
/** `aria-rowindex` of data row `i`; its detail row (open) is the next one. */
|
|
44
|
+
ariaRow: (i: number) => number;
|
|
45
|
+
/** `aria-rowindex` of group `g`'s band of `level`. */
|
|
46
|
+
ariaBand: (g: number, level: 1 | 2) => number;
|
|
47
|
+
/** The locked widths for the `<colgroup>`, by column key; null while measuring. */
|
|
48
|
+
colWidths: Record<string, number> | null;
|
|
49
|
+
/** Move the focus to row `i`, rendering it first when it is not. */
|
|
50
|
+
focusRow: (i: number) => void;
|
|
51
|
+
}
|
|
52
|
+
/** The `<colgroup>` key of the selection column. */
|
|
53
|
+
export declare const VIRTUAL_SELECT_COL = "\0select";
|
|
54
|
+
interface Model {
|
|
55
|
+
n: number;
|
|
56
|
+
keys: (string | number)[];
|
|
57
|
+
/** Top of row i, from the top of the first group's `<tbody>`. */
|
|
58
|
+
tops: Float64Array;
|
|
59
|
+
/** Full height of row i (its detail row included while open). */
|
|
60
|
+
h: Float64Array;
|
|
61
|
+
/** Top of group g's `<tbody>`; [groups.length] is the total. */
|
|
62
|
+
gTop: Float64Array;
|
|
63
|
+
total: number;
|
|
64
|
+
ariaRows: Int32Array;
|
|
65
|
+
ariaBands: Int32Array;
|
|
66
|
+
rowCount: number;
|
|
67
|
+
}
|
|
68
|
+
/** The `<tbody>`s to render: the groups holding a rendered row (or the period's first
|
|
69
|
+
* day, for its band), and one spacer for each run of groups in between. Pure. */
|
|
70
|
+
export declare function planBodies(m: Pick<Model, "n" | "tops" | "h" | "gTop">, groups: readonly VirtualGroup[], start: number, end: number, pinned: readonly number[]): VirtualBody[];
|
|
71
|
+
export declare function useRowWindow<T>({ enabled, rows, rowKey, groups, expanded, pinnedKeys, scrollerRef, tableRef, options, compact, rowsBefore, rowsAfter, colKeys, lockable, resetKey, }: {
|
|
72
|
+
enabled: boolean;
|
|
73
|
+
/** The rows on screen, in order. */
|
|
74
|
+
rows: T[];
|
|
75
|
+
rowKey: (row: T) => string | number;
|
|
76
|
+
groups: readonly VirtualGroup[];
|
|
77
|
+
/** Indices of the open rows: always rendered, their detail rows counted. */
|
|
78
|
+
expanded: readonly number[];
|
|
79
|
+
/** Keys always rendered (the roving tab stop). */
|
|
80
|
+
pinnedKeys: readonly (string | number | null)[];
|
|
81
|
+
scrollerRef: RefObject<HTMLElement | null>;
|
|
82
|
+
tableRef: RefObject<HTMLTableElement | null>;
|
|
83
|
+
options: DataTableVirtualize;
|
|
84
|
+
compact: boolean;
|
|
85
|
+
/** Rows above the first group: the header, the leading row. */
|
|
86
|
+
rowsBefore: number;
|
|
87
|
+
/** Rows after the last: the totals row. */
|
|
88
|
+
rowsAfter: number;
|
|
89
|
+
/** The header cells' keys, in order (the selection column as {@link VIRTUAL_SELECT_COL}). */
|
|
90
|
+
colKeys: readonly string[];
|
|
91
|
+
/** The keys whose width is locked (not a `grow` column, not a user-resized one). */
|
|
92
|
+
lockable: ReadonlySet<string>;
|
|
93
|
+
/** Anything that re-measures the column widths from scratch when it changes. */
|
|
94
|
+
resetKey: string;
|
|
95
|
+
}): RowWindow | null;
|
|
96
|
+
/** The roving rows' Arrow/Home/End target over ALL the rows, rendered or not. */
|
|
97
|
+
export declare function rowNavTarget(from: number, key: string, n: number): number | null;
|
|
98
|
+
export {};
|