basalt-ui 2.27.2 → 2.29.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 +466 -307
- package/MIGRATING.md +358 -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-app/SKILL.md +3 -3
- package/agent/skills/basalt-charts/SKILL.md +1 -1
- package/agent/skills/basalt-design/SKILL.md +12 -6
- package/agent/skills/basalt-design/references/catalogue.md +42 -36
- package/agent/skills/basalt-design/references/recipes.md +47 -0
- package/agent/skills/basalt-design/references/states.md +1 -1
- package/configs/oxlint-basalt.json +2 -1
- package/configs/oxlint-plugin.js +112 -3
- package/configs/oxlint-plugin.test.ts +99 -4
- package/configs/oxlint.json +1 -0
- 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 +14 -7
- package/dist/charts/ChartCard.d.ts.map +1 -1
- package/dist/charts/ChartCard.js +112 -23
- package/dist/charts/Lines.d.ts.map +1 -1
- package/dist/charts/Lines.js +11 -4
- package/dist/charts/Sparkline.d.ts +14 -2
- package/dist/charts/Sparkline.d.ts.map +1 -1
- package/dist/charts/Sparkline.js +155 -44
- package/dist/charts/chart-box.module.css +59 -2
- package/dist/charts/chart-box.module.css.d.ts +5 -0
- package/dist/charts/chart-card.module.css +28 -17
- package/dist/charts/chart-card.module.css.d.ts +3 -0
- package/dist/charts/compile.d.ts +1 -1
- package/dist/charts/compile.d.ts.map +1 -1
- package/dist/charts/compile.js +38 -27
- 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 +37 -8
- package/dist/charts/ref-label.d.ts.map +1 -1
- package/dist/charts/ref-label.js +55 -10
- package/dist/charts/sparkline.module.css +50 -0
- package/dist/charts/sparkline.module.css.d.ts +3 -0
- package/dist/charts/state.d.ts +4 -4
- package/dist/charts/state.d.ts.map +1 -1
- package/dist/charts/state.js +23 -5
- package/dist/cli/doctor-upgrade.d.ts +11 -0
- package/dist/cli/doctor-upgrade.d.ts.map +1 -1
- package/dist/cli/doctor-upgrade.js +54 -0
- package/dist/cli/doctor.d.ts.map +1 -1
- package/dist/cli/doctor.js +32 -0
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +8 -3
- package/dist/cli/index.d.ts +13 -13
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +36 -2
- package/dist/cli/init.d.ts +6 -0
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +118 -27
- package/dist/cli/router-wiring.d.ts +3 -0
- package/dist/cli/router-wiring.d.ts.map +1 -1
- package/dist/cli/router-wiring.js +2 -0
- package/dist/cli/shot/capture.d.ts +34 -2
- package/dist/cli/shot/capture.d.ts.map +1 -1
- package/dist/cli/shot/capture.js +95 -12
- package/dist/cli/shot/detect.d.ts +4 -1
- package/dist/cli/shot/detect.d.ts.map +1 -1
- package/dist/cli/shot/detect.js +38 -16
- package/dist/cli/shot/index.d.ts.map +1 -1
- package/dist/cli/shot/index.js +9 -2
- package/dist/cli/shot/measure.d.ts.map +1 -1
- package/dist/cli/shot/measure.js +11 -2
- package/dist/cli/shot/types.d.ts +4 -1
- package/dist/cli/shot/types.d.ts.map +1 -1
- package/dist/cli/sync.d.ts.map +1 -1
- package/dist/cli/sync.js +10 -2
- package/dist/common/could-not-load.d.ts +13 -0
- package/dist/common/could-not-load.d.ts.map +1 -0
- package/dist/common/could-not-load.js +14 -0
- 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/index.d.ts +1 -0
- package/dist/common/index.d.ts.map +1 -1
- package/dist/common/index.js +3 -0
- package/dist/common/props.d.ts +20 -0
- package/dist/common/props.d.ts.map +1 -1
- package/dist/common/props.js +13 -1
- package/dist/common/retry-button.module.css +7 -3
- 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 +5 -5
- package/dist/dashboard/bar-list.d.ts.map +1 -1
- package/dist/dashboard/bar-list.js +15 -8
- package/dist/dashboard/bar-list.module.css +21 -5
- 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 +247 -0
- package/dist/dashboard/board.module.css +179 -0
- package/dist/dashboard/board.module.css.d.ts +28 -0
- package/dist/dashboard/empty-state.d.ts +6 -6
- package/dist/dashboard/empty-state.d.ts.map +1 -1
- package/dist/dashboard/empty-state.js +17 -8
- package/dist/dashboard/event-list-model.d.ts +54 -0
- package/dist/dashboard/event-list-model.d.ts.map +1 -0
- package/dist/dashboard/event-list-model.js +76 -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 +89 -0
- package/dist/dashboard/event-list-scroll.d.ts +55 -0
- package/dist/dashboard/event-list-scroll.d.ts.map +1 -0
- package/dist/dashboard/event-list-scroll.js +216 -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 +34 -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 +208 -0
- package/dist/dashboard/event-list.module.css +336 -0
- package/dist/dashboard/event-list.module.css.d.ts +34 -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-model.d.ts +6 -3
- package/dist/dashboard/meter-model.d.ts.map +1 -1
- package/dist/dashboard/meter-model.js +9 -4
- package/dist/dashboard/meter-parts.d.ts +3 -0
- package/dist/dashboard/meter-parts.d.ts.map +1 -1
- package/dist/dashboard/meter-parts.js +36 -6
- package/dist/dashboard/meter.d.ts +3 -3
- package/dist/dashboard/meter.d.ts.map +1 -1
- package/dist/dashboard/meter.js +10 -2
- package/dist/dashboard/meter.module.css +20 -12
- package/dist/dashboard/meter.module.css.d.ts +0 -1
- package/dist/dashboard/page-summary.d.ts +3 -3
- package/dist/dashboard/page-summary.d.ts.map +1 -1
- package/dist/dashboard/page-summary.js +7 -2
- package/dist/dashboard/page-summary.module.css +5 -2
- package/dist/dashboard/query-state.d.ts +9 -8
- package/dist/dashboard/query-state.d.ts.map +1 -1
- package/dist/dashboard/query-state.js +29 -11
- package/dist/dashboard/section.d.ts +11 -3
- package/dist/dashboard/section.d.ts.map +1 -1
- package/dist/dashboard/section.js +34 -7
- package/dist/dashboard/settings-section.d.ts +8 -5
- package/dist/dashboard/settings-section.d.ts.map +1 -1
- package/dist/dashboard/settings-section.js +12 -8
- package/dist/dashboard/settings-section.module.css +25 -4
- package/dist/dashboard/settings-section.module.css.d.ts +1 -0
- 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 +3 -3
- package/dist/dashboard/stat-card.d.ts.map +1 -1
- package/dist/dashboard/stat-card.js +47 -12
- package/dist/dashboard/stat-card.module.css +42 -7
- package/dist/dashboard/stat-card.module.css.d.ts +3 -0
- package/dist/dashboard/stat-group.d.ts +2 -2
- package/dist/dashboard/stat-group.d.ts.map +1 -1
- package/dist/dashboard/stat-group.js +10 -3
- package/dist/dashboard/stat-strip.d.ts +5 -4
- package/dist/dashboard/stat-strip.d.ts.map +1 -1
- package/dist/dashboard/stat-strip.js +41 -31
- package/dist/dashboard/stat-strip.module.css +8 -6
- package/dist/dashboard/visual-slot.d.ts +4 -0
- package/dist/dashboard/visual-slot.d.ts.map +1 -1
- package/dist/dashboard/visual-slot.js +2 -0
- package/dist/dashboard/widget-header.d.ts +6 -6
- package/dist/dashboard/widget-header.d.ts.map +1 -1
- package/dist/dashboard/widget-header.js +4 -2
- package/dist/dashboard/widget-header.module.css +12 -15
- package/dist/format/shared.d.ts.map +1 -1
- package/dist/format/shared.js +24 -1
- package/dist/guard/index.d.ts +1 -1
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +4 -1
- 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 +69 -0
- 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 +47 -0
- package/dist/table/cell-kinds.d.ts.map +1 -0
- package/dist/table/cell-kinds.js +180 -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 +155 -0
- package/dist/table/data-table-fold.d.ts.map +1 -0
- package/dist/table/data-table-fold.js +320 -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 +13 -28
- package/dist/table/data-table.d.ts.map +1 -1
- package/dist/table/data-table.js +362 -255
- package/dist/table/data-table.module.css +282 -3
- package/dist/table/data-table.module.css.d.ts +16 -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 +55 -2
- 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 +295 -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 +175 -31
- package/src/charts/Lines.tsx +13 -4
- package/src/charts/Sparkline.tsx +213 -48
- package/src/charts/chart-box.module.css +59 -2
- package/src/charts/chart-box.module.css.d.ts +5 -0
- package/src/charts/chart-card.module.css +28 -17
- package/src/charts/chart-card.module.css.d.ts +3 -0
- package/src/charts/compile.ts +59 -33
- package/src/charts/labels.ts +175 -24
- package/src/charts/legend.tsx +3 -2
- package/src/charts/ref-label.ts +114 -18
- package/src/charts/sparkline.module.css +50 -0
- package/src/charts/sparkline.module.css.d.ts +3 -0
- package/src/charts/state.tsx +40 -10
- package/src/cli/doctor-upgrade.ts +75 -0
- package/src/cli/doctor.ts +36 -0
- package/src/cli/help.ts +16 -6
- package/src/cli/index.ts +73 -67
- package/src/cli/init.ts +157 -36
- package/src/cli/router-wiring.ts +2 -2
- package/src/cli/shot/capture.ts +138 -16
- package/src/cli/shot/detect.ts +46 -22
- package/src/cli/shot/index.ts +8 -2
- package/src/cli/shot/measure.ts +11 -2
- package/src/cli/shot/types.ts +4 -1
- package/src/cli/sync.ts +12 -2
- package/src/common/could-not-load.ts +22 -0
- package/src/common/empty-copy.ts +17 -0
- package/src/common/index.ts +1 -0
- package/src/common/props.ts +30 -0
- package/src/common/retry-button.module.css +7 -3
- 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 +21 -5
- package/src/dashboard/bar-list.tsx +53 -45
- package/src/dashboard/board-nav.ts +67 -0
- package/src/dashboard/board.module.css +179 -0
- package/src/dashboard/board.module.css.d.ts +28 -0
- package/src/dashboard/board.tsx +415 -0
- package/src/dashboard/empty-state.tsx +21 -11
- package/src/dashboard/event-list-model.ts +125 -0
- package/src/dashboard/event-list-rows.tsx +117 -0
- package/src/dashboard/event-list-scroll.ts +291 -0
- package/src/dashboard/event-list-skeleton.tsx +62 -0
- package/src/dashboard/event-list.module.css +336 -0
- package/src/dashboard/event-list.module.css.d.ts +34 -0
- package/src/dashboard/event-list.tsx +336 -0
- package/src/dashboard/index.ts +2 -0
- package/src/dashboard/meter-model.ts +16 -7
- package/src/dashboard/meter-parts.tsx +53 -14
- package/src/dashboard/meter.module.css +20 -12
- package/src/dashboard/meter.module.css.d.ts +0 -1
- package/src/dashboard/meter.tsx +36 -18
- package/src/dashboard/page-summary.module.css +5 -2
- package/src/dashboard/page-summary.tsx +13 -6
- package/src/dashboard/query-state.tsx +55 -30
- package/src/dashboard/section.tsx +83 -41
- package/src/dashboard/settings-section.module.css +25 -4
- package/src/dashboard/settings-section.module.css.d.ts +1 -0
- package/src/dashboard/settings-section.tsx +18 -8
- package/src/dashboard/stat-card-parts.tsx +20 -3
- package/src/dashboard/stat-card.module.css +42 -7
- package/src/dashboard/stat-card.module.css.d.ts +3 -0
- package/src/dashboard/stat-card.tsx +55 -13
- package/src/dashboard/stat-group.tsx +22 -14
- package/src/dashboard/stat-strip.module.css +8 -6
- package/src/dashboard/stat-strip.tsx +29 -20
- package/src/dashboard/visual-slot.ts +5 -0
- package/src/dashboard/widget-header.module.css +12 -15
- package/src/dashboard/widget-header.tsx +8 -5
- package/src/format/shared.ts +30 -1
- package/src/guard/index.ts +7 -1
- package/src/index.ts +4 -0
- package/src/shell/app-main.module.css +18 -0
- package/src/styles.css +69 -0
- 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 +263 -0
- package/src/table/data-table-fold.tsx +567 -0
- package/src/table/data-table-state.ts +24 -13
- package/src/table/data-table.module.css +282 -3
- package/src/table/data-table.module.css.d.ts +16 -0
- package/src/table/data-table.tsx +430 -362
- 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 +55 -2
- 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/src/table/data-table.tsx
CHANGED
|
@@ -54,7 +54,6 @@ import type {
|
|
|
54
54
|
ColumnVisibilityState,
|
|
55
55
|
FilterFn,
|
|
56
56
|
PaginationState,
|
|
57
|
-
Row,
|
|
58
57
|
RowData,
|
|
59
58
|
RowSelectionState,
|
|
60
59
|
SortingState,
|
|
@@ -62,10 +61,11 @@ import type {
|
|
|
62
61
|
} from '@tanstack/react-table'
|
|
63
62
|
import { constructFilterFn, FlexRender, useTable } from '@tanstack/react-table'
|
|
64
63
|
import type { CSSProperties, MouseEvent as ReactMouseEvent, ReactNode, RefObject } from 'react'
|
|
65
|
-
import { Fragment, useLayoutEffect, useMemo, useRef, useState } from 'react'
|
|
64
|
+
import { Fragment, useId, useLayoutEffect, useMemo, useRef, useState } from 'react'
|
|
66
65
|
import { useDebouncedCallback } from '@mantine/hooks'
|
|
67
|
-
import {
|
|
68
|
-
import
|
|
66
|
+
import { HostTitleContext } from '../common/could-not-load'
|
|
67
|
+
import { cx, pickDataAttributes } from '../common/props'
|
|
68
|
+
import type { BasaltProps, DataAttributes, SlotStylesProps } from '../common/props'
|
|
69
69
|
import { BASALT_PREFIX } from '../common/errors'
|
|
70
70
|
import { HIT_COARSE } from '../common/hit-floor'
|
|
71
71
|
import { useMeasuredWidths } from '../common/use-measured-widths'
|
|
@@ -81,21 +81,52 @@ import { EnumFilter } from '../controls/enum-filter'
|
|
|
81
81
|
import { MultiSelectFilter } from '../controls/multi-select-filter'
|
|
82
82
|
import { CtlSlot } from '../theme'
|
|
83
83
|
import { IconSlot } from '../theme/icon-slot'
|
|
84
|
-
import {
|
|
84
|
+
import { CONTAINER_CLASSES, VX } from '../tokens'
|
|
85
85
|
import type { EnumField, FieldHandle, MultiField } from '../state/fields'
|
|
86
86
|
import { WidgetHeader } from '../dashboard'
|
|
87
|
+
import { EmptyState } from '../dashboard/empty-state'
|
|
87
88
|
import { ErrorState } from '../dashboard/query-state'
|
|
88
89
|
import type { QueryStateLike } from '../dashboard/query-state'
|
|
89
90
|
import {
|
|
90
91
|
activationProps,
|
|
91
|
-
EMPTY_FOLD_SET,
|
|
92
92
|
useCardProjection,
|
|
93
93
|
useDataTableState,
|
|
94
|
+
useNarrowerThan,
|
|
94
95
|
useRowDisclosure,
|
|
95
96
|
} from './data-table-state'
|
|
97
|
+
export { planColumnFold } from './data-table-fold'
|
|
96
98
|
import { dataQueryBranch } from './query-branch'
|
|
97
99
|
import { basaltTableFeatures } from './table-features'
|
|
98
|
-
import type {
|
|
100
|
+
import type {
|
|
101
|
+
BasaltColumnDef,
|
|
102
|
+
BasaltTableFeatures,
|
|
103
|
+
DataTableAlign,
|
|
104
|
+
DataTableColumnKind,
|
|
105
|
+
} from './table-features'
|
|
106
|
+
import {
|
|
107
|
+
columnDefId,
|
|
108
|
+
columnLabel,
|
|
109
|
+
FIXED_ID_ATTR,
|
|
110
|
+
FOLD_ID_ATTR,
|
|
111
|
+
foldOrder,
|
|
112
|
+
foldToggleCellProps,
|
|
113
|
+
FoldHeaderLabel,
|
|
114
|
+
FoldToggle,
|
|
115
|
+
PIN_MIN_WIDTH,
|
|
116
|
+
pinnedCellProps,
|
|
117
|
+
RowDisclosure,
|
|
118
|
+
useColumnFold,
|
|
119
|
+
} from './data-table-fold'
|
|
120
|
+
import type { PinContext } from './data-table-fold'
|
|
121
|
+
import {
|
|
122
|
+
CellContent,
|
|
123
|
+
DEFAULT_CELL,
|
|
124
|
+
kindAlign,
|
|
125
|
+
kindClass,
|
|
126
|
+
KindSkeleton,
|
|
127
|
+
planColumnSizing,
|
|
128
|
+
resolveKind,
|
|
129
|
+
} from './cell-kinds'
|
|
99
130
|
import classes from './data-table.module.css'
|
|
100
131
|
|
|
101
132
|
// ── Column alignment ──────────────────────────────────────────────────────────
|
|
@@ -321,6 +352,9 @@ const facetAnyOf = constructFilterFn({
|
|
|
321
352
|
* selection state, which is a reordering nobody asked for.
|
|
322
353
|
*/
|
|
323
354
|
const SELECT_COLUMN_ID = '__basalt_select__'
|
|
355
|
+
/** The checkbox column's width when it pins beside an auto-pinned identifier — the pinned offsets
|
|
356
|
+
* sum `getSize()`, so the real cell is held to it (the coarse hit floor, one tap target wide). */
|
|
357
|
+
const SELECT_COLUMN_SIZE = HIT_COARSE
|
|
324
358
|
|
|
325
359
|
/**
|
|
326
360
|
* Built per render inside a `useMemo`, not hoisted as a constant: `ColumnDef` is generic in `T`, and
|
|
@@ -333,6 +367,7 @@ const SELECT_COLUMN_ID = '__basalt_select__'
|
|
|
333
367
|
function selectionColumn<T extends RowData>(): ColumnDef<BasaltTableFeatures, T, unknown> {
|
|
334
368
|
return {
|
|
335
369
|
id: SELECT_COLUMN_ID,
|
|
370
|
+
size: SELECT_COLUMN_SIZE,
|
|
336
371
|
enableSorting: false,
|
|
337
372
|
header: ({ table }) => (
|
|
338
373
|
// oxlint-disable-next-line jsx-a11y/label-has-associated-control -- wraps <Checkbox>, which oxlint cannot see is an input
|
|
@@ -416,7 +451,7 @@ function RowActionCell<T>({
|
|
|
416
451
|
aria-label={named === undefined ? only.label : `${only.label}: ${named}`}
|
|
417
452
|
disabled={only.disabled?.(row) === true}
|
|
418
453
|
loading={only.loading?.(row) === true}
|
|
419
|
-
{...(only.danger === true && {
|
|
454
|
+
{...(only.danger === true && { className: classes.dangerAction })}
|
|
420
455
|
onClick={() => {
|
|
421
456
|
if (!inert) only.onClick(row)
|
|
422
457
|
}}
|
|
@@ -513,6 +548,7 @@ export type BasaltDataTableSlot = 'root' | 'toolbar' | 'table' | 'footer'
|
|
|
513
548
|
* }
|
|
514
549
|
*/
|
|
515
550
|
export type BasaltDataTableProps<T extends RowData> = BasaltProps &
|
|
551
|
+
DataAttributes &
|
|
516
552
|
SlotStylesProps<BasaltDataTableSlot> & {
|
|
517
553
|
// ── Header (WidgetHeader, docs/CONTROLS-SPEC.md §2.2) ──────────────────────────
|
|
518
554
|
|
|
@@ -568,7 +604,8 @@ export type BasaltDataTableProps<T extends RowData> = BasaltProps &
|
|
|
568
604
|
manualSorting?: boolean
|
|
569
605
|
/** Stripe alternate rows. Forwarded to Mantine `Table` — `'odd'`/`'even'` pick the phase. */
|
|
570
606
|
striped?: boolean | 'odd' | 'even'
|
|
571
|
-
/** Highlight hovered rows. Forwarded to Mantine `Table`.
|
|
607
|
+
/** Highlight hovered rows with `VX.surface.rowHover` on a fine pointer. Forwarded to Mantine `Table`.
|
|
608
|
+
* @default true */
|
|
572
609
|
highlightOnHover?: boolean
|
|
573
610
|
/**
|
|
574
611
|
* Rendered when no rows are VISIBLE — `data` is empty, or a filter/page matches none of it.
|
|
@@ -604,7 +641,9 @@ export type BasaltDataTableProps<T extends RowData> = BasaltProps &
|
|
|
604
641
|
*/
|
|
605
642
|
query?: QueryStateLike<unknown>
|
|
606
643
|
/**
|
|
607
|
-
* Number of skeleton rows to render when `isLoading` is true
|
|
644
|
+
* Number of skeleton rows to render when `isLoading` is true and neither a page size nor an
|
|
645
|
+
* earlier load says better: a paginated table loads at its page size, any other at the row
|
|
646
|
+
* count it last showed.
|
|
608
647
|
* @default 5
|
|
609
648
|
*/
|
|
610
649
|
skeletonRows?: number
|
|
@@ -648,6 +687,11 @@ export type BasaltDataTableProps<T extends RowData> = BasaltProps &
|
|
|
648
687
|
* restoring the search term from a URL search param.
|
|
649
688
|
*/
|
|
650
689
|
initialGlobalFilter?: string
|
|
690
|
+
/**
|
|
691
|
+
* Initial facet filters — `[{ id: 'department', value: 'Engineering' }]` opens the table with
|
|
692
|
+
* that facet preset. Uncontrolled, like `initialSorting`; `onColumnFiltersChange` reports edits.
|
|
693
|
+
*/
|
|
694
|
+
initialColumnFilters?: ColumnFiltersState
|
|
651
695
|
/** Called whenever the internal global filter value changes. */
|
|
652
696
|
onGlobalFilterChange?: (value: string) => void
|
|
653
697
|
/**
|
|
@@ -952,6 +996,33 @@ export type BasaltDataTableProps<T extends RowData> = BasaltProps &
|
|
|
952
996
|
withTableBorder?: boolean
|
|
953
997
|
}
|
|
954
998
|
|
|
999
|
+
/**
|
|
1000
|
+
* A skeleton cell's floor by `meta.kind`, rem: roughly what a typical value of the kind measures, so
|
|
1001
|
+
* a loading table plans the same fold as the loaded one instead of squeezing every column to its
|
|
1002
|
+
* (narrow) header. A kindless column floors at a short phrase. `text` is a short word
|
|
1003
|
+
* (a scope, a category): the bar was once 10rem wide, which made such a column 3x its loaded width
|
|
1004
|
+
* and folded one column more than the rows do.
|
|
1005
|
+
*/
|
|
1006
|
+
const SKELETON_MIN_REM: Partial<Record<DataTableColumnKind | 'kindless', number>> = {
|
|
1007
|
+
entity: 7,
|
|
1008
|
+
text: 4.5,
|
|
1009
|
+
// A kindless column is the one-line cause or note of an outage or event log.
|
|
1010
|
+
kindless: 8,
|
|
1011
|
+
'relative-time': 5,
|
|
1012
|
+
status: 4,
|
|
1013
|
+
money: 4.5,
|
|
1014
|
+
number: 3.5,
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
function skeletonMinWidth<T extends RowData>(
|
|
1018
|
+
column: Column<BasaltTableFeatures, T, unknown>,
|
|
1019
|
+
): string | undefined {
|
|
1020
|
+
// The checkbox and actions columns are synthetic: no kind, and a fixed width of their own.
|
|
1021
|
+
if (column.id === SELECT_COLUMN_ID || column.id === ACTIONS_COLUMN_ID) return undefined
|
|
1022
|
+
const rem = SKELETON_MIN_REM[resolveKind(column) ?? 'kindless']
|
|
1023
|
+
return rem === undefined ? undefined : `${rem}rem`
|
|
1024
|
+
}
|
|
1025
|
+
|
|
955
1026
|
// ── Sort indicator ────────────────────────────────────────────────────────────
|
|
956
1027
|
|
|
957
1028
|
function SortIndicator({ direction }: { direction: 'asc' | 'desc' | false }) {
|
|
@@ -965,21 +1036,21 @@ function SortIndicator({ direction }: { direction: 'asc' | 'desc' | false }) {
|
|
|
965
1036
|
|
|
966
1037
|
const ARIA_SORT = { asc: 'ascending', desc: 'descending' } as const
|
|
967
1038
|
|
|
968
|
-
// ── Numeral cell idiom (
|
|
969
|
-
//
|
|
970
|
-
// every numeric column gets tabular
|
|
1039
|
+
// ── Numeral cell idiom (SPEC D33: figures are the proportional sans with `tabular-nums`, mono is
|
|
1040
|
+
// for captions, times and code) — auto-detected from the cell's raw value (no column-level opt-in
|
|
1041
|
+
// prop needed) so every numeric column gets tabular figures with zero call-site configuration.
|
|
971
1042
|
const NUMERIC_CELL_STYLE: CSSProperties = {
|
|
972
|
-
fontFamily: 'var(--mantine-font-family-monospace)',
|
|
973
1043
|
fontSize: VX.text.sm,
|
|
974
1044
|
fontWeight: 500,
|
|
975
1045
|
fontVariantNumeric: 'tabular-nums',
|
|
976
1046
|
color: 'var(--vx-ink)',
|
|
977
1047
|
}
|
|
978
1048
|
|
|
979
|
-
// docs/DESIGN-SPEC.md §3: mono/micro-label idiom for the pagination bar's row-count label
|
|
1049
|
+
// docs/DESIGN-SPEC.md §3: mono/micro-label idiom for the pagination bar's row-count label — the
|
|
1050
|
+
// header's own micro size, so a paginated table reads in three sizes (micro, sm, the field's 16).
|
|
980
1051
|
const RANGE_LABEL_STYLE: CSSProperties = {
|
|
981
1052
|
fontFamily: 'var(--mantine-font-family-monospace)',
|
|
982
|
-
fontSize: VX.text.
|
|
1053
|
+
fontSize: VX.text.micro,
|
|
983
1054
|
fontVariantNumeric: 'tabular-nums',
|
|
984
1055
|
color: 'var(--vx-faint)',
|
|
985
1056
|
}
|
|
@@ -987,21 +1058,25 @@ const RANGE_LABEL_STYLE: CSSProperties = {
|
|
|
987
1058
|
const DEFAULT_PAGE_SIZE_OPTIONS = [10, 25, 50, 100]
|
|
988
1059
|
|
|
989
1060
|
/**
|
|
990
|
-
* The header row's two halves. The
|
|
991
|
-
*
|
|
1061
|
+
* The header row's two halves (`docs/waves/design-parity/SPEC.md` § 6.6). The TOOLBAR grows and the
|
|
1062
|
+
* title does not: the title ellipsizes into whatever it needs, and the toolbar takes the rest of the
|
|
1063
|
+
* row, so its facet row (`FilterSet`, `flex: 1 1 auto`) fills it and pushes the `actions` slot to
|
|
1064
|
+
* the right edge — beside the title when the two fit, full-width under it when they do not.
|
|
992
1065
|
*
|
|
993
1066
|
* Both SHRINK, and that half is not a preference. `CtlSlot` between the header row and the toolbar
|
|
994
|
-
* is `display: contents`, so the toolbar `Group` IS the row's flex item — and with
|
|
995
|
-
* `
|
|
996
|
-
*
|
|
997
|
-
*
|
|
998
|
-
*
|
|
999
|
-
*
|
|
1000
|
-
*
|
|
1001
|
-
*
|
|
1067
|
+
* is `display: contents`, so the toolbar `Group` IS the row's flex item — and a flex item with
|
|
1068
|
+
* `min-width: auto` cannot give up a pixel. MEASURED at 390x844 on `/data`: a 220px search beside a
|
|
1069
|
+
* 230px facet pill row, gap 11, is a 461px item in a 302px column, and `AppShell.Main` read
|
|
1070
|
+
* `scrollWidth` 505 against `clientWidth` 390 — the whole app draggable sideways over a table
|
|
1071
|
+
* header. `min-width: 0` lets the item shrink to the column; inside it the search gives up width
|
|
1072
|
+
* down to its floor and `FilterSet` folds what still does not fit behind its own `+N`.
|
|
1073
|
+
*
|
|
1074
|
+
* The toolbar is ONE row at every container width from the `compact` class (240px) up
|
|
1075
|
+
* (`.toolbar` in `data-table.module.css`, keyed on the header row's own width — never the
|
|
1076
|
+
* viewport). Only below it may the row wrap.
|
|
1002
1077
|
*/
|
|
1003
|
-
const TABLE_HEADER_LEAD_STYLE: CSSProperties = { flex: '
|
|
1004
|
-
const TABLE_TOOLBAR_STYLE: CSSProperties = { flex: '
|
|
1078
|
+
const TABLE_HEADER_LEAD_STYLE: CSSProperties = { flex: '0 1 auto', minWidth: 0 }
|
|
1079
|
+
const TABLE_TOOLBAR_STYLE: CSSProperties = { flex: '1 1 auto', minWidth: 0 }
|
|
1005
1080
|
/**
|
|
1006
1081
|
* The toolbar search's width. Mantine's Input grows to its container, which in a `justify:
|
|
1007
1082
|
* space-between` row means "whatever is left" — so the field was 600px on a wide table and 180px on a
|
|
@@ -1017,12 +1092,20 @@ const TABLE_TOOLBAR_STYLE: CSSProperties = { flex: '0 1 auto', minWidth: 0 }
|
|
|
1017
1092
|
* column was half of the overflow above.
|
|
1018
1093
|
*/
|
|
1019
1094
|
const SEARCH_WIDTH = 220
|
|
1095
|
+
/**
|
|
1096
|
+
* The search gives up width FIRST. Flex shrinks items in proportion to `shrink × basis`; at `1` the
|
|
1097
|
+
* search and `FilterSet`'s row (`flex: 1 1 auto`, whose slots cannot shrink) split the deficit, so the
|
|
1098
|
+
* pills overflowed their own box and the phone's `Filters` pill was clipped. A large factor takes the
|
|
1099
|
+
* whole deficit from the search until its `12ch` floor, and only then from the pill row — where
|
|
1100
|
+
* `FilterSet`'s fold takes over.
|
|
1101
|
+
*/
|
|
1102
|
+
const SEARCH_SHRINK = 100
|
|
1020
1103
|
/** How long the global search waits after the last keystroke before filtering. */
|
|
1021
1104
|
const SEARCH_DEBOUNCE_MS = 250
|
|
1022
1105
|
const TABLE_SEARCH_STYLE: CSSProperties = {
|
|
1023
1106
|
// `width` as well as the basis — see the `SEARCH_WIDTH` JSDoc.
|
|
1024
1107
|
width: SEARCH_WIDTH,
|
|
1025
|
-
flex: `0
|
|
1108
|
+
flex: `0 ${SEARCH_SHRINK} ${SEARCH_WIDTH}px`,
|
|
1026
1109
|
minWidth: '12ch',
|
|
1027
1110
|
maxWidth: '100%',
|
|
1028
1111
|
}
|
|
@@ -1044,264 +1127,6 @@ function getOrderedHeaderGroups<T extends RowData>(table: TanstackTable<BasaltTa
|
|
|
1044
1127
|
}))
|
|
1045
1128
|
}
|
|
1046
1129
|
|
|
1047
|
-
// Sticky offset math (column.getStart('start') / getAfter('end')) is computed purely from the
|
|
1048
|
-
// pinned columns' own `getSize()`, so only pinned cells need an explicit width to keep the offsets
|
|
1049
|
-
// accurate — center columns stay naturally sized. The hairline shadow marks the edge column
|
|
1050
|
-
// touching the unpinned center (first end-pinned index 0 / last start-pinned index). Offsets are
|
|
1051
|
-
// logical insets, so `dir=rtl` mirrors them; the hairline shadow is a physical offset and does not.
|
|
1052
|
-
function getPinnedCellStyle<T extends RowData>(
|
|
1053
|
-
table: TanstackTable<BasaltTableFeatures, T>,
|
|
1054
|
-
column: Column<BasaltTableFeatures, T, unknown>,
|
|
1055
|
-
): CSSProperties | undefined {
|
|
1056
|
-
const pinned = column.getIsPinned()
|
|
1057
|
-
if (!pinned) return undefined
|
|
1058
|
-
const size = column.getSize()
|
|
1059
|
-
const shared: CSSProperties = {
|
|
1060
|
-
position: 'sticky',
|
|
1061
|
-
zIndex: 1,
|
|
1062
|
-
width: size,
|
|
1063
|
-
minWidth: size,
|
|
1064
|
-
maxWidth: size,
|
|
1065
|
-
backgroundColor: VX.surface.panel,
|
|
1066
|
-
}
|
|
1067
|
-
if (pinned === 'start') {
|
|
1068
|
-
const isEdge = column.getPinnedIndex() === table.getStartLeafColumns().length - 1
|
|
1069
|
-
return {
|
|
1070
|
-
...shared,
|
|
1071
|
-
insetInlineStart: column.getStart('start'),
|
|
1072
|
-
boxShadow: isEdge ? `4px 0 6px -4px ${alpha(VX.ink, 0.18)}` : undefined,
|
|
1073
|
-
}
|
|
1074
|
-
}
|
|
1075
|
-
const isEdge = column.getPinnedIndex() === 0
|
|
1076
|
-
return {
|
|
1077
|
-
...shared,
|
|
1078
|
-
insetInlineEnd: column.getAfter('end'),
|
|
1079
|
-
boxShadow: isEdge ? `-4px 0 6px -4px ${alpha(VX.ink, 0.18)}` : undefined,
|
|
1080
|
-
}
|
|
1081
|
-
}
|
|
1082
|
-
|
|
1083
|
-
// ── Column fold (`meta.priority`, docs/CONTROLS-SPEC.md §2) ──────────────────
|
|
1084
|
-
|
|
1085
|
-
/** The column id TanStack will resolve internally for this raw def — explicit `id`, else the
|
|
1086
|
-
* accessor key string. Mirrors the resolution `facetColumns` already relies on above. */
|
|
1087
|
-
function columnDefId<T extends RowData>(
|
|
1088
|
-
column: ColumnDef<BasaltTableFeatures, T, unknown>,
|
|
1089
|
-
): string | undefined {
|
|
1090
|
-
if (column.id !== undefined) return column.id
|
|
1091
|
-
return 'accessorKey' in column && typeof column.accessorKey === 'string'
|
|
1092
|
-
? column.accessorKey
|
|
1093
|
-
: undefined
|
|
1094
|
-
}
|
|
1095
|
-
|
|
1096
|
-
/**
|
|
1097
|
-
* Fold order for `meta.priority` — the FIRST id in the returned list folds first. Effective
|
|
1098
|
-
* priority is `meta.priority ?? declaredIndex`, so with no `meta.priority` set anywhere it is just
|
|
1099
|
-
* the column's position: the LAST declared column folds first, the zero-config default a bare
|
|
1100
|
-
* `<BasaltDataTable data columns />` needs. An explicit priority folds a HIGHER number before a
|
|
1101
|
-
* lower one; a tie folds in reverse declared order. A column with no resolvable id (an
|
|
1102
|
-
* `accessorFn` with no explicit `id`) is never a fold candidate — nothing downstream could
|
|
1103
|
-
* reliably re-identify it once hidden.
|
|
1104
|
-
*/
|
|
1105
|
-
function foldOrder<T extends RowData>(
|
|
1106
|
-
columns: readonly ColumnDef<BasaltTableFeatures, T, unknown>[],
|
|
1107
|
-
): string[] {
|
|
1108
|
-
return columns
|
|
1109
|
-
.map((column, index) => ({
|
|
1110
|
-
id: columnDefId(column),
|
|
1111
|
-
priority: column.meta?.priority ?? index,
|
|
1112
|
-
index,
|
|
1113
|
-
}))
|
|
1114
|
-
.filter((candidate): candidate is { id: string; priority: number; index: number } =>
|
|
1115
|
-
Boolean(candidate.id),
|
|
1116
|
-
)
|
|
1117
|
-
.toSorted((a, b) => b.priority - a.priority || b.index - a.index)
|
|
1118
|
-
.map((candidate) => candidate.id)
|
|
1119
|
-
}
|
|
1120
|
-
|
|
1121
|
-
/** Marks a rendered data column header for `useColumnFold`'s width measurement — never read past
|
|
1122
|
-
* that hook, so it carries no styling and needs no CSS-module counterpart. */
|
|
1123
|
-
const FOLD_ID_ATTR = 'data-basalt-fold-id'
|
|
1124
|
-
|
|
1125
|
-
/**
|
|
1126
|
-
* Pure decision: fold columns off the FRONT of `order` (already fold-first sorted) until the
|
|
1127
|
-
* still-unfolded ones — plus `overhead` (the columns excluded from candidacy altogether — pinned,
|
|
1128
|
-
* or `enableHiding: false` — which occupy room but can never fold) and the disclosure toggle's own
|
|
1129
|
-
* width, once anything is folded — fit `room`. A candidate with no measured width yet (never
|
|
1130
|
-
* rendered) is skipped rather than folded blind, since folding it would remove the one place its
|
|
1131
|
-
* width could ever be read from.
|
|
1132
|
-
*
|
|
1133
|
-
* Every width is a rounded integer (`offsetWidth`, `clientWidth`), and a table that fills its
|
|
1134
|
-
* wrapper stretches its columns to sum to `room` exactly — so the rounded sum lands up to half a
|
|
1135
|
-
* pixel per column over it, and a table that fits folded a column on hydration (a server-painted
|
|
1136
|
-
* table whose cells then moved). The fit check forgives that rounding and nothing more: half a
|
|
1137
|
-
* pixel for each measured width (the foldable columns AND `fixedCount`, the pinned / non-hiding
|
|
1138
|
-
* ones `overhead` sums), plus half a pixel for `room`'s own rounding (the `+ 1` in the slack).
|
|
1139
|
-
*/
|
|
1140
|
-
export function planColumnFold(input: {
|
|
1141
|
-
room: number
|
|
1142
|
-
toggleWidth: number
|
|
1143
|
-
overhead: number
|
|
1144
|
-
/** How many columns `overhead` sums, for the rounding slack. */
|
|
1145
|
-
fixedCount?: number
|
|
1146
|
-
order: readonly string[]
|
|
1147
|
-
widths: ReadonlyMap<string, number>
|
|
1148
|
-
}): ReadonlySet<string> {
|
|
1149
|
-
const { room, toggleWidth, overhead, fixedCount = 0, order, widths } = input
|
|
1150
|
-
const known = order.filter((id) => widths.has(id))
|
|
1151
|
-
const roundingSlack = (known.length + fixedCount + 1) / 2
|
|
1152
|
-
let unfolded = overhead + known.reduce((sum, id) => sum + (widths.get(id) ?? 0), 0)
|
|
1153
|
-
const folded = new Set<string>()
|
|
1154
|
-
for (const id of known) {
|
|
1155
|
-
// Never fold the last remaining data column — a table with every column folded has no row
|
|
1156
|
-
// identifier left to read at all, which is worse than the horizontal scroll this exists to
|
|
1157
|
-
// avoid. With no explicit `meta.priority` this is `order`'s LAST id, which `foldOrder`'s own
|
|
1158
|
-
// doc pins as the FIRST declared column (the last-declared one folds first).
|
|
1159
|
-
if (folded.size >= known.length - 1) break
|
|
1160
|
-
const withToggle = unfolded + (folded.size > 0 ? toggleWidth : 0)
|
|
1161
|
-
if (withToggle <= room + roundingSlack) break
|
|
1162
|
-
folded.add(id)
|
|
1163
|
-
unfolded -= widths.get(id) ?? 0
|
|
1164
|
-
}
|
|
1165
|
-
return folded
|
|
1166
|
-
}
|
|
1167
|
-
|
|
1168
|
-
/**
|
|
1169
|
-
* The general-case measured fold. Reacting to `useMeasuredContainment`'s boolean fit directly
|
|
1170
|
-
* (fold one, remeasure, maybe unfold) would oscillate, because folding changes the very box being
|
|
1171
|
-
* measured. Instead this reads each candidate `<th data-basalt-fold-id>`'s width once, while it is
|
|
1172
|
-
* visible, caches it, and decides analytically (`planColumnFold`). `useMeasuredWidths` owns the
|
|
1173
|
-
* cache and the wrapper-vs-table observer that `controls/actions.tsx`'s fold shares.
|
|
1174
|
-
*/
|
|
1175
|
-
function useColumnFold(input: {
|
|
1176
|
-
active: boolean
|
|
1177
|
-
order: readonly string[]
|
|
1178
|
-
/**
|
|
1179
|
-
* Columns excluded from fold candidacy altogether (pinned, or `enableHiding: false`) — they are
|
|
1180
|
-
* never in `order`, but they still occupy room, and their measured widths (carried in the same
|
|
1181
|
-
* `[data-basalt-fold-id]` sweep as every eligible column's) become fixed overhead against the
|
|
1182
|
-
* fold baseline. See `planColumnFold`'s `overhead` param.
|
|
1183
|
-
*/
|
|
1184
|
-
fixedIds: readonly string[]
|
|
1185
|
-
}): {
|
|
1186
|
-
wrapperRef: RefObject<HTMLDivElement | null>
|
|
1187
|
-
folded: ReadonlySet<string>
|
|
1188
|
-
} {
|
|
1189
|
-
const { active, order, fixedIds } = input
|
|
1190
|
-
const wrapperRef = useRef<HTMLDivElement>(null)
|
|
1191
|
-
const [folded, setFolded] = useState<ReadonlySet<string>>(EMPTY_FOLD_SET)
|
|
1192
|
-
const orderRef = useRef(order)
|
|
1193
|
-
const fixedIdsRef = useRef(fixedIds)
|
|
1194
|
-
useLayoutEffect(() => {
|
|
1195
|
-
orderRef.current = order
|
|
1196
|
-
fixedIdsRef.current = fixedIds
|
|
1197
|
-
})
|
|
1198
|
-
if ((!active || order.length === 0) && folded.size > 0) setFolded(EMPTY_FOLD_SET)
|
|
1199
|
-
|
|
1200
|
-
useMeasuredWidths({
|
|
1201
|
-
resolveRoot: () => wrapperRef.current,
|
|
1202
|
-
signature: `${order.join('|')}::${fixedIds.join('|')}`,
|
|
1203
|
-
enabled: active && order.length > 0,
|
|
1204
|
-
// The table too, not only the wrapper: a re-measured column set moves its min-content width
|
|
1205
|
-
// while the wrapper's own box never changes.
|
|
1206
|
-
extra: (root) => [root.querySelector('table')],
|
|
1207
|
-
onMeasure: (root, boxes) => {
|
|
1208
|
-
for (const cell of root.querySelectorAll<HTMLElement>(`[${FOLD_ID_ATTR}]`)) {
|
|
1209
|
-
const id = cell.getAttribute(FOLD_ID_ATTR)
|
|
1210
|
-
if (id !== null && cell.offsetWidth > 0) {
|
|
1211
|
-
boxes.current.set(id, { width: cell.offsetWidth, height: cell.offsetHeight })
|
|
1212
|
-
}
|
|
1213
|
-
}
|
|
1214
|
-
const room = root.clientWidth
|
|
1215
|
-
// A zero reading is an un-laid-out ancestor, not a table with no room — the same guard
|
|
1216
|
-
// `useMeasuredContainment` above runs against the aside animating in from 0.
|
|
1217
|
-
if (room === 0) return
|
|
1218
|
-
const widths = new Map([...boxes.current].map(([id, box]) => [id, box.width]))
|
|
1219
|
-
const overhead = fixedIdsRef.current.reduce((sum, id) => sum + (widths.get(id) ?? 0), 0)
|
|
1220
|
-
const next = planColumnFold({
|
|
1221
|
-
room,
|
|
1222
|
-
// The disclosure toggle is a fixed icon-button cell matched to the coarse hit floor, so it
|
|
1223
|
-
// reads as one more `--vx-hit` control rather than a narrower afterthought.
|
|
1224
|
-
toggleWidth: HIT_COARSE,
|
|
1225
|
-
overhead,
|
|
1226
|
-
fixedCount: fixedIdsRef.current.length,
|
|
1227
|
-
order: orderRef.current,
|
|
1228
|
-
widths,
|
|
1229
|
-
})
|
|
1230
|
-
setFolded((current) =>
|
|
1231
|
-
current.size === next.size && [...current].every((id) => next.has(id)) ? current : next,
|
|
1232
|
-
)
|
|
1233
|
-
},
|
|
1234
|
-
})
|
|
1235
|
-
|
|
1236
|
-
return { wrapperRef, folded: active ? folded : EMPTY_FOLD_SET }
|
|
1237
|
-
}
|
|
1238
|
-
|
|
1239
|
-
/** The label half of a folded column's disclosure row — its own header when it is a plain string
|
|
1240
|
-
* (the common case), else the column id, since a function/`ReactNode` header has no header
|
|
1241
|
-
* CONTEXT to render with here (this is a body row, not the `<thead>`). */
|
|
1242
|
-
function columnLabel<T extends RowData>(column: Column<BasaltTableFeatures, T, unknown>): string {
|
|
1243
|
-
const header = column.columnDef.header
|
|
1244
|
-
return typeof header === 'string' ? header : column.id
|
|
1245
|
-
}
|
|
1246
|
-
|
|
1247
|
-
/** One row's folded columns as label/value pairs, directly under it. `row.getAllCells()` returns
|
|
1248
|
-
* every leaf cell regardless of visibility (unlike `getVisibleCells()`), so a folded column's own
|
|
1249
|
-
* `cell` renderer still draws here exactly as it would in the `<td>` it no longer occupies. */
|
|
1250
|
-
function RowDisclosure<T extends RowData>({
|
|
1251
|
-
row,
|
|
1252
|
-
folded,
|
|
1253
|
-
}: {
|
|
1254
|
-
row: Row<BasaltTableFeatures, T>
|
|
1255
|
-
folded: ReadonlySet<string>
|
|
1256
|
-
}): ReactNode {
|
|
1257
|
-
const cells = row.getAllCells().filter((cell) => folded.has(cell.column.id))
|
|
1258
|
-
return (
|
|
1259
|
-
<div className={classes.foldDisclosure}>
|
|
1260
|
-
{cells.map((cell) => (
|
|
1261
|
-
<div key={cell.id} className={classes.foldDisclosureRow}>
|
|
1262
|
-
<Text className={classes.foldDisclosureLabel}>{columnLabel(cell.column)}</Text>
|
|
1263
|
-
<div className={classes.foldDisclosureValue}>
|
|
1264
|
-
<FlexRender cell={cell} />
|
|
1265
|
-
</div>
|
|
1266
|
-
</div>
|
|
1267
|
-
))}
|
|
1268
|
-
</div>
|
|
1269
|
-
)
|
|
1270
|
-
}
|
|
1271
|
-
|
|
1272
|
-
/** The per-row expand/collapse control the fold-disclosure column renders — a text glyph, since
|
|
1273
|
-
* basalt ships no icon set (`docs/CONTROLS-SPEC.md` §2, mirrors `SortIndicator` above). */
|
|
1274
|
-
function FoldToggle({
|
|
1275
|
-
expanded,
|
|
1276
|
-
controlsId,
|
|
1277
|
-
onToggle,
|
|
1278
|
-
}: {
|
|
1279
|
-
expanded: boolean
|
|
1280
|
-
controlsId: string
|
|
1281
|
-
onToggle: () => void
|
|
1282
|
-
}): ReactNode {
|
|
1283
|
-
return (
|
|
1284
|
-
<button
|
|
1285
|
-
type="button"
|
|
1286
|
-
className={classes.foldToggle}
|
|
1287
|
-
data-basalt-hit
|
|
1288
|
-
aria-expanded={expanded}
|
|
1289
|
-
aria-controls={controlsId}
|
|
1290
|
-
aria-label={expanded ? 'Hide row details' : 'Show row details'}
|
|
1291
|
-
// A row carrying `onRowActivate` reads a bubbled click as "activate the row" — the toggle
|
|
1292
|
-
// would open/close its disclosure AND fire the row's own action underneath it.
|
|
1293
|
-
onClick={(event) => {
|
|
1294
|
-
event.stopPropagation()
|
|
1295
|
-
onToggle()
|
|
1296
|
-
}}
|
|
1297
|
-
>
|
|
1298
|
-
<Box component="span" aria-hidden>
|
|
1299
|
-
{expanded ? '▾' : '▸'}
|
|
1300
|
-
</Box>
|
|
1301
|
-
</button>
|
|
1302
|
-
)
|
|
1303
|
-
}
|
|
1304
|
-
|
|
1305
1130
|
// ── The manual-pagination contract ────────────────────────────────────────────
|
|
1306
1131
|
|
|
1307
1132
|
/** One client-side control that `manualPagination` turns into a claim the table cannot support. */
|
|
@@ -1478,11 +1303,11 @@ export function BasaltDataTable<T extends RowData>(props: BasaltDataTableProps<T
|
|
|
1478
1303
|
enableSorting = true,
|
|
1479
1304
|
manualSorting = false,
|
|
1480
1305
|
striped,
|
|
1481
|
-
highlightOnHover,
|
|
1306
|
+
highlightOnHover = true,
|
|
1482
1307
|
emptyState,
|
|
1483
1308
|
isLoading = false,
|
|
1484
1309
|
query,
|
|
1485
|
-
skeletonRows
|
|
1310
|
+
skeletonRows,
|
|
1486
1311
|
enableGlobalFilter = false,
|
|
1487
1312
|
globalFilterPlaceholder = 'Search…',
|
|
1488
1313
|
searchIcon,
|
|
@@ -1635,7 +1460,7 @@ export function BasaltDataTable<T extends RowData>(props: BasaltDataTableProps<T
|
|
|
1635
1460
|
// the declared-order default and the explicit-priority rule. `enableHiding: false` and a PINNED
|
|
1636
1461
|
// column are excluded outright, not merely de-prioritized — both are the caller stating this
|
|
1637
1462
|
// column must stay visible, the same declaration a fold candidate has no way to override.
|
|
1638
|
-
const { columnFoldOrder, columnFoldFixedIds } = useMemo(() => {
|
|
1463
|
+
const { columnFoldOrder, columnFoldFixedIds, pinCandidates } = useMemo(() => {
|
|
1639
1464
|
const pinnedIds = new Set([...columnPinning.start, ...columnPinning.end])
|
|
1640
1465
|
const excluded = new Set(
|
|
1641
1466
|
columns.flatMap((column) => {
|
|
@@ -1647,17 +1472,54 @@ export function BasaltDataTable<T extends RowData>(props: BasaltDataTableProps<T
|
|
|
1647
1472
|
return {
|
|
1648
1473
|
columnFoldOrder: foldOrder(columns).filter((id) => !excluded.has(id)),
|
|
1649
1474
|
columnFoldFixedIds: [...excluded],
|
|
1475
|
+
// Leaf columns the caller did not pin itself, declared order: a caller's END pin must not
|
|
1476
|
+
// also become the start pin, where TanStack would resolve it as start.
|
|
1477
|
+
pinCandidates: columns.flatMap((column) => {
|
|
1478
|
+
const id = columnDefId(column)
|
|
1479
|
+
return id === undefined || 'columns' in column || pinnedIds.has(id) ? [] : [id]
|
|
1480
|
+
}),
|
|
1650
1481
|
}
|
|
1651
1482
|
}, [columns, columnPinning])
|
|
1483
|
+
// ── The query branch (law C3) ───────────────────────────────────────────────
|
|
1484
|
+
// `query`, when given, owns the body: it resolves the pending branch `isLoading` used to own,
|
|
1485
|
+
// plus the error branch the table had none of. `isLoading` stays live for every caller who never
|
|
1486
|
+
// had a query result to hand — the dev warning above covers the pair.
|
|
1487
|
+
const branch = query === undefined ? undefined : dataQueryBranch('BasaltDataTable', query)
|
|
1488
|
+
const showSkeleton = branch === undefined ? isLoading : branch === 'pending'
|
|
1489
|
+
const queryError = branch === 'error' && query !== undefined ? query : undefined
|
|
1652
1490
|
// The card projection unmounts the table, so the fold and the containment wrapper go inactive with
|
|
1653
1491
|
// it — their measuring effects re-attach to the remounted table when the width returns.
|
|
1654
1492
|
const { cards: showCards, rootRef: projectionRootRef } = useCardProjection(
|
|
1655
1493
|
renderCard !== undefined,
|
|
1656
1494
|
)
|
|
1657
|
-
const
|
|
1495
|
+
const renderedRows = useRef(0)
|
|
1496
|
+
// The row count the table last showed with data: a reload skeleton is that tall, not a guess.
|
|
1497
|
+
const [lastLoadedRows, setLastLoadedRows] = useState(0)
|
|
1498
|
+
const foldExtraIds = useMemo(
|
|
1499
|
+
() => [
|
|
1500
|
+
...(enableRowSelection ? [SELECT_COLUMN_ID] : []),
|
|
1501
|
+
...(hasRowActions ? [ACTIONS_COLUMN_ID] : []),
|
|
1502
|
+
],
|
|
1503
|
+
[enableRowSelection, hasRowActions],
|
|
1504
|
+
)
|
|
1505
|
+
const {
|
|
1506
|
+
folded: foldedColumns,
|
|
1507
|
+
wrapperRef: foldWrapperRef,
|
|
1508
|
+
pinId: autoPinId,
|
|
1509
|
+
overflowing: foldOverflowing,
|
|
1510
|
+
widths: measuredWidths,
|
|
1511
|
+
} = useColumnFold({
|
|
1658
1512
|
active: foldEligible && !showCards,
|
|
1659
1513
|
order: columnFoldOrder,
|
|
1660
1514
|
fixedIds: columnFoldFixedIds,
|
|
1515
|
+
extraIds: foldExtraIds,
|
|
1516
|
+
pinCandidates,
|
|
1517
|
+
// An explicit caller pin wins: the fold already treats it as fixed overhead, and a second,
|
|
1518
|
+
// implicit one beside it would stack two sticky columns nobody asked for.
|
|
1519
|
+
// A one-column table has nothing to scroll beside an identifier.
|
|
1520
|
+
allowPin: columnPinning.start.length === 0 && columns.length > 1,
|
|
1521
|
+
headerOnly: showSkeleton || queryError !== undefined,
|
|
1522
|
+
renderedRows,
|
|
1661
1523
|
})
|
|
1662
1524
|
const columnVisibility: ColumnVisibilityState = useMemo(
|
|
1663
1525
|
() => Object.fromEntries([...foldedColumns].map((id) => [id, false])),
|
|
@@ -1668,19 +1530,33 @@ export function BasaltDataTable<T extends RowData>(props: BasaltDataTableProps<T
|
|
|
1668
1530
|
|
|
1669
1531
|
// The actions column always sticks to the end edge, behind any end-pinned columns the caller
|
|
1670
1532
|
// asked for — so it is pinned through TanStack's own state, which also keeps their offsets right.
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1533
|
+
//
|
|
1534
|
+
// The auto-pin (SPEC § 6.6): once the fold has hit its floor and the table STILL overflows, the
|
|
1535
|
+
// first visible data column pins to the start edge (with the checkbox column ahead of it) so the
|
|
1536
|
+
// rest scrolls under a fixed identifier. It rides TanStack's own `columnPinning` state, merged
|
|
1537
|
+
// with the caller's — which wins outright whenever it pins a start column itself.
|
|
1538
|
+
const pinningActive = enablePinning || hasRowActions || autoPinId !== undefined
|
|
1539
|
+
const tablePinning = useMemo(() => {
|
|
1540
|
+
const start =
|
|
1541
|
+
autoPinId === undefined
|
|
1542
|
+
? columnPinning.start
|
|
1543
|
+
: [...(enableRowSelection ? [SELECT_COLUMN_ID] : []), autoPinId]
|
|
1544
|
+
const end = hasRowActions ? [...columnPinning.end, ACTIONS_COLUMN_ID] : columnPinning.end
|
|
1545
|
+
return { start, end }
|
|
1546
|
+
}, [columnPinning, hasRowActions, autoPinId, enableRowSelection])
|
|
1547
|
+
// The fold toggle column leads the row and sticks beside the pinned start cells, so they sit past it.
|
|
1548
|
+
const pinStartOffset = hasFolded && tablePinning.start.length > 0 ? HIT_COARSE : 0
|
|
1549
|
+
const autoPinMinWidth =
|
|
1550
|
+
autoPinId === undefined
|
|
1551
|
+
? undefined
|
|
1552
|
+
: (columns.find((column) => columnDefId(column) === autoPinId)?.minSize ?? PIN_MIN_WIDTH)
|
|
1553
|
+
const tableId = useId()
|
|
1679
1554
|
|
|
1680
1555
|
const table = useTable({
|
|
1681
1556
|
features: basaltTableFeatures,
|
|
1682
1557
|
data,
|
|
1683
1558
|
columns: tableColumns,
|
|
1559
|
+
defaultColumn: { cell: DEFAULT_CELL },
|
|
1684
1560
|
state: {
|
|
1685
1561
|
sorting: tableState.sorting,
|
|
1686
1562
|
globalFilter,
|
|
@@ -1720,14 +1596,14 @@ export function BasaltDataTable<T extends RowData>(props: BasaltDataTableProps<T
|
|
|
1720
1596
|
const showSearch = enableGlobalFilter && filteringEnabled
|
|
1721
1597
|
const showFacets = hasFacets && filteringEnabled
|
|
1722
1598
|
const showToolbar = showSearch || showFacets || Boolean(actions)
|
|
1723
|
-
|
|
1724
|
-
//
|
|
1725
|
-
// `
|
|
1726
|
-
//
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1599
|
+
// The PHONE tier of the toolbar, read off the header row's own width (never the viewport): below
|
|
1600
|
+
// the `regular` container class the facets live behind the one `Filters (n)` pill
|
|
1601
|
+
// (`FilterSet inline={0}`) — a search, a facet pill, `Filters` and the actions cannot share a
|
|
1602
|
+
// ~272px row, and two homes for the same facets is worse than one.
|
|
1603
|
+
const { ref: headerRef, narrow: narrowToolbar } = useNarrowerThan(
|
|
1604
|
+
CONTAINER_CLASSES.regular,
|
|
1605
|
+
showToolbar,
|
|
1606
|
+
)
|
|
1731
1607
|
|
|
1732
1608
|
// Every colSpan and every skeleton row counts the RENDERED columns: one more than `columns` for
|
|
1733
1609
|
// the prepended checkbox column, one more again for the fold-disclosure toggle once anything has
|
|
@@ -1739,6 +1615,28 @@ export function BasaltDataTable<T extends RowData>(props: BasaltDataTableProps<T
|
|
|
1739
1615
|
(hasFolded ? 1 : 0) -
|
|
1740
1616
|
foldedColumns.size
|
|
1741
1617
|
|
|
1618
|
+
// ARIA column positions (WCAG F102): `aria-colcount` counts the FULL column set — folded and
|
|
1619
|
+
// hidden columns included — and every cell's `aria-colindex` is its 1-based slot in that order,
|
|
1620
|
+
// so a fold leaves a gap a screen-reader user can hear. The fold toggle column is a real cell
|
|
1621
|
+
// leading the row, so while it renders it takes slot 1 and shifts the rest.
|
|
1622
|
+
const fullLeafColumns = pinningActive
|
|
1623
|
+
? [
|
|
1624
|
+
...table.getStartLeafColumns(),
|
|
1625
|
+
...table.getCenterLeafColumns(),
|
|
1626
|
+
...table.getEndLeafColumns(),
|
|
1627
|
+
]
|
|
1628
|
+
: table.getAllLeafColumns()
|
|
1629
|
+
const colIndexOffset = hasFolded ? 1 : 0
|
|
1630
|
+
const colIndexById = new Map(
|
|
1631
|
+
fullLeafColumns.map((column, index) => [column.id, index + 1 + colIndexOffset]),
|
|
1632
|
+
)
|
|
1633
|
+
const ariaColCount = fullLeafColumns.length + colIndexOffset
|
|
1634
|
+
// What the toggle announces: the folded columns' own headers, in column order.
|
|
1635
|
+
const foldedNames = fullLeafColumns
|
|
1636
|
+
.filter((column) => foldedColumns.has(column.id))
|
|
1637
|
+
.map((column) => columnLabel(column))
|
|
1638
|
+
const foldedLabel = foldedNames.join(', ')
|
|
1639
|
+
|
|
1742
1640
|
// `getSelectedRowModel()` is TanStack's own memo, so its `rows` array keeps its identity until
|
|
1743
1641
|
// the selection or the row model actually moves — which is what makes both memos below hold.
|
|
1744
1642
|
const selectedModelRows = enableRowSelection ? table.getSelectedRowModel().rows : undefined
|
|
@@ -1760,6 +1658,14 @@ export function BasaltDataTable<T extends RowData>(props: BasaltDataTableProps<T
|
|
|
1760
1658
|
// The rows actually rendered, not `data` — a filter or a page index that matches nothing leaves
|
|
1761
1659
|
// `data` non-empty while the body has nothing in it, and a blank body reads as a broken table.
|
|
1762
1660
|
const rows = table.getRowModel().rows
|
|
1661
|
+
const stateless = showSkeleton || queryError !== undefined
|
|
1662
|
+
useLayoutEffect(() => {
|
|
1663
|
+
renderedRows.current = rows.length
|
|
1664
|
+
})
|
|
1665
|
+
// Derived during render (React's own seam for state that follows a prop), not in an effect.
|
|
1666
|
+
if (!stateless && rows.length > 0 && rows.length !== lastLoadedRows) {
|
|
1667
|
+
setLastLoadedRows(rows.length)
|
|
1668
|
+
}
|
|
1763
1669
|
|
|
1764
1670
|
// `stickyHeaderOffset` is a WINDOW-scroll concept — the height of whatever fixed chrome the page
|
|
1765
1671
|
// scrolls under (the AppShell header plus `PageBar` row 2). Inside the scroll container it is
|
|
@@ -1783,6 +1689,17 @@ export function BasaltDataTable<T extends RowData>(props: BasaltDataTableProps<T
|
|
|
1783
1689
|
pageStickyHeader && !showCards,
|
|
1784
1690
|
)
|
|
1785
1691
|
const resolvedStickyHeaderOffset = scrolls ? undefined : stickyHeaderOffset
|
|
1692
|
+
// The declared-`minWidth` shape has no fold hook, so its scroller is measured on its own.
|
|
1693
|
+
const { wrapperRef: minWidthScrollerRef, contained: minWidthOverflowing } =
|
|
1694
|
+
useMeasuredContainment(!foldEligible && !showCards)
|
|
1695
|
+
// A scroll container is a keyboard tab stop ONLY while it actually scrolls (WCAG 2.1.1 — a
|
|
1696
|
+
// sighted keyboard user otherwise has no way to reach the clipped columns), and a focusable box
|
|
1697
|
+
// needs a role and a name (axe `scrollable-region-focusable`). The ring is `.scroller`'s.
|
|
1698
|
+
const scrollerLabel = `${title ?? 'Table'}, scrolls horizontally`
|
|
1699
|
+
const scrollerProps = (overflowing: boolean) =>
|
|
1700
|
+
overflowing
|
|
1701
|
+
? { tabIndex: 0, role: 'region', 'aria-label': scrollerLabel, className: classes.scroller }
|
|
1702
|
+
: undefined
|
|
1786
1703
|
|
|
1787
1704
|
// The error branch the table did not have (components audit #3) carries the query's OWN `refetch`
|
|
1788
1705
|
// behind Retry, so the failure is reported where the rows would have been — in a row spanning
|
|
@@ -1790,18 +1707,53 @@ export function BasaltDataTable<T extends RowData>(props: BasaltDataTableProps<T
|
|
|
1790
1707
|
const errorNode = queryError !== undefined && (
|
|
1791
1708
|
<ErrorState
|
|
1792
1709
|
error={queryError.error}
|
|
1793
|
-
title
|
|
1710
|
+
// A titled table names itself; an untitled one reads its host's title (`Section`, a card)
|
|
1711
|
+
// through `ErrorState`, which falls back to the bare "Could not load" outside any host.
|
|
1712
|
+
{...(title !== undefined && { title: `Could not load ${title}` })}
|
|
1794
1713
|
tier="section"
|
|
1795
1714
|
retrying={queryError.fetchStatus === 'fetching'}
|
|
1796
1715
|
onRetry={() => void queryError.refetch()}
|
|
1797
1716
|
/>
|
|
1798
1717
|
)
|
|
1799
|
-
const emptyNode =
|
|
1800
|
-
<
|
|
1801
|
-
No data to display.
|
|
1802
|
-
</
|
|
1718
|
+
const emptyNode = (
|
|
1719
|
+
<HostTitleContext value={title}>
|
|
1720
|
+
{emptyState ?? <EmptyState tier="section" title="No data to display." />}
|
|
1721
|
+
</HostTitleContext>
|
|
1803
1722
|
)
|
|
1804
1723
|
|
|
1724
|
+
// The cells in render order (start → center → end) with only the visible ones — the skeleton rows
|
|
1725
|
+
// mirror the header with it.
|
|
1726
|
+
const orderedVisibleColumns = pinningActive
|
|
1727
|
+
? [
|
|
1728
|
+
...table.getStartVisibleLeafColumns(),
|
|
1729
|
+
...table.getCenterVisibleLeafColumns(),
|
|
1730
|
+
...table.getEndVisibleLeafColumns(),
|
|
1731
|
+
]
|
|
1732
|
+
: table.getVisibleLeafColumns()
|
|
1733
|
+
// One description of every sticky cell, read by the header, skeleton and body sites alike.
|
|
1734
|
+
const pinCtx: PinContext<T> = {
|
|
1735
|
+
table,
|
|
1736
|
+
startOffset: pinStartOffset,
|
|
1737
|
+
autoPinId,
|
|
1738
|
+
autoPinMinWidth,
|
|
1739
|
+
}
|
|
1740
|
+
const toggleCell = foldToggleCellProps(pinCtx)
|
|
1741
|
+
const { fitIds, spacer } = planColumnSizing(
|
|
1742
|
+
orderedVisibleColumns,
|
|
1743
|
+
new Set([SELECT_COLUMN_ID, ACTIONS_COLUMN_ID]),
|
|
1744
|
+
// Every row, not the page: paging, sorting or filtering must not move a column's width.
|
|
1745
|
+
table.getCoreRowModel().rows,
|
|
1746
|
+
)
|
|
1747
|
+
const fitAttr = (id: string) => (fitIds.has(id) ? { 'data-fit': true } : undefined)
|
|
1748
|
+
// colSpan covers the rendered cells, the trailing spacer included.
|
|
1749
|
+
const spanCount = columnCount + (spacer ? 1 : 0)
|
|
1750
|
+
// A page of rows when paginated, else what the table last showed, else the caller's guess.
|
|
1751
|
+
const skeletonCount = enablePagination
|
|
1752
|
+
? table.state.pagination.pageSize
|
|
1753
|
+
: lastLoadedRows > 0
|
|
1754
|
+
? lastLoadedRows
|
|
1755
|
+
: (skeletonRows ?? 5)
|
|
1756
|
+
|
|
1805
1757
|
const tableNode = (
|
|
1806
1758
|
<Table
|
|
1807
1759
|
className={cx(
|
|
@@ -1809,6 +1761,7 @@ export function BasaltDataTable<T extends RowData>(props: BasaltDataTableProps<T
|
|
|
1809
1761
|
pageStickyHeader && !contained && classes.pageSticky,
|
|
1810
1762
|
classNames?.table,
|
|
1811
1763
|
)}
|
|
1764
|
+
aria-colcount={ariaColCount}
|
|
1812
1765
|
{...(striped !== undefined && { striped })}
|
|
1813
1766
|
{...(highlightOnHover !== undefined && { highlightOnHover })}
|
|
1814
1767
|
{...(stickyHeader !== undefined && { stickyHeader })}
|
|
@@ -1823,30 +1776,32 @@ export function BasaltDataTable<T extends RowData>(props: BasaltDataTableProps<T
|
|
|
1823
1776
|
<Table.Thead>
|
|
1824
1777
|
{headerGroups.map((headerGroup) => (
|
|
1825
1778
|
<Table.Tr key={headerGroup.id}>
|
|
1826
|
-
{/* The disclosure toggle column
|
|
1827
|
-
|
|
1779
|
+
{/* The disclosure toggle column sorts and selects nothing: its header says that columns
|
|
1780
|
+
are folded, and which. */}
|
|
1828
1781
|
{hasFolded && (
|
|
1829
|
-
<Table.Th
|
|
1830
|
-
<
|
|
1782
|
+
<Table.Th {...toggleCell} aria-colindex={1}>
|
|
1783
|
+
<FoldHeaderLabel names={foldedNames} />
|
|
1831
1784
|
</Table.Th>
|
|
1832
1785
|
)}
|
|
1833
1786
|
{headerGroup.headers.map((header) => {
|
|
1834
1787
|
const canSort = sortingEnabled && header.column.getCanSort()
|
|
1835
1788
|
const sorted = header.column.getIsSorted()
|
|
1836
1789
|
const toggleSorting = header.column.getToggleSortingHandler()
|
|
1837
|
-
const
|
|
1838
|
-
|
|
1839
|
-
: undefined
|
|
1840
|
-
const align = resolveAlign(header.column)
|
|
1790
|
+
const pinned = pinningActive ? pinnedCellProps(pinCtx, header.column) : undefined
|
|
1791
|
+
const align = resolveAlign(header.column) ?? kindAlign(resolveKind(header.column))
|
|
1841
1792
|
const isSelectColumn = header.column.id === SELECT_COLUMN_ID
|
|
1842
1793
|
const isFoldCandidate = !isSelectColumn && header.column.id !== ACTIONS_COLUMN_ID
|
|
1843
1794
|
return (
|
|
1844
1795
|
<Table.Th
|
|
1845
1796
|
key={header.id}
|
|
1846
|
-
{
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1797
|
+
aria-colindex={colIndexById.get(header.column.id)}
|
|
1798
|
+
className={cx(isSelectColumn && classes.selectCell, pinned?.className)}
|
|
1799
|
+
{...fitAttr(header.column.id)}
|
|
1800
|
+
// The measured fold's own read (`useColumnFold`): a candidate's width plans the
|
|
1801
|
+
// fold, the checkbox / actions column's is fixed overhead against it.
|
|
1802
|
+
{...{
|
|
1803
|
+
[isFoldCandidate ? FOLD_ID_ATTR : FIXED_ID_ATTR]: header.column.id,
|
|
1804
|
+
}}
|
|
1850
1805
|
onClick={canSort ? toggleSorting : undefined}
|
|
1851
1806
|
onKeyDown={
|
|
1852
1807
|
canSort
|
|
@@ -1862,7 +1817,7 @@ export function BasaltDataTable<T extends RowData>(props: BasaltDataTableProps<T
|
|
|
1862
1817
|
style={{
|
|
1863
1818
|
...(canSort ? { cursor: 'pointer', userSelect: 'none' } : undefined),
|
|
1864
1819
|
...(align !== undefined && { textAlign: align }),
|
|
1865
|
-
...
|
|
1820
|
+
...pinned?.style,
|
|
1866
1821
|
}}
|
|
1867
1822
|
>
|
|
1868
1823
|
{header.isPlaceholder ? null : <FlexRender header={header} />}
|
|
@@ -1870,27 +1825,60 @@ export function BasaltDataTable<T extends RowData>(props: BasaltDataTableProps<T
|
|
|
1870
1825
|
</Table.Th>
|
|
1871
1826
|
)
|
|
1872
1827
|
})}
|
|
1828
|
+
{spacer && <Table.Th className={classes.spacer} aria-hidden />}
|
|
1873
1829
|
</Table.Tr>
|
|
1874
1830
|
))}
|
|
1875
1831
|
</Table.Thead>
|
|
1876
1832
|
<Table.Tbody>
|
|
1877
1833
|
{queryError !== undefined ? (
|
|
1878
1834
|
<Table.Tr>
|
|
1879
|
-
<Table.Td colSpan={
|
|
1835
|
+
<Table.Td colSpan={spanCount}>{errorNode}</Table.Td>
|
|
1880
1836
|
</Table.Tr>
|
|
1881
1837
|
) : showSkeleton ? (
|
|
1882
|
-
|
|
1838
|
+
// The same visible columns as the header — a folded table loads folded, and the pinned
|
|
1839
|
+
// identifier keeps its sticky cell, so nothing shifts when the rows arrive.
|
|
1840
|
+
Array.from({ length: skeletonCount }, (_, rowIndex) => (
|
|
1883
1841
|
<Table.Tr key={`skeleton-${rowIndex}`}>
|
|
1884
|
-
{
|
|
1885
|
-
<Table.Td
|
|
1886
|
-
<Skeleton
|
|
1842
|
+
{hasFolded && (
|
|
1843
|
+
<Table.Td {...toggleCell} aria-colindex={1}>
|
|
1844
|
+
<Skeleton h={12} w={12} radius="sm" display="inline-block" />
|
|
1887
1845
|
</Table.Td>
|
|
1888
|
-
)
|
|
1846
|
+
)}
|
|
1847
|
+
{orderedVisibleColumns.map((column) => {
|
|
1848
|
+
const pinned = pinningActive ? pinnedCellProps(pinCtx, column) : undefined
|
|
1849
|
+
const kind = resolveKind(column)
|
|
1850
|
+
// The loaded grid: a content-sized column keeps the width it last measured, the
|
|
1851
|
+
// others the kind's floor, so the rows arrive without the columns moving.
|
|
1852
|
+
const measuredWidth = fitIds.has(column.id)
|
|
1853
|
+
? measuredWidths.get(column.id)
|
|
1854
|
+
: undefined
|
|
1855
|
+
return (
|
|
1856
|
+
<Table.Td
|
|
1857
|
+
key={column.id}
|
|
1858
|
+
aria-colindex={colIndexById.get(column.id)}
|
|
1859
|
+
className={pinned?.className}
|
|
1860
|
+
{...fitAttr(column.id)}
|
|
1861
|
+
style={{
|
|
1862
|
+
minWidth:
|
|
1863
|
+
measuredWidth === undefined ? skeletonMinWidth(column) : measuredWidth,
|
|
1864
|
+
...pinned?.style,
|
|
1865
|
+
}}
|
|
1866
|
+
>
|
|
1867
|
+
{column.id === SELECT_COLUMN_ID || column.id === ACTIONS_COLUMN_ID ? null : (
|
|
1868
|
+
<KindSkeleton
|
|
1869
|
+
kind={kind}
|
|
1870
|
+
right={(resolveAlign(column) ?? kindAlign(kind)) === 'right'}
|
|
1871
|
+
/>
|
|
1872
|
+
)}
|
|
1873
|
+
</Table.Td>
|
|
1874
|
+
)
|
|
1875
|
+
})}
|
|
1876
|
+
{spacer && <Table.Td aria-hidden />}
|
|
1889
1877
|
</Table.Tr>
|
|
1890
1878
|
))
|
|
1891
1879
|
) : rows.length === 0 ? (
|
|
1892
1880
|
<Table.Tr>
|
|
1893
|
-
<Table.Td colSpan={
|
|
1881
|
+
<Table.Td colSpan={spanCount}>{emptyNode}</Table.Td>
|
|
1894
1882
|
</Table.Tr>
|
|
1895
1883
|
) : (
|
|
1896
1884
|
rows.map((row) => {
|
|
@@ -1909,47 +1897,67 @@ export function BasaltDataTable<T extends RowData>(props: BasaltDataTableProps<T
|
|
|
1909
1897
|
{...activationProps(onRowActivate, row.original)}
|
|
1910
1898
|
>
|
|
1911
1899
|
{hasFolded && (
|
|
1912
|
-
<Table.Td
|
|
1900
|
+
<Table.Td {...toggleCell} aria-colindex={1}>
|
|
1913
1901
|
<FoldToggle
|
|
1914
1902
|
expanded={rowExpanded}
|
|
1915
|
-
controlsId={`${row.id}-fold`}
|
|
1903
|
+
controlsId={`${tableId}-${row.id}-fold`}
|
|
1904
|
+
foldedLabel={foldedLabel}
|
|
1916
1905
|
onToggle={() => foldRows.toggle(row.id)}
|
|
1917
1906
|
/>
|
|
1918
1907
|
</Table.Td>
|
|
1919
1908
|
)}
|
|
1920
1909
|
{cells.map((cell) => {
|
|
1921
|
-
const
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
const align = resolveAlign(cell.column)
|
|
1910
|
+
const pinned = pinningActive ? pinnedCellProps(pinCtx, cell.column) : undefined
|
|
1911
|
+
const pinnedValue = cell.column.id === autoPinId ? cell.getValue() : undefined
|
|
1912
|
+
const kind = resolveKind(cell.column)
|
|
1913
|
+
const align = resolveAlign(cell.column) ?? kindAlign(kind)
|
|
1925
1914
|
return (
|
|
1926
1915
|
<Table.Td
|
|
1927
1916
|
key={cell.id}
|
|
1928
|
-
{
|
|
1929
|
-
|
|
1917
|
+
aria-colindex={colIndexById.get(cell.column.id)}
|
|
1918
|
+
className={cx(
|
|
1919
|
+
cell.column.id === SELECT_COLUMN_ID && classes.selectCell,
|
|
1920
|
+
kind !== undefined && kindClass(kind),
|
|
1921
|
+
pinned?.className,
|
|
1922
|
+
)}
|
|
1923
|
+
// The pinned column ellipsizes past its cap — the full text stays reachable.
|
|
1924
|
+
{...((typeof pinnedValue === 'string' ||
|
|
1925
|
+
typeof pinnedValue === 'number') && {
|
|
1926
|
+
title: String(pinnedValue),
|
|
1930
1927
|
})}
|
|
1928
|
+
{...(kind !== undefined && { 'data-kind': kind })}
|
|
1929
|
+
{...fitAttr(cell.column.id)}
|
|
1931
1930
|
{...(stopsRowActivation(cell) && {
|
|
1932
1931
|
// The label's ::after fills the select cell, so a tap on it bubbles to the
|
|
1933
1932
|
// row; the actions menu portals out but React bubbles through the portal.
|
|
1934
1933
|
onClick: (event: ReactMouseEvent) => event.stopPropagation(),
|
|
1935
1934
|
})}
|
|
1936
1935
|
style={{
|
|
1937
|
-
...(
|
|
1936
|
+
...(kind === undefined &&
|
|
1937
|
+
typeof cell.getValue() === 'number' &&
|
|
1938
1938
|
cell.column.columnDef.meta?.numeral !== false
|
|
1939
1939
|
? NUMERIC_CELL_STYLE
|
|
1940
1940
|
: undefined),
|
|
1941
1941
|
...(align !== undefined && { textAlign: align }),
|
|
1942
|
-
...
|
|
1942
|
+
...pinned?.style,
|
|
1943
1943
|
}}
|
|
1944
1944
|
>
|
|
1945
|
-
<
|
|
1945
|
+
<CellContent cell={cell} />
|
|
1946
1946
|
</Table.Td>
|
|
1947
1947
|
)
|
|
1948
1948
|
})}
|
|
1949
|
+
{spacer && <Table.Td aria-hidden />}
|
|
1949
1950
|
</Table.Tr>
|
|
1950
1951
|
{rowExpanded && (
|
|
1951
|
-
<Table.Tr
|
|
1952
|
-
|
|
1952
|
+
<Table.Tr
|
|
1953
|
+
id={`${tableId}-${row.id}-fold`}
|
|
1954
|
+
className={classes.foldDisclosureRowTr}
|
|
1955
|
+
>
|
|
1956
|
+
<Table.Td
|
|
1957
|
+
colSpan={spanCount}
|
|
1958
|
+
className={classes.foldDisclosureCell}
|
|
1959
|
+
aria-colindex={1}
|
|
1960
|
+
>
|
|
1953
1961
|
<RowDisclosure row={row} folded={foldedColumns} />
|
|
1954
1962
|
</Table.Td>
|
|
1955
1963
|
</Table.Tr>
|
|
@@ -1968,7 +1976,7 @@ export function BasaltDataTable<T extends RowData>(props: BasaltDataTableProps<T
|
|
|
1968
1976
|
{queryError !== undefined
|
|
1969
1977
|
? errorNode
|
|
1970
1978
|
: showSkeleton
|
|
1971
|
-
? Array.from({ length:
|
|
1979
|
+
? Array.from({ length: skeletonCount }, (_, index) => (
|
|
1972
1980
|
<Skeleton key={`skeleton-${index}`} height={48} radius="md" />
|
|
1973
1981
|
))
|
|
1974
1982
|
: rows.length === 0
|
|
@@ -1992,9 +2000,18 @@ export function BasaltDataTable<T extends RowData>(props: BasaltDataTableProps<T
|
|
|
1992
2000
|
const total = table.getRowCount()
|
|
1993
2001
|
const rangeStart = total === 0 ? 0 : paginationState.pageIndex * paginationState.pageSize + 1
|
|
1994
2002
|
const rangeEnd = Math.min((paginationState.pageIndex + 1) * paginationState.pageSize, total)
|
|
2003
|
+
// A page past the end (server-driven, the count shrank) keeps its pager so the reader can step
|
|
2004
|
+
// back, but states no range: "Showing 91–7 of 7" is a contradiction.
|
|
2005
|
+
const rangeInBounds = rangeStart <= rangeEnd || total === 0
|
|
2006
|
+
// Only a table that has NO rows drops its footer: a filter or search that matches nothing keeps
|
|
2007
|
+
// it (the pager and "Showing 0–0 of 0" belong to a table that has rows to page). Loading and
|
|
2008
|
+
// error keep the box too, the rows are about to land.
|
|
2009
|
+
const unfilteredCount = manualPagination ? total : table.getPreFilteredRowModel().rows.length
|
|
2010
|
+
const showFooter = enablePagination && (stateless || unfilteredCount > 0)
|
|
1995
2011
|
|
|
1996
2012
|
return (
|
|
1997
2013
|
<div
|
|
2014
|
+
{...pickDataAttributes(props)}
|
|
1998
2015
|
ref={projectionRootRef}
|
|
1999
2016
|
className={cx(classNames?.root, className)}
|
|
2000
2017
|
{...(style !== undefined && { style })}
|
|
@@ -2005,13 +2022,21 @@ export function BasaltDataTable<T extends RowData>(props: BasaltDataTableProps<T
|
|
|
2005
2022
|
* spent title → 11px → search → 11px → thead before a single datum appeared, and the toolbar
|
|
2006
2023
|
* read as page furniture rather than as this table's controls.
|
|
2007
2024
|
*
|
|
2008
|
-
* `wrap="wrap"` is the
|
|
2009
|
-
*
|
|
2010
|
-
*
|
|
2011
|
-
*
|
|
2025
|
+
* `wrap="wrap"` is the header row's own: a toolbar whose natural width exceeds what is left
|
|
2026
|
+
* beside a title drops under it, full width. The TOOLBAR itself never wraps from the `compact`
|
|
2027
|
+
* container class up (`.toolbar`) — the search shrinks to its floor and `FilterSet` folds the
|
|
2028
|
+
* rest behind `+N`. `align="center"` puts the 28px controls on the title's optical line.
|
|
2012
2029
|
*/}
|
|
2013
2030
|
{(title !== undefined || showToolbar) && (
|
|
2014
|
-
<Group
|
|
2031
|
+
<Group
|
|
2032
|
+
ref={headerRef}
|
|
2033
|
+
className={classes.tableHeader}
|
|
2034
|
+
justify="space-between"
|
|
2035
|
+
align="center"
|
|
2036
|
+
wrap="wrap"
|
|
2037
|
+
gap="xs"
|
|
2038
|
+
mb="xs"
|
|
2039
|
+
>
|
|
2015
2040
|
{title !== undefined ? (
|
|
2016
2041
|
<Box style={TABLE_HEADER_LEAD_STYLE}>
|
|
2017
2042
|
<WidgetHeader
|
|
@@ -2019,22 +2044,25 @@ export function BasaltDataTable<T extends RowData>(props: BasaltDataTableProps<T
|
|
|
2019
2044
|
title={title}
|
|
2020
2045
|
{...(icon !== undefined && { icon })}
|
|
2021
2046
|
{...(subtitle !== undefined && { subtitle })}
|
|
2022
|
-
count
|
|
2047
|
+
// A count is a figure read from rows: none while the rows are loading or failed.
|
|
2048
|
+
{...(!stateless && { count: table.getRowCount() })}
|
|
2023
2049
|
/>
|
|
2024
2050
|
</Box>
|
|
2025
2051
|
) : null}
|
|
2026
2052
|
{showToolbar && (
|
|
2027
2053
|
<CtlSlot>
|
|
2028
2054
|
<Group
|
|
2029
|
-
className={cx(classNames?.toolbar)}
|
|
2055
|
+
className={cx(classes.toolbar, classNames?.toolbar)}
|
|
2030
2056
|
data-basalt-dense
|
|
2031
2057
|
gap="xs"
|
|
2032
|
-
wrap="wrap"
|
|
2033
2058
|
align="center"
|
|
2034
2059
|
style={TABLE_TOOLBAR_STYLE}
|
|
2035
2060
|
>
|
|
2036
2061
|
{showSearch && (
|
|
2037
2062
|
<TextInput
|
|
2063
|
+
size="ctl"
|
|
2064
|
+
classNames={{ wrapper: classes.toolbarWrapper, input: classes.toolbarInput }}
|
|
2065
|
+
wrapperProps={{ 'data-basalt-hit': true }}
|
|
2038
2066
|
radius="md"
|
|
2039
2067
|
style={TABLE_SEARCH_STYLE}
|
|
2040
2068
|
placeholder={globalFilterPlaceholder}
|
|
@@ -2047,7 +2075,7 @@ export function BasaltDataTable<T extends RowData>(props: BasaltDataTableProps<T
|
|
|
2047
2075
|
/>
|
|
2048
2076
|
)}
|
|
2049
2077
|
{showFacets && (
|
|
2050
|
-
<FilterSet>
|
|
2078
|
+
<FilterSet inline={narrowToolbar ? 0 : 1}>
|
|
2051
2079
|
{facets?.map((facet) => {
|
|
2052
2080
|
const column = resolveFacetColumn(table, facet)
|
|
2053
2081
|
if (!column) return null
|
|
@@ -2067,7 +2095,11 @@ export function BasaltDataTable<T extends RowData>(props: BasaltDataTableProps<T
|
|
|
2067
2095
|
})}
|
|
2068
2096
|
</FilterSet>
|
|
2069
2097
|
)}
|
|
2070
|
-
{actions !== undefined &&
|
|
2098
|
+
{actions !== undefined && (
|
|
2099
|
+
<div className={classes.toolbarActions}>
|
|
2100
|
+
<BarActionSlot actions={actions} />
|
|
2101
|
+
</div>
|
|
2102
|
+
)}
|
|
2071
2103
|
</Group>
|
|
2072
2104
|
</CtlSlot>
|
|
2073
2105
|
)}
|
|
@@ -2088,7 +2120,13 @@ export function BasaltDataTable<T extends RowData>(props: BasaltDataTableProps<T
|
|
|
2088
2120
|
// An explicit `minWidth` is the one genuinely DECLARED horizontal floor — the column fold
|
|
2089
2121
|
// never engages here (see `foldEligible`, above), so this shape keeps its exact
|
|
2090
2122
|
// pre-existing DOM: no extra measuring wrapper for a table nothing folds.
|
|
2091
|
-
<Table.ScrollContainer
|
|
2123
|
+
<Table.ScrollContainer
|
|
2124
|
+
ref={minWidthScrollerRef}
|
|
2125
|
+
type="native"
|
|
2126
|
+
minWidth={minWidth ?? 0}
|
|
2127
|
+
maxHeight={maxHeight}
|
|
2128
|
+
{...scrollerProps(minWidthOverflowing)}
|
|
2129
|
+
>
|
|
2092
2130
|
{tableNode}
|
|
2093
2131
|
</Table.ScrollContainer>
|
|
2094
2132
|
) : (
|
|
@@ -2104,21 +2142,31 @@ export function BasaltDataTable<T extends RowData>(props: BasaltDataTableProps<T
|
|
|
2104
2142
|
// used to sit here was the exact inert-sticky defect this shape exists to avoid.
|
|
2105
2143
|
<div
|
|
2106
2144
|
ref={containmentRef}
|
|
2107
|
-
className={classes.containment}
|
|
2145
|
+
className={cx(classes.containment, contained && classes.scroller)}
|
|
2108
2146
|
data-contained={contained ? 'true' : 'false'}
|
|
2147
|
+
{...(contained && {
|
|
2148
|
+
tabIndex: 0,
|
|
2149
|
+
role: 'region',
|
|
2150
|
+
'aria-label': scrollerLabel,
|
|
2151
|
+
})}
|
|
2109
2152
|
>
|
|
2110
2153
|
{tableNode}
|
|
2111
2154
|
</div>
|
|
2112
2155
|
) : (
|
|
2113
2156
|
// `pageStickyHeader` is false whenever `maxHeight` is set (`scrolls` above), so a vertical
|
|
2114
2157
|
// cap lands here — its own `ScrollArea` scrollport, just with no `minWidth` floor.
|
|
2115
|
-
<Table.ScrollContainer
|
|
2158
|
+
<Table.ScrollContainer
|
|
2159
|
+
type="native"
|
|
2160
|
+
minWidth={0}
|
|
2161
|
+
maxHeight={maxHeight}
|
|
2162
|
+
{...scrollerProps(foldOverflowing)}
|
|
2163
|
+
>
|
|
2116
2164
|
{tableNode}
|
|
2117
2165
|
</Table.ScrollContainer>
|
|
2118
2166
|
)}
|
|
2119
2167
|
</div>
|
|
2120
2168
|
)}
|
|
2121
|
-
{
|
|
2169
|
+
{showFooter && (
|
|
2122
2170
|
<Group
|
|
2123
2171
|
className={cx(classNames?.footer)}
|
|
2124
2172
|
justify="space-between"
|
|
@@ -2127,15 +2175,24 @@ export function BasaltDataTable<T extends RowData>(props: BasaltDataTableProps<T
|
|
|
2127
2175
|
gap="xs"
|
|
2128
2176
|
align="center"
|
|
2129
2177
|
>
|
|
2130
|
-
<Text
|
|
2178
|
+
<Text
|
|
2179
|
+
// Hidden, not removed: the footer keeps its height and nothing shifts when rows land.
|
|
2180
|
+
style={
|
|
2181
|
+
stateless || !rangeInBounds
|
|
2182
|
+
? { ...RANGE_LABEL_STYLE, visibility: 'hidden' }
|
|
2183
|
+
: RANGE_LABEL_STYLE
|
|
2184
|
+
}
|
|
2185
|
+
>
|
|
2131
2186
|
Showing {rangeStart}–{rangeEnd}
|
|
2132
2187
|
{totalIsAuthoritative ? ` of ${total}` : ''}
|
|
2133
2188
|
</Text>
|
|
2134
|
-
<Group gap="xs" align="center">
|
|
2189
|
+
<Group gap="xs" align="center" data-basalt-dense>
|
|
2135
2190
|
{/* theme-allow control-outside-home — the table's own page-size setting, not a page
|
|
2136
2191
|
filter: its state is the table's pagination, owned inside this component. */}
|
|
2137
2192
|
<Select
|
|
2138
2193
|
size="ctl"
|
|
2194
|
+
classNames={{ wrapper: classes.toolbarWrapper, input: classes.toolbarInput }}
|
|
2195
|
+
wrapperProps={{ 'data-basalt-hit': true }}
|
|
2139
2196
|
radius="md"
|
|
2140
2197
|
w={PAGE_SIZE_WIDTH}
|
|
2141
2198
|
data={pageSizeRows}
|
|
@@ -2150,6 +2207,17 @@ export function BasaltDataTable<T extends RowData>(props: BasaltDataTableProps<T
|
|
|
2150
2207
|
size on its own — an explicit `size="sm"` is the visual this footer always had. */}
|
|
2151
2208
|
<Pagination
|
|
2152
2209
|
size="sm"
|
|
2210
|
+
// Mantine writes `--pagination-control-size` inline from `size`, which a class cannot
|
|
2211
|
+
// outrank — `vars` is the seam. The `ctl` height of the dense group above: 28 at a
|
|
2212
|
+
// fine pointer, 32 at a coarse one, the Select's own height either way. The labels
|
|
2213
|
+
// read `sm`, the cells' size, whatever the `size` prop maps to.
|
|
2214
|
+
vars={() => ({
|
|
2215
|
+
root: {
|
|
2216
|
+
'--pagination-control-size':
|
|
2217
|
+
'calc(var(--vx-space-control-height-ctl) * var(--mantine-scale))',
|
|
2218
|
+
'--pagination-control-fz': 'var(--vx-text-sm)',
|
|
2219
|
+
},
|
|
2220
|
+
})}
|
|
2153
2221
|
radius="md"
|
|
2154
2222
|
total={Math.max(table.getPageCount(), 1)}
|
|
2155
2223
|
value={paginationState.pageIndex + 1}
|