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
@@ -0,0 +1,155 @@
1
+ import type { Column, ColumnDef, Row, RowData, Table as TanstackTable } from '@tanstack/react-table';
2
+ import type { CSSProperties, ReactNode, RefObject } from 'react';
3
+ import type { BasaltTableFeatures } from './table-features.js';
4
+ /** The column id TanStack will resolve internally for this raw def — explicit `id`, else the
5
+ * accessor key string. */
6
+ export declare function columnDefId<T extends RowData>(column: ColumnDef<BasaltTableFeatures, T, unknown>): string | undefined;
7
+ /**
8
+ * Fold order for `meta.priority` — the FIRST id in the returned list folds first. Effective
9
+ * priority is `meta.priority ?? declaredIndex`, so with no `meta.priority` set anywhere it is just
10
+ * the column's position: the LAST declared column folds first, the zero-config default a bare
11
+ * `<BasaltDataTable data columns />` needs. An explicit priority folds a HIGHER number before a
12
+ * lower one; a tie folds in reverse declared order. A column with no resolvable id (an
13
+ * `accessorFn` with no explicit `id`) is never a fold candidate — nothing downstream could
14
+ * reliably re-identify it once hidden.
15
+ */
16
+ export declare function foldOrder<T extends RowData>(columns: readonly ColumnDef<BasaltTableFeatures, T, unknown>[]): string[];
17
+ /** Marks a rendered data column header for `useColumnFold`'s width measurement — never read past
18
+ * that hook, so it carries no styling and needs no CSS-module counterpart. */
19
+ export declare const FOLD_ID_ATTR = "data-basalt-fold-id";
20
+ /** The same mark on the columns that are never folded but still take room — the checkbox and the
21
+ * row-actions column — so their widths join the plan's overhead. */
22
+ export declare const FIXED_ID_ATTR = "data-basalt-fixed-id";
23
+ /** The auto-pinned identifier column's width floor, px, when its `columnDef.minSize` is unset. */
24
+ export declare const PIN_MIN_WIDTH = 120;
25
+ /**
26
+ * Pure decision: fold columns off the FRONT of `order` (already fold-first sorted) until the
27
+ * still-unfolded ones — plus `overhead` (the columns excluded from candidacy altogether — pinned,
28
+ * `enableHiding: false`, the checkbox and actions columns — which occupy room but can never fold)
29
+ * and the disclosure toggle's own width, once anything is folded — fit `room`, or only
30
+ * {@link FOLD_FLOOR} data columns remain (`fixedCount` of them are the excluded data columns).
31
+ * A candidate with no measured width yet (never rendered) is skipped rather than folded blind,
32
+ * since folding it would remove the one place its width could ever be read from.
33
+ *
34
+ * Every width is a rounded integer (`offsetWidth`, `clientWidth`), and a table that fills its
35
+ * wrapper stretches its columns to sum to `room` exactly — so the rounded sum lands up to half a
36
+ * pixel per column over it, and a table that fits folded a column on hydration (a server-painted
37
+ * table whose cells then moved). The fit check forgives that rounding and nothing more: half a
38
+ * pixel for each measured width (the foldable columns, `fixedCount` and `extraCount` — the
39
+ * excluded data columns and the checkbox / actions ones `overhead` sums), plus half a pixel for
40
+ * `room`'s own rounding (the `+ 1` in the slack).
41
+ */
42
+ export declare function planColumnFold(input: {
43
+ room: number;
44
+ toggleWidth: number;
45
+ overhead: number;
46
+ /** How many excluded DATA columns `overhead` sums: they count toward the floor and the slack. */
47
+ fixedCount?: number;
48
+ /** How many non-data columns (checkbox, actions) `overhead` sums: the slack only. */
49
+ extraCount?: number;
50
+ order: readonly string[];
51
+ widths: ReadonlyMap<string, number>;
52
+ }): ReadonlySet<string>;
53
+ /**
54
+ * The general-case measured fold. Reacting to `useMeasuredContainment`'s boolean fit directly
55
+ * (fold one, remeasure, maybe unfold) would oscillate, because folding changes the very box being
56
+ * measured. Instead this reads each candidate `<th data-basalt-fold-id>`'s width once, while it is
57
+ * visible, caches it, and decides analytically (`planColumnFold`). `useMeasuredWidths` owns the
58
+ * cache and the wrapper-vs-table observer that `controls/actions.tsx`'s fold shares.
59
+ */
60
+ export declare function useColumnFold(input: {
61
+ active: boolean;
62
+ order: readonly string[];
63
+ /**
64
+ * Columns excluded from fold candidacy altogether (pinned, or `enableHiding: false`) — they are
65
+ * never in `order`, but they still occupy room, and their measured widths (carried in the same
66
+ * sweep as every eligible column's) become fixed overhead against the fold baseline.
67
+ */
68
+ fixedIds: readonly string[];
69
+ /** The checkbox / actions columns: never folded, never data, but they take room all the same. */
70
+ extraIds: readonly string[];
71
+ /** Every pin CANDIDATE in declared order: the caller's columns minus any it pinned itself. */
72
+ pinCandidates: readonly string[];
73
+ /** False when the caller pinned a start column itself: an explicit pin wins, nothing auto-pins. */
74
+ allowPin: boolean;
75
+ /**
76
+ * The body holds no rows (loading, empty, error): its widths are header-only and narrower than
77
+ * the loaded table's, so they never overwrite what a loaded table already measured — the states
78
+ * keep the loaded fold instead of unfolding a column the rows would fold again.
79
+ */
80
+ headerOnly: boolean;
81
+ /** The rows the body renders right now: a filter that matches nothing leaves a header-only body too. */
82
+ renderedRows: RefObject<number>;
83
+ }): {
84
+ wrapperRef: RefObject<HTMLDivElement | null>;
85
+ folded: ReadonlySet<string>;
86
+ /** The column pinned to the start edge because the floor-folded table still overflows. */
87
+ pinId: string | undefined;
88
+ /** Whether the table is wider than its container right now — i.e. whether the scroller scrolls. */
89
+ overflowing: boolean;
90
+ /** The last natural width of every column the sweep has seen, read by the loading skeleton's grid. */
91
+ widths: ReadonlyMap<string, number>;
92
+ };
93
+ /** What every sticky cell of a render shares — built once, read by each header, skeleton and body
94
+ * site through {@link pinnedCellProps} so none of them can drift. */
95
+ export type PinContext<T extends RowData> = {
96
+ table: TanstackTable<BasaltTableFeatures, T>;
97
+ /** The room the fold toggle column takes ahead of the first start-pinned cell; 0 without one. */
98
+ startOffset: number;
99
+ /** The auto-pinned identifier: content width bounded by `autoPinMinWidth` and the `.pinnedFluid` cap. */
100
+ autoPinId: string | undefined;
101
+ autoPinMinWidth: number | undefined;
102
+ };
103
+ /**
104
+ * The class and inline style of one column's cell when it pins (`{}` when it does not): the opaque
105
+ * sticky base with the row's own tint layered over it (`.pinnedLayer`), the logical inset of its
106
+ * start/end offset (`dir=rtl` mirrors it) and, on the edge cell touching the scrolling center, the
107
+ * hairline shadow (a physical offset, which does not mirror). The auto-pinned column takes its
108
+ * content width, not the fixed `getSize()` — a 150px default would waste a 360px table's room on a
109
+ * short date.
110
+ */
111
+ export declare function pinnedCellProps<T extends RowData>(ctx: PinContext<T>, column: Column<BasaltTableFeatures, T, unknown>): {
112
+ className?: string;
113
+ style?: CSSProperties;
114
+ };
115
+ /** The fold toggle column's cell: one `HIT_COARSE` px wide, and sticky at the start edge — the same
116
+ * base, unit and layer as a pinned column — whenever a start pin follows it. */
117
+ export declare function foldToggleCellProps<T extends RowData>(ctx: PinContext<T>): {
118
+ className: string;
119
+ style: CSSProperties;
120
+ };
121
+ /** A folded column's name for the toggle, the header count and the disclosure row: its own header
122
+ * when that is a non-empty string, else the column id — a function/`ReactNode` header has no header
123
+ * CONTEXT to render with here (this is a body row, not the `<thead>`). */
124
+ export declare function columnLabel<T extends RowData>(column: Column<BasaltTableFeatures, T, unknown>): string;
125
+ /** One row's folded columns as label/value pairs, directly under it. `row.getAllCells()` returns
126
+ * every leaf cell regardless of visibility (unlike `getVisibleCells()`), so a folded column's own
127
+ * `cell` renderer still draws here exactly as it would in the `<td>` it no longer occupies. */
128
+ export declare function RowDisclosure<T extends RowData>({ row, folded, }: {
129
+ row: Row<BasaltTableFeatures, T>;
130
+ folded: ReadonlySet<string>;
131
+ }): ReactNode;
132
+ /** "2 more columns: C, D" — the folded columns, counted and named. */
133
+ export declare function foldedSummary(count: number, label: string): string;
134
+ /** The header cell above the toggles: a micro count of what folded, and a button that NAMES them. The
135
+ * button's accessible name is the one summary (F102 — a hidden column must be announced, not merely
136
+ * reachable); its `title` is the mouse hint, and a tap, Enter or Space opens a popover listing the
137
+ * folded columns, because a touch reader never sees a `title` (the 390 crop read as an unexplained
138
+ * "+3 cols"). The popover closes on outside click and Escape. A bare `+N` read as an unexplained
139
+ * figure at 390, so the word rides with it — in the sans micro face, which keeps "+4 cols" inside
140
+ * the 44px toggle cell (the mono face did not). A second line shows the first folded name, ellipsised to
141
+ * the cell, so the button says what it opens before it is tapped. */
142
+ export declare function FoldHeaderLabel({ names, }: {
143
+ /** The folded columns' headers, in column order. */
144
+ names: readonly string[];
145
+ }): ReactNode;
146
+ /** The per-row expand/collapse control the fold column renders — a ghost chevron whose accessible
147
+ * name says WHAT folded ("Show Volume, Duration"), its 44px hit area carried by the hit overlay
148
+ * (`docs/CONTROLS-SPEC.md` §2; basalt ships no icon set, so the chevron is inline). */
149
+ export declare function FoldToggle({ expanded, controlsId, foldedLabel, onToggle, }: {
150
+ expanded: boolean;
151
+ controlsId: string;
152
+ foldedLabel: string;
153
+ onToggle: () => void;
154
+ }): ReactNode;
155
+ //# sourceMappingURL=data-table-fold.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-table-fold.d.ts","sourceRoot":"","sources":["../../src/table/data-table-fold.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAEV,MAAM,EACN,SAAS,EACT,GAAG,EACH,OAAO,EACP,KAAK,IAAI,aAAa,EACvB,MAAM,uBAAuB,CAAA;AA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IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,aAAa,CAAA;CAAE,CAW7C;AAID;;0EAE0E;AAC1E,wBAAgB,WAAW,CAAC,CAAC,SAAS,OAAO,EAC3C,MAAM,EAAE,MAAM,CAAC,mBAAmB,EAAE,CAAC,EAAE,OAAO,CAAC,GAC9C,MAAM,CAGR;AAED;;+FAE+F;AAC/F,wBAAgB,aAAa,CAAC,CAAC,SAAS,OAAO,EAAE,EAC/C,GAAG,EACH,MAAM,GACP,EAAE;IACD,GAAG,EAAE,GAAG,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAA;IAChC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;CAC5B,GAAG,SAAS,CAgBZ;AAQD,sEAAsE;AACtE,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAElE;AAED;;;;;;;qEAOqE;AACrE,wBAAgB,eAAe,CAAC,EAC9B,KAAK,GACN,EAAE;IACD,oDAAoD;IACpD,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;CACzB,GAAG,SAAS,CA8CZ;AAED;;uFAEuF;AACvF,wBAAgB,UAAU,CAAC,EACzB,QAAQ,EACR,UAAU,EACV,WAAW,EACX,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,OAAO,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,IAAI,CAAA;CACrB,GAAG,SAAS,CA2BZ"}
@@ -0,0 +1,320 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Popover, Text } from "@mantine/core";
3
+ import { useLayoutEffect, useRef, useState } from "react";
4
+ import { HIT_COARSE } from "../common/hit-floor.js";
5
+ import { useMeasuredWidths } from "../common/use-measured-widths.js";
6
+ import { alpha, VX } from "../tokens/index.js";
7
+ import { CellContent } from "./cell-kinds.js";
8
+ import { EMPTY_FOLD_SET } from "./data-table-state.js";
9
+ import classes from "./data-table.module.css";
10
+ function columnDefId(column) {
11
+ if (column.id !== void 0) return column.id;
12
+ return "accessorKey" in column && typeof column.accessorKey === "string" ? column.accessorKey : void 0;
13
+ }
14
+ function foldOrder(columns) {
15
+ return columns.map((column, index) => ({
16
+ id: columnDefId(column),
17
+ priority: column.meta?.priority ?? index,
18
+ index
19
+ })).filter(
20
+ (candidate) => Boolean(candidate.id)
21
+ ).toSorted((a, b) => b.priority - a.priority || b.index - a.index).map((candidate) => candidate.id);
22
+ }
23
+ const FOLD_ID_ATTR = "data-basalt-fold-id";
24
+ const FIXED_ID_ATTR = "data-basalt-fixed-id";
25
+ const FOLD_FLOOR = 2;
26
+ const EMPTY_WIDTHS = /* @__PURE__ */ new Map();
27
+ const PIN_MIN_WIDTH = 120;
28
+ function roundingSlack(measured, fixedCount) {
29
+ return (measured + fixedCount + 1) / 2;
30
+ }
31
+ function planColumnFold(input) {
32
+ const { room, toggleWidth, overhead, fixedCount = 0, extraCount = 0, order, widths } = input;
33
+ const known = order.filter((id) => widths.has(id));
34
+ const slack = roundingSlack(known.length, fixedCount + extraCount);
35
+ let unfolded = overhead + known.reduce((sum, id) => sum + (widths.get(id) ?? 0), 0);
36
+ const folded = /* @__PURE__ */ new Set();
37
+ for (const id of known) {
38
+ if (known.length - folded.size + fixedCount <= FOLD_FLOOR) break;
39
+ const withToggle = unfolded + (folded.size > 0 ? toggleWidth : 0);
40
+ if (withToggle <= room + slack) break;
41
+ folded.add(id);
42
+ unfolded -= widths.get(id) ?? 0;
43
+ }
44
+ return folded;
45
+ }
46
+ function foldOverflows(input) {
47
+ const { room, toggleWidth, overhead, fixedCount, extraCount, order, widths, folded } = input;
48
+ const known = order.filter((id) => widths.has(id));
49
+ const kept = known.filter((id) => !folded.has(id));
50
+ const total = overhead + kept.reduce((sum, id) => sum + (widths.get(id) ?? 0), 0) + (folded.size > 0 ? toggleWidth : 0);
51
+ return total > room + roundingSlack(known.length, fixedCount + extraCount);
52
+ }
53
+ function surfaceBehind(el) {
54
+ for (let node = el; node !== null; node = node.parentElement) {
55
+ const color = getComputedStyle(node).backgroundColor;
56
+ if (color !== "rgba(0, 0, 0, 0)" && color !== "transparent") return color;
57
+ }
58
+ return "";
59
+ }
60
+ function useColumnFold(input) {
61
+ const { active, order, fixedIds, extraIds, pinCandidates, allowPin, headerOnly, renderedRows } = input;
62
+ const wrapperRef = useRef(null);
63
+ const [folded, setFolded] = useState(EMPTY_FOLD_SET);
64
+ const [pinId, setPinId] = useState(void 0);
65
+ const [overflowing, setOverflowing] = useState(false);
66
+ const [measuredWidths, setMeasuredWidths] = useState(EMPTY_WIDTHS);
67
+ const latest = useRef({ order, fixedIds, extraIds, pinCandidates, allowPin, headerOnly });
68
+ const decidedPin = useRef(void 0);
69
+ useLayoutEffect(() => {
70
+ latest.current = { order, fixedIds, extraIds, pinCandidates, allowPin, headerOnly };
71
+ if (!active || order.length === 0) decidedPin.current = void 0;
72
+ });
73
+ if ((!active || order.length === 0) && (folded.size > 0 || pinId !== void 0)) {
74
+ setFolded(EMPTY_FOLD_SET);
75
+ setPinId(void 0);
76
+ setOverflowing(false);
77
+ }
78
+ const { remeasure } = useMeasuredWidths({
79
+ resolveRoot: () => wrapperRef.current,
80
+ signature: `${order.join("|")}::${fixedIds.join("|")}::${extraIds.join("|")}`,
81
+ enabled: active && order.length > 0,
82
+ // The table too, not only the wrapper: a re-measured column set moves its min-content width
83
+ // while the wrapper's own box never changes.
84
+ extra: (root) => [root.querySelector("table")],
85
+ onMeasure: (root, boxes) => {
86
+ const current = latest.current;
87
+ for (const cell of root.querySelectorAll(
88
+ `[${FOLD_ID_ATTR}], [${FIXED_ID_ATTR}]`
89
+ )) {
90
+ const id = cell.getAttribute(FOLD_ID_ATTR) ?? cell.getAttribute(FIXED_ID_ATTR);
91
+ if (id === null || cell.offsetWidth === 0) continue;
92
+ const keepCached = (id === decidedPin.current || current.headerOnly || renderedRows.current === 0) && boxes.current.has(id);
93
+ if (!keepCached)
94
+ boxes.current.set(id, { width: cell.offsetWidth, height: cell.offsetHeight });
95
+ }
96
+ const room = root.clientWidth;
97
+ if (room === 0) return;
98
+ root.style.setProperty("--basalt-table-room", `${room}px`);
99
+ const surface = surfaceBehind(root);
100
+ if (surface !== "") root.style.setProperty("--basalt-table-surface", surface);
101
+ const widths = new Map([...boxes.current].map(([id, box]) => [id, box.width]));
102
+ setMeasuredWidths(
103
+ (prev) => prev.size === widths.size && [...widths].every(([id, width]) => prev.get(id) === width) ? prev : widths
104
+ );
105
+ const overhead = [...current.fixedIds, ...current.extraIds].reduce(
106
+ (sum, id) => sum + (widths.get(id) ?? 0),
107
+ 0
108
+ );
109
+ const plan = {
110
+ room,
111
+ // The disclosure toggle is a fixed icon-button cell matched to the coarse hit floor, so it
112
+ // reads as one more `--vx-hit` control rather than a narrower afterthought.
113
+ toggleWidth: HIT_COARSE,
114
+ overhead,
115
+ fixedCount: current.fixedIds.length,
116
+ extraCount: current.extraIds.length,
117
+ order: current.order,
118
+ widths
119
+ };
120
+ const next = planColumnFold(plan);
121
+ setFolded(
122
+ (prev) => prev.size === next.size && [...prev].every((id) => next.has(id)) ? prev : next
123
+ );
124
+ const nextPin = current.allowPin && foldOverflows({ ...plan, folded: next }) ? current.pinCandidates.find((id) => !next.has(id)) : void 0;
125
+ decidedPin.current = nextPin;
126
+ setPinId(nextPin);
127
+ const table = root.querySelector("table");
128
+ setOverflowing(table !== null && table.offsetWidth > room);
129
+ }
130
+ });
131
+ const remeasureRef = useRef(remeasure);
132
+ useLayoutEffect(() => {
133
+ remeasureRef.current = remeasure;
134
+ });
135
+ useLayoutEffect(() => {
136
+ if (!active || typeof MutationObserver === "undefined") return;
137
+ const root = document.documentElement;
138
+ let scheme = root.getAttribute("data-mantine-color-scheme");
139
+ let frame = 0;
140
+ const observer = new MutationObserver(() => {
141
+ const next = root.getAttribute("data-mantine-color-scheme");
142
+ if (next === scheme) return;
143
+ scheme = next;
144
+ cancelAnimationFrame(frame);
145
+ frame = requestAnimationFrame(() => remeasureRef.current());
146
+ });
147
+ observer.observe(root, { attributes: true, attributeFilter: ["data-mantine-color-scheme"] });
148
+ return () => {
149
+ cancelAnimationFrame(frame);
150
+ observer.disconnect();
151
+ };
152
+ }, [active]);
153
+ return {
154
+ wrapperRef,
155
+ folded: active ? folded : EMPTY_FOLD_SET,
156
+ pinId: active ? pinId : void 0,
157
+ overflowing: active && overflowing,
158
+ widths: measuredWidths
159
+ };
160
+ }
161
+ const STICKY_BASE = {
162
+ position: "sticky",
163
+ zIndex: 1,
164
+ backgroundColor: `var(--basalt-pin-fill, var(--basalt-table-surface, ${VX.surface.panel}))`
165
+ };
166
+ function pinnedCellProps(ctx, column) {
167
+ const pinned = column.getIsPinned();
168
+ if (!pinned) return {};
169
+ const fluid = column.id === ctx.autoPinId && ctx.autoPinMinWidth !== void 0;
170
+ const size = column.getSize();
171
+ const shared = {
172
+ ...STICKY_BASE,
173
+ ...fluid ? { minWidth: ctx.autoPinMinWidth } : { width: size, minWidth: size, maxWidth: size }
174
+ };
175
+ const className = fluid ? `${classes.pinnedLayer} ${classes.pinnedFluid}` : classes.pinnedLayer;
176
+ if (pinned === "start") {
177
+ const isEdge2 = column.getPinnedIndex() === ctx.table.getStartLeafColumns().length - 1;
178
+ return {
179
+ className,
180
+ style: {
181
+ ...shared,
182
+ insetInlineStart: column.getStart("start") + ctx.startOffset,
183
+ boxShadow: isEdge2 ? `4px 0 6px -4px ${alpha(VX.ink, 0.18)}` : void 0
184
+ }
185
+ };
186
+ }
187
+ const isEdge = column.getPinnedIndex() === 0;
188
+ return {
189
+ className,
190
+ style: {
191
+ ...shared,
192
+ insetInlineEnd: column.getAfter("end"),
193
+ boxShadow: isEdge ? `-4px 0 6px -4px ${alpha(VX.ink, 0.18)}` : void 0
194
+ }
195
+ };
196
+ }
197
+ function foldToggleCellProps(ctx) {
198
+ const sticky = ctx.startOffset > 0;
199
+ return {
200
+ className: sticky ? `${classes.foldToggleCell} ${classes.pinnedLayer}` : classes.foldToggleCell,
201
+ style: {
202
+ width: HIT_COARSE,
203
+ minWidth: HIT_COARSE,
204
+ maxWidth: HIT_COARSE,
205
+ ...sticky && { ...STICKY_BASE, insetInlineStart: 0 }
206
+ }
207
+ };
208
+ }
209
+ function columnLabel(column) {
210
+ const header = column.columnDef.header;
211
+ return typeof header === "string" && header.trim() !== "" ? header : column.id;
212
+ }
213
+ function RowDisclosure({
214
+ row,
215
+ folded
216
+ }) {
217
+ const cells = row.getAllCells().filter((cell) => folded.has(cell.column.id));
218
+ return /* @__PURE__ */ jsx("div", { className: classes.foldDisclosure, children: cells.map((cell) => /* @__PURE__ */ jsxs("div", { className: classes.foldDisclosureRow, children: [
219
+ /* @__PURE__ */ jsx(Text, { className: classes.foldDisclosureLabel, children: columnLabel(cell.column) }),
220
+ /* @__PURE__ */ jsx("div", { className: classes.foldDisclosureValue, children: /* @__PURE__ */ jsx(CellContent, { cell }) })
221
+ ] }, cell.id)) });
222
+ }
223
+ function foldNoun(count, short) {
224
+ const noun = short ? "col" : "column";
225
+ return count === 1 ? noun : `${noun}s`;
226
+ }
227
+ function foldedSummary(count, label) {
228
+ return `${count} more ${foldNoun(count, false)}: ${label}`;
229
+ }
230
+ function FoldHeaderLabel({
231
+ names
232
+ }) {
233
+ const [opened, setOpened] = useState(false);
234
+ const count = names.length;
235
+ const summary = foldedSummary(count, names.join(", "));
236
+ const visible = `+${count} ${foldNoun(count, true)}`;
237
+ return /* @__PURE__ */ jsx("span", { className: classes.foldCount, children: /* @__PURE__ */ jsxs(
238
+ Popover,
239
+ {
240
+ opened,
241
+ onChange: setOpened,
242
+ position: "bottom-start",
243
+ withinPortal: true,
244
+ shadow: "md",
245
+ transitionProps: { duration: 0 },
246
+ children: [
247
+ /* @__PURE__ */ jsx(Popover.Target, { children: /* @__PURE__ */ jsxs(
248
+ "button",
249
+ {
250
+ type: "button",
251
+ className: classes.foldCountButton,
252
+ "data-basalt-hit": true,
253
+ title: summary,
254
+ "aria-label": `${visible}, ${summary}`,
255
+ "aria-haspopup": "dialog",
256
+ "aria-expanded": opened,
257
+ onClick: (event) => {
258
+ event.stopPropagation();
259
+ setOpened((open) => !open);
260
+ },
261
+ children: [
262
+ visible,
263
+ /* @__PURE__ */ jsx("span", { className: classes.foldCountHint, "aria-hidden": true, children: names[0] })
264
+ ]
265
+ }
266
+ ) }),
267
+ /* @__PURE__ */ jsx(Popover.Dropdown, { p: "xs", className: classes.foldNames, "aria-label": summary, children: /* @__PURE__ */ jsx("ul", { className: classes.foldNameList, children: names.map((name, index) => /* @__PURE__ */ jsx("li", { children: name }, `${index}-${name}`)) }) })
268
+ ]
269
+ }
270
+ ) });
271
+ }
272
+ function FoldToggle({
273
+ expanded,
274
+ controlsId,
275
+ foldedLabel,
276
+ onToggle
277
+ }) {
278
+ return /* @__PURE__ */ jsx(
279
+ "button",
280
+ {
281
+ type: "button",
282
+ className: classes.foldToggle,
283
+ "data-basalt-hit": true,
284
+ "aria-expanded": expanded,
285
+ "aria-controls": controlsId,
286
+ "aria-label": `${expanded ? "Hide" : "Show"} ${foldedLabel}`,
287
+ onClick: (event) => {
288
+ event.stopPropagation();
289
+ onToggle();
290
+ },
291
+ children: /* @__PURE__ */ jsx(
292
+ "svg",
293
+ {
294
+ className: classes.foldChevron,
295
+ "data-expanded": expanded ? "true" : "false",
296
+ viewBox: "0 0 16 16",
297
+ "aria-hidden": true,
298
+ focusable: "false",
299
+ children: /* @__PURE__ */ jsx("path", { d: "M5.5 3.5 10.5 8l-5 4.5" })
300
+ }
301
+ )
302
+ }
303
+ );
304
+ }
305
+ export {
306
+ FIXED_ID_ATTR,
307
+ FOLD_ID_ATTR,
308
+ FoldHeaderLabel,
309
+ FoldToggle,
310
+ PIN_MIN_WIDTH,
311
+ RowDisclosure,
312
+ columnDefId,
313
+ columnLabel,
314
+ foldOrder,
315
+ foldToggleCellProps,
316
+ foldedSummary,
317
+ pinnedCellProps,
318
+ planColumnFold,
319
+ useColumnFold
320
+ };
@@ -38,6 +38,7 @@ export type DataTableStateProps = {
38
38
  onSortingChange?: ((sorting: SortingState) => void) | undefined;
39
39
  initialGlobalFilter?: string | undefined;
40
40
  onGlobalFilterChange?: ((value: string) => void) | undefined;
41
+ initialColumnFilters?: ColumnFiltersState | undefined;
41
42
  onColumnFiltersChange?: ((filters: ColumnFiltersState) => void) | undefined;
42
43
  initialPagination?: PaginationState | undefined;
43
44
  onPaginationChange?: ((pagination: PaginationState) => void) | undefined;
@@ -62,10 +63,16 @@ export declare function useDataTableState(props: DataTableStateProps, defaultPag
62
63
  rowSelection: RowSelectionState;
63
64
  onRowSelectionChange: (updater: Updater<RowSelectionState>) => void;
64
65
  };
66
+ /** Whether an element's own width is below `px`, measured on a ResizeObserver — never the viewport.
67
+ * A zero width is an un-laid-out ancestor, not a narrow one, so it moves nothing; the default (and
68
+ * the SSR answer) is `false`. */
69
+ export declare function useNarrowerThan(px: number, enabled: boolean): {
70
+ ref: RefObject<HTMLDivElement | null>;
71
+ narrow: boolean;
72
+ };
65
73
  /** Whether the table renders as `renderCard` projections: its own root measured below the `regular`
66
- * container class. A zero width is an un-laid-out ancestor, not a narrow table, so it moves nothing
67
- * — the default (and the SSR answer) is the table. The root's width never depends on which body it
68
- * holds, so the swap cannot oscillate. */
74
+ * container class. The root's width never depends on which body it holds, so the swap cannot
75
+ * oscillate. */
69
76
  export declare function useCardProjection(enabled: boolean): {
70
77
  rootRef: RefObject<HTMLDivElement | null>;
71
78
  cards: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"data-table-state.d.ts","sourceRoot":"","sources":["../../src/table/data-table-state.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EACV,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,OAAO,EACR,MAAM,uBAAuB,CAAA;AAE9B,OAAO,KAAK,EAAE,aAAa,IAAI,kBAAkB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAM3E,eA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,OAAO,EAAE,OAAO,GACf;IAAE,GAAG,EAAE,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CAc5D;AAED;;gBAEgB;AAChB,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG;IACnD,OAAO,EAAE,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAA;IACzC,KAAK,EAAE,OAAO,CAAA;CACf,CAGA;AAED;;2DAE2D;AAC3D,wBAAgB,eAAe,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,KAAK,IAAI,CAAC,GAAG,SAAS,EAAE,GAAG,EAAE,CAAC;;;;;uBAOjE,kBAAkB,CAAC,WAAW,CAAC;cAUrD"}
@@ -60,7 +60,7 @@ function useDataTableState(props, defaultPageSize) {
60
60
  props.onGlobalFilterChange
61
61
  );
62
62
  const [columnFilters, onColumnFiltersChange] = useReportedState(
63
- [],
63
+ props.initialColumnFilters ?? [],
64
64
  props.onColumnFiltersChange
65
65
  );
66
66
  const [pagination, onPaginationChange] = useReportedState(
@@ -101,20 +101,24 @@ function useDataTableState(props, defaultPageSize) {
101
101
  onRowSelectionChange: handleRowSelectionChange
102
102
  };
103
103
  }
104
- function useCardProjection(enabled) {
105
- const rootRef = useRef(null);
104
+ function useNarrowerThan(px, enabled) {
105
+ const ref = useRef(null);
106
106
  const [narrow, setNarrow] = useState(false);
107
107
  useMeasuredWidths({
108
- resolveRoot: () => rootRef.current,
108
+ resolveRoot: () => ref.current,
109
109
  signature: "",
110
110
  enabled,
111
111
  onMeasure: (root) => {
112
112
  if (root.clientWidth === 0) return;
113
- const next = root.clientWidth < CONTAINER_CLASSES.regular;
113
+ const next = root.clientWidth < px;
114
114
  setNarrow((current) => current === next ? current : next);
115
115
  }
116
116
  });
117
- return { rootRef, cards: enabled && narrow };
117
+ return { ref, narrow: enabled && narrow };
118
+ }
119
+ function useCardProjection(enabled) {
120
+ const { ref, narrow } = useNarrowerThan(CONTAINER_CLASSES.regular, enabled);
121
+ return { rootRef: ref, cards: narrow };
118
122
  }
119
123
  function activationProps(onRowActivate, row) {
120
124
  if (onRowActivate === void 0) return void 0;
@@ -136,5 +140,6 @@ export {
136
140
  activationProps,
137
141
  useCardProjection,
138
142
  useDataTableState,
143
+ useNarrowerThan,
139
144
  useRowDisclosure
140
145
  };
@@ -1,9 +1,10 @@
1
1
  import type { MantineSpacing } from '@mantine/core';
2
2
  import type { ColumnFiltersState, PaginationState, RowData, RowSelectionState, SortingState } from '@tanstack/react-table';
3
3
  import type { ReactNode } from 'react';
4
- import type { BasaltProps, SlotStylesProps } from '../common/props.js';
4
+ import type { BasaltProps, DataAttributes, SlotStylesProps } from '../common/props.js';
5
5
  import type { BarAction, SlotActions } from '../controls/actions.js';
6
6
  import type { QueryStateLike } from '../dashboard/query-state.js';
7
+ export { planColumnFold } from './data-table-fold.js';
7
8
  import type { BasaltColumnDef } from './table-features.js';
8
9
  /** A single selectable option inside a {@link DataTableFacet}'s `EnumFilter`/`MultiSelectFilter` pill. */
9
10
  export type DataTableFacetOption = {
@@ -84,7 +85,7 @@ export type BasaltDataTableSlot = 'root' | 'toolbar' | 'table' | 'footer';
84
85
  * emptyState: <Text c="dimmed">No results found.</Text>,
85
86
  * }
86
87
  */
87
- export type BasaltDataTableProps<T extends RowData> = BasaltProps & SlotStylesProps<BasaltDataTableSlot> & {
88
+ export type BasaltDataTableProps<T extends RowData> = BasaltProps & DataAttributes & SlotStylesProps<BasaltDataTableSlot> & {
88
89
  /**
89
90
  * Optional heading rendered above the toolbar via `WidgetHeader tier="widget"`. The count tag
90
91
  * beside it is automatic, not a prop (there is no `count`): it reads `table.getRowCount()` (C11)
@@ -134,7 +135,8 @@ export type BasaltDataTableProps<T extends RowData> = BasaltProps & SlotStylesPr
134
135
  manualSorting?: boolean;
135
136
  /** Stripe alternate rows. Forwarded to Mantine `Table` — `'odd'`/`'even'` pick the phase. */
136
137
  striped?: boolean | 'odd' | 'even';
137
- /** Highlight hovered rows. Forwarded to Mantine `Table`. */
138
+ /** Highlight hovered rows with `VX.surface.rowHover` on a fine pointer. Forwarded to Mantine `Table`.
139
+ * @default true */
138
140
  highlightOnHover?: boolean;
139
141
  /**
140
142
  * Rendered when no rows are VISIBLE — `data` is empty, or a filter/page matches none of it.
@@ -170,7 +172,9 @@ export type BasaltDataTableProps<T extends RowData> = BasaltProps & SlotStylesPr
170
172
  */
171
173
  query?: QueryStateLike<unknown>;
172
174
  /**
173
- * Number of skeleton rows to render when `isLoading` is true.
175
+ * Number of skeleton rows to render when `isLoading` is true and neither a page size nor an
176
+ * earlier load says better: a paginated table loads at its page size, any other at the row
177
+ * count it last showed.
174
178
  * @default 5
175
179
  */
176
180
  skeletonRows?: number;
@@ -211,6 +215,11 @@ export type BasaltDataTableProps<T extends RowData> = BasaltProps & SlotStylesPr
211
215
  * restoring the search term from a URL search param.
212
216
  */
213
217
  initialGlobalFilter?: string;
218
+ /**
219
+ * Initial facet filters — `[{ id: 'department', value: 'Engineering' }]` opens the table with
220
+ * that facet preset. Uncontrolled, like `initialSorting`; `onColumnFiltersChange` reports edits.
221
+ */
222
+ initialColumnFilters?: ColumnFiltersState;
214
223
  /** Called whenever the internal global filter value changes. */
215
224
  onGlobalFilterChange?: (value: string) => void;
216
225
  /**
@@ -500,30 +509,6 @@ export type BasaltDataTableProps<T extends RowData> = BasaltProps & SlotStylesPr
500
509
  */
501
510
  withTableBorder?: boolean;
502
511
  };
503
- /**
504
- * Pure decision: fold columns off the FRONT of `order` (already fold-first sorted) until the
505
- * still-unfolded ones — plus `overhead` (the columns excluded from candidacy altogether — pinned,
506
- * or `enableHiding: false` — which occupy room but can never fold) and the disclosure toggle's own
507
- * width, once anything is folded — fit `room`. A candidate with no measured width yet (never
508
- * rendered) is skipped rather than folded blind, since folding it would remove the one place its
509
- * width could ever be read from.
510
- *
511
- * Every width is a rounded integer (`offsetWidth`, `clientWidth`), and a table that fills its
512
- * wrapper stretches its columns to sum to `room` exactly — so the rounded sum lands up to half a
513
- * pixel per column over it, and a table that fits folded a column on hydration (a server-painted
514
- * table whose cells then moved). The fit check forgives that rounding and nothing more: half a
515
- * pixel for each measured width (the foldable columns AND `fixedCount`, the pinned / non-hiding
516
- * ones `overhead` sums), plus half a pixel for `room`'s own rounding (the `+ 1` in the slack).
517
- */
518
- export declare function planColumnFold(input: {
519
- room: number;
520
- toggleWidth: number;
521
- overhead: number;
522
- /** How many columns `overhead` sums, for the rounding slack. */
523
- fixedCount?: number;
524
- order: readonly string[];
525
- widths: ReadonlyMap<string, number>;
526
- }): ReadonlySet<string>;
527
512
  /**
528
513
  * A sortable data table backed by TanStack Table and rendered with Mantine primitives.
529
514
  * Generic over `T` — column types are inferred from `ColumnDef<T>`.