basalt-ui 2.27.1 → 2.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +111 -0
- package/MIGRATING.md +172 -12
- package/agent/rules/basalt-batteries.md +1 -1
- package/agent/rules/basalt-mantine.md +1 -1
- package/agent/rules/basalt-tokens.md +2 -2
- package/agent/skills/basalt-design/SKILL.md +1 -1
- package/agent/skills/basalt-design/references/catalogue.md +40 -36
- package/agent/skills/basalt-design/references/recipes.md +47 -0
- package/configs/oxlint-basalt.json +2 -1
- package/configs/oxlint-plugin.js +110 -2
- package/configs/oxlint-plugin.test.ts +99 -4
- package/dist/agent/chat/thread-message.d.ts +1 -160
- package/dist/agent/chat/thread-message.d.ts.map +1 -1
- package/dist/agent/chat/thread-message.js +7 -162
- package/dist/agent/chat/virtualize.d.ts +5 -5
- package/dist/charts/ChartCard.d.ts +5 -2
- package/dist/charts/ChartCard.d.ts.map +1 -1
- package/dist/charts/ChartCard.js +46 -13
- package/dist/charts/Lines.d.ts.map +1 -1
- package/dist/charts/Lines.js +11 -4
- package/dist/charts/Sparkline.d.ts +9 -2
- package/dist/charts/Sparkline.d.ts.map +1 -1
- package/dist/charts/Sparkline.js +104 -41
- package/dist/charts/chart-box.module.css +69 -3
- package/dist/charts/chart-box.module.css.d.ts +5 -0
- package/dist/charts/chart-card.module.css +12 -4
- package/dist/charts/chart-card.module.css.d.ts +1 -0
- package/dist/charts/compile.d.ts.map +1 -1
- package/dist/charts/compile.js +21 -19
- package/dist/charts/labels.d.ts +13 -3
- package/dist/charts/labels.d.ts.map +1 -1
- package/dist/charts/labels.js +131 -20
- package/dist/charts/legend.d.ts.map +1 -1
- package/dist/charts/legend.js +1 -1
- package/dist/charts/ref-label.d.ts +31 -8
- package/dist/charts/ref-label.d.ts.map +1 -1
- package/dist/charts/ref-label.js +40 -9
- package/dist/charts/sparkline.module.css +6 -0
- package/dist/charts/state.d.ts +3 -3
- package/dist/charts/state.d.ts.map +1 -1
- package/dist/charts/state.js +20 -2
- package/dist/cli/shot/capture.d.ts +6 -1
- package/dist/cli/shot/capture.d.ts.map +1 -1
- package/dist/cli/shot/capture.js +18 -5
- package/dist/common/empty-copy.d.ts +16 -0
- package/dist/common/empty-copy.d.ts.map +1 -0
- package/dist/common/empty-copy.js +9 -0
- package/dist/common/virtual-rows.d.ts +196 -0
- package/dist/common/virtual-rows.d.ts.map +1 -0
- package/dist/common/virtual-rows.js +290 -0
- package/dist/controls/controls.module.css +33 -1
- package/dist/controls/controls.module.css.d.ts +2 -0
- package/dist/controls/enum-filter.d.ts.map +1 -1
- package/dist/controls/enum-filter.js +8 -2
- package/dist/controls/filter-pill.d.ts +27 -3
- package/dist/controls/filter-pill.d.ts.map +1 -1
- package/dist/controls/filter-pill.js +15 -4
- package/dist/controls/form-layout.d.ts +9 -3
- package/dist/controls/form-layout.d.ts.map +1 -1
- package/dist/controls/form-layout.js +74 -12
- package/dist/controls/form-layout.module.css +112 -7
- package/dist/controls/form-layout.module.css.d.ts +1 -0
- package/dist/controls/multi-select-filter.d.ts +2 -2
- package/dist/controls/multi-select-filter.d.ts.map +1 -1
- package/dist/controls/multi-select-filter.js +12 -6
- package/dist/controls/range-filter.d.ts +1 -1
- package/dist/controls/range-filter.d.ts.map +1 -1
- package/dist/controls/range-filter.js +8 -2
- package/dist/dashboard/bar-list.d.ts +1 -1
- package/dist/dashboard/bar-list.d.ts.map +1 -1
- package/dist/dashboard/bar-list.js +6 -2
- package/dist/dashboard/bar-list.module.css +0 -2
- package/dist/dashboard/board-nav.d.ts +22 -0
- package/dist/dashboard/board-nav.d.ts.map +1 -0
- package/dist/dashboard/board-nav.js +49 -0
- package/dist/dashboard/board.d.ts +52 -0
- package/dist/dashboard/board.d.ts.map +1 -0
- package/dist/dashboard/board.js +228 -0
- package/dist/dashboard/board.module.css +160 -0
- package/dist/dashboard/board.module.css.d.ts +26 -0
- package/dist/dashboard/empty-state.d.ts +3 -3
- package/dist/dashboard/empty-state.d.ts.map +1 -1
- package/dist/dashboard/empty-state.js +13 -6
- package/dist/dashboard/event-list-model.d.ts +51 -0
- package/dist/dashboard/event-list-model.d.ts.map +1 -0
- package/dist/dashboard/event-list-model.js +72 -0
- package/dist/dashboard/event-list-rows.d.ts +23 -0
- package/dist/dashboard/event-list-rows.d.ts.map +1 -0
- package/dist/dashboard/event-list-rows.js +93 -0
- package/dist/dashboard/event-list-scroll.d.ts +27 -0
- package/dist/dashboard/event-list-scroll.d.ts.map +1 -0
- package/dist/dashboard/event-list-scroll.js +103 -0
- package/dist/dashboard/event-list-skeleton.d.ts +10 -0
- package/dist/dashboard/event-list-skeleton.d.ts.map +1 -0
- package/dist/dashboard/event-list-skeleton.js +36 -0
- package/dist/dashboard/event-list.d.ts +65 -0
- package/dist/dashboard/event-list.d.ts.map +1 -0
- package/dist/dashboard/event-list.js +178 -0
- package/dist/dashboard/event-list.module.css +283 -0
- package/dist/dashboard/event-list.module.css.d.ts +33 -0
- package/dist/dashboard/index.d.ts +2 -0
- package/dist/dashboard/index.d.ts.map +1 -1
- package/dist/dashboard/index.js +4 -0
- package/dist/dashboard/meter-parts.d.ts.map +1 -1
- package/dist/dashboard/meter-parts.js +5 -3
- package/dist/dashboard/meter.module.css +2 -1
- package/dist/dashboard/query-state.js +1 -1
- package/dist/dashboard/settings-section.d.ts +4 -1
- package/dist/dashboard/settings-section.d.ts.map +1 -1
- package/dist/dashboard/settings-section.js +1 -1
- package/dist/dashboard/settings-section.module.css +19 -4
- package/dist/dashboard/stat-card-parts.d.ts +5 -1
- package/dist/dashboard/stat-card-parts.d.ts.map +1 -1
- package/dist/dashboard/stat-card-parts.js +8 -3
- package/dist/dashboard/stat-card.d.ts.map +1 -1
- package/dist/dashboard/stat-card.js +26 -7
- package/dist/dashboard/stat-card.module.css +31 -7
- package/dist/dashboard/stat-card.module.css.d.ts +3 -0
- package/dist/dashboard/stat-strip.js +1 -1
- package/dist/dashboard/stat-strip.module.css +4 -1
- package/dist/dashboard/widget-header.d.ts.map +1 -1
- package/dist/dashboard/widget-header.js +15 -2
- package/dist/dashboard/widget-header.module.css +17 -1
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/shell/app-main.module.css +18 -0
- package/dist/styles.css +46 -8
- package/dist/surfaces.d.ts +2 -2
- package/dist/surfaces.d.ts.map +1 -1
- package/dist/surfaces.js +8 -2
- package/dist/table/cell-kinds.d.ts +44 -0
- package/dist/table/cell-kinds.d.ts.map +1 -0
- package/dist/table/cell-kinds.js +169 -0
- package/dist/table/cell-kinds.module.css +55 -0
- package/dist/table/cell-kinds.module.css.d.ts +15 -0
- package/dist/table/data-table-fold.d.ts +147 -0
- package/dist/table/data-table-fold.d.ts.map +1 -0
- package/dist/table/data-table-fold.js +288 -0
- package/dist/table/data-table-state.d.ts +10 -3
- package/dist/table/data-table-state.d.ts.map +1 -1
- package/dist/table/data-table-state.js +11 -6
- package/dist/table/data-table.d.ts +11 -26
- package/dist/table/data-table.d.ts.map +1 -1
- package/dist/table/data-table.js +354 -254
- package/dist/table/data-table.module.css +210 -3
- package/dist/table/data-table.module.css.d.ts +12 -0
- package/dist/table/table-features.d.ts +34 -4
- package/dist/table/table-features.d.ts.map +1 -1
- package/dist/table/table-features.js +10 -0
- package/dist/theme/card-inset.module.css +35 -0
- package/dist/theme/controls.module.css +32 -0
- package/dist/theme/ctl-theme.d.ts.map +1 -1
- package/dist/theme/ctl-theme.js +5 -0
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +14 -10
- package/dist/tokens/core.d.ts +1 -0
- package/dist/tokens/core.d.ts.map +1 -1
- package/dist/tokens/core.js +1 -0
- package/dist/tokens/derive.js +1 -1
- package/dist/tokens/palette.d.ts +2 -1
- package/dist/tokens/palette.d.ts.map +1 -1
- package/llms.txt +34 -5
- package/package.json +1 -1
- package/src/agent/chat/thread-message.tsx +10 -403
- package/src/agent/chat/virtualize.ts +5 -5
- package/src/charts/ChartCard.tsx +79 -17
- package/src/charts/Lines.tsx +13 -4
- package/src/charts/Sparkline.tsx +131 -45
- package/src/charts/chart-box.module.css +69 -3
- package/src/charts/chart-box.module.css.d.ts +5 -0
- package/src/charts/chart-card.module.css +12 -4
- package/src/charts/chart-card.module.css.d.ts +1 -0
- package/src/charts/compile.ts +24 -20
- package/src/charts/labels.ts +175 -24
- package/src/charts/legend.tsx +3 -2
- package/src/charts/ref-label.ts +86 -17
- package/src/charts/sparkline.module.css +6 -0
- package/src/charts/state.tsx +36 -7
- package/src/cli/shot/capture.ts +29 -6
- package/src/common/empty-copy.ts +17 -0
- package/src/common/virtual-rows.tsx +682 -0
- package/src/controls/controls.module.css +33 -1
- package/src/controls/controls.module.css.d.ts +2 -0
- package/src/controls/enum-filter.tsx +8 -2
- package/src/controls/filter-pill.tsx +80 -27
- package/src/controls/form-layout.module.css +112 -7
- package/src/controls/form-layout.module.css.d.ts +1 -0
- package/src/controls/form-layout.tsx +115 -22
- package/src/controls/multi-select-filter.tsx +22 -11
- package/src/controls/range-filter.tsx +9 -3
- package/src/dashboard/bar-list.module.css +0 -2
- package/src/dashboard/bar-list.tsx +8 -5
- package/src/dashboard/board-nav.ts +67 -0
- package/src/dashboard/board.module.css +160 -0
- package/src/dashboard/board.module.css.d.ts +26 -0
- package/src/dashboard/board.tsx +394 -0
- package/src/dashboard/empty-state.tsx +16 -9
- package/src/dashboard/event-list-model.ts +113 -0
- package/src/dashboard/event-list-rows.tsx +120 -0
- package/src/dashboard/event-list-scroll.ts +145 -0
- package/src/dashboard/event-list-skeleton.tsx +58 -0
- package/src/dashboard/event-list.module.css +283 -0
- package/src/dashboard/event-list.module.css.d.ts +33 -0
- package/src/dashboard/event-list.tsx +309 -0
- package/src/dashboard/index.ts +2 -0
- package/src/dashboard/meter-parts.tsx +9 -2
- package/src/dashboard/meter.module.css +2 -1
- package/src/dashboard/query-state.tsx +1 -1
- package/src/dashboard/settings-section.module.css +19 -4
- package/src/dashboard/settings-section.tsx +7 -2
- package/src/dashboard/stat-card-parts.tsx +20 -3
- package/src/dashboard/stat-card.module.css +31 -7
- package/src/dashboard/stat-card.module.css.d.ts +3 -0
- package/src/dashboard/stat-card.tsx +25 -6
- package/src/dashboard/stat-strip.module.css +4 -1
- package/src/dashboard/stat-strip.tsx +1 -1
- package/src/dashboard/widget-header.module.css +17 -1
- package/src/dashboard/widget-header.tsx +29 -5
- package/src/guard/index.ts +2 -0
- package/src/index.ts +4 -0
- package/src/shell/app-main.module.css +18 -0
- package/src/styles.css +46 -8
- package/src/surfaces.ts +7 -1
- package/src/table/cell-kinds.module.css +55 -0
- package/src/table/cell-kinds.module.css.d.ts +15 -0
- package/src/table/cell-kinds.tsx +234 -0
- package/src/table/data-table-fold.tsx +514 -0
- package/src/table/data-table-state.ts +24 -13
- package/src/table/data-table.module.css +210 -3
- package/src/table/data-table.module.css.d.ts +12 -0
- package/src/table/data-table.tsx +406 -359
- package/src/table/table-features.ts +44 -4
- package/src/theme/__snapshots__/plain-theme.test.ts.snap +2 -66
- package/src/theme/card-inset.module.css +35 -0
- package/src/theme/controls.module.css +32 -0
- package/src/theme/ctl-theme.tsx +8 -0
- package/src/theme/index.ts +12 -8
- package/src/tokens/core.ts +1 -0
- package/src/tokens/derive.ts +1 -1
- package/src/tokens/palette.ts +4 -1
package/dist/table/data-table.js
CHANGED
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
TextInput
|
|
15
15
|
} from "@mantine/core";
|
|
16
16
|
import { constructFilterFn, FlexRender, useTable } from "@tanstack/react-table";
|
|
17
|
-
import { Fragment, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
17
|
+
import { Fragment, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
18
18
|
import { useDebouncedCallback } from "@mantine/hooks";
|
|
19
19
|
import { cx } from "../common/props.js";
|
|
20
20
|
import { BASALT_PREFIX } from "../common/errors.js";
|
|
@@ -27,18 +27,43 @@ import { EnumFilter } from "../controls/enum-filter.js";
|
|
|
27
27
|
import { MultiSelectFilter } from "../controls/multi-select-filter.js";
|
|
28
28
|
import { CtlSlot } from "../theme/index.js";
|
|
29
29
|
import { IconSlot } from "../theme/icon-slot.js";
|
|
30
|
-
import {
|
|
30
|
+
import { CONTAINER_CLASSES, VX } from "../tokens/index.js";
|
|
31
31
|
import { WidgetHeader } from "../dashboard/index.js";
|
|
32
|
+
import { EmptyState } from "../dashboard/empty-state.js";
|
|
32
33
|
import { ErrorState } from "../dashboard/query-state.js";
|
|
33
34
|
import {
|
|
34
35
|
activationProps,
|
|
35
|
-
EMPTY_FOLD_SET,
|
|
36
36
|
useCardProjection,
|
|
37
37
|
useDataTableState,
|
|
38
|
+
useNarrowerThan,
|
|
38
39
|
useRowDisclosure
|
|
39
40
|
} from "./data-table-state.js";
|
|
41
|
+
import { planColumnFold } from "./data-table-fold.js";
|
|
40
42
|
import { dataQueryBranch } from "./query-branch.js";
|
|
41
43
|
import { basaltTableFeatures } from "./table-features.js";
|
|
44
|
+
import {
|
|
45
|
+
columnDefId,
|
|
46
|
+
columnLabel,
|
|
47
|
+
FIXED_ID_ATTR,
|
|
48
|
+
FOLD_ID_ATTR,
|
|
49
|
+
foldOrder,
|
|
50
|
+
foldToggleCellProps,
|
|
51
|
+
FoldHeaderLabel,
|
|
52
|
+
FoldToggle,
|
|
53
|
+
PIN_MIN_WIDTH,
|
|
54
|
+
pinnedCellProps,
|
|
55
|
+
RowDisclosure,
|
|
56
|
+
useColumnFold
|
|
57
|
+
} from "./data-table-fold.js";
|
|
58
|
+
import {
|
|
59
|
+
CellContent,
|
|
60
|
+
DEFAULT_CELL,
|
|
61
|
+
kindAlign,
|
|
62
|
+
kindClass,
|
|
63
|
+
KindSkeleton,
|
|
64
|
+
planColumnSizing,
|
|
65
|
+
resolveKind
|
|
66
|
+
} from "./cell-kinds.js";
|
|
42
67
|
import classes from "./data-table.module.css";
|
|
43
68
|
const ALIGNMENTS = /* @__PURE__ */ new Set(["left", "center", "right"]);
|
|
44
69
|
function resolveAlign(column) {
|
|
@@ -118,9 +143,11 @@ const facetAnyOf = constructFilterFn({
|
|
|
118
143
|
autoRemove: facetAutoRemove
|
|
119
144
|
});
|
|
120
145
|
const SELECT_COLUMN_ID = "__basalt_select__";
|
|
146
|
+
const SELECT_COLUMN_SIZE = HIT_COARSE;
|
|
121
147
|
function selectionColumn() {
|
|
122
148
|
return {
|
|
123
149
|
id: SELECT_COLUMN_ID,
|
|
150
|
+
size: SELECT_COLUMN_SIZE,
|
|
124
151
|
enableSorting: false,
|
|
125
152
|
header: ({ table }) => (
|
|
126
153
|
// oxlint-disable-next-line jsx-a11y/label-has-associated-control -- wraps <Checkbox>, which oxlint cannot see is an input
|
|
@@ -174,7 +201,7 @@ function RowActionCell({
|
|
|
174
201
|
"aria-label": named === void 0 ? only.label : `${only.label}: ${named}`,
|
|
175
202
|
disabled: only.disabled?.(row) === true,
|
|
176
203
|
loading: only.loading?.(row) === true,
|
|
177
|
-
...only.danger === true && {
|
|
204
|
+
...only.danger === true && { className: classes.dangerAction },
|
|
178
205
|
onClick: () => {
|
|
179
206
|
if (!inert) only.onClick(row);
|
|
180
207
|
},
|
|
@@ -227,13 +254,25 @@ function BulkActionBar({ count, actions }) {
|
|
|
227
254
|
/* @__PURE__ */ jsx(CtlSlot, { children: /* @__PURE__ */ jsx(ActionGroup, { secondary: actions }) })
|
|
228
255
|
] });
|
|
229
256
|
}
|
|
257
|
+
const SKELETON_MIN_REM = {
|
|
258
|
+
entity: 7,
|
|
259
|
+
text: 6,
|
|
260
|
+
"relative-time": 5,
|
|
261
|
+
status: 4,
|
|
262
|
+
money: 4.5,
|
|
263
|
+
number: 3.5
|
|
264
|
+
};
|
|
265
|
+
function skeletonMinWidth(column) {
|
|
266
|
+
const kind = resolveKind(column);
|
|
267
|
+
const rem = kind === void 0 ? void 0 : SKELETON_MIN_REM[kind];
|
|
268
|
+
return rem === void 0 ? void 0 : `${rem}rem`;
|
|
269
|
+
}
|
|
230
270
|
function SortIndicator({ direction }) {
|
|
231
271
|
if (!direction) return null;
|
|
232
272
|
return /* @__PURE__ */ jsx(Box, { component: "span", ml: 4, "aria-hidden": true, children: direction === "asc" ? "\u2191" : "\u2193" });
|
|
233
273
|
}
|
|
234
274
|
const ARIA_SORT = { asc: "ascending", desc: "descending" };
|
|
235
275
|
const NUMERIC_CELL_STYLE = {
|
|
236
|
-
fontFamily: "var(--mantine-font-family-monospace)",
|
|
237
276
|
fontSize: VX.text.sm,
|
|
238
277
|
fontWeight: 500,
|
|
239
278
|
fontVariantNumeric: "tabular-nums",
|
|
@@ -241,19 +280,20 @@ const NUMERIC_CELL_STYLE = {
|
|
|
241
280
|
};
|
|
242
281
|
const RANGE_LABEL_STYLE = {
|
|
243
282
|
fontFamily: "var(--mantine-font-family-monospace)",
|
|
244
|
-
fontSize: VX.text.
|
|
283
|
+
fontSize: VX.text.micro,
|
|
245
284
|
fontVariantNumeric: "tabular-nums",
|
|
246
285
|
color: "var(--vx-faint)"
|
|
247
286
|
};
|
|
248
287
|
const DEFAULT_PAGE_SIZE_OPTIONS = [10, 25, 50, 100];
|
|
249
|
-
const TABLE_HEADER_LEAD_STYLE = { flex: "
|
|
250
|
-
const TABLE_TOOLBAR_STYLE = { flex: "
|
|
288
|
+
const TABLE_HEADER_LEAD_STYLE = { flex: "0 1 auto", minWidth: 0 };
|
|
289
|
+
const TABLE_TOOLBAR_STYLE = { flex: "1 1 auto", minWidth: 0 };
|
|
251
290
|
const SEARCH_WIDTH = 220;
|
|
291
|
+
const SEARCH_SHRINK = 100;
|
|
252
292
|
const SEARCH_DEBOUNCE_MS = 250;
|
|
253
293
|
const TABLE_SEARCH_STYLE = {
|
|
254
294
|
// `width` as well as the basis — see the `SEARCH_WIDTH` JSDoc.
|
|
255
295
|
width: SEARCH_WIDTH,
|
|
256
|
-
flex: `0
|
|
296
|
+
flex: `0 ${SEARCH_SHRINK} ${SEARCH_WIDTH}px`,
|
|
257
297
|
minWidth: "12ch",
|
|
258
298
|
maxWidth: "100%"
|
|
259
299
|
};
|
|
@@ -267,144 +307,6 @@ function getOrderedHeaderGroups(table) {
|
|
|
267
307
|
headers: [...start[index]?.headers ?? [], ...group.headers, ...end[index]?.headers ?? []]
|
|
268
308
|
}));
|
|
269
309
|
}
|
|
270
|
-
function getPinnedCellStyle(table, column) {
|
|
271
|
-
const pinned = column.getIsPinned();
|
|
272
|
-
if (!pinned) return void 0;
|
|
273
|
-
const size = column.getSize();
|
|
274
|
-
const shared = {
|
|
275
|
-
position: "sticky",
|
|
276
|
-
zIndex: 1,
|
|
277
|
-
width: size,
|
|
278
|
-
minWidth: size,
|
|
279
|
-
maxWidth: size,
|
|
280
|
-
backgroundColor: VX.surface.panel
|
|
281
|
-
};
|
|
282
|
-
if (pinned === "start") {
|
|
283
|
-
const isEdge2 = column.getPinnedIndex() === table.getStartLeafColumns().length - 1;
|
|
284
|
-
return {
|
|
285
|
-
...shared,
|
|
286
|
-
insetInlineStart: column.getStart("start"),
|
|
287
|
-
boxShadow: isEdge2 ? `4px 0 6px -4px ${alpha(VX.ink, 0.18)}` : void 0
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
const isEdge = column.getPinnedIndex() === 0;
|
|
291
|
-
return {
|
|
292
|
-
...shared,
|
|
293
|
-
insetInlineEnd: column.getAfter("end"),
|
|
294
|
-
boxShadow: isEdge ? `-4px 0 6px -4px ${alpha(VX.ink, 0.18)}` : void 0
|
|
295
|
-
};
|
|
296
|
-
}
|
|
297
|
-
function columnDefId(column) {
|
|
298
|
-
if (column.id !== void 0) return column.id;
|
|
299
|
-
return "accessorKey" in column && typeof column.accessorKey === "string" ? column.accessorKey : void 0;
|
|
300
|
-
}
|
|
301
|
-
function foldOrder(columns) {
|
|
302
|
-
return columns.map((column, index) => ({
|
|
303
|
-
id: columnDefId(column),
|
|
304
|
-
priority: column.meta?.priority ?? index,
|
|
305
|
-
index
|
|
306
|
-
})).filter(
|
|
307
|
-
(candidate) => Boolean(candidate.id)
|
|
308
|
-
).toSorted((a, b) => b.priority - a.priority || b.index - a.index).map((candidate) => candidate.id);
|
|
309
|
-
}
|
|
310
|
-
const FOLD_ID_ATTR = "data-basalt-fold-id";
|
|
311
|
-
function planColumnFold(input) {
|
|
312
|
-
const { room, toggleWidth, overhead, fixedCount = 0, order, widths } = input;
|
|
313
|
-
const known = order.filter((id) => widths.has(id));
|
|
314
|
-
const roundingSlack = (known.length + fixedCount + 1) / 2;
|
|
315
|
-
let unfolded = overhead + known.reduce((sum, id) => sum + (widths.get(id) ?? 0), 0);
|
|
316
|
-
const folded = /* @__PURE__ */ new Set();
|
|
317
|
-
for (const id of known) {
|
|
318
|
-
if (folded.size >= known.length - 1) break;
|
|
319
|
-
const withToggle = unfolded + (folded.size > 0 ? toggleWidth : 0);
|
|
320
|
-
if (withToggle <= room + roundingSlack) break;
|
|
321
|
-
folded.add(id);
|
|
322
|
-
unfolded -= widths.get(id) ?? 0;
|
|
323
|
-
}
|
|
324
|
-
return folded;
|
|
325
|
-
}
|
|
326
|
-
function useColumnFold(input) {
|
|
327
|
-
const { active, order, fixedIds } = input;
|
|
328
|
-
const wrapperRef = useRef(null);
|
|
329
|
-
const [folded, setFolded] = useState(EMPTY_FOLD_SET);
|
|
330
|
-
const orderRef = useRef(order);
|
|
331
|
-
const fixedIdsRef = useRef(fixedIds);
|
|
332
|
-
useLayoutEffect(() => {
|
|
333
|
-
orderRef.current = order;
|
|
334
|
-
fixedIdsRef.current = fixedIds;
|
|
335
|
-
});
|
|
336
|
-
if ((!active || order.length === 0) && folded.size > 0) setFolded(EMPTY_FOLD_SET);
|
|
337
|
-
useMeasuredWidths({
|
|
338
|
-
resolveRoot: () => wrapperRef.current,
|
|
339
|
-
signature: `${order.join("|")}::${fixedIds.join("|")}`,
|
|
340
|
-
enabled: active && order.length > 0,
|
|
341
|
-
// The table too, not only the wrapper: a re-measured column set moves its min-content width
|
|
342
|
-
// while the wrapper's own box never changes.
|
|
343
|
-
extra: (root) => [root.querySelector("table")],
|
|
344
|
-
onMeasure: (root, boxes) => {
|
|
345
|
-
for (const cell of root.querySelectorAll(`[${FOLD_ID_ATTR}]`)) {
|
|
346
|
-
const id = cell.getAttribute(FOLD_ID_ATTR);
|
|
347
|
-
if (id !== null && cell.offsetWidth > 0) {
|
|
348
|
-
boxes.current.set(id, { width: cell.offsetWidth, height: cell.offsetHeight });
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
const room = root.clientWidth;
|
|
352
|
-
if (room === 0) return;
|
|
353
|
-
const widths = new Map([...boxes.current].map(([id, box]) => [id, box.width]));
|
|
354
|
-
const overhead = fixedIdsRef.current.reduce((sum, id) => sum + (widths.get(id) ?? 0), 0);
|
|
355
|
-
const next = planColumnFold({
|
|
356
|
-
room,
|
|
357
|
-
// The disclosure toggle is a fixed icon-button cell matched to the coarse hit floor, so it
|
|
358
|
-
// reads as one more `--vx-hit` control rather than a narrower afterthought.
|
|
359
|
-
toggleWidth: HIT_COARSE,
|
|
360
|
-
overhead,
|
|
361
|
-
fixedCount: fixedIdsRef.current.length,
|
|
362
|
-
order: orderRef.current,
|
|
363
|
-
widths
|
|
364
|
-
});
|
|
365
|
-
setFolded(
|
|
366
|
-
(current) => current.size === next.size && [...current].every((id) => next.has(id)) ? current : next
|
|
367
|
-
);
|
|
368
|
-
}
|
|
369
|
-
});
|
|
370
|
-
return { wrapperRef, folded: active ? folded : EMPTY_FOLD_SET };
|
|
371
|
-
}
|
|
372
|
-
function columnLabel(column) {
|
|
373
|
-
const header = column.columnDef.header;
|
|
374
|
-
return typeof header === "string" ? header : column.id;
|
|
375
|
-
}
|
|
376
|
-
function RowDisclosure({
|
|
377
|
-
row,
|
|
378
|
-
folded
|
|
379
|
-
}) {
|
|
380
|
-
const cells = row.getAllCells().filter((cell) => folded.has(cell.column.id));
|
|
381
|
-
return /* @__PURE__ */ jsx("div", { className: classes.foldDisclosure, children: cells.map((cell) => /* @__PURE__ */ jsxs("div", { className: classes.foldDisclosureRow, children: [
|
|
382
|
-
/* @__PURE__ */ jsx(Text, { className: classes.foldDisclosureLabel, children: columnLabel(cell.column) }),
|
|
383
|
-
/* @__PURE__ */ jsx("div", { className: classes.foldDisclosureValue, children: /* @__PURE__ */ jsx(FlexRender, { cell }) })
|
|
384
|
-
] }, cell.id)) });
|
|
385
|
-
}
|
|
386
|
-
function FoldToggle({
|
|
387
|
-
expanded,
|
|
388
|
-
controlsId,
|
|
389
|
-
onToggle
|
|
390
|
-
}) {
|
|
391
|
-
return /* @__PURE__ */ jsx(
|
|
392
|
-
"button",
|
|
393
|
-
{
|
|
394
|
-
type: "button",
|
|
395
|
-
className: classes.foldToggle,
|
|
396
|
-
"data-basalt-hit": true,
|
|
397
|
-
"aria-expanded": expanded,
|
|
398
|
-
"aria-controls": controlsId,
|
|
399
|
-
"aria-label": expanded ? "Hide row details" : "Show row details",
|
|
400
|
-
onClick: (event) => {
|
|
401
|
-
event.stopPropagation();
|
|
402
|
-
onToggle();
|
|
403
|
-
},
|
|
404
|
-
children: /* @__PURE__ */ jsx(Box, { component: "span", "aria-hidden": true, children: expanded ? "\u25BE" : "\u25B8" })
|
|
405
|
-
}
|
|
406
|
-
);
|
|
407
|
-
}
|
|
408
310
|
const BREACH_REMEDY = {
|
|
409
311
|
inert: "`enablePagination` is not set, so `manualPagination` never reaches the table and the server page renders as if it were the whole set, with no bar to say otherwise. Pass `enablePagination`, or drop `manualPagination`.",
|
|
410
312
|
total: 'neither `rowCount` nor `pageCount` was given, so "of N" counts only the rows on this page and the pager collapses to one page nobody can leave. Pass `rowCount={total}`.',
|
|
@@ -465,11 +367,11 @@ function BasaltDataTable(props) {
|
|
|
465
367
|
enableSorting = true,
|
|
466
368
|
manualSorting = false,
|
|
467
369
|
striped,
|
|
468
|
-
highlightOnHover,
|
|
370
|
+
highlightOnHover = true,
|
|
469
371
|
emptyState,
|
|
470
372
|
isLoading = false,
|
|
471
373
|
query,
|
|
472
|
-
skeletonRows
|
|
374
|
+
skeletonRows,
|
|
473
375
|
enableGlobalFilter = false,
|
|
474
376
|
globalFilterPlaceholder = "Search\u2026",
|
|
475
377
|
searchIcon,
|
|
@@ -563,7 +465,7 @@ function BasaltDataTable(props) {
|
|
|
563
465
|
const totalIsAuthoritative = !breaches.includes("total");
|
|
564
466
|
const scrolls = maxHeight !== void 0 || minWidth !== void 0;
|
|
565
467
|
const foldEligible = minWidth === void 0;
|
|
566
|
-
const { columnFoldOrder, columnFoldFixedIds } = useMemo(() => {
|
|
468
|
+
const { columnFoldOrder, columnFoldFixedIds, pinCandidates } = useMemo(() => {
|
|
567
469
|
const pinnedIds = /* @__PURE__ */ new Set([...columnPinning.start, ...columnPinning.end]);
|
|
568
470
|
const excluded = new Set(
|
|
569
471
|
columns.flatMap((column) => {
|
|
@@ -574,16 +476,48 @@ function BasaltDataTable(props) {
|
|
|
574
476
|
);
|
|
575
477
|
return {
|
|
576
478
|
columnFoldOrder: foldOrder(columns).filter((id) => !excluded.has(id)),
|
|
577
|
-
columnFoldFixedIds: [...excluded]
|
|
479
|
+
columnFoldFixedIds: [...excluded],
|
|
480
|
+
// Leaf columns the caller did not pin itself, declared order: a caller's END pin must not
|
|
481
|
+
// also become the start pin, where TanStack would resolve it as start.
|
|
482
|
+
pinCandidates: columns.flatMap((column) => {
|
|
483
|
+
const id = columnDefId(column);
|
|
484
|
+
return id === void 0 || "columns" in column || pinnedIds.has(id) ? [] : [id];
|
|
485
|
+
})
|
|
578
486
|
};
|
|
579
487
|
}, [columns, columnPinning]);
|
|
488
|
+
const branch = query === void 0 ? void 0 : dataQueryBranch("BasaltDataTable", query);
|
|
489
|
+
const showSkeleton = branch === void 0 ? isLoading : branch === "pending";
|
|
490
|
+
const queryError = branch === "error" && query !== void 0 ? query : void 0;
|
|
580
491
|
const { cards: showCards, rootRef: projectionRootRef } = useCardProjection(
|
|
581
492
|
renderCard !== void 0
|
|
582
493
|
);
|
|
583
|
-
const
|
|
494
|
+
const renderedRows = useRef(0);
|
|
495
|
+
const [lastLoadedRows, setLastLoadedRows] = useState(0);
|
|
496
|
+
const foldExtraIds = useMemo(
|
|
497
|
+
() => [
|
|
498
|
+
...enableRowSelection ? [SELECT_COLUMN_ID] : [],
|
|
499
|
+
...hasRowActions ? [ACTIONS_COLUMN_ID] : []
|
|
500
|
+
],
|
|
501
|
+
[enableRowSelection, hasRowActions]
|
|
502
|
+
);
|
|
503
|
+
const {
|
|
504
|
+
folded: foldedColumns,
|
|
505
|
+
wrapperRef: foldWrapperRef,
|
|
506
|
+
pinId: autoPinId,
|
|
507
|
+
overflowing: foldOverflowing,
|
|
508
|
+
widths: measuredWidths
|
|
509
|
+
} = useColumnFold({
|
|
584
510
|
active: foldEligible && !showCards,
|
|
585
511
|
order: columnFoldOrder,
|
|
586
|
-
fixedIds: columnFoldFixedIds
|
|
512
|
+
fixedIds: columnFoldFixedIds,
|
|
513
|
+
extraIds: foldExtraIds,
|
|
514
|
+
pinCandidates,
|
|
515
|
+
// An explicit caller pin wins: the fold already treats it as fixed overhead, and a second,
|
|
516
|
+
// implicit one beside it would stack two sticky columns nobody asked for.
|
|
517
|
+
// A one-column table has nothing to scroll beside an identifier.
|
|
518
|
+
allowPin: columnPinning.start.length === 0 && columns.length > 1,
|
|
519
|
+
headerOnly: showSkeleton || queryError !== void 0,
|
|
520
|
+
renderedRows
|
|
587
521
|
});
|
|
588
522
|
const columnVisibility = useMemo(
|
|
589
523
|
() => Object.fromEntries([...foldedColumns].map((id) => [id, false])),
|
|
@@ -591,15 +525,20 @@ function BasaltDataTable(props) {
|
|
|
591
525
|
);
|
|
592
526
|
const hasFolded = foldedColumns.size > 0;
|
|
593
527
|
const foldRows = useRowDisclosure({ data, getRowId });
|
|
594
|
-
const pinningActive = enablePinning || hasRowActions;
|
|
595
|
-
const tablePinning = useMemo(
|
|
596
|
-
|
|
597
|
-
[columnPinning,
|
|
598
|
-
|
|
528
|
+
const pinningActive = enablePinning || hasRowActions || autoPinId !== void 0;
|
|
529
|
+
const tablePinning = useMemo(() => {
|
|
530
|
+
const start = autoPinId === void 0 ? columnPinning.start : [...enableRowSelection ? [SELECT_COLUMN_ID] : [], autoPinId];
|
|
531
|
+
const end = hasRowActions ? [...columnPinning.end, ACTIONS_COLUMN_ID] : columnPinning.end;
|
|
532
|
+
return { start, end };
|
|
533
|
+
}, [columnPinning, hasRowActions, autoPinId, enableRowSelection]);
|
|
534
|
+
const pinStartOffset = hasFolded && tablePinning.start.length > 0 ? HIT_COARSE : 0;
|
|
535
|
+
const autoPinMinWidth = autoPinId === void 0 ? void 0 : columns.find((column) => columnDefId(column) === autoPinId)?.minSize ?? PIN_MIN_WIDTH;
|
|
536
|
+
const tableId = useId();
|
|
599
537
|
const table = useTable({
|
|
600
538
|
features: basaltTableFeatures,
|
|
601
539
|
data,
|
|
602
540
|
columns: tableColumns,
|
|
541
|
+
defaultColumn: { cell: DEFAULT_CELL },
|
|
603
542
|
state: {
|
|
604
543
|
sorting: tableState.sorting,
|
|
605
544
|
globalFilter,
|
|
@@ -638,10 +577,22 @@ function BasaltDataTable(props) {
|
|
|
638
577
|
const showSearch = enableGlobalFilter && filteringEnabled;
|
|
639
578
|
const showFacets = hasFacets && filteringEnabled;
|
|
640
579
|
const showToolbar = showSearch || showFacets || Boolean(actions);
|
|
641
|
-
const
|
|
642
|
-
|
|
643
|
-
|
|
580
|
+
const { ref: headerRef, narrow: narrowToolbar } = useNarrowerThan(
|
|
581
|
+
CONTAINER_CLASSES.regular,
|
|
582
|
+
showToolbar
|
|
583
|
+
);
|
|
644
584
|
const columnCount = columns.length + (enableRowSelection ? 1 : 0) + (hasRowActions ? 1 : 0) + (hasFolded ? 1 : 0) - foldedColumns.size;
|
|
585
|
+
const fullLeafColumns = pinningActive ? [
|
|
586
|
+
...table.getStartLeafColumns(),
|
|
587
|
+
...table.getCenterLeafColumns(),
|
|
588
|
+
...table.getEndLeafColumns()
|
|
589
|
+
] : table.getAllLeafColumns();
|
|
590
|
+
const colIndexOffset = hasFolded ? 1 : 0;
|
|
591
|
+
const colIndexById = new Map(
|
|
592
|
+
fullLeafColumns.map((column, index) => [column.id, index + 1 + colIndexOffset])
|
|
593
|
+
);
|
|
594
|
+
const ariaColCount = fullLeafColumns.length + colIndexOffset;
|
|
595
|
+
const foldedLabel = fullLeafColumns.filter((column) => foldedColumns.has(column.id)).map((column) => columnLabel(column)).join(", ");
|
|
645
596
|
const selectedModelRows = enableRowSelection ? table.getSelectedRowModel().rows : void 0;
|
|
646
597
|
const selectedRows = useMemo(
|
|
647
598
|
() => selectedModelRows?.map((row) => row.original) ?? [],
|
|
@@ -653,22 +604,51 @@ function BasaltDataTable(props) {
|
|
|
653
604
|
);
|
|
654
605
|
const headerGroups = pinningActive ? getOrderedHeaderGroups(table) : table.getHeaderGroups();
|
|
655
606
|
const rows = table.getRowModel().rows;
|
|
607
|
+
const stateless = showSkeleton || queryError !== void 0;
|
|
608
|
+
useLayoutEffect(() => {
|
|
609
|
+
renderedRows.current = rows.length;
|
|
610
|
+
});
|
|
611
|
+
if (!stateless && rows.length > 0 && rows.length !== lastLoadedRows) {
|
|
612
|
+
setLastLoadedRows(rows.length);
|
|
613
|
+
}
|
|
656
614
|
const pageStickyHeader = !scrolls && stickyHeader === true;
|
|
657
615
|
const { wrapperRef: containmentRef, contained } = useMeasuredContainment(
|
|
658
616
|
pageStickyHeader && !showCards
|
|
659
617
|
);
|
|
660
618
|
const resolvedStickyHeaderOffset = scrolls ? void 0 : stickyHeaderOffset;
|
|
619
|
+
const { wrapperRef: minWidthScrollerRef, contained: minWidthOverflowing } = useMeasuredContainment(!foldEligible && !showCards);
|
|
620
|
+
const scrollerLabel = `${title ?? "Table"}, scrolls horizontally`;
|
|
621
|
+
const scrollerProps = (overflowing) => overflowing ? { tabIndex: 0, role: "region", "aria-label": scrollerLabel, className: classes.scroller } : void 0;
|
|
661
622
|
const errorNode = queryError !== void 0 && /* @__PURE__ */ jsx(
|
|
662
623
|
ErrorState,
|
|
663
624
|
{
|
|
664
625
|
error: queryError.error,
|
|
665
|
-
title: "Could not load
|
|
626
|
+
title: "Could not load",
|
|
666
627
|
tier: "section",
|
|
667
628
|
retrying: queryError.fetchStatus === "fetching",
|
|
668
629
|
onRetry: () => void queryError.refetch()
|
|
669
630
|
}
|
|
670
631
|
);
|
|
671
|
-
const emptyNode = emptyState ?? /* @__PURE__ */ jsx(
|
|
632
|
+
const emptyNode = emptyState ?? /* @__PURE__ */ jsx(EmptyState, { tier: "section", title: "No data to display." });
|
|
633
|
+
const orderedVisibleColumns = pinningActive ? [
|
|
634
|
+
...table.getStartVisibleLeafColumns(),
|
|
635
|
+
...table.getCenterVisibleLeafColumns(),
|
|
636
|
+
...table.getEndVisibleLeafColumns()
|
|
637
|
+
] : table.getVisibleLeafColumns();
|
|
638
|
+
const pinCtx = {
|
|
639
|
+
table,
|
|
640
|
+
startOffset: pinStartOffset,
|
|
641
|
+
autoPinId,
|
|
642
|
+
autoPinMinWidth
|
|
643
|
+
};
|
|
644
|
+
const toggleCell = foldToggleCellProps(pinCtx);
|
|
645
|
+
const { fitIds, spacer } = planColumnSizing(
|
|
646
|
+
orderedVisibleColumns,
|
|
647
|
+
/* @__PURE__ */ new Set([SELECT_COLUMN_ID, ACTIONS_COLUMN_ID])
|
|
648
|
+
);
|
|
649
|
+
const fitAttr = (id) => fitIds.has(id) ? { "data-fit": true } : void 0;
|
|
650
|
+
const spanCount = columnCount + (spacer ? 1 : 0);
|
|
651
|
+
const skeletonCount = enablePagination ? table.state.pagination.pageSize : lastLoadedRows > 0 ? lastLoadedRows : skeletonRows ?? 5;
|
|
672
652
|
const tableNode = /* @__PURE__ */ jsxs(
|
|
673
653
|
Table,
|
|
674
654
|
{
|
|
@@ -677,6 +657,7 @@ function BasaltDataTable(props) {
|
|
|
677
657
|
pageStickyHeader && !contained && classes.pageSticky,
|
|
678
658
|
classNames?.table
|
|
679
659
|
),
|
|
660
|
+
"aria-colcount": ariaColCount,
|
|
680
661
|
...striped !== void 0 && { striped },
|
|
681
662
|
...highlightOnHover !== void 0 && { highlightOnHover },
|
|
682
663
|
...stickyHeader !== void 0 && { stickyHeader },
|
|
@@ -689,20 +670,24 @@ function BasaltDataTable(props) {
|
|
|
689
670
|
withTableBorder,
|
|
690
671
|
children: [
|
|
691
672
|
/* @__PURE__ */ jsx(Table.Thead, { children: headerGroups.map((headerGroup) => /* @__PURE__ */ jsxs(Table.Tr, { children: [
|
|
692
|
-
hasFolded && /* @__PURE__ */ jsx(Table.Th, {
|
|
673
|
+
hasFolded && /* @__PURE__ */ jsx(Table.Th, { ...toggleCell, "aria-colindex": 1, children: /* @__PURE__ */ jsx(FoldHeaderLabel, { count: foldedColumns.size, foldedLabel }) }),
|
|
693
674
|
headerGroup.headers.map((header) => {
|
|
694
675
|
const canSort = sortingEnabled && header.column.getCanSort();
|
|
695
676
|
const sorted = header.column.getIsSorted();
|
|
696
677
|
const toggleSorting = header.column.getToggleSortingHandler();
|
|
697
|
-
const
|
|
698
|
-
const align = resolveAlign(header.column);
|
|
678
|
+
const pinned = pinningActive ? pinnedCellProps(pinCtx, header.column) : void 0;
|
|
679
|
+
const align = resolveAlign(header.column) ?? kindAlign(resolveKind(header.column));
|
|
699
680
|
const isSelectColumn = header.column.id === SELECT_COLUMN_ID;
|
|
700
681
|
const isFoldCandidate = !isSelectColumn && header.column.id !== ACTIONS_COLUMN_ID;
|
|
701
682
|
return /* @__PURE__ */ jsxs(
|
|
702
683
|
Table.Th,
|
|
703
684
|
{
|
|
704
|
-
|
|
705
|
-
|
|
685
|
+
"aria-colindex": colIndexById.get(header.column.id),
|
|
686
|
+
className: cx(isSelectColumn && classes.selectCell, pinned?.className),
|
|
687
|
+
...fitAttr(header.column.id),
|
|
688
|
+
...{
|
|
689
|
+
[isFoldCandidate ? FOLD_ID_ATTR : FIXED_ID_ATTR]: header.column.id
|
|
690
|
+
},
|
|
706
691
|
onClick: canSort ? toggleSorting : void 0,
|
|
707
692
|
onKeyDown: canSort ? (event) => {
|
|
708
693
|
if (event.key !== "Enter" && event.key !== " ") return;
|
|
@@ -714,7 +699,7 @@ function BasaltDataTable(props) {
|
|
|
714
699
|
style: {
|
|
715
700
|
...canSort ? { cursor: "pointer", userSelect: "none" } : void 0,
|
|
716
701
|
...align !== void 0 && { textAlign: align },
|
|
717
|
-
...
|
|
702
|
+
...pinned?.style
|
|
718
703
|
},
|
|
719
704
|
children: [
|
|
720
705
|
header.isPlaceholder ? null : /* @__PURE__ */ jsx(FlexRender, { header }),
|
|
@@ -723,9 +708,42 @@ function BasaltDataTable(props) {
|
|
|
723
708
|
},
|
|
724
709
|
header.id
|
|
725
710
|
);
|
|
726
|
-
})
|
|
711
|
+
}),
|
|
712
|
+
spacer && /* @__PURE__ */ jsx(Table.Th, { className: classes.spacer, "aria-hidden": true })
|
|
727
713
|
] }, headerGroup.id)) }),
|
|
728
|
-
/* @__PURE__ */ jsx(Table.Tbody, { children: queryError !== void 0 ? /* @__PURE__ */ jsx(Table.Tr, { children: /* @__PURE__ */ jsx(Table.Td, { colSpan:
|
|
714
|
+
/* @__PURE__ */ jsx(Table.Tbody, { children: queryError !== void 0 ? /* @__PURE__ */ jsx(Table.Tr, { children: /* @__PURE__ */ jsx(Table.Td, { colSpan: spanCount, children: errorNode }) }) : showSkeleton ? (
|
|
715
|
+
// The same visible columns as the header — a folded table loads folded, and the pinned
|
|
716
|
+
// identifier keeps its sticky cell, so nothing shifts when the rows arrive.
|
|
717
|
+
Array.from({ length: skeletonCount }, (_, rowIndex) => /* @__PURE__ */ jsxs(Table.Tr, { children: [
|
|
718
|
+
hasFolded && /* @__PURE__ */ jsx(Table.Td, { ...toggleCell, "aria-colindex": 1, children: /* @__PURE__ */ jsx(Skeleton, { h: 12, w: 12, radius: "sm", display: "inline-block" }) }),
|
|
719
|
+
orderedVisibleColumns.map((column) => {
|
|
720
|
+
const pinned = pinningActive ? pinnedCellProps(pinCtx, column) : void 0;
|
|
721
|
+
const kind = resolveKind(column);
|
|
722
|
+
const measuredWidth = fitIds.has(column.id) ? measuredWidths.get(column.id) : void 0;
|
|
723
|
+
return /* @__PURE__ */ jsx(
|
|
724
|
+
Table.Td,
|
|
725
|
+
{
|
|
726
|
+
"aria-colindex": colIndexById.get(column.id),
|
|
727
|
+
className: pinned?.className,
|
|
728
|
+
...fitAttr(column.id),
|
|
729
|
+
style: {
|
|
730
|
+
minWidth: measuredWidth === void 0 ? skeletonMinWidth(column) : measuredWidth,
|
|
731
|
+
...pinned?.style
|
|
732
|
+
},
|
|
733
|
+
children: column.id === SELECT_COLUMN_ID || column.id === ACTIONS_COLUMN_ID ? null : /* @__PURE__ */ jsx(
|
|
734
|
+
KindSkeleton,
|
|
735
|
+
{
|
|
736
|
+
kind,
|
|
737
|
+
right: (resolveAlign(column) ?? kindAlign(kind)) === "right"
|
|
738
|
+
}
|
|
739
|
+
)
|
|
740
|
+
},
|
|
741
|
+
column.id
|
|
742
|
+
);
|
|
743
|
+
}),
|
|
744
|
+
spacer && /* @__PURE__ */ jsx(Table.Td, { "aria-hidden": true })
|
|
745
|
+
] }, `skeleton-${rowIndex}`))
|
|
746
|
+
) : rows.length === 0 ? /* @__PURE__ */ jsx(Table.Tr, { children: /* @__PURE__ */ jsx(Table.Td, { colSpan: spanCount, children: emptyNode }) }) : rows.map((row) => {
|
|
729
747
|
const cells = pinningActive ? [
|
|
730
748
|
...row.getStartVisibleCells(),
|
|
731
749
|
...row.getCenterVisibleCells(),
|
|
@@ -739,53 +757,83 @@ function BasaltDataTable(props) {
|
|
|
739
757
|
...enableRowSelection && row.getIsSelected() && { "data-selected": true },
|
|
740
758
|
...activationProps(onRowActivate, row.original),
|
|
741
759
|
children: [
|
|
742
|
-
hasFolded && /* @__PURE__ */ jsx(Table.Td, {
|
|
760
|
+
hasFolded && /* @__PURE__ */ jsx(Table.Td, { ...toggleCell, "aria-colindex": 1, children: /* @__PURE__ */ jsx(
|
|
743
761
|
FoldToggle,
|
|
744
762
|
{
|
|
745
763
|
expanded: rowExpanded,
|
|
746
|
-
controlsId: `${row.id}-fold`,
|
|
764
|
+
controlsId: `${tableId}-${row.id}-fold`,
|
|
765
|
+
foldedLabel,
|
|
747
766
|
onToggle: () => foldRows.toggle(row.id)
|
|
748
767
|
}
|
|
749
768
|
) }),
|
|
750
769
|
cells.map((cell) => {
|
|
751
|
-
const
|
|
752
|
-
const
|
|
770
|
+
const pinned = pinningActive ? pinnedCellProps(pinCtx, cell.column) : void 0;
|
|
771
|
+
const pinnedValue = cell.column.id === autoPinId ? cell.getValue() : void 0;
|
|
772
|
+
const kind = resolveKind(cell.column);
|
|
773
|
+
const align = resolveAlign(cell.column) ?? kindAlign(kind);
|
|
753
774
|
return /* @__PURE__ */ jsx(
|
|
754
775
|
Table.Td,
|
|
755
776
|
{
|
|
756
|
-
|
|
757
|
-
|
|
777
|
+
"aria-colindex": colIndexById.get(cell.column.id),
|
|
778
|
+
className: cx(
|
|
779
|
+
cell.column.id === SELECT_COLUMN_ID && classes.selectCell,
|
|
780
|
+
kind !== void 0 && kindClass(kind),
|
|
781
|
+
pinned?.className
|
|
782
|
+
),
|
|
783
|
+
...(typeof pinnedValue === "string" || typeof pinnedValue === "number") && {
|
|
784
|
+
title: String(pinnedValue)
|
|
758
785
|
},
|
|
786
|
+
...kind !== void 0 && { "data-kind": kind },
|
|
787
|
+
...fitAttr(cell.column.id),
|
|
759
788
|
...stopsRowActivation(cell) && {
|
|
760
789
|
// The label's ::after fills the select cell, so a tap on it bubbles to the
|
|
761
790
|
// row; the actions menu portals out but React bubbles through the portal.
|
|
762
791
|
onClick: (event) => event.stopPropagation()
|
|
763
792
|
},
|
|
764
793
|
style: {
|
|
765
|
-
...typeof cell.getValue() === "number" && cell.column.columnDef.meta?.numeral !== false ? NUMERIC_CELL_STYLE : void 0,
|
|
794
|
+
...kind === void 0 && typeof cell.getValue() === "number" && cell.column.columnDef.meta?.numeral !== false ? NUMERIC_CELL_STYLE : void 0,
|
|
766
795
|
...align !== void 0 && { textAlign: align },
|
|
767
|
-
...
|
|
796
|
+
...pinned?.style
|
|
768
797
|
},
|
|
769
|
-
children: /* @__PURE__ */ jsx(
|
|
798
|
+
children: /* @__PURE__ */ jsx(CellContent, { cell })
|
|
770
799
|
},
|
|
771
800
|
cell.id
|
|
772
801
|
);
|
|
773
|
-
})
|
|
802
|
+
}),
|
|
803
|
+
spacer && /* @__PURE__ */ jsx(Table.Td, { "aria-hidden": true })
|
|
774
804
|
]
|
|
775
805
|
}
|
|
776
806
|
),
|
|
777
|
-
rowExpanded && /* @__PURE__ */ jsx(
|
|
807
|
+
rowExpanded && /* @__PURE__ */ jsx(
|
|
808
|
+
Table.Tr,
|
|
809
|
+
{
|
|
810
|
+
id: `${tableId}-${row.id}-fold`,
|
|
811
|
+
className: classes.foldDisclosureRowTr,
|
|
812
|
+
children: /* @__PURE__ */ jsx(
|
|
813
|
+
Table.Td,
|
|
814
|
+
{
|
|
815
|
+
colSpan: spanCount,
|
|
816
|
+
className: classes.foldDisclosureCell,
|
|
817
|
+
"aria-colindex": 1,
|
|
818
|
+
children: /* @__PURE__ */ jsx(RowDisclosure, { row, folded: foldedColumns })
|
|
819
|
+
}
|
|
820
|
+
)
|
|
821
|
+
}
|
|
822
|
+
)
|
|
778
823
|
] }, row.id);
|
|
779
824
|
}) })
|
|
780
825
|
]
|
|
781
826
|
}
|
|
782
827
|
);
|
|
783
|
-
const renderCardList = () => /* @__PURE__ */ jsx(Stack, { gap: "xs", className: cx(classNames?.table), children: queryError !== void 0 ? errorNode : showSkeleton ? Array.from({ length:
|
|
828
|
+
const renderCardList = () => /* @__PURE__ */ jsx(Stack, { gap: "xs", className: cx(classNames?.table), children: queryError !== void 0 ? errorNode : showSkeleton ? Array.from({ length: skeletonCount }, (_, index) => /* @__PURE__ */ jsx(Skeleton, { height: 48, radius: "md" }, `skeleton-${index}`)) : rows.length === 0 ? emptyNode : rows.map((row) => /* @__PURE__ */ jsx(Box, { ...activationProps(onRowActivate, row.original), children: renderCard?.(row.original) }, row.id)) });
|
|
784
829
|
const paginationState = table.state.pagination;
|
|
785
830
|
const pageSizeRows = [.../* @__PURE__ */ new Set([...pageSizeOptions, paginationState.pageSize])].sort((a, b) => a - b).map((size) => ({ value: String(size), label: `${size} / page` }));
|
|
786
831
|
const total = table.getRowCount();
|
|
787
832
|
const rangeStart = total === 0 ? 0 : paginationState.pageIndex * paginationState.pageSize + 1;
|
|
788
833
|
const rangeEnd = Math.min((paginationState.pageIndex + 1) * paginationState.pageSize, total);
|
|
834
|
+
const rangeInBounds = rangeStart <= rangeEnd || total === 0;
|
|
835
|
+
const unfilteredCount = manualPagination ? total : table.getPreFilteredRowModel().rows.length;
|
|
836
|
+
const showFooter = enablePagination && (stateless || unfilteredCount > 0);
|
|
789
837
|
return /* @__PURE__ */ jsxs(
|
|
790
838
|
"div",
|
|
791
839
|
{
|
|
@@ -793,71 +841,95 @@ function BasaltDataTable(props) {
|
|
|
793
841
|
className: cx(classNames?.root, className),
|
|
794
842
|
...style !== void 0 && { style },
|
|
795
843
|
children: [
|
|
796
|
-
(title !== void 0 || showToolbar) && /* @__PURE__ */ jsxs(
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
{
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
844
|
+
(title !== void 0 || showToolbar) && /* @__PURE__ */ jsxs(
|
|
845
|
+
Group,
|
|
846
|
+
{
|
|
847
|
+
ref: headerRef,
|
|
848
|
+
className: classes.tableHeader,
|
|
849
|
+
justify: "space-between",
|
|
850
|
+
align: "center",
|
|
851
|
+
wrap: "wrap",
|
|
852
|
+
gap: "xs",
|
|
853
|
+
mb: "xs",
|
|
854
|
+
children: [
|
|
855
|
+
title !== void 0 ? /* @__PURE__ */ jsx(Box, { style: TABLE_HEADER_LEAD_STYLE, children: /* @__PURE__ */ jsx(
|
|
856
|
+
WidgetHeader,
|
|
857
|
+
{
|
|
858
|
+
tier: "widget",
|
|
859
|
+
title,
|
|
860
|
+
...icon !== void 0 && { icon },
|
|
861
|
+
...subtitle !== void 0 && { subtitle },
|
|
862
|
+
...!stateless && { count: table.getRowCount() }
|
|
863
|
+
}
|
|
864
|
+
) }) : null,
|
|
865
|
+
showToolbar && /* @__PURE__ */ jsx(CtlSlot, { children: /* @__PURE__ */ jsxs(
|
|
866
|
+
Group,
|
|
867
|
+
{
|
|
868
|
+
className: cx(classes.toolbar, classNames?.toolbar),
|
|
869
|
+
"data-basalt-dense": true,
|
|
870
|
+
gap: "xs",
|
|
871
|
+
align: "center",
|
|
872
|
+
style: TABLE_TOOLBAR_STYLE,
|
|
873
|
+
children: [
|
|
874
|
+
showSearch && /* @__PURE__ */ jsx(
|
|
875
|
+
TextInput,
|
|
876
|
+
{
|
|
877
|
+
size: "ctl",
|
|
878
|
+
classNames: { wrapper: classes.toolbarWrapper, input: classes.toolbarInput },
|
|
879
|
+
wrapperProps: { "data-basalt-hit": true },
|
|
880
|
+
radius: "md",
|
|
881
|
+
style: TABLE_SEARCH_STYLE,
|
|
882
|
+
placeholder: globalFilterPlaceholder,
|
|
883
|
+
leftSection: searchIcon,
|
|
884
|
+
value: searchDraft,
|
|
885
|
+
onChange: (event) => {
|
|
886
|
+
setSearchDraft(event.currentTarget.value);
|
|
887
|
+
commitSearch(event.currentTarget.value);
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
),
|
|
891
|
+
showFacets && /* @__PURE__ */ jsx(FilterSet, { inline: narrowToolbar ? 0 : 1, children: facets?.map((facet) => {
|
|
892
|
+
const column = resolveFacetColumn(table, facet);
|
|
893
|
+
if (!column) return null;
|
|
894
|
+
return facet.multiple ? /* @__PURE__ */ jsx(
|
|
895
|
+
MultiSelectFilter,
|
|
896
|
+
{
|
|
897
|
+
field: facetMultiHandle(column, facet),
|
|
898
|
+
label: facet.label
|
|
899
|
+
},
|
|
900
|
+
facet.columnId
|
|
901
|
+
) : /* @__PURE__ */ jsx(
|
|
902
|
+
EnumFilter,
|
|
903
|
+
{
|
|
904
|
+
field: facetEnumHandle(column, facet),
|
|
905
|
+
label: facet.label
|
|
906
|
+
},
|
|
907
|
+
facet.columnId
|
|
908
|
+
);
|
|
909
|
+
}) }),
|
|
910
|
+
actions !== void 0 && /* @__PURE__ */ jsx("div", { className: classes.toolbarActions, children: /* @__PURE__ */ jsx(BarActionSlot, { actions }) })
|
|
911
|
+
]
|
|
912
|
+
}
|
|
913
|
+
) })
|
|
914
|
+
]
|
|
915
|
+
}
|
|
916
|
+
),
|
|
855
917
|
bulkBarActions !== void 0 && /* @__PURE__ */ jsx(BulkActionBar, { count: selectedRows.length, actions: bulkBarActions }),
|
|
856
918
|
showCards ? maxHeight === void 0 ? renderCardList() : /* @__PURE__ */ jsx(ScrollArea.Autosize, { mah: maxHeight, type: "hover", scrollbars: "y", children: renderCardList() }) : !foldEligible ? (
|
|
857
919
|
// An explicit `minWidth` is the one genuinely DECLARED horizontal floor — the column fold
|
|
858
920
|
// never engages here (see `foldEligible`, above), so this shape keeps its exact
|
|
859
921
|
// pre-existing DOM: no extra measuring wrapper for a table nothing folds.
|
|
860
|
-
/* @__PURE__ */ jsx(
|
|
922
|
+
/* @__PURE__ */ jsx(
|
|
923
|
+
Table.ScrollContainer,
|
|
924
|
+
{
|
|
925
|
+
ref: minWidthScrollerRef,
|
|
926
|
+
type: "native",
|
|
927
|
+
minWidth: minWidth ?? 0,
|
|
928
|
+
maxHeight,
|
|
929
|
+
...scrollerProps(minWidthOverflowing),
|
|
930
|
+
children: tableNode
|
|
931
|
+
}
|
|
932
|
+
)
|
|
861
933
|
) : (
|
|
862
934
|
// The column fold's own measuring box (`useColumnFold`) — wraps every remaining shape,
|
|
863
935
|
// `maxHeight`-only included: a vertical cap is orthogonal to column width, so a
|
|
@@ -872,18 +944,32 @@ function BasaltDataTable(props) {
|
|
|
872
944
|
"div",
|
|
873
945
|
{
|
|
874
946
|
ref: containmentRef,
|
|
875
|
-
className: classes.containment,
|
|
947
|
+
className: cx(classes.containment, contained && classes.scroller),
|
|
876
948
|
"data-contained": contained ? "true" : "false",
|
|
949
|
+
...contained && {
|
|
950
|
+
tabIndex: 0,
|
|
951
|
+
role: "region",
|
|
952
|
+
"aria-label": scrollerLabel
|
|
953
|
+
},
|
|
877
954
|
children: tableNode
|
|
878
955
|
}
|
|
879
956
|
)
|
|
880
957
|
) : (
|
|
881
958
|
// `pageStickyHeader` is false whenever `maxHeight` is set (`scrolls` above), so a vertical
|
|
882
959
|
// cap lands here — its own `ScrollArea` scrollport, just with no `minWidth` floor.
|
|
883
|
-
/* @__PURE__ */ jsx(
|
|
960
|
+
/* @__PURE__ */ jsx(
|
|
961
|
+
Table.ScrollContainer,
|
|
962
|
+
{
|
|
963
|
+
type: "native",
|
|
964
|
+
minWidth: 0,
|
|
965
|
+
maxHeight,
|
|
966
|
+
...scrollerProps(foldOverflowing),
|
|
967
|
+
children: tableNode
|
|
968
|
+
}
|
|
969
|
+
)
|
|
884
970
|
) })
|
|
885
971
|
),
|
|
886
|
-
|
|
972
|
+
showFooter && /* @__PURE__ */ jsxs(
|
|
887
973
|
Group,
|
|
888
974
|
{
|
|
889
975
|
className: cx(classNames?.footer),
|
|
@@ -893,18 +979,26 @@ function BasaltDataTable(props) {
|
|
|
893
979
|
gap: "xs",
|
|
894
980
|
align: "center",
|
|
895
981
|
children: [
|
|
896
|
-
/* @__PURE__ */ jsxs(
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
982
|
+
/* @__PURE__ */ jsxs(
|
|
983
|
+
Text,
|
|
984
|
+
{
|
|
985
|
+
style: stateless || !rangeInBounds ? { ...RANGE_LABEL_STYLE, visibility: "hidden" } : RANGE_LABEL_STYLE,
|
|
986
|
+
children: [
|
|
987
|
+
"Showing ",
|
|
988
|
+
rangeStart,
|
|
989
|
+
"\u2013",
|
|
990
|
+
rangeEnd,
|
|
991
|
+
totalIsAuthoritative ? ` of ${total}` : ""
|
|
992
|
+
]
|
|
993
|
+
}
|
|
994
|
+
),
|
|
995
|
+
/* @__PURE__ */ jsxs(Group, { gap: "xs", align: "center", "data-basalt-dense": true, children: [
|
|
904
996
|
/* @__PURE__ */ jsx(
|
|
905
997
|
Select,
|
|
906
998
|
{
|
|
907
999
|
size: "ctl",
|
|
1000
|
+
classNames: { wrapper: classes.toolbarWrapper, input: classes.toolbarInput },
|
|
1001
|
+
wrapperProps: { "data-basalt-hit": true },
|
|
908
1002
|
radius: "md",
|
|
909
1003
|
w: PAGE_SIZE_WIDTH,
|
|
910
1004
|
data: pageSizeRows,
|
|
@@ -917,6 +1011,12 @@ function BasaltDataTable(props) {
|
|
|
917
1011
|
Pagination,
|
|
918
1012
|
{
|
|
919
1013
|
size: "sm",
|
|
1014
|
+
vars: () => ({
|
|
1015
|
+
root: {
|
|
1016
|
+
"--pagination-control-size": "calc(var(--vx-space-control-height-ctl) * var(--mantine-scale))",
|
|
1017
|
+
"--pagination-control-fz": "var(--vx-text-sm)"
|
|
1018
|
+
}
|
|
1019
|
+
}),
|
|
920
1020
|
radius: "md",
|
|
921
1021
|
total: Math.max(table.getPageCount(), 1),
|
|
922
1022
|
value: paginationState.pageIndex + 1,
|