@jcsoftdev/ui 0.5.0 → 0.6.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 (373) hide show
  1. package/CHANGELOG.md +337 -0
  2. package/README.md +25 -3
  3. package/bin/ui-theme.mjs +40 -6
  4. package/dist/ai/code-block/code-block.js +1 -1
  5. package/dist/atoms/big-date/big-date.js +2 -2
  6. package/dist/atoms/button/button.d.ts +6 -1
  7. package/dist/atoms/button/button.js +2 -2
  8. package/dist/atoms/chip/chip.d.ts +5 -0
  9. package/dist/atoms/chip/chip.js +3 -3
  10. package/dist/atoms/icon-button/icon-button.js +1 -1
  11. package/dist/atoms/internal/hit-area.d.ts +5 -4
  12. package/dist/atoms/internal/hit-area.js +1 -1
  13. package/dist/atoms/progress/index.d.ts +1 -1
  14. package/dist/atoms/progress/index.js +4 -1
  15. package/dist/atoms/progress/progress.d.ts +6 -1
  16. package/dist/atoms/progress/progress.js +19 -1
  17. package/dist/atoms/radio-group/radio-group.js +1 -1
  18. package/dist/atoms/status-pill/status-pill.d.ts +16 -5
  19. package/dist/atoms/status-pill/status-pill.js +43 -18
  20. package/dist/brand/logo-forge.js +1 -1
  21. package/dist/charts/candlestick-chart/candlestick-chart.js +2 -2
  22. package/dist/charts/chart-grid/chart-grid.js +2 -2
  23. package/dist/charts/chord-chart/chord-chart.js +1 -1
  24. package/dist/charts/core/axes.js +2 -2
  25. package/dist/charts/core/cartesian/annotations.js +2 -2
  26. package/dist/charts/core/cartesian/marks.js +1 -1
  27. package/dist/charts/core/distribution/marks.js +1 -1
  28. package/dist/charts/core/distribution/xy-points.js +1 -1
  29. package/dist/charts/core/export-menu.js +1 -1
  30. package/dist/charts/funnel-chart/funnel-chart.js +1 -1
  31. package/dist/charts/gantt-chart/gantt-chart.js +4 -4
  32. package/dist/charts/gantt-chart/gantt-marks.js +3 -3
  33. package/dist/charts/index.d.ts +2 -0
  34. package/dist/charts/index.js +2 -0
  35. package/dist/charts/maps/geo/map-data-table.js +1 -1
  36. package/dist/charts/polar-area-chart/polar-area-chart.js +1 -1
  37. package/dist/charts/radar-chart/radar-chart.js +1 -1
  38. package/dist/charts/stock-chart/stock-chart.js +1 -1
  39. package/dist/charts/stock-chart/stock-drawing-layer.js +3 -3
  40. package/dist/charts/stock-chart/stock-plot.js +2 -2
  41. package/dist/containers/chat-thread/chat-thread.d.ts +98 -0
  42. package/dist/containers/chat-thread/chat-thread.js +219 -0
  43. package/dist/containers/chat-thread/format.d.ts +20 -0
  44. package/dist/containers/chat-thread/format.js +50 -0
  45. package/dist/containers/chat-thread/index.d.ts +1 -0
  46. package/dist/containers/chat-thread/index.js +8 -0
  47. package/dist/containers/cols/cols.d.ts +1 -1
  48. package/dist/containers/cols/cols.js +7 -0
  49. package/dist/containers/comment/comment.js +1 -1
  50. package/dist/containers/context-rail/context-rail.d.ts +62 -0
  51. package/dist/containers/context-rail/context-rail.js +175 -0
  52. package/dist/containers/context-rail/index.d.ts +1 -0
  53. package/dist/containers/context-rail/index.js +6 -0
  54. package/dist/containers/dashboard/dashboard.d.ts +40 -0
  55. package/dist/containers/dashboard/dashboard.js +84 -0
  56. package/dist/containers/dashboard/index.d.ts +1 -0
  57. package/dist/containers/dashboard/index.js +14 -0
  58. package/dist/containers/data-grid/data-grid.demos.js +4 -4
  59. package/dist/containers/data-grid/data-grid.js +6 -6
  60. package/dist/containers/data-grid/filter-builder-editor.js +2 -2
  61. package/dist/containers/data-grid/grid-toolbar.js +1 -1
  62. package/dist/containers/data-grid/spreadsheet.demos.d.ts +1 -1
  63. package/dist/containers/data-grid/spreadsheet.demos.js +1 -1
  64. package/dist/containers/detail-header/detail-header.d.ts +24 -0
  65. package/dist/containers/detail-header/detail-header.js +32 -0
  66. package/dist/containers/detail-header/index.d.ts +1 -0
  67. package/dist/containers/detail-header/index.js +6 -0
  68. package/dist/containers/facts/facts.js +1 -1
  69. package/dist/containers/filter-bar/filter-bar.d.ts +58 -0
  70. package/dist/containers/filter-bar/filter-bar.js +123 -0
  71. package/dist/containers/filter-bar/index.d.ts +1 -0
  72. package/dist/containers/filter-bar/index.js +6 -0
  73. package/dist/containers/hbars/hbars.js +2 -2
  74. package/dist/containers/index.d.ts +9 -0
  75. package/dist/containers/index.js +9 -0
  76. package/dist/containers/kanban/kanban.d.ts +23 -2
  77. package/dist/containers/kanban/kanban.js +101 -21
  78. package/dist/containers/kanban/model.d.ts +12 -0
  79. package/dist/containers/kanban/model.js +8 -0
  80. package/dist/containers/kpi/kpi.js +1 -1
  81. package/dist/containers/kpi-group/kpi-group.d.ts +6 -1
  82. package/dist/containers/kpi-group/kpi-group.js +6 -2
  83. package/dist/containers/list-detail/index.d.ts +1 -1
  84. package/dist/containers/list-detail/index.js +4 -0
  85. package/dist/containers/list-detail/list-detail.d.ts +51 -3
  86. package/dist/containers/list-detail/list-detail.js +109 -15
  87. package/dist/containers/page/page.d.ts +17 -4
  88. package/dist/containers/page/page.js +33 -4
  89. package/dist/containers/page-header/back.d.ts +10 -0
  90. package/dist/containers/page-header/back.js +28 -0
  91. package/dist/containers/page-header/index.d.ts +1 -0
  92. package/dist/containers/page-header/index.js +1 -0
  93. package/dist/containers/page-header/page-header.d.ts +19 -2
  94. package/dist/containers/page-header/page-header.js +26 -2
  95. package/dist/containers/pagination/cursor-pagination.d.ts +28 -0
  96. package/dist/containers/pagination/cursor-pagination.js +48 -0
  97. package/dist/containers/pagination/index.d.ts +3 -0
  98. package/dist/containers/pagination/index.js +10 -0
  99. package/dist/containers/pagination/pagination.d.ts +52 -0
  100. package/dist/containers/pagination/pagination.js +216 -0
  101. package/dist/containers/pagination/range.d.ts +29 -0
  102. package/dist/containers/pagination/range.js +42 -0
  103. package/dist/containers/pagination/use-pagination.d.ts +18 -0
  104. package/dist/containers/pagination/use-pagination.js +22 -0
  105. package/dist/containers/responsive-list/responsive-list.d.ts +28 -2
  106. package/dist/containers/responsive-list/responsive-list.js +134 -25
  107. package/dist/containers/row-actions/index.d.ts +1 -0
  108. package/dist/containers/row-actions/index.js +4 -0
  109. package/dist/containers/row-actions/row-actions.d.ts +26 -0
  110. package/dist/containers/row-actions/row-actions.js +78 -0
  111. package/dist/containers/selectable-card/index.d.ts +1 -0
  112. package/dist/containers/selectable-card/index.js +6 -0
  113. package/dist/containers/selectable-card/selectable-card.d.ts +26 -0
  114. package/dist/containers/selectable-card/selectable-card.js +57 -0
  115. package/dist/containers/settings-layout/settings-layout.d.ts +24 -7
  116. package/dist/containers/settings-layout/settings-layout.js +63 -8
  117. package/dist/containers/shortcuts/shortcuts.js +1 -1
  118. package/dist/containers/table/cell-padding.d.ts +2 -0
  119. package/dist/containers/table/cell-padding.js +4 -0
  120. package/dist/containers/table/index.d.ts +1 -0
  121. package/dist/containers/table/index.js +8 -0
  122. package/dist/containers/table/sort.d.ts +14 -0
  123. package/dist/containers/table/sort.js +11 -0
  124. package/dist/containers/table/table-parts.d.ts +24 -0
  125. package/dist/containers/table/table-parts.js +52 -0
  126. package/dist/containers/table/table.d.ts +37 -3
  127. package/dist/containers/table/table.js +120 -19
  128. package/dist/containers/table-columns-menu/index.d.ts +1 -0
  129. package/dist/containers/table-columns-menu/index.js +6 -0
  130. package/dist/containers/table-columns-menu/table-columns-menu.d.ts +14 -0
  131. package/dist/containers/table-columns-menu/table-columns-menu.js +46 -0
  132. package/dist/dashboards/layout.d.ts +1 -27
  133. package/dist/dashboards/layout.js +8 -40
  134. package/dist/forms/chip-group/chip-group.d.ts +5 -0
  135. package/dist/forms/chip-group/chip-group.js +3 -1
  136. package/dist/forms/combobox/combobox.js +1 -1
  137. package/dist/forms/copy-field/copy-field.js +1 -1
  138. package/dist/forms/date-picker/date-picker.d.ts +3 -1
  139. package/dist/forms/date-picker/date-picker.js +4 -2
  140. package/dist/forms/date-picker/date-time-picker.d.ts +8 -2
  141. package/dist/forms/date-picker/date-time-picker.js +13 -2
  142. package/dist/forms/field/field.d.ts +9 -2
  143. package/dist/forms/field/field.js +18 -4
  144. package/dist/forms/fieldset/fieldset.d.ts +11 -0
  145. package/dist/forms/fieldset/fieldset.js +12 -0
  146. package/dist/forms/fieldset/index.d.ts +1 -0
  147. package/dist/forms/fieldset/index.js +4 -0
  148. package/dist/forms/form-footer/form-footer.d.ts +26 -0
  149. package/dist/forms/form-footer/form-footer.js +44 -0
  150. package/dist/forms/form-footer/index.d.ts +1 -0
  151. package/dist/forms/form-footer/index.js +4 -0
  152. package/dist/forms/form-grid/form-grid.d.ts +21 -4
  153. package/dist/forms/form-grid/form-grid.js +20 -3
  154. package/dist/forms/form-grid/index.d.ts +1 -1
  155. package/dist/forms/form-grid/index.js +6 -2
  156. package/dist/forms/form-section/form-section.d.ts +12 -0
  157. package/dist/forms/form-section/form-section.js +30 -0
  158. package/dist/forms/form-section/index.d.ts +1 -0
  159. package/dist/forms/form-section/index.js +4 -0
  160. package/dist/forms/index.d.ts +3 -0
  161. package/dist/forms/index.js +3 -0
  162. package/dist/forms/input/input.d.ts +6 -2
  163. package/dist/forms/input/input.js +4 -1
  164. package/dist/forms/internal/listbox-items.d.ts +1 -1
  165. package/dist/forms/internal/listbox-items.js +3 -2
  166. package/dist/forms/native-select/native-select.js +1 -1
  167. package/dist/forms/select/index.d.ts +1 -1
  168. package/dist/forms/select/select.d.ts +5 -2
  169. package/dist/forms/select/select.js +7 -2
  170. package/dist/forms/select-menu/select-menu.js +1 -1
  171. package/dist/forms/time-input/time-input.d.ts +4 -2
  172. package/dist/forms/time-input/time-input.js +3 -1
  173. package/dist/i18n/strings.d.ts +86 -0
  174. package/dist/i18n/strings.js +46 -0
  175. package/dist/motion/count-up.d.ts +20 -0
  176. package/dist/motion/count-up.js +59 -0
  177. package/dist/motion/cross-fade.d.ts +21 -0
  178. package/dist/motion/cross-fade.js +86 -0
  179. package/dist/motion/index.d.ts +5 -0
  180. package/dist/motion/index.js +14 -0
  181. package/dist/motion/model.d.ts +15 -0
  182. package/dist/motion/model.js +68 -0
  183. package/dist/motion/motion-styles.d.ts +1 -0
  184. package/dist/motion/motion-styles.js +35 -0
  185. package/dist/motion/reveal.d.ts +37 -0
  186. package/dist/motion/reveal.js +69 -0
  187. package/dist/motion/use-enter-phase.d.ts +11 -0
  188. package/dist/motion/use-enter-phase.js +40 -0
  189. package/dist/motion/use-highlight-row.d.ts +22 -0
  190. package/dist/motion/use-highlight-row.js +38 -0
  191. package/dist/navigation/tabs/tabs.js +1 -1
  192. package/dist/navigation/wizard/wizard.d.ts +4 -1
  193. package/dist/navigation/wizard/wizard.js +3 -0
  194. package/dist/overlays/alert-dialog/alert-dialog.js +8 -1
  195. package/dist/overlays/context-menu/context-menu.js +3 -1
  196. package/dist/overlays/dialog/dialog.js +10 -2
  197. package/dist/overlays/drawer/drawer.d.ts +18 -4
  198. package/dist/overlays/drawer/drawer.js +53 -4
  199. package/dist/overlays/drawer/index.d.ts +1 -1
  200. package/dist/overlays/dropdown-menu/dropdown-menu.d.ts +1 -1
  201. package/dist/overlays/dropdown-menu/dropdown-menu.js +5 -4
  202. package/dist/overlays/hover-card/hover-card.js +2 -0
  203. package/dist/overlays/popover/popover.js +2 -0
  204. package/dist/overlays/toaster/index.d.ts +1 -1
  205. package/dist/overlays/toaster/toaster.d.ts +28 -2
  206. package/dist/overlays/toaster/toaster.js +73 -29
  207. package/dist/overlays/tooltip/tooltip.js +2 -0
  208. package/dist/primitives/use-presence.js +9 -0
  209. package/dist/shell/app-shell/app-shell.d.ts +8 -1
  210. package/dist/shell/app-shell/app-shell.js +50 -3
  211. package/dist/shell/index.d.ts +1 -0
  212. package/dist/shell/index.js +1 -0
  213. package/dist/shell/sidebar/sidebar.d.ts +17 -1
  214. package/dist/shell/sidebar/sidebar.js +126 -76
  215. package/dist/shell/topbar/topbar.d.ts +4 -2
  216. package/dist/shell/topbar/topbar.js +2 -0
  217. package/dist/showcase/operations-bento.js +2 -2
  218. package/dist/states/empty-state/empty-state.d.ts +10 -3
  219. package/dist/states/empty-state/empty-state.js +46 -5
  220. package/dist/states/error-state/error-state.js +1 -1
  221. package/dist/states/skeleton/skeleton.js +1 -1
  222. package/dist/utils/class-tokens.generated.js +4 -6
  223. package/dist/utils/list-navigation.d.ts +14 -0
  224. package/dist/utils/list-navigation.js +44 -0
  225. package/dist/utils/overlay-motion.d.ts +12 -0
  226. package/dist/utils/overlay-motion.js +14 -0
  227. package/dist/utils/use-container-width.d.ts +6 -0
  228. package/dist/utils/use-container-width.js +19 -0
  229. package/package.json +2 -2
  230. package/scripts/build-theme.mjs +46 -5
  231. package/src/ai/code-block/code-block.tsx +1 -1
  232. package/src/atoms/big-date/big-date.tsx +2 -2
  233. package/src/atoms/button/button.tsx +8 -3
  234. package/src/atoms/chip/chip.tsx +8 -3
  235. package/src/atoms/icon-button/icon-button.tsx +1 -1
  236. package/src/atoms/internal/hit-area.ts +5 -4
  237. package/src/atoms/progress/index.ts +8 -1
  238. package/src/atoms/progress/progress.tsx +30 -1
  239. package/src/atoms/radio-group/radio-group.tsx +1 -1
  240. package/src/atoms/status-pill/status-pill.tsx +59 -18
  241. package/src/brand/logo-forge.tsx +1 -1
  242. package/src/charts/candlestick-chart/candlestick-chart.tsx +2 -2
  243. package/src/charts/chart-grid/chart-grid.tsx +2 -2
  244. package/src/charts/chord-chart/chord-chart.tsx +1 -1
  245. package/src/charts/core/axes.tsx +2 -2
  246. package/src/charts/core/cartesian/annotations.tsx +2 -2
  247. package/src/charts/core/cartesian/marks.tsx +1 -1
  248. package/src/charts/core/distribution/marks.tsx +1 -1
  249. package/src/charts/core/distribution/xy-points.tsx +1 -1
  250. package/src/charts/core/export-menu.tsx +1 -1
  251. package/src/charts/funnel-chart/funnel-chart.tsx +1 -1
  252. package/src/charts/gantt-chart/gantt-chart.tsx +4 -4
  253. package/src/charts/gantt-chart/gantt-marks.tsx +3 -3
  254. package/src/charts/index.ts +2 -0
  255. package/src/charts/maps/geo/map-data-table.tsx +1 -1
  256. package/src/charts/polar-area-chart/polar-area-chart.tsx +1 -1
  257. package/src/charts/radar-chart/radar-chart.tsx +1 -1
  258. package/src/charts/stock-chart/stock-chart.tsx +1 -1
  259. package/src/charts/stock-chart/stock-drawing-layer.tsx +3 -3
  260. package/src/charts/stock-chart/stock-plot.tsx +2 -2
  261. package/src/containers/chat-thread/chat-thread.tsx +331 -0
  262. package/src/containers/chat-thread/format.ts +67 -0
  263. package/src/containers/chat-thread/index.ts +12 -0
  264. package/src/containers/cols/cols.tsx +13 -1
  265. package/src/containers/comment/comment.tsx +1 -1
  266. package/src/containers/context-rail/context-rail.tsx +229 -0
  267. package/src/containers/context-rail/index.ts +7 -0
  268. package/src/containers/dashboard/dashboard.tsx +142 -0
  269. package/src/containers/dashboard/index.ts +12 -0
  270. package/src/containers/data-grid/data-grid.demos.tsx +4 -4
  271. package/src/containers/data-grid/data-grid.tsx +6 -6
  272. package/src/containers/data-grid/filter-builder-editor.tsx +2 -2
  273. package/src/containers/data-grid/grid-toolbar.tsx +1 -1
  274. package/src/containers/data-grid/spreadsheet.demos.tsx +1 -1
  275. package/src/containers/detail-header/detail-header.tsx +64 -0
  276. package/src/containers/detail-header/index.ts +5 -0
  277. package/src/containers/facts/facts.tsx +1 -1
  278. package/src/containers/filter-bar/filter-bar.tsx +201 -0
  279. package/src/containers/filter-bar/index.ts +7 -0
  280. package/src/containers/hbars/hbars.tsx +2 -2
  281. package/src/containers/index.ts +9 -0
  282. package/src/containers/kanban/kanban.tsx +146 -39
  283. package/src/containers/kanban/model.ts +20 -0
  284. package/src/containers/kpi/kpi.tsx +1 -1
  285. package/src/containers/kpi-group/kpi-group.tsx +17 -2
  286. package/src/containers/list-detail/index.ts +5 -0
  287. package/src/containers/list-detail/list-detail.tsx +157 -9
  288. package/src/containers/page/page.tsx +61 -7
  289. package/src/containers/page-header/back.tsx +42 -0
  290. package/src/containers/page-header/index.ts +1 -0
  291. package/src/containers/page-header/page-header.tsx +49 -3
  292. package/src/containers/pagination/cursor-pagination.tsx +79 -0
  293. package/src/containers/pagination/index.ts +7 -0
  294. package/src/containers/pagination/pagination.tsx +266 -0
  295. package/src/containers/pagination/range.ts +68 -0
  296. package/src/containers/pagination/use-pagination.ts +44 -0
  297. package/src/containers/responsive-list/responsive-list.tsx +183 -46
  298. package/src/containers/row-actions/index.ts +1 -0
  299. package/src/containers/row-actions/row-actions.tsx +114 -0
  300. package/src/containers/selectable-card/index.ts +5 -0
  301. package/src/containers/selectable-card/selectable-card.tsx +84 -0
  302. package/src/containers/settings-layout/settings-layout.tsx +104 -13
  303. package/src/containers/shortcuts/shortcuts.tsx +1 -1
  304. package/src/containers/table/cell-padding.ts +2 -0
  305. package/src/containers/table/index.ts +6 -0
  306. package/src/containers/table/sort.ts +23 -0
  307. package/src/containers/table/table-parts.tsx +81 -0
  308. package/src/containers/table/table.tsx +212 -45
  309. package/src/containers/table-columns-menu/index.ts +5 -0
  310. package/src/containers/table-columns-menu/table-columns-menu.tsx +68 -0
  311. package/src/dashboards/layout.tsx +8 -75
  312. package/src/forms/chip-group/chip-group.tsx +8 -1
  313. package/src/forms/combobox/combobox.tsx +1 -1
  314. package/src/forms/copy-field/copy-field.tsx +1 -1
  315. package/src/forms/date-picker/date-picker.tsx +7 -2
  316. package/src/forms/date-picker/date-time-picker.tsx +28 -2
  317. package/src/forms/field/field.tsx +30 -3
  318. package/src/forms/fieldset/fieldset.tsx +22 -0
  319. package/src/forms/fieldset/index.ts +1 -0
  320. package/src/forms/form-footer/form-footer.tsx +74 -0
  321. package/src/forms/form-footer/index.ts +1 -0
  322. package/src/forms/form-grid/form-grid.tsx +42 -5
  323. package/src/forms/form-grid/index.ts +8 -1
  324. package/src/forms/form-section/form-section.tsx +41 -0
  325. package/src/forms/form-section/index.ts +1 -0
  326. package/src/forms/index.ts +3 -0
  327. package/src/forms/input/input.tsx +10 -3
  328. package/src/forms/internal/listbox-items.tsx +3 -4
  329. package/src/forms/native-select/native-select.tsx +1 -1
  330. package/src/forms/select/index.ts +1 -1
  331. package/src/forms/select/select.tsx +14 -3
  332. package/src/forms/select-menu/select-menu.tsx +1 -1
  333. package/src/forms/time-input/time-input.tsx +6 -2
  334. package/src/i18n/strings.ts +86 -0
  335. package/src/motion/count-up.tsx +83 -0
  336. package/src/motion/cross-fade.tsx +139 -0
  337. package/src/motion/index.ts +5 -0
  338. package/src/motion/model.ts +86 -0
  339. package/src/motion/motion-styles.tsx +47 -0
  340. package/src/motion/reveal.tsx +115 -0
  341. package/src/motion/use-enter-phase.ts +50 -0
  342. package/src/motion/use-highlight-row.ts +63 -0
  343. package/src/navigation/tabs/tabs.tsx +1 -1
  344. package/src/navigation/wizard/wizard.tsx +6 -1
  345. package/src/overlays/alert-dialog/alert-dialog.tsx +5 -1
  346. package/src/overlays/context-menu/context-menu.tsx +3 -2
  347. package/src/overlays/dialog/dialog.tsx +7 -2
  348. package/src/overlays/drawer/drawer.tsx +68 -6
  349. package/src/overlays/drawer/index.ts +1 -0
  350. package/src/overlays/dropdown-menu/dropdown-menu.tsx +5 -4
  351. package/src/overlays/hover-card/hover-card.tsx +2 -0
  352. package/src/overlays/popover/popover.tsx +2 -0
  353. package/src/overlays/toaster/index.ts +2 -0
  354. package/src/overlays/toaster/toaster.tsx +113 -17
  355. package/src/overlays/tooltip/tooltip.tsx +2 -0
  356. package/src/primitives/use-presence.ts +13 -0
  357. package/src/shell/app-shell/app-shell.tsx +54 -2
  358. package/src/shell/index.ts +1 -0
  359. package/src/shell/sidebar/sidebar.tsx +154 -75
  360. package/src/shell/topbar/topbar.tsx +8 -0
  361. package/src/showcase/operations-bento.tsx +2 -2
  362. package/src/states/empty-state/empty-state.tsx +52 -9
  363. package/src/states/error-state/error-state.tsx +1 -1
  364. package/src/states/skeleton/skeleton.tsx +1 -1
  365. package/src/utils/class-tokens.generated.ts +4 -6
  366. package/src/utils/list-navigation.ts +63 -0
  367. package/src/utils/overlay-motion.ts +33 -0
  368. package/src/utils/use-container-width.ts +24 -0
  369. package/styles/Theme.kt +15 -18
  370. package/styles/tailwind.css +29 -28
  371. package/styles/theme.css +29 -28
  372. package/styles/tokens.css +46 -0
  373. package/tokens/default.json +51 -29
@@ -0,0 +1,331 @@
1
+ "use client";
2
+
3
+ import { type ReactNode, useEffect, useLayoutEffect, useRef } from "react";
4
+ import { Button } from "../../atoms/button/button.js";
5
+ import { useUiStrings } from "../../i18n/index.js";
6
+ import { Check, CheckCheck } from "../../icons/index.js";
7
+ import type { ClassNames } from "../../utils/class-names.js";
8
+ import { cn } from "../../utils/cn.js";
9
+ import { type ChatTimestamp, dayKey, formatDay, formatTime, withDayBreaks } from "./format.js";
10
+
11
+ export type ChatAuthorKind = "customer" | "bot" | "staff";
12
+ export type ChatDeliveryStatus = "sending" | "sent" | "delivered" | "read" | "failed";
13
+
14
+ export interface ChatThreadMessage {
15
+ id: string;
16
+ kind?: "message";
17
+ /** Who wrote it: the customer (incoming), the bot or a staff member (outgoing). */
18
+ author: ChatAuthorKind;
19
+ /** Name shown above the bubble. Defaults to the localized author kind. */
20
+ name?: string;
21
+ at: ChatTimestamp;
22
+ content: ReactNode;
23
+ /** Delivery state, shown under outgoing messages only. Omit it to show none. */
24
+ status?: ChatDeliveryStatus;
25
+ }
26
+
27
+ /** A line in the middle of the thread that is not a message, e.g. "The customer asked for a person". */
28
+ export interface ChatThreadNote {
29
+ id: string;
30
+ kind: "note";
31
+ at: ChatTimestamp;
32
+ content: ReactNode;
33
+ }
34
+
35
+ export type ChatThreadItem = ChatThreadMessage | ChatThreadNote;
36
+
37
+ export interface ChatThreadLabels {
38
+ conversation: string;
39
+ today: string;
40
+ yesterday: string;
41
+ customer: string;
42
+ bot: string;
43
+ staff: string;
44
+ sending: string;
45
+ sent: string;
46
+ delivered: string;
47
+ read: string;
48
+ notSent: string;
49
+ }
50
+
51
+ /** Ready-made labels; the thread defaults to `en`. Pass `chatThreadLabels.es` for Spanish. */
52
+ export const chatThreadLabels = {
53
+ en: {
54
+ conversation: "Conversation",
55
+ today: "Today",
56
+ yesterday: "Yesterday",
57
+ customer: "Customer",
58
+ bot: "Bot",
59
+ staff: "Staff",
60
+ sending: "Sending",
61
+ sent: "Sent",
62
+ delivered: "Delivered",
63
+ read: "Read",
64
+ notSent: "Not sent",
65
+ },
66
+ es: {
67
+ conversation: "Conversación",
68
+ today: "Hoy",
69
+ yesterday: "Ayer",
70
+ customer: "Cliente",
71
+ bot: "Bot",
72
+ staff: "Equipo",
73
+ sending: "Enviando",
74
+ sent: "Enviado",
75
+ delivered: "Entregado",
76
+ read: "Leído",
77
+ notSent: "No se envió",
78
+ },
79
+ } as const satisfies Record<"en" | "es", ChatThreadLabels>;
80
+
81
+ export type ChatThreadPart =
82
+ | "root"
83
+ | "log"
84
+ | "day"
85
+ | "message"
86
+ | "bubble"
87
+ | "author"
88
+ | "meta"
89
+ | "note"
90
+ | "composer";
91
+
92
+ export interface ChatThreadProps {
93
+ items: readonly ChatThreadItem[];
94
+ /** Slot under the thread, usually a `Textarea` or `PromptInput` with a send button. */
95
+ composer?: ReactNode;
96
+ /** Texts of the thread (name, day labels, authors, delivery states). English by default; see `chatThreadLabels`. */
97
+ labels?: Partial<ChatThreadLabels>;
98
+ /** Accessible name of the thread. Defaults to `labels.conversation`. */
99
+ label?: string;
100
+ /** Called by the retry button of a `failed` message. Without it the button is not shown. */
101
+ onRetry?: (id: string) => void;
102
+ /** Shown instead of the log while there are no items. */
103
+ empty?: ReactNode;
104
+ /** `Intl` locale for times and day labels. */
105
+ locale?: string;
106
+ /** Time zone for times and day breaks; the local one when omitted. */
107
+ timeZone?: string;
108
+ /** The instant "Today" refers to. Pass a fixed value for stable output. Defaults to the current time. */
109
+ now?: ChatTimestamp;
110
+ className?: string;
111
+ /** Per-part classes merged with `cn`; consumer classes win. `className` still targets the root and is merged last. */
112
+ classNames?: ClassNames<ChatThreadPart>;
113
+ }
114
+
115
+ const useIsomorphicLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
116
+
117
+ const bubbleTone: Record<ChatAuthorKind, string> = {
118
+ customer: "bg-surface-2 text-ink",
119
+ bot: "border border-accent-line bg-accent-soft text-accent-ink",
120
+ staff: "bg-accent text-on-accent",
121
+ };
122
+
123
+ function Status({ status, labels }: { status: ChatDeliveryStatus; labels: ChatThreadLabels }) {
124
+ const label = {
125
+ sending: labels.sending,
126
+ sent: labels.sent,
127
+ delivered: labels.delivered,
128
+ read: labels.read,
129
+ failed: labels.notSent,
130
+ }[status];
131
+ return (
132
+ <span
133
+ data-status={status}
134
+ className={cn(
135
+ "inline-flex items-center gap-1",
136
+ status === "read" && "text-accent-ink",
137
+ status === "failed" && "text-danger",
138
+ )}
139
+ >
140
+ {status === "sent" ? <Check aria-hidden="true" className="size-3" /> : null}
141
+ {status === "delivered" || status === "read" ? (
142
+ <CheckCheck aria-hidden="true" className="size-3" />
143
+ ) : null}
144
+ {label}
145
+ </span>
146
+ );
147
+ }
148
+
149
+ /**
150
+ * Business conversation between a customer, a bot and staff: incoming messages on the start side,
151
+ * outgoing ones (bot, staff) on the end side with distinct tones, day separators, optional delivery
152
+ * status, system notes and a composer slot. It is a live `log` that stays at the bottom while new
153
+ * items arrive and you are already there. Colors come from the kit tokens in both schemes. The
154
+ * `ai/` chat parts model user and assistant only; this one models the three authors of a shop chat.
155
+ */
156
+ export function ChatThread({
157
+ items,
158
+ composer,
159
+ labels: labelsProp,
160
+ label,
161
+ onRetry,
162
+ empty,
163
+ locale,
164
+ timeZone,
165
+ now,
166
+ className,
167
+ classNames,
168
+ }: ChatThreadProps) {
169
+ const labels: ChatThreadLabels = { ...chatThreadLabels.en, ...labelsProp };
170
+ const logRef = useRef<HTMLDivElement>(null);
171
+ const stickToEnd = useRef(true);
172
+ const reference = now ?? new Date();
173
+ const format = { locale, timeZone };
174
+ const authorName = { customer: labels.customer, bot: labels.bot, staff: labels.staff };
175
+
176
+ useIsomorphicLayoutEffect(() => {
177
+ const log = logRef.current;
178
+ if (log && stickToEnd.current) log.scrollTop = log.scrollHeight;
179
+ });
180
+
181
+ return (
182
+ <section
183
+ aria-label={label ?? labels.conversation}
184
+ className={cn("flex min-h-0 min-w-0 flex-col", classNames?.root, className)}
185
+ >
186
+ {items.length === 0 && empty != null ? (
187
+ <div className="flex flex-1 items-center justify-center p-card">{empty}</div>
188
+ ) : (
189
+ <div
190
+ ref={logRef}
191
+ role="log"
192
+ aria-live="polite"
193
+ aria-relevant="additions"
194
+ // biome-ignore lint/a11y/noNoninteractiveTabindex: a scrollable log must be reachable with the keyboard
195
+ tabIndex={0}
196
+ onScroll={(event) => {
197
+ const log = event.currentTarget;
198
+ stickToEnd.current = log.scrollHeight - log.scrollTop - log.clientHeight < 80;
199
+ }}
200
+ className={cn(
201
+ "min-h-0 flex-1 overflow-y-auto overscroll-contain p-density focus-visible:focus-ring",
202
+ classNames?.log,
203
+ )}
204
+ >
205
+ <ol className="m-0 flex list-none flex-col gap-2 p-0">
206
+ {withDayBreaks(items, timeZone).map(({ item, dayStart }) => (
207
+ <ChatThreadRow
208
+ key={item.id}
209
+ item={item}
210
+ dayLabel={
211
+ dayStart
212
+ ? formatDay(
213
+ item.at,
214
+ reference,
215
+ { today: labels.today, yesterday: labels.yesterday },
216
+ format,
217
+ )
218
+ : undefined
219
+ }
220
+ dayValue={dayStart ? dayKey(item.at, timeZone) : undefined}
221
+ time={formatTime(item.at, format)}
222
+ authorName={authorName}
223
+ labels={labels}
224
+ onRetry={onRetry}
225
+ classNames={classNames}
226
+ />
227
+ ))}
228
+ </ol>
229
+ </div>
230
+ )}
231
+ {composer != null ? (
232
+ <div
233
+ className={cn("shrink-0 border-t-divider p-density", classNames?.composer)}
234
+ data-slot="composer"
235
+ >
236
+ {composer}
237
+ </div>
238
+ ) : null}
239
+ </section>
240
+ );
241
+ }
242
+
243
+ interface RowProps {
244
+ item: ChatThreadItem;
245
+ dayLabel: string | undefined;
246
+ dayValue: string | undefined;
247
+ time: string;
248
+ authorName: Record<ChatAuthorKind, string>;
249
+ labels: ChatThreadLabels;
250
+ onRetry: ((id: string) => void) | undefined;
251
+ classNames: ClassNames<ChatThreadPart> | undefined;
252
+ }
253
+
254
+ function ChatThreadRow({
255
+ item,
256
+ dayLabel,
257
+ dayValue,
258
+ time,
259
+ authorName,
260
+ labels,
261
+ onRetry,
262
+ classNames,
263
+ }: RowProps) {
264
+ const strings = useUiStrings();
265
+ return (
266
+ <>
267
+ {dayLabel ? (
268
+ <li className={cn("flex justify-center py-1", classNames?.day)} data-slot="day">
269
+ <time
270
+ dateTime={dayValue}
271
+ className="rounded-badge bg-sunken px-2.5 py-0.5 text-ink-2 text-meta"
272
+ >
273
+ {dayLabel}
274
+ </time>
275
+ </li>
276
+ ) : null}
277
+ {item.kind === "note" ? (
278
+ <li className="flex justify-center" data-kind="note">
279
+ <p
280
+ className={cn(
281
+ "m-0 max-w-[85%] rounded-badge bg-sunken px-3 py-1 text-center text-ink-2 text-meta",
282
+ classNames?.note,
283
+ )}
284
+ >
285
+ {item.content}
286
+ </p>
287
+ </li>
288
+ ) : (
289
+ <li
290
+ data-author={item.author}
291
+ className={cn(
292
+ "flex",
293
+ item.author === "customer" ? "justify-start" : "justify-end",
294
+ classNames?.message,
295
+ )}
296
+ >
297
+ <div
298
+ className={cn(
299
+ "flex min-w-0 max-w-[min(34rem,85%)] flex-col gap-0.5",
300
+ item.author === "customer" ? "items-start" : "items-end",
301
+ )}
302
+ >
303
+ <span className={cn("text-ink-3 text-meta", classNames?.author)}>
304
+ {item.name ?? authorName[item.author]}
305
+ </span>
306
+ <div
307
+ className={cn(
308
+ "min-w-0 whitespace-pre-wrap rounded-card px-3 py-2 text-body [overflow-wrap:anywhere]",
309
+ bubbleTone[item.author],
310
+ classNames?.bubble,
311
+ )}
312
+ >
313
+ {item.content}
314
+ </div>
315
+ <div className={cn("flex items-center gap-2 text-ink-3 text-meta", classNames?.meta)}>
316
+ <time dateTime={new Date(item.at).toISOString()}>{time}</time>
317
+ {item.author !== "customer" && item.status ? (
318
+ <Status status={item.status} labels={labels} />
319
+ ) : null}
320
+ {item.status === "failed" && onRetry ? (
321
+ <Button variant="ghost" size="sm" onClick={() => onRetry(item.id)}>
322
+ {strings.retry}
323
+ </Button>
324
+ ) : null}
325
+ </div>
326
+ </div>
327
+ </li>
328
+ )}
329
+ </>
330
+ );
331
+ }
@@ -0,0 +1,67 @@
1
+ export type ChatTimestamp = Date | string | number;
2
+
3
+ export interface ChatThreadFormat {
4
+ locale?: string | undefined;
5
+ timeZone?: string | undefined;
6
+ }
7
+
8
+ const toDate = (at: ChatTimestamp) => (at instanceof Date ? at : new Date(at));
9
+
10
+ /** `YYYY-MM-DD` of the instant in `timeZone` (the local zone when omitted). */
11
+ export function dayKey(at: ChatTimestamp, timeZone?: string): string {
12
+ return new Intl.DateTimeFormat("en-CA", {
13
+ timeZone,
14
+ year: "numeric",
15
+ month: "2-digit",
16
+ day: "2-digit",
17
+ }).format(toDate(at));
18
+ }
19
+
20
+ function shiftDay(key: string, days: number): string {
21
+ const [year = 0, month = 1, day = 1] = key.split("-").map(Number);
22
+ const shifted = new Date(Date.UTC(year, month - 1, day + days));
23
+ return shifted.toISOString().slice(0, 10);
24
+ }
25
+
26
+ export function formatTime(at: ChatTimestamp, { locale, timeZone }: ChatThreadFormat = {}): string {
27
+ return new Intl.DateTimeFormat(locale, {
28
+ timeZone,
29
+ hour: "2-digit",
30
+ minute: "2-digit",
31
+ }).format(toDate(at));
32
+ }
33
+
34
+ /** "Today" and "Yesterday" relative to `now`, otherwise a long date (with the year when it differs). */
35
+ export function formatDay(
36
+ at: ChatTimestamp,
37
+ now: ChatTimestamp,
38
+ labels: { today: string; yesterday: string },
39
+ { locale, timeZone }: ChatThreadFormat = {},
40
+ ): string {
41
+ const key = dayKey(at, timeZone);
42
+ const today = dayKey(now, timeZone);
43
+ if (key === today) return labels.today;
44
+ if (key === shiftDay(today, -1)) return labels.yesterday;
45
+ const sameYear = key.slice(0, 4) === today.slice(0, 4);
46
+ return new Intl.DateTimeFormat(locale, {
47
+ timeZone,
48
+ weekday: "long",
49
+ day: "numeric",
50
+ month: "long",
51
+ ...(sameYear ? {} : { year: "numeric" }),
52
+ }).format(toDate(at));
53
+ }
54
+
55
+ /** Items in order, each flagged with whether a new day starts at it. */
56
+ export function withDayBreaks<T extends { at: ChatTimestamp }>(
57
+ items: readonly T[],
58
+ timeZone?: string,
59
+ ): Array<{ item: T; dayStart: boolean }> {
60
+ let previous: string | null = null;
61
+ return items.map((item) => {
62
+ const key = dayKey(item.at, timeZone);
63
+ const dayStart = key !== previous;
64
+ previous = key;
65
+ return { item, dayStart };
66
+ });
67
+ }
@@ -0,0 +1,12 @@
1
+ export {
2
+ type ChatAuthorKind,
3
+ type ChatDeliveryStatus,
4
+ ChatThread,
5
+ type ChatThreadItem,
6
+ type ChatThreadLabels,
7
+ type ChatThreadMessage,
8
+ type ChatThreadNote,
9
+ type ChatThreadPart,
10
+ type ChatThreadProps,
11
+ chatThreadLabels,
12
+ } from "./chat-thread.js";
@@ -1,12 +1,17 @@
1
1
  import type { ComponentPropsWithoutRef } from "react";
2
2
  import { cn } from "../../utils/cn.js";
3
3
 
4
- export type ColsVariant = "rail" | "half" | "calc";
4
+ export type ColsVariant = "rail" | "half" | "calc" | "thirds";
5
5
 
6
6
  /**
7
7
  * Responsive column layouts. Breakpoints react to the nearest ancestor
8
8
  * container named `page` (`@container/page`), not to the viewport; without
9
9
  * such an ancestor the wide layouts always apply.
10
+ *
11
+ * `base`, `rail`, `half` and `calc` cut at 940 / 1080 / 1500 px. `thirds` uses the page
12
+ * breakpoints of the layout containers, 720 / 1280 (`--container-page-m` and `-w` in
13
+ * `theme.css`): three equal columns from 1280 px, two from 720 px (an odd last item spans
14
+ * both) and one below.
10
15
  */
11
16
  const variantClasses: Record<"base" | ColsVariant, string> = {
12
17
  base: cn(
@@ -25,6 +30,13 @@ const variantClasses: Record<"base" | ColsVariant, string> = {
25
30
  "@min-[1500px]/page:grid-cols-[minmax(0,1fr)_minmax(0,2fr)]",
26
31
  "@max-[940px]/page:grid-cols-[minmax(0,1fr)]",
27
32
  ),
33
+ thirds: cn(
34
+ "grid-cols-[repeat(3,minmax(0,1fr))]",
35
+ "@max-[1279px]/page:grid-cols-[repeat(2,minmax(0,1fr))]",
36
+ "@max-[1279px]/page:[&>:last-child:nth-child(odd)]:col-span-2",
37
+ "@max-[719px]/page:grid-cols-[minmax(0,1fr)]",
38
+ "@max-[719px]/page:[&>:last-child:nth-child(odd)]:col-span-1",
39
+ ),
28
40
  };
29
41
 
30
42
  export interface ColsProps extends ComponentPropsWithoutRef<"div"> {
@@ -39,7 +39,7 @@ export function Comment({
39
39
  role="note"
40
40
  aria-label={label}
41
41
  className={cn(
42
- "mx-4 mb-3.5 break-words rounded-control px-3 py-2.5 text-fs-125",
42
+ "mx-4 mb-3.5 break-words rounded-control px-3 py-2.5 text-fs-120",
43
43
  toneClasses[tone],
44
44
  className,
45
45
  )}
@@ -0,0 +1,229 @@
1
+ "use client";
2
+
3
+ import { type CSSProperties, type ReactNode, useRef, useState } from "react";
4
+ import { useUiStrings } from "../../i18n/index.js";
5
+ import { X } from "../../icons/index.js";
6
+ import * as DialogPrimitive from "../../primitives/dialog/dialog.js";
7
+ import type { ClassNames } from "../../utils/class-names.js";
8
+ import { cn } from "../../utils/cn.js";
9
+ import { useContainerWidth } from "../../utils/use-container-width.js";
10
+
11
+ export type ContextRailPart = "root" | "grid" | "main" | "rail" | "summary" | "sheet";
12
+
13
+ /**
14
+ * Container widths (px) under which the rail collapses; the set is closed so every query is a
15
+ * literal class. `"never"` keeps the rail beside the work area at any width and `"always"`
16
+ * collapses it at any width.
17
+ */
18
+ export type ContextRailBreakpoint = 720 | 960 | 1280 | "never" | "always";
19
+
20
+ export interface ContextRailWidths {
21
+ /** Rail width (px) from the collapse breakpoint up. */
22
+ m?: number;
23
+ /** From 1280 px of container width. */
24
+ w?: number;
25
+ /** From 1600 px of container width. */
26
+ xw?: number;
27
+ }
28
+
29
+ export interface ContextRailProps {
30
+ /** The work area. */
31
+ children: ReactNode;
32
+ /** Content of the rail. */
33
+ rail: ReactNode;
34
+ /** Rail width in px, or one width per breakpoint. Defaults to 360 / 400 / 440. */
35
+ width?: number | ContextRailWidths;
36
+ /** Distance (px) the sticky rail keeps from the top of the scroll container. Defaults to 0. */
37
+ stickyTop?: number;
38
+ /** Container width under which the rail collapses (`"never"` / `"always"` pin it). Defaults to 720. */
39
+ breakpoint?: ContextRailBreakpoint;
40
+ /**
41
+ * Collapsed behaviour: `"stack"` puts the rail below the work area; `"sheet"` hides it behind a
42
+ * `summary` bar that opens it as a bottom sheet.
43
+ */
44
+ collapse?: "stack" | "sheet";
45
+ /** Compact bar shown while collapsed to a sheet (total plus the main action). It owns the button that opens the sheet. Inside an `AppShell` with a `bottomBar` it sits above that bar. */
46
+ summary?: ReactNode;
47
+ /** Label of the button that opens the sheet, and name of the sheet. */
48
+ sheetLabel?: string;
49
+ /** Accessible name of the rail region. */
50
+ railLabel?: string;
51
+ /** Controlled open state of the sheet. */
52
+ sheetOpen?: boolean;
53
+ onSheetOpenChange?: (open: boolean) => void;
54
+ className?: string;
55
+ /** Per-part classes merged with `cn`; consumer classes win. `className` still targets the root and is merged last. */
56
+ classNames?: ClassNames<ContextRailPart>;
57
+ }
58
+
59
+ const DEFAULT_WIDTHS: Required<ContextRailWidths> = { m: 360, w: 400, xw: 440 };
60
+
61
+ const collapseClasses: Record<
62
+ ContextRailBreakpoint,
63
+ { grid: string; rail: string; bar: string; hide: string }
64
+ > = {
65
+ 720: {
66
+ grid: "@max-[719px]/rail:grid-cols-[minmax(0,1fr)]",
67
+ rail: "@max-[719px]/rail:static @max-[719px]/rail:max-h-none",
68
+ bar: "hidden @max-[719px]/rail:block",
69
+ hide: "@max-[719px]/rail:hidden",
70
+ },
71
+ 960: {
72
+ grid: "@max-[959px]/rail:grid-cols-[minmax(0,1fr)]",
73
+ rail: "@max-[959px]/rail:static @max-[959px]/rail:max-h-none",
74
+ bar: "hidden @max-[959px]/rail:block",
75
+ hide: "@max-[959px]/rail:hidden",
76
+ },
77
+ 1280: {
78
+ grid: "@max-[1279px]/rail:grid-cols-[minmax(0,1fr)]",
79
+ rail: "@max-[1279px]/rail:static @max-[1279px]/rail:max-h-none",
80
+ bar: "hidden @max-[1279px]/rail:block",
81
+ hide: "@max-[1279px]/rail:hidden",
82
+ },
83
+ never: { grid: "", rail: "", bar: "hidden", hide: "" },
84
+ always: {
85
+ grid: "grid-cols-[minmax(0,1fr)]",
86
+ rail: "static max-h-none",
87
+ bar: "block",
88
+ hide: "hidden",
89
+ },
90
+ };
91
+
92
+ /** Whether the rail is collapsed for a measured container width (`null` before the first measurement). */
93
+ export function isRailCollapsed(breakpoint: ContextRailBreakpoint, width: number | null): boolean {
94
+ if (breakpoint === "always") return true;
95
+ if (breakpoint === "never") return false;
96
+ return width !== null && width < breakpoint;
97
+ }
98
+
99
+ export function resolveRailWidths(width: number | ContextRailWidths | undefined) {
100
+ if (typeof width === "number") return { m: width, w: width, xw: width };
101
+ return { ...DEFAULT_WIDTHS, ...width };
102
+ }
103
+
104
+ /**
105
+ * Work area with a persistent side rail (cart, payment, selected table). The rail sticks to the
106
+ * top of the scroll container with its own scroll, and its width grows with the container.
107
+ * Under `breakpoint` it stacks below the work area, or with `collapse="sheet"` it leaves the page
108
+ * for a bottom sheet opened from the `summary` bar. `breakpoint="never"` keeps it beside the work
109
+ * area at any width, `"always"` collapses it at any width. Widths and cuts follow the container
110
+ * (`@container/rail`), not the viewport.
111
+ */
112
+ export function ContextRail({
113
+ children,
114
+ rail,
115
+ width,
116
+ stickyTop = 0,
117
+ breakpoint = 720,
118
+ collapse = "stack",
119
+ summary,
120
+ sheetLabel,
121
+ railLabel,
122
+ sheetOpen: sheetOpenProp,
123
+ onSheetOpenChange,
124
+ className,
125
+ classNames,
126
+ }: ContextRailProps) {
127
+ const strings = useUiStrings();
128
+ const rootRef = useRef<HTMLDivElement>(null);
129
+ const measured = useContainerWidth(rootRef);
130
+ const collapsed = isRailCollapsed(breakpoint, measured);
131
+ const [openState, setOpenState] = useState(false);
132
+ const controlled = sheetOpenProp !== undefined;
133
+ const open = (controlled ? sheetOpenProp : openState) && collapsed;
134
+ const setOpen = (next: boolean) => {
135
+ if (!controlled) setOpenState(next);
136
+ onSheetOpenChange?.(next);
137
+ };
138
+
139
+ const widths = resolveRailWidths(width);
140
+ const classes = collapseClasses[breakpoint];
141
+ const sheet = collapse === "sheet";
142
+ const label = sheetLabel ?? railLabel;
143
+
144
+ const style = {
145
+ "--rail-m": `${widths.m}px`,
146
+ "--rail-w": `${widths.w}px`,
147
+ "--rail-xw": `${widths.xw}px`,
148
+ "--rail-top": `${stickyTop}px`,
149
+ } as CSSProperties;
150
+
151
+ return (
152
+ <div
153
+ ref={rootRef}
154
+ data-collapsed={collapsed ? "" : undefined}
155
+ style={style}
156
+ className={cn("@container/rail min-w-0", classNames?.root, className)}
157
+ >
158
+ <div
159
+ className={cn(
160
+ "grid items-start gap-4 [--rail:var(--rail-m)] @min-[1280px]/rail:[--rail:var(--rail-w)] @min-[1600px]/rail:[--rail:var(--rail-xw)]",
161
+ breakpoint === "always" ? undefined : "grid-cols-[minmax(0,1fr)_var(--rail)]",
162
+ classes.grid,
163
+ classNames?.grid,
164
+ )}
165
+ >
166
+ <div className={cn("min-w-0", classNames?.main)}>{children}</div>
167
+ <aside
168
+ aria-label={railLabel}
169
+ className={cn(
170
+ "sticky top-(--rail-top) min-w-0 max-h-[calc(100dvh-var(--rail-top))] overflow-y-auto overscroll-contain",
171
+ classes.rail,
172
+ sheet && classes.hide,
173
+ classNames?.rail,
174
+ )}
175
+ >
176
+ {sheet && collapsed ? null : rail}
177
+ </aside>
178
+ </div>
179
+ {sheet && summary != null ? (
180
+ <div
181
+ className={cn(
182
+ "sticky bottom-(--app-bottom-bar,0px) z-10 border-t-divider surface-card p-density",
183
+ classes.bar,
184
+ classNames?.summary,
185
+ )}
186
+ >
187
+ <div className="flex items-center justify-between gap-3">
188
+ <div className="min-w-0 flex-1">{summary}</div>
189
+ <button
190
+ type="button"
191
+ aria-haspopup="dialog"
192
+ aria-expanded={open}
193
+ onClick={() => setOpen(true)}
194
+ className="shrink-0 rounded-button px-3 py-2 font-semibold text-accent-ink text-body focus-visible:focus-ring"
195
+ >
196
+ {label ?? strings.actions}
197
+ </button>
198
+ </div>
199
+ </div>
200
+ ) : null}
201
+ {sheet ? (
202
+ <DialogPrimitive.Root open={open} onOpenChange={setOpen}>
203
+ <DialogPrimitive.Portal>
204
+ <DialogPrimitive.Overlay className="fixed inset-0 z-70 bg-scrim" />
205
+ <DialogPrimitive.Content
206
+ className={cn(
207
+ "fixed inset-x-0 bottom-0 z-70 flex max-h-[85dvh] flex-col overflow-y-auto rounded-t-card p-card outline-none surface-overlay shadow-overlay",
208
+ classNames?.sheet,
209
+ )}
210
+ >
211
+ <div className="mb-2 flex items-center justify-between gap-3">
212
+ <DialogPrimitive.Title className="m-0 font-semibold text-card-title text-ink">
213
+ {label ?? strings.actions}
214
+ </DialogPrimitive.Title>
215
+ <DialogPrimitive.Close
216
+ aria-label={strings.close}
217
+ className="rounded-event p-1 text-ink-3 hover:text-ink focus-visible:focus-ring"
218
+ >
219
+ <X aria-hidden="true" className="size-4" />
220
+ </DialogPrimitive.Close>
221
+ </div>
222
+ {rail}
223
+ </DialogPrimitive.Content>
224
+ </DialogPrimitive.Portal>
225
+ </DialogPrimitive.Root>
226
+ ) : null}
227
+ </div>
228
+ );
229
+ }
@@ -0,0 +1,7 @@
1
+ export {
2
+ ContextRail,
3
+ type ContextRailBreakpoint,
4
+ type ContextRailPart,
5
+ type ContextRailProps,
6
+ type ContextRailWidths,
7
+ } from "./context-rail.js";