@krizaka/ui 3.74.0 → 3.76.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 (286) hide show
  1. package/README.md +2 -6
  2. package/dist/blocks.css +2 -0
  3. package/dist/{chunk-GSQRSWOE.js → chunk-CEW3LQOZ.js} +520 -429
  4. package/dist/chunk-CEW3LQOZ.js.map +1 -0
  5. package/dist/{chunk-E4FMPPDL.js → chunk-WC3SO4CE.js} +2 -2
  6. package/dist/{chunk-KF7UB3LM.js → chunk-YQWYGQTV.js} +11 -9
  7. package/dist/{chunk-KF7UB3LM.js.map → chunk-YQWYGQTV.js.map} +1 -1
  8. package/dist/{chunk-M3GEYLMR.js → chunk-ZPOVOEO3.js} +1 -2
  9. package/dist/data-table.d.ts +1 -1
  10. package/dist/data-table.js +3 -3
  11. package/dist/filter-bar.d.ts +12 -4
  12. package/dist/filter-bar.js +1 -1
  13. package/dist/gallery-page.js +3 -3
  14. package/dist/genui.js +101 -35
  15. package/dist/genui.js.map +1 -1
  16. package/dist/language-switch.d.ts +9 -9
  17. package/dist/{lightbox-D5NAHFEA.js → lightbox-Q45BZ3HW.js} +3 -3
  18. package/dist/match-dialog.js +2 -2
  19. package/dist/motion.css +1 -25
  20. package/dist/native/list.js +1 -1
  21. package/dist/native/list.js.map +1 -1
  22. package/dist/native.d.ts +2 -54
  23. package/dist/native.js +464 -560
  24. package/dist/native.js.map +1 -1
  25. package/dist/nav-bar.js +1 -1
  26. package/dist/nav-bar.js.map +1 -1
  27. package/dist/product-page.js +3 -3
  28. package/dist/shop-gallery.js +1 -1
  29. package/dist/tag-selector.js +16 -10
  30. package/dist/tag-selector.js.map +1 -1
  31. package/dist/theme.d.ts +3 -1
  32. package/dist/theme.js +2 -1
  33. package/dist/theme.js.map +1 -1
  34. package/dist/vertical-video.js +1 -1
  35. package/dist/waveform.js.map +1 -1
  36. package/package.json +8 -84
  37. package/registry/account-menu.json +1 -1
  38. package/registry/account-settings.json +1 -1
  39. package/registry/achievement.json +1 -1
  40. package/registry/action-bar.json +1 -1
  41. package/registry/activity-feed.json +1 -1
  42. package/registry/agenda.json +1 -1
  43. package/registry/alert.json +1 -1
  44. package/registry/analysis-report.json +1 -1
  45. package/registry/anatomy-plate.json +1 -1
  46. package/registry/app-frame.json +2 -2
  47. package/registry/app-header.json +1 -1
  48. package/registry/app-shell.json +1 -1
  49. package/registry/argument-card.json +1 -1
  50. package/registry/auth-layout.json +1 -1
  51. package/registry/avatar.json +1 -1
  52. package/registry/badge.json +1 -1
  53. package/registry/bird-plate.json +1 -1
  54. package/registry/button.json +1 -1
  55. package/registry/captcha.json +1 -1
  56. package/registry/card-grid.json +1 -1
  57. package/registry/card.json +1 -1
  58. package/registry/catalogue-page.json +1 -1
  59. package/registry/changelog-page.json +1 -1
  60. package/registry/chapter.json +1 -1
  61. package/registry/chat.json +3 -3
  62. package/registry/checkbox.json +1 -1
  63. package/registry/chip-link.json +1 -1
  64. package/registry/chip-row.json +1 -1
  65. package/registry/chip.json +1 -1
  66. package/registry/choice-grid.json +1 -1
  67. package/registry/code-block.json +1 -1
  68. package/registry/collection-switcher.json +1 -1
  69. package/registry/combobox.json +1 -1
  70. package/registry/command.json +1 -1
  71. package/registry/comparison-table.json +1 -1
  72. package/registry/component-page.json +1 -1
  73. package/registry/confirm-button.json +1 -1
  74. package/registry/contact-page.json +1 -1
  75. package/registry/continue-prompt.json +1 -1
  76. package/registry/copy-button.json +1 -1
  77. package/registry/countdown.json +1 -1
  78. package/registry/cover-hero.json +1 -1
  79. package/registry/cta-panel.json +1 -1
  80. package/registry/dashboard-layout.json +1 -1
  81. package/registry/data-table.json +20 -20
  82. package/registry/date-picker.json +1 -1
  83. package/registry/decision-list.json +1 -1
  84. package/registry/description-list.json +1 -1
  85. package/registry/desktop-window.json +1 -1
  86. package/registry/detail-layout.json +1 -1
  87. package/registry/dialog.json +1 -1
  88. package/registry/docs-article-page.json +1 -1
  89. package/registry/docs-hub-page.json +1 -1
  90. package/registry/docs-layout.json +1 -1
  91. package/registry/docs-nav.json +1 -1
  92. package/registry/document-viewer.json +1 -1
  93. package/registry/doodle.json +1 -1
  94. package/registry/drop-overlay.json +1 -1
  95. package/registry/dropdown-menu.json +1 -1
  96. package/registry/elephant.json +1 -1
  97. package/registry/embed-facade.json +1 -1
  98. package/registry/empty-state.json +1 -1
  99. package/registry/engine-flow.json +1 -1
  100. package/registry/entity-header.json +1 -1
  101. package/registry/environment-notice.json +1 -1
  102. package/registry/error-page.json +1 -1
  103. package/registry/field.json +1 -1
  104. package/registry/file-upload.json +1 -1
  105. package/registry/filter-bar.json +2 -2
  106. package/registry/flock.json +1 -1
  107. package/registry/footnote.json +1 -1
  108. package/registry/force-update-screen.json +1 -1
  109. package/registry/form.json +1 -1
  110. package/registry/gallery-page.json +1 -1
  111. package/registry/genui.json +1 -1
  112. package/registry/glossary-term.json +1 -1
  113. package/registry/glossary.json +1 -1
  114. package/registry/glow-card.json +1 -1
  115. package/registry/goal-gauge.json +1 -1
  116. package/registry/grade-stamp.json +1 -1
  117. package/registry/image-cropper.json +1 -1
  118. package/registry/index.json +10 -185
  119. package/registry/kanban.json +1 -1
  120. package/registry/kbd.json +1 -1
  121. package/registry/kind-config-editor.json +1 -1
  122. package/registry/kpi-explained.json +1 -1
  123. package/registry/landing-page.json +1 -1
  124. package/registry/landscape.json +1 -1
  125. package/registry/language-switch.json +1 -1
  126. package/registry/legal-page.json +1 -1
  127. package/registry/link-card.json +1 -1
  128. package/registry/list.json +1 -1
  129. package/registry/loader.json +1 -1
  130. package/registry/longform-page.json +1 -1
  131. package/registry/maintenance-screen.json +1 -1
  132. package/registry/map.json +2 -2
  133. package/registry/margin-layout.json +1 -1
  134. package/registry/markdown.json +1 -1
  135. package/registry/marketing-layout.json +1 -1
  136. package/registry/mascot-quote.json +1 -1
  137. package/registry/mascot-state.json +1 -1
  138. package/registry/mascots.json +1 -1
  139. package/registry/match-dialog.json +1 -1
  140. package/registry/media-capture.json +1 -1
  141. package/registry/media-gallery.json +3 -14
  142. package/registry/meter.json +1 -1
  143. package/registry/money-input.json +1 -1
  144. package/registry/nav-bar.json +3 -3
  145. package/registry/next-actions.json +1 -1
  146. package/registry/notification-preferences.json +1 -1
  147. package/registry/number-ticker.json +1 -1
  148. package/registry/opening-hours.json +1 -1
  149. package/registry/page-header.json +1 -1
  150. package/registry/page-hero.json +1 -1
  151. package/registry/page-index.json +1 -1
  152. package/registry/page.json +1 -1
  153. package/registry/pagination.json +1 -1
  154. package/registry/pointer-light.json +1 -1
  155. package/registry/popover.json +1 -1
  156. package/registry/price-catalogue-editor.json +1 -1
  157. package/registry/pricing-page.json +1 -1
  158. package/registry/product-page.json +2 -6
  159. package/registry/profile-card.json +1 -1
  160. package/registry/progress.json +1 -1
  161. package/registry/promise-card.json +1 -1
  162. package/registry/promo-code-field.json +1 -1
  163. package/registry/proposal.json +1 -1
  164. package/registry/qr-code.json +1 -1
  165. package/registry/quota-meter.json +1 -1
  166. package/registry/radio-group.json +1 -1
  167. package/registry/rail-nav.json +2 -2
  168. package/registry/recipes.json +1 -1
  169. package/registry/retro-tv.json +2 -3
  170. package/registry/reviews.json +1 -1
  171. package/registry/router.json +1 -1
  172. package/registry/schema-form.json +1 -1
  173. package/registry/scroll-stage.json +1 -1
  174. package/registry/search-field.json +1 -1
  175. package/registry/section-backdrop.json +1 -1
  176. package/registry/separator.json +1 -1
  177. package/registry/service-card.json +1 -1
  178. package/registry/settings-layout.json +1 -1
  179. package/registry/shop-composer.json +1 -1
  180. package/registry/shop-gallery.json +3 -8
  181. package/registry/shop.json +2 -2
  182. package/registry/showcase.json +2 -7
  183. package/registry/signature.json +1 -1
  184. package/registry/site-cahier.json +1 -1
  185. package/registry/site-footer.json +2 -2
  186. package/registry/sites.json +1 -1
  187. package/registry/skeleton.json +1 -1
  188. package/registry/skip-link.json +1 -1
  189. package/registry/slider.json +1 -1
  190. package/registry/slot-picker.json +1 -1
  191. package/registry/slot.json +1 -1
  192. package/registry/specimen-tag.json +1 -1
  193. package/registry/speed-lines.json +1 -1
  194. package/registry/spinner.json +1 -1
  195. package/registry/split-view.json +1 -1
  196. package/registry/stage-banner.json +1 -1
  197. package/registry/stat.json +1 -1
  198. package/registry/status-chip.json +1 -1
  199. package/registry/status-page.json +1 -1
  200. package/registry/step-progress.json +1 -1
  201. package/registry/step-showcase.json +1 -1
  202. package/registry/stepper.json +1 -1
  203. package/registry/sticky-action.json +1 -1
  204. package/registry/stuck.json +1 -1
  205. package/registry/swipe-deck.json +3 -4
  206. package/registry/switch.json +1 -1
  207. package/registry/tabs.json +1 -1
  208. package/registry/tag-input.json +1 -1
  209. package/registry/tag-selector.json +2 -2
  210. package/registry/taped-photo.json +1 -1
  211. package/registry/terminal-replay.json +1 -1
  212. package/registry/text-style.json +1 -1
  213. package/registry/theme.json +4 -4
  214. package/registry/toast.json +1 -1
  215. package/registry/toc.json +1 -1
  216. package/registry/tooltip.json +1 -1
  217. package/registry/tree-view.json +1 -1
  218. package/registry/update-prompt.json +1 -1
  219. package/registry/upload-queue.json +1 -1
  220. package/registry/usage.json +1 -1
  221. package/registry/verified-badge.json +1 -1
  222. package/registry/versus-card.json +1 -1
  223. package/registry/vertical-video.json +2 -6
  224. package/registry/video-player.json +2 -7
  225. package/registry/video-trimmer.json +3 -4
  226. package/registry/virtual.json +1 -1
  227. package/registry/wall.json +3 -9
  228. package/registry/waveform.json +4 -9
  229. package/dist/audio-player.d.ts +0 -115
  230. package/dist/audio-player.js +0 -211
  231. package/dist/audio-player.js.map +0 -1
  232. package/dist/chunk-GSQRSWOE.js.map +0 -1
  233. package/dist/chunk-YKOLME7R.js +0 -126
  234. package/dist/chunk-YKOLME7R.js.map +0 -1
  235. package/dist/how-it-works-page.d.ts +0 -49
  236. package/dist/how-it-works-page.js +0 -28
  237. package/dist/how-it-works-page.js.map +0 -1
  238. package/dist/marquee.d.ts +0 -34
  239. package/dist/marquee.js +0 -52
  240. package/dist/marquee.js.map +0 -1
  241. package/dist/media-grid.d.ts +0 -246
  242. package/dist/media-grid.js +0 -468
  243. package/dist/media-grid.js.map +0 -1
  244. package/dist/photo-grid.d.ts +0 -123
  245. package/dist/photo-grid.js +0 -94
  246. package/dist/photo-grid.js.map +0 -1
  247. package/registry/audio-player.json +0 -300
  248. package/registry/examples/audio-player/podcast.d.ts +0 -4
  249. package/registry/examples/audio-player/podcast.js +0 -22
  250. package/registry/examples/audio-player/podcast.tsx +0 -19
  251. package/registry/examples/audio-player/voice-note.d.ts +0 -4
  252. package/registry/examples/audio-player/voice-note.js +0 -12
  253. package/registry/examples/audio-player/voice-note.tsx +0 -12
  254. package/registry/examples/how-it-works-page/orazaka.d.ts +0 -4
  255. package/registry/examples/how-it-works-page/orazaka.js +0 -30
  256. package/registry/examples/how-it-works-page/orazaka.tsx +0 -26
  257. package/registry/examples/marquee/cards.d.ts +0 -4
  258. package/registry/examples/marquee/cards.js +0 -23
  259. package/registry/examples/marquee/cards.tsx +0 -21
  260. package/registry/examples/marquee/logos.d.ts +0 -4
  261. package/registry/examples/marquee/logos.js +0 -12
  262. package/registry/examples/marquee/logos.tsx +0 -17
  263. package/registry/examples/media-grid/feed.d.ts +0 -4
  264. package/registry/examples/media-grid/feed.js +0 -31
  265. package/registry/examples/media-grid/feed.tsx +0 -30
  266. package/registry/examples/media-grid/loading.d.ts +0 -4
  267. package/registry/examples/media-grid/loading.js +0 -28
  268. package/registry/examples/media-grid/loading.tsx +0 -25
  269. package/registry/examples/media-grid/uniform.d.ts +0 -4
  270. package/registry/examples/media-grid/uniform.js +0 -29
  271. package/registry/examples/media-grid/uniform.tsx +0 -26
  272. package/registry/examples/photo-grid/native/profile-photos.d.ts +0 -4
  273. package/registry/examples/photo-grid/native/profile-photos.dark.png +0 -0
  274. package/registry/examples/photo-grid/native/profile-photos.js +0 -27
  275. package/registry/examples/photo-grid/native/profile-photos.light.png +0 -0
  276. package/registry/examples/photo-grid/native/profile-photos.tsx +0 -24
  277. package/registry/examples/photo-grid/profile-photos.d.ts +0 -4
  278. package/registry/examples/photo-grid/profile-photos.js +0 -28
  279. package/registry/examples/photo-grid/profile-photos.tsx +0 -25
  280. package/registry/how-it-works-page.json +0 -258
  281. package/registry/marquee.json +0 -241
  282. package/registry/media-grid.json +0 -1034
  283. package/registry/photo-grid.json +0 -316
  284. /package/dist/{chunk-E4FMPPDL.js.map → chunk-WC3SO4CE.js.map} +0 -0
  285. /package/dist/{chunk-M3GEYLMR.js.map → chunk-ZPOVOEO3.js.map} +0 -0
  286. /package/dist/{lightbox-D5NAHFEA.js.map → lightbox-Q45BZ3HW.js.map} +0 -0
@@ -164,35 +164,35 @@
164
164
  {
165
165
  "name": "defaultColumnVisibility",
166
166
  "type": "Readonly<Record<string, boolean>>",
167
- "default": "{}",
167
+ "default": null,
168
168
  "description": "The visibility at first, uncontrolled.",
169
169
  "required": false
170
170
  },
171
171
  {
172
172
  "name": "defaultExpanded",
173
173
  "type": "Readonly<Record<string, boolean>>",
174
- "default": "{}",
174
+ "default": null,
175
175
  "description": "The opened rows at first, uncontrolled.",
176
176
  "required": false
177
177
  },
178
178
  {
179
179
  "name": "defaultFilters",
180
180
  "type": "Readonly<Record<string, FilterValue>>",
181
- "default": "{}",
181
+ "default": null,
182
182
  "description": "The filters at first, uncontrolled.",
183
183
  "required": false
184
184
  },
185
185
  {
186
186
  "name": "defaultGroupBy",
187
187
  "type": "readonly string[]",
188
- "default": "[]",
188
+ "default": null,
189
189
  "description": "The grouping at first, uncontrolled.",
190
190
  "required": false
191
191
  },
192
192
  {
193
193
  "name": "defaultPage",
194
194
  "type": "number",
195
- "default": "1",
195
+ "default": null,
196
196
  "description": "The page at first, uncontrolled. Default 1.",
197
197
  "required": false
198
198
  },
@@ -206,14 +206,14 @@
206
206
  {
207
207
  "name": "defaultSelected",
208
208
  "type": "readonly string[]",
209
- "default": "[]",
209
+ "default": null,
210
210
  "description": "The ids selected at first, uncontrolled.",
211
211
  "required": false
212
212
  },
213
213
  {
214
214
  "name": "defaultSort",
215
215
  "type": "DataTableSort",
216
- "default": "null",
216
+ "default": null,
217
217
  "description": "The sort at first, uncontrolled.",
218
218
  "required": false
219
219
  },
@@ -283,7 +283,7 @@
283
283
  {
284
284
  "name": "layout",
285
285
  "type": "\"table\" | \"auto\" | \"cards\"",
286
- "default": "auto",
286
+ "default": null,
287
287
  "description": "`auto` (default): a table, cards below 36rem of container width. `table` or `cards` to force one.",
288
288
  "required": false
289
289
  },
@@ -297,7 +297,7 @@
297
297
  {
298
298
  "name": "loadingRows",
299
299
  "type": "number",
300
- "default": "5",
300
+ "default": null,
301
301
  "description": "How many skeleton rows while loading. Default 5.",
302
302
  "required": false
303
303
  },
@@ -791,7 +791,7 @@
791
791
  },
792
792
  {
793
793
  "path": "data-table/data-table.tsx",
794
- "content": "// Client (the table's state, the windowing of long lists). A real `<table>` with a caption and column headers\n// (`scope=\"col\"`, `aria-sort` on the sorted one) that turns into a stack of cards in a narrow container — one DOM, the\n// roles written out so that the change of `display` never loses the table's semantics. The engine is TanStack Table v9\n// (engine.ts): sorting, filters and facets, grouping, expanding, pagination, selection, visibility, pinning, resizing —\n// in the browser, or on the server (`manual` + `onStateChange`). Long lists render by what is in view (`virtualized`).\nimport { useTable } from \"@tanstack/react-table\";\nimport * as React from \"react\";\nimport { tv } from \"tailwind-variants\";\n\nimport { Checkbox } from \"../checkbox\";\nimport { cn } from \"../cn\";\nimport { ChevronGlyph, SortGlyph } from \"../glyphs\";\nimport { useControllable } from \"../media\";\nimport { Pagination, type PaginationLabels } from \"../pagination\";\nimport { useLayoutFallbacks, useVirtualizer } from \"../virtual/virtual\";\nimport {\n type CellValue,\n type ColumnDef,\n type ColumnResizingState,\n type DataTableFilterState,\n type DataTableInstance,\n features,\n FILTERS,\n type FilterValue,\n type RowData,\n sortByValue,\n type TableCell,\n type TableColumn,\n type TableRow,\n} from \"./engine\";\nimport { SelectionBar, type SelectionBarLabels } from \"./selection-bar\";\nimport { useRouteTable } from \"./use-route-table\";\n\nexport const dataTable = tv({\n slots: {\n root: \"@container w-full overflow-clip rounded-xl border border-border-default bg-surface-1\",\n toolbar: \"border-b border-border-default p-3\",\n scroller: \"w-full overflow-x-auto\",\n table: \"w-full border-collapse text-left text-sm text-fg\",\n caption: \"px-4 pt-4 pb-2 text-left text-sm font-semibold text-fg\",\n thead: \"bg-surface-2/60\",\n headRow: \"border-b border-border-default\",\n th: \"relative whitespace-nowrap px-4 py-3 text-xs font-semibold text-fg-secondary\",\n sortButton:\n \"-mx-1.5 inline-flex items-center gap-1 rounded-md px-1.5 py-1 hover:bg-surface-3 hover:text-fg \" +\n \"focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring aria-[pressed=true]:text-fg\",\n resizer:\n \"absolute top-0 right-0 h-full w-1.5 cursor-col-resize touch-none select-none bg-transparent hover:bg-border-strong \" +\n \"focus-visible:bg-accent focus-visible:outline-hidden data-[resizing]:bg-accent\",\n tbody: \"\",\n tr: \"border-b border-border-subtle transition-colors last:border-b-0 hover:bg-surface-2/50 data-[state=selected]:bg-accent-soft\",\n groupRow: \"bg-surface-2/40 font-semibold\",\n td: \"px-4 py-3 align-middle\",\n select: \"w-10\",\n expander: \"w-10\",\n toggle:\n \"inline-flex h-7 min-w-7 items-center justify-center gap-1.5 rounded-md text-fg-secondary hover:bg-surface-3 hover:text-fg \" +\n \"focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring [&[aria-expanded=true]>svg]:rotate-90 [&>svg]:transition-transform motion-reduce:[&>svg]:transition-none\",\n detail: \"bg-surface-0 px-4 py-4\",\n message: \"px-4 py-10 text-center text-sm text-fg-secondary\",\n skeleton: \"h-4 w-full max-w-40 animate-pulse rounded bg-surface-3 motion-reduce:animate-none\",\n footer: \"border-t border-border-default px-4 py-3\",\n },\n variants: {\n layout: {\n table: {\n th: \"data-[pin]:sticky data-[pin]:z-[2] data-[pin]:bg-surface-2 data-[pin=start]:left-(--dt-pin) data-[pin=end]:right-(--dt-pin)\",\n td: \"data-[pin]:sticky data-[pin]:z-[1] data-[pin]:bg-surface-1 data-[pin=start]:left-(--dt-pin) data-[pin=end]:right-(--dt-pin)\",\n },\n // Below 36rem of container: cards. The sortable headers stay, as a row of sort buttons above the cards.\n auto: {\n table: \"@max-xl:block\",\n caption: \"@max-xl:block\",\n thead: \"@max-xl:sr-only @max-xl:bg-transparent @max-xl:has-[[data-keep]]:not-sr-only @max-xl:has-[[data-keep]]:block\",\n headRow: \"@max-xl:flex @max-xl:flex-wrap @max-xl:items-center @max-xl:gap-2 @max-xl:px-3 @max-xl:py-2\",\n th:\n \"@max-xl:sr-only @max-xl:data-[keep]:not-sr-only @max-xl:data-[keep]:block @max-xl:p-0 \" +\n \"@xl:data-[pin]:sticky @xl:data-[pin]:z-[2] @xl:data-[pin]:bg-surface-2 @xl:data-[pin=start]:left-(--dt-pin) @xl:data-[pin=end]:right-(--dt-pin)\",\n tbody: \"@max-xl:grid @max-xl:gap-3 @max-xl:p-3\",\n tr: \"@max-xl:relative @max-xl:grid @max-xl:gap-1.5 @max-xl:rounded-xl @max-xl:border @max-xl:border-border-default @max-xl:bg-surface-0 @max-xl:p-4 @max-xl:last:border-b\",\n td:\n \"@max-xl:flex @max-xl:min-w-0 @max-xl:items-baseline @max-xl:justify-between @max-xl:gap-4 @max-xl:p-0 @max-xl:text-right @max-xl:[overflow-wrap:anywhere] \" +\n \"@max-xl:[&>*]:min-w-0 @max-xl:[&>*]:shrink @max-xl:[&>*]:whitespace-normal \" +\n \"@max-xl:before:shrink-0 @max-xl:before:text-xs @max-xl:before:font-semibold @max-xl:before:text-fg-secondary @max-xl:before:content-[attr(data-label)] \" +\n \"@max-xl:data-[card=title]:order-first @max-xl:data-[card=title]:pr-8 @max-xl:data-[card=title]:text-left @max-xl:data-[card=title]:text-base @max-xl:data-[card=title]:font-semibold @max-xl:data-[card=title]:before:content-none \" +\n \"@max-xl:data-[card=hidden]:hidden @max-xl:data-[card=message]:block @max-xl:data-[card=message]:text-center @max-xl:data-[card=message]:before:content-none \" +\n \"@xl:data-[pin]:sticky @xl:data-[pin]:z-[1] @xl:data-[pin]:bg-surface-1 @xl:data-[pin=start]:left-(--dt-pin) @xl:data-[pin=end]:right-(--dt-pin)\",\n select: \"@max-xl:absolute @max-xl:right-3 @max-xl:top-3 @max-xl:w-auto @max-xl:before:content-none\",\n expander: \"@max-xl:before:content-none\",\n },\n cards: {\n table: \"block\",\n caption: \"block\",\n thead: \"sr-only bg-transparent has-[[data-keep]]:not-sr-only has-[[data-keep]]:block\",\n headRow: \"flex flex-wrap items-center gap-2 px-3 py-2\",\n th: \"sr-only p-0 data-[keep]:not-sr-only data-[keep]:block\",\n tbody: \"grid gap-3 p-3\",\n tr: \"relative grid gap-1.5 rounded-xl border border-border-default bg-surface-0 p-4 last:border-b\",\n td:\n \"flex min-w-0 items-baseline justify-between gap-4 p-0 text-right [overflow-wrap:anywhere] before:shrink-0 before:text-xs before:font-semibold before:text-fg-secondary before:content-[attr(data-label)] \" +\n \"[&>*]:min-w-0 [&>*]:shrink [&>*]:whitespace-normal \" +\n \"data-[card=title]:order-first data-[card=title]:pr-8 data-[card=title]:text-left data-[card=title]:text-base data-[card=title]:font-semibold data-[card=title]:before:content-none \" +\n \"data-[card=hidden]:hidden data-[card=message]:block data-[card=message]:text-center data-[card=message]:before:content-none\",\n select: \"absolute right-3 top-3 w-auto before:content-none\",\n expander: \"before:content-none\",\n },\n },\n density: {\n comfortable: {},\n compact: { th: \"py-2\", td: \"py-1.5\" },\n },\n // The header stays in view while the page scrolls (table layouts only; `--dt-top` clears a fixed bar).\n sticky: { true: {}, false: {} },\n // Zebra rows (the table layouts); the cards keep their frame.\n striped: { true: {}, false: {} },\n // Typed columns: one height per row (`typed`); untyped tables keep the height of their content.\n typed: { true: {}, false: {} },\n // What a row becomes on a phone (under 36 rem, or with `layout=\"cards\"`): a card, or a list row (#636).\n phone: { cards: {}, list: {} },\n },\n compoundVariants: [\n { layout: \"table\", sticky: true, class: { th: \"sticky top-(--dt-top,0px) z-[3] bg-surface-2\" } },\n { layout: \"auto\", sticky: true, class: { th: \"@xl:sticky @xl:top-(--dt-top,0px) @xl:z-[3] @xl:bg-surface-2\" } },\n { layout: \"table\", striped: true, class: { tr: \"even:bg-surface-2/40\" } },\n { layout: \"auto\", striped: true, class: { tr: \"@xl:even:bg-surface-2/40\" } },\n // One row height per density (a two-line row — a name and its id — is the tallest).\n { layout: \"table\", density: \"comfortable\", typed: true, class: { td: \"h-15\" } },\n { layout: \"auto\", density: \"comfortable\", typed: true, class: { td: \"@xl:h-15\" } },\n { layout: \"table\", density: \"compact\", typed: true, class: { td: \"h-12\" } },\n { layout: \"auto\", density: \"compact\", typed: true, class: { td: \"@xl:h-12\" } },\n // The list rows (#636): no box in the box, no label/value lines — the checkbox, the title and its line of facts, the\n // status at the end, a hairline between rows. Each cell says its place in `data-list` (title · status · away).\n {\n layout: \"auto\",\n phone: \"list\",\n class: {\n tbody: \"@max-xl:gap-0 @max-xl:p-0\",\n tr:\n \"@max-xl:flex @max-xl:items-center @max-xl:gap-3 @max-xl:rounded-none @max-xl:border-0 @max-xl:border-b @max-xl:border-border-subtle @max-xl:bg-transparent \" +\n \"@max-xl:px-4 @max-xl:py-3 @max-xl:last:border-b-0\",\n td:\n \"@max-xl:block @max-xl:text-left @max-xl:before:content-none @max-xl:data-[list=title]:min-w-0 @max-xl:data-[list=title]:flex-1 \" +\n \"@max-xl:data-[list=status]:shrink-0 @max-xl:data-[list=away]:hidden @max-xl:data-[card=message]:w-full\",\n select: \"@max-xl:relative @max-xl:right-auto @max-xl:top-auto @max-xl:z-[1] @max-xl:shrink-0 @max-xl:self-center\",\n expander: \"@max-xl:relative @max-xl:z-[1] @max-xl:shrink-0\",\n },\n },\n {\n layout: \"cards\",\n phone: \"list\",\n class: {\n tbody: \"gap-0 p-0\",\n tr: \"flex items-center gap-3 rounded-none border-0 border-b border-border-subtle bg-transparent px-4 py-3 last:border-b-0\",\n td: \"block text-left before:content-none data-[list=title]:min-w-0 data-[list=title]:flex-1 data-[list=status]:shrink-0 data-[list=away]:hidden data-[card=message]:w-full\",\n select: \"relative right-auto top-auto z-[1] shrink-0 self-center\",\n expander: \"relative z-[1] shrink-0\",\n },\n },\n ],\n defaultVariants: { layout: \"auto\", density: \"comfortable\", sticky: false, striped: false, typed: false, phone: \"cards\" },\n});\n\n// Column priorities. `priority: 1` (default) is always in the row; a higher number leaves the row when the table's own\n// width (a container query, not the window's) falls under its tier and goes to the row's detail — the same\n// `@container` that turns the table into cards. Written out in full: Tailwind finds a class only as a whole string.\n// priority 2 → 42rem · 3 → 48rem · 4 → 56rem · 5 → 64rem · 6 → 72rem · 7 → 80rem\n// On the cards (under 36rem), priority 2 stays on the card's face and 3+ go to its detail.\ntype Priority = 2 | 3 | 4 | 5 | 6 | 7;\ntype ByLayout = { auto: Record<Priority, string>; table: Record<Priority, string>; cards: Record<Priority, string> };\nconst NO_CLASS: Record<Priority, string> = { 2: \"\", 3: \"\", 4: \"\", 5: \"\", 6: \"\", 7: \"\" };\n/** The cell of a column that leaves the row. */\nconst LEAVES: ByLayout = {\n auto: { 2: \"@xl:@max-2xl:hidden!\", 3: \"@max-3xl:hidden!\", 4: \"@max-4xl:hidden!\", 5: \"@max-5xl:hidden!\", 6: \"@max-6xl:hidden!\", 7: \"@max-7xl:hidden!\" },\n table: { 2: \"@max-2xl:hidden!\", 3: \"@max-3xl:hidden!\", 4: \"@max-4xl:hidden!\", 5: \"@max-5xl:hidden!\", 6: \"@max-6xl:hidden!\", 7: \"@max-7xl:hidden!\" },\n cards: { 2: \"\", 3: \"hidden!\", 4: \"hidden!\", 5: \"hidden!\", 6: \"hidden!\", 7: \"hidden!\" },\n};\n/** Its header (the cards keep the sort buttons). */\nconst LEAVES_HEAD: ByLayout = {\n auto: { 2: \"@xl:@max-2xl:hidden!\", 3: \"@xl:@max-3xl:hidden!\", 4: \"@xl:@max-4xl:hidden!\", 5: \"@xl:@max-5xl:hidden!\", 6: \"@xl:@max-6xl:hidden!\", 7: \"@xl:@max-7xl:hidden!\" },\n table: LEAVES.table,\n cards: NO_CLASS,\n};\n/** Its line in the row's detail: shown exactly when the cell is not. */\nconst IN_DETAIL: ByLayout = {\n auto: { 2: \"hidden @xl:@max-2xl:grid\", 3: \"hidden @max-3xl:grid\", 4: \"hidden @max-4xl:grid\", 5: \"hidden @max-5xl:grid\", 6: \"hidden @max-6xl:grid\", 7: \"hidden @max-7xl:grid\" },\n table: { 2: \"hidden @max-2xl:grid\", 3: \"hidden @max-3xl:grid\", 4: \"hidden @max-4xl:grid\", 5: \"hidden @max-5xl:grid\", 6: \"hidden @max-6xl:grid\", 7: \"hidden @max-7xl:grid\" },\n cards: { 2: \"hidden\", 3: \"grid\", 4: \"grid\", 5: \"grid\", 6: \"grid\", 7: \"grid\" },\n};\n/** The button that opens the detail, and its panel, keyed by the highest priority of the table: seen only when something left the row. */\nconst TOGGLE: ByLayout = {\n auto: { 2: \"hidden @xl:@max-2xl:inline-flex\", 3: \"hidden @max-3xl:inline-flex\", 4: \"hidden @max-4xl:inline-flex\", 5: \"hidden @max-5xl:inline-flex\", 6: \"hidden @max-6xl:inline-flex\", 7: \"hidden @max-7xl:inline-flex\" },\n table: { 2: \"hidden @max-2xl:inline-flex\", 3: \"hidden @max-3xl:inline-flex\", 4: \"hidden @max-4xl:inline-flex\", 5: \"hidden @max-5xl:inline-flex\", 6: \"hidden @max-6xl:inline-flex\", 7: \"hidden @max-7xl:inline-flex\" },\n cards: { 2: \"hidden\", 3: \"inline-flex\", 4: \"inline-flex\", 5: \"inline-flex\", 6: \"inline-flex\", 7: \"inline-flex\" },\n};\nconst PANEL: ByLayout = {\n auto: { 2: \"hidden @xl:@max-2xl:block\", 3: \"hidden @max-3xl:block\", 4: \"hidden @max-4xl:block\", 5: \"hidden @max-5xl:block\", 6: \"hidden @max-6xl:block\", 7: \"hidden @max-7xl:block\" },\n table: { 2: \"hidden @max-2xl:block\", 3: \"hidden @max-3xl:block\", 4: \"hidden @max-4xl:block\", 5: \"hidden @max-5xl:block\", 6: \"hidden @max-6xl:block\", 7: \"hidden @max-7xl:block\" },\n cards: { 2: \"hidden\", 3: \"block\", 4: \"block\", 5: \"block\", 6: \"block\", 7: \"block\" },\n};\n\n// The list rows (`phone=\"list\"`): the facts line under the title, the columns that go to the row's detail (every\n// priority-1 column that is neither the title nor a status), the button and the panel that show them, the title's link\n// stretched over the row.\nconst LIST_FACTS = { auto: \"hidden @max-xl:mt-0.5 @max-xl:block @max-xl:truncate text-xs font-normal text-fg-secondary\", table: \"hidden\", cards: \"mt-0.5 block truncate text-xs font-normal text-fg-secondary\" } as const;\nconst LIST_IN_DETAIL = { auto: \"hidden @max-xl:grid\", table: \"hidden\", cards: \"grid\" } as const;\nconst LIST_TOGGLE = { auto: \"@max-xl:inline-flex\", table: \"\", cards: \"inline-flex\" } as const;\nconst LIST_PANEL = { auto: \"@max-xl:block\", table: \"\", cards: \"block\" } as const;\nconst LIST_LINK = { auto: \"@max-xl:after:absolute @max-xl:after:inset-0 @max-xl:after:content-['']\", table: \"\", cards: \"after:absolute after:inset-0 after:content-['']\" } as const;\n\nexport type DataTableColumnType = \"title\" | \"badge\" | \"number\" | \"link\" | \"date\" | \"status\" | \"text\";\n\n// What each type does to its cell. Sizes apply to the table layouts only (a card is not a column).\n// title: the column that takes the slack, truncated, full value on hover · badge, status, number, date: as wide as\n// their content, never stretched · link: truncated · text: wraps, two lines.\nconst TYPE_CELL: Record<DataTableColumnType, ByLayoutString> = {\n title: { auto: \"@xl:w-full @xl:max-w-0 @xl:min-w-44\", table: \"w-full max-w-0 min-w-44\", cards: \"\" },\n badge: { auto: \"@xl:w-px\", table: \"w-px\", cards: \"\" },\n status: { auto: \"@xl:w-px @xl:whitespace-nowrap\", table: \"w-px whitespace-nowrap\", cards: \"\" },\n number: { auto: \"@xl:w-px @xl:whitespace-nowrap tabular-nums\", table: \"w-px whitespace-nowrap tabular-nums\", cards: \"tabular-nums\" },\n date: { auto: \"@xl:w-px @xl:whitespace-nowrap tabular-nums\", table: \"w-px whitespace-nowrap tabular-nums\", cards: \"tabular-nums\" },\n link: { auto: \"@xl:min-w-28 @xl:max-w-56\", table: \"min-w-28 max-w-56\", cards: \"\" },\n text: { auto: \"@xl:min-w-36\", table: \"min-w-36\", cards: \"\" },\n};\ntype ByLayoutString = { auto: string; table: string; cards: string };\nconst CLAMP = { 1: \"line-clamp-1\", 2: \"line-clamp-2\", 3: \"line-clamp-3\" } as const;\n\nexport type SortDirection = \"ascending\" | \"descending\";\nexport type DataTableSort = { column: string; direction: SortDirection } | null;\n\n/** What the server needs to fetch a page (`manual` mode): given to `onStateChange` at each change. */\nexport type DataTableQuery = {\n /** The sorted column, or `null`. */\n sort: DataTableSort;\n /** The filters in force, by column id. */\n filters: DataTableFilterState;\n /** The page, from 1 (1 without pagination). */\n page: number;\n /** Rows per page (`Infinity` without pagination). */\n pageSize: number;\n};\n\nexport type DataTableColumn<T> = {\n /** A key of the column (and of the row, for the default value). */\n id: string;\n /** The column's name, passed translated: the header, the label of the value in a card, the filter's name. */\n header: string;\n /** What a cell shows. Default: the value as text. */\n cell?: (row: T) => React.ReactNode;\n /** The value sorted, filtered, grouped and exported. Default `row[id]`. */\n value?: (row: T) => CellValue;\n /** The header becomes a sort button (ascending → descending → none). */\n sortable?: boolean;\n /** How `DataTableFilters` filters it: `text` (a search), `facet` (values to choose), `range` (numbers between bounds). */\n filter?: \"text\" | \"facet\" | \"range\";\n /** The choices of a `facet` filter, with their words (and counts from the server). Default: the values found in the rows. */\n options?: readonly { value: string; label: string; count?: number }[];\n /** The rows can be grouped by this column (`groupBy`). */\n groupable?: boolean;\n /** What a group's row shows in this column, from the group's rows (a sum, a count). */\n aggregate?: (rows: readonly T[]) => React.ReactNode;\n /** Text alignment: `end` for amounts and counts. */\n align?: \"start\" | \"center\" | \"end\";\n /** The width, in px (the starting width when `resizing`). */\n width?: number;\n /** The narrowest the column may be, in px (also what a resized one may shrink to). Default 64. */\n minWidth?: number;\n /** In a card: `title` (the heading of the card), `label` (default: \"Header value\"), `hidden`. */\n card?: \"title\" | \"label\" | \"hidden\";\n /** Hides the header visually (an actions column), keeping it for screen readers. */\n headerHidden?: boolean;\n /** Listed in `DataTableColumnsMenu`, so a person can hide it. Default `true`. */\n hideable?: boolean;\n /**\n * What the column holds, which sizes and aligns it: `title` (the name, takes the slack, truncated, `subtitle` under it in\n * mono — and the card's heading), `badge` · `status` (as wide as the badge, never stretched), `number` (end-aligned,\n * tabular), `date`, `link` (truncated, `href`), `text` (wraps, two lines). Untyped: as before.\n */\n type?: DataTableColumnType;\n /**\n * 1 (default) always in the row; 2 to 7 leave it when the table is narrower than 42 · 48 · 56 · 64 · 72 · 80 rem and\n * go to the row's detail (a chevron opens it); under 36 rem (cards) 2 stays on the card, 3+ go to its detail. In the phone's\n * list rows (`phone=\"list\"`), the 2s are joined as the line of facts under the title.\n */\n priority?: 1 | 2 | 3 | 4 | 5 | 6 | 7;\n /** `title`: the line under the name (an id), in mono. */\n subtitle?: (row: T) => React.ReactNode;\n /** `link`: where the value leads. `title`: the row's page — the name becomes its link (the whole row, in the phone's list rows). */\n href?: (row: T) => string | undefined;\n /** `number`: the unit after the value (muted). */\n unit?: string;\n /** The widest the column may be in the table layouts, in px; longer text is clamped, the full value on hover. */\n maxWidth?: number;\n /** One line only, truncated (the full value on hover). */\n nowrap?: boolean;\n /** Lines of text kept before the ellipsis (default 2 for `text`). */\n clamp?: 1 | 2 | 3;\n};\n\nexport type DataTableLabels = {\n /** The checkbox of the header (\"Select all rows\"). */\n selectAll: string;\n /** The checkbox of a row: `(name) => \"Select \" + name`, the name from `rowLabel`. */\n selectRow: (name: string) => string;\n /** Read while the rows load (\"Loading\"). */\n loading: string;\n /** The default empty state (\"Nothing to show\"). */\n empty: string;\n /** The header of the column of the expand buttons, for screen readers (\"Details\"). */\n details: string;\n /** The button that opens a row: `(name) => \"Show details of \" + name`. */\n expandRow: (name: string) => string;\n /** The button of a group's row: `(value, count) => value + \", \" + count + \" rows\"`. */\n group: (value: string, count: number) => string;\n /** The handle that resizes a column: `(header) => \"Resize \" + header`. */\n resize: (header: string) => string;\n /** The count of results under the filters: `(count) => count + \" rows\"`. */\n results: (count: number) => string;\n /** The accessible name of the filters' bar (\"Filter the table\"). */\n filters: string;\n /** \"Clear filters\". */\n clearFilters: string;\n /** A filter's chip remove button: `(label) => \"Remove \" + label`. */\n removeFilter: (label: string) => string;\n /** The words of a filter in force: `(header, value) => header + \": \" + value`. */\n activeFilter: (header: string, value: string) => string;\n /** A `text` filter's field: `(header) => \"Search \" + header`. */\n search: (header: string) => string;\n /** The lower bound of a `range` filter: `(header) => header + \" from\"`. */\n rangeFrom: (header: string) => string;\n /** The upper bound of a `range` filter: `(header) => header + \" to\"`. */\n rangeTo: (header: string) => string;\n /** The button of the columns menu (\"Columns\"). */\n columns: string;\n /** The button that opens what left the row: `(name) => \"Show more about \" + name`. */\n showMore: (name: string) => string;\n /** The export button (\"Export CSV\"). */\n export: string;\n /** The words of the pagination under the table. */\n pagination?: Partial<PaginationLabels>;\n /** The words of the bar of a selection (`bulkActions`). */\n selection?: Partial<SelectionBarLabels>;\n};\n\nexport const dataTableLabels: DataTableLabels = {\n selectAll: \"Select all rows\",\n selectRow: (name) => `Select ${name}`,\n loading: \"Loading\",\n empty: \"Nothing to show\",\n details: \"Details\",\n expandRow: (name) => `Show details of ${name}`,\n group: (value, count) => `${value}, ${count} ${count === 1 ? \"row\" : \"rows\"}`,\n resize: (header) => `Resize ${header}`,\n results: (count) => `${count.toLocaleString(\"en\")} ${count === 1 ? \"row\" : \"rows\"}`,\n filters: \"Filter the table\",\n clearFilters: \"Clear filters\",\n removeFilter: (label) => `Remove ${label}`,\n activeFilter: (header, value) => `${header}: ${value}`,\n search: (header) => `Search ${header.toLocaleLowerCase()}`,\n rangeFrom: (header) => `${header} from`,\n rangeTo: (header) => `${header} to`,\n columns: \"Columns\",\n showMore: (name) => `Show more about ${name}`,\n export: \"Export CSV\",\n};\n\nexport type DataTableProps<T> = {\n /** The rows (stable: module scope, state or a query's data). Sorted, filtered and paginated here unless `manual`. */\n rows: readonly T[];\n /** The columns, in order (stable: module scope or `useMemo`). */\n columns: readonly DataTableColumn<T>[];\n /** A stable id per row: the React key, the selection's value, the expansion's key. */\n getRowId: (row: T) => string;\n /** What the table lists (\"Jobs\", \"Your videos\"): its `<caption>`, hidden unless `showCaption`. */\n caption: string;\n /** Shows the caption above the table. */\n showCaption?: boolean;\n\n /** The sorted column (controlled), `null` for none. */\n sort?: DataTableSort;\n /** The sort at first, uncontrolled. */\n defaultSort?: DataTableSort;\n /** Called when a header asks for a new sort. */\n onSortChange?: (sort: DataTableSort) => void;\n\n /** The filters in force (controlled), by column id — what `DataTableFilters` edits. */\n filters?: DataTableFilterState;\n /** The filters at first, uncontrolled. */\n defaultFilters?: DataTableFilterState;\n /** Called with the new filters. */\n onFiltersChange?: (filters: DataTableFilterState) => void;\n\n /**\n * Keeps the sort, the filters and the page in the address (`?clients.sort=…&clients.page=2`): back and forward, a reload\n * and a shared link all land on the same table. Replaces `sort`, `filters` and `page`; needs the router's adapter\n * (`RouteStateProvider`) in a framework.\n */\n routeKey?: string;\n\n /** Adds a checkbox per row and one in the header. */\n selectable?: boolean;\n /** The ids selected (controlled). */\n selected?: readonly string[];\n /** The ids selected at first, uncontrolled. */\n defaultSelected?: readonly string[];\n /** Called with the new selection. */\n onSelectedChange?: (selected: string[]) => void;\n /** The name of a row in its labels (checkbox, expand button). Default: its id. */\n rowLabel?: (row: T) => string;\n /**\n * The actions on the selection, given by the product: the bar (`SelectionBar`) appears under the table while rows are\n * chosen — the count, these actions, « Clear selection » — sticky, docked above the tab bar on a phone. Needs `selectable`.\n */\n bulkActions?: (selection: { selected: string[]; clear: () => void }) => React.ReactNode;\n /** The most rows a bulk call takes (200 for `@krizaka/organize`): the bar says so past it and its actions rest. */\n bulkMax?: number;\n /** What the last bulk change did (\"3 moved, 1 skipped\"), announced politely by the bar. */\n bulkResult?: string;\n\n /** The columns the rows are grouped by, in order (controlled) — each `groupable`. */\n groupBy?: readonly string[];\n /** The grouping at first, uncontrolled. */\n defaultGroupBy?: readonly string[];\n /** Called with the new grouping. */\n onGroupByChange?: (groupBy: string[]) => void;\n\n /** Visible (`true`) or hidden (`false`) columns, by id (controlled); a column not listed is visible. */\n columnVisibility?: Readonly<Record<string, boolean>>;\n /** The visibility at first, uncontrolled. */\n defaultColumnVisibility?: Readonly<Record<string, boolean>>;\n /** Called with the new visibility (`DataTableColumnsMenu`). */\n onColumnVisibilityChange?: (visibility: Record<string, boolean>) => void;\n\n /** Columns that stay in view while the table scrolls sideways: at the start (a name) or the end (actions). */\n pinning?: { start?: readonly string[]; end?: readonly string[] };\n /** Columns can be resized (pointer drag, or the arrow keys on the focused handle). */\n resizing?: boolean;\n\n /** The children of a row (a tree): each row with children gets a button that shows them. */\n getSubRows?: (row: T) => readonly T[] | undefined;\n /** A panel under an opened row (the details of a job): each row gets a button that opens it. */\n renderDetail?: (row: T) => React.ReactNode;\n /** The opened rows and groups (controlled), by id. */\n expanded?: Readonly<Record<string, boolean>>;\n /** The opened rows at first, uncontrolled. */\n defaultExpanded?: Readonly<Record<string, boolean>>;\n /** Called with the opened rows. */\n onExpandedChange?: (expanded: Record<string, boolean>) => void;\n\n /** Rows per page (controlled): turns on the pagination under the table. */\n pageSize?: number;\n /** Rows per page at first, uncontrolled: turns on the pagination under the table. */\n defaultPageSize?: number;\n /** Called with the size chosen in the pagination's select (`pageSizeOptions`). */\n onPageSizeChange?: (pageSize: number) => void;\n /** The sizes the pagination offers (`[10, 25, 50]`). */\n pageSizeOptions?: readonly number[];\n /** The page, from 1 (controlled). */\n page?: number;\n /** The page at first, uncontrolled. Default 1. */\n defaultPage?: number;\n /** Called with the page asked for. */\n onPageChange?: (page: number) => void;\n\n /** The server does the work: the rows are shown as given (sorted, filtered, a single page) — fetch in `onStateChange`. */\n manual?: { sorting?: boolean; filtering?: boolean; pagination?: boolean };\n /** The number of rows on the server (`manual.pagination`): the page count and the results' count. */\n rowCount?: number;\n /** Called with the sort, the filters and the page after each change: the query key of a server table. */\n onStateChange?: (query: DataTableQuery) => void;\n\n /** Rows are loading: skeleton rows (`loadingRows` of them) and `aria-busy`. */\n loading?: boolean;\n /** How many skeleton rows while loading. Default 5. */\n loadingRows?: number;\n /** A failure, shown in place of the rows (an `Alert`, a retry button); announced. */\n error?: React.ReactNode;\n /** Shown when there is no row (an `EmptyState`). Default: `labels.empty`. */\n empty?: React.ReactNode;\n\n /** `auto` (default): a table, cards below 36rem of container width. `table` or `cards` to force one. */\n layout?: \"auto\" | \"table\" | \"cards\";\n /**\n * What a row becomes on a phone (under 36 rem, or always with `layout=\"cards\"`): `cards` (a card per row, its values\n * labelled) or `list` — a list row: the selection's checkbox, the `title` column with its `priority: 2` columns joined as\n * one line of facts, the `status` / `badge` column at the end; the other columns in the row's detail.\n * @default \"cards\"\n */\n phone?: \"cards\" | \"list\";\n /** comfortable (default) · compact — one row height per density. */\n density?: \"comfortable\" | \"compact\";\n /** The header stays at the top of the window while the page scrolls (`--dt-top` on the table, or a number of px, clears a fixed bar). */\n stickyHeader?: boolean | number;\n /** Zebra rows. */\n striped?: boolean;\n /**\n * The table never scrolls sideways by default once its columns have a `type` or a `priority`: what does not fit goes to\n * the row's detail, then to cards. `true` opts in to a sideways scroll instead, with fades at the edges.\n */\n scroll?: boolean;\n /** Keeps the first column in view while the table scrolls sideways (with `scroll`). */\n stickyFirstColumn?: boolean;\n /** Renders only the rows in view, in a scrolling body of `height` px; rows are measured (`estimateRowHeight` is a guess). Forces the table layout. */\n virtualized?: { height: number; estimateRowHeight?: number; overscan?: number };\n\n /** Above the table, inside its frame: `DataTableFilters`, `DataTableColumnsMenu`, `DataTableExport`, actions. */\n toolbar?: React.ReactNode;\n /** Under the table (after the pagination): a total, a note. */\n footer?: React.ReactNode;\n /** The words, passed translated; English by default. */\n labels?: Partial<DataTableLabels>;\n /** Classes merged on the root. */\n className?: string;\n};\n\ntype Context = {\n table: DataTableInstance<object>;\n columns: readonly DataTableColumn<object>[];\n labels: DataTableLabels;\n filters: DataTableFilterState;\n setFilters: (filters: DataTableFilterState) => void;\n /** The rows after the filters (all pages), or the server's count. */\n resultCount: number;\n /** The rows to export: filtered and sorted, every page, without the group rows. */\n exportRows: () => readonly unknown[];\n manualFiltering: boolean;\n};\n\nconst DataTableContext = React.createContext<Context | null>(null);\n\n/**\n * The table a component sits in (`toolbar`, or anything under it): the TanStack Table instance (`table` — the escape\n * hatch for what the props do not cover), the columns, the words, the filters and their setter.\n */\nexport function useDataTable<T extends RowData = object>() {\n const context = React.useContext(DataTableContext);\n if (!context) throw new Error(\"useDataTable: call it inside a DataTable (its `toolbar`, `footer` or a cell)\");\n return context as unknown as Omit<Context, \"table\" | \"columns\" | \"exportRows\"> & {\n table: DataTableInstance<T>;\n columns: readonly DataTableColumn<T>[];\n exportRows: () => readonly T[];\n };\n}\n\n// A card never scrolls sideways, even when untyped columns keep the table's scroller.\nconst CARD_CLIP = { auto: \"@max-xl:overflow-x-clip!\", table: undefined, cards: \"overflow-x-clip!\" } as const;\nconst TRUNCATE = { auto: \"@xl:truncate\", table: \"truncate\", cards: \"\" } as const;\nconst MIN = { auto: \"@xl:min-w-(--dt-min)!\", table: \"min-w-(--dt-min)!\", cards: \"\" } as const;\nconst MAX = { auto: \"@xl:max-w-(--dt-max)!\", table: \"max-w-(--dt-max)!\", cards: \"\" } as const;\n// A sideways scroll asked for (`scroll`): the edges fade where there is more to see.\nconst SHADOWS =\n \"[background:linear-gradient(to_right,var(--kz-surface-1),transparent)_left/24px_100%_no-repeat_local,linear-gradient(to_left,var(--kz-surface-1),transparent)_right/24px_100%_no-repeat_local,linear-gradient(to_right,rgb(0_0_0/0.18),transparent)_left/10px_100%_no-repeat_scroll,linear-gradient(to_left,rgb(0_0_0/0.18),transparent)_right/10px_100%_no-repeat_scroll]\";\nconst ALIGN = { start: \"text-left\", center: \"text-center\", end: \"text-right\" } as const;\nconst NONE: readonly never[] = [];\nconst NO_RECORD: Readonly<Record<string, never>> = {};\nconst apply = <S,>(updater: S | ((old: S) => S), old: S): S => (typeof updater === \"function\" ? (updater as (old: S) => S)(old) : updater);\n\nconst valueOf = <T,>(column: DataTableColumn<T>, row: T): CellValue =>\n column.value ? column.value(row) : ((row as Record<string, unknown>)[column.id] as CellValue);\n\nconst display = (value: CellValue) => (value instanceof Date ? value.toISOString() : String(value ?? \"\"));\n\n/** A table of records — sort, filters and facets, groups, details, pages, selection, visibility, pinning, resizing — on the client or the server, cards on a phone, windowing for long lists. */\nexport function DataTable<T extends RowData>({\n rows,\n columns,\n getRowId,\n caption,\n showCaption,\n sort: sortProp,\n routeKey,\n defaultSort = null,\n onSortChange,\n filters: filtersProp,\n defaultFilters = NO_RECORD,\n onFiltersChange,\n selectable,\n selected: selectedProp,\n defaultSelected = NONE,\n onSelectedChange,\n rowLabel,\n bulkActions,\n bulkMax,\n bulkResult,\n groupBy: groupByProp,\n defaultGroupBy = NONE,\n onGroupByChange,\n columnVisibility: visibilityProp,\n defaultColumnVisibility = NO_RECORD,\n onColumnVisibilityChange,\n pinning,\n resizing,\n getSubRows,\n renderDetail,\n expanded: expandedProp,\n defaultExpanded = NO_RECORD,\n onExpandedChange,\n pageSize: pageSizeProp,\n defaultPageSize,\n onPageSizeChange,\n pageSizeOptions,\n page: pageProp,\n defaultPage = 1,\n onPageChange,\n manual,\n rowCount,\n onStateChange,\n loading,\n loadingRows = 5,\n error,\n empty,\n layout = \"auto\",\n phone = \"cards\",\n density,\n stickyHeader,\n striped,\n scroll,\n stickyFirstColumn,\n virtualized,\n toolbar,\n footer,\n labels: given,\n className,\n}: DataTableProps<T>) {\n const labels = { ...dataTableLabels, ...given };\n const effectiveLayout = virtualized ? \"table\" : layout;\n const L = effectiveLayout;\n const typed = columns.some((c) => c.type || c.priority);\n const list = phone === \"list\" && L !== \"table\";\n const s = dataTable({ layout: L, density, sticky: Boolean(stickyHeader), striped: Boolean(striped), typed, phone: list ? \"list\" : \"cards\" });\n\n const route = useRouteTable(routeKey, { sort: defaultSort, page: defaultPage, filters: defaultFilters }, columns.map((c) => c.id));\n const [sort, setSort] = useControllable<DataTableSort>(route ? route.sort : sortProp, defaultSort, route?.onSortChange ?? onSortChange);\n const [filters, setFiltersState] = useControllable<DataTableFilterState>(route ? route.filters : filtersProp, defaultFilters, route?.onFiltersChange ?? onFiltersChange);\n const [selected, setSelected] = useControllable<readonly string[]>(selectedProp, defaultSelected, onSelectedChange as (next: readonly string[]) => void);\n const [groupBy, setGroupBy] = useControllable<readonly string[]>(groupByProp, defaultGroupBy, onGroupByChange as (next: readonly string[]) => void);\n const [visibility, setVisibility] = useControllable<Readonly<Record<string, boolean>>>(visibilityProp, defaultColumnVisibility, onColumnVisibilityChange as (next: Readonly<Record<string, boolean>>) => void);\n const [expanded, setExpanded] = useControllable<Readonly<Record<string, boolean>>>(expandedProp, defaultExpanded, onExpandedChange as (next: Readonly<Record<string, boolean>>) => void);\n const paginated = pageSizeProp !== undefined || defaultPageSize !== undefined;\n const [pageSize, setPageSize] = useControllable<number>(pageSizeProp, defaultPageSize ?? Number.POSITIVE_INFINITY, onPageSizeChange);\n const [page, setPage] = useControllable<number>(route ? route.page : pageProp, defaultPage, route?.onPageChange ?? onPageChange);\n const [sizing, setSizing] = React.useState<Record<string, number>>({});\n const [resizeState, setResizeState] = React.useState<ColumnResizingState | undefined>(undefined);\n\n const announced = React.useRef(JSON.stringify([defaultSort, defaultFilters, paginated ? defaultPage : 1, paginated ? pageSize : null]));\n // One place announces the server's query: after any change of sort, filters, page or page size.\n const announce = (next: Partial<DataTableQuery>) => {\n const query = { sort, filters, page: paginated ? page : 1, pageSize: paginated ? pageSize : Number.POSITIVE_INFINITY, ...next };\n if (route) announced.current = JSON.stringify([query.sort, query.filters, query.page, paginated ? query.pageSize : null]);\n onStateChange?.(query);\n };\n // In the address (routeKey), the sort or the filters reset the page in the same navigation: no second write.\n const changeSort = (next: DataTableSort) => {\n setSort(next);\n if (paginated && page !== 1 && !route) setPage(1);\n announce({ sort: next, page: 1 });\n };\n const changeFilters = (next: DataTableFilterState) => {\n setFiltersState(next);\n if (paginated && page !== 1 && !route) setPage(1);\n announce({ filters: next, page: 1 });\n };\n // The address can change under the table (back, forward, a shared link): the server is told the query it now shows,\n // once — a change the table made itself was announced already. A first visit on the defaults says nothing.\n const routeQuery = route ? JSON.stringify([route.sort, route.filters, paginated ? route.page : 1, paginated ? pageSize : null]) : null;\n React.useEffect(() => {\n if (routeQuery === null || routeQuery === announced.current) return;\n announced.current = routeQuery;\n announce({});\n // eslint-disable-next-line react-hooks/exhaustive-deps -- only a change of the address's query announces\n }, [routeQuery]);\n const changePage = (next: number) => {\n setPage(next);\n announce({ page: next });\n };\n const changePageSize = (next: number) => {\n setPageSize(next);\n setPage(1);\n announce({ pageSize: next, page: 1 });\n };\n\n const hasExpander = Boolean(renderDetail || getSubRows);\n // Columns that can leave the row: their lines go to the row's detail, opened by a chevron in the first cell.\n const priorityOf = (column: DataTableColumn<T>): 1 | Priority => (column.priority && column.priority > 1 ? (column.priority as Priority) : 1);\n const maxPriority = columns.reduce<1 | Priority>((max, column) => (priorityOf(column) > max ? priorityOf(column) : max), 1);\n // The list rows' places: the title (the `title` column, else the first), the status at the end, the facts (the 2s) under\n // the title, and the rest away, in the row's detail.\n const titleColumn = columns.find((c) => c.card === \"title\" || (!c.card && c.type === \"title\")) ?? columns[0];\n const placeOf = (column: DataTableColumn<T>): \"title\" | \"status\" | \"facts\" | \"away\" | \"hidden\" => {\n if (column.card === \"hidden\") return \"hidden\";\n if (column === titleColumn) return \"title\";\n if (column.type === \"status\" || column.type === \"badge\") return \"status\";\n return priorityOf(column) === 2 ? \"facts\" : \"away\";\n };\n const listAway = list ? columns.filter((c) => placeOf(c) === \"away\" && priorityOf(c) === 1) : [];\n const facts = list ? columns.filter((c) => placeOf(c) === \"facts\") : [];\n const inlineToggle = (maxPriority > 1 || listAway.length > 0) && !hasExpander;\n const detailed = Boolean(renderDetail) || inlineToggle;\n const defs = React.useMemo<ColumnDef<typeof features, T>[]>(\n () =>\n columns.map((column) => ({\n id: column.id,\n accessorFn: (row: T) => valueOf(column, row),\n header: column.header,\n enableSorting: Boolean(column.sortable),\n sortFn: sortByValue as never,\n sortUndefined: \"last\",\n enableColumnFilter: Boolean(column.filter),\n filterFn: (column.filter ? FILTERS[column.filter] : FILTERS.text) as never,\n enableGrouping: Boolean(column.groupable),\n enableHiding: column.hideable !== false,\n enableResizing: Boolean(resizing),\n ...(column.width ? { size: column.width } : {}),\n minSize: column.minWidth ?? 64,\n })),\n [columns, resizing],\n );\n\n const firstId = columns[0]?.id;\n const pinned = stickyFirstColumn && firstId && !pinning?.start?.length ? { ...pinning, start: [firstId] } : pinning;\n const pageIndex = Math.max(0, page - 1);\n const table = useTable<typeof features, T>({\n features,\n columns: defs,\n data: rows as T[],\n getRowId: (row) => getRowId(row),\n getSubRows: getSubRows ? (row) => getSubRows(row) as T[] | undefined : undefined,\n getRowCanExpand: detailed ? () => true : undefined,\n state: {\n sorting: sort ? [{ id: sort.column, desc: sort.direction === \"descending\" }] : [],\n columnFilters: Object.entries(filters).map(([id, value]) => ({ id, value })),\n rowSelection: Object.fromEntries(selected.map((id) => [id, true])),\n grouping: [...groupBy],\n columnVisibility: { ...visibility },\n expanded: { ...expanded },\n pagination: { pageIndex, pageSize: paginated ? pageSize : Math.max(1, rows.length) },\n columnPinning: { start: [...(pinned?.start ?? [])], end: [...(pinned?.end ?? [])] },\n columnSizing: sizing,\n ...(resizeState ? { columnResizing: resizeState } : {}),\n },\n onSortingChange: (updater) => {\n const [first] = apply(updater, sort ? [{ id: sort.column, desc: sort.direction === \"descending\" }] : []);\n changeSort(first ? { column: first.id, direction: first.desc ? \"descending\" : \"ascending\" } : null);\n },\n onColumnFiltersChange: (updater) => {\n const next = apply(updater, Object.entries(filters).map(([id, value]) => ({ id, value })));\n changeFilters(Object.fromEntries(next.map((f) => [f.id, f.value as FilterValue])));\n },\n onRowSelectionChange: (updater) => {\n const next = apply(updater, Object.fromEntries(selected.map((id) => [id, true])));\n setSelected(Object.keys(next).filter((id) => next[id]));\n },\n onGroupingChange: (updater) => setGroupBy(apply(updater, [...groupBy])),\n onColumnVisibilityChange: (updater) => setVisibility(apply(updater, { ...visibility })),\n onExpandedChange: (updater) => {\n const next = apply(updater, { ...expanded });\n setExpanded(next === true ? Object.fromEntries(table.getRowModel().rows.map((r) => [r.id, true])) : next);\n },\n onColumnSizingChange: (updater) => setSizing((old: Record<string, number>) => apply(updater, old)),\n onColumnResizingChange: (updater) => setResizeState((old) => apply(updater, old as ColumnResizingState)),\n enableSortingRemoval: true,\n sortDescFirst: false,\n manualSorting: manual?.sorting,\n manualFiltering: manual?.filtering,\n manualPagination: manual?.pagination || !paginated,\n rowCount: manual?.pagination ? rowCount : undefined,\n autoResetPageIndex: false,\n autoResetExpanded: false,\n groupedColumnMode: false,\n columnResizeMode: \"onChange\",\n enableRowSelection: (row) => !row.getIsGrouped(),\n });\n\n const visibleColumns = table.getVisibleLeafColumns();\n const byId = new Map(columns.map((c) => [c.id, c]));\n const pageRows = table.getRowModel().rows;\n const leafCount = (manual?.pagination || manual?.filtering) && rowCount !== undefined ? rowCount : table.getFilteredRowModel().rows.length;\n const pageCount = paginated ? Math.max(1, manual?.pagination ? Math.ceil((rowCount ?? rows.length) / pageSize) : table.getPageCount()) : 1;\n // A page beyond the last (the filters shrank the list): show the last one.\n React.useEffect(() => {\n if (paginated && !loading && page > pageCount) changePage(pageCount);\n // eslint-disable-next-line react-hooks/exhaustive-deps -- only when the count of pages drops under the page\n }, [pageCount]);\n\n const selectableIds = pageRows.filter((r) => !r.getIsGrouped()).map((r) => r.id);\n const chosen = new Set(selected);\n const allChosen = selectableIds.length > 0 && selectableIds.every((id) => chosen.has(id));\n const someChosen = selectableIds.some((id) => chosen.has(id));\n const toggleAll = () =>\n setSelected(allChosen ? selected.filter((id) => !selectableIds.includes(id)) : [...new Set([...selected, ...selectableIds])]);\n\n const span = visibleColumns.length + (selectable ? 1 : 0) + (hasExpander ? 1 : 0);\n const fixedLayout = Boolean(resizing || pinned?.start?.length || pinned?.end?.length);\n const sideways = scroll ?? (!typed && !stickyHeader);\n const nameOf = (row: TableRow<T>) => (rowLabel ? rowLabel(row.original) : row.id);\n\n // Windowing: the rows in view, between two spacer rows that keep the scroll height.\n const scroller = React.useRef<HTMLDivElement>(null);\n const fallbacks = useLayoutFallbacks(virtualized?.height ?? 0, virtualized?.estimateRowHeight ?? 44);\n const virtualizer = useVirtualizer({\n ...fallbacks,\n count: pageRows.length,\n getScrollElement: () => scroller.current,\n estimateSize: () => virtualized?.estimateRowHeight ?? 44,\n overscan: virtualized?.overscan ?? 6,\n initialRect: { width: 0, height: virtualized?.height ?? 0 },\n getItemKey: (index) => pageRows[index]?.id ?? index,\n enabled: Boolean(virtualized) && !loading,\n });\n const windowItems = virtualized && !loading ? virtualizer.getVirtualItems() : null;\n const before = windowItems?.[0]?.start ?? 0;\n const after = windowItems && windowItems.length > 0 ? virtualizer.getTotalSize() - (windowItems.at(-1)?.end ?? 0) : 0;\n\n const pin = (column: TableColumn<T>): { \"data-pin\"?: \"start\" | \"end\"; style?: React.CSSProperties } => {\n const position = column.getIsPinned();\n if (!position) return {};\n const offset = position === \"start\" ? column.getStart(\"start\") : column.getAfter(\"end\");\n return { \"data-pin\": position, style: { [\"--dt-pin\" as string]: `${offset}px` } };\n };\n const width = (column: TableColumn<T>): React.CSSProperties | undefined =>\n fixedLayout || byId.get(column.id)?.width ? { width: column.getSize() } : undefined;\n\n const message = (content: React.ReactNode, alert?: boolean) => (\n <tr role=\"row\" className={s.tr({ className: \"hover:bg-transparent\" })}>\n <td role=\"cell\" colSpan={span} data-card=\"message\" className={s.td({ className: s.message() })}>\n {alert ? <div role=\"alert\">{content}</div> : content}\n </td>\n </tr>\n );\n\n const cardOf = (column: DataTableColumn<T> | undefined) =>\n column?.card === \"title\" || (column && !column.card && column.type === \"title\") ? \"title\" : column?.card === \"hidden\" ? \"hidden\" : undefined;\n\n // What a cell shows: the column's `cell`, or its value by type.\n const contentOf = (column: DataTableColumn<T>, original: T): React.ReactNode => {\n if (column.cell) return column.cell(original);\n const value = valueOf(column, original);\n const text = column.type === \"date\" && value instanceof Date ? value.toISOString().slice(0, 10) : display(value);\n const cut = TRUNCATE[L];\n switch (column.type) {\n case \"title\": {\n const sub = column.subtitle?.(original);\n const href = column.href?.(original);\n return (\n <span className=\"block min-w-0\">\n {href ? (\n <a href={href} className={cn(\"block font-semibold text-fg no-underline hover:underline focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring\", cut, list && LIST_LINK[L])} title={text}>\n {text}\n </a>\n ) : (\n <span className={cn(\"block font-semibold text-fg\", cut)} title={text}>\n {text}\n </span>\n )}\n {sub ? <span className={cn(\"block font-mono text-xs text-fg-tertiary\", cut)}>{sub}</span> : null}\n </span>\n );\n }\n case \"number\":\n return (\n <span>\n {typeof value === \"number\" ? value.toLocaleString(\"en\") : text}\n {column.unit ? <span className=\"ms-1 text-fg-secondary\">{column.unit}</span> : null}\n </span>\n );\n case \"link\": {\n const href = column.href?.(original);\n return href ? (\n <a href={href} title={text} className={cn(\"block text-fg-accent underline-offset-2 hover:underline\", cut)}>\n {text}\n </a>\n ) : (\n <span className={cn(\"block\", cut)} title={text}>\n {text}\n </span>\n );\n }\n default: {\n const lines = column.clamp ?? (column.type === \"text\" ? 2 : undefined);\n if (!column.nowrap && !lines) return text;\n return (\n <span className={column.nowrap ? cn(\"block\", cut || \"truncate\") : CLAMP[lines as 1 | 2 | 3]} title={text}>\n {text}\n </span>\n );\n }\n }\n };\n\n // A group's row keeps its value as the title and its aggregates; a facts column is away (its value is in the title's line).\n const listPlace = (row: TableRow<T> | null, column: DataTableColumn<T>) => {\n if (row?.getIsGrouped()) return row.groupingColumnId === column.id ? \"title\" : column.aggregate ? \"status\" : \"away\";\n const place = placeOf(column);\n return place === \"facts\" || place === \"hidden\" ? \"away\" : place;\n };\n\n const dataCell = (row: TableRow<T>, cell: TableCell<T>, first: boolean) => {\n const column = byId.get(cell.column.id);\n if (!column) return null;\n const { style, ...pinnedProps } = pin(cell.column);\n let content: React.ReactNode;\n if (row.getIsGrouped()) {\n const leaves = row.getLeafRows().filter((r) => !r.getIsGrouped()).map((r) => r.original);\n if (cell.column.id === row.groupingColumnId) {\n const value = display(row.groupingValue as CellValue);\n content = (\n <button type=\"button\" className={s.toggle({ className: \"px-1.5 font-semibold text-fg\" })} aria-expanded={row.getIsExpanded()} onClick={row.getToggleExpandedHandler()}>\n <ChevronGlyph direction=\"right\" className=\"h-4 w-4\" />\n {labels.group(value, leaves.length)}\n </button>\n );\n } else content = column.aggregate ? column.aggregate(leaves) : null;\n } else {\n content = contentOf(column, row.original);\n if (list && column === titleColumn && facts.length > 0) {\n content = (\n <span className=\"block min-w-0\">\n {content}\n <span data-facts=\"\" className={LIST_FACTS[L]}>\n {facts.map((c, i) => (\n <React.Fragment key={c.id}>\n {i > 0 ? <span aria-hidden>{\" · \"}</span> : null}\n {contentOf(c, row.original)}\n </React.Fragment>\n ))}\n </span>\n </span>\n );\n }\n if (first && inlineToggle) {\n content = (\n <span className=\"flex min-w-0 items-center gap-1\">\n <button\n type=\"button\"\n className={s.toggle({ className: cn(maxPriority > 1 ? TOGGLE[L][maxPriority as Priority] : \"hidden\", listAway.length > 0 && LIST_TOGGLE[L], list && \"relative z-[1]\") })}\n aria-expanded={row.getIsExpanded()}\n aria-label={labels.showMore(nameOf(row))}\n onClick={row.getToggleExpandedHandler()}\n >\n <ChevronGlyph direction=\"right\" className=\"h-4 w-4\" />\n </button>\n <span className=\"min-w-0 flex-1\">{content}</span>\n </span>\n );\n }\n }\n const level = priorityOf(column);\n const type = column.type;\n const cellClass = [\n ALIGN[column.align ?? (type === \"number\" ? \"end\" : \"start\")],\n type ? TYPE_CELL[type][L] : \"\",\n level > 1 ? LEAVES[L][level as Priority] : \"\",\n (type || column.priority) && column.minWidth !== undefined ? MIN[L] : \"\",\n column.maxWidth !== undefined ? MAX[L] : \"\",\n ].join(\" \");\n return (\n <td\n role=\"cell\"\n key={cell.id}\n data-label={column.header}\n data-card={list ? (placeOf(column) === \"hidden\" ? \"hidden\" : undefined) : row.getIsGrouped() ? (cell.column.id === row.groupingColumnId ? \"title\" : column.aggregate ? undefined : \"hidden\") : cardOf(column)}\n data-list={list ? listPlace(row, column) : undefined}\n {...pinnedProps}\n className={s.td({ className: cellClass })}\n style={{\n ...style,\n ...(column.minWidth !== undefined ? { [\"--dt-min\" as string]: `${column.minWidth}px` } : {}),\n ...(column.maxWidth !== undefined ? { [\"--dt-max\" as string]: `${column.maxWidth}px` } : {}),\n ...(first && row.depth > 0 && !row.getIsGrouped() ? { paddingInlineStart: `${1 + row.depth * 1.25}rem` } : {}),\n }}\n >\n {content}\n </td>\n );\n };\n\n const renderRow = (row: TableRow<T>, index: number) => {\n const isChosen = chosen.has(row.id);\n const grouped = row.getIsGrouped();\n const canExpand = !grouped && (renderDetail ? true : row.getCanExpand());\n const showDetail = detailed && !grouped && row.getIsExpanded() && !virtualized;\n const cells = row.getVisibleCells();\n const main = (\n <tr\n role=\"row\"\n data-index={windowItems ? index : undefined}\n ref={windowItems ? virtualizer.measureElement : undefined}\n aria-rowindex={virtualized ? index + 2 : undefined}\n data-state={isChosen ? \"selected\" : undefined}\n data-group={grouped ? \"\" : undefined}\n className={s.tr({ className: grouped ? s.groupRow() : undefined })}\n >\n {selectable && (\n <td role=\"cell\" className={s.td({ className: s.select() })}>\n {grouped ? null : <Checkbox checked={isChosen} onCheckedChange={() => row.toggleSelected()} aria-label={labels.selectRow(nameOf(row))} />}\n </td>\n )}\n {hasExpander && (\n <td role=\"cell\" className={s.td({ className: s.expander() })}>\n {canExpand ? (\n <button type=\"button\" className={s.toggle()} aria-expanded={row.getIsExpanded()} aria-label={labels.expandRow(nameOf(row))} onClick={row.getToggleExpandedHandler()}>\n <ChevronGlyph direction=\"right\" className=\"h-4 w-4\" />\n </button>\n ) : null}\n </td>\n )}\n {cells.map((cell, i) => dataCell(row, cell, i === 0))}\n </tr>\n );\n // One Fragment keyed by the row either way: opening a row keeps its button (and the focus on it).\n if (!showDetail) return <React.Fragment key={row.id}>{main}</React.Fragment>;\n const left = visibleColumns.filter((c) => {\n const column = byId.get(c.id) as DataTableColumn<T>;\n return priorityOf(column) > 1 || listAway.includes(column);\n });\n return (\n <React.Fragment key={row.id}>\n {main}\n <tr role=\"row\" className={s.tr({ className: \"hover:bg-transparent\" })}>\n <td role=\"cell\" colSpan={span} data-card=\"message\" className={s.td({ className: renderDetail ? s.detail() : \"bg-surface-0 p-0 text-left\" })}>\n {left.length > 0 ? (\n <dl className={cn(\"m-0 grid gap-3 text-left\", renderDetail ? \"mb-4\" : cn(\"px-4 py-4\", maxPriority > 1 ? PANEL[L][maxPriority as Priority] : \"hidden\", listAway.length > 0 && LIST_PANEL[L]))}>\n {left.map((c) => {\n const column = byId.get(c.id) as DataTableColumn<T>;\n return (\n <div key={c.id} className={cn(listAway.includes(column) ? LIST_IN_DETAIL[L] : IN_DETAIL[L][priorityOf(column) as Priority], \"grid-cols-[minmax(5rem,8rem)_minmax(0,1fr)] items-baseline gap-3\")}>\n <dt className=\"text-xs font-semibold text-fg-secondary\">{column.header}</dt>\n <dd className=\"m-0 min-w-0 text-sm text-fg\">{contentOf(column, row.original)}</dd>\n </div>\n );\n })}\n </dl>\n ) : null}\n {renderDetail ? renderDetail(row.original) : null}\n </td>\n </tr>\n </React.Fragment>\n );\n };\n\n let body: React.ReactNode;\n if (loading) {\n body = Array.from({ length: loadingRows }, (_, i) => (\n <tr role=\"row\" key={`loading-${i}`} aria-hidden className={s.tr()}>\n {selectable && <td role=\"cell\" className={s.td({ className: s.select() })} />}\n {hasExpander && <td role=\"cell\" className={s.td({ className: s.expander() })} />}\n {visibleColumns.map((column) => (\n <td role=\"cell\" key={column.id} data-card={list ? undefined : cardOf(byId.get(column.id))} data-list={list ? listPlace(null, byId.get(column.id) as DataTableColumn<T>) : undefined} className={s.td()}>\n <div className={s.skeleton()} />\n </td>\n ))}\n </tr>\n ));\n } else if (error) body = message(error, true);\n else if (pageRows.length === 0) body = message(empty ?? labels.empty);\n else if (windowItems) body = windowItems.map((item) => renderRow(pageRows[item.index] as TableRow<T>, item.index));\n else body = pageRows.map((row, i) => renderRow(row, i));\n\n const headers = table.getHeaderGroups().at(-1)?.headers ?? [];\n const tableElement = (\n <table\n role=\"table\"\n aria-busy={loading || undefined}\n aria-rowcount={virtualized ? pageRows.length + 1 : undefined}\n className={s.table({ className: fixedLayout ? \"table-fixed\" : undefined })}\n style={fixedLayout ? { minWidth: table.getTotalSize() + (selectable ? 40 : 0) + (hasExpander ? 40 : 0) } : undefined}\n >\n <caption className={showCaption ? s.caption() : \"sr-only\"}>\n {caption}\n {loading ? <span className=\"sr-only\">{` — ${labels.loading}`}</span> : null}\n </caption>\n <thead role=\"rowgroup\" className={s.thead({ className: virtualized ? \"sticky top-0 z-10 bg-surface-2\" : undefined })}>\n <tr role=\"row\" aria-rowindex={virtualized ? 1 : undefined} className={s.headRow()}>\n {selectable && (\n <th role=\"columnheader\" scope=\"col\" data-keep=\"\" className={s.th({ className: s.select() })}>\n <Checkbox\n checked={allChosen ? true : someChosen ? \"indeterminate\" : false}\n onCheckedChange={toggleAll}\n disabled={loading || selectableIds.length === 0}\n aria-label={labels.selectAll}\n />\n </th>\n )}\n {hasExpander && (\n <th role=\"columnheader\" scope=\"col\" className={s.th({ className: s.expander() })}>\n <span className=\"sr-only\">{labels.details}</span>\n </th>\n )}\n {headers.map((header) => {\n const column = byId.get(header.column.id);\n if (!column) return null;\n const sorted = header.column.getIsSorted();\n const direction: SortDirection | undefined = sorted === \"asc\" ? \"ascending\" : sorted === \"desc\" ? \"descending\" : undefined;\n const { style, ...pinnedProps } = pin(header.column);\n const level = priorityOf(column);\n return (\n <th\n role=\"columnheader\"\n scope=\"col\"\n key={header.id}\n aria-sort={column.sortable ? (direction ?? \"none\") : undefined}\n data-keep={column.sortable ? \"\" : undefined}\n {...pinnedProps}\n className={s.th({ className: cn(ALIGN[column.align ?? (column.type === \"number\" ? \"end\" : \"start\")], level > 1 && LEAVES_HEAD[L][level as Priority]) })}\n style={{ ...style, ...(typeof stickyHeader === \"number\" ? { [\"--dt-top\" as string]: `${stickyHeader}px` } : {}), ...width(header.column) }}\n >\n {column.sortable ? (\n <button type=\"button\" aria-pressed={Boolean(direction)} className={s.sortButton()} onClick={() => header.column.toggleSorting(undefined, false)}>\n {column.header}\n <SortGlyph direction={direction} className=\"h-3.5 w-3.5\" />\n </button>\n ) : column.headerHidden ? (\n <span className=\"sr-only\">{column.header}</span>\n ) : (\n column.header\n )}\n {resizing && header.column.getCanResize() ? (\n <ResizeHandle\n label={labels.resize(column.header)}\n size={header.column.getSize()}\n min={column.minWidth ?? 64}\n resizing={header.column.getIsResizing()}\n className={s.resizer()}\n onPointerStart={header.getResizeHandler()}\n onSize={(size) => setSizing((old: Record<string, number>) => ({ ...old, [header.column.id]: size }))}\n />\n ) : null}\n </th>\n );\n })}\n </tr>\n </thead>\n <tbody role=\"rowgroup\" className={s.tbody()}>\n {before > 0 && (\n <tr aria-hidden style={{ height: before }}>\n <td colSpan={span} />\n </tr>\n )}\n {body}\n {after > 0 && (\n <tr aria-hidden style={{ height: after }}>\n <td colSpan={span} />\n </tr>\n )}\n </tbody>\n </table>\n );\n\n const context: Context = {\n table: table as unknown as DataTableInstance<object>,\n columns: columns as readonly DataTableColumn<object>[],\n labels,\n filters,\n setFilters: changeFilters,\n resultCount: leafCount,\n exportRows: () => table.getSortedRowModel().flatRows.filter((r) => !r.getIsGrouped()).map((r) => r.original),\n manualFiltering: Boolean(manual?.filtering),\n };\n\n const pagination = paginated ? (\n <Pagination\n page={Math.min(page, pageCount)}\n pageCount={pageCount}\n onPageChange={changePage}\n pageSize={pageSizeOptions ? pageSize : undefined}\n pageSizeOptions={pageSizeOptions}\n onPageSizeChange={pageSizeOptions ? changePageSize : undefined}\n disabled={loading}\n labels={labels.pagination}\n />\n ) : null;\n\n return (\n <DataTableContext.Provider value={context}>\n <div className={s.root({ className })}>\n {toolbar ? <div className={s.toolbar()}>{toolbar}</div> : null}\n {virtualized ? (\n // A scrolling region the keyboard can reach: Tab lands on it, the arrows scroll it.\n <div\n ref={scroller}\n tabIndex={0}\n role=\"region\"\n aria-label={caption}\n className={s.scroller({ className: \"overflow-y-auto focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring\" })}\n style={{ height: virtualized.height }}\n >\n {tableElement}\n </div>\n ) : (\n <div className={s.scroller({ className: sideways ? (scroll ? SHADOWS : CARD_CLIP[L]) : \"overflow-x-clip\" })}>{tableElement}</div>\n )}\n {selectable && bulkActions ? (\n <SelectionBar count={selected.length} max={bulkMax} result={bulkResult} labels={labels.selection} onClear={() => setSelected([])}>\n {bulkActions({ selected: [...selected], clear: () => setSelected([]) })}\n </SelectionBar>\n ) : null}\n {pagination || footer ? (\n <div className={s.footer({ className: \"flex flex-col gap-3\" })}>\n {pagination}\n {footer}\n </div>\n ) : null}\n </div>\n </DataTableContext.Provider>\n );\n}\n\n/** The handle on a header's edge: drag it, or focus it and use ← → (Shift for larger steps). */\nfunction ResizeHandle({\n label,\n size,\n min,\n resizing,\n className,\n onPointerStart,\n onSize,\n}: {\n label: string;\n size: number;\n min: number;\n resizing: boolean;\n className: string;\n onPointerStart: (event: unknown) => void;\n onSize: (size: number) => void;\n}) {\n return (\n // A focusable separator is interactive (WAI-ARIA \"window splitter\"): its value is the width, the arrows change it.\n <div\n role=\"separator\"\n aria-orientation=\"vertical\"\n aria-label={label}\n aria-valuenow={Math.round(size)}\n aria-valuemin={min}\n tabIndex={0}\n data-resizing={resizing ? \"\" : undefined}\n className={className}\n onMouseDown={onPointerStart}\n onTouchStart={onPointerStart}\n onClick={(event) => event.stopPropagation()}\n onKeyDown={(event) => {\n const step = event.shiftKey ? 48 : 16;\n if (event.key === \"ArrowLeft\") onSize(Math.max(min, size - step));\n else if (event.key === \"ArrowRight\") onSize(size + step);\n else return;\n event.preventDefault();\n }}\n />\n );\n}\n"
794
+ "content": "// Client (the table's state, the windowing of long lists). A real `<table>` with a caption and column headers\n// (`scope=\"col\"`, `aria-sort` on the sorted one) that turns into a stack of cards in a narrow container — one DOM, the\n// roles written out so that the change of `display` never loses the table's semantics. The engine is TanStack Table v9\n// (engine.ts): sorting, filters and facets, grouping, expanding, pagination, selection, visibility, pinning, resizing —\n// in the browser, or on the server (`manual` + `onStateChange`). Long lists render by what is in view (`virtualized`).\nimport { useTable } from \"@tanstack/react-table\";\nimport * as React from \"react\";\nimport { tv } from \"tailwind-variants\";\n\nimport { Checkbox } from \"../checkbox\";\nimport { cn } from \"../cn\";\nimport { ChevronGlyph, SortGlyph } from \"../glyphs\";\nimport { useControllable } from \"../media\";\nimport { Pagination, type PaginationLabels } from \"../pagination\";\nimport { useLayoutFallbacks, useVirtualizer } from \"../virtual/virtual\";\nimport {\n type CellValue,\n type ColumnDef,\n type ColumnResizingState,\n type DataTableFilterState,\n type DataTableInstance,\n features,\n FILTERS,\n type FilterValue,\n type RowData,\n sortByValue,\n type TableCell,\n type TableColumn,\n type TableRow,\n} from \"./engine\";\nimport { SelectionBar, type SelectionBarLabels } from \"./selection-bar\";\nimport { useRouteTable } from \"./use-route-table\";\n\nexport const dataTable = tv({\n slots: {\n root: \"@container w-full overflow-clip rounded-xl border border-border-default bg-surface-1\",\n toolbar: \"border-b border-border-default p-3\",\n scroller: \"w-full overflow-x-auto\",\n table: \"w-full border-collapse text-left text-sm text-fg\",\n caption: \"px-4 pt-4 pb-2 text-left text-sm font-semibold text-fg\",\n thead: \"bg-surface-2/60\",\n headRow: \"border-b border-border-default\",\n th: \"relative whitespace-nowrap px-4 py-3 text-xs font-semibold text-fg-secondary\",\n sortButton:\n \"-mx-1.5 inline-flex items-center gap-1 rounded-md px-1.5 py-1 hover:bg-surface-3 hover:text-fg \" +\n \"focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring aria-[pressed=true]:text-fg\",\n resizer:\n \"absolute top-0 right-0 h-full w-1.5 cursor-col-resize touch-none select-none bg-transparent hover:bg-border-strong \" +\n \"focus-visible:bg-accent focus-visible:outline-hidden data-[resizing]:bg-accent\",\n tbody: \"\",\n tr: \"border-b border-border-subtle transition-colors last:border-b-0 hover:bg-surface-2/50 data-[state=selected]:bg-accent-soft\",\n groupRow: \"bg-surface-2/40 font-semibold\",\n td: \"px-4 py-3 align-middle\",\n select: \"w-10\",\n expander: \"w-10\",\n toggle:\n \"inline-flex h-7 min-w-7 items-center justify-center gap-1.5 rounded-md text-fg-secondary hover:bg-surface-3 hover:text-fg \" +\n \"focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring [&[aria-expanded=true]>svg]:rotate-90 [&>svg]:transition-transform motion-reduce:[&>svg]:transition-none\",\n detail: \"bg-surface-0 px-4 py-4\",\n message: \"px-4 py-10 text-center text-sm text-fg-secondary\",\n skeleton: \"h-4 w-full max-w-40 animate-pulse rounded bg-surface-3 motion-reduce:animate-none\",\n footer: \"border-t border-border-default px-4 py-3\",\n },\n variants: {\n layout: {\n table: {\n th: \"data-[pin]:sticky data-[pin]:z-[2] data-[pin]:bg-surface-2 data-[pin=start]:left-(--dt-pin) data-[pin=end]:right-(--dt-pin)\",\n td: \"data-[pin]:sticky data-[pin]:z-[1] data-[pin]:bg-surface-1 data-[pin=start]:left-(--dt-pin) data-[pin=end]:right-(--dt-pin)\",\n },\n // Below 36rem of container: cards. The sortable headers stay, as a row of sort buttons above the cards.\n auto: {\n table: \"@max-xl:block\",\n caption: \"@max-xl:block\",\n thead: \"@max-xl:sr-only @max-xl:bg-transparent @max-xl:has-[[data-keep]]:not-sr-only @max-xl:has-[[data-keep]]:block\",\n headRow: \"@max-xl:flex @max-xl:flex-wrap @max-xl:items-center @max-xl:gap-2 @max-xl:px-3 @max-xl:py-2\",\n th:\n \"@max-xl:sr-only @max-xl:data-[keep]:not-sr-only @max-xl:data-[keep]:block @max-xl:p-0 \" +\n \"@xl:data-[pin]:sticky @xl:data-[pin]:z-[2] @xl:data-[pin]:bg-surface-2 @xl:data-[pin=start]:left-(--dt-pin) @xl:data-[pin=end]:right-(--dt-pin)\",\n tbody: \"@max-xl:grid @max-xl:gap-3 @max-xl:p-3\",\n tr: \"@max-xl:relative @max-xl:grid @max-xl:gap-1.5 @max-xl:rounded-xl @max-xl:border @max-xl:border-border-default @max-xl:bg-surface-0 @max-xl:p-4 @max-xl:last:border-b\",\n td:\n \"@max-xl:flex @max-xl:min-w-0 @max-xl:items-baseline @max-xl:justify-between @max-xl:gap-4 @max-xl:p-0 @max-xl:text-right @max-xl:[overflow-wrap:anywhere] \" +\n \"@max-xl:[&>*]:min-w-0 @max-xl:[&>*]:shrink @max-xl:[&>*]:whitespace-normal \" +\n \"@max-xl:before:shrink-0 @max-xl:before:text-xs @max-xl:before:font-semibold @max-xl:before:text-fg-secondary @max-xl:before:content-[attr(data-label)] \" +\n \"@max-xl:data-[card=title]:order-first @max-xl:data-[card=title]:pr-8 @max-xl:data-[card=title]:text-left @max-xl:data-[card=title]:text-base @max-xl:data-[card=title]:font-semibold @max-xl:data-[card=title]:before:content-none \" +\n \"@max-xl:data-[card=hidden]:hidden @max-xl:data-[card=message]:block @max-xl:data-[card=message]:text-center @max-xl:data-[card=message]:before:content-none \" +\n \"@xl:data-[pin]:sticky @xl:data-[pin]:z-[1] @xl:data-[pin]:bg-surface-1 @xl:data-[pin=start]:left-(--dt-pin) @xl:data-[pin=end]:right-(--dt-pin)\",\n select: \"@max-xl:absolute @max-xl:right-3 @max-xl:top-3 @max-xl:w-auto @max-xl:before:content-none\",\n expander: \"@max-xl:before:content-none\",\n },\n cards: {\n table: \"block\",\n caption: \"block\",\n thead: \"sr-only bg-transparent has-[[data-keep]]:not-sr-only has-[[data-keep]]:block\",\n headRow: \"flex flex-wrap items-center gap-2 px-3 py-2\",\n th: \"sr-only p-0 data-[keep]:not-sr-only data-[keep]:block\",\n tbody: \"grid gap-3 p-3\",\n tr: \"relative grid gap-1.5 rounded-xl border border-border-default bg-surface-0 p-4 last:border-b\",\n td:\n \"flex min-w-0 items-baseline justify-between gap-4 p-0 text-right [overflow-wrap:anywhere] before:shrink-0 before:text-xs before:font-semibold before:text-fg-secondary before:content-[attr(data-label)] \" +\n \"[&>*]:min-w-0 [&>*]:shrink [&>*]:whitespace-normal \" +\n \"data-[card=title]:order-first data-[card=title]:pr-8 data-[card=title]:text-left data-[card=title]:text-base data-[card=title]:font-semibold data-[card=title]:before:content-none \" +\n \"data-[card=hidden]:hidden data-[card=message]:block data-[card=message]:text-center data-[card=message]:before:content-none\",\n select: \"absolute right-3 top-3 w-auto before:content-none\",\n expander: \"before:content-none\",\n },\n },\n density: {\n comfortable: {},\n compact: { th: \"py-2\", td: \"py-1.5\" },\n },\n // The header stays in view while the page scrolls (table layouts only; `--dt-top` clears a fixed bar).\n sticky: { true: {}, false: {} },\n // Zebra rows (the table layouts); the cards keep their frame.\n striped: { true: {}, false: {} },\n // Typed columns: one height per row (`typed`); untyped tables keep the height of their content.\n typed: { true: {}, false: {} },\n // What a row becomes on a phone (under 36 rem, or with `layout=\"cards\"`): a card, or a list row (#636).\n phone: { cards: {}, list: {} },\n },\n compoundVariants: [\n { layout: \"table\", sticky: true, class: { th: \"sticky top-(--dt-top,0px) z-[3] bg-surface-2\" } },\n { layout: \"auto\", sticky: true, class: { th: \"@xl:sticky @xl:top-(--dt-top,0px) @xl:z-[3] @xl:bg-surface-2\" } },\n { layout: \"table\", striped: true, class: { tr: \"even:bg-surface-2/40\" } },\n { layout: \"auto\", striped: true, class: { tr: \"@xl:even:bg-surface-2/40\" } },\n // One row height per density (a two-line row — a name and its id — is the tallest).\n { layout: \"table\", density: \"comfortable\", typed: true, class: { td: \"h-15\" } },\n { layout: \"auto\", density: \"comfortable\", typed: true, class: { td: \"@xl:h-15\" } },\n { layout: \"table\", density: \"compact\", typed: true, class: { td: \"h-12\" } },\n { layout: \"auto\", density: \"compact\", typed: true, class: { td: \"@xl:h-12\" } },\n // The list rows (#636): no box in the box, no label/value lines — the checkbox, the title and its line of facts, the\n // status at the end, a hairline between rows. Each cell says its place in `data-list` (title · status · away).\n {\n layout: \"auto\",\n phone: \"list\",\n class: {\n tbody: \"@max-xl:gap-0 @max-xl:p-0\",\n tr:\n \"@max-xl:flex @max-xl:items-center @max-xl:gap-3 @max-xl:rounded-none @max-xl:border-0 @max-xl:border-b @max-xl:border-border-subtle @max-xl:bg-transparent \" +\n \"@max-xl:px-4 @max-xl:py-3 @max-xl:last:border-b-0\",\n td:\n \"@max-xl:block @max-xl:text-left @max-xl:before:content-none @max-xl:data-[list=title]:min-w-0 @max-xl:data-[list=title]:flex-1 \" +\n \"@max-xl:data-[list=status]:shrink-0 @max-xl:data-[list=away]:hidden @max-xl:data-[card=message]:w-full\",\n select: \"@max-xl:relative @max-xl:right-auto @max-xl:top-auto @max-xl:z-[1] @max-xl:shrink-0 @max-xl:self-center\",\n expander: \"@max-xl:relative @max-xl:z-[1] @max-xl:shrink-0\",\n },\n },\n {\n layout: \"cards\",\n phone: \"list\",\n class: {\n tbody: \"gap-0 p-0\",\n tr: \"flex items-center gap-3 rounded-none border-0 border-b border-border-subtle bg-transparent px-4 py-3 last:border-b-0\",\n td: \"block text-left before:content-none data-[list=title]:min-w-0 data-[list=title]:flex-1 data-[list=status]:shrink-0 data-[list=away]:hidden data-[card=message]:w-full\",\n select: \"relative right-auto top-auto z-[1] shrink-0 self-center\",\n expander: \"relative z-[1] shrink-0\",\n },\n },\n ],\n defaultVariants: { layout: \"auto\", density: \"comfortable\", sticky: false, striped: false, typed: false, phone: \"cards\" },\n});\n\n// Column priorities. `priority: 1` (default) is always in the row; a higher number leaves the row when the table's own\n// width (a container query, not the window's) falls under its tier and goes to the row's detail — the same\n// `@container` that turns the table into cards. Written out in full: Tailwind finds a class only as a whole string.\n// priority 2 → 42rem · 3 → 48rem · 4 → 56rem · 5 → 64rem · 6 → 72rem · 7 → 80rem\n// On the cards (under 36rem), priority 2 stays on the card's face and 3+ go to its detail.\ntype Priority = 2 | 3 | 4 | 5 | 6 | 7;\ntype ByLayout = { auto: Record<Priority, string>; table: Record<Priority, string>; cards: Record<Priority, string> };\nconst NO_CLASS: Record<Priority, string> = { 2: \"\", 3: \"\", 4: \"\", 5: \"\", 6: \"\", 7: \"\" };\n/** The cell of a column that leaves the row. */\nconst LEAVES: ByLayout = {\n auto: { 2: \"@xl:@max-2xl:hidden!\", 3: \"@max-3xl:hidden!\", 4: \"@max-4xl:hidden!\", 5: \"@max-5xl:hidden!\", 6: \"@max-6xl:hidden!\", 7: \"@max-7xl:hidden!\" },\n table: { 2: \"@max-2xl:hidden!\", 3: \"@max-3xl:hidden!\", 4: \"@max-4xl:hidden!\", 5: \"@max-5xl:hidden!\", 6: \"@max-6xl:hidden!\", 7: \"@max-7xl:hidden!\" },\n cards: { 2: \"\", 3: \"hidden!\", 4: \"hidden!\", 5: \"hidden!\", 6: \"hidden!\", 7: \"hidden!\" },\n};\n/** Its header (the cards keep the sort buttons). */\nconst LEAVES_HEAD: ByLayout = {\n auto: { 2: \"@xl:@max-2xl:hidden!\", 3: \"@xl:@max-3xl:hidden!\", 4: \"@xl:@max-4xl:hidden!\", 5: \"@xl:@max-5xl:hidden!\", 6: \"@xl:@max-6xl:hidden!\", 7: \"@xl:@max-7xl:hidden!\" },\n table: LEAVES.table,\n cards: NO_CLASS,\n};\n/** Its line in the row's detail: shown exactly when the cell is not. */\nconst IN_DETAIL: ByLayout = {\n auto: { 2: \"hidden @xl:@max-2xl:grid\", 3: \"hidden @max-3xl:grid\", 4: \"hidden @max-4xl:grid\", 5: \"hidden @max-5xl:grid\", 6: \"hidden @max-6xl:grid\", 7: \"hidden @max-7xl:grid\" },\n table: { 2: \"hidden @max-2xl:grid\", 3: \"hidden @max-3xl:grid\", 4: \"hidden @max-4xl:grid\", 5: \"hidden @max-5xl:grid\", 6: \"hidden @max-6xl:grid\", 7: \"hidden @max-7xl:grid\" },\n cards: { 2: \"hidden\", 3: \"grid\", 4: \"grid\", 5: \"grid\", 6: \"grid\", 7: \"grid\" },\n};\n/** The button that opens the detail, and its panel, keyed by the highest priority of the table: seen only when something left the row. */\nconst TOGGLE: ByLayout = {\n auto: { 2: \"hidden @xl:@max-2xl:inline-flex\", 3: \"hidden @max-3xl:inline-flex\", 4: \"hidden @max-4xl:inline-flex\", 5: \"hidden @max-5xl:inline-flex\", 6: \"hidden @max-6xl:inline-flex\", 7: \"hidden @max-7xl:inline-flex\" },\n table: { 2: \"hidden @max-2xl:inline-flex\", 3: \"hidden @max-3xl:inline-flex\", 4: \"hidden @max-4xl:inline-flex\", 5: \"hidden @max-5xl:inline-flex\", 6: \"hidden @max-6xl:inline-flex\", 7: \"hidden @max-7xl:inline-flex\" },\n cards: { 2: \"hidden\", 3: \"inline-flex\", 4: \"inline-flex\", 5: \"inline-flex\", 6: \"inline-flex\", 7: \"inline-flex\" },\n};\nconst PANEL: ByLayout = {\n auto: { 2: \"hidden @xl:@max-2xl:block\", 3: \"hidden @max-3xl:block\", 4: \"hidden @max-4xl:block\", 5: \"hidden @max-5xl:block\", 6: \"hidden @max-6xl:block\", 7: \"hidden @max-7xl:block\" },\n table: { 2: \"hidden @max-2xl:block\", 3: \"hidden @max-3xl:block\", 4: \"hidden @max-4xl:block\", 5: \"hidden @max-5xl:block\", 6: \"hidden @max-6xl:block\", 7: \"hidden @max-7xl:block\" },\n cards: { 2: \"hidden\", 3: \"block\", 4: \"block\", 5: \"block\", 6: \"block\", 7: \"block\" },\n};\n\n// The list rows (`phone=\"list\"`): the facts line under the title, the columns that go to the row's detail (every\n// priority-1 column that is neither the title nor a status), the button and the panel that show them, the title's link\n// stretched over the row.\nconst LIST_FACTS = { auto: \"hidden @max-xl:mt-0.5 @max-xl:block @max-xl:truncate text-xs font-normal text-fg-secondary\", table: \"hidden\", cards: \"mt-0.5 block truncate text-xs font-normal text-fg-secondary\" } as const;\nconst LIST_IN_DETAIL = { auto: \"hidden @max-xl:grid\", table: \"hidden\", cards: \"grid\" } as const;\nconst LIST_TOGGLE = { auto: \"@max-xl:inline-flex\", table: \"\", cards: \"inline-flex\" } as const;\nconst LIST_PANEL = { auto: \"@max-xl:block\", table: \"\", cards: \"block\" } as const;\nconst LIST_LINK = { auto: \"@max-xl:after:absolute @max-xl:after:inset-0 @max-xl:after:content-['']\", table: \"\", cards: \"after:absolute after:inset-0 after:content-['']\" } as const;\n\nexport type DataTableColumnType = \"title\" | \"badge\" | \"number\" | \"link\" | \"date\" | \"status\" | \"text\";\n\n// What each type does to its cell. Sizes apply to the table layouts only (a card is not a column).\n// title: the column that takes the slack, truncated, full value on hover · badge, status, number, date: as wide as\n// their content, never stretched · link: truncated · text: wraps, two lines.\nconst TYPE_CELL: Record<DataTableColumnType, ByLayoutString> = {\n title: { auto: \"@xl:w-full @xl:max-w-0 @xl:min-w-44\", table: \"w-full max-w-0 min-w-44\", cards: \"\" },\n badge: { auto: \"@xl:w-px\", table: \"w-px\", cards: \"\" },\n status: { auto: \"@xl:w-px @xl:whitespace-nowrap\", table: \"w-px whitespace-nowrap\", cards: \"\" },\n number: { auto: \"@xl:w-px @xl:whitespace-nowrap tabular-nums\", table: \"w-px whitespace-nowrap tabular-nums\", cards: \"tabular-nums\" },\n date: { auto: \"@xl:w-px @xl:whitespace-nowrap tabular-nums\", table: \"w-px whitespace-nowrap tabular-nums\", cards: \"tabular-nums\" },\n link: { auto: \"@xl:min-w-28 @xl:max-w-56\", table: \"min-w-28 max-w-56\", cards: \"\" },\n text: { auto: \"@xl:min-w-36\", table: \"min-w-36\", cards: \"\" },\n};\ntype ByLayoutString = { auto: string; table: string; cards: string };\nconst CLAMP = { 1: \"line-clamp-1\", 2: \"line-clamp-2\", 3: \"line-clamp-3\" } as const;\n\nexport type SortDirection = \"ascending\" | \"descending\";\nexport type DataTableSort = { column: string; direction: SortDirection } | null;\n\n/** What the server needs to fetch a page (`manual` mode): given to `onStateChange` at each change. */\nexport type DataTableQuery = {\n /** The sorted column, or `null`. */\n sort: DataTableSort;\n /** The filters in force, by column id. */\n filters: DataTableFilterState;\n /** The page, from 1 (1 without pagination). */\n page: number;\n /** Rows per page (`Infinity` without pagination). */\n pageSize: number;\n};\n\nexport type DataTableColumn<T> = {\n /** A key of the column (and of the row, for the default value). */\n id: string;\n /** The column's name, passed translated: the header, the label of the value in a card, the filter's name. */\n header: string;\n /** What a cell shows. Default: the value as text. */\n cell?: (row: T) => React.ReactNode;\n /** The value sorted, filtered, grouped and exported. Default `row[id]`. */\n value?: (row: T) => CellValue;\n /** The header becomes a sort button (ascending → descending → none). */\n sortable?: boolean;\n /** How `DataTableFilters` filters it: `text` (a search), `facet` (values to choose), `range` (numbers between bounds). */\n filter?: \"text\" | \"facet\" | \"range\";\n /** The choices of a `facet` filter, with their words (and counts from the server). Default: the values found in the rows. */\n options?: readonly { value: string; label: string; count?: number }[];\n /** The rows can be grouped by this column (`groupBy`). */\n groupable?: boolean;\n /** What a group's row shows in this column, from the group's rows (a sum, a count). */\n aggregate?: (rows: readonly T[]) => React.ReactNode;\n /** Text alignment: `end` for amounts and counts. */\n align?: \"start\" | \"center\" | \"end\";\n /** The width, in px (the starting width when `resizing`). */\n width?: number;\n /** The narrowest the column may be, in px (also what a resized one may shrink to). Default 64. */\n minWidth?: number;\n /** In a card: `title` (the heading of the card), `label` (default: \"Header value\"), `hidden`. */\n card?: \"title\" | \"label\" | \"hidden\";\n /** Hides the header visually (an actions column), keeping it for screen readers. */\n headerHidden?: boolean;\n /** Listed in `DataTableColumnsMenu`, so a person can hide it. Default `true`. */\n hideable?: boolean;\n /**\n * What the column holds, which sizes and aligns it: `title` (the name, takes the slack, truncated, `subtitle` under it in\n * mono — and the card's heading), `badge` · `status` (as wide as the badge, never stretched), `number` (end-aligned,\n * tabular), `date`, `link` (truncated, `href`), `text` (wraps, two lines). Untyped: as before.\n */\n type?: DataTableColumnType;\n /**\n * 1 (default) always in the row; 2 to 7 leave it when the table is narrower than 42 · 48 · 56 · 64 · 72 · 80 rem and\n * go to the row's detail (a chevron opens it); under 36 rem (cards) 2 stays on the card, 3+ go to its detail. In the phone's\n * list rows (`phone=\"list\"`), the 2s are joined as the line of facts under the title.\n */\n priority?: 1 | 2 | 3 | 4 | 5 | 6 | 7;\n /** `title`: the line under the name (an id), in mono. */\n subtitle?: (row: T) => React.ReactNode;\n /** `link`: where the value leads. `title`: the row's page — the name becomes its link (the whole row, in the phone's list rows). */\n href?: (row: T) => string | undefined;\n /** `number`: the unit after the value (muted). */\n unit?: string;\n /** The widest the column may be in the table layouts, in px; longer text is clamped, the full value on hover. */\n maxWidth?: number;\n /** One line only, truncated (the full value on hover). */\n nowrap?: boolean;\n /** Lines of text kept before the ellipsis (default 2 for `text`). */\n clamp?: 1 | 2 | 3;\n};\n\nexport type DataTableLabels = {\n /** The checkbox of the header (\"Select all rows\"). */\n selectAll: string;\n /** The checkbox of a row: `(name) => \"Select \" + name`, the name from `rowLabel`. */\n selectRow: (name: string) => string;\n /** Read while the rows load (\"Loading\"). */\n loading: string;\n /** The default empty state (\"Nothing to show\"). */\n empty: string;\n /** The header of the column of the expand buttons, for screen readers (\"Details\"). */\n details: string;\n /** The button that opens a row: `(name) => \"Show details of \" + name`. */\n expandRow: (name: string) => string;\n /** The button of a group's row: `(value, count) => value + \", \" + count + \" rows\"`. */\n group: (value: string, count: number) => string;\n /** The handle that resizes a column: `(header) => \"Resize \" + header`. */\n resize: (header: string) => string;\n /** The count of results under the filters: `(count) => count + \" rows\"`. */\n results: (count: number) => string;\n /** The accessible name of the filters' bar (\"Filter the table\"). */\n filters: string;\n /** \"Clear filters\". */\n clearFilters: string;\n /** A filter's chip remove button: `(label) => \"Remove \" + label`. */\n removeFilter: (label: string) => string;\n /** The words of a filter in force: `(header, value) => header + \": \" + value`. */\n activeFilter: (header: string, value: string) => string;\n /** A `text` filter's field: `(header) => \"Search \" + header`. */\n search: (header: string) => string;\n /** The lower bound of a `range` filter: `(header) => header + \" from\"`. */\n rangeFrom: (header: string) => string;\n /** The upper bound of a `range` filter: `(header) => header + \" to\"`. */\n rangeTo: (header: string) => string;\n /** The button of the columns menu (\"Columns\"). */\n columns: string;\n /** The button that opens what left the row: `(name) => \"Show more about \" + name`. */\n showMore: (name: string) => string;\n /** The export button (\"Export CSV\"). */\n export: string;\n /** The words of the pagination under the table. */\n pagination?: Partial<PaginationLabels>;\n /** The words of the bar of a selection (`bulkActions`). */\n selection?: Partial<SelectionBarLabels>;\n};\n\nexport const dataTableLabels: DataTableLabels = {\n selectAll: \"Select all rows\",\n selectRow: (name) => `Select ${name}`,\n loading: \"Loading\",\n empty: \"Nothing to show\",\n details: \"Details\",\n expandRow: (name) => `Show details of ${name}`,\n group: (value, count) => `${value}, ${count} ${count === 1 ? \"row\" : \"rows\"}`,\n resize: (header) => `Resize ${header}`,\n results: (count) => `${count.toLocaleString(\"en\")} ${count === 1 ? \"row\" : \"rows\"}`,\n filters: \"Filter the table\",\n clearFilters: \"Clear filters\",\n removeFilter: (label) => `Remove ${label}`,\n activeFilter: (header, value) => `${header}: ${value}`,\n search: (header) => `Search ${header.toLocaleLowerCase()}`,\n rangeFrom: (header) => `${header} from`,\n rangeTo: (header) => `${header} to`,\n columns: \"Columns\",\n showMore: (name) => `Show more about ${name}`,\n export: \"Export CSV\",\n};\n\nexport type DataTableProps<T> = {\n /** The rows (stable: module scope, state or a query's data). Sorted, filtered and paginated here unless `manual`. */\n rows: readonly T[];\n /** The columns, in order (stable: module scope or `useMemo`). */\n columns: readonly DataTableColumn<T>[];\n /** A stable id per row: the React key, the selection's value, the expansion's key. */\n getRowId: (row: T) => string;\n /** What the table lists (\"Jobs\", \"Your videos\"): its `<caption>`, hidden unless `showCaption`. */\n caption: string;\n /** Shows the caption above the table. */\n showCaption?: boolean;\n\n /** The sorted column (controlled), `null` for none. */\n sort?: DataTableSort;\n /** The sort at first, uncontrolled. */\n defaultSort?: DataTableSort;\n /** Called when a header asks for a new sort. */\n onSortChange?: (sort: DataTableSort) => void;\n\n /** The filters in force (controlled), by column id — what `DataTableFilters` edits. */\n filters?: DataTableFilterState;\n /** The filters at first, uncontrolled. */\n defaultFilters?: DataTableFilterState;\n /** Called with the new filters. */\n onFiltersChange?: (filters: DataTableFilterState) => void;\n\n /**\n * Keeps the sort, the filters and the page in the address (`?clients.sort=…&clients.page=2`): back and forward, a reload\n * and a shared link all land on the same table. Replaces `sort`, `filters` and `page`; needs the router's adapter\n * (`RouteStateProvider`) in a framework.\n */\n routeKey?: string;\n\n /** Adds a checkbox per row and one in the header. */\n selectable?: boolean;\n /** The ids selected (controlled). */\n selected?: readonly string[];\n /** The ids selected at first, uncontrolled. */\n defaultSelected?: readonly string[];\n /** Called with the new selection. */\n onSelectedChange?: (selected: string[]) => void;\n /** The name of a row in its labels (checkbox, expand button). Default: its id. */\n rowLabel?: (row: T) => string;\n /**\n * The actions on the selection, given by the product: the bar (`SelectionBar`) appears under the table while rows are\n * chosen — the count, these actions, « Clear selection » — sticky, docked above the tab bar on a phone. Needs `selectable`.\n */\n bulkActions?: (selection: { selected: string[]; clear: () => void }) => React.ReactNode;\n /** The most rows a bulk call takes (200 for `@krizaka/organize`): the bar says so past it and its actions rest. */\n bulkMax?: number;\n /** What the last bulk change did (\"3 moved, 1 skipped\"), announced politely by the bar. */\n bulkResult?: string;\n\n /** The columns the rows are grouped by, in order (controlled) — each `groupable`. */\n groupBy?: readonly string[];\n /** The grouping at first, uncontrolled. */\n defaultGroupBy?: readonly string[];\n /** Called with the new grouping. */\n onGroupByChange?: (groupBy: string[]) => void;\n\n /** Visible (`true`) or hidden (`false`) columns, by id (controlled); a column not listed is visible. */\n columnVisibility?: Readonly<Record<string, boolean>>;\n /** The visibility at first, uncontrolled. */\n defaultColumnVisibility?: Readonly<Record<string, boolean>>;\n /** Called with the new visibility (`DataTableColumnsMenu`). */\n onColumnVisibilityChange?: (visibility: Record<string, boolean>) => void;\n\n /** Columns that stay in view while the table scrolls sideways: at the start (a name) or the end (actions). */\n pinning?: { start?: readonly string[]; end?: readonly string[] };\n /** Columns can be resized (pointer drag, or the arrow keys on the focused handle). */\n resizing?: boolean;\n\n /** The children of a row (a tree): each row with children gets a button that shows them. */\n getSubRows?: (row: T) => readonly T[] | undefined;\n /** A panel under an opened row (the details of a job): each row gets a button that opens it. */\n renderDetail?: (row: T) => React.ReactNode;\n /** The opened rows and groups (controlled), by id. */\n expanded?: Readonly<Record<string, boolean>>;\n /** The opened rows at first, uncontrolled. */\n defaultExpanded?: Readonly<Record<string, boolean>>;\n /** Called with the opened rows. */\n onExpandedChange?: (expanded: Record<string, boolean>) => void;\n\n /** Rows per page (controlled): turns on the pagination under the table. */\n pageSize?: number;\n /** Rows per page at first, uncontrolled: turns on the pagination under the table. */\n defaultPageSize?: number;\n /** Called with the size chosen in the pagination's select (`pageSizeOptions`). */\n onPageSizeChange?: (pageSize: number) => void;\n /** The sizes the pagination offers (`[10, 25, 50]`). */\n pageSizeOptions?: readonly number[];\n /** The page, from 1 (controlled). */\n page?: number;\n /** The page at first, uncontrolled. Default 1. */\n defaultPage?: number;\n /** Called with the page asked for. */\n onPageChange?: (page: number) => void;\n\n /** The server does the work: the rows are shown as given (sorted, filtered, a single page) — fetch in `onStateChange`. */\n manual?: { sorting?: boolean; filtering?: boolean; pagination?: boolean };\n /** The number of rows on the server (`manual.pagination`): the page count and the results' count. */\n rowCount?: number;\n /** Called with the sort, the filters and the page after each change: the query key of a server table. */\n onStateChange?: (query: DataTableQuery) => void;\n\n /** Rows are loading: skeleton rows (`loadingRows` of them) and `aria-busy`. */\n loading?: boolean;\n /** How many skeleton rows while loading. Default 5. */\n loadingRows?: number;\n /** A failure, shown in place of the rows (an `Alert`, a retry button); announced. */\n error?: React.ReactNode;\n /** Shown when there is no row (an `EmptyState`). Default: `labels.empty`. */\n empty?: React.ReactNode;\n\n /** `auto` (default): a table, cards below 36rem of container width. `table` or `cards` to force one. */\n layout?: \"auto\" | \"table\" | \"cards\";\n /**\n * What a row becomes on a phone (under 36 rem, or always with `layout=\"cards\"`): `cards` (a card per row, its values\n * labelled) or `list` — a list row: the selection's checkbox, the `title` column with its `priority: 2` columns joined as\n * one line of facts, the `status` / `badge` column at the end; the other columns in the row's detail.\n * @default \"cards\"\n */\n phone?: \"cards\" | \"list\";\n /** comfortable (default) · compact — one row height per density. */\n density?: \"comfortable\" | \"compact\";\n /** The header stays at the top of the window while the page scrolls (`--dt-top` on the table, or a number of px, clears a fixed bar). */\n stickyHeader?: boolean | number;\n /** Zebra rows. */\n striped?: boolean;\n /**\n * The table never scrolls sideways by default once its columns have a `type` or a `priority`: what does not fit goes to\n * the row's detail, then to cards. `true` opts in to a sideways scroll instead, with fades at the edges.\n */\n scroll?: boolean;\n /** Keeps the first column in view while the table scrolls sideways (with `scroll`). */\n stickyFirstColumn?: boolean;\n /** Renders only the rows in view, in a scrolling body of `height` px; rows are measured (`estimateRowHeight` is a guess). Forces the table layout. */\n virtualized?: { height: number; estimateRowHeight?: number; overscan?: number };\n\n /** Above the table, inside its frame: `DataTableFilters`, `DataTableColumnsMenu`, `DataTableExport`, actions. */\n toolbar?: React.ReactNode;\n /** Under the table (after the pagination): a total, a note. */\n footer?: React.ReactNode;\n /** The words, passed translated; English by default. */\n labels?: Partial<DataTableLabels>;\n /** Classes merged on the root. */\n className?: string;\n};\n\ntype Context = {\n table: DataTableInstance<object>;\n columns: readonly DataTableColumn<object>[];\n labels: DataTableLabels;\n filters: DataTableFilterState;\n setFilters: (filters: DataTableFilterState) => void;\n /** The rows after the filters (all pages), or the server's count. */\n resultCount: number;\n /** The rows to export: filtered and sorted, every page, without the group rows. */\n exportRows: () => readonly unknown[];\n manualFiltering: boolean;\n};\n\nconst DataTableContext = React.createContext<Context | null>(null);\n\n/**\n * The table a component sits in (`toolbar`, or anything under it): the TanStack Table instance (`table` — the escape\n * hatch for what the props do not cover), the columns, the words, the filters and their setter.\n */\nexport function useDataTable<T extends RowData = object>() {\n const context = React.useContext(DataTableContext);\n if (!context) throw new Error(\"useDataTable: call it inside a DataTable (its `toolbar`, `footer` or a cell)\");\n return context as unknown as Omit<Context, \"table\" | \"columns\" | \"exportRows\"> & {\n table: DataTableInstance<T>;\n columns: readonly DataTableColumn<T>[];\n exportRows: () => readonly T[];\n };\n}\n\n// A card never scrolls sideways, even when untyped columns keep the table's scroller.\nconst CARD_CLIP = { auto: \"@max-xl:overflow-x-clip!\", table: undefined, cards: \"overflow-x-clip!\" } as const;\nconst TRUNCATE = { auto: \"@xl:truncate\", table: \"truncate\", cards: \"\" } as const;\nconst MIN = { auto: \"@xl:min-w-(--dt-min)!\", table: \"min-w-(--dt-min)!\", cards: \"\" } as const;\nconst MAX = { auto: \"@xl:max-w-(--dt-max)!\", table: \"max-w-(--dt-max)!\", cards: \"\" } as const;\n// A sideways scroll asked for (`scroll`): the edges fade where there is more to see.\nconst SHADOWS =\n \"[background:linear-gradient(to_right,var(--kz-surface-1),transparent)_left/24px_100%_no-repeat_local,linear-gradient(to_left,var(--kz-surface-1),transparent)_right/24px_100%_no-repeat_local,linear-gradient(to_right,rgb(0_0_0/0.18),transparent)_left/10px_100%_no-repeat_scroll,linear-gradient(to_left,rgb(0_0_0/0.18),transparent)_right/10px_100%_no-repeat_scroll]\";\nconst ALIGN = { start: \"text-left\", center: \"text-center\", end: \"text-right\" } as const;\nconst NONE: readonly never[] = [];\nconst NO_RECORD: Readonly<Record<string, never>> = {};\ntype Up<S> = S | ((old: S) => S);\nconst apply = <S,>(updater: S | ((old: S) => S), old: S): S => (typeof updater === \"function\" ? (updater as (old: S) => S)(old) : updater);\n\nconst valueOf = <T,>(column: DataTableColumn<T>, row: T): CellValue =>\n column.value ? column.value(row) : ((row as Record<string, unknown>)[column.id] as CellValue);\n\nconst display = (value: CellValue) => (value instanceof Date ? value.toISOString() : String(value ?? \"\"));\n\ntype Layout = \"auto\" | \"table\" | \"cards\";\ntype Styles = ReturnType<typeof dataTable>;\ntype Place = \"title\" | \"status\" | \"facts\" | \"away\" | \"hidden\";\ntype TableHeader<T extends RowData> = ReturnType<DataTableInstance<T>[\"getHeaderGroups\"]>[number][\"headers\"][number];\ntype Pin = { \"data-pin\"?: \"start\" | \"end\"; style?: React.CSSProperties };\n\nconst sortingOf = (sort: DataTableSort) => (sort ? [{ id: sort.column, desc: sort.direction === \"descending\" }] : []);\nconst filterListOf = (filters: DataTableFilterState) => Object.entries(filters).map(([id, value]) => ({ id, value }));\nconst selectionOf = (selected: readonly string[]) => Object.fromEntries(selected.map((id) => [id, true as const]));\n\n// Columns that can leave the row: their lines go to the row's detail, opened by a chevron in the first cell.\nconst priorityOf = <T extends RowData>(column: DataTableColumn<T>): 1 | Priority => (column.priority && column.priority > 1 ? (column.priority as Priority) : 1);\n\n// The list rows' places: the title (the `title` column, else the first), the status at the end, the facts (the 2s) under\n// the title, and the rest away, in the row's detail.\nconst placeOf = <T extends RowData>(titleColumn: DataTableColumn<T> | undefined, column: DataTableColumn<T>): Place => {\n if (column.card === \"hidden\") return \"hidden\";\n if (column === titleColumn) return \"title\";\n if (column.type === \"status\" || column.type === \"badge\") return \"status\";\n return priorityOf(column) === 2 ? \"facts\" : \"away\";\n};\n\nconst cardOf = <T extends RowData>(column: DataTableColumn<T> | undefined) =>\n column?.card === \"title\" || (column && !column.card && column.type === \"title\") ? \"title\" : column?.card === \"hidden\" ? \"hidden\" : undefined;\n\n/** What the cells and the rows need to know about the table they are in. */\ntype View<T extends RowData> = {\n s: Styles;\n L: Layout;\n list: boolean;\n labels: DataTableLabels;\n byId: Map<string, DataTableColumn<T>>;\n titleColumn: DataTableColumn<T> | undefined;\n facts: DataTableColumn<T>[];\n listAway: DataTableColumn<T>[];\n maxPriority: 1 | Priority;\n inlineToggle: boolean;\n hasExpander: boolean;\n detailed: boolean;\n selectable: boolean;\n span: number;\n chosen: Set<string>;\n virtualized: boolean;\n fixedLayout: boolean;\n renderDetail: ((row: T) => React.ReactNode) | undefined;\n rowLabel: ((row: T) => string) | undefined;\n visibleColumns: TableColumn<T>[];\n measureElement: ((node: Element | null) => void) | undefined;\n loading: boolean | undefined;\n loadingCount: number;\n error: React.ReactNode;\n empty: React.ReactNode;\n pageRows: TableRow<T>[];\n windowItems: { index: number }[] | null;\n resizing: boolean | undefined;\n stickyHeader: boolean | number | undefined;\n setSizing: React.Dispatch<React.SetStateAction<Record<string, number>>>;\n allChosen: boolean;\n someChosen: boolean;\n selectableCount: number;\n toggleAll: () => void;\n};\n\nconst nameOf = <T extends RowData>(v: View<T>, row: TableRow<T>) => (v.rowLabel ? v.rowLabel(row.original) : row.id);\n\nconst pin = <T extends RowData>(column: TableColumn<T>): Pin => {\n const position = column.getIsPinned();\n if (!position) return {};\n const offset = position === \"start\" ? column.getStart(\"start\") : column.getAfter(\"end\");\n return { \"data-pin\": position, style: { [\"--dt-pin\" as string]: `${offset}px` } };\n};\n\nconst widthOf = <T extends RowData>(v: View<T>, column: TableColumn<T>): React.CSSProperties | undefined =>\n v.fixedLayout || v.byId.get(column.id)?.width ? { width: column.getSize() } : undefined;\n\n/** A title: a link when the column has addresses, with its subtitle under it. */\nfunction titleContent<T extends RowData>(v: View<T>, column: DataTableColumn<T>, original: T, text: string, cut: string) {\n const sub = column.subtitle?.(original);\n const href = column.href?.(original);\n const link = cn(\"block font-semibold text-fg no-underline hover:underline focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring\", cut, v.list && LIST_LINK[v.L]);\n return (\n <span className=\"block min-w-0\">\n {href ? (\n <a href={href} className={link} title={text}>\n {text}\n </a>\n ) : (\n <span className={cn(\"block font-semibold text-fg\", cut)} title={text}>\n {text}\n </span>\n )}\n {sub ? <span className={cn(\"block font-mono text-xs text-fg-tertiary\", cut)}>{sub}</span> : null}\n </span>\n );\n}\n\nfunction numberContent<T extends RowData>(column: DataTableColumn<T>, value: CellValue, text: string) {\n return (\n <span>\n {typeof value === \"number\" ? value.toLocaleString(\"en\") : text}\n {column.unit ? <span className=\"ms-1 text-fg-secondary\">{column.unit}</span> : null}\n </span>\n );\n}\n\nfunction linkContent<T extends RowData>(column: DataTableColumn<T>, original: T, text: string, cut: string) {\n const href = column.href?.(original);\n if (!href) {\n return (\n <span className={cn(\"block\", cut)} title={text}>\n {text}\n </span>\n );\n }\n return (\n <a href={href} title={text} className={cn(\"block text-fg-accent underline-offset-2 hover:underline\", cut)}>\n {text}\n </a>\n );\n}\n\nfunction plainContent<T extends RowData>(column: DataTableColumn<T>, text: string, cut: string) {\n const lines = column.clamp ?? (column.type === \"text\" ? 2 : undefined);\n if (!column.nowrap && !lines) return text;\n return (\n <span className={column.nowrap ? cn(\"block\", cut || \"truncate\") : CLAMP[lines as 1 | 2 | 3]} title={text}>\n {text}\n </span>\n );\n}\n\n// What a cell shows: the column's `cell`, or its value by type.\nfunction contentOf<T extends RowData>(v: View<T>, column: DataTableColumn<T>, original: T): React.ReactNode {\n if (column.cell) return column.cell(original);\n const value = valueOf(column, original);\n const text = column.type === \"date\" && value instanceof Date ? value.toISOString().slice(0, 10) : display(value);\n const cut = TRUNCATE[v.L];\n switch (column.type) {\n case \"title\":\n return titleContent(v, column, original, text, cut);\n case \"number\":\n return numberContent(column, value, text);\n case \"link\":\n return linkContent(column, original, text, cut);\n default:\n return plainContent(column, text, cut);\n }\n}\n\n// A group's row keeps its value as the title and its aggregates; a facts column is away (its value is in the title's line).\nfunction listPlace<T extends RowData>(v: View<T>, row: TableRow<T> | null, column: DataTableColumn<T>) {\n if (row?.getIsGrouped()) return row.groupingColumnId === column.id ? \"title\" : column.aggregate ? \"status\" : \"away\";\n const place = placeOf(v.titleColumn, column);\n return place === \"facts\" || place === \"hidden\" ? \"away\" : place;\n}\n\n/** The cell of a group row: the group's value as a button that opens it, or the column's aggregate. */\nfunction groupContent<T extends RowData>(v: View<T>, row: TableRow<T>, column: DataTableColumn<T>, columnId: string) {\n const leaves = row\n .getLeafRows()\n .filter((r) => !r.getIsGrouped())\n .map((r) => r.original);\n if (columnId !== row.groupingColumnId) return column.aggregate ? column.aggregate(leaves) : null;\n const value = display(row.groupingValue as CellValue);\n return (\n <button type=\"button\" className={v.s.toggle({ className: \"px-1.5 font-semibold text-fg\" })} aria-expanded={row.getIsExpanded()} onClick={row.getToggleExpandedHandler()}>\n <ChevronGlyph direction=\"right\" className=\"h-4 w-4\" />\n {v.labels.group(value, leaves.length)}\n </button>\n );\n}\n\n/** The list row's title cell: the title, and under it the facts joined by a dot. */\nfunction withFacts<T extends RowData>(v: View<T>, content: React.ReactNode, original: T) {\n return (\n <span className=\"block min-w-0\">\n {content}\n <span data-facts=\"\" className={LIST_FACTS[v.L]}>\n {v.facts.map((c, i) => (\n <React.Fragment key={c.id}>\n {i > 0 ? <span aria-hidden>{\" · \"}</span> : null}\n {contentOf(v, c, original)}\n </React.Fragment>\n ))}\n </span>\n </span>\n );\n}\n\n/** The first cell with its chevron, when the columns that left the row are shown in its detail. */\nfunction withToggle<T extends RowData>(v: View<T>, content: React.ReactNode, row: TableRow<T>) {\n const shown = v.maxPriority > 1 ? TOGGLE[v.L][v.maxPriority as Priority] : \"hidden\";\n return (\n <span className=\"flex min-w-0 items-center gap-1\">\n <button\n type=\"button\"\n className={v.s.toggle({ className: cn(shown, v.listAway.length > 0 && LIST_TOGGLE[v.L], v.list && \"relative z-[1]\") })}\n aria-expanded={row.getIsExpanded()}\n aria-label={v.labels.showMore(nameOf(v, row))}\n onClick={row.getToggleExpandedHandler()}\n >\n <ChevronGlyph direction=\"right\" className=\"h-4 w-4\" />\n </button>\n <span className=\"min-w-0 flex-1\">{content}</span>\n </span>\n );\n}\n\nfunction bodyContent<T extends RowData>(v: View<T>, row: TableRow<T>, column: DataTableColumn<T>, first: boolean) {\n let content = contentOf(v, column, row.original);\n if (v.list && column === v.titleColumn && v.facts.length > 0) content = withFacts(v, content, row.original);\n if (first && v.inlineToggle) content = withToggle(v, content, row);\n return content;\n}\n\nfunction cellClass<T extends RowData>(v: View<T>, column: DataTableColumn<T>) {\n const level = priorityOf(column);\n const type = column.type;\n return [\n ALIGN[column.align ?? (type === \"number\" ? \"end\" : \"start\")],\n type ? TYPE_CELL[type][v.L] : \"\",\n level > 1 ? LEAVES[v.L][level as Priority] : \"\",\n (type || column.priority) && column.minWidth !== undefined ? MIN[v.L] : \"\",\n column.maxWidth !== undefined ? MAX[v.L] : \"\",\n ].join(\" \");\n}\n\nfunction cardRole<T extends RowData>(v: View<T>, row: TableRow<T>, column: DataTableColumn<T>, columnId: string) {\n if (v.list) return column.card === \"hidden\" ? \"hidden\" : undefined;\n if (!row.getIsGrouped()) return cardOf(column);\n if (columnId === row.groupingColumnId) return \"title\";\n return column.aggregate ? undefined : \"hidden\";\n}\n\nfunction cellStyle<T extends RowData>(row: TableRow<T>, column: DataTableColumn<T>, first: boolean, base: React.CSSProperties | undefined): React.CSSProperties {\n const indent = first && row.depth > 0 && !row.getIsGrouped();\n return {\n ...base,\n ...(column.minWidth !== undefined ? { [\"--dt-min\" as string]: `${column.minWidth}px` } : {}),\n ...(column.maxWidth !== undefined ? { [\"--dt-max\" as string]: `${column.maxWidth}px` } : {}),\n ...(indent ? { paddingInlineStart: `${1 + row.depth * 1.25}rem` } : {}),\n };\n}\n\nfunction dataCell<T extends RowData>(v: View<T>, row: TableRow<T>, cell: TableCell<T>, first: boolean) {\n const column = v.byId.get(cell.column.id);\n if (!column) return null;\n const { style, ...pinnedProps } = pin(cell.column);\n const content = row.getIsGrouped() ? groupContent(v, row, column, cell.column.id) : bodyContent(v, row, column, first);\n return (\n <td\n role=\"cell\"\n key={cell.id}\n data-label={column.header}\n data-card={cardRole(v, row, column, cell.column.id)}\n data-list={v.list ? listPlace(v, row, column) : undefined}\n {...pinnedProps}\n className={v.s.td({ className: cellClass(v, column) })}\n style={cellStyle(row, column, first, style)}\n >\n {content}\n </td>\n );\n}\n\n/** The panel under an opened row: the columns that left the row, then the host's own detail. */\nfunction detailRow<T extends RowData>(v: View<T>, row: TableRow<T>) {\n const left = v.visibleColumns.filter((c) => {\n const column = v.byId.get(c.id) as DataTableColumn<T>;\n return priorityOf(column) > 1 || v.listAway.includes(column);\n });\n const { L, s, renderDetail } = v;\n const panel = cn(\"px-4 py-4\", v.maxPriority > 1 ? PANEL[L][v.maxPriority as Priority] : \"hidden\", v.listAway.length > 0 && LIST_PANEL[L]);\n return wideRow(\n v,\n renderDetail ? s.detail() : \"bg-surface-0 p-0 text-left\",\n <>\n {left.length > 0 ? (\n <dl className={cn(\"m-0 grid gap-3 text-left\", renderDetail ? \"mb-4\" : panel)}>\n {left.map((c) => {\n const column = v.byId.get(c.id) as DataTableColumn<T>;\n const place = v.listAway.includes(column) ? LIST_IN_DETAIL[L] : IN_DETAIL[L][priorityOf(column) as Priority];\n return (\n <div key={c.id} className={cn(place, \"grid-cols-[minmax(5rem,8rem)_minmax(0,1fr)] items-baseline gap-3\")}>\n <dt className=\"text-xs font-semibold text-fg-secondary\">{column.header}</dt>\n <dd className=\"m-0 min-w-0 text-sm text-fg\">{contentOf(v, column, row.original)}</dd>\n </div>\n );\n })}\n </dl>\n ) : null}\n {renderDetail ? renderDetail(row.original) : null}\n </>,\n );\n}\n\n/** The leading cells of a row: its checkbox, then the button that opens it. */\nfunction rowLeadCells<T extends RowData>(v: View<T>, row: TableRow<T>, isChosen: boolean) {\n const { s, labels } = v;\n const grouped = row.getIsGrouped();\n const canExpand = !grouped && (v.renderDetail ? true : row.getCanExpand());\n return (\n <>\n {v.selectable && (\n <td role=\"cell\" className={s.td({ className: s.select() })}>\n {grouped ? null : <Checkbox checked={isChosen} onCheckedChange={() => row.toggleSelected()} aria-label={labels.selectRow(nameOf(v, row))} />}\n </td>\n )}\n {v.hasExpander && (\n <td role=\"cell\" className={s.td({ className: s.expander() })}>\n {canExpand ? (\n <button type=\"button\" className={s.toggle()} aria-expanded={row.getIsExpanded()} aria-label={labels.expandRow(nameOf(v, row))} onClick={row.getToggleExpandedHandler()}>\n <ChevronGlyph direction=\"right\" className=\"h-4 w-4\" />\n </button>\n ) : null}\n </td>\n )}\n </>\n );\n}\n\nfunction renderRow<T extends RowData>(v: View<T>, row: TableRow<T>, index: number) {\n const isChosen = v.chosen.has(row.id);\n const grouped = row.getIsGrouped();\n const showDetail = v.detailed && !grouped && row.getIsExpanded() && !v.virtualized;\n const main = (\n <tr\n role=\"row\"\n data-index={v.measureElement ? index : undefined}\n ref={v.measureElement}\n aria-rowindex={v.virtualized ? index + 2 : undefined}\n data-state={isChosen ? \"selected\" : undefined}\n data-group={grouped ? \"\" : undefined}\n className={v.s.tr({ className: grouped ? v.s.groupRow() : undefined })}\n >\n {rowLeadCells(v, row, isChosen)}\n {row.getVisibleCells().map((cell, i) => dataCell(v, row, cell, i === 0))}\n </tr>\n );\n // One Fragment keyed by the row either way: opening a row keeps its button (and the focus on it).\n return (\n <React.Fragment key={row.id}>\n {main}\n {showDetail ? detailRow(v, row) : null}\n </React.Fragment>\n );\n}\n\n/** A full-width row: a message, or the opened row's detail. */\nfunction wideRow<T extends RowData>(v: View<T>, tdClass: string, children: React.ReactNode) {\n return (\n <tr role=\"row\" className={v.s.tr({ className: \"hover:bg-transparent\" })}>\n <td role=\"cell\" colSpan={v.span} data-card=\"message\" className={v.s.td({ className: tdClass })}>\n {children}\n </td>\n </tr>\n );\n}\n\nfunction messageRow<T extends RowData>(v: View<T>, content: React.ReactNode, alert?: boolean) {\n return wideRow(v, v.s.message(), alert ? <div role=\"alert\">{content}</div> : content);\n}\n\nfunction skeletonRows<T extends RowData>(v: View<T>, count: number) {\n const { s, list } = v;\n return Array.from({ length: count }, (_, i) => (\n <tr role=\"row\" key={`loading-${i}`} aria-hidden className={s.tr()}>\n {v.selectable && <td role=\"cell\" className={s.td({ className: s.select() })} />}\n {v.hasExpander && <td role=\"cell\" className={s.td({ className: s.expander() })} />}\n {v.visibleColumns.map((column) => (\n <td role=\"cell\" key={column.id} data-card={list ? undefined : cardOf(v.byId.get(column.id))} data-list={list ? listPlace(v, null, v.byId.get(column.id) as DataTableColumn<T>) : undefined} className={s.td()}>\n <div className={s.skeleton()} />\n </td>\n ))}\n </tr>\n ));\n}\n\nfunction bodyRows<T extends RowData>(v: View<T>) {\n const { pageRows: rows, windowItems } = v;\n if (v.loading) return skeletonRows(v, v.loadingCount);\n if (v.error) return messageRow(v, v.error, true);\n if (rows.length === 0) return messageRow(v, v.empty ?? v.labels.empty);\n if (windowItems) return windowItems.map((item) => renderRow(v, rows[item.index] as TableRow<T>, item.index));\n return rows.map((row, i) => renderRow(v, row, i));\n}\n\nfunction headerLabel<T extends RowData>(v: View<T>, header: TableHeader<T>, column: DataTableColumn<T>, direction: SortDirection | undefined) {\n if (column.sortable) {\n return (\n <button type=\"button\" aria-pressed={Boolean(direction)} className={v.s.sortButton()} onClick={() => header.column.toggleSorting(undefined, false)}>\n {column.header}\n <SortGlyph direction={direction} className=\"h-3.5 w-3.5\" />\n </button>\n );\n }\n return column.headerHidden ? <span className=\"sr-only\">{column.header}</span> : column.header;\n}\n\nfunction headerCell<T extends RowData>(v: View<T>, header: TableHeader<T>) {\n const column = v.byId.get(header.column.id);\n if (!column) return null;\n const sorted = header.column.getIsSorted();\n const direction: SortDirection | undefined = sorted === \"asc\" ? \"ascending\" : sorted === \"desc\" ? \"descending\" : undefined;\n const { style, ...pinnedProps } = pin(header.column);\n const level = priorityOf(column);\n const top = typeof v.stickyHeader === \"number\" ? { [\"--dt-top\" as string]: `${v.stickyHeader}px` } : {};\n return (\n <th\n role=\"columnheader\"\n scope=\"col\"\n key={header.id}\n aria-sort={column.sortable ? (direction ?? \"none\") : undefined}\n data-keep={column.sortable ? \"\" : undefined}\n {...pinnedProps}\n className={v.s.th({ className: cn(ALIGN[column.align ?? (column.type === \"number\" ? \"end\" : \"start\")], level > 1 && LEAVES_HEAD[v.L][level as Priority]) })}\n style={{ ...style, ...top, ...widthOf(v, header.column) }}\n >\n {headerLabel(v, header, column, direction)}\n {v.resizing && header.column.getCanResize() ? (\n <ResizeHandle\n label={v.labels.resize(column.header)}\n size={header.column.getSize()}\n min={column.minWidth ?? 64}\n resizing={header.column.getIsResizing()}\n className={v.s.resizer()}\n onPointerStart={header.getResizeHandler()}\n onSize={(size) => v.setSizing((old) => ({ ...old, [header.column.id]: size }))}\n />\n ) : null}\n </th>\n );\n}\n\nfunction headerRow<T extends RowData>(v: View<T>, headers: TableHeader<T>[]) {\n const { s, labels } = v;\n return (\n <tr role=\"row\" aria-rowindex={v.virtualized ? 1 : undefined} className={s.headRow()}>\n {v.selectable && (\n <th role=\"columnheader\" scope=\"col\" data-keep=\"\" className={s.th({ className: s.select() })}>\n <Checkbox\n checked={v.allChosen ? true : v.someChosen ? \"indeterminate\" : false}\n onCheckedChange={v.toggleAll}\n disabled={v.loading || v.selectableCount === 0}\n aria-label={labels.selectAll}\n />\n </th>\n )}\n {v.hasExpander && (\n <th role=\"columnheader\" scope=\"col\" className={s.th({ className: s.expander() })}>\n <span className=\"sr-only\">{labels.details}</span>\n </th>\n )}\n {headers.map((header) => headerCell(v, header))}\n </tr>\n );\n}\n\n/** The sort, filters, selection, grouping, visibility, opened rows, page and page size — controlled or not — and the address's query. */\nfunction useControlled<T extends RowData>(p: DataTableProps<T>, route: ReturnType<typeof useRouteTable>) {\n const { defaultSort = null, defaultFilters = NO_RECORD, defaultSelected = NONE, defaultGroupBy = NONE, defaultColumnVisibility = NO_RECORD, defaultExpanded = NO_RECORD, defaultPage = 1 } = p;\n const paginated = p.pageSize !== undefined || p.defaultPageSize !== undefined;\n const [sort, setSort] = useControllable<DataTableSort>(route ? route.sort : p.sort, defaultSort, route?.onSortChange ?? p.onSortChange);\n const [filters, setFiltersState] = useControllable<DataTableFilterState>(route ? route.filters : p.filters, defaultFilters, route?.onFiltersChange ?? p.onFiltersChange);\n const [selected, setSelected] = useControllable<readonly string[]>(p.selected, defaultSelected, p.onSelectedChange as (next: readonly string[]) => void);\n const [groupBy, setGroupBy] = useControllable<readonly string[]>(p.groupBy, defaultGroupBy, p.onGroupByChange as (next: readonly string[]) => void);\n const [visibility, setVisibility] = useControllable<Readonly<Record<string, boolean>>>(p.columnVisibility, defaultColumnVisibility, p.onColumnVisibilityChange as (next: Readonly<Record<string, boolean>>) => void);\n const [expanded, setExpanded] = useControllable<Readonly<Record<string, boolean>>>(p.expanded, defaultExpanded, p.onExpandedChange as (next: Readonly<Record<string, boolean>>) => void);\n const [pageSize, setPageSize] = useControllable<number>(p.pageSize, p.defaultPageSize ?? Number.POSITIVE_INFINITY, p.onPageSizeChange);\n const [page, setPage] = useControllable<number>(route ? route.page : p.page, defaultPage, route?.onPageChange ?? p.onPageChange);\n return { paginated, sort, setSort, filters, setFiltersState, selected, setSelected, groupBy, setGroupBy, visibility, setVisibility, expanded, setExpanded, pageSize, setPageSize, page, setPage };\n}\n\ntype Controlled = ReturnType<typeof useControlled>;\n\n/** One place announces the server's query: after any change of sort, filters, page or page size. */\nfunction useAnnounce<T extends RowData>(p: DataTableProps<T>, c: Controlled, route: ReturnType<typeof useRouteTable>) {\n const { paginated, sort, filters, page, pageSize } = c;\n const { defaultSort = null, defaultFilters = NO_RECORD, defaultPage = 1 } = p;\n const announced = React.useRef(JSON.stringify([defaultSort, defaultFilters, paginated ? defaultPage : 1, paginated ? pageSize : null]));\n const announce = (next: Partial<DataTableQuery>) => {\n const query = { sort, filters, page: paginated ? page : 1, pageSize: paginated ? pageSize : Number.POSITIVE_INFINITY, ...next };\n if (route) announced.current = JSON.stringify([query.sort, query.filters, query.page, paginated ? query.pageSize : null]);\n p.onStateChange?.(query);\n };\n // The address can change under the table (back, forward, a shared link): the server is told the query it now shows,\n // once — a change the table made itself was announced already. A first visit on the defaults says nothing.\n const routeQuery = route ? JSON.stringify([route.sort, route.filters, paginated ? route.page : 1, paginated ? pageSize : null]) : null;\n React.useEffect(() => {\n if (routeQuery === null || routeQuery === announced.current) return;\n announced.current = routeQuery;\n announce({});\n // eslint-disable-next-line react-hooks/exhaustive-deps -- only a change of the address's query announces\n }, [routeQuery]);\n return announce;\n}\n\n/** The changes of the query, each announced; in the address, the sort or the filters reset the page in the same navigation. */\nfunction useQueryChanges<T extends RowData>(p: DataTableProps<T>, c: Controlled, route: ReturnType<typeof useRouteTable>) {\n const announce = useAnnounce(p, c, route);\n const resetPage = () => {\n if (c.paginated && c.page !== 1 && !route) c.setPage(1);\n };\n return {\n changeSort: (next: DataTableSort) => {\n c.setSort(next);\n resetPage();\n announce({ sort: next, page: 1 });\n },\n changeFilters: (next: DataTableFilterState) => {\n c.setFiltersState(next);\n resetPage();\n announce({ filters: next, page: 1 });\n },\n changePage: (next: number) => {\n c.setPage(next);\n announce({ page: next });\n },\n changePageSize: (next: number) => {\n c.setPageSize(next);\n c.setPage(1);\n announce({ pageSize: next, page: 1 });\n },\n };\n}\n\ntype Changes = ReturnType<typeof useQueryChanges>;\n\nconst columnDefs = <T extends RowData>(columns: readonly DataTableColumn<T>[], resizing: boolean | undefined): ColumnDef<typeof features, T>[] =>\n columns.map((column) => ({\n id: column.id,\n accessorFn: (row: T) => valueOf(column, row),\n header: column.header,\n enableSorting: Boolean(column.sortable),\n sortFn: sortByValue as never,\n sortUndefined: \"last\",\n enableColumnFilter: Boolean(column.filter),\n filterFn: (column.filter ? FILTERS[column.filter] : FILTERS.text) as never,\n enableGrouping: Boolean(column.groupable),\n enableHiding: column.hideable !== false,\n enableResizing: Boolean(resizing),\n ...(column.width ? { size: column.width } : {}),\n minSize: column.minWidth ?? 64,\n }));\n\ntype Pinning = { start?: readonly string[]; end?: readonly string[] } | undefined;\n\n/** The table's state handed to the engine, from what the props and the hooks hold. */\nfunction engineState(c: Controlled, rowCount: number, pinned: Pinning, sizing: Record<string, number>, resizeState: ColumnResizingState | undefined) {\n return {\n sorting: sortingOf(c.sort),\n columnFilters: filterListOf(c.filters),\n rowSelection: selectionOf(c.selected),\n grouping: [...c.groupBy],\n columnVisibility: { ...c.visibility },\n expanded: { ...c.expanded },\n pagination: { pageIndex: Math.max(0, c.page - 1), pageSize: c.paginated ? c.pageSize : Math.max(1, rowCount) },\n columnPinning: { start: [...(pinned?.start ?? [])], end: [...(pinned?.end ?? [])] },\n columnSizing: sizing,\n ...(resizeState ? { columnResizing: resizeState } : {}),\n };\n}\n\n/** What the engine tells us changed: each becomes our own state, announced when it is the query. */\nfunction engineHandlers<T extends RowData>(\n c: Controlled,\n changes: Changes,\n setSizing: React.Dispatch<React.SetStateAction<Record<string, number>>>,\n setResizeState: React.Dispatch<React.SetStateAction<ColumnResizingState | undefined>>,\n currentRows: () => TableRow<T>[],\n) {\n return {\n onSortingChange: (updater: Up<ReturnType<typeof sortingOf>>) => {\n const [first] = apply(updater, sortingOf(c.sort));\n changes.changeSort(first ? { column: first.id, direction: first.desc ? \"descending\" : \"ascending\" } : null);\n },\n onColumnFiltersChange: (updater: Up<{ id: string; value: unknown }[]>) => {\n const next = apply(updater, filterListOf(c.filters));\n changes.changeFilters(Object.fromEntries(next.map((f) => [f.id, f.value as FilterValue])));\n },\n onRowSelectionChange: (updater: Up<Record<string, true>>) => {\n const next = apply(updater, selectionOf(c.selected));\n c.setSelected(Object.keys(next).filter((id) => next[id]));\n },\n onGroupingChange: (updater: Up<string[]>) => c.setGroupBy(apply(updater, [...c.groupBy])),\n onColumnVisibilityChange: (updater: Up<Record<string, boolean>>) => c.setVisibility(apply(updater, { ...c.visibility })),\n onExpandedChange: (updater: Up<Record<string, boolean> | true>) => {\n const next = apply<Record<string, boolean> | true>(updater, { ...c.expanded });\n c.setExpanded(next === true ? Object.fromEntries(currentRows().map((r) => [r.id, true])) : next);\n },\n onColumnSizingChange: (updater: Up<Record<string, number>>) => setSizing((old: Record<string, number>) => apply(updater, old)),\n onColumnResizingChange: (updater: Up<ColumnResizingState>) => setResizeState((old) => apply(updater, old as ColumnResizingState)),\n };\n}\n\n/** What the props and the columns say about the table's layout. */\nfunction shapeOf<T extends RowData>(props: DataTableProps<T>) {\n const { columns, phone = \"cards\", virtualized, renderDetail, getSubRows } = props;\n const L: Layout = virtualized ? \"table\" : (props.layout ?? \"auto\");\n const typed = columns.some((c) => c.type || c.priority);\n const list = phone === \"list\" && L !== \"table\";\n const hasExpander = Boolean(renderDetail || getSubRows);\n const maxPriority = columns.reduce<1 | Priority>((max, column) => (priorityOf(column) > max ? priorityOf(column) : max), 1);\n const titleColumn = columns.find((col) => col.card === \"title\" || (!col.card && col.type === \"title\")) ?? columns[0];\n const listAway = list ? columns.filter((col) => placeOf(titleColumn, col) === \"away\" && priorityOf(col) === 1) : [];\n const facts = list ? columns.filter((col) => placeOf(titleColumn, col) === \"facts\") : [];\n const inlineToggle = (maxPriority > 1 || listAway.length > 0) && !hasExpander;\n return { L, typed, list, hasExpander, maxPriority, inlineToggle, detailed: Boolean(renderDetail) || inlineToggle, titleColumn, listAway, facts };\n}\n\n/** The engine, fed by our own state: sizing and resizing live here, everything else in `c`. */\nfunction useEngine<T extends RowData>(props: DataTableProps<T>, c: Controlled, changes: Changes, detailed: boolean) {\n const { rows, columns, getRowId, getSubRows, pinning, resizing, manual, rowCount, stickyFirstColumn } = props;\n const [sizing, setSizing] = React.useState<Record<string, number>>({});\n const [resizeState, setResizeState] = React.useState<ColumnResizingState | undefined>(undefined);\n const defs = React.useMemo(() => columnDefs(columns, resizing), [columns, resizing]);\n const firstId = columns[0]?.id;\n const pinned = stickyFirstColumn && firstId && !pinning?.start?.length ? { ...pinning, start: [firstId] } : pinning;\n const table: DataTableInstance<T> = useTable<typeof features, T>({\n features,\n columns: defs,\n data: rows as T[],\n getRowId: (row) => getRowId(row),\n getSubRows: getSubRows ? (row) => getSubRows(row) as T[] | undefined : undefined,\n getRowCanExpand: detailed ? () => true : undefined,\n state: engineState(c, rows.length, pinned, sizing, resizeState),\n ...engineHandlers<T>(c, changes, setSizing, setResizeState, () => table.getRowModel().rows),\n enableSortingRemoval: true,\n sortDescFirst: false,\n manualSorting: manual?.sorting,\n manualFiltering: manual?.filtering,\n manualPagination: manual?.pagination || !c.paginated,\n rowCount: manual?.pagination ? rowCount : undefined,\n autoResetPageIndex: false,\n autoResetExpanded: false,\n groupedColumnMode: false,\n columnResizeMode: \"onChange\",\n enableRowSelection: (row) => !row.getIsGrouped(),\n }) as unknown as DataTableInstance<T>;\n return { table, pinned, setSizing };\n}\n\n/** The count of results and of pages; a page beyond the last (the filters shrank the list) shows the last one. */\nfunction usePaging<T extends RowData>(props: DataTableProps<T>, c: Controlled, changes: Changes, table: DataTableInstance<T>) {\n const { manual, rowCount, rows, loading } = props;\n const { paginated, page, pageSize } = c;\n const leafCount = (manual?.pagination || manual?.filtering) && rowCount !== undefined ? rowCount : table.getFilteredRowModel().rows.length;\n const pageCount = paginated ? Math.max(1, manual?.pagination ? Math.ceil((rowCount ?? rows.length) / pageSize) : table.getPageCount()) : 1;\n React.useEffect(() => {\n if (paginated && !loading && page > pageCount) changes.changePage(pageCount);\n // eslint-disable-next-line react-hooks/exhaustive-deps -- only when the count of pages drops under the page\n }, [pageCount]);\n return { leafCount, pageCount };\n}\n\n/** What is chosen on this page: the ids that can be, whether all or some are, and the toggle. */\nfunction useChoice<T extends RowData>(pageRows: TableRow<T>[], selected: readonly string[], setSelected: (ids: string[]) => void) {\n const selectableIds = pageRows.filter((r) => !r.getIsGrouped()).map((r) => r.id);\n const chosen = new Set(selected);\n const allChosen = selectableIds.length > 0 && selectableIds.every((id) => chosen.has(id));\n const someChosen = selectableIds.some((id) => chosen.has(id));\n const toggleAll = () => setSelected(allChosen ? selected.filter((id) => !selectableIds.includes(id)) : [...new Set([...selected, ...selectableIds])]);\n return { chosen, allChosen, someChosen, toggleAll, selectableCount: selectableIds.length };\n}\n\n/** The query in the address (or in memory): the sort, the page, the filters. */\nfunction useRoute<T extends RowData>(props: DataTableProps<T>) {\n const { defaultSort, defaultPage, defaultFilters, columns } = props;\n return useRouteTable(props.routeKey, { sort: defaultSort ?? null, page: defaultPage ?? 1, filters: defaultFilters ?? NO_RECORD }, columns.map((c) => c.id));\n}\n\n/** The table element: caption, header and the body between two spacer rows when windowed. */\nfunction tableOf<T extends RowData>(v: View<T>, table: DataTableInstance<T>, caption: string, showCaption: boolean | undefined, before: number, after: number) {\n const { s, labels, virtualized, span, fixedLayout, loading } = v;\n const headers = table.getHeaderGroups().at(-1)?.headers ?? [];\n const spacer = (height: number) => (\n <tr aria-hidden style={{ height }}>\n <td colSpan={span} />\n </tr>\n );\n return (\n <table\n role=\"table\"\n aria-busy={loading || undefined}\n aria-rowcount={virtualized ? v.pageRows.length + 1 : undefined}\n className={s.table({ className: fixedLayout ? \"table-fixed\" : undefined })}\n style={fixedLayout ? { minWidth: table.getTotalSize() + (v.selectable ? 40 : 0) + (v.hasExpander ? 40 : 0) } : undefined}\n >\n <caption className={showCaption ? s.caption() : \"sr-only\"}>\n {caption}\n {loading ? <span className=\"sr-only\">{` — ${labels.loading}`}</span> : null}\n </caption>\n <thead role=\"rowgroup\" className={s.thead({ className: virtualized ? \"sticky top-0 z-10 bg-surface-2\" : undefined })}>\n {headerRow(v, headers as unknown as TableHeader<T>[])}\n </thead>\n <tbody role=\"rowgroup\" className={s.tbody()}>\n {before > 0 && spacer(before)}\n {bodyRows(v)}\n {after > 0 && spacer(after)}\n </tbody>\n </table>\n );\n}\n\n/** The page controls under the table. */\nfunction pager<T extends RowData>(props: DataTableProps<T>, c: Controlled, changes: Changes, pageCount: number, labels: DataTableLabels) {\n const { pageSizeOptions, loading } = props;\n return (\n <Pagination\n page={Math.min(c.page, pageCount)}\n pageCount={pageCount}\n onPageChange={changes.changePage}\n pageSize={pageSizeOptions ? c.pageSize : undefined}\n pageSizeOptions={pageSizeOptions}\n onPageSizeChange={pageSizeOptions ? changes.changePageSize : undefined}\n disabled={loading}\n labels={labels.pagination}\n />\n );\n}\n\n/** A table of records — sort, filters and facets, groups, details, pages, selection, visibility, pinning, resizing — on the client or the server, cards on a phone, windowing for long lists. */\nexport function DataTable<T extends RowData>(props: DataTableProps<T>) {\n const { columns, caption, showCaption, selectable, bulkActions, bulkMax, bulkResult, resizing, renderDetail, rowLabel, toolbar, footer, className, virtualized, loading, stickyHeader, scroll, manual } = props;\n const labels = { ...dataTableLabels, ...props.labels };\n const shape = shapeOf(props);\n const s = dataTable({ layout: shape.L, density: props.density, sticky: Boolean(stickyHeader), striped: Boolean(props.striped), typed: shape.typed, phone: shape.list ? \"list\" : \"cards\" });\n\n const route = useRoute(props);\n const c = useControlled(props, route);\n const changes = useQueryChanges(props, c, route);\n const { table, pinned, setSizing } = useEngine(props, c, changes, shape.detailed);\n const { leafCount, pageCount } = usePaging(props, c, changes, table);\n const pageRows = table.getRowModel().rows;\n const pick = useChoice(pageRows, c.selected, c.setSelected);\n const scroller = React.useRef<HTMLDivElement>(null);\n const win = useWindow(virtualized, loading, pageRows, scroller);\n\n const span = table.getVisibleLeafColumns().length + (selectable ? 1 : 0) + (shape.hasExpander ? 1 : 0);\n const fixedLayout = Boolean(resizing || pinned?.start?.length || pinned?.end?.length);\n const v: View<T> = {\n ...shape, ...pick,\n s, labels, byId: new Map(columns.map((col) => [col.id, col])),\n selectable: Boolean(selectable), span, virtualized: Boolean(virtualized), fixedLayout, renderDetail,\n rowLabel, visibleColumns: table.getVisibleLeafColumns(), measureElement: win.measureElement, loading, loadingCount: props.loadingRows ?? 5, error: props.error, empty: props.empty, pageRows, windowItems: win.items, resizing, stickyHeader, setSizing,\n };\n\n const context: Context = {\n table: table as unknown as DataTableInstance<object>,\n columns: columns as readonly DataTableColumn<object>[],\n labels,\n filters: c.filters,\n setFilters: changes.changeFilters,\n resultCount: leafCount,\n exportRows: () => table.getSortedRowModel().flatRows.filter((r) => !r.getIsGrouped()).map((r) => r.original),\n manualFiltering: Boolean(manual?.filtering),\n };\n\n const tableElement = tableOf(v, table, caption, showCaption, win.before, win.after);\n const sideways = scroll ?? (!shape.typed && !stickyHeader);\n const pagination = c.paginated ? pager(props, c, changes, pageCount, labels) : null;\n\n return (\n <DataTableContext.Provider value={context}>\n <div className={s.root({ className })}>\n {toolbar ? <div className={s.toolbar()}>{toolbar}</div> : null}\n {virtualized ? (\n // A scrolling region the keyboard can reach: Tab lands on it, the arrows scroll it.\n <div\n ref={scroller}\n tabIndex={0}\n role=\"region\"\n aria-label={caption}\n className={s.scroller({ className: \"overflow-y-auto focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring\" })}\n style={{ height: virtualized.height }}\n >\n {tableElement}\n </div>\n ) : (\n <div className={s.scroller({ className: sideways ? (scroll ? SHADOWS : CARD_CLIP[shape.L]) : \"overflow-x-clip\" })}>{tableElement}</div>\n )}\n {selectable && bulkActions ? (\n <SelectionBar count={c.selected.length} max={bulkMax} result={bulkResult} labels={labels.selection} onClear={() => c.setSelected([])}>\n {bulkActions({ selected: [...c.selected], clear: () => c.setSelected([]) })}\n </SelectionBar>\n ) : null}\n {pagination || footer ? (\n <div className={s.footer({ className: \"flex flex-col gap-3\" })}>\n {pagination}\n {footer}\n </div>\n ) : null}\n </div>\n </DataTableContext.Provider>\n );\n}\n\n/** Windowing: the rows in view, between two spacer rows that keep the scroll height. */\nfunction useWindow<T extends RowData>(virtualized: DataTableProps<T>[\"virtualized\"], loading: boolean | undefined, pageRows: TableRow<T>[], scroller: React.RefObject<HTMLDivElement | null>) {\n const fallbacks = useLayoutFallbacks(virtualized?.height ?? 0, virtualized?.estimateRowHeight ?? 44);\n const virtualizer = useVirtualizer({\n ...fallbacks,\n count: pageRows.length,\n getScrollElement: () => scroller.current,\n estimateSize: () => virtualized?.estimateRowHeight ?? 44,\n overscan: virtualized?.overscan ?? 6,\n initialRect: { width: 0, height: virtualized?.height ?? 0 },\n getItemKey: (index) => pageRows[index]?.id ?? index,\n enabled: Boolean(virtualized) && !loading,\n });\n const items = virtualized && !loading ? virtualizer.getVirtualItems() : null;\n const before = items?.[0]?.start ?? 0;\n const after = items && items.length > 0 ? virtualizer.getTotalSize() - (items.at(-1)?.end ?? 0) : 0;\n return { items, before, after, measureElement: items ? virtualizer.measureElement : undefined };\n}\n\n/** The handle on a header's edge: drag it, or focus it and use ← → (Shift for larger steps). */\nfunction ResizeHandle({\n label,\n size,\n min,\n resizing,\n className,\n onPointerStart,\n onSize,\n}: {\n label: string;\n size: number;\n min: number;\n resizing: boolean;\n className: string;\n onPointerStart: (event: unknown) => void;\n onSize: (size: number) => void;\n}) {\n return (\n // A focusable separator is interactive (WAI-ARIA \"window splitter\"): its value is the width, the arrows change it.\n <div\n role=\"separator\"\n aria-orientation=\"vertical\"\n aria-label={label}\n aria-valuenow={Math.round(size)}\n aria-valuemin={min}\n tabIndex={0}\n data-resizing={resizing ? \"\" : undefined}\n className={className}\n onMouseDown={onPointerStart}\n onTouchStart={onPointerStart}\n onClick={(event) => event.stopPropagation()}\n onKeyDown={(event) => {\n const step = event.shiftKey ? 48 : 16;\n if (event.key === \"ArrowLeft\") onSize(Math.max(min, size - step));\n else if (event.key === \"ArrowRight\") onSize(size + step);\n else return;\n event.preventDefault();\n }}\n />\n );\n}\n"
795
795
  },
796
796
  {
797
797
  "path": "data-table/engine.ts",
@@ -831,7 +831,7 @@
831
831
  },
832
832
  {
833
833
  "path": "meta.ts",
834
- "content": "// The documentation of a component, carried by its code: each primitive has a `meta.ts` beside its source\n// (`src/<name>/meta.ts`; a component that exists only in React Native: `src/native/meta/<name>.ts`). Never built into\n// the package: `scripts/build-registry.mjs` reads them into `registry/<name>.json`, which ui.krizaka.com (apps/site) renders as\n// ui.krizaka.com/components/<name>, and `scripts/registry.test.mjs` fails when one is missing or incomplete.\n//\n// Why a typed module and not JSDoc tags: the fields are lists and links (`related`, `whenNotToUse[].use`, examples),\n// which a type checks and a comment does not; the file is plain data (erasable TypeScript), so Node reads it without a\n// compiler, and an editor completes it.\n\n/** Every documented component: the web primitives (one entry of the package each) and the native-only ones. */\nexport type ComponentName =\n | \"notification-preferences\"\n | \"quota-meter\"\n | \"environment-notice\"\n | \"embed-facade\"\n | \"reviews\"\n | \"margin-layout\"\n | \"analysis-report\"\n | \"status-chip\"\n | \"kind-config-editor\"\n | \"agenda\"\n | \"account-settings\"\n | \"drop-overlay\"\n | \"upload-queue\"\n | \"achievement\"\n | \"anatomy-plate\"\n | \"bird-plate\"\n | \"taped-photo\"\n | \"stuck\"\n | \"doodle\"\n | \"signature\"\n | \"grade-stamp\"\n | \"versus-card\"\n | \"speed-lines\"\n | \"site-cahier\"\n | \"text-style\"\n | \"flock\"\n | \"elephant\"\n | \"footnote\"\n | \"page-index\"\n | \"chapter\"\n | \"specimen-tag\"\n | \"action-bar\"\n | \"action-sheet\"\n | \"activity-feed\"\n | \"alert\"\n | \"app-frame\"\n | \"desktop-window\"\n | \"form-flow\"\n | \"grid\"\n | \"list-detail\"\n | \"state-screen\"\n | \"app-header\"\n | \"app-shell\"\n | \"argument-card\"\n | \"audio-player\"\n | \"auth-layout\"\n | \"avatar\"\n | \"badge\"\n | \"button\"\n | \"captcha\"\n | \"card\"\n | \"card-grid\"\n | \"catalogue-page\"\n | \"changelog-page\"\n | \"chat\"\n | \"checkbox\"\n | \"chip\"\n | \"chip-link\"\n | \"chip-row\"\n | \"choice-grid\"\n | \"cn\"\n | \"code-block\"\n | \"combobox\"\n | \"comparison-table\"\n | \"command\"\n | \"component-page\"\n | \"confirm-button\"\n | \"copy-button\"\n | \"money-input\"\n | \"price-catalogue-editor\"\n | \"promo-code-field\"\n | \"contact-page\"\n | \"continue-prompt\"\n | \"countdown\"\n | \"cover-hero\"\n | \"cta-panel\"\n | \"dashboard-layout\"\n | \"data-table\"\n | \"date-picker\"\n | \"decision-list\"\n | \"description-list\"\n | \"detail-layout\"\n | \"dialog\"\n | \"docs-article-page\"\n | \"docs-hub-page\"\n | \"docs-layout\"\n | \"docs-nav\"\n | \"document-viewer\"\n | \"dropdown-menu\"\n | \"empty-state\"\n | \"engine-flow\"\n | \"error-page\"\n | \"fab\"\n | \"field\"\n | \"file-upload\"\n | \"filter-bar\"\n | \"force-update-screen\"\n | \"form\"\n | \"gallery-page\"\n | \"genui\"\n | \"glossary\"\n | \"glossary-term\"\n | \"glow-card\"\n | \"goal-gauge\"\n | \"header\"\n | \"how-it-works-page\"\n | \"image-cropper\"\n | \"image-viewer\"\n | \"kanban\"\n | \"kbd\"\n | \"kpi-explained\"\n | \"landing-page\"\n | \"landscape\"\n | \"legal-page\"\n | \"link-card\"\n | \"list\"\n | \"loader\"\n | \"longform-page\"\n | \"maintenance-screen\"\n | \"map\"\n | \"markdown\"\n | \"waveform\"\n | \"proposal\"\n | \"qr-code\"\n | \"entity-header\"\n | \"collection-switcher\"\n | \"marketing-layout\"\n | \"marquee\"\n | \"mascot-quote\"\n | \"mascot-state\"\n | \"mascots\"\n | \"match-dialog\"\n | \"media-capture\"\n | \"media-grid\"\n | \"language-switch\"\n | \"media-gallery\"\n | \"media-picker\"\n | \"meter\"\n | \"nav-bar\"\n | \"number-ticker\"\n | \"onboarding\"\n | \"opening-hours\"\n | \"otp-input\"\n | \"page\"\n | \"page-header\"\n | \"page-hero\"\n | \"pagination\"\n | \"permission-prompt\"\n | \"photo-grid\"\n | \"pointer-light\"\n | \"popover\"\n | \"pricing-page\"\n | \"product-page\"\n | \"profile-card\"\n | \"progress\"\n | \"promise-card\"\n | \"pull-to-refresh\"\n | \"retro-tv\"\n | \"shop-gallery\"\n | \"radio-group\"\n | \"router\"\n | \"rail-nav\"\n | \"recipes\"\n | \"screen\"\n | \"scroll-stage\"\n | \"search-field\"\n | \"section-backdrop\"\n | \"segmented\"\n | \"separator\"\n | \"service-card\"\n | \"shop\"\n | \"shop-composer\"\n | \"schema-form\"\n | \"settings-layout\"\n | \"account-menu\"\n | \"showcase\"\n | \"step-showcase\"\n | \"site-footer\"\n | \"sites\"\n | \"skeleton\"\n | \"skip-link\"\n | \"slider\"\n | \"slot-picker\"\n | \"slot\"\n | \"spinner\"\n | \"sticky-action\"\n | \"splash-handoff\"\n | \"split-view\"\n | \"stage-banner\"\n | \"stat\"\n | \"usage\"\n | \"status-page\"\n | \"step-progress\"\n | \"stepper\"\n | \"swipe-deck\"\n | \"swipeable-row\"\n | \"switch\"\n | \"tab-bar\"\n | \"tabs\"\n | \"tag-input\"\n | \"tag-selector\"\n | \"terminal-replay\"\n | \"theme\"\n | \"toast\"\n | \"toc\"\n | \"tooltip\"\n | \"tree-view\"\n | \"txt\"\n | \"update-prompt\"\n | \"verified-badge\"\n | \"vertical-video\"\n | \"video-player\"\n | \"video-trimmer\"\n | \"virtual\"\n | \"wall\";\n\n/** Where a component exists: `@krizaka/ui/<name>` (web), `@krizaka/ui/native` (React Native), or both. */\nexport type Platform = \"web\" | \"native\" | \"both\";\n\n/**\n * Why a component is not on a platform — a decision, never a silence (the parity matrix of ui.krizaka.com/platforms):\n * - `gap` (✗): it belongs there and is not built yet; `issue` is the issue that tracks it (`krizaka/krizaka-ui#275`);\n * - `n/a`: it is not meant for that platform (a site's page block on a phone, a swipe on a desktop); `use` names the\n * component that answers there, when one does.\n */\nexport type Absence =\n | { readonly status: \"gap\"; readonly issue: string; readonly reason: string; readonly use?: undefined }\n | { readonly status: \"n/a\"; readonly reason: string; readonly use?: ComponentName; readonly issue?: undefined };\n\n/**\n * Desktop is the Orazaka Mac app (Tauri 2: the system WebView renders the web components — ADR-002). `web`: the web\n * component runs there as it is; `desktop`: it also has a desktop form (a window's title bar, a denser layout…), said in\n * its documentation; otherwise the absence and why.\n */\nexport type DesktopSupport = \"web\" | \"desktop\" | Absence;\n\n/**\n * The three platforms of Krizaka UI — web · native (React Native, Expo) · desktop — for one component. The side a\n * component has is `platforms`; the side it lacks says why here: `native` is required for (and only for) a web-only\n * component, `web` for a native-only one; `desktop` always. `scripts/registry.test.mjs` fails on a missing decision.\n */\nexport interface Parity {\n readonly web?: Absence;\n readonly native?: Absence;\n readonly desktop: DesktopSupport;\n}\n\n/**\n * `experimental`: created for a filed need (ADR-008 §4), it may change or go in any minor until its first consumer imports it; `adoption`\n * names that consumer's issue. `stable`: its API only changes in a major. `beta`: it may still change in a minor. `deprecated`: no product uses it and\n * no work plans to — it still works, says what replaces it, and goes in the major named by `deprecated.removedIn`.\n */\nexport type Status = \"experimental\" | \"stable\" | \"beta\" | \"deprecated\";\n\n/**\n * What a component is for (ADR-008 §3): the twelve domains the documentation, the size budgets and the guards are\n * organised by. The domain is metadata: the entries stay flat (`@krizaka/ui/<name>`). `cahier` is the sites' register\n * (ADR-004): a product never imports it.\n */\nexport type Domain =\n | \"foundations\"\n | \"forms\"\n | \"data-display\"\n | \"navigation-shell\"\n | \"feedback\"\n | \"maps\"\n | \"media\"\n | \"commerce\"\n | \"identity\"\n | \"conversation\"\n | \"page-blocks\"\n | \"cahier\";\n\n/** What a deprecated component says (required when `status` is `deprecated`, absent otherwise). */\nexport interface Deprecation {\n /** The version that deprecated it (`3.6.0`). */\n readonly since: string;\n /** The major that removes it (`4.0.0`). */\n readonly removedIn: string;\n /** What replaces it, when a component does. */\n readonly use?: ComponentName;\n /** Why it goes: no product uses it, no planned work needs it. */\n readonly reason: string;\n}\n\n/**\n * The group of the catalogue. `media`: video, sound, camera, files, cropping. `blocks`: the page blocks — the frame,\n * the hero, sections, cards that lead or argue, decisions, code, calls to act — that every page of a site is made of.\n * `layouts`: the shells of whole screens — an application, a dashboard, settings, sign-in, an object, a list and its\n * item, a site's page, a documentation page — each with its screens. `templates`: the page templates — whole pages of a\n * site (a landing, a product, a docs hub, a long read, a changelog, pricing, status, an error…), each a distinct\n * composition of the blocks, words and content as props.\n */\nexport type Category = \"actions\" | \"forms\" | \"navigation\" | \"overlays\" | \"feedback\" | \"data-display\" | \"media\" | \"blocks\" | \"layouts\" | \"templates\" | \"layout\" | \"foundations\";\n\n/** Why a reader needs a template: the seven intents the templates are grouped by (sidebar sub-headings, catalogue filter). */\nexport type TemplatePurpose = \"convince\" | \"explain\" | \"show\" | \"act\" | \"operate\" | \"converse\" | \"recover\";\n\n/** The groups of templates, in reading order: the title, and the one line that says when to come to that group. */\nexport const templatePurposes = {\n convince: { title: \"Convince\", useWhen: \"You come here when a visitor must decide: a landing, a product, a price, a comparison, a proof.\" },\n explain: { title: \"Explain\", useWhen: \"You come here when a reader must understand: how it works, a documentation hub or article, a changelog, a FAQ, a policy.\" },\n show: { title: \"Show\", useWhen: \"You come here when the work itself is the argument: a gallery, a story, a case study, an object and its details.\" },\n act: { title: \"Act\", useWhen: \"You come here when a person must do something once: reach the team, sign in or up, set up, pay.\" },\n operate: { title: \"Operate\", useWhen: \"You come here when a person works every day: a dashboard, a console with a table, settings, an app shell.\" },\n converse: { title: \"Converse\", useWhen: \"You come here when people talk: an inbox, a chat, comments, a notifications centre.\" },\n recover: { title: \"Recover\", useWhen: \"You come here when the way is blocked: an empty list, an error, a missing page, maintenance, a product still being built.\" },\n} as const satisfies Record<TemplatePurpose, { readonly title: string; readonly useWhen: string }>;\n\n/**\n * A named example: the file `registry/examples/<component>/<name>.tsx` (web) or\n * `registry/examples/<component>/native/<name>.tsx` (React Native) — at most 40 lines, imported by the stories and\n * shown (live, with its code) by the documentation.\n */\ninterface ExampleBase {\n /** The file name, kebab-case (`primary`, `icon-button`). */\n readonly name: string;\n /** A short title (`Primary`, `Icon button`). */\n readonly title: string;\n /** One or two sentences: when this variant is the right one. */\n readonly description: string;\n}\n\n/** A plain example, or a template: a whole screen with its intent (`purpose`) and the user goal its layout serves (`why`). */\nexport type Example =\n | (ExampleBase & { readonly template?: false; readonly purpose?: undefined; readonly why?: undefined })\n | (ExampleBase & {\n /**\n * A template: a whole screen of a product composed from the platform (a layout and its blocks, real words, its\n * phone version thought out), copied as a starting point — at most 160 lines, listed on ui.krizaka.com/templates.\n */\n readonly template: true;\n /** The intent that groups it: why you need this block. */\n readonly purpose: TemplatePurpose;\n /** Why this layout: the user goal it serves, in one sentence. */\n readonly why: string;\n });\n\n/** One platform's side of a component. */\nexport interface PlatformDocs {\n /** The names to import (`[\"Button\", \"IconButton\"]`): from `@krizaka/ui/<name>` on the web, `@krizaka/ui/native` in React Native. */\n readonly imports: readonly string[];\n /** The examples, in reading order; the first one is the component's preview. */\n readonly examples: readonly Example[];\n}\n\n/** The React Native side: the same concept, and what differs from the web API. */\nexport interface NativeDocs extends PlatformDocs {\n /**\n * The entry to import from when it is not `@krizaka/ui/native`: a component that needs an Expo module (an optional\n * peer) has its own, `@krizaka/ui/native/<name>`, so an app that does not use it never installs the module.\n */\n readonly entry?: string;\n /** What differs from the web API (`label` instead of children…); empty for a native-only component. */\n readonly differences: readonly string[];\n /** The React Native entry alone is deprecated while the web one stays (ADR-006 §7); a deprecated component says it once, above. */\n readonly deprecated?: Deprecation;\n}\n\nexport interface KeyboardInteraction {\n /** The keys, as written on a keyboard: `Space`, `Enter`, `Arrow keys`, `Esc`, `Tab`. */\n readonly keys: string;\n /** What they do. */\n readonly action: string;\n}\n\nexport interface ComponentMeta {\n /** The display name: `Button`, `Dropdown menu`. */\n readonly title: string;\n /** One sentence: what it is. */\n readonly summary: string;\n readonly status: Status;\n /** Required for, and only for, a `deprecated` component. */\n readonly deprecated?: Deprecation;\n readonly category: Category;\n /** What it is for: one of the twelve domains (ADR-008 §3). */\n readonly domain: Domain;\n /** The `<repo>#<n>` issue of its first consumer: required for, and only for, an `experimental` component. */\n readonly adoption?: string;\n /** Must match the sides below: `both` ⇔ `web` and `native`. */\n readonly platforms: Platform;\n /** The platforms it is not on, and why; and its desktop form (see `Parity`). */\n readonly parity: Parity;\n /** When to reach for it: concrete situations, one per item. */\n readonly whenToUse: readonly string[];\n /** When not to — and what to use instead (`use`), when another component is the answer. */\n readonly whenNotToUse: readonly { readonly when: string; readonly use?: ComponentName }[];\n /** How to use it well: wording, placement, composition. */\n readonly bestPractices: readonly string[];\n readonly accessibility: {\n /** The keyboard, when it does more than Tab and Enter. */\n readonly keyboard: readonly KeyboardInteraction[];\n /** Roles, names and announcements: what the component does, what the app must provide. */\n readonly notes: readonly string[];\n };\n /** The components a reader of this page should know about. */\n readonly related: readonly ComponentName[];\n readonly web?: PlatformDocs;\n readonly native?: NativeDocs;\n}\n"
834
+ "content": "// The documentation of a component, carried by its code: each primitive has a `meta.ts` beside its source\n// (`src/<name>/meta.ts`; a component that exists only in React Native: `src/native/meta/<name>.ts`). Never built into\n// the package: `scripts/build-registry.mjs` reads them into `registry/<name>.json`, which ui.krizaka.com (apps/site) renders as\n// ui.krizaka.com/components/<name>, and `scripts/registry.test.mjs` fails when one is missing or incomplete.\n//\n// Why a typed module and not JSDoc tags: the fields are lists and links (`related`, `whenNotToUse[].use`, examples),\n// which a type checks and a comment does not; the file is plain data (erasable TypeScript), so Node reads it without a\n// compiler, and an editor completes it.\n\n/** Every documented component: the web primitives (one entry of the package each) and the native-only ones. */\nexport type ComponentName =\n | \"notification-preferences\"\n | \"quota-meter\"\n | \"environment-notice\"\n | \"embed-facade\"\n | \"reviews\"\n | \"margin-layout\"\n | \"analysis-report\"\n | \"status-chip\"\n | \"kind-config-editor\"\n | \"agenda\"\n | \"account-settings\"\n | \"drop-overlay\"\n | \"upload-queue\"\n | \"achievement\"\n | \"anatomy-plate\"\n | \"bird-plate\"\n | \"taped-photo\"\n | \"stuck\"\n | \"doodle\"\n | \"signature\"\n | \"grade-stamp\"\n | \"versus-card\"\n | \"speed-lines\"\n | \"site-cahier\"\n | \"text-style\"\n | \"flock\"\n | \"elephant\"\n | \"footnote\"\n | \"page-index\"\n | \"chapter\"\n | \"specimen-tag\"\n | \"action-bar\"\n | \"action-sheet\"\n | \"activity-feed\"\n | \"alert\"\n | \"app-frame\"\n | \"desktop-window\"\n | \"form-flow\"\n | \"grid\"\n | \"list-detail\"\n | \"state-screen\"\n | \"app-header\"\n | \"app-shell\"\n | \"argument-card\"\n | \"auth-layout\"\n | \"avatar\"\n | \"badge\"\n | \"button\"\n | \"captcha\"\n | \"card\"\n | \"card-grid\"\n | \"catalogue-page\"\n | \"changelog-page\"\n | \"chat\"\n | \"checkbox\"\n | \"chip\"\n | \"chip-link\"\n | \"chip-row\"\n | \"choice-grid\"\n | \"cn\"\n | \"code-block\"\n | \"combobox\"\n | \"comparison-table\"\n | \"command\"\n | \"component-page\"\n | \"confirm-button\"\n | \"copy-button\"\n | \"money-input\"\n | \"price-catalogue-editor\"\n | \"promo-code-field\"\n | \"contact-page\"\n | \"continue-prompt\"\n | \"countdown\"\n | \"cover-hero\"\n | \"cta-panel\"\n | \"dashboard-layout\"\n | \"data-table\"\n | \"date-picker\"\n | \"decision-list\"\n | \"description-list\"\n | \"detail-layout\"\n | \"dialog\"\n | \"docs-article-page\"\n | \"docs-hub-page\"\n | \"docs-layout\"\n | \"docs-nav\"\n | \"document-viewer\"\n | \"dropdown-menu\"\n | \"empty-state\"\n | \"engine-flow\"\n | \"error-page\"\n | \"fab\"\n | \"field\"\n | \"file-upload\"\n | \"filter-bar\"\n | \"force-update-screen\"\n | \"form\"\n | \"gallery-page\"\n | \"genui\"\n | \"glossary\"\n | \"glossary-term\"\n | \"glow-card\"\n | \"goal-gauge\"\n | \"header\"\n | \"image-cropper\"\n | \"image-viewer\"\n | \"kanban\"\n | \"kbd\"\n | \"kpi-explained\"\n | \"landing-page\"\n | \"landscape\"\n | \"legal-page\"\n | \"link-card\"\n | \"list\"\n | \"loader\"\n | \"longform-page\"\n | \"maintenance-screen\"\n | \"map\"\n | \"markdown\"\n | \"waveform\"\n | \"proposal\"\n | \"qr-code\"\n | \"entity-header\"\n | \"collection-switcher\"\n | \"marketing-layout\"\n | \"mascot-quote\"\n | \"mascot-state\"\n | \"mascots\"\n | \"match-dialog\"\n | \"media-capture\"\n | \"language-switch\"\n | \"media-gallery\"\n | \"media-picker\"\n | \"meter\"\n | \"nav-bar\"\n | \"number-ticker\"\n | \"onboarding\"\n | \"opening-hours\"\n | \"otp-input\"\n | \"page\"\n | \"page-header\"\n | \"page-hero\"\n | \"pagination\"\n | \"permission-prompt\"\n | \"pointer-light\"\n | \"popover\"\n | \"pricing-page\"\n | \"product-page\"\n | \"profile-card\"\n | \"progress\"\n | \"promise-card\"\n | \"pull-to-refresh\"\n | \"retro-tv\"\n | \"shop-gallery\"\n | \"radio-group\"\n | \"router\"\n | \"rail-nav\"\n | \"recipes\"\n | \"screen\"\n | \"scroll-stage\"\n | \"search-field\"\n | \"section-backdrop\"\n | \"segmented\"\n | \"separator\"\n | \"service-card\"\n | \"shop\"\n | \"shop-composer\"\n | \"schema-form\"\n | \"settings-layout\"\n | \"account-menu\"\n | \"showcase\"\n | \"step-showcase\"\n | \"site-footer\"\n | \"sites\"\n | \"skeleton\"\n | \"skip-link\"\n | \"slider\"\n | \"slot-picker\"\n | \"slot\"\n | \"spinner\"\n | \"sticky-action\"\n | \"splash-handoff\"\n | \"split-view\"\n | \"stage-banner\"\n | \"stat\"\n | \"usage\"\n | \"status-page\"\n | \"step-progress\"\n | \"stepper\"\n | \"swipe-deck\"\n | \"swipeable-row\"\n | \"switch\"\n | \"tab-bar\"\n | \"tabs\"\n | \"tag-input\"\n | \"tag-selector\"\n | \"terminal-replay\"\n | \"theme\"\n | \"toast\"\n | \"toc\"\n | \"tooltip\"\n | \"tree-view\"\n | \"txt\"\n | \"update-prompt\"\n | \"verified-badge\"\n | \"vertical-video\"\n | \"video-player\"\n | \"video-trimmer\"\n | \"virtual\"\n | \"wall\";\n\n/** Where a component exists: `@krizaka/ui/<name>` (web), `@krizaka/ui/native` (React Native), or both. */\nexport type Platform = \"web\" | \"native\" | \"both\";\n\n/**\n * Why a component is not on a platform — a decision, never a silence (the parity matrix of ui.krizaka.com/platforms):\n * - `gap` (✗): it belongs there and is not built yet; `issue` is the issue that tracks it (`krizaka/krizaka-ui#275`);\n * - `n/a`: it is not meant for that platform (a site's page block on a phone, a swipe on a desktop); `use` names the\n * component that answers there, when one does.\n */\nexport type Absence =\n | { readonly status: \"gap\"; readonly issue: string; readonly reason: string; readonly use?: undefined }\n | { readonly status: \"n/a\"; readonly reason: string; readonly use?: ComponentName; readonly issue?: undefined };\n\n/**\n * Desktop is the Orazaka Mac app (Tauri 2: the system WebView renders the web components — ADR-002). `web`: the web\n * component runs there as it is; `desktop`: it also has a desktop form (a window's title bar, a denser layout…), said in\n * its documentation; otherwise the absence and why.\n */\nexport type DesktopSupport = \"web\" | \"desktop\" | Absence;\n\n/**\n * The three platforms of Krizaka UI — web · native (React Native, Expo) · desktop — for one component. The side a\n * component has is `platforms`; the side it lacks says why here: `native` is required for (and only for) a web-only\n * component, `web` for a native-only one; `desktop` always. `scripts/registry.test.mjs` fails on a missing decision.\n */\nexport interface Parity {\n readonly web?: Absence;\n readonly native?: Absence;\n readonly desktop: DesktopSupport;\n}\n\n/**\n * `experimental`: created for a filed need (ADR-008 §4), it may change or go in any minor until its first consumer imports it; `adoption`\n * names that consumer's issue. `stable`: its API only changes in a major. `beta`: it may still change in a minor. `deprecated`: no product uses it and\n * no work plans to — it still works, says what replaces it, and goes in the major named by `deprecated.removedIn`.\n */\nexport type Status = \"experimental\" | \"stable\" | \"beta\" | \"deprecated\";\n\n/**\n * What a component is for (ADR-008 §3): the twelve domains the documentation, the size budgets and the guards are\n * organised by. The domain is metadata: the entries stay flat (`@krizaka/ui/<name>`). `cahier` is the sites' register\n * (ADR-004): a product never imports it.\n */\nexport type Domain =\n | \"foundations\"\n | \"forms\"\n | \"data-display\"\n | \"navigation-shell\"\n | \"feedback\"\n | \"maps\"\n | \"media\"\n | \"commerce\"\n | \"identity\"\n | \"conversation\"\n | \"page-blocks\"\n | \"cahier\";\n\n/** What a deprecated component says (required when `status` is `deprecated`, absent otherwise). */\nexport interface Deprecation {\n /** The version that deprecated it (`3.6.0`). */\n readonly since: string;\n /** The major that removes it (`4.0.0`). */\n readonly removedIn: string;\n /** What replaces it, when a component does. */\n readonly use?: ComponentName;\n /** Why it goes: no product uses it, no planned work needs it. */\n readonly reason: string;\n}\n\n/**\n * The group of the catalogue. `media`: video, sound, camera, files, cropping. `blocks`: the page blocks — the frame,\n * the hero, sections, cards that lead or argue, decisions, code, calls to act — that every page of a site is made of.\n * `layouts`: the shells of whole screens — an application, a dashboard, settings, sign-in, an object, a list and its\n * item, a site's page, a documentation page — each with its screens. `templates`: the page templates — whole pages of a\n * site (a landing, a product, a docs hub, a long read, a changelog, pricing, status, an error…), each a distinct\n * composition of the blocks, words and content as props.\n */\nexport type Category = \"actions\" | \"forms\" | \"navigation\" | \"overlays\" | \"feedback\" | \"data-display\" | \"media\" | \"blocks\" | \"layouts\" | \"templates\" | \"layout\" | \"foundations\";\n\n/** Why a reader needs a template: the seven intents the templates are grouped by (sidebar sub-headings, catalogue filter). */\nexport type TemplatePurpose = \"convince\" | \"explain\" | \"show\" | \"act\" | \"operate\" | \"converse\" | \"recover\";\n\n/** The groups of templates, in reading order: the title, and the one line that says when to come to that group. */\nexport const templatePurposes = {\n convince: { title: \"Convince\", useWhen: \"You come here when a visitor must decide: a landing, a product, a price, a comparison, a proof.\" },\n explain: { title: \"Explain\", useWhen: \"You come here when a reader must understand: how it works, a documentation hub or article, a changelog, a FAQ, a policy.\" },\n show: { title: \"Show\", useWhen: \"You come here when the work itself is the argument: a gallery, a story, a case study, an object and its details.\" },\n act: { title: \"Act\", useWhen: \"You come here when a person must do something once: reach the team, sign in or up, set up, pay.\" },\n operate: { title: \"Operate\", useWhen: \"You come here when a person works every day: a dashboard, a console with a table, settings, an app shell.\" },\n converse: { title: \"Converse\", useWhen: \"You come here when people talk: an inbox, a chat, comments, a notifications centre.\" },\n recover: { title: \"Recover\", useWhen: \"You come here when the way is blocked: an empty list, an error, a missing page, maintenance, a product still being built.\" },\n} as const satisfies Record<TemplatePurpose, { readonly title: string; readonly useWhen: string }>;\n\n/**\n * A named example: the file `registry/examples/<component>/<name>.tsx` (web) or\n * `registry/examples/<component>/native/<name>.tsx` (React Native) — at most 40 lines, imported by the stories and\n * shown (live, with its code) by the documentation.\n */\ninterface ExampleBase {\n /** The file name, kebab-case (`primary`, `icon-button`). */\n readonly name: string;\n /** A short title (`Primary`, `Icon button`). */\n readonly title: string;\n /** One or two sentences: when this variant is the right one. */\n readonly description: string;\n}\n\n/** A plain example, or a template: a whole screen with its intent (`purpose`) and the user goal its layout serves (`why`). */\nexport type Example =\n | (ExampleBase & { readonly template?: false; readonly purpose?: undefined; readonly why?: undefined })\n | (ExampleBase & {\n /**\n * A template: a whole screen of a product composed from the platform (a layout and its blocks, real words, its\n * phone version thought out), copied as a starting point — at most 160 lines, listed on ui.krizaka.com/templates.\n */\n readonly template: true;\n /** The intent that groups it: why you need this block. */\n readonly purpose: TemplatePurpose;\n /** Why this layout: the user goal it serves, in one sentence. */\n readonly why: string;\n });\n\n/** One platform's side of a component. */\nexport interface PlatformDocs {\n /** The names to import (`[\"Button\", \"IconButton\"]`): from `@krizaka/ui/<name>` on the web, `@krizaka/ui/native` in React Native. */\n readonly imports: readonly string[];\n /** The examples, in reading order; the first one is the component's preview. */\n readonly examples: readonly Example[];\n}\n\n/** The React Native side: the same concept, and what differs from the web API. */\nexport interface NativeDocs extends PlatformDocs {\n /**\n * The entry to import from when it is not `@krizaka/ui/native`: a component that needs an Expo module (an optional\n * peer) has its own, `@krizaka/ui/native/<name>`, so an app that does not use it never installs the module.\n */\n readonly entry?: string;\n /** What differs from the web API (`label` instead of children…); empty for a native-only component. */\n readonly differences: readonly string[];\n /** The React Native entry alone is deprecated while the web one stays (ADR-006 §7); a deprecated component says it once, above. */\n readonly deprecated?: Deprecation;\n}\n\nexport interface KeyboardInteraction {\n /** The keys, as written on a keyboard: `Space`, `Enter`, `Arrow keys`, `Esc`, `Tab`. */\n readonly keys: string;\n /** What they do. */\n readonly action: string;\n}\n\nexport interface ComponentMeta {\n /** The display name: `Button`, `Dropdown menu`. */\n readonly title: string;\n /** One sentence: what it is. */\n readonly summary: string;\n readonly status: Status;\n /** Required for, and only for, a `deprecated` component. */\n readonly deprecated?: Deprecation;\n readonly category: Category;\n /** What it is for: one of the twelve domains (ADR-008 §3). */\n readonly domain: Domain;\n /** The `<repo>#<n>` issue of its first consumer: required for, and only for, an `experimental` component. */\n readonly adoption?: string;\n /** Must match the sides below: `both` ⇔ `web` and `native`. */\n readonly platforms: Platform;\n /** The platforms it is not on, and why; and its desktop form (see `Parity`). */\n readonly parity: Parity;\n /** When to reach for it: concrete situations, one per item. */\n readonly whenToUse: readonly string[];\n /** When not to — and what to use instead (`use`), when another component is the answer. */\n readonly whenNotToUse: readonly { readonly when: string; readonly use?: ComponentName }[];\n /** How to use it well: wording, placement, composition. */\n readonly bestPractices: readonly string[];\n readonly accessibility: {\n /** The keyboard, when it does more than Tab and Enter. */\n readonly keyboard: readonly KeyboardInteraction[];\n /** Roles, names and announcements: what the component does, what the app must provide. */\n readonly notes: readonly string[];\n };\n /** The components a reader of this page should know about. */\n readonly related: readonly ComponentName[];\n readonly web?: PlatformDocs;\n readonly native?: NativeDocs;\n}\n"
835
835
  }
836
836
  ],
837
837
  "dependencies": [
@@ -925,35 +925,35 @@
925
925
  {
926
926
  "name": "defaultColumnVisibility",
927
927
  "type": "Readonly<Record<string, boolean>>",
928
- "default": "{}",
928
+ "default": null,
929
929
  "description": "The visibility at first, uncontrolled.",
930
930
  "required": false
931
931
  },
932
932
  {
933
933
  "name": "defaultExpanded",
934
934
  "type": "Readonly<Record<string, boolean>>",
935
- "default": "{}",
935
+ "default": null,
936
936
  "description": "The opened rows at first, uncontrolled.",
937
937
  "required": false
938
938
  },
939
939
  {
940
940
  "name": "defaultFilters",
941
941
  "type": "Readonly<Record<string, FilterValue>>",
942
- "default": "{}",
942
+ "default": null,
943
943
  "description": "The filters at first, uncontrolled.",
944
944
  "required": false
945
945
  },
946
946
  {
947
947
  "name": "defaultGroupBy",
948
948
  "type": "readonly string[]",
949
- "default": "[]",
949
+ "default": null,
950
950
  "description": "The grouping at first, uncontrolled.",
951
951
  "required": false
952
952
  },
953
953
  {
954
954
  "name": "defaultPage",
955
955
  "type": "number",
956
- "default": "1",
956
+ "default": null,
957
957
  "description": "The page at first, uncontrolled. Default 1.",
958
958
  "required": false
959
959
  },
@@ -967,14 +967,14 @@
967
967
  {
968
968
  "name": "defaultSelected",
969
969
  "type": "readonly string[]",
970
- "default": "[]",
970
+ "default": null,
971
971
  "description": "The ids selected at first, uncontrolled.",
972
972
  "required": false
973
973
  },
974
974
  {
975
975
  "name": "defaultSort",
976
976
  "type": "DataTableSort",
977
- "default": "null",
977
+ "default": null,
978
978
  "description": "The sort at first, uncontrolled.",
979
979
  "required": false
980
980
  },
@@ -1044,7 +1044,7 @@
1044
1044
  {
1045
1045
  "name": "layout",
1046
1046
  "type": "\"table\" | \"auto\" | \"cards\"",
1047
- "default": "auto",
1047
+ "default": null,
1048
1048
  "description": "`auto` (default): a table, cards below 36rem of container width. `table` or `cards` to force one.",
1049
1049
  "required": false
1050
1050
  },
@@ -1058,7 +1058,7 @@
1058
1058
  {
1059
1059
  "name": "loadingRows",
1060
1060
  "type": "number",
1061
- "default": "5",
1061
+ "default": null,
1062
1062
  "description": "How many skeleton rows while loading. Default 5.",
1063
1063
  "required": false
1064
1064
  },