@zonsh/ui 0.0.0 → 0.4.1

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 (425) hide show
  1. package/LICENSE +43 -0
  2. package/README.md +81 -1
  3. package/assets/illustrations/drawing/bracket-construction-dark.svg +77 -0
  4. package/assets/illustrations/drawing/bracket-construction-filled-dark.svg +50 -0
  5. package/assets/illustrations/drawing/bracket-construction-filled.svg +50 -0
  6. package/assets/illustrations/drawing/bracket-construction.svg +77 -0
  7. package/assets/illustrations/drawing/crescent-dark.svg +28 -0
  8. package/assets/illustrations/drawing/crescent-guides-dark.svg +33 -0
  9. package/assets/illustrations/drawing/crescent-guides.svg +33 -0
  10. package/assets/illustrations/drawing/crescent.svg +28 -0
  11. package/assets/illustrations/drawing/eclipse-dark.svg +187 -0
  12. package/assets/illustrations/drawing/eclipse-guides-dark.svg +191 -0
  13. package/assets/illustrations/drawing/eclipse-guides.svg +191 -0
  14. package/assets/illustrations/drawing/eclipse.svg +187 -0
  15. package/assets/illustrations/drawing/elevation-guides-dark.svg +31 -0
  16. package/assets/illustrations/drawing/elevation-guides-plain-dark.svg +9 -0
  17. package/assets/illustrations/drawing/elevation-guides-plain.svg +9 -0
  18. package/assets/illustrations/drawing/elevation-guides.svg +31 -0
  19. package/assets/illustrations/drawing/horizon-dark.svg +30 -0
  20. package/assets/illustrations/drawing/horizon.svg +30 -0
  21. package/assets/illustrations/drawing/nib-study-dark.svg +107 -0
  22. package/assets/illustrations/drawing/nib-study-plain-dark.svg +93 -0
  23. package/assets/illustrations/drawing/nib-study-plain.svg +93 -0
  24. package/assets/illustrations/drawing/nib-study.svg +107 -0
  25. package/assets/illustrations/editorial/assistant-640.webp +0 -0
  26. package/assets/illustrations/editorial/assistant.webp +0 -0
  27. package/assets/illustrations/editorial/automation-640.webp +0 -0
  28. package/assets/illustrations/editorial/automation.webp +0 -0
  29. package/assets/illustrations/editorial/bracket-left-640.webp +0 -0
  30. package/assets/illustrations/editorial/bracket-left.webp +0 -0
  31. package/assets/illustrations/editorial/bracket-right-640.webp +0 -0
  32. package/assets/illustrations/editorial/bracket-right.webp +0 -0
  33. package/assets/illustrations/editorial/custom-software-640.webp +0 -0
  34. package/assets/illustrations/editorial/custom-software.webp +0 -0
  35. package/assets/illustrations/editorial/digitalization-640.webp +0 -0
  36. package/assets/illustrations/editorial/digitalization.webp +0 -0
  37. package/assets/illustrations/editorial/integration-640.webp +0 -0
  38. package/assets/illustrations/editorial/integration.webp +0 -0
  39. package/assets/illustrations/editorial/problem-640.webp +0 -0
  40. package/assets/illustrations/editorial/problem.webp +0 -0
  41. package/assets/illustrations/editorial/process-analysis-640.webp +0 -0
  42. package/assets/illustrations/editorial/process-analysis.webp +0 -0
  43. package/assets/illustrations/editorial/process-concept-640.webp +0 -0
  44. package/assets/illustrations/editorial/process-concept.webp +0 -0
  45. package/assets/illustrations/editorial/process-development-640.webp +0 -0
  46. package/assets/illustrations/editorial/process-development.webp +0 -0
  47. package/assets/illustrations/editorial/process-discovery-640.webp +0 -0
  48. package/assets/illustrations/editorial/process-discovery.webp +0 -0
  49. package/assets/illustrations/editorial/process-maintenance-640.webp +0 -0
  50. package/assets/illustrations/editorial/process-maintenance.webp +0 -0
  51. package/assets/illustrations/editorial/process-prototype-640.webp +0 -0
  52. package/assets/illustrations/editorial/process-prototype.webp +0 -0
  53. package/assets/illustrations/editorial/process-testing-640.webp +0 -0
  54. package/assets/illustrations/editorial/process-testing.webp +0 -0
  55. package/assets/illustrations/iso/automation-dark.svg +6 -0
  56. package/assets/illustrations/iso/automation.svg +6 -0
  57. package/assets/illustrations/iso/bar-chart-dark.svg +6 -0
  58. package/assets/illustrations/iso/bar-chart.svg +6 -0
  59. package/assets/illustrations/iso/brackets-classic-dark.svg +6 -0
  60. package/assets/illustrations/iso/brackets-classic.svg +6 -0
  61. package/assets/illustrations/iso/brackets-dark.svg +6 -0
  62. package/assets/illustrations/iso/brackets.svg +6 -0
  63. package/assets/illustrations/iso/city-dark.svg +6 -0
  64. package/assets/illustrations/iso/city.svg +6 -0
  65. package/assets/illustrations/iso/conveyor-dark.svg +6 -0
  66. package/assets/illustrations/iso/conveyor.svg +6 -0
  67. package/assets/illustrations/iso/database-dark.svg +6 -0
  68. package/assets/illustrations/iso/database.svg +6 -0
  69. package/assets/illustrations/iso/documents-dark.svg +6 -0
  70. package/assets/illustrations/iso/documents.svg +6 -0
  71. package/assets/illustrations/iso/inbox-dark.svg +6 -0
  72. package/assets/illustrations/iso/inbox.svg +6 -0
  73. package/assets/illustrations/iso/laptop-dark.svg +6 -0
  74. package/assets/illustrations/iso/laptop.svg +6 -0
  75. package/assets/illustrations/iso/monitor-dark.svg +6 -0
  76. package/assets/illustrations/iso/monitor.svg +6 -0
  77. package/assets/illustrations/iso/pipeline-dark.svg +6 -0
  78. package/assets/illustrations/iso/pipeline.svg +6 -0
  79. package/assets/illustrations/iso/platform-dark.svg +6 -0
  80. package/assets/illustrations/iso/platform.svg +6 -0
  81. package/assets/illustrations/iso/server-dark.svg +6 -0
  82. package/assets/illustrations/iso/server.svg +6 -0
  83. package/assets/illustrations/iso/spreadsheet-dark.svg +6 -0
  84. package/assets/illustrations/iso/spreadsheet.svg +6 -0
  85. package/assets/illustrations/iso/timeline-dark.svg +6 -0
  86. package/assets/illustrations/iso/timeline.svg +6 -0
  87. package/assets/illustrations/sheet/construction.svg +115 -0
  88. package/assets/illustrations/sheet/crescent.svg +40 -0
  89. package/assets/illustrations/sheet/limb.svg +42 -0
  90. package/assets/illustrations/sheet/stress-axis.svg +119 -0
  91. package/assets/illustrations/sheet/totality.svg +215 -0
  92. package/assets/illustrations/sheet/vertical-metrics.svg +43 -0
  93. package/assets/logo-left.svg +1 -0
  94. package/assets/logo-right.svg +1 -0
  95. package/assets/logo.svg +1 -0
  96. package/dist/components/_overlay.d.ts +47 -0
  97. package/dist/components/_overlay.js +59 -0
  98. package/dist/components/accordion.d.ts +32 -0
  99. package/dist/components/accordion.js +39 -0
  100. package/dist/components/alert-dialog.d.ts +45 -0
  101. package/dist/components/alert-dialog.js +56 -0
  102. package/dist/components/alert.d.ts +35 -0
  103. package/dist/components/alert.js +42 -0
  104. package/dist/components/ascii-field.d.ts +34 -0
  105. package/dist/components/ascii-field.js +410 -0
  106. package/dist/components/aspect-ratio.d.ts +14 -0
  107. package/dist/components/aspect-ratio.js +17 -0
  108. package/dist/components/avatar.d.ts +42 -0
  109. package/dist/components/avatar.js +55 -0
  110. package/dist/components/badge.d.ts +70 -0
  111. package/dist/components/badge.js +62 -0
  112. package/dist/components/bottom-nav.d.ts +86 -0
  113. package/dist/components/bottom-nav.js +175 -0
  114. package/dist/components/breadcrumb.d.ts +31 -0
  115. package/dist/components/breadcrumb.js +37 -0
  116. package/dist/components/button-group.d.ts +30 -0
  117. package/dist/components/button-group.js +47 -0
  118. package/dist/components/button.d.ts +53 -0
  119. package/dist/components/button.js +130 -0
  120. package/dist/components/calendar.d.ts +26 -0
  121. package/dist/components/calendar.js +179 -0
  122. package/dist/components/card.d.ts +42 -0
  123. package/dist/components/card.js +76 -0
  124. package/dist/components/carousel.d.ts +109 -0
  125. package/dist/components/carousel.js +231 -0
  126. package/dist/components/chart.d.ts +189 -0
  127. package/dist/components/chart.js +323 -0
  128. package/dist/components/checkbox.d.ts +23 -0
  129. package/dist/components/checkbox.js +43 -0
  130. package/dist/components/code-block.d.ts +55 -0
  131. package/dist/components/code-block.js +100 -0
  132. package/dist/components/collapsible.d.ts +20 -0
  133. package/dist/components/collapsible.js +32 -0
  134. package/dist/components/color-picker.d.ts +107 -0
  135. package/dist/components/color-picker.js +428 -0
  136. package/dist/components/combobox.d.ts +99 -0
  137. package/dist/components/combobox.js +172 -0
  138. package/dist/components/command.d.ts +132 -0
  139. package/dist/components/command.js +257 -0
  140. package/dist/components/context-menu.d.ts +29 -0
  141. package/dist/components/context-menu.js +35 -0
  142. package/dist/components/conversation.d.ts +36 -0
  143. package/dist/components/conversation.js +303 -0
  144. package/dist/components/copy-button.d.ts +55 -0
  145. package/dist/components/copy-button.js +133 -0
  146. package/dist/components/data-table.d.ts +235 -0
  147. package/dist/components/data-table.js +655 -0
  148. package/dist/components/date-picker.d.ts +160 -0
  149. package/dist/components/date-picker.js +338 -0
  150. package/dist/components/dialog.d.ts +57 -0
  151. package/dist/components/dialog.js +95 -0
  152. package/dist/components/direction.d.ts +16 -0
  153. package/dist/components/direction.js +18 -0
  154. package/dist/components/drawer.d.ts +69 -0
  155. package/dist/components/drawer.js +79 -0
  156. package/dist/components/empty.d.ts +31 -0
  157. package/dist/components/empty.js +50 -0
  158. package/dist/components/feature-list.d.ts +54 -0
  159. package/dist/components/feature-list.js +43 -0
  160. package/dist/components/field.d.ts +34 -0
  161. package/dist/components/field.js +81 -0
  162. package/dist/components/file-drop.d.ts +77 -0
  163. package/dist/components/file-drop.js +258 -0
  164. package/dist/components/filter-bar.d.ts +153 -0
  165. package/dist/components/filter-bar.js +334 -0
  166. package/dist/components/form.d.ts +35 -0
  167. package/dist/components/form.js +56 -0
  168. package/dist/components/graph.d.ts +146 -0
  169. package/dist/components/graph.js +825 -0
  170. package/dist/components/illustration.d.ts +85 -0
  171. package/dist/components/illustration.js +165 -0
  172. package/dist/components/input-group.d.ts +138 -0
  173. package/dist/components/input-group.js +312 -0
  174. package/dist/components/input.d.ts +16 -0
  175. package/dist/components/input.js +25 -0
  176. package/dist/components/item.d.ts +64 -0
  177. package/dist/components/item.js +116 -0
  178. package/dist/components/kbd.d.ts +50 -0
  179. package/dist/components/kbd.js +45 -0
  180. package/dist/components/label.d.ts +12 -0
  181. package/dist/components/label.js +24 -0
  182. package/dist/components/layout.d.ts +136 -0
  183. package/dist/components/layout.js +162 -0
  184. package/dist/components/lightbox.d.ts +100 -0
  185. package/dist/components/lightbox.js +439 -0
  186. package/dist/components/locale.d.ts +44 -0
  187. package/dist/components/locale.js +37 -0
  188. package/dist/components/logo.d.ts +54 -0
  189. package/dist/components/logo.js +96 -0
  190. package/dist/components/menu.d.ts +60 -0
  191. package/dist/components/menu.js +140 -0
  192. package/dist/components/menubar.d.ts +62 -0
  193. package/dist/components/menubar.js +223 -0
  194. package/dist/components/message.d.ts +42 -0
  195. package/dist/components/message.js +59 -0
  196. package/dist/components/meter.d.ts +31 -0
  197. package/dist/components/meter.js +27 -0
  198. package/dist/components/money-input.d.ts +80 -0
  199. package/dist/components/money-input.js +253 -0
  200. package/dist/components/native-select.d.ts +26 -0
  201. package/dist/components/native-select.js +35 -0
  202. package/dist/components/navigation-menu.d.ts +42 -0
  203. package/dist/components/navigation-menu.js +97 -0
  204. package/dist/components/number-field.d.ts +55 -0
  205. package/dist/components/number-field.js +164 -0
  206. package/dist/components/otp-field.d.ts +48 -0
  207. package/dist/components/otp-field.js +102 -0
  208. package/dist/components/pagination.d.ts +37 -0
  209. package/dist/components/pagination.js +81 -0
  210. package/dist/components/pdf-viewer.d.ts +134 -0
  211. package/dist/components/pdf-viewer.js +996 -0
  212. package/dist/components/phone-input.d.ts +79 -0
  213. package/dist/components/phone-input.js +282 -0
  214. package/dist/components/popover.d.ts +33 -0
  215. package/dist/components/popover.js +48 -0
  216. package/dist/components/preview-card.d.ts +25 -0
  217. package/dist/components/preview-card.js +22 -0
  218. package/dist/components/progress.d.ts +27 -0
  219. package/dist/components/progress.js +25 -0
  220. package/dist/components/prompt-input.d.ts +156 -0
  221. package/dist/components/prompt-input.js +415 -0
  222. package/dist/components/quote.d.ts +22 -0
  223. package/dist/components/quote.js +15 -0
  224. package/dist/components/radio-group.d.ts +18 -0
  225. package/dist/components/radio-group.js +34 -0
  226. package/dist/components/rating.d.ts +73 -0
  227. package/dist/components/rating.js +124 -0
  228. package/dist/components/reasoning.d.ts +46 -0
  229. package/dist/components/reasoning.js +73 -0
  230. package/dist/components/resizable.d.ts +47 -0
  231. package/dist/components/resizable.js +44 -0
  232. package/dist/components/response.d.ts +41 -0
  233. package/dist/components/response.js +566 -0
  234. package/dist/components/scroll-area.d.ts +33 -0
  235. package/dist/components/scroll-area.js +31 -0
  236. package/dist/components/select.d.ts +35 -0
  237. package/dist/components/select.js +71 -0
  238. package/dist/components/separator.d.ts +14 -0
  239. package/dist/components/separator.js +17 -0
  240. package/dist/components/sidebar.d.ts +163 -0
  241. package/dist/components/sidebar.js +505 -0
  242. package/dist/components/site-header.d.ts +93 -0
  243. package/dist/components/site-header.js +121 -0
  244. package/dist/components/skeleton.d.ts +31 -0
  245. package/dist/components/skeleton.js +29 -0
  246. package/dist/components/slider.d.ts +24 -0
  247. package/dist/components/slider.js +131 -0
  248. package/dist/components/sortable.d.ts +178 -0
  249. package/dist/components/sortable.js +1258 -0
  250. package/dist/components/sources.d.ts +40 -0
  251. package/dist/components/sources.js +42 -0
  252. package/dist/components/spinner.d.ts +48 -0
  253. package/dist/components/spinner.js +75 -0
  254. package/dist/components/stat.d.ts +91 -0
  255. package/dist/components/stat.js +141 -0
  256. package/dist/components/stepper.d.ts +71 -0
  257. package/dist/components/stepper.js +101 -0
  258. package/dist/components/suggestions.d.ts +20 -0
  259. package/dist/components/suggestions.js +18 -0
  260. package/dist/components/switch.d.ts +14 -0
  261. package/dist/components/switch.js +26 -0
  262. package/dist/components/table.d.ts +172 -0
  263. package/dist/components/table.js +895 -0
  264. package/dist/components/tabs.d.ts +25 -0
  265. package/dist/components/tabs.js +162 -0
  266. package/dist/components/tag.d.ts +41 -0
  267. package/dist/components/tag.js +88 -0
  268. package/dist/components/tags-input.d.ts +56 -0
  269. package/dist/components/tags-input.js +271 -0
  270. package/dist/components/textarea.d.ts +13 -0
  271. package/dist/components/textarea.js +16 -0
  272. package/dist/components/theme.d.ts +55 -0
  273. package/dist/components/theme.js +120 -0
  274. package/dist/components/time-field.d.ts +70 -0
  275. package/dist/components/time-field.js +450 -0
  276. package/dist/components/timeline.d.ts +92 -0
  277. package/dist/components/timeline.js +108 -0
  278. package/dist/components/tippy.d.ts +48 -0
  279. package/dist/components/tippy.js +648 -0
  280. package/dist/components/toast.d.ts +88 -0
  281. package/dist/components/toast.js +205 -0
  282. package/dist/components/toggle-group.d.ts +41 -0
  283. package/dist/components/toggle-group.js +140 -0
  284. package/dist/components/toggle.d.ts +23 -0
  285. package/dist/components/toggle.js +35 -0
  286. package/dist/components/tool-call.d.ts +63 -0
  287. package/dist/components/tool-call.js +68 -0
  288. package/dist/components/toolbar.d.ts +17 -0
  289. package/dist/components/toolbar.js +39 -0
  290. package/dist/components/tooltip.d.ts +42 -0
  291. package/dist/components/tooltip.js +47 -0
  292. package/dist/components/tour.d.ts +127 -0
  293. package/dist/components/tour.js +648 -0
  294. package/dist/components/tree.d.ts +75 -0
  295. package/dist/components/tree.js +649 -0
  296. package/dist/components/typography.d.ts +134 -0
  297. package/dist/components/typography.js +176 -0
  298. package/dist/components/video-player.d.ts +284 -0
  299. package/dist/components/video-player.js +1392 -0
  300. package/dist/illustration.d.ts +2 -0
  301. package/dist/illustration.js +7 -0
  302. package/dist/index.d.ts +93 -0
  303. package/dist/index.js +94 -0
  304. package/dist/lib/cn.d.ts +20 -0
  305. package/dist/lib/cn.js +38 -0
  306. package/dist/lib/code-highlight.d.ts +18 -0
  307. package/dist/lib/code-highlight.js +174 -0
  308. package/dist/lib/code-theme.d.ts +19 -0
  309. package/dist/lib/code-theme.js +140 -0
  310. package/dist/lib/collapse-row.d.ts +9 -0
  311. package/dist/lib/collapse-row.js +129 -0
  312. package/dist/lib/digit-roll.d.ts +21 -0
  313. package/dist/lib/digit-roll.js +31 -0
  314. package/dist/lib/editorial-assets.d.ts +16 -0
  315. package/dist/lib/editorial-assets.js +56 -0
  316. package/dist/lib/field-errors.d.ts +28 -0
  317. package/dist/lib/field-errors.js +24 -0
  318. package/dist/lib/field-value.d.ts +13 -0
  319. package/dist/lib/field-value.js +44 -0
  320. package/dist/lib/figure/catalog.d.ts +127 -0
  321. package/dist/lib/figure/catalog.js +130 -0
  322. package/dist/lib/figure/figures/automation.d.ts +7 -0
  323. package/dist/lib/figure/figures/automation.js +143 -0
  324. package/dist/lib/figure/figures/bar-chart.d.ts +7 -0
  325. package/dist/lib/figure/figures/bar-chart.js +99 -0
  326. package/dist/lib/figure/figures/brackets-classic.d.ts +11 -0
  327. package/dist/lib/figure/figures/brackets-classic.js +170 -0
  328. package/dist/lib/figure/figures/brackets.d.ts +8 -0
  329. package/dist/lib/figure/figures/brackets.js +84 -0
  330. package/dist/lib/figure/figures/city.d.ts +7 -0
  331. package/dist/lib/figure/figures/city.js +93 -0
  332. package/dist/lib/figure/figures/conveyor.d.ts +7 -0
  333. package/dist/lib/figure/figures/conveyor.js +97 -0
  334. package/dist/lib/figure/figures/database.d.ts +7 -0
  335. package/dist/lib/figure/figures/database.js +65 -0
  336. package/dist/lib/figure/figures/documents.d.ts +7 -0
  337. package/dist/lib/figure/figures/documents.js +83 -0
  338. package/dist/lib/figure/figures/inbox.d.ts +7 -0
  339. package/dist/lib/figure/figures/inbox.js +92 -0
  340. package/dist/lib/figure/figures/laptop.d.ts +7 -0
  341. package/dist/lib/figure/figures/laptop.js +67 -0
  342. package/dist/lib/figure/figures/monitor.d.ts +7 -0
  343. package/dist/lib/figure/figures/monitor.js +59 -0
  344. package/dist/lib/figure/figures/pipeline.d.ts +8 -0
  345. package/dist/lib/figure/figures/pipeline.js +117 -0
  346. package/dist/lib/figure/figures/platform.d.ts +7 -0
  347. package/dist/lib/figure/figures/platform.js +117 -0
  348. package/dist/lib/figure/figures/server.d.ts +7 -0
  349. package/dist/lib/figure/figures/server.js +115 -0
  350. package/dist/lib/figure/figures/spreadsheet.d.ts +7 -0
  351. package/dist/lib/figure/figures/spreadsheet.js +87 -0
  352. package/dist/lib/figure/figures/timeline.d.ts +7 -0
  353. package/dist/lib/figure/figures/timeline.js +65 -0
  354. package/dist/lib/figure/kernel.d.ts +152 -0
  355. package/dist/lib/figure/kernel.js +576 -0
  356. package/dist/lib/figure/parts.d.ts +42 -0
  357. package/dist/lib/figure/parts.js +126 -0
  358. package/dist/lib/form-reset.d.ts +11 -0
  359. package/dist/lib/form-reset.js +22 -0
  360. package/dist/lib/glide.d.ts +53 -0
  361. package/dist/lib/glide.js +138 -0
  362. package/dist/lib/graph-layout.d.ts +58 -0
  363. package/dist/lib/graph-layout.js +209 -0
  364. package/dist/lib/illustration-drawings.d.ts +89 -0
  365. package/dist/lib/illustration-drawings.js +539 -0
  366. package/dist/lib/illustration-info.d.ts +37 -0
  367. package/dist/lib/illustration-info.js +22 -0
  368. package/dist/lib/illustration-library.d.ts +87 -0
  369. package/dist/lib/illustration-library.js +352 -0
  370. package/dist/lib/logo-geometry.d.ts +29 -0
  371. package/dist/lib/logo-geometry.js +67 -0
  372. package/dist/lib/markdown-guard.d.ts +16 -0
  373. package/dist/lib/markdown-guard.js +123 -0
  374. package/dist/lib/merge-refs.d.ts +10 -0
  375. package/dist/lib/merge-refs.js +26 -0
  376. package/dist/lib/money.d.ts +73 -0
  377. package/dist/lib/money.js +343 -0
  378. package/dist/lib/motion.d.ts +6 -0
  379. package/dist/lib/motion.js +12 -0
  380. package/dist/lib/pdf-worker.d.ts +1 -0
  381. package/dist/lib/pdf-worker.js +6 -0
  382. package/dist/lib/pdf.d.ts +19 -0
  383. package/dist/lib/pdf.js +58 -0
  384. package/dist/lib/phone-countries.d.ts +1 -0
  385. package/dist/lib/phone-countries.js +281 -0
  386. package/dist/lib/phone.d.ts +90 -0
  387. package/dist/lib/phone.js +286 -0
  388. package/dist/lib/platform.d.ts +38 -0
  389. package/dist/lib/platform.js +75 -0
  390. package/dist/lib/room.d.ts +25 -0
  391. package/dist/lib/room.js +46 -0
  392. package/dist/lib/row-index.d.ts +15 -0
  393. package/dist/lib/row-index.js +136 -0
  394. package/dist/lib/table-fit.d.ts +143 -0
  395. package/dist/lib/table-fit.js +596 -0
  396. package/dist/lib/theme-script.d.ts +31 -0
  397. package/dist/lib/theme-script.js +49 -0
  398. package/dist/lib/tippy/pixels.d.ts +47 -0
  399. package/dist/lib/tippy/pixels.js +187 -0
  400. package/dist/lib/tippy/sprite.d.ts +86 -0
  401. package/dist/lib/tippy/sprite.js +753 -0
  402. package/dist/messages/de.d.ts +12 -0
  403. package/dist/messages/de.js +326 -0
  404. package/dist/styles/expressive.css +203 -0
  405. package/dist/styles/fonts.css +145 -0
  406. package/dist/styles/index.css +207 -0
  407. package/dist/styles/material.css +317 -0
  408. package/dist/styles/parts/ai.css +361 -0
  409. package/dist/styles/parts/brand.css +75 -0
  410. package/dist/styles/parts/controls.css +774 -0
  411. package/dist/styles/parts/data.css +222 -0
  412. package/dist/styles/parts/editorial.css +120 -0
  413. package/dist/styles/parts/feedback.css +340 -0
  414. package/dist/styles/parts/foundations.css +166 -0
  415. package/dist/styles/parts/graph.css +214 -0
  416. package/dist/styles/parts/inputs.css +261 -0
  417. package/dist/styles/parts/isometric.css +124 -0
  418. package/dist/styles/parts/navigation.css +424 -0
  419. package/dist/styles/parts/overlays.css +250 -0
  420. package/dist/styles/parts/pdf.css +154 -0
  421. package/dist/styles/parts/react-flow.css +519 -0
  422. package/dist/styles/tokens.css +299 -0
  423. package/dist/vite.d.ts +66 -0
  424. package/dist/vite.js +29 -0
  425. package/package.json +183 -5
@@ -0,0 +1,895 @@
1
+ "use client";
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { defaultRangeExtractor, observeElementOffset, observeElementRect, observeWindowOffset, observeWindowRect, useVirtualizer, } from "@tanstack/react-virtual";
4
+ import { ChevronRightIcon } from "lucide-react";
5
+ import * as React from "react";
6
+ import { flushSync } from "react-dom";
7
+ import { cn } from "../lib/cn.js";
8
+ import { mergeRefs } from "../lib/merge-refs.js";
9
+ import { Flip, drawOrder, fitStep, layoutFor, measureMetrics, reducedMotion, removalOrder, titleRoom, widestRows, } from "../lib/table-fit.js";
10
+ const TableDenseContext = React.createContext(false);
11
+ const TableFitContext = React.createContext(null);
12
+ const TableSectionContext = React.createContext("body");
13
+ const TableCellSlotContext = React.createContext(null);
14
+ const SUBGRID = "col-span-full grid grid-cols-subgrid";
15
+ /**
16
+ * The space between a title and an inline cell: an ordinary space, widened to an en space (Licht
17
+ * Sans' space is 0.285em; an en space is 0.5em).
18
+ */
19
+ const INLINE_SPACE = "[word-spacing:0.215em]";
20
+ /**
21
+ * Whether an element scrolls: its content is wider or taller than it. A table that scrolls must
22
+ * be reachable by keyboard, so its scroller then takes the focus — as a region named like the
23
+ * table, where the table is inside it.
24
+ */
25
+ function useScrolls(ref) {
26
+ const [scrolls, setScrolls] = React.useState(false);
27
+ React.useLayoutEffect(() => {
28
+ const el = ref.current;
29
+ if (!el)
30
+ return;
31
+ const check = () => setScrolls(el.scrollWidth > el.clientWidth + 1 || el.scrollHeight > el.clientHeight + 1);
32
+ // The scroller and what is in it (the table, or the fitting table's row groups) decide.
33
+ const ro = new ResizeObserver(check);
34
+ const watch = () => {
35
+ ro.disconnect();
36
+ ro.observe(el);
37
+ for (const child of el.children)
38
+ ro.observe(child);
39
+ };
40
+ watch();
41
+ const mo = new MutationObserver(watch);
42
+ mo.observe(el, { childList: true });
43
+ return () => {
44
+ ro.disconnect();
45
+ mo.disconnect();
46
+ };
47
+ }, [ref]);
48
+ return scrolls;
49
+ }
50
+ /**
51
+ * Table — tabular data as an **object**: a 20px card in the `surface-card` material that
52
+ * scrolls horizontally when the columns do not fit. Rows are separated by hairlines and take
53
+ * a subtle `--control-hover` on hover; headers are eyebrows; numbers are mono and tabular.
54
+ *
55
+ * The card's padding is carried by the cells so rules and hover run edge to edge — do not
56
+ * pad the table at the call site. `variant="plain"` is the same table without the card, for
57
+ * tables that are part of the page rather than an object on it. The rule people break: zebra
58
+ * stripes, vertical rules or a second border around the table. Hairlines between rows are the whole grid.
59
+ *
60
+ * With `fit`, the columns follow the **container's** width instead of scrolling: see `fit`.
61
+ */
62
+ export function Table({ fit = false, ...props }) {
63
+ return fit ? _jsx(FitTable, { ...props }) : _jsx(StaticTable, { ...props });
64
+ }
65
+ function StaticTable({ dense = false, variant = "card", containerProps, className, ...props }) {
66
+ const containerRef = React.useRef(null);
67
+ const containerRefs = React.useMemo(() => mergeRefs(containerRef, containerProps?.ref), [containerProps?.ref]);
68
+ const scrolls = useScrolls(containerRef);
69
+ return (_jsx(TableDenseContext.Provider, { value: dense, children: _jsx("div", { "data-slot": "table-container", "data-variant": variant, tabIndex: scrolls ? 0 : undefined, role: scrolls ? "region" : undefined, "aria-label": scrolls ? props["aria-label"] : undefined, "aria-labelledby": scrolls ? props["aria-labelledby"] : undefined, ...containerProps, ref: containerRefs, className: cn("relative w-full overflow-x-auto focus-ring", variant === "card" && "surface-card [--card-padding:0] [--scrollbar-inset:var(--radius-card)]", containerProps?.className), children: _jsx("table", { "data-slot": "table", "data-dense": dense ? "" : undefined, "data-variant": variant, className: cn("w-full caption-bottom border-collapse text-start font-body text-sm", className), ...props }) }) }));
70
+ }
71
+ /**
72
+ * Card padding, carried by the rows in a fitting table: 16px, 24px from a 40rem container; and the
73
+ * gap between columns, 12–28px with the container's width. The fit sets both as it measures the
74
+ * width (`fitSpacing`). Not a container query and `cqi`: WebKit restyles every cell of a size
75
+ * container on each resize, which made a fitting table drag as Safari resized it.
76
+ */
77
+ const FIT_SPACING = "[--table-pad:--spacing(4)] in-data-wide:[--table-pad:--spacing(6)] gap-x-(--fit-gap,0.75rem)";
78
+ /** The container's padding (`data-wide`) and column gap (`--fit-gap`) at its current width. */
79
+ function fitSpacing(container, body, rem) {
80
+ const width = container.clientWidth;
81
+ container.toggleAttribute("data-wide", width >= 40 * rem);
82
+ const gap = Math.min(Math.max(0.046 * width - 0.45 * rem, 0.75 * rem), 1.75 * rem);
83
+ body.style.setProperty("--fit-gap", `${gap}px`);
84
+ return gap;
85
+ }
86
+ /**
87
+ * A table that fits its columns to its container. It is one table at every width — `role="table"`
88
+ * on a CSS grid whose groups and rows are subgrids — so a column is as wide as its widest cell
89
+ * in every group, and cells keep their DOM order whatever is drawn where.
90
+ */
91
+ function FitTable({ dense = false, variant = "card", containerProps, className, style, ref, children, ...props }) {
92
+ const containerRef = React.useRef(null);
93
+ const bodyRef = React.useRef(null);
94
+ const layerRef = React.useRef(null);
95
+ const flipRef = React.useRef(null);
96
+ const remeasureRef = React.useRef(null);
97
+ // The header row's `TableHead`s register their columns as they mount and change.
98
+ const registered = React.useRef(new Map());
99
+ const [version, setVersion] = React.useState(0);
100
+ const register = React.useCallback((index, options) => {
101
+ registered.current.set(index, options);
102
+ setVersion((v) => v + 1);
103
+ return () => {
104
+ if (registered.current.get(index) !== options)
105
+ return;
106
+ registered.current.delete(index);
107
+ setVersion((v) => v + 1);
108
+ };
109
+ }, []);
110
+ const { columns, title, align } = React.useMemo(() => {
111
+ const map = registered.current;
112
+ const count = map.size ? Math.max(...map.keys()) + 1 : 0;
113
+ const all = Array.from({ length: count }, (_, i) => map.get(i));
114
+ // The title is the column marked `titleColumn`, or the first. It never steps out, and
115
+ // columns before it step out but never move inline.
116
+ const at = Math.max(0, all.findIndex((o) => o?.title));
117
+ const columns = all.map((o, i) => ({
118
+ id: String(i),
119
+ priority: i === at ? undefined : o?.priority,
120
+ inline: i > at && !!o?.inline,
121
+ minWidth: i === at ? undefined : o?.minWidth,
122
+ width: o?.width,
123
+ }));
124
+ return {
125
+ columns,
126
+ title: String(at),
127
+ align: all.map((o) => (o?.end ? "end" : "start")),
128
+ };
129
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- `version` stands for the registered columns.
130
+ }, [version]);
131
+ const order = React.useMemo(() => removalOrder(columns, title), [columns, title]);
132
+ const drawn = React.useMemo(() => drawOrder(columns, title), [columns, title]);
133
+ const [step, setStep] = React.useState(0);
134
+ const layout = React.useMemo(() => layoutFor(Math.min(step, order.length), order, columns), [step, order, columns]);
135
+ const latest = React.useRef({ step, order, columns, drawn, title });
136
+ latest.current = { step, order, columns, drawn, title };
137
+ React.useLayoutEffect(() => {
138
+ const container = containerRef.current;
139
+ const body = bodyRef.current;
140
+ const layer = layerRef.current;
141
+ if (!container || !body || !layer)
142
+ return;
143
+ const flip = new Flip(container, body, layer);
144
+ flipRef.current = flip;
145
+ let metrics = null;
146
+ const rem = () => parseFloat(getComputedStyle(document.documentElement).fontSize) || 16;
147
+ /**
148
+ * Places the current width. From a layout effect the new layout commits before paint and
149
+ * must not (and need not) be flushed; from a resize it is flushed so the glide can measure
150
+ * it; from an observer (new rows, fonts) it lands at once, without a glide.
151
+ */
152
+ const evaluate = (from) => {
153
+ if (!metrics)
154
+ return;
155
+ const { step, order, columns, drawn, title } = latest.current;
156
+ const gap = fitSpacing(container, body, rem());
157
+ const row = body.querySelector("[data-slot=table-row]");
158
+ const edge = row ? parseFloat(getComputedStyle(row).paddingInlineStart) : 16;
159
+ const available = body.clientWidth;
160
+ const next = fitStep({
161
+ available,
162
+ current: step,
163
+ order,
164
+ columns,
165
+ drawn,
166
+ title,
167
+ metrics,
168
+ edge,
169
+ gap,
170
+ widthRem: container.clientWidth / rem(),
171
+ });
172
+ // In the final layout the title's track is at least 12rem — or what the columns that keep
173
+ // their own leave it, so a narrow table never pushes them out of the card.
174
+ const room = titleRoom(layoutFor(next, order, columns), drawn, title, metrics, available, edge, gap);
175
+ if (room == null)
176
+ body.style.removeProperty("--fit-title-room");
177
+ else
178
+ body.style.setProperty("--fit-title-room", `${room}px`);
179
+ if (next === step) {
180
+ if (from === "resize" && !reducedMotion())
181
+ flip.reflow();
182
+ return;
183
+ }
184
+ if (from === "effect")
185
+ return setStep(next);
186
+ const commit = () => flushSync(() => setStep(next));
187
+ if (from === "resize" && !reducedMotion())
188
+ flip.tier(layoutFor(next, order, columns), commit);
189
+ else
190
+ commit();
191
+ };
192
+ const remeasure = (from) => {
193
+ metrics = measureMetrics(container, body, latest.current.columns);
194
+ evaluate(from);
195
+ };
196
+ remeasureRef.current = remeasure;
197
+ // Before the first paint: measure, and start in the layout that fits, without a glide.
198
+ remeasure("effect");
199
+ const ro = new ResizeObserver(() => evaluate("resize"));
200
+ ro.observe(container);
201
+ // New, sorted or filtered rows and changed cell content are measured again. The cells a
202
+ // layout change moves (between a row and its title) are not content: their records target
203
+ // the row or the title's wrapper, not the inside of a cell.
204
+ const has = (n, slot) => n instanceof Element && (n.matches(`[data-slot=${slot}]`) || !!n.querySelector(`[data-slot=${slot}]`));
205
+ const changed = (r, virtual) => {
206
+ const nodes = [...r.addedNodes, ...r.removedNodes];
207
+ const target = r.target instanceof Element ? r.target : r.target.parentElement;
208
+ if (nodes.some((n) => has(n, "table-sizer")))
209
+ return true;
210
+ // A virtual body adds and removes rows as they scroll by. Only its header and its sizer
211
+ // rows are measured (measuredRows), so only their changes count.
212
+ if (virtual)
213
+ return !!target?.closest("[data-slot=table-sizer],[data-slot=table-header]");
214
+ if (r.type === "characterData")
215
+ return true;
216
+ if (nodes.some((n) => has(n, "table-row")))
217
+ return true;
218
+ return !!target?.closest("[data-slot=table-cell],[data-slot=table-head]");
219
+ };
220
+ const mo = new MutationObserver((records) => {
221
+ // A group that opens or closes moves the rows under it: the next resize starts afresh.
222
+ flip.invalidate();
223
+ const virtual = !!body.querySelector("[data-slot=table-sizer]");
224
+ if (records.some((r) => r.type !== "attributes" && changed(r, virtual)))
225
+ remeasure("observer");
226
+ });
227
+ mo.observe(body, {
228
+ childList: true,
229
+ subtree: true,
230
+ characterData: true,
231
+ attributes: true,
232
+ attributeFilter: ["data-closed"],
233
+ });
234
+ // Titles are measured in the real fonts once they load.
235
+ const fonts = typeof document !== "undefined" ? document.fonts : undefined;
236
+ let alive = true;
237
+ fonts?.ready.then(() => alive && remeasure("observer"));
238
+ const onFonts = () => remeasure("observer");
239
+ fonts?.addEventListener("loadingdone", onFonts);
240
+ const onScroll = () => flip.invalidate();
241
+ body.addEventListener("scroll", onScroll, { passive: true });
242
+ return () => {
243
+ alive = false;
244
+ ro.disconnect();
245
+ mo.disconnect();
246
+ fonts?.removeEventListener("loadingdone", onFonts);
247
+ body.removeEventListener("scroll", onScroll);
248
+ flip.cancel();
249
+ flipRef.current = null;
250
+ remeasureRef.current = null;
251
+ };
252
+ }, []);
253
+ // New columns: measure again before the frame paints.
254
+ React.useLayoutEffect(() => {
255
+ flipRef.current?.invalidate();
256
+ remeasureRef.current?.("effect");
257
+ }, [columns]);
258
+ // Grid tracks: every column that has its own column, in drawing order. Until the final layout
259
+ // the title's track never gets narrower than its longest one-line title.
260
+ const { track, template } = React.useMemo(() => {
261
+ const own = drawn.filter((c) => layout.modes[c.id] === "column");
262
+ return {
263
+ track: new Map(own.map((c, i) => [Number(c.id), i + 1])),
264
+ template: own.length
265
+ ? own
266
+ .map((c) => c.id === title
267
+ ? layout.final
268
+ ? "minmax(min(12rem,var(--fit-title-room,100%)),1fr)"
269
+ : "minmax(max-content,1fr)"
270
+ : (c.width ?? "auto"))
271
+ .join(" ")
272
+ : undefined,
273
+ };
274
+ }, [drawn, layout, title]);
275
+ const value = React.useMemo(() => ({
276
+ register,
277
+ count: columns.length,
278
+ title: Number(title),
279
+ order: drawn.map((c) => Number(c.id)),
280
+ modes: columns.map((c) => layout.modes[c.id] ?? "column"),
281
+ align,
282
+ track,
283
+ inlined: layout.inlined,
284
+ final: layout.final,
285
+ }), [register, columns, title, drawn, layout, align, track]);
286
+ const containerRefs = React.useMemo(() => mergeRefs(containerRef, containerProps?.ref), [containerProps?.ref]);
287
+ const bodyRefs = React.useMemo(() => mergeRefs(bodyRef, ref), [ref]);
288
+ const scrolls = useScrolls(bodyRef);
289
+ return (_jsx(TableFitContext.Provider, { value: value, children: _jsx(TableDenseContext.Provider, { value: dense, children: _jsxs("div", { "data-slot": "table-container", "data-variant": variant, "data-fit": "", "data-tier": order.length - layout.step, "data-final": layout.final ? "" : undefined, ...containerProps, ref: containerRefs, className: cn("relative flex w-full max-w-full min-w-0 flex-col overflow-hidden", variant === "card" && "surface-card [--card-padding:0] [--scrollbar-inset:var(--radius-card)]", containerProps?.className), children: [_jsx("div", { tabIndex: scrolls ? 0 : undefined, ...props, ref: bodyRefs, role: "table", "data-slot": "table", "data-fit": "", "data-dense": dense ? "" : undefined, "data-variant": variant, className: cn("relative grid min-h-0 flex-1 content-start overflow-auto text-start font-body text-sm focus-visible:outline-none", FIT_SPACING, className), style: { gridTemplateColumns: template, ...style }, children: children }), _jsx("div", { ref: layerRef, "aria-hidden": true, "data-slot": "table-ghosts", className: "pointer-events-none absolute inset-0 z-3 overflow-hidden font-body text-sm" })] }) }) }));
290
+ }
291
+ /* ── Sections ──────────────────────────────────────────────────────────────── */
292
+ export function TableHeader({ className, ...props }) {
293
+ const fit = React.useContext(TableFitContext);
294
+ return (_jsx(TableSectionContext.Provider, { value: "head", children: fit ? (_jsx("div", { role: "rowgroup", "data-slot": "table-header", className: cn(SUBGRID, "[&_[data-slot=table-row]]:hover:bg-transparent", className), ...props })) : (_jsx("thead", { "data-slot": "table-header", className: cn("[&_tr]:border-b [&_tr]:border-border/60 [&_tr]:hover:bg-transparent", className), ...props })) }));
295
+ }
296
+ export function TableBody({ className, ...props }) {
297
+ const fit = React.useContext(TableFitContext);
298
+ if (fit)
299
+ return (_jsx("div", { role: "rowgroup", "data-slot": "table-body", className: cn(SUBGRID, "[&>[data-slot=table-row]:last-child]:border-b-0", className), ...props }));
300
+ return (_jsx("tbody", { "data-slot": "table-body", className: cn("[&_tr:last-child]:border-b-0", className), ...props }));
301
+ }
302
+ export function TableFooter({ className, ...props }) {
303
+ const fit = React.useContext(TableFitContext);
304
+ const classes = "border-t border-border/60 font-medium text-foreground";
305
+ if (fit)
306
+ return (_jsx("div", { role: "rowgroup", "data-slot": "table-footer", className: cn(SUBGRID, classes, "[&_[data-slot=table-row]]:hover:bg-transparent", className), ...props }));
307
+ return (_jsx("tfoot", { "data-slot": "table-footer", className: cn(classes, "[&_tr]:hover:bg-transparent", className), ...props }));
308
+ }
309
+ /* ── Rows and cells ────────────────────────────────────────────────────────── */
310
+ /**
311
+ * A row. Mark a selected row with `aria-selected` / `data-selected`.
312
+ *
313
+ * In a fitting table its cells follow the header's columns by position — give it one cell per
314
+ * column, as direct children — and it draws them where the layout says: in their own column,
315
+ * inline after the title, or only for screen readers.
316
+ */
317
+ export function TableRow({ className, children, ref, ...props }) {
318
+ const fit = React.useContext(TableFitContext);
319
+ const head = React.useContext(TableSectionContext) === "head";
320
+ const dense = React.useContext(TableDenseContext);
321
+ const [virtualProps, rowRef] = useVirtualRow(ref);
322
+ const rowKey = React.useId();
323
+ const rowClasses = cn("border-b border-border/60 transition-colors duration-(--duration) ease-(--ease)", "hover:bg-control-hover/50 aria-selected:bg-control-hover data-selected:bg-control-hover",
324
+ // On the selected fill muted text falls under 4.5:1; there it takes the softer foreground.
325
+ "aria-selected:[--muted-foreground:var(--foreground-soft)] data-selected:[--muted-foreground:var(--foreground-soft)]");
326
+ if (!fit)
327
+ return (_jsx("tr", { "data-slot": "table-row", className: cn(rowClasses, className), ...virtualProps, ...props, ref: rowRef, children: children }));
328
+ const cells = React.Children.toArray(children).filter(React.isValidElement);
329
+ const mapped = fit.count > 0 && cells.length === fit.count;
330
+ const at = (i) => (_jsx(TableCellSlotContext.Provider, { value: { index: i, rowKey, head, mapped }, children: cells[i] }, cells[i].key ?? i));
331
+ let content;
332
+ if (!mapped)
333
+ content = cells.map((_, i) => at(i));
334
+ else if (head)
335
+ content = fit.order.map(at);
336
+ else {
337
+ // Inline columns move into the title in the order they are drawn, so the cells inside the
338
+ // wrapper are always a prefix and the DOM order never changes. The others sit outside it,
339
+ // where they are grid items.
340
+ const t = fit.order.indexOf(fit.title);
341
+ const inside = fit.order.filter((i) => fit.modes[i] === "inline");
342
+ const outside = fit.order.slice(t + 1).filter((i) => !inside.includes(i));
343
+ content = (_jsxs(_Fragment, { children: [fit.order.slice(0, t).map(at), _jsxs("div", { role: "none", "data-slot": "table-lead", className: cn(fit.inlined ? "block min-w-0 py-1" : "contents", fit.inlined && (fit.final ? "text-pretty" : "whitespace-nowrap")), style: fit.inlined ? { gridColumn: fit.track.get(fit.title) } : undefined, children: [at(fit.title), inside.map((i) => (_jsxs(React.Fragment, { children: [_jsx("span", { className: INLINE_SPACE, children: " " }), at(i)] }, i)))] }), outside.map(at)] }));
344
+ }
345
+ return (_jsx("div", { role: "row", "data-slot": "table-row", "data-flip": "row", className: cn(SUBGRID, rowClasses, "relative px-(--table-pad) leading-5.5", head
346
+ ? cn("items-center", dense ? "min-h-(--control-h-sm)" : "min-h-(--control-h)")
347
+ : cn("items-start", !dense && "py-2"), className), ...virtualProps, ...props, ref: rowRef, children: content }));
348
+ }
349
+ /**
350
+ * A cell of a fitting table, drawn where the layout puts its column. The title is always in
351
+ * its own column (and names the row, as its `rowheader`); a column that steps out stays in the
352
+ * accessibility tree, visually hidden, and an inline one flows after the title's last word.
353
+ */
354
+ function FitCell({ place, fit, kind, className, style, children, colSpan, scope: _scope, ...props }) {
355
+ const { index, rowKey, head, mapped } = place;
356
+ const role = head
357
+ ? "columnheader"
358
+ : kind === "head" || (mapped && index === fit.title)
359
+ ? "rowheader"
360
+ : "cell";
361
+ if (!mapped)
362
+ return (_jsx("div", { role: role, className: cn("min-w-0", (colSpan ?? 1) > 1 && "col-span-full", className), style: style, ...props, children: children }));
363
+ if (index === fit.title) {
364
+ const inline = fit.inlined && !head;
365
+ return (_jsx("div", { role: role, "data-title": "", className: cn(inline
366
+ ? "inline"
367
+ : cn("flex min-w-0", head ? "items-center" : "min-h-(--control-h-sm) items-start py-1"), className), style: inline ? style : { gridColumn: fit.track.get(index), ...style }, ...props, children: _jsx("span", { "data-slot": "table-title-text", className: fit.final && !head ? "min-w-0 text-pretty break-words" : "whitespace-nowrap", children: children }) }));
368
+ }
369
+ const end = fit.align[index] === "end";
370
+ const column = fit.modes[index] ?? "column";
371
+ // A header has its own column or is only read; it never rides in the title.
372
+ const mode = head && column !== "column" ? "hidden" : column;
373
+ return (_jsx("div", { role: role, "data-column": index, "data-head": head ? "" : undefined, "data-mode": mode, "data-align": end ? "end" : "start", "data-flip": "piece", "data-flip-key": `${rowKey}:${index}`, className: cn("min-w-0 items-center whitespace-nowrap", mode === "column" && "flex",
374
+ // Cells are 30px, the height of a dense control, so a button sits in a 46px row; text
375
+ // centres on the title's first line.
376
+ mode === "column" && !head && "min-h-(--control-h-sm)", mode === "column" && (end ? "justify-self-end text-end" : "justify-self-start"),
377
+ // Inline cells flow right after the title's last word, and wrap like words.
378
+ mode === "inline" && "inline-flex min-h-5.5 align-top",
379
+ // In the final layout, where titles wrap, one longer than the line (a link) wraps inside
380
+ // the title cell too, instead of running out of the table.
381
+ mode === "inline" && fit.final && "max-w-full wrap-anywhere whitespace-normal", mode === "hidden" && "sr-only", className), style: mode === "column" ? { gridColumn: fit.track.get(index), ...style } : style, ...props, children: children }));
382
+ }
383
+ /**
384
+ * A header cell. In the `TableHeader` it is a column header, set as an eyebrow: 12px mono,
385
+ * uppercase, 0.18em tracking, muted. In a body or footer row it is that row's header — a
386
+ * `<th scope="row">` set like a cell in the foreground ink, not as an eyebrow: use it for the
387
+ * cell that names the row (a feature in a comparison, a month in a report).
388
+ */
389
+ export function TableHead({ numeric = false, align, width, priority, inline, minWidth, titleColumn, className, style, ...props }) {
390
+ const dense = React.useContext(TableDenseContext);
391
+ const fit = React.useContext(TableFitContext);
392
+ const slot = React.useContext(TableCellSlotContext);
393
+ const row = React.useContext(TableSectionContext) === "body";
394
+ const end = (align ?? (numeric ? "end" : "start")) === "end";
395
+ const register = fit?.register;
396
+ const index = slot?.head ? slot.index : -1;
397
+ React.useLayoutEffect(() => {
398
+ if (!register || index < 0)
399
+ return;
400
+ return register(index, { priority, inline, minWidth, width, title: titleColumn, end });
401
+ }, [register, index, priority, inline, minWidth, width, titleColumn, end]);
402
+ if (fit && slot)
403
+ return (_jsx(FitCell, { place: slot, fit: fit, kind: "head", "data-slot": "table-head", className: cn(slot.head ? "eyebrow font-normal" : "text-start font-normal text-foreground", className), style: style, ...props }));
404
+ if (row)
405
+ return (_jsx("th", { "data-slot": "table-head", scope: "row", className: cn("px-4 text-start align-middle font-normal text-foreground first:ps-6 last:pe-6", dense ? "h-(--control-h-sm) py-1 text-[13px]" : "h-(--control-h-lg) py-2", end && "text-end", numeric && "font-mono text-[13px] whitespace-nowrap tabular-nums", className), style: width ? { width, ...style } : style, ...props }));
406
+ return (_jsx("th", { "data-slot": "table-head", scope: "col", className: cn("px-4 text-start align-middle eyebrow font-normal whitespace-nowrap first:ps-6 last:pe-6", dense ? "h-(--control-h-sm)" : "h-(--control-h)", end && "text-end", className), style: width ? { width, ...style } : style, ...props }));
407
+ }
408
+ export function TableCell({ numeric = false, className, ...props }) {
409
+ const dense = React.useContext(TableDenseContext);
410
+ const fit = React.useContext(TableFitContext);
411
+ const slot = React.useContext(TableCellSlotContext);
412
+ if (fit && slot)
413
+ return (_jsx(FitCell, { place: slot, fit: fit, kind: "cell", "data-slot": "table-cell", className: cn(
414
+ // The title names the row.
415
+ slot.mapped && !slot.head && slot.index === fit.title ? "text-foreground" : "text-foreground-soft", dense && "text-[13px]", numeric && "font-mono text-[13px] tabular-nums", className), ...props }));
416
+ return (_jsx("td", { "data-slot": "table-cell", className: cn("px-4 align-middle text-foreground-soft first:ps-6 last:pe-6", dense ? "h-(--control-h-sm) py-1 text-[13px]" : "h-(--control-h-lg) py-2", numeric && "text-end font-mono text-[13px] whitespace-nowrap tabular-nums", className), ...props }));
417
+ }
418
+ const TableGroupContext = React.createContext(null);
419
+ /**
420
+ * TableGroup — one group of rows: a `<tbody>` that starts with a `TableGroupHeader` and holds
421
+ * ordinary `TableRow`s. Use several in place of a single `TableBody`.
422
+ *
423
+ * Groups answer "which rows belong together" (by status, by owner, by month). The rule people
424
+ * break: grouping by something every row shares, or into groups of one. If most groups would
425
+ * hold a single row, sort the column instead.
426
+ */
427
+ export function TableGroup({ open: openProp, defaultOpen = true, onOpenChange, collapsible = true, className, ...props }) {
428
+ const fit = React.useContext(TableFitContext);
429
+ const [uncontrolled, setUncontrolled] = React.useState(defaultOpen);
430
+ const open = openProp ?? uncontrolled;
431
+ const onOpenChangeRef = React.useRef(onOpenChange);
432
+ onOpenChangeRef.current = onOpenChange;
433
+ const setOpen = React.useCallback((next) => {
434
+ if (openProp === undefined)
435
+ setUncontrolled(next);
436
+ onOpenChangeRef.current?.(next);
437
+ }, [openProp]);
438
+ const value = React.useMemo(() => ({ open, setOpen, collapsible }), [open, setOpen, collapsible]);
439
+ const state = { "data-open": open ? "" : undefined, "data-closed": open ? undefined : "" };
440
+ return (_jsx(TableGroupContext.Provider, { value: value, children: fit ? (_jsx("div", { role: "rowgroup", "data-slot": "table-group", ...state, className: cn(SUBGRID, className), ...props })) : (_jsx("tbody", { "data-slot": "table-group", ...state, className: className, ...props })) }));
441
+ }
442
+ /**
443
+ * The first row of a `TableGroup`: a full-width band with the label, a mono count and an
444
+ * optional summary. When the group is collapsible the label is a button with a chevron that
445
+ * opens and closes the group (`aria-expanded`).
446
+ *
447
+ * `sticky` pins the header to the top of the table card while its rows scroll — give the
448
+ * card a height (`containerProps={{ className: "max-h-96" }}`) so the card itself scrolls.
449
+ */
450
+ export function TableGroupHeader({ icon, count, summary, colSpan = 100, sticky = false, className, children, ref, ...props }) {
451
+ const dense = React.useContext(TableDenseContext);
452
+ const fit = React.useContext(TableFitContext);
453
+ const group = React.useContext(TableGroupContext);
454
+ const [virtualProps, rowRef] = useVirtualRow(ref);
455
+ const collapsible = group?.collapsible ?? false;
456
+ const open = group?.open ?? true;
457
+ const label = (_jsxs(_Fragment, { children: [icon != null && (_jsx("span", { "aria-hidden": true, className: "flex shrink-0 text-foreground-soft [&_svg]:size-4 [&_svg]:shrink-0", children: icon })), _jsx("span", { "data-slot": "table-group-label", className: "-m-px min-w-0 truncate p-px text-[13px] font-medium text-foreground", children: children }), count != null && (_jsx("span", { "data-slot": "table-group-count", className: "font-mono text-[12px] font-normal text-muted-foreground tabular-nums", children: count }))] }));
458
+ const content = (_jsxs("div", { className: "flex min-w-0 items-center gap-4", children: [collapsible ? (_jsxs("button", { type: "button", "data-slot": "table-group-trigger", "aria-expanded": open, onClick: () => group?.setOpen(!open), className: cn("group/table-group -ms-2 inline-flex min-w-0 cursor-pointer items-center gap-2 rounded-item material-row px-2 focus-ring select-none", dense ? "min-h-(--control-inset-sm)" : "min-h-(--control-h-sm)"), children: [_jsx(ChevronRightIcon, { "aria-hidden": true, className: "size-3.5 shrink-0 text-muted-foreground transition-[rotate] duration-(--duration) ease-(--ease) group-aria-expanded/table-group:rotate-90 rtl:-scale-x-100 rtl:group-aria-expanded/table-group:-rotate-90" }), label] })) : (_jsx("span", { className: "inline-flex min-w-0 items-center gap-2", children: label })), summary != null && (_jsx("span", { "data-slot": "table-group-summary", className: "ms-auto shrink-0 font-mono text-[12px] whitespace-nowrap text-muted-foreground tabular-nums", children: summary }))] }));
459
+ const band = cn("relative bg-control-surface text-start align-middle font-normal", "after:pointer-events-none after:absolute after:inset-x-0 after:bottom-0 after:h-px after:bg-border/60", dense ? "h-(--control-h-sm)" : "h-(--control-h)");
460
+ if (fit)
461
+ return (_jsx("div", { role: "row", "data-slot": "table-group-header", "data-flip": "band", "data-sticky": sticky ? "" : undefined, className: cn(SUBGRID, sticky && "sticky top-0 z-2", className), ...virtualProps, ...props, ref: rowRef, children: _jsx("div", { role: "rowheader", "aria-colspan": fit.count || undefined, "data-slot": "table-group-band", className: cn(band, "col-span-full flex items-center px-(--table-pad)"), children: content }) }));
462
+ return (_jsx("tr", { "data-slot": "table-group-header", "data-sticky": sticky ? "" : undefined, className: className, ...virtualProps, ...props, ref: rowRef, children: _jsx("th", { scope: "rowgroup", colSpan: colSpan, "data-slot": "table-group-band",
463
+ // Sticks 1px above the top: a sticky cell in a collapsed-border table leaves its top pixel
464
+ // uncovered, and the rows scrolling under showed through it; the scroller clips the extra.
465
+ className: cn(band, "px-6", sticky && "sticky -top-px z-1"), children: content }) }));
466
+ }
467
+ const TableVirtualRowContext = React.createContext(null);
468
+ /** A row's `data-index`, `aria-rowindex` and measuring ref, when a `TableVirtualBody` renders it. */
469
+ function useVirtualRow(ref) {
470
+ const virtual = React.useContext(TableVirtualRowContext);
471
+ const measure = virtual?.measure;
472
+ const rowRef = React.useMemo(() => (measure ? mergeRefs(measure, ref) : ref), [measure, ref]);
473
+ const props = virtual ? { "data-index": virtual.index, "aria-rowindex": virtual.rowIndex } : undefined;
474
+ return [props, rowRef];
475
+ }
476
+ /** Rows drawn before the scroller is measured: on the server, and in the first client render. */
477
+ const FIRST_ROWS = 40;
478
+ /** The height of the view assumed until the scroller is measured. */
479
+ const FIRST_VIEW = 1000;
480
+ /** The most a virtual body is drawn tall, under every browser's limit: more rows share it. */
481
+ const MAX_HEIGHT = 15_000_000;
482
+ /** A compressed body keeps the scroll position as rows are measured: a pixel there isn't one here. */
483
+ const noAdjust = () => false;
484
+ const isWindow = (value) => typeof window !== "undefined" && value === window;
485
+ /**
486
+ * The nearest ancestor that scrolls vertically — the table's own box when it has a height, a
487
+ * dialog's body, an app shell's main area — or else the window.
488
+ */
489
+ function scrollParent(el) {
490
+ for (let node = el.parentElement; node && node !== document.body; node = node.parentElement) {
491
+ const { overflowY } = getComputedStyle(node);
492
+ if (/auto|scroll|overlay/.test(overflowY) && node.scrollHeight > node.clientHeight + 1)
493
+ return node;
494
+ }
495
+ return window;
496
+ }
497
+ /** Where `el` starts in `scroller`'s content: how far below its top it is, scrolled to the top. */
498
+ function offsetIn(el, scroller) {
499
+ const top = el.getBoundingClientRect().top;
500
+ if (isWindow(scroller))
501
+ return top + scroller.scrollY;
502
+ return top - scroller.getBoundingClientRect().top - scroller.clientTop + scroller.scrollTop;
503
+ }
504
+ /** Each field's value: what a `TableVirtualBody` sizes its columns by, unless given `sizeRows`. */
505
+ const fieldsOf = (row) => Array.isArray(row) ? row : row !== null && typeof row === "object" ? Object.values(row) : [row];
506
+ /** A group's header, rendered by `VirtualRow` like a row: it is an element already. */
507
+ const renderHeader = (header) => header;
508
+ /** One rendered row. Rows that stay in view are not rendered again as the table scrolls. */
509
+ const VirtualRow = React.memo(function VirtualRow({ index, rowIndex, measure, row, at, render, }) {
510
+ const value = React.useMemo(() => ({ index, rowIndex, measure }), [index, rowIndex, measure]);
511
+ return _jsx(TableVirtualRowContext.Provider, { value: value, children: render(row, at) });
512
+ });
513
+ /**
514
+ * TableVirtualBody — the body of a table with thousands of rows, in place of `TableBody` (or the
515
+ * `TableGroup`s): it renders only the rows in view and a few beyond, and the space of the others,
516
+ * as the table's own box or the page scrolls. Pass the rows and how to render one; the rows can be
517
+ * grouped, and work in every Table mode (`dense`, `fit`, sticky group headers).
518
+ *
519
+ * Use it from a few hundred rows on. The rule people break: reaching for it for a page of rows —
520
+ * rows that are not rendered can't be found with the browser's search or printed.
521
+ */
522
+ export function TableVirtualBody({ rows, groups, renderRow, getRowKey, sizeRows, overscan = 8, scrollResetKey, onRangeChange, }) {
523
+ const fit = React.useContext(TableFitContext);
524
+ const dense = React.useContext(TableDenseContext);
525
+ /** The sizer rows' group, of no height: the rows start at its top. */
526
+ const anchorRef = React.useRef(null);
527
+ const keyRef = React.useRef(getRowKey);
528
+ keyRef.current = getRowKey;
529
+ // A group is open as it says (`open`), else as last toggled here, else as `defaultOpen` says.
530
+ const [toggled, setToggled] = React.useState(() => new Map());
531
+ const { items, spans } = React.useMemo(() => {
532
+ const items = [];
533
+ /** Each group's entries, from its header to the entry after its last row, and whether it is open. */
534
+ const spans = [];
535
+ const keyOf = (row, at) => String(keyRef.current?.(row, at) ?? at);
536
+ if (groups)
537
+ groups.forEach((group, g) => {
538
+ const start = items.length;
539
+ const open = group.open ?? toggled.get(group.key) ?? group.defaultOpen ?? true;
540
+ items.push({ header: true, key: `g:${String(group.key)}`, group: g });
541
+ if (open)
542
+ group.rows.forEach((row, at) => items.push({ header: false, key: `r:${String(group.key)}:${keyOf(row, at)}`, group: g, row, at }));
543
+ spans.push({ start, end: items.length, open });
544
+ });
545
+ return { items, spans };
546
+ }, [groups, toggled]);
547
+ // Without groups, each row is an entry of its own, made when it is asked for: a million rows
548
+ // need no list of a million entries, and rows filled in where they were (a server's, as they
549
+ // load) are read as they are now.
550
+ const count = groups ? items.length : (rows?.length ?? 0);
551
+ const itemAt = React.useCallback((i) => {
552
+ if (groups)
553
+ return items[i];
554
+ if (!rows || i < 0 || i >= rows.length)
555
+ return undefined;
556
+ const row = rows[i];
557
+ return { header: false, key: `r:${String(keyRef.current?.(row, i) ?? i)}`, group: -1, row, at: i };
558
+ }, [groups, items, rows]);
559
+ // The rows that size the columns, with their index (renderRow's second argument).
560
+ const sized = React.useMemo(() => {
561
+ if (!groups && rows && !sizeRows)
562
+ return widestRows(rows, fieldsOf).map((at) => ({ row: rows[at], at }));
563
+ const all = [];
564
+ if (groups)
565
+ for (const group of groups)
566
+ group.rows.forEach((row, at) => all.push({ row, at }));
567
+ else
568
+ rows?.forEach((row, at) => all.push({ row, at }));
569
+ if (!sizeRows)
570
+ return widestRows(all, (entry) => fieldsOf(entry.row)).map((i) => all[i]);
571
+ const index = new Map(all.map((entry) => [entry.row, entry.at]));
572
+ return sizeRows.map((row) => ({ row, at: index.get(row) ?? -1 }));
573
+ }, [rows, groups, sizeRows]);
574
+ // Rows are 46px (30px dense) and group headers 38px until they are drawn; from then on, as tall
575
+ // as most of the drawn ones (`drawn`, below). An estimate off by a pixel makes every row drawn
576
+ // move every row after it, which with a million rows is most of each frame.
577
+ const [drawnSize, setDrawnSize] = React.useState(null);
578
+ const estimate = React.useCallback((i) => groups && items[i]?.header
579
+ ? (drawnSize?.header ?? (dense ? 30 : 38))
580
+ : (drawnSize?.row ?? (dense ? 30 : 46)), [items, dense, drawnSize]);
581
+ const getItemKey = React.useCallback((i) => itemAt(i)?.key ?? i, [itemAt]);
582
+ // The last row to take the focus stays rendered wherever it scrolls, with the rows on either side,
583
+ // so Tab and Shift+Tab carry on from it to the next row, and a menu it opened can give the focus
584
+ // back to it.
585
+ const [focusKey, setFocusKey] = React.useState(null);
586
+ const focusIndex = React.useMemo(() => {
587
+ if (focusKey == null)
588
+ return -1;
589
+ for (let i = 0; i < count; i++)
590
+ if (itemAt(i).key === focusKey)
591
+ return i;
592
+ return -1;
593
+ }, [focusKey, itemAt, count]);
594
+ const rangeExtractor = React.useCallback((range) => {
595
+ const shown = new Set(defaultRangeExtractor(range));
596
+ // The group of the first row in view keeps its header, so a sticky one stays at the top.
597
+ const first = groups ? items[range.startIndex] : undefined;
598
+ if (first && first.group >= 0)
599
+ shown.add(spans[first.group].start);
600
+ if (focusIndex >= 0)
601
+ for (let i = Math.max(0, focusIndex - 1); i <= Math.min(range.count - 1, focusIndex + 1); i++)
602
+ shown.add(i);
603
+ return [...shown].sort((a, b) => a - b);
604
+ }, [groups, items, spans, focusIndex]);
605
+ // What scrolls the rows — the table's own box, an ancestor or the window — and where in it they
606
+ // start. Both are known only once the table is in the page: before that (on the server, and in
607
+ // the first render here) the first rows are drawn, the same on both.
608
+ const [scroller, setScroller] = React.useState(null);
609
+ const scrollerRef = React.useRef(null);
610
+ const [margin, setMargin] = React.useState(0);
611
+ const live = scroller != null;
612
+ // Set at each render, read as the scroller moves (see `compress`).
613
+ const realOffsetRef = React.useRef(0);
614
+ const compressRef = React.useRef(1);
615
+ const marginRef = React.useRef(0);
616
+ const toRows = (offset) => offset <= marginRef.current
617
+ ? offset
618
+ : marginRef.current + (offset - marginRef.current) * compressRef.current;
619
+ const virtualizer = useVirtualizer({
620
+ count,
621
+ enabled: live,
622
+ getScrollElement: () => scroller,
623
+ estimateSize: estimate,
624
+ getItemKey,
625
+ overscan,
626
+ scrollMargin: margin,
627
+ rangeExtractor,
628
+ initialRect: { width: 0, height: FIRST_VIEW },
629
+ initialOffset: () => toRows(!scroller ? 0 : isWindow(scroller) ? scroller.scrollY : scroller.scrollTop),
630
+ observeElementRect: (instance, cb) => isWindow(instance.scrollElement)
631
+ ? observeWindowRect(instance, cb)
632
+ : observeElementRect(instance, cb),
633
+ // The scroller's offset, in the rows' own space: past where they start, `compress` times as far.
634
+ observeElementOffset: (instance, cb) => {
635
+ const report = (offset, scrolling) => {
636
+ realOffsetRef.current = offset;
637
+ cb(toRows(offset), scrolling);
638
+ };
639
+ return isWindow(instance.scrollElement)
640
+ ? observeWindowOffset(instance, report)
641
+ : observeElementOffset(instance, report);
642
+ },
643
+ });
644
+ // Rows taller in all than a browser can draw (about 33M px in Chrome and Safari, 17M in Firefox)
645
+ // are drawn in at most MAX_HEIGHT: the space between them shrinks, and the rows in view sit
646
+ // where they would, at their own height.
647
+ const viewHeight = virtualizer.scrollRect?.height ?? FIRST_VIEW;
648
+ const virtualTotal = virtualizer.getTotalSize();
649
+ const compress = live && virtualTotal > MAX_HEIGHT ? (virtualTotal - viewHeight) / (MAX_HEIGHT - viewHeight) : 1;
650
+ compressRef.current = compress;
651
+ marginRef.current = margin;
652
+ virtualizer.shouldAdjustScrollPositionOnItemSizeChange = compress > 1 ? noAdjust : undefined;
653
+ /** Looks for the scroller again: when the rows change, or the table or the window resize. */
654
+ const findScroller = React.useCallback(() => {
655
+ const anchor = anchorRef.current;
656
+ if (!anchor)
657
+ return;
658
+ const next = scrollParent(anchor);
659
+ if (scrollerRef.current === next)
660
+ return;
661
+ // A new scroller: start from where it is scrolled, not from where the last one was.
662
+ scrollerRef.current = next;
663
+ virtualizer.scrollOffset = null;
664
+ virtualizer.scrollRect = null;
665
+ setScroller(next);
666
+ }, [virtualizer]);
667
+ /** Measures where the rows start again: whenever what is above them may have moved. */
668
+ const measureMargin = React.useCallback(() => {
669
+ const anchor = anchorRef.current;
670
+ const target = scrollerRef.current;
671
+ if (anchor && target)
672
+ setMargin(Math.round(offsetIn(anchor, target)));
673
+ }, []);
674
+ React.useLayoutEffect(() => {
675
+ findScroller();
676
+ measureMargin();
677
+ }, [findScroller, measureMargin, count]);
678
+ React.useEffect(() => {
679
+ const anchor = anchorRef.current;
680
+ if (!anchor)
681
+ return;
682
+ const sync = () => {
683
+ findScroller();
684
+ measureMargin();
685
+ };
686
+ const resized = new ResizeObserver(sync);
687
+ resized.observe(anchor.closest("[data-slot=table-container]") ?? anchor);
688
+ // What is above the rows where they scroll: the page, or the content of the box.
689
+ const moved = new ResizeObserver(measureMargin);
690
+ if (scroller && !isWindow(scroller))
691
+ for (const child of scroller.children)
692
+ moved.observe(child);
693
+ else
694
+ moved.observe(document.documentElement);
695
+ window.addEventListener("resize", sync);
696
+ return () => {
697
+ resized.disconnect();
698
+ moved.disconnect();
699
+ window.removeEventListener("resize", sync);
700
+ };
701
+ }, [findScroller, measureMargin, scroller]);
702
+ // Screen readers learn the real size: the table's row count, each row's number in it.
703
+ const [headRows, setHeadRows] = React.useState(1);
704
+ React.useLayoutEffect(() => {
705
+ const table = anchorRef.current?.closest("table, [role=table]");
706
+ if (!table)
707
+ return;
708
+ const heads = [
709
+ ...table.querySelectorAll(":scope > thead > tr, :scope > [data-slot=table-header] > [data-slot=table-row]"),
710
+ ];
711
+ setHeadRows(heads.length);
712
+ heads.forEach((row, i) => row.setAttribute("aria-rowindex", String(i + 1)));
713
+ table.setAttribute("aria-rowcount", String(heads.length + count));
714
+ return () => {
715
+ table.removeAttribute("aria-rowcount");
716
+ heads.forEach((row) => row.removeAttribute("aria-rowindex"));
717
+ };
718
+ }, [count]);
719
+ const itemsRef = React.useRef(itemAt);
720
+ itemsRef.current = itemAt;
721
+ React.useEffect(() => {
722
+ const table = anchorRef.current?.closest("table, [role=table]");
723
+ if (!table)
724
+ return;
725
+ const onFocus = (event) => {
726
+ const row = event.target instanceof Element
727
+ ? event.target.closest("[data-slot=table-row][data-index],[data-slot=table-group-header][data-index]")
728
+ : null;
729
+ if (!row || row.closest("table, [role=table]") !== table)
730
+ return;
731
+ const entry = itemsRef.current(Number(row.getAttribute("data-index")));
732
+ if (entry)
733
+ setFocusKey(entry.key);
734
+ };
735
+ table.addEventListener("focusin", onFocus);
736
+ return () => table.removeEventListener("focusin", onFocus);
737
+ }, []);
738
+ // A new search: back to the first row — the top of the table's own box, or of the table in the
739
+ // page — if the view has scrolled past it.
740
+ const resetRef = React.useRef(scrollResetKey);
741
+ React.useLayoutEffect(() => {
742
+ if (Object.is(resetRef.current, scrollResetKey))
743
+ return;
744
+ resetRef.current = scrollResetKey;
745
+ const anchor = anchorRef.current;
746
+ const target = scrollerRef.current;
747
+ if (!anchor || !target)
748
+ return;
749
+ const container = anchor.closest("[data-slot=table-container]") ?? anchor;
750
+ const top = !isWindow(target) && container.contains(target)
751
+ ? 0
752
+ : Math.max(0, Math.floor(offsetIn(container, target)));
753
+ if ((isWindow(target) ? target.scrollY : target.scrollTop) > top)
754
+ target.scrollTo({ top });
755
+ }, [scrollResetKey]);
756
+ /* Render: the entries to draw, in order, with the space of those between them as spacers. */
757
+ const measure = virtualizer.measureElement;
758
+ const shown = live
759
+ ? virtualizer.getVirtualIndexes()
760
+ : Array.from({ length: Math.min(FIRST_ROWS, count) }, (_, i) => i);
761
+ let starts = null;
762
+ if (!live) {
763
+ starts = new Float64Array(count + 1);
764
+ for (let i = 0; i < count; i++)
765
+ starts[i + 1] = starts[i] + estimate(i);
766
+ }
767
+ const startOf = (i) => (starts ? starts[i] : virtualizer.measurementsCache[i].start - margin);
768
+ const endOf = (i) => (starts ? starts[i + 1] : virtualizer.measurementsCache[i].end - margin);
769
+ const total = starts ? starts[count] : compress > 1 ? MAX_HEIGHT : virtualTotal;
770
+ // Where a point of the rows is drawn. Compressed, the view's top (`seen`, the rows' own space)
771
+ // is drawn where the scroller is (`at`), the rows around it at their height, and the rest of the
772
+ // rows shrink into the space on either side.
773
+ let place = (y) => y;
774
+ if (compress > 1) {
775
+ const at = realOffsetRef.current - margin;
776
+ const seen = at > 0 ? at * compress : at;
777
+ const near = viewHeight * 2;
778
+ const from = Math.max(0, seen - Math.min(near, Math.max(0, at)));
779
+ const to = Math.min(virtualTotal, seen + Math.min(near, Math.max(0, total - at)));
780
+ const fromAt = at - (seen - from);
781
+ const toAt = at + (to - seen);
782
+ place = (y) => y < from
783
+ ? from > 0
784
+ ? (y / from) * fromAt
785
+ : 0
786
+ : y > to
787
+ ? toAt + ((y - to) / Math.max(1, virtualTotal - to)) * (total - toAt)
788
+ : at + (y - seen);
789
+ }
790
+ // The estimate follows the rows drawn: most of them are one height (and a theme can change it).
791
+ React.useLayoutEffect(() => {
792
+ const table = anchorRef.current?.closest("table, [role=table]");
793
+ if (!live || !table)
794
+ return;
795
+ const common = (selector) => {
796
+ const count = new Map();
797
+ for (const el of table.querySelectorAll(selector)) {
798
+ const h = Math.round(el.getBoundingClientRect().height * 2) / 2;
799
+ if (h > 0)
800
+ count.set(h, (count.get(h) ?? 0) + 1);
801
+ }
802
+ let best;
803
+ for (const [h, n] of count)
804
+ if (best === undefined || n > count.get(best))
805
+ best = h;
806
+ return best;
807
+ };
808
+ const row = common(":scope [data-slot=table-row][data-index]");
809
+ const header = common(":scope [data-slot=table-group-header][data-index]");
810
+ setDrawnSize((old) => {
811
+ const next = {
812
+ row: row ?? old?.row ?? (dense ? 30 : 46),
813
+ header: header ?? old?.header ?? (dense ? 30 : 38),
814
+ };
815
+ return old && old.row === next.row && old.header === next.header ? old : next;
816
+ });
817
+ });
818
+ const spacer = (key, height, outer = false) => fit ? (_jsx("div", { "aria-hidden": true, "data-slot": "table-spacer", className: "col-span-full", style: { height } }, key)) : outer ? (_jsx("tbody", { "aria-hidden": true, "data-slot": "table-spacer", children: _jsx("tr", { children: _jsx("td", { style: { height, padding: 0 } }) }) }, key)) : (_jsx("tr", { "aria-hidden": true, "data-slot": "table-spacer", children: _jsx("td", { style: { height, padding: 0 } }) }, key));
819
+ const entry = (i) => {
820
+ const item = itemAt(i);
821
+ const rowIndex = headRows + i + 1;
822
+ if (item.header)
823
+ return (_jsx(VirtualRow, { index: i, rowIndex: rowIndex, measure: measure, row: groups[item.group].header, at: -1, render: renderHeader }, item.key));
824
+ return (_jsx(VirtualRow, { index: i, rowIndex: rowIndex, measure: measure, row: item.row, at: item.at, render: renderRow }, item.key));
825
+ };
826
+ // The rows rendered, for a body that loads them as they come into view.
827
+ // The rows in view and `overscan` beyond — not a far-off row kept for the focus.
828
+ const range = live ? virtualizer.range : null;
829
+ const firstRow = groups || !range ? -1 : Math.max(0, range.startIndex - overscan);
830
+ const lastRow = groups || !range ? -1 : Math.min(count - 1, range.endIndex + overscan);
831
+ const rangeRef = React.useRef(onRangeChange);
832
+ rangeRef.current = onRangeChange;
833
+ React.useEffect(() => {
834
+ if (lastRow >= 0)
835
+ rangeRef.current?.(firstRow, lastRow + 1);
836
+ }, [firstRow, lastRow]);
837
+ /** Where the last `run` ended. */
838
+ let runEnd = 0;
839
+ /** The shown entries `from` up to `to`, spaced out between `top` and `bottom`. */
840
+ const run = (from, to, top, bottom) => {
841
+ const out = [];
842
+ let y = top;
843
+ for (let j = from; j < to; j++) {
844
+ const i = shown[j];
845
+ const start = place(startOf(i));
846
+ if (start > y + 0.5)
847
+ out.push(spacer(`gap-${i}`, start - y));
848
+ out.push(entry(i));
849
+ y = Math.max(y, start) + endOf(i) - startOf(i);
850
+ }
851
+ if (bottom > y + 0.5)
852
+ out.push(spacer("end", bottom - y));
853
+ runEnd = Math.max(y, bottom);
854
+ return out;
855
+ };
856
+ // Rendered once per change of the rows, not as the table scrolls.
857
+ const sizerRows = React.useMemo(() => sized.map(({ row, at }, n) => _jsx(React.Fragment, { children: renderRow(row, at) }, n)), [sized, renderRow]);
858
+ const sizer = (_jsx(TableVirtualRowContext.Provider, { value: null, children: fit ? (_jsx("div", { ref: anchorRef, "aria-hidden": true, inert: true, "data-slot": "table-sizer", className: cn(SUBGRID, "invisible h-0 overflow-hidden"), children: sizerRows })) : (_jsx("tbody", { ref: anchorRef, "aria-hidden": true, inert: true, "data-slot": "table-sizer", children: sizerRows })) }));
859
+ if (!groups)
860
+ return (_jsxs(_Fragment, { children: [sizer, _jsx(TableBody, { children: run(0, shown.length, 0, total) })] }));
861
+ // Each group with a shown entry is drawn whole: its header, its rows in view and the space of
862
+ // the rest, so a sticky header stays up for as long as its group is in view.
863
+ const out = [];
864
+ let y = 0;
865
+ for (let j = 0; j < shown.length;) {
866
+ const g = items[shown[j]].group;
867
+ const { start: first, end, open } = spans[g];
868
+ const top = Math.max(y, place(startOf(first)));
869
+ const bottom = place(endOf(end - 1));
870
+ let k = j;
871
+ while (k < shown.length && items[shown[k]].group === g)
872
+ k++;
873
+ if (top > y + 0.5)
874
+ out.push(spacer(`gap-${first}`, top - y, true));
875
+ const group = groups[g];
876
+ out.push(_jsx(TableGroup, { open: open, onOpenChange: (next) => {
877
+ if (group.open === undefined)
878
+ setToggled((map) => new Map(map).set(group.key, next));
879
+ group.onOpenChange?.(next);
880
+ }, collapsible: group.collapsible, children: run(j, k, top, bottom) }, `g:${String(group.key)}`));
881
+ y = runEnd;
882
+ j = k;
883
+ }
884
+ if (total > y + 0.5)
885
+ out.push(spacer("end", total - y, true));
886
+ return (_jsxs(_Fragment, { children: [sizer, out] }));
887
+ }
888
+ /** A short description of the table, under it. Prefer it over a heading inside the card. */
889
+ export function TableCaption({ className, ...props }) {
890
+ const fit = React.useContext(TableFitContext);
891
+ const classes = "border-t border-border/60 py-4 text-start text-[13px] text-muted-foreground";
892
+ if (fit)
893
+ return (_jsx("div", { role: "caption", "data-slot": "table-caption", className: cn(classes, "order-last col-span-full px-(--table-pad)", className), ...props }));
894
+ return _jsx("caption", { "data-slot": "table-caption", className: cn(classes, "px-6", className), ...props });
895
+ }