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.
Files changed (343) hide show
  1. package/CHANGELOG.md +466 -307
  2. package/MIGRATING.md +358 -12
  3. package/agent/rules/basalt-batteries.md +1 -1
  4. package/agent/rules/basalt-mantine.md +1 -1
  5. package/agent/rules/basalt-tokens.md +2 -2
  6. package/agent/skills/basalt-app/SKILL.md +3 -3
  7. package/agent/skills/basalt-charts/SKILL.md +1 -1
  8. package/agent/skills/basalt-design/SKILL.md +12 -6
  9. package/agent/skills/basalt-design/references/catalogue.md +42 -36
  10. package/agent/skills/basalt-design/references/recipes.md +47 -0
  11. package/agent/skills/basalt-design/references/states.md +1 -1
  12. package/configs/oxlint-basalt.json +2 -1
  13. package/configs/oxlint-plugin.js +112 -3
  14. package/configs/oxlint-plugin.test.ts +99 -4
  15. package/configs/oxlint.json +1 -0
  16. package/dist/agent/chat/thread-message.d.ts +1 -160
  17. package/dist/agent/chat/thread-message.d.ts.map +1 -1
  18. package/dist/agent/chat/thread-message.js +7 -162
  19. package/dist/agent/chat/virtualize.d.ts +5 -5
  20. package/dist/charts/ChartCard.d.ts +14 -7
  21. package/dist/charts/ChartCard.d.ts.map +1 -1
  22. package/dist/charts/ChartCard.js +112 -23
  23. package/dist/charts/Lines.d.ts.map +1 -1
  24. package/dist/charts/Lines.js +11 -4
  25. package/dist/charts/Sparkline.d.ts +14 -2
  26. package/dist/charts/Sparkline.d.ts.map +1 -1
  27. package/dist/charts/Sparkline.js +155 -44
  28. package/dist/charts/chart-box.module.css +59 -2
  29. package/dist/charts/chart-box.module.css.d.ts +5 -0
  30. package/dist/charts/chart-card.module.css +28 -17
  31. package/dist/charts/chart-card.module.css.d.ts +3 -0
  32. package/dist/charts/compile.d.ts +1 -1
  33. package/dist/charts/compile.d.ts.map +1 -1
  34. package/dist/charts/compile.js +38 -27
  35. package/dist/charts/labels.d.ts +13 -3
  36. package/dist/charts/labels.d.ts.map +1 -1
  37. package/dist/charts/labels.js +131 -20
  38. package/dist/charts/legend.d.ts.map +1 -1
  39. package/dist/charts/legend.js +1 -1
  40. package/dist/charts/ref-label.d.ts +37 -8
  41. package/dist/charts/ref-label.d.ts.map +1 -1
  42. package/dist/charts/ref-label.js +55 -10
  43. package/dist/charts/sparkline.module.css +50 -0
  44. package/dist/charts/sparkline.module.css.d.ts +3 -0
  45. package/dist/charts/state.d.ts +4 -4
  46. package/dist/charts/state.d.ts.map +1 -1
  47. package/dist/charts/state.js +23 -5
  48. package/dist/cli/doctor-upgrade.d.ts +11 -0
  49. package/dist/cli/doctor-upgrade.d.ts.map +1 -1
  50. package/dist/cli/doctor-upgrade.js +54 -0
  51. package/dist/cli/doctor.d.ts.map +1 -1
  52. package/dist/cli/doctor.js +32 -0
  53. package/dist/cli/help.d.ts.map +1 -1
  54. package/dist/cli/help.js +8 -3
  55. package/dist/cli/index.d.ts +13 -13
  56. package/dist/cli/index.d.ts.map +1 -1
  57. package/dist/cli/index.js +36 -2
  58. package/dist/cli/init.d.ts +6 -0
  59. package/dist/cli/init.d.ts.map +1 -1
  60. package/dist/cli/init.js +118 -27
  61. package/dist/cli/router-wiring.d.ts +3 -0
  62. package/dist/cli/router-wiring.d.ts.map +1 -1
  63. package/dist/cli/router-wiring.js +2 -0
  64. package/dist/cli/shot/capture.d.ts +34 -2
  65. package/dist/cli/shot/capture.d.ts.map +1 -1
  66. package/dist/cli/shot/capture.js +95 -12
  67. package/dist/cli/shot/detect.d.ts +4 -1
  68. package/dist/cli/shot/detect.d.ts.map +1 -1
  69. package/dist/cli/shot/detect.js +38 -16
  70. package/dist/cli/shot/index.d.ts.map +1 -1
  71. package/dist/cli/shot/index.js +9 -2
  72. package/dist/cli/shot/measure.d.ts.map +1 -1
  73. package/dist/cli/shot/measure.js +11 -2
  74. package/dist/cli/shot/types.d.ts +4 -1
  75. package/dist/cli/shot/types.d.ts.map +1 -1
  76. package/dist/cli/sync.d.ts.map +1 -1
  77. package/dist/cli/sync.js +10 -2
  78. package/dist/common/could-not-load.d.ts +13 -0
  79. package/dist/common/could-not-load.d.ts.map +1 -0
  80. package/dist/common/could-not-load.js +14 -0
  81. package/dist/common/empty-copy.d.ts +16 -0
  82. package/dist/common/empty-copy.d.ts.map +1 -0
  83. package/dist/common/empty-copy.js +9 -0
  84. package/dist/common/index.d.ts +1 -0
  85. package/dist/common/index.d.ts.map +1 -1
  86. package/dist/common/index.js +3 -0
  87. package/dist/common/props.d.ts +20 -0
  88. package/dist/common/props.d.ts.map +1 -1
  89. package/dist/common/props.js +13 -1
  90. package/dist/common/retry-button.module.css +7 -3
  91. package/dist/common/virtual-rows.d.ts +196 -0
  92. package/dist/common/virtual-rows.d.ts.map +1 -0
  93. package/dist/common/virtual-rows.js +290 -0
  94. package/dist/controls/controls.module.css +33 -1
  95. package/dist/controls/controls.module.css.d.ts +2 -0
  96. package/dist/controls/enum-filter.d.ts.map +1 -1
  97. package/dist/controls/enum-filter.js +8 -2
  98. package/dist/controls/filter-pill.d.ts +27 -3
  99. package/dist/controls/filter-pill.d.ts.map +1 -1
  100. package/dist/controls/filter-pill.js +15 -4
  101. package/dist/controls/form-layout.d.ts +9 -3
  102. package/dist/controls/form-layout.d.ts.map +1 -1
  103. package/dist/controls/form-layout.js +74 -12
  104. package/dist/controls/form-layout.module.css +112 -7
  105. package/dist/controls/form-layout.module.css.d.ts +1 -0
  106. package/dist/controls/multi-select-filter.d.ts +2 -2
  107. package/dist/controls/multi-select-filter.d.ts.map +1 -1
  108. package/dist/controls/multi-select-filter.js +12 -6
  109. package/dist/controls/range-filter.d.ts +1 -1
  110. package/dist/controls/range-filter.d.ts.map +1 -1
  111. package/dist/controls/range-filter.js +8 -2
  112. package/dist/dashboard/bar-list.d.ts +5 -5
  113. package/dist/dashboard/bar-list.d.ts.map +1 -1
  114. package/dist/dashboard/bar-list.js +15 -8
  115. package/dist/dashboard/bar-list.module.css +21 -5
  116. package/dist/dashboard/board-nav.d.ts +22 -0
  117. package/dist/dashboard/board-nav.d.ts.map +1 -0
  118. package/dist/dashboard/board-nav.js +49 -0
  119. package/dist/dashboard/board.d.ts +52 -0
  120. package/dist/dashboard/board.d.ts.map +1 -0
  121. package/dist/dashboard/board.js +247 -0
  122. package/dist/dashboard/board.module.css +179 -0
  123. package/dist/dashboard/board.module.css.d.ts +28 -0
  124. package/dist/dashboard/empty-state.d.ts +6 -6
  125. package/dist/dashboard/empty-state.d.ts.map +1 -1
  126. package/dist/dashboard/empty-state.js +17 -8
  127. package/dist/dashboard/event-list-model.d.ts +54 -0
  128. package/dist/dashboard/event-list-model.d.ts.map +1 -0
  129. package/dist/dashboard/event-list-model.js +76 -0
  130. package/dist/dashboard/event-list-rows.d.ts +23 -0
  131. package/dist/dashboard/event-list-rows.d.ts.map +1 -0
  132. package/dist/dashboard/event-list-rows.js +89 -0
  133. package/dist/dashboard/event-list-scroll.d.ts +55 -0
  134. package/dist/dashboard/event-list-scroll.d.ts.map +1 -0
  135. package/dist/dashboard/event-list-scroll.js +216 -0
  136. package/dist/dashboard/event-list-skeleton.d.ts +10 -0
  137. package/dist/dashboard/event-list-skeleton.d.ts.map +1 -0
  138. package/dist/dashboard/event-list-skeleton.js +34 -0
  139. package/dist/dashboard/event-list.d.ts +65 -0
  140. package/dist/dashboard/event-list.d.ts.map +1 -0
  141. package/dist/dashboard/event-list.js +208 -0
  142. package/dist/dashboard/event-list.module.css +336 -0
  143. package/dist/dashboard/event-list.module.css.d.ts +34 -0
  144. package/dist/dashboard/index.d.ts +2 -0
  145. package/dist/dashboard/index.d.ts.map +1 -1
  146. package/dist/dashboard/index.js +4 -0
  147. package/dist/dashboard/meter-model.d.ts +6 -3
  148. package/dist/dashboard/meter-model.d.ts.map +1 -1
  149. package/dist/dashboard/meter-model.js +9 -4
  150. package/dist/dashboard/meter-parts.d.ts +3 -0
  151. package/dist/dashboard/meter-parts.d.ts.map +1 -1
  152. package/dist/dashboard/meter-parts.js +36 -6
  153. package/dist/dashboard/meter.d.ts +3 -3
  154. package/dist/dashboard/meter.d.ts.map +1 -1
  155. package/dist/dashboard/meter.js +10 -2
  156. package/dist/dashboard/meter.module.css +20 -12
  157. package/dist/dashboard/meter.module.css.d.ts +0 -1
  158. package/dist/dashboard/page-summary.d.ts +3 -3
  159. package/dist/dashboard/page-summary.d.ts.map +1 -1
  160. package/dist/dashboard/page-summary.js +7 -2
  161. package/dist/dashboard/page-summary.module.css +5 -2
  162. package/dist/dashboard/query-state.d.ts +9 -8
  163. package/dist/dashboard/query-state.d.ts.map +1 -1
  164. package/dist/dashboard/query-state.js +29 -11
  165. package/dist/dashboard/section.d.ts +11 -3
  166. package/dist/dashboard/section.d.ts.map +1 -1
  167. package/dist/dashboard/section.js +34 -7
  168. package/dist/dashboard/settings-section.d.ts +8 -5
  169. package/dist/dashboard/settings-section.d.ts.map +1 -1
  170. package/dist/dashboard/settings-section.js +12 -8
  171. package/dist/dashboard/settings-section.module.css +25 -4
  172. package/dist/dashboard/settings-section.module.css.d.ts +1 -0
  173. package/dist/dashboard/stat-card-parts.d.ts +5 -1
  174. package/dist/dashboard/stat-card-parts.d.ts.map +1 -1
  175. package/dist/dashboard/stat-card-parts.js +8 -3
  176. package/dist/dashboard/stat-card.d.ts +3 -3
  177. package/dist/dashboard/stat-card.d.ts.map +1 -1
  178. package/dist/dashboard/stat-card.js +47 -12
  179. package/dist/dashboard/stat-card.module.css +42 -7
  180. package/dist/dashboard/stat-card.module.css.d.ts +3 -0
  181. package/dist/dashboard/stat-group.d.ts +2 -2
  182. package/dist/dashboard/stat-group.d.ts.map +1 -1
  183. package/dist/dashboard/stat-group.js +10 -3
  184. package/dist/dashboard/stat-strip.d.ts +5 -4
  185. package/dist/dashboard/stat-strip.d.ts.map +1 -1
  186. package/dist/dashboard/stat-strip.js +41 -31
  187. package/dist/dashboard/stat-strip.module.css +8 -6
  188. package/dist/dashboard/visual-slot.d.ts +4 -0
  189. package/dist/dashboard/visual-slot.d.ts.map +1 -1
  190. package/dist/dashboard/visual-slot.js +2 -0
  191. package/dist/dashboard/widget-header.d.ts +6 -6
  192. package/dist/dashboard/widget-header.d.ts.map +1 -1
  193. package/dist/dashboard/widget-header.js +4 -2
  194. package/dist/dashboard/widget-header.module.css +12 -15
  195. package/dist/format/shared.d.ts.map +1 -1
  196. package/dist/format/shared.js +24 -1
  197. package/dist/guard/index.d.ts +1 -1
  198. package/dist/guard/index.d.ts.map +1 -1
  199. package/dist/guard/index.js +4 -1
  200. package/dist/index.d.ts +1 -1
  201. package/dist/index.d.ts.map +1 -1
  202. package/dist/index.js +4 -0
  203. package/dist/shell/app-main.module.css +18 -0
  204. package/dist/styles.css +69 -0
  205. package/dist/surfaces.d.ts +2 -2
  206. package/dist/surfaces.d.ts.map +1 -1
  207. package/dist/surfaces.js +8 -2
  208. package/dist/table/cell-kinds.d.ts +47 -0
  209. package/dist/table/cell-kinds.d.ts.map +1 -0
  210. package/dist/table/cell-kinds.js +180 -0
  211. package/dist/table/cell-kinds.module.css +55 -0
  212. package/dist/table/cell-kinds.module.css.d.ts +15 -0
  213. package/dist/table/data-table-fold.d.ts +155 -0
  214. package/dist/table/data-table-fold.d.ts.map +1 -0
  215. package/dist/table/data-table-fold.js +320 -0
  216. package/dist/table/data-table-state.d.ts +10 -3
  217. package/dist/table/data-table-state.d.ts.map +1 -1
  218. package/dist/table/data-table-state.js +11 -6
  219. package/dist/table/data-table.d.ts +13 -28
  220. package/dist/table/data-table.d.ts.map +1 -1
  221. package/dist/table/data-table.js +362 -255
  222. package/dist/table/data-table.module.css +282 -3
  223. package/dist/table/data-table.module.css.d.ts +16 -0
  224. package/dist/table/table-features.d.ts +34 -4
  225. package/dist/table/table-features.d.ts.map +1 -1
  226. package/dist/table/table-features.js +10 -0
  227. package/dist/theme/card-inset.module.css +35 -0
  228. package/dist/theme/controls.module.css +55 -2
  229. package/dist/theme/ctl-theme.d.ts.map +1 -1
  230. package/dist/theme/ctl-theme.js +5 -0
  231. package/dist/theme/index.d.ts.map +1 -1
  232. package/dist/theme/index.js +14 -10
  233. package/dist/tokens/core.d.ts +1 -0
  234. package/dist/tokens/core.d.ts.map +1 -1
  235. package/dist/tokens/core.js +1 -0
  236. package/dist/tokens/derive.js +1 -1
  237. package/dist/tokens/palette.d.ts +2 -1
  238. package/dist/tokens/palette.d.ts.map +1 -1
  239. package/llms.txt +295 -5
  240. package/package.json +1 -1
  241. package/src/agent/chat/thread-message.tsx +10 -403
  242. package/src/agent/chat/virtualize.ts +5 -5
  243. package/src/charts/ChartCard.tsx +175 -31
  244. package/src/charts/Lines.tsx +13 -4
  245. package/src/charts/Sparkline.tsx +213 -48
  246. package/src/charts/chart-box.module.css +59 -2
  247. package/src/charts/chart-box.module.css.d.ts +5 -0
  248. package/src/charts/chart-card.module.css +28 -17
  249. package/src/charts/chart-card.module.css.d.ts +3 -0
  250. package/src/charts/compile.ts +59 -33
  251. package/src/charts/labels.ts +175 -24
  252. package/src/charts/legend.tsx +3 -2
  253. package/src/charts/ref-label.ts +114 -18
  254. package/src/charts/sparkline.module.css +50 -0
  255. package/src/charts/sparkline.module.css.d.ts +3 -0
  256. package/src/charts/state.tsx +40 -10
  257. package/src/cli/doctor-upgrade.ts +75 -0
  258. package/src/cli/doctor.ts +36 -0
  259. package/src/cli/help.ts +16 -6
  260. package/src/cli/index.ts +73 -67
  261. package/src/cli/init.ts +157 -36
  262. package/src/cli/router-wiring.ts +2 -2
  263. package/src/cli/shot/capture.ts +138 -16
  264. package/src/cli/shot/detect.ts +46 -22
  265. package/src/cli/shot/index.ts +8 -2
  266. package/src/cli/shot/measure.ts +11 -2
  267. package/src/cli/shot/types.ts +4 -1
  268. package/src/cli/sync.ts +12 -2
  269. package/src/common/could-not-load.ts +22 -0
  270. package/src/common/empty-copy.ts +17 -0
  271. package/src/common/index.ts +1 -0
  272. package/src/common/props.ts +30 -0
  273. package/src/common/retry-button.module.css +7 -3
  274. package/src/common/virtual-rows.tsx +682 -0
  275. package/src/controls/controls.module.css +33 -1
  276. package/src/controls/controls.module.css.d.ts +2 -0
  277. package/src/controls/enum-filter.tsx +8 -2
  278. package/src/controls/filter-pill.tsx +80 -27
  279. package/src/controls/form-layout.module.css +112 -7
  280. package/src/controls/form-layout.module.css.d.ts +1 -0
  281. package/src/controls/form-layout.tsx +115 -22
  282. package/src/controls/multi-select-filter.tsx +22 -11
  283. package/src/controls/range-filter.tsx +9 -3
  284. package/src/dashboard/bar-list.module.css +21 -5
  285. package/src/dashboard/bar-list.tsx +53 -45
  286. package/src/dashboard/board-nav.ts +67 -0
  287. package/src/dashboard/board.module.css +179 -0
  288. package/src/dashboard/board.module.css.d.ts +28 -0
  289. package/src/dashboard/board.tsx +415 -0
  290. package/src/dashboard/empty-state.tsx +21 -11
  291. package/src/dashboard/event-list-model.ts +125 -0
  292. package/src/dashboard/event-list-rows.tsx +117 -0
  293. package/src/dashboard/event-list-scroll.ts +291 -0
  294. package/src/dashboard/event-list-skeleton.tsx +62 -0
  295. package/src/dashboard/event-list.module.css +336 -0
  296. package/src/dashboard/event-list.module.css.d.ts +34 -0
  297. package/src/dashboard/event-list.tsx +336 -0
  298. package/src/dashboard/index.ts +2 -0
  299. package/src/dashboard/meter-model.ts +16 -7
  300. package/src/dashboard/meter-parts.tsx +53 -14
  301. package/src/dashboard/meter.module.css +20 -12
  302. package/src/dashboard/meter.module.css.d.ts +0 -1
  303. package/src/dashboard/meter.tsx +36 -18
  304. package/src/dashboard/page-summary.module.css +5 -2
  305. package/src/dashboard/page-summary.tsx +13 -6
  306. package/src/dashboard/query-state.tsx +55 -30
  307. package/src/dashboard/section.tsx +83 -41
  308. package/src/dashboard/settings-section.module.css +25 -4
  309. package/src/dashboard/settings-section.module.css.d.ts +1 -0
  310. package/src/dashboard/settings-section.tsx +18 -8
  311. package/src/dashboard/stat-card-parts.tsx +20 -3
  312. package/src/dashboard/stat-card.module.css +42 -7
  313. package/src/dashboard/stat-card.module.css.d.ts +3 -0
  314. package/src/dashboard/stat-card.tsx +55 -13
  315. package/src/dashboard/stat-group.tsx +22 -14
  316. package/src/dashboard/stat-strip.module.css +8 -6
  317. package/src/dashboard/stat-strip.tsx +29 -20
  318. package/src/dashboard/visual-slot.ts +5 -0
  319. package/src/dashboard/widget-header.module.css +12 -15
  320. package/src/dashboard/widget-header.tsx +8 -5
  321. package/src/format/shared.ts +30 -1
  322. package/src/guard/index.ts +7 -1
  323. package/src/index.ts +4 -0
  324. package/src/shell/app-main.module.css +18 -0
  325. package/src/styles.css +69 -0
  326. package/src/surfaces.ts +7 -1
  327. package/src/table/cell-kinds.module.css +55 -0
  328. package/src/table/cell-kinds.module.css.d.ts +15 -0
  329. package/src/table/cell-kinds.tsx +263 -0
  330. package/src/table/data-table-fold.tsx +567 -0
  331. package/src/table/data-table-state.ts +24 -13
  332. package/src/table/data-table.module.css +282 -3
  333. package/src/table/data-table.module.css.d.ts +16 -0
  334. package/src/table/data-table.tsx +430 -362
  335. package/src/table/table-features.ts +44 -4
  336. package/src/theme/__snapshots__/plain-theme.test.ts.snap +2 -66
  337. package/src/theme/card-inset.module.css +35 -0
  338. package/src/theme/controls.module.css +55 -2
  339. package/src/theme/ctl-theme.tsx +8 -0
  340. package/src/theme/index.ts +12 -8
  341. package/src/tokens/core.ts +1 -0
  342. package/src/tokens/derive.ts +1 -1
  343. package/src/tokens/palette.ts +4 -1
@@ -14,9 +14,10 @@ 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
- import { cx } from "../common/props.js";
19
+ import { HostTitleContext } from "../common/could-not-load.js";
20
+ import { cx, pickDataAttributes } from "../common/props.js";
20
21
  import { BASALT_PREFIX } from "../common/errors.js";
21
22
  import { HIT_COARSE } from "../common/hit-floor.js";
22
23
  import { useMeasuredWidths } from "../common/use-measured-widths.js";
@@ -27,18 +28,43 @@ import { EnumFilter } from "../controls/enum-filter.js";
27
28
  import { MultiSelectFilter } from "../controls/multi-select-filter.js";
28
29
  import { CtlSlot } from "../theme/index.js";
29
30
  import { IconSlot } from "../theme/icon-slot.js";
30
- import { alpha, VX } from "../tokens/index.js";
31
+ import { CONTAINER_CLASSES, VX } from "../tokens/index.js";
31
32
  import { WidgetHeader } from "../dashboard/index.js";
33
+ import { EmptyState } from "../dashboard/empty-state.js";
32
34
  import { ErrorState } from "../dashboard/query-state.js";
33
35
  import {
34
36
  activationProps,
35
- EMPTY_FOLD_SET,
36
37
  useCardProjection,
37
38
  useDataTableState,
39
+ useNarrowerThan,
38
40
  useRowDisclosure
39
41
  } from "./data-table-state.js";
42
+ import { planColumnFold } from "./data-table-fold.js";
40
43
  import { dataQueryBranch } from "./query-branch.js";
41
44
  import { basaltTableFeatures } from "./table-features.js";
45
+ import {
46
+ columnDefId,
47
+ columnLabel,
48
+ FIXED_ID_ATTR,
49
+ FOLD_ID_ATTR,
50
+ foldOrder,
51
+ foldToggleCellProps,
52
+ FoldHeaderLabel,
53
+ FoldToggle,
54
+ PIN_MIN_WIDTH,
55
+ pinnedCellProps,
56
+ RowDisclosure,
57
+ useColumnFold
58
+ } from "./data-table-fold.js";
59
+ import {
60
+ CellContent,
61
+ DEFAULT_CELL,
62
+ kindAlign,
63
+ kindClass,
64
+ KindSkeleton,
65
+ planColumnSizing,
66
+ resolveKind
67
+ } from "./cell-kinds.js";
42
68
  import classes from "./data-table.module.css";
43
69
  const ALIGNMENTS = /* @__PURE__ */ new Set(["left", "center", "right"]);
44
70
  function resolveAlign(column) {
@@ -118,9 +144,11 @@ const facetAnyOf = constructFilterFn({
118
144
  autoRemove: facetAutoRemove
119
145
  });
120
146
  const SELECT_COLUMN_ID = "__basalt_select__";
147
+ const SELECT_COLUMN_SIZE = HIT_COARSE;
121
148
  function selectionColumn() {
122
149
  return {
123
150
  id: SELECT_COLUMN_ID,
151
+ size: SELECT_COLUMN_SIZE,
124
152
  enableSorting: false,
125
153
  header: ({ table }) => (
126
154
  // oxlint-disable-next-line jsx-a11y/label-has-associated-control -- wraps <Checkbox>, which oxlint cannot see is an input
@@ -174,7 +202,7 @@ function RowActionCell({
174
202
  "aria-label": named === void 0 ? only.label : `${only.label}: ${named}`,
175
203
  disabled: only.disabled?.(row) === true,
176
204
  loading: only.loading?.(row) === true,
177
- ...only.danger === true && { color: "red" },
205
+ ...only.danger === true && { className: classes.dangerAction },
178
206
  onClick: () => {
179
207
  if (!inert) only.onClick(row);
180
208
  },
@@ -227,13 +255,27 @@ function BulkActionBar({ count, actions }) {
227
255
  /* @__PURE__ */ jsx(CtlSlot, { children: /* @__PURE__ */ jsx(ActionGroup, { secondary: actions }) })
228
256
  ] });
229
257
  }
258
+ const SKELETON_MIN_REM = {
259
+ entity: 7,
260
+ text: 4.5,
261
+ // A kindless column is the one-line cause or note of an outage or event log.
262
+ kindless: 8,
263
+ "relative-time": 5,
264
+ status: 4,
265
+ money: 4.5,
266
+ number: 3.5
267
+ };
268
+ function skeletonMinWidth(column) {
269
+ if (column.id === SELECT_COLUMN_ID || column.id === ACTIONS_COLUMN_ID) return void 0;
270
+ const rem = SKELETON_MIN_REM[resolveKind(column) ?? "kindless"];
271
+ return rem === void 0 ? void 0 : `${rem}rem`;
272
+ }
230
273
  function SortIndicator({ direction }) {
231
274
  if (!direction) return null;
232
275
  return /* @__PURE__ */ jsx(Box, { component: "span", ml: 4, "aria-hidden": true, children: direction === "asc" ? "\u2191" : "\u2193" });
233
276
  }
234
277
  const ARIA_SORT = { asc: "ascending", desc: "descending" };
235
278
  const NUMERIC_CELL_STYLE = {
236
- fontFamily: "var(--mantine-font-family-monospace)",
237
279
  fontSize: VX.text.sm,
238
280
  fontWeight: 500,
239
281
  fontVariantNumeric: "tabular-nums",
@@ -241,19 +283,20 @@ const NUMERIC_CELL_STYLE = {
241
283
  };
242
284
  const RANGE_LABEL_STYLE = {
243
285
  fontFamily: "var(--mantine-font-family-monospace)",
244
- fontSize: VX.text.xs,
286
+ fontSize: VX.text.micro,
245
287
  fontVariantNumeric: "tabular-nums",
246
288
  color: "var(--vx-faint)"
247
289
  };
248
290
  const DEFAULT_PAGE_SIZE_OPTIONS = [10, 25, 50, 100];
249
- const TABLE_HEADER_LEAD_STYLE = { flex: "1 1 auto", minWidth: 0 };
250
- const TABLE_TOOLBAR_STYLE = { flex: "0 1 auto", minWidth: 0 };
291
+ const TABLE_HEADER_LEAD_STYLE = { flex: "0 1 auto", minWidth: 0 };
292
+ const TABLE_TOOLBAR_STYLE = { flex: "1 1 auto", minWidth: 0 };
251
293
  const SEARCH_WIDTH = 220;
294
+ const SEARCH_SHRINK = 100;
252
295
  const SEARCH_DEBOUNCE_MS = 250;
253
296
  const TABLE_SEARCH_STYLE = {
254
297
  // `width` as well as the basis — see the `SEARCH_WIDTH` JSDoc.
255
298
  width: SEARCH_WIDTH,
256
- flex: `0 1 ${SEARCH_WIDTH}px`,
299
+ flex: `0 ${SEARCH_SHRINK} ${SEARCH_WIDTH}px`,
257
300
  minWidth: "12ch",
258
301
  maxWidth: "100%"
259
302
  };
@@ -267,144 +310,6 @@ function getOrderedHeaderGroups(table) {
267
310
  headers: [...start[index]?.headers ?? [], ...group.headers, ...end[index]?.headers ?? []]
268
311
  }));
269
312
  }
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
313
  const BREACH_REMEDY = {
409
314
  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
315
  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 +370,11 @@ function BasaltDataTable(props) {
465
370
  enableSorting = true,
466
371
  manualSorting = false,
467
372
  striped,
468
- highlightOnHover,
373
+ highlightOnHover = true,
469
374
  emptyState,
470
375
  isLoading = false,
471
376
  query,
472
- skeletonRows = 5,
377
+ skeletonRows,
473
378
  enableGlobalFilter = false,
474
379
  globalFilterPlaceholder = "Search\u2026",
475
380
  searchIcon,
@@ -563,7 +468,7 @@ function BasaltDataTable(props) {
563
468
  const totalIsAuthoritative = !breaches.includes("total");
564
469
  const scrolls = maxHeight !== void 0 || minWidth !== void 0;
565
470
  const foldEligible = minWidth === void 0;
566
- const { columnFoldOrder, columnFoldFixedIds } = useMemo(() => {
471
+ const { columnFoldOrder, columnFoldFixedIds, pinCandidates } = useMemo(() => {
567
472
  const pinnedIds = /* @__PURE__ */ new Set([...columnPinning.start, ...columnPinning.end]);
568
473
  const excluded = new Set(
569
474
  columns.flatMap((column) => {
@@ -574,16 +479,48 @@ function BasaltDataTable(props) {
574
479
  );
575
480
  return {
576
481
  columnFoldOrder: foldOrder(columns).filter((id) => !excluded.has(id)),
577
- columnFoldFixedIds: [...excluded]
482
+ columnFoldFixedIds: [...excluded],
483
+ // Leaf columns the caller did not pin itself, declared order: a caller's END pin must not
484
+ // also become the start pin, where TanStack would resolve it as start.
485
+ pinCandidates: columns.flatMap((column) => {
486
+ const id = columnDefId(column);
487
+ return id === void 0 || "columns" in column || pinnedIds.has(id) ? [] : [id];
488
+ })
578
489
  };
579
490
  }, [columns, columnPinning]);
491
+ const branch = query === void 0 ? void 0 : dataQueryBranch("BasaltDataTable", query);
492
+ const showSkeleton = branch === void 0 ? isLoading : branch === "pending";
493
+ const queryError = branch === "error" && query !== void 0 ? query : void 0;
580
494
  const { cards: showCards, rootRef: projectionRootRef } = useCardProjection(
581
495
  renderCard !== void 0
582
496
  );
583
- const { folded: foldedColumns, wrapperRef: foldWrapperRef } = useColumnFold({
497
+ const renderedRows = useRef(0);
498
+ const [lastLoadedRows, setLastLoadedRows] = useState(0);
499
+ const foldExtraIds = useMemo(
500
+ () => [
501
+ ...enableRowSelection ? [SELECT_COLUMN_ID] : [],
502
+ ...hasRowActions ? [ACTIONS_COLUMN_ID] : []
503
+ ],
504
+ [enableRowSelection, hasRowActions]
505
+ );
506
+ const {
507
+ folded: foldedColumns,
508
+ wrapperRef: foldWrapperRef,
509
+ pinId: autoPinId,
510
+ overflowing: foldOverflowing,
511
+ widths: measuredWidths
512
+ } = useColumnFold({
584
513
  active: foldEligible && !showCards,
585
514
  order: columnFoldOrder,
586
- fixedIds: columnFoldFixedIds
515
+ fixedIds: columnFoldFixedIds,
516
+ extraIds: foldExtraIds,
517
+ pinCandidates,
518
+ // An explicit caller pin wins: the fold already treats it as fixed overhead, and a second,
519
+ // implicit one beside it would stack two sticky columns nobody asked for.
520
+ // A one-column table has nothing to scroll beside an identifier.
521
+ allowPin: columnPinning.start.length === 0 && columns.length > 1,
522
+ headerOnly: showSkeleton || queryError !== void 0,
523
+ renderedRows
587
524
  });
588
525
  const columnVisibility = useMemo(
589
526
  () => Object.fromEntries([...foldedColumns].map((id) => [id, false])),
@@ -591,15 +528,20 @@ function BasaltDataTable(props) {
591
528
  );
592
529
  const hasFolded = foldedColumns.size > 0;
593
530
  const foldRows = useRowDisclosure({ data, getRowId });
594
- const pinningActive = enablePinning || hasRowActions;
595
- const tablePinning = useMemo(
596
- () => hasRowActions ? { ...columnPinning, end: [...columnPinning.end, ACTIONS_COLUMN_ID] } : columnPinning,
597
- [columnPinning, hasRowActions]
598
- );
531
+ const pinningActive = enablePinning || hasRowActions || autoPinId !== void 0;
532
+ const tablePinning = useMemo(() => {
533
+ const start = autoPinId === void 0 ? columnPinning.start : [...enableRowSelection ? [SELECT_COLUMN_ID] : [], autoPinId];
534
+ const end = hasRowActions ? [...columnPinning.end, ACTIONS_COLUMN_ID] : columnPinning.end;
535
+ return { start, end };
536
+ }, [columnPinning, hasRowActions, autoPinId, enableRowSelection]);
537
+ const pinStartOffset = hasFolded && tablePinning.start.length > 0 ? HIT_COARSE : 0;
538
+ const autoPinMinWidth = autoPinId === void 0 ? void 0 : columns.find((column) => columnDefId(column) === autoPinId)?.minSize ?? PIN_MIN_WIDTH;
539
+ const tableId = useId();
599
540
  const table = useTable({
600
541
  features: basaltTableFeatures,
601
542
  data,
602
543
  columns: tableColumns,
544
+ defaultColumn: { cell: DEFAULT_CELL },
603
545
  state: {
604
546
  sorting: tableState.sorting,
605
547
  globalFilter,
@@ -638,10 +580,23 @@ function BasaltDataTable(props) {
638
580
  const showSearch = enableGlobalFilter && filteringEnabled;
639
581
  const showFacets = hasFacets && filteringEnabled;
640
582
  const showToolbar = showSearch || showFacets || Boolean(actions);
641
- const branch = query === void 0 ? void 0 : dataQueryBranch("BasaltDataTable", query);
642
- const showSkeleton = branch === void 0 ? isLoading : branch === "pending";
643
- const queryError = branch === "error" && query !== void 0 ? query : void 0;
583
+ const { ref: headerRef, narrow: narrowToolbar } = useNarrowerThan(
584
+ CONTAINER_CLASSES.regular,
585
+ showToolbar
586
+ );
644
587
  const columnCount = columns.length + (enableRowSelection ? 1 : 0) + (hasRowActions ? 1 : 0) + (hasFolded ? 1 : 0) - foldedColumns.size;
588
+ const fullLeafColumns = pinningActive ? [
589
+ ...table.getStartLeafColumns(),
590
+ ...table.getCenterLeafColumns(),
591
+ ...table.getEndLeafColumns()
592
+ ] : table.getAllLeafColumns();
593
+ const colIndexOffset = hasFolded ? 1 : 0;
594
+ const colIndexById = new Map(
595
+ fullLeafColumns.map((column, index) => [column.id, index + 1 + colIndexOffset])
596
+ );
597
+ const ariaColCount = fullLeafColumns.length + colIndexOffset;
598
+ const foldedNames = fullLeafColumns.filter((column) => foldedColumns.has(column.id)).map((column) => columnLabel(column));
599
+ const foldedLabel = foldedNames.join(", ");
645
600
  const selectedModelRows = enableRowSelection ? table.getSelectedRowModel().rows : void 0;
646
601
  const selectedRows = useMemo(
647
602
  () => selectedModelRows?.map((row) => row.original) ?? [],
@@ -653,22 +608,53 @@ function BasaltDataTable(props) {
653
608
  );
654
609
  const headerGroups = pinningActive ? getOrderedHeaderGroups(table) : table.getHeaderGroups();
655
610
  const rows = table.getRowModel().rows;
611
+ const stateless = showSkeleton || queryError !== void 0;
612
+ useLayoutEffect(() => {
613
+ renderedRows.current = rows.length;
614
+ });
615
+ if (!stateless && rows.length > 0 && rows.length !== lastLoadedRows) {
616
+ setLastLoadedRows(rows.length);
617
+ }
656
618
  const pageStickyHeader = !scrolls && stickyHeader === true;
657
619
  const { wrapperRef: containmentRef, contained } = useMeasuredContainment(
658
620
  pageStickyHeader && !showCards
659
621
  );
660
622
  const resolvedStickyHeaderOffset = scrolls ? void 0 : stickyHeaderOffset;
623
+ const { wrapperRef: minWidthScrollerRef, contained: minWidthOverflowing } = useMeasuredContainment(!foldEligible && !showCards);
624
+ const scrollerLabel = `${title ?? "Table"}, scrolls horizontally`;
625
+ const scrollerProps = (overflowing) => overflowing ? { tabIndex: 0, role: "region", "aria-label": scrollerLabel, className: classes.scroller } : void 0;
661
626
  const errorNode = queryError !== void 0 && /* @__PURE__ */ jsx(
662
627
  ErrorState,
663
628
  {
664
629
  error: queryError.error,
665
- title: "Could not load rows",
630
+ ...title !== void 0 && { title: `Could not load ${title}` },
666
631
  tier: "section",
667
632
  retrying: queryError.fetchStatus === "fetching",
668
633
  onRetry: () => void queryError.refetch()
669
634
  }
670
635
  );
671
- const emptyNode = emptyState ?? /* @__PURE__ */ jsx(Text, { c: "dimmed", ta: "center", size: "sm", py: "sm", children: "No data to display." });
636
+ const emptyNode = /* @__PURE__ */ jsx(HostTitleContext, { value: title, children: emptyState ?? /* @__PURE__ */ jsx(EmptyState, { tier: "section", title: "No data to display." }) });
637
+ const orderedVisibleColumns = pinningActive ? [
638
+ ...table.getStartVisibleLeafColumns(),
639
+ ...table.getCenterVisibleLeafColumns(),
640
+ ...table.getEndVisibleLeafColumns()
641
+ ] : table.getVisibleLeafColumns();
642
+ const pinCtx = {
643
+ table,
644
+ startOffset: pinStartOffset,
645
+ autoPinId,
646
+ autoPinMinWidth
647
+ };
648
+ const toggleCell = foldToggleCellProps(pinCtx);
649
+ const { fitIds, spacer } = planColumnSizing(
650
+ orderedVisibleColumns,
651
+ /* @__PURE__ */ new Set([SELECT_COLUMN_ID, ACTIONS_COLUMN_ID]),
652
+ // Every row, not the page: paging, sorting or filtering must not move a column's width.
653
+ table.getCoreRowModel().rows
654
+ );
655
+ const fitAttr = (id) => fitIds.has(id) ? { "data-fit": true } : void 0;
656
+ const spanCount = columnCount + (spacer ? 1 : 0);
657
+ const skeletonCount = enablePagination ? table.state.pagination.pageSize : lastLoadedRows > 0 ? lastLoadedRows : skeletonRows ?? 5;
672
658
  const tableNode = /* @__PURE__ */ jsxs(
673
659
  Table,
674
660
  {
@@ -677,6 +663,7 @@ function BasaltDataTable(props) {
677
663
  pageStickyHeader && !contained && classes.pageSticky,
678
664
  classNames?.table
679
665
  ),
666
+ "aria-colcount": ariaColCount,
680
667
  ...striped !== void 0 && { striped },
681
668
  ...highlightOnHover !== void 0 && { highlightOnHover },
682
669
  ...stickyHeader !== void 0 && { stickyHeader },
@@ -689,20 +676,24 @@ function BasaltDataTable(props) {
689
676
  withTableBorder,
690
677
  children: [
691
678
  /* @__PURE__ */ jsx(Table.Thead, { children: headerGroups.map((headerGroup) => /* @__PURE__ */ jsxs(Table.Tr, { children: [
692
- hasFolded && /* @__PURE__ */ jsx(Table.Th, { className: classes.foldToggleCell, children: /* @__PURE__ */ jsx("span", { className: classes.srOnly, children: "Details" }) }),
679
+ hasFolded && /* @__PURE__ */ jsx(Table.Th, { ...toggleCell, "aria-colindex": 1, children: /* @__PURE__ */ jsx(FoldHeaderLabel, { names: foldedNames }) }),
693
680
  headerGroup.headers.map((header) => {
694
681
  const canSort = sortingEnabled && header.column.getCanSort();
695
682
  const sorted = header.column.getIsSorted();
696
683
  const toggleSorting = header.column.getToggleSortingHandler();
697
- const pinnedStyle = pinningActive ? getPinnedCellStyle(table, header.column) : void 0;
698
- const align = resolveAlign(header.column);
684
+ const pinned = pinningActive ? pinnedCellProps(pinCtx, header.column) : void 0;
685
+ const align = resolveAlign(header.column) ?? kindAlign(resolveKind(header.column));
699
686
  const isSelectColumn = header.column.id === SELECT_COLUMN_ID;
700
687
  const isFoldCandidate = !isSelectColumn && header.column.id !== ACTIONS_COLUMN_ID;
701
688
  return /* @__PURE__ */ jsxs(
702
689
  Table.Th,
703
690
  {
704
- ...isSelectColumn && { className: classes.selectCell },
705
- ...isFoldCandidate && { [FOLD_ID_ATTR]: header.column.id },
691
+ "aria-colindex": colIndexById.get(header.column.id),
692
+ className: cx(isSelectColumn && classes.selectCell, pinned?.className),
693
+ ...fitAttr(header.column.id),
694
+ ...{
695
+ [isFoldCandidate ? FOLD_ID_ATTR : FIXED_ID_ATTR]: header.column.id
696
+ },
706
697
  onClick: canSort ? toggleSorting : void 0,
707
698
  onKeyDown: canSort ? (event) => {
708
699
  if (event.key !== "Enter" && event.key !== " ") return;
@@ -714,7 +705,7 @@ function BasaltDataTable(props) {
714
705
  style: {
715
706
  ...canSort ? { cursor: "pointer", userSelect: "none" } : void 0,
716
707
  ...align !== void 0 && { textAlign: align },
717
- ...pinnedStyle
708
+ ...pinned?.style
718
709
  },
719
710
  children: [
720
711
  header.isPlaceholder ? null : /* @__PURE__ */ jsx(FlexRender, { header }),
@@ -723,9 +714,42 @@ function BasaltDataTable(props) {
723
714
  },
724
715
  header.id
725
716
  );
726
- })
717
+ }),
718
+ spacer && /* @__PURE__ */ jsx(Table.Th, { className: classes.spacer, "aria-hidden": true })
727
719
  ] }, headerGroup.id)) }),
728
- /* @__PURE__ */ jsx(Table.Tbody, { children: queryError !== void 0 ? /* @__PURE__ */ jsx(Table.Tr, { children: /* @__PURE__ */ jsx(Table.Td, { colSpan: columnCount, children: errorNode }) }) : showSkeleton ? Array.from({ length: skeletonRows }, (_, rowIndex) => /* @__PURE__ */ jsx(Table.Tr, { children: Array.from({ length: columnCount }, (__, colIndex) => /* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsx(Skeleton, { height: 16, radius: "sm" }) }, `skeleton-${rowIndex}-${colIndex}`)) }, `skeleton-${rowIndex}`)) : rows.length === 0 ? /* @__PURE__ */ jsx(Table.Tr, { children: /* @__PURE__ */ jsx(Table.Td, { colSpan: columnCount, children: emptyNode }) }) : rows.map((row) => {
720
+ /* @__PURE__ */ jsx(Table.Tbody, { children: queryError !== void 0 ? /* @__PURE__ */ jsx(Table.Tr, { children: /* @__PURE__ */ jsx(Table.Td, { colSpan: spanCount, children: errorNode }) }) : showSkeleton ? (
721
+ // The same visible columns as the header — a folded table loads folded, and the pinned
722
+ // identifier keeps its sticky cell, so nothing shifts when the rows arrive.
723
+ Array.from({ length: skeletonCount }, (_, rowIndex) => /* @__PURE__ */ jsxs(Table.Tr, { children: [
724
+ hasFolded && /* @__PURE__ */ jsx(Table.Td, { ...toggleCell, "aria-colindex": 1, children: /* @__PURE__ */ jsx(Skeleton, { h: 12, w: 12, radius: "sm", display: "inline-block" }) }),
725
+ orderedVisibleColumns.map((column) => {
726
+ const pinned = pinningActive ? pinnedCellProps(pinCtx, column) : void 0;
727
+ const kind = resolveKind(column);
728
+ const measuredWidth = fitIds.has(column.id) ? measuredWidths.get(column.id) : void 0;
729
+ return /* @__PURE__ */ jsx(
730
+ Table.Td,
731
+ {
732
+ "aria-colindex": colIndexById.get(column.id),
733
+ className: pinned?.className,
734
+ ...fitAttr(column.id),
735
+ style: {
736
+ minWidth: measuredWidth === void 0 ? skeletonMinWidth(column) : measuredWidth,
737
+ ...pinned?.style
738
+ },
739
+ children: column.id === SELECT_COLUMN_ID || column.id === ACTIONS_COLUMN_ID ? null : /* @__PURE__ */ jsx(
740
+ KindSkeleton,
741
+ {
742
+ kind,
743
+ right: (resolveAlign(column) ?? kindAlign(kind)) === "right"
744
+ }
745
+ )
746
+ },
747
+ column.id
748
+ );
749
+ }),
750
+ spacer && /* @__PURE__ */ jsx(Table.Td, { "aria-hidden": true })
751
+ ] }, `skeleton-${rowIndex}`))
752
+ ) : rows.length === 0 ? /* @__PURE__ */ jsx(Table.Tr, { children: /* @__PURE__ */ jsx(Table.Td, { colSpan: spanCount, children: emptyNode }) }) : rows.map((row) => {
729
753
  const cells = pinningActive ? [
730
754
  ...row.getStartVisibleCells(),
731
755
  ...row.getCenterVisibleCells(),
@@ -739,125 +763,180 @@ function BasaltDataTable(props) {
739
763
  ...enableRowSelection && row.getIsSelected() && { "data-selected": true },
740
764
  ...activationProps(onRowActivate, row.original),
741
765
  children: [
742
- hasFolded && /* @__PURE__ */ jsx(Table.Td, { className: classes.foldToggleCell, children: /* @__PURE__ */ jsx(
766
+ hasFolded && /* @__PURE__ */ jsx(Table.Td, { ...toggleCell, "aria-colindex": 1, children: /* @__PURE__ */ jsx(
743
767
  FoldToggle,
744
768
  {
745
769
  expanded: rowExpanded,
746
- controlsId: `${row.id}-fold`,
770
+ controlsId: `${tableId}-${row.id}-fold`,
771
+ foldedLabel,
747
772
  onToggle: () => foldRows.toggle(row.id)
748
773
  }
749
774
  ) }),
750
775
  cells.map((cell) => {
751
- const pinnedStyle = pinningActive ? getPinnedCellStyle(table, cell.column) : void 0;
752
- const align = resolveAlign(cell.column);
776
+ const pinned = pinningActive ? pinnedCellProps(pinCtx, cell.column) : void 0;
777
+ const pinnedValue = cell.column.id === autoPinId ? cell.getValue() : void 0;
778
+ const kind = resolveKind(cell.column);
779
+ const align = resolveAlign(cell.column) ?? kindAlign(kind);
753
780
  return /* @__PURE__ */ jsx(
754
781
  Table.Td,
755
782
  {
756
- ...cell.column.id === SELECT_COLUMN_ID && {
757
- className: classes.selectCell
783
+ "aria-colindex": colIndexById.get(cell.column.id),
784
+ className: cx(
785
+ cell.column.id === SELECT_COLUMN_ID && classes.selectCell,
786
+ kind !== void 0 && kindClass(kind),
787
+ pinned?.className
788
+ ),
789
+ ...(typeof pinnedValue === "string" || typeof pinnedValue === "number") && {
790
+ title: String(pinnedValue)
758
791
  },
792
+ ...kind !== void 0 && { "data-kind": kind },
793
+ ...fitAttr(cell.column.id),
759
794
  ...stopsRowActivation(cell) && {
760
795
  // The label's ::after fills the select cell, so a tap on it bubbles to the
761
796
  // row; the actions menu portals out but React bubbles through the portal.
762
797
  onClick: (event) => event.stopPropagation()
763
798
  },
764
799
  style: {
765
- ...typeof cell.getValue() === "number" && cell.column.columnDef.meta?.numeral !== false ? NUMERIC_CELL_STYLE : void 0,
800
+ ...kind === void 0 && typeof cell.getValue() === "number" && cell.column.columnDef.meta?.numeral !== false ? NUMERIC_CELL_STYLE : void 0,
766
801
  ...align !== void 0 && { textAlign: align },
767
- ...pinnedStyle
802
+ ...pinned?.style
768
803
  },
769
- children: /* @__PURE__ */ jsx(FlexRender, { cell })
804
+ children: /* @__PURE__ */ jsx(CellContent, { cell })
770
805
  },
771
806
  cell.id
772
807
  );
773
- })
808
+ }),
809
+ spacer && /* @__PURE__ */ jsx(Table.Td, { "aria-hidden": true })
774
810
  ]
775
811
  }
776
812
  ),
777
- rowExpanded && /* @__PURE__ */ jsx(Table.Tr, { id: `${row.id}-fold`, className: classes.foldDisclosureRowTr, children: /* @__PURE__ */ jsx(Table.Td, { colSpan: columnCount, className: classes.foldDisclosureCell, children: /* @__PURE__ */ jsx(RowDisclosure, { row, folded: foldedColumns }) }) })
813
+ rowExpanded && /* @__PURE__ */ jsx(
814
+ Table.Tr,
815
+ {
816
+ id: `${tableId}-${row.id}-fold`,
817
+ className: classes.foldDisclosureRowTr,
818
+ children: /* @__PURE__ */ jsx(
819
+ Table.Td,
820
+ {
821
+ colSpan: spanCount,
822
+ className: classes.foldDisclosureCell,
823
+ "aria-colindex": 1,
824
+ children: /* @__PURE__ */ jsx(RowDisclosure, { row, folded: foldedColumns })
825
+ }
826
+ )
827
+ }
828
+ )
778
829
  ] }, row.id);
779
830
  }) })
780
831
  ]
781
832
  }
782
833
  );
783
- const renderCardList = () => /* @__PURE__ */ jsx(Stack, { gap: "xs", className: cx(classNames?.table), children: queryError !== void 0 ? errorNode : showSkeleton ? Array.from({ length: skeletonRows }, (_, 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)) });
834
+ 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
835
  const paginationState = table.state.pagination;
785
836
  const pageSizeRows = [.../* @__PURE__ */ new Set([...pageSizeOptions, paginationState.pageSize])].sort((a, b) => a - b).map((size) => ({ value: String(size), label: `${size} / page` }));
786
837
  const total = table.getRowCount();
787
838
  const rangeStart = total === 0 ? 0 : paginationState.pageIndex * paginationState.pageSize + 1;
788
839
  const rangeEnd = Math.min((paginationState.pageIndex + 1) * paginationState.pageSize, total);
840
+ const rangeInBounds = rangeStart <= rangeEnd || total === 0;
841
+ const unfilteredCount = manualPagination ? total : table.getPreFilteredRowModel().rows.length;
842
+ const showFooter = enablePagination && (stateless || unfilteredCount > 0);
789
843
  return /* @__PURE__ */ jsxs(
790
844
  "div",
791
845
  {
846
+ ...pickDataAttributes(props),
792
847
  ref: projectionRootRef,
793
848
  className: cx(classNames?.root, className),
794
849
  ...style !== void 0 && { style },
795
850
  children: [
796
- (title !== void 0 || showToolbar) && /* @__PURE__ */ jsxs(Group, { justify: "space-between", align: "center", wrap: "wrap", gap: "xs", mb: "xs", children: [
797
- title !== void 0 ? /* @__PURE__ */ jsx(Box, { style: TABLE_HEADER_LEAD_STYLE, children: /* @__PURE__ */ jsx(
798
- WidgetHeader,
799
- {
800
- tier: "widget",
801
- title,
802
- ...icon !== void 0 && { icon },
803
- ...subtitle !== void 0 && { subtitle },
804
- count: table.getRowCount()
805
- }
806
- ) }) : null,
807
- showToolbar && /* @__PURE__ */ jsx(CtlSlot, { children: /* @__PURE__ */ jsxs(
808
- Group,
809
- {
810
- className: cx(classNames?.toolbar),
811
- "data-basalt-dense": true,
812
- gap: "xs",
813
- wrap: "wrap",
814
- align: "center",
815
- style: TABLE_TOOLBAR_STYLE,
816
- children: [
817
- showSearch && /* @__PURE__ */ jsx(
818
- TextInput,
819
- {
820
- radius: "md",
821
- style: TABLE_SEARCH_STYLE,
822
- placeholder: globalFilterPlaceholder,
823
- leftSection: searchIcon,
824
- value: searchDraft,
825
- onChange: (event) => {
826
- setSearchDraft(event.currentTarget.value);
827
- commitSearch(event.currentTarget.value);
828
- }
829
- }
830
- ),
831
- showFacets && /* @__PURE__ */ jsx(FilterSet, { children: facets?.map((facet) => {
832
- const column = resolveFacetColumn(table, facet);
833
- if (!column) return null;
834
- return facet.multiple ? /* @__PURE__ */ jsx(
835
- MultiSelectFilter,
836
- {
837
- field: facetMultiHandle(column, facet),
838
- label: facet.label
839
- },
840
- facet.columnId
841
- ) : /* @__PURE__ */ jsx(
842
- EnumFilter,
843
- {
844
- field: facetEnumHandle(column, facet),
845
- label: facet.label
846
- },
847
- facet.columnId
848
- );
849
- }) }),
850
- actions !== void 0 && /* @__PURE__ */ jsx(BarActionSlot, { actions })
851
- ]
852
- }
853
- ) })
854
- ] }),
851
+ (title !== void 0 || showToolbar) && /* @__PURE__ */ jsxs(
852
+ Group,
853
+ {
854
+ ref: headerRef,
855
+ className: classes.tableHeader,
856
+ justify: "space-between",
857
+ align: "center",
858
+ wrap: "wrap",
859
+ gap: "xs",
860
+ mb: "xs",
861
+ children: [
862
+ title !== void 0 ? /* @__PURE__ */ jsx(Box, { style: TABLE_HEADER_LEAD_STYLE, children: /* @__PURE__ */ jsx(
863
+ WidgetHeader,
864
+ {
865
+ tier: "widget",
866
+ title,
867
+ ...icon !== void 0 && { icon },
868
+ ...subtitle !== void 0 && { subtitle },
869
+ ...!stateless && { count: table.getRowCount() }
870
+ }
871
+ ) }) : null,
872
+ showToolbar && /* @__PURE__ */ jsx(CtlSlot, { children: /* @__PURE__ */ jsxs(
873
+ Group,
874
+ {
875
+ className: cx(classes.toolbar, classNames?.toolbar),
876
+ "data-basalt-dense": true,
877
+ gap: "xs",
878
+ align: "center",
879
+ style: TABLE_TOOLBAR_STYLE,
880
+ children: [
881
+ showSearch && /* @__PURE__ */ jsx(
882
+ TextInput,
883
+ {
884
+ size: "ctl",
885
+ classNames: { wrapper: classes.toolbarWrapper, input: classes.toolbarInput },
886
+ wrapperProps: { "data-basalt-hit": true },
887
+ radius: "md",
888
+ style: TABLE_SEARCH_STYLE,
889
+ placeholder: globalFilterPlaceholder,
890
+ leftSection: searchIcon,
891
+ value: searchDraft,
892
+ onChange: (event) => {
893
+ setSearchDraft(event.currentTarget.value);
894
+ commitSearch(event.currentTarget.value);
895
+ }
896
+ }
897
+ ),
898
+ showFacets && /* @__PURE__ */ jsx(FilterSet, { inline: narrowToolbar ? 0 : 1, children: facets?.map((facet) => {
899
+ const column = resolveFacetColumn(table, facet);
900
+ if (!column) return null;
901
+ return facet.multiple ? /* @__PURE__ */ jsx(
902
+ MultiSelectFilter,
903
+ {
904
+ field: facetMultiHandle(column, facet),
905
+ label: facet.label
906
+ },
907
+ facet.columnId
908
+ ) : /* @__PURE__ */ jsx(
909
+ EnumFilter,
910
+ {
911
+ field: facetEnumHandle(column, facet),
912
+ label: facet.label
913
+ },
914
+ facet.columnId
915
+ );
916
+ }) }),
917
+ actions !== void 0 && /* @__PURE__ */ jsx("div", { className: classes.toolbarActions, children: /* @__PURE__ */ jsx(BarActionSlot, { actions }) })
918
+ ]
919
+ }
920
+ ) })
921
+ ]
922
+ }
923
+ ),
855
924
  bulkBarActions !== void 0 && /* @__PURE__ */ jsx(BulkActionBar, { count: selectedRows.length, actions: bulkBarActions }),
856
925
  showCards ? maxHeight === void 0 ? renderCardList() : /* @__PURE__ */ jsx(ScrollArea.Autosize, { mah: maxHeight, type: "hover", scrollbars: "y", children: renderCardList() }) : !foldEligible ? (
857
926
  // An explicit `minWidth` is the one genuinely DECLARED horizontal floor — the column fold
858
927
  // never engages here (see `foldEligible`, above), so this shape keeps its exact
859
928
  // pre-existing DOM: no extra measuring wrapper for a table nothing folds.
860
- /* @__PURE__ */ jsx(Table.ScrollContainer, { type: "native", minWidth: minWidth ?? 0, maxHeight, children: tableNode })
929
+ /* @__PURE__ */ jsx(
930
+ Table.ScrollContainer,
931
+ {
932
+ ref: minWidthScrollerRef,
933
+ type: "native",
934
+ minWidth: minWidth ?? 0,
935
+ maxHeight,
936
+ ...scrollerProps(minWidthOverflowing),
937
+ children: tableNode
938
+ }
939
+ )
861
940
  ) : (
862
941
  // The column fold's own measuring box (`useColumnFold`) — wraps every remaining shape,
863
942
  // `maxHeight`-only included: a vertical cap is orthogonal to column width, so a
@@ -872,18 +951,32 @@ function BasaltDataTable(props) {
872
951
  "div",
873
952
  {
874
953
  ref: containmentRef,
875
- className: classes.containment,
954
+ className: cx(classes.containment, contained && classes.scroller),
876
955
  "data-contained": contained ? "true" : "false",
956
+ ...contained && {
957
+ tabIndex: 0,
958
+ role: "region",
959
+ "aria-label": scrollerLabel
960
+ },
877
961
  children: tableNode
878
962
  }
879
963
  )
880
964
  ) : (
881
965
  // `pageStickyHeader` is false whenever `maxHeight` is set (`scrolls` above), so a vertical
882
966
  // cap lands here — its own `ScrollArea` scrollport, just with no `minWidth` floor.
883
- /* @__PURE__ */ jsx(Table.ScrollContainer, { type: "native", minWidth: 0, maxHeight, children: tableNode })
967
+ /* @__PURE__ */ jsx(
968
+ Table.ScrollContainer,
969
+ {
970
+ type: "native",
971
+ minWidth: 0,
972
+ maxHeight,
973
+ ...scrollerProps(foldOverflowing),
974
+ children: tableNode
975
+ }
976
+ )
884
977
  ) })
885
978
  ),
886
- enablePagination && /* @__PURE__ */ jsxs(
979
+ showFooter && /* @__PURE__ */ jsxs(
887
980
  Group,
888
981
  {
889
982
  className: cx(classNames?.footer),
@@ -893,18 +986,26 @@ function BasaltDataTable(props) {
893
986
  gap: "xs",
894
987
  align: "center",
895
988
  children: [
896
- /* @__PURE__ */ jsxs(Text, { style: RANGE_LABEL_STYLE, children: [
897
- "Showing ",
898
- rangeStart,
899
- "\u2013",
900
- rangeEnd,
901
- totalIsAuthoritative ? ` of ${total}` : ""
902
- ] }),
903
- /* @__PURE__ */ jsxs(Group, { gap: "xs", align: "center", children: [
989
+ /* @__PURE__ */ jsxs(
990
+ Text,
991
+ {
992
+ style: stateless || !rangeInBounds ? { ...RANGE_LABEL_STYLE, visibility: "hidden" } : RANGE_LABEL_STYLE,
993
+ children: [
994
+ "Showing ",
995
+ rangeStart,
996
+ "\u2013",
997
+ rangeEnd,
998
+ totalIsAuthoritative ? ` of ${total}` : ""
999
+ ]
1000
+ }
1001
+ ),
1002
+ /* @__PURE__ */ jsxs(Group, { gap: "xs", align: "center", "data-basalt-dense": true, children: [
904
1003
  /* @__PURE__ */ jsx(
905
1004
  Select,
906
1005
  {
907
1006
  size: "ctl",
1007
+ classNames: { wrapper: classes.toolbarWrapper, input: classes.toolbarInput },
1008
+ wrapperProps: { "data-basalt-hit": true },
908
1009
  radius: "md",
909
1010
  w: PAGE_SIZE_WIDTH,
910
1011
  data: pageSizeRows,
@@ -917,6 +1018,12 @@ function BasaltDataTable(props) {
917
1018
  Pagination,
918
1019
  {
919
1020
  size: "sm",
1021
+ vars: () => ({
1022
+ root: {
1023
+ "--pagination-control-size": "calc(var(--vx-space-control-height-ctl) * var(--mantine-scale))",
1024
+ "--pagination-control-fz": "var(--vx-text-sm)"
1025
+ }
1026
+ }),
920
1027
  radius: "md",
921
1028
  total: Math.max(table.getPageCount(), 1),
922
1029
  value: paginationState.pageIndex + 1,