@jcsoftdev/ui 0.8.0 → 0.10.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 (476) hide show
  1. package/CHANGELOG.md +151 -0
  2. package/README.md +22 -2
  3. package/dist/ai/attachment/attachment.d.ts +4 -3
  4. package/dist/ai/attachment/attachment.js +5 -1
  5. package/dist/ai/chat-message/chat-message.d.ts +4 -3
  6. package/dist/ai/chat-message/chat-message.js +5 -0
  7. package/dist/ai/code-block/code-block.js +2 -2
  8. package/dist/ai/conversation/conversation.d.ts +2 -2
  9. package/dist/ai/internal/disclosure.js +1 -1
  10. package/dist/ai/internal/icon-action.d.ts +4 -3
  11. package/dist/ai/internal/icon-action.js +11 -2
  12. package/dist/ai/message-actions/message-actions.d.ts +6 -3
  13. package/dist/ai/message-actions/message-actions.js +26 -1
  14. package/dist/ai/prompt-input/prompt-input.d.ts +3 -2
  15. package/dist/ai/prompt-input/prompt-input.js +14 -4
  16. package/dist/ai/prompt-suggestion/prompt-suggestion.d.ts +5 -4
  17. package/dist/ai/prompt-suggestion/prompt-suggestion.js +4 -0
  18. package/dist/ai/source/source.d.ts +4 -3
  19. package/dist/ai/source/source.js +16 -1
  20. package/dist/ai/tool-call/tool-call.d.ts +3 -2
  21. package/dist/ai/tool-call/tool-call.js +5 -1
  22. package/dist/atoms/big-date/big-date.d.ts +2 -2
  23. package/dist/atoms/button/button.d.ts +3 -2
  24. package/dist/atoms/button/button.js +9 -0
  25. package/dist/atoms/checkbox/checkbox.d.ts +5 -3
  26. package/dist/atoms/checkbox/checkbox.js +29 -19
  27. package/dist/atoms/chip/chip.d.ts +3 -2
  28. package/dist/atoms/chip/chip.js +10 -1
  29. package/dist/atoms/divider/divider.d.ts +2 -2
  30. package/dist/atoms/elapsed-time/elapsed-time.d.ts +2 -2
  31. package/dist/atoms/elapsed-time/elapsed-time.js +10 -7
  32. package/dist/atoms/elapsed-time/model.d.ts +8 -0
  33. package/dist/atoms/elapsed-time/model.js +44 -0
  34. package/dist/atoms/icon-button/icon-button.d.ts +2 -1
  35. package/dist/atoms/internal/labelled-control.d.ts +16 -0
  36. package/dist/atoms/internal/labelled-control.js +56 -0
  37. package/dist/atoms/number-value/number-value.d.ts +2 -2
  38. package/dist/atoms/pressable-feedback/pressable-feedback.d.ts +4 -3
  39. package/dist/atoms/pressable-feedback/pressable-feedback.js +13 -1
  40. package/dist/atoms/progress/progress.d.ts +2 -2
  41. package/dist/atoms/radio-group/radio-group-primitive.d.ts +3 -2
  42. package/dist/atoms/radio-group/radio-group-primitive.js +10 -1
  43. package/dist/atoms/radio-group/radio-group.d.ts +2 -0
  44. package/dist/atoms/radio-group/radio-group.js +3 -1
  45. package/dist/atoms/seal/seal.d.ts +2 -2
  46. package/dist/atoms/status-pill/status-pill.js +1 -1
  47. package/dist/atoms/switch/switch.d.ts +7 -4
  48. package/dist/atoms/switch/switch.js +35 -5
  49. package/dist/atoms/table-glyph/table-glyph.d.ts +2 -2
  50. package/dist/atoms/trend-chip/trend-chip.d.ts +2 -2
  51. package/dist/auth/login-form/parts.js +2 -2
  52. package/dist/calendar/date-calendar/date-calendar.js +1 -1
  53. package/dist/calendar/day-chip/day-chip.d.ts +3 -2
  54. package/dist/calendar/day-chip/day-chip.js +12 -1
  55. package/dist/calendar/event-block/event-block.d.ts +3 -2
  56. package/dist/calendar/event-block/event-block.js +7 -0
  57. package/dist/calendar/internal/grid-navigation.d.ts +11 -0
  58. package/dist/calendar/internal/grid-navigation.js +34 -0
  59. package/dist/calendar/internal/intent.d.ts +3 -0
  60. package/dist/calendar/internal/intent.js +7 -0
  61. package/dist/calendar/internal/month-model.d.ts +11 -0
  62. package/dist/calendar/internal/month-model.js +11 -0
  63. package/dist/calendar/internal/types.d.ts +4 -0
  64. package/dist/calendar/month-view/month-grid.d.ts +27 -0
  65. package/dist/calendar/month-view/month-grid.js +210 -0
  66. package/dist/calendar/month-view/month-view.d.ts +3 -1
  67. package/dist/calendar/month-view/month-view.js +29 -131
  68. package/dist/calendar/week-view/week-view.d.ts +3 -1
  69. package/dist/calendar/week-view/week-view.js +218 -128
  70. package/dist/charts/bar-chart/bar-race-chart.js +1 -1
  71. package/dist/charts/core/breadcrumb.js +1 -1
  72. package/dist/charts/core/chart-states.js +1 -1
  73. package/dist/charts/core/distribution/xy-points.js +4 -2
  74. package/dist/charts/crossfilter/crossfilter.js +1 -1
  75. package/dist/charts/gantt-chart/gantt-chart.js +1 -1
  76. package/dist/charts/maps/geo/map-data-table.js +1 -1
  77. package/dist/charts/sankey-chart/sankey-chart.js +1 -3
  78. package/dist/charts/tree-chart/tree-chart.js +1 -1
  79. package/dist/containers/action-bar/action-bar.d.ts +2 -2
  80. package/dist/containers/action-bar/action-bar.js +1 -1
  81. package/dist/containers/aside/aside.d.ts +3 -3
  82. package/dist/containers/banner/banner.d.ts +2 -2
  83. package/dist/containers/card/card.d.ts +5 -5
  84. package/dist/containers/card/card.js +3 -1
  85. package/dist/containers/carousel/carousel.d.ts +2 -2
  86. package/dist/containers/carousel/carousel.js +2 -2
  87. package/dist/containers/cols/cols.d.ts +3 -3
  88. package/dist/containers/comment/comment.d.ts +2 -2
  89. package/dist/containers/confirm-action/confirm-action.d.ts +3 -2
  90. package/dist/containers/confirm-action/confirm-action.js +10 -2
  91. package/dist/containers/dashboard/dashboard.d.ts +4 -4
  92. package/dist/containers/data-grid/column-menu.js +1 -1
  93. package/dist/containers/data-grid/data-grid.d.ts +7 -3
  94. package/dist/containers/data-grid/data-grid.js +45 -7
  95. package/dist/containers/data-grid/formula-bar.js +1 -1
  96. package/dist/containers/data-grid/grid-toolbar.js +1 -1
  97. package/dist/containers/data-grid/tool-panel.js +1 -1
  98. package/dist/containers/description-list/description-list.d.ts +2 -2
  99. package/dist/containers/detail-header/detail-header.d.ts +2 -2
  100. package/dist/containers/facts/facts.d.ts +2 -2
  101. package/dist/containers/feed/feed.d.ts +5 -4
  102. package/dist/containers/feed/feed.js +12 -0
  103. package/dist/containers/file-tree/file-tree.js +11 -0
  104. package/dist/containers/file-tree/model.d.ts +2 -0
  105. package/dist/containers/filter-bar/filter-bar.d.ts +2 -2
  106. package/dist/containers/floor-plan/floor-plan.d.ts +2 -0
  107. package/dist/containers/floor-plan/floor-plan.js +17 -9
  108. package/dist/containers/floor-plan/index.d.ts +1 -1
  109. package/dist/containers/floor-plan/index.js +6 -1
  110. package/dist/containers/floor-plan/model.d.ts +3 -0
  111. package/dist/containers/floor-plan/model.js +8 -0
  112. package/dist/containers/generic-row/generic-row.d.ts +8 -6
  113. package/dist/containers/generic-row/generic-row.js +3 -1
  114. package/dist/containers/grid/grid.d.ts +2 -2
  115. package/dist/containers/hbars/hbars.js +2 -2
  116. package/dist/containers/highlight-line/highlight-line.d.ts +2 -2
  117. package/dist/containers/index.d.ts +1 -0
  118. package/dist/containers/index.js +1 -0
  119. package/dist/containers/item-card-group/item-card-group.d.ts +4 -2
  120. package/dist/containers/item-card-group/item-card-group.js +4 -0
  121. package/dist/containers/kanban/kanban.js +13 -0
  122. package/dist/containers/kanban/model.d.ts +2 -0
  123. package/dist/containers/kpi/kpi-model.d.ts +7 -0
  124. package/dist/containers/kpi/kpi-model.js +22 -0
  125. package/dist/containers/kpi/kpi-parts.d.ts +28 -0
  126. package/dist/containers/kpi/kpi-parts.js +121 -0
  127. package/dist/containers/kpi/kpi.d.ts +7 -30
  128. package/dist/containers/kpi/kpi.js +4 -119
  129. package/dist/containers/kpi-group/kpi-group.d.ts +2 -2
  130. package/dist/containers/list-detail/list-detail.d.ts +12 -11
  131. package/dist/containers/list-detail/list-detail.js +9 -1
  132. package/dist/containers/note/note.d.ts +2 -2
  133. package/dist/containers/order-ticket/index.d.ts +2 -0
  134. package/dist/containers/order-ticket/index.js +18 -0
  135. package/dist/containers/order-ticket/model.d.ts +24 -0
  136. package/dist/containers/order-ticket/model.js +45 -0
  137. package/dist/containers/order-ticket/order-ticket.d.ts +35 -0
  138. package/dist/containers/order-ticket/order-ticket.js +406 -0
  139. package/dist/containers/page/page.d.ts +2 -2
  140. package/dist/containers/page-header/back.d.ts +2 -2
  141. package/dist/containers/page-header/page-header.d.ts +6 -6
  142. package/dist/containers/pagination/cursor-pagination.d.ts +2 -2
  143. package/dist/containers/pagination/pagination.d.ts +2 -2
  144. package/dist/containers/pagination/pagination.js +2 -2
  145. package/dist/containers/resizable/resizable.d.ts +4 -4
  146. package/dist/containers/resizable/resizable.js +1 -1
  147. package/dist/containers/row-actions/row-actions.d.ts +4 -3
  148. package/dist/containers/row-actions/row-actions.js +14 -1
  149. package/dist/containers/scrolly/scrolly.js +1 -1
  150. package/dist/containers/section/section.d.ts +10 -9
  151. package/dist/containers/section/section.js +12 -0
  152. package/dist/containers/selectable-card/selectable-card.d.ts +3 -2
  153. package/dist/containers/selectable-card/selectable-card.js +10 -1
  154. package/dist/containers/settings-layout/settings-layout.d.ts +7 -6
  155. package/dist/containers/settings-layout/settings-layout.js +10 -1
  156. package/dist/containers/settings-row/settings-row.d.ts +4 -3
  157. package/dist/containers/settings-row/settings-row.js +4 -0
  158. package/dist/containers/shortcuts/shortcuts.d.ts +3 -3
  159. package/dist/containers/stack/stack.d.ts +2 -2
  160. package/dist/containers/table/table.d.ts +14 -13
  161. package/dist/containers/table/table.js +22 -4
  162. package/dist/containers/timeline/timeline.d.ts +5 -4
  163. package/dist/containers/timeline/timeline.js +12 -0
  164. package/dist/containers/toolbar/toolbar.d.ts +3 -3
  165. package/dist/forms/accent-picker/accent-picker.d.ts +5 -2
  166. package/dist/forms/accent-picker/accent-picker.js +22 -1
  167. package/dist/forms/checkbox-button-group/checkbox-button-group.d.ts +3 -2
  168. package/dist/forms/checkbox-button-group/checkbox-button-group.js +16 -0
  169. package/dist/forms/chip-group/chip-group.d.ts +4 -1
  170. package/dist/forms/chip-group/chip-group.js +20 -2
  171. package/dist/forms/combobox/combobox.d.ts +3 -2
  172. package/dist/forms/combobox/combobox.js +10 -1
  173. package/dist/forms/copy-field/copy-field.d.ts +4 -3
  174. package/dist/forms/copy-field/copy-field.js +7 -0
  175. package/dist/forms/date-picker/date-picker.d.ts +3 -2
  176. package/dist/forms/date-picker/date-picker.js +10 -1
  177. package/dist/forms/date-picker/date-time-picker.d.ts +3 -2
  178. package/dist/forms/date-picker/date-time-picker.js +4 -0
  179. package/dist/forms/dropzone/dropzone.d.ts +3 -2
  180. package/dist/forms/dropzone/dropzone.js +21 -3
  181. package/dist/forms/emoji-picker/emoji-picker.d.ts +3 -2
  182. package/dist/forms/emoji-picker/emoji-picker.js +9 -2
  183. package/dist/forms/emoji-reaction-button/emoji-reaction-button.d.ts +3 -2
  184. package/dist/forms/emoji-reaction-button/emoji-reaction-button.js +8 -1
  185. package/dist/forms/field/field.d.ts +2 -2
  186. package/dist/forms/fieldset/fieldset.d.ts +2 -2
  187. package/dist/forms/form/form.d.ts +6 -4
  188. package/dist/forms/form/form.js +10 -2
  189. package/dist/forms/form-footer/form-footer.d.ts +2 -2
  190. package/dist/forms/form-grid/form-grid.d.ts +3 -3
  191. package/dist/forms/form-section/form-section.d.ts +2 -2
  192. package/dist/forms/inline-select/inline-select.d.ts +4 -3
  193. package/dist/forms/inline-select/inline-select.js +9 -1
  194. package/dist/forms/input/input.d.ts +3 -2
  195. package/dist/forms/input/input.js +6 -1
  196. package/dist/forms/internal/button-option.d.ts +2 -0
  197. package/dist/forms/label/label.d.ts +2 -2
  198. package/dist/forms/native-select/native-select.d.ts +4 -3
  199. package/dist/forms/native-select/native-select.js +4 -0
  200. package/dist/forms/number-stepper/number-stepper.d.ts +2 -1
  201. package/dist/forms/number-stepper/number-stepper.js +13 -3
  202. package/dist/forms/password-input/password-input.d.ts +1 -1
  203. package/dist/forms/password-input/password-input.js +12 -0
  204. package/dist/forms/pin-input/pin-input.d.ts +3 -2
  205. package/dist/forms/pin-input/pin-input.js +8 -1
  206. package/dist/forms/radio-button-group/radio-button-group.d.ts +3 -2
  207. package/dist/forms/radio-button-group/radio-button-group.js +16 -0
  208. package/dist/forms/rating/rating.d.ts +3 -2
  209. package/dist/forms/rating/rating.js +12 -0
  210. package/dist/forms/select/select.d.ts +4 -3
  211. package/dist/forms/select/select.js +11 -2
  212. package/dist/forms/select-menu/select-menu.d.ts +3 -2
  213. package/dist/forms/select-menu/select-menu.js +10 -1
  214. package/dist/forms/slider/model.d.ts +1 -0
  215. package/dist/forms/slider/model.js +5 -0
  216. package/dist/forms/slider/slider.d.ts +2 -1
  217. package/dist/forms/slider/slider.js +12 -3
  218. package/dist/forms/textarea/textarea.d.ts +4 -3
  219. package/dist/forms/textarea/textarea.js +4 -2
  220. package/dist/forms/time-input/time-input.d.ts +4 -3
  221. package/dist/forms/time-input/time-input.js +13 -1
  222. package/dist/glass/crystal-map.d.ts +3 -1
  223. package/dist/glass/crystal-map.js +13 -2
  224. package/dist/i18n/strings.d.ts +78 -0
  225. package/dist/i18n/strings.js +52 -0
  226. package/dist/icons/alarm-clock.d.ts +2 -0
  227. package/dist/icons/alarm-clock.js +15 -0
  228. package/dist/icons/hourglass.d.ts +2 -0
  229. package/dist/icons/hourglass.js +13 -0
  230. package/dist/icons/index.d.ts +2 -0
  231. package/dist/icons/index.js +4 -0
  232. package/dist/intent/attributes.d.ts +11 -0
  233. package/dist/intent/attributes.js +77 -0
  234. package/dist/intent/bridge.d.ts +8 -0
  235. package/dist/intent/bridge.js +19 -0
  236. package/dist/intent/index.d.ts +4 -0
  237. package/dist/intent/index.js +31 -0
  238. package/dist/intent/target-registrations.d.ts +16 -0
  239. package/dist/intent/target-registrations.js +91 -0
  240. package/dist/intent/types.d.ts +29 -0
  241. package/dist/intent/types.js +0 -0
  242. package/dist/intent/use-intent-target.d.ts +4 -0
  243. package/dist/intent/use-intent-target.js +75 -0
  244. package/dist/navigation/breadcrumbs/breadcrumbs.d.ts +6 -4
  245. package/dist/navigation/breadcrumbs/breadcrumbs.js +11 -1
  246. package/dist/navigation/floating-toc/floating-toc.d.ts +2 -2
  247. package/dist/navigation/floating-toc/floating-toc.js +5 -0
  248. package/dist/navigation/floating-toc/model.d.ts +2 -1
  249. package/dist/navigation/segmented/segmented.d.ts +3 -2
  250. package/dist/navigation/segmented/segmented.js +11 -1
  251. package/dist/navigation/stepper/stepper.d.ts +4 -2
  252. package/dist/navigation/stepper/stepper.js +3 -0
  253. package/dist/navigation/tabs/tabs-nav.d.ts +5 -4
  254. package/dist/navigation/tabs/tabs-nav.js +11 -0
  255. package/dist/navigation/tabs/tabs.d.ts +5 -4
  256. package/dist/navigation/tabs/tabs.js +20 -1
  257. package/dist/navigation/wizard/wizard.d.ts +4 -3
  258. package/dist/navigation/wizard/wizard.js +9 -1
  259. package/dist/overlays/alert-dialog/alert-dialog.d.ts +5 -4
  260. package/dist/overlays/alert-dialog/alert-dialog.js +20 -3
  261. package/dist/overlays/context-menu/context-menu.d.ts +14 -12
  262. package/dist/overlays/context-menu/context-menu.js +57 -8
  263. package/dist/overlays/dialog/dialog.d.ts +9 -8
  264. package/dist/overlays/dialog/dialog.js +11 -0
  265. package/dist/overlays/drawer/drawer.d.ts +6 -5
  266. package/dist/overlays/drawer/drawer.js +11 -0
  267. package/dist/overlays/dropdown-menu/dropdown-menu.d.ts +14 -13
  268. package/dist/overlays/dropdown-menu/dropdown-menu.js +58 -5
  269. package/dist/overlays/hover-card/hover-card.d.ts +4 -3
  270. package/dist/overlays/hover-card/hover-card.js +12 -1
  271. package/dist/overlays/popover/popover.d.ts +3 -2
  272. package/dist/overlays/popover/popover.js +12 -1
  273. package/dist/overlays/tooltip/model.d.ts +1 -0
  274. package/dist/overlays/tooltip/model.js +8 -0
  275. package/dist/overlays/tooltip/tooltip.d.ts +2 -1
  276. package/dist/overlays/tooltip/tooltip.js +8 -2
  277. package/dist/palette/command-palette/command-palette.d.ts +8 -4
  278. package/dist/palette/command-palette/command-palette.js +49 -1
  279. package/dist/palette/command-palette/index.d.ts +1 -0
  280. package/dist/palette/command-palette/index.js +3 -1
  281. package/dist/palette/command-palette/model.d.ts +7 -0
  282. package/dist/palette/command-palette/model.js +11 -0
  283. package/dist/primitives/command/command.js +4 -1
  284. package/dist/primitives/dialog/dialog.js +1 -3
  285. package/dist/primitives/popper/popper.js +15 -4
  286. package/dist/shell/bottom-nav/bottom-nav.js +54 -42
  287. package/dist/shell/sidebar/sidebar.d.ts +5 -3
  288. package/dist/shell/sidebar/sidebar.js +14 -2
  289. package/dist/showcase/bento.js +1 -0
  290. package/dist/utils/is-production.d.ts +1 -0
  291. package/dist/utils/is-production.js +6 -0
  292. package/dist/utils/slot.js +17 -3
  293. package/icons/svg/alarm-clock.svg +8 -0
  294. package/icons/svg/hourglass.svg +6 -0
  295. package/package.json +2 -2
  296. package/src/ai/attachment/attachment.tsx +10 -3
  297. package/src/ai/chat-message/chat-message.tsx +10 -2
  298. package/src/ai/code-block/code-block.tsx +2 -2
  299. package/src/ai/conversation/conversation.tsx +2 -2
  300. package/src/ai/internal/disclosure.tsx +1 -1
  301. package/src/ai/internal/icon-action.tsx +14 -4
  302. package/src/ai/message-actions/message-actions.tsx +28 -3
  303. package/src/ai/prompt-input/prompt-input.tsx +15 -4
  304. package/src/ai/prompt-suggestion/prompt-suggestion.tsx +9 -3
  305. package/src/ai/source/source.tsx +17 -3
  306. package/src/ai/tool-call/tool-call.tsx +6 -1
  307. package/src/atoms/big-date/big-date.tsx +2 -2
  308. package/src/atoms/button/button.tsx +11 -1
  309. package/src/atoms/checkbox/checkbox.tsx +40 -21
  310. package/src/atoms/chip/chip.tsx +12 -2
  311. package/src/atoms/divider/divider.tsx +2 -2
  312. package/src/atoms/elapsed-time/elapsed-time.tsx +14 -10
  313. package/src/atoms/elapsed-time/model.ts +57 -0
  314. package/src/atoms/icon-button/icon-button.tsx +3 -1
  315. package/src/atoms/internal/labelled-control.tsx +83 -0
  316. package/src/atoms/number-value/number-value.tsx +2 -2
  317. package/src/atoms/pressable-feedback/pressable-feedback.tsx +16 -3
  318. package/src/atoms/progress/progress.tsx +2 -2
  319. package/src/atoms/radio-group/radio-group-primitive.tsx +13 -2
  320. package/src/atoms/radio-group/radio-group.tsx +5 -1
  321. package/src/atoms/seal/seal.tsx +2 -2
  322. package/src/atoms/status-pill/status-pill.tsx +1 -1
  323. package/src/atoms/switch/switch.tsx +43 -9
  324. package/src/atoms/table-glyph/table-glyph.tsx +2 -2
  325. package/src/atoms/trend-chip/trend-chip.tsx +2 -2
  326. package/src/auth/login-form/parts.tsx +2 -2
  327. package/src/calendar/date-calendar/date-calendar.tsx +1 -1
  328. package/src/calendar/day-chip/day-chip.tsx +14 -2
  329. package/src/calendar/event-block/event-block.tsx +9 -1
  330. package/src/calendar/internal/grid-navigation.ts +47 -0
  331. package/src/calendar/internal/intent.ts +10 -0
  332. package/src/calendar/internal/month-model.ts +23 -0
  333. package/src/calendar/internal/types.ts +4 -0
  334. package/src/calendar/month-view/month-grid.tsx +248 -0
  335. package/src/calendar/month-view/month-view.tsx +32 -148
  336. package/src/calendar/week-view/week-view.tsx +87 -10
  337. package/src/charts/README.md +10 -0
  338. package/src/charts/bar-chart/bar-race-chart.tsx +1 -1
  339. package/src/charts/core/breadcrumb.tsx +1 -1
  340. package/src/charts/core/chart-states.tsx +1 -1
  341. package/src/charts/core/distribution/xy-points.tsx +4 -2
  342. package/src/charts/crossfilter/crossfilter.tsx +1 -1
  343. package/src/charts/gantt-chart/gantt-chart.tsx +1 -1
  344. package/src/charts/maps/geo/map-data-table.tsx +1 -1
  345. package/src/charts/sankey-chart/sankey-chart.tsx +1 -4
  346. package/src/charts/tree-chart/tree-chart.tsx +1 -1
  347. package/src/containers/action-bar/action-bar.tsx +3 -3
  348. package/src/containers/aside/aside.tsx +3 -3
  349. package/src/containers/banner/banner.tsx +2 -2
  350. package/src/containers/card/card.tsx +7 -5
  351. package/src/containers/carousel/carousel.tsx +4 -4
  352. package/src/containers/cols/cols.tsx +3 -3
  353. package/src/containers/comment/comment.tsx +2 -2
  354. package/src/containers/confirm-action/confirm-action.tsx +11 -2
  355. package/src/containers/dashboard/dashboard.tsx +4 -4
  356. package/src/containers/data-grid/column-menu.tsx +1 -1
  357. package/src/containers/data-grid/data-grid.tsx +53 -4
  358. package/src/containers/data-grid/formula-bar.tsx +1 -1
  359. package/src/containers/data-grid/grid-toolbar.tsx +1 -1
  360. package/src/containers/data-grid/tool-panel.tsx +1 -1
  361. package/src/containers/description-list/description-list.tsx +2 -2
  362. package/src/containers/detail-header/detail-header.tsx +2 -2
  363. package/src/containers/facts/facts.tsx +2 -2
  364. package/src/containers/feed/feed.tsx +16 -3
  365. package/src/containers/file-tree/file-tree.tsx +11 -0
  366. package/src/containers/file-tree/model.ts +2 -0
  367. package/src/containers/filter-bar/filter-bar.tsx +2 -2
  368. package/src/containers/floor-plan/floor-plan.tsx +18 -10
  369. package/src/containers/floor-plan/index.ts +7 -1
  370. package/src/containers/floor-plan/model.ts +16 -0
  371. package/src/containers/generic-row/generic-row.tsx +9 -6
  372. package/src/containers/grid/grid.tsx +2 -2
  373. package/src/containers/hbars/hbars.tsx +23 -21
  374. package/src/containers/highlight-line/highlight-line.tsx +2 -2
  375. package/src/containers/index.ts +1 -0
  376. package/src/containers/item-card-group/item-card-group.tsx +10 -2
  377. package/src/containers/kanban/kanban.tsx +13 -0
  378. package/src/containers/kanban/model.ts +2 -0
  379. package/src/containers/kpi/kpi-model.ts +37 -0
  380. package/src/containers/kpi/kpi-parts.tsx +153 -0
  381. package/src/containers/kpi/kpi.tsx +10 -176
  382. package/src/containers/kpi-group/kpi-group.tsx +2 -2
  383. package/src/containers/list-detail/list-detail.tsx +22 -12
  384. package/src/containers/note/note.tsx +2 -2
  385. package/src/containers/order-ticket/index.ts +17 -0
  386. package/src/containers/order-ticket/model.ts +76 -0
  387. package/src/containers/order-ticket/order-ticket.tsx +480 -0
  388. package/src/containers/page/page.tsx +2 -2
  389. package/src/containers/page-header/back.tsx +2 -2
  390. package/src/containers/page-header/page-header.tsx +6 -6
  391. package/src/containers/pagination/cursor-pagination.tsx +2 -2
  392. package/src/containers/pagination/pagination.tsx +4 -4
  393. package/src/containers/resizable/resizable.tsx +7 -5
  394. package/src/containers/row-actions/row-actions.tsx +18 -3
  395. package/src/containers/scrolly/scrolly.tsx +1 -1
  396. package/src/containers/section/section.tsx +21 -8
  397. package/src/containers/selectable-card/selectable-card.tsx +13 -2
  398. package/src/containers/settings-layout/settings-layout.tsx +15 -5
  399. package/src/containers/settings-row/settings-row.tsx +7 -2
  400. package/src/containers/shortcuts/shortcuts.tsx +4 -4
  401. package/src/containers/stack/stack.tsx +2 -2
  402. package/src/containers/table/table.tsx +35 -14
  403. package/src/containers/timeline/timeline.tsx +17 -3
  404. package/src/containers/toolbar/toolbar.tsx +3 -3
  405. package/src/forms/accent-picker/accent-picker.tsx +27 -2
  406. package/src/forms/checkbox-button-group/checkbox-button-group.tsx +18 -1
  407. package/src/forms/chip-group/chip-group.tsx +23 -2
  408. package/src/forms/combobox/combobox.tsx +15 -4
  409. package/src/forms/copy-field/copy-field.tsx +11 -2
  410. package/src/forms/date-picker/date-picker.tsx +23 -12
  411. package/src/forms/date-picker/date-time-picker.tsx +9 -3
  412. package/src/forms/dropzone/dropzone.tsx +18 -3
  413. package/src/forms/emoji-picker/emoji-picker.tsx +10 -2
  414. package/src/forms/emoji-reaction-button/emoji-reaction-button.tsx +9 -1
  415. package/src/forms/field/field.tsx +2 -2
  416. package/src/forms/fieldset/fieldset.tsx +2 -2
  417. package/src/forms/form/form.tsx +13 -5
  418. package/src/forms/form-footer/form-footer.tsx +2 -2
  419. package/src/forms/form-grid/form-grid.tsx +3 -3
  420. package/src/forms/form-section/form-section.tsx +2 -2
  421. package/src/forms/inline-select/inline-select.tsx +14 -3
  422. package/src/forms/input/input.tsx +8 -2
  423. package/src/forms/internal/button-option.tsx +2 -0
  424. package/src/forms/label/label.tsx +2 -2
  425. package/src/forms/native-select/native-select.tsx +9 -2
  426. package/src/forms/number-stepper/number-stepper.tsx +14 -3
  427. package/src/forms/password-input/password-input.tsx +12 -0
  428. package/src/forms/pin-input/pin-input.tsx +9 -1
  429. package/src/forms/radio-button-group/radio-button-group.tsx +18 -1
  430. package/src/forms/rating/rating.tsx +14 -1
  431. package/src/forms/select/select.tsx +14 -4
  432. package/src/forms/select-menu/select-menu.tsx +15 -4
  433. package/src/forms/slider/model.ts +5 -0
  434. package/src/forms/slider/slider.tsx +13 -3
  435. package/src/forms/textarea/textarea.tsx +7 -4
  436. package/src/forms/time-input/time-input.tsx +19 -5
  437. package/src/glass/crystal-map.ts +21 -3
  438. package/src/i18n/strings.ts +78 -0
  439. package/src/icons/alarm-clock.tsx +16 -0
  440. package/src/icons/hourglass.tsx +14 -0
  441. package/src/icons/index.ts +2 -0
  442. package/src/intent/attributes.ts +96 -0
  443. package/src/intent/bridge.tsx +25 -0
  444. package/src/intent/index.ts +24 -0
  445. package/src/intent/target-registrations.ts +127 -0
  446. package/src/intent/types.ts +44 -0
  447. package/src/intent/use-intent-target.ts +96 -0
  448. package/src/navigation/breadcrumbs/breadcrumbs.tsx +18 -5
  449. package/src/navigation/floating-toc/floating-toc.tsx +7 -2
  450. package/src/navigation/floating-toc/model.ts +3 -1
  451. package/src/navigation/segmented/segmented.tsx +14 -2
  452. package/src/navigation/stepper/stepper.tsx +7 -2
  453. package/src/navigation/tabs/tabs-nav.tsx +16 -3
  454. package/src/navigation/tabs/tabs.tsx +24 -3
  455. package/src/navigation/wizard/wizard.tsx +12 -4
  456. package/src/overlays/alert-dialog/alert-dialog.tsx +21 -4
  457. package/src/overlays/context-menu/context-menu.tsx +58 -11
  458. package/src/overlays/dialog/dialog.tsx +18 -7
  459. package/src/overlays/drawer/drawer.tsx +15 -4
  460. package/src/overlays/dropdown-menu/dropdown-menu.tsx +67 -10
  461. package/src/overlays/hover-card/hover-card.tsx +13 -2
  462. package/src/overlays/popover/popover.tsx +12 -1
  463. package/src/overlays/tooltip/model.ts +8 -0
  464. package/src/overlays/tooltip/tooltip.tsx +15 -2
  465. package/src/palette/command-palette/command-palette.tsx +66 -3
  466. package/src/palette/command-palette/index.ts +1 -0
  467. package/src/palette/command-palette/model.ts +15 -0
  468. package/src/primitives/command/command.tsx +4 -1
  469. package/src/primitives/dialog/dialog.tsx +1 -4
  470. package/src/primitives/popper/popper.tsx +16 -5
  471. package/src/shell/bottom-nav/bottom-nav.tsx +67 -55
  472. package/src/shell/sidebar/sidebar.tsx +22 -4
  473. package/src/showcase/bento.tsx +2 -0
  474. package/src/utils/is-production.ts +3 -0
  475. package/src/utils/slot.tsx +21 -3
  476. package/styles/base.css +34 -0
@@ -61,7 +61,9 @@ export interface CrystalMapOptions {
61
61
  * Margin past each side of the surface, in px (default: `margin` on all four). A surface inside
62
62
  * a clipping ancestor (an `overflow` or `clip-path` stage) only has the backdrop within it: a
63
63
  * layer that reaches past the clip is cut by the browser and its filter is shifted, so the map
64
- * covers only the backdrop that exists, and the offsets are clamped so no sample lands beyond it.
64
+ * covers only the backdrop that exists. A side with less room than the margin scales its offsets
65
+ * down so its silhouette still samples inside the room, eased across the surface; the hard clamp
66
+ * that remains only bites in the margin, which the layer clips away.
65
67
  */
66
68
  room?: Partial<Record<"left" | "right" | "top" | "bottom", number>>;
67
69
  /** Largest factor the offset is multiplied by (chromatic dispersion pulls red this much further). Default 1. */
@@ -112,17 +114,33 @@ export function computeCrystalField({
112
114
  const [minY, maxY] = [-hy - top + slack, hy + bottom - slack];
113
115
  const unit = Math.max(amplitude, 1e-6);
114
116
  const f = Math.max(reach, 1);
117
+ // Share of the offset a side keeps so its silhouette, where the offset peaks at `amplitude
118
+ // extent / half`, still samples inside the room. A side with the whole margin keeps all of it.
119
+ const keep = (free: number, extent: number) =>
120
+ free >= m ? 1 : clamp((free - EDGE_SLACK) / Math.max((f * unit * extent) / half, 1e-6), 0, 1);
121
+ const shares = {
122
+ x: [keep(left, hx), keep(right, hx)],
123
+ y: [keep(top, hy), keep(bottom, hy)],
124
+ } as const;
125
+ // Eased from one side's share to the other across the surface, so the lens bends less towards
126
+ // a short side without a crease down the middle (a hard per-side switch would put one there).
127
+ const share = ([low, high]: readonly [number, number], p: number, extent: number) => {
128
+ const u = clamp((p + extent) / (2 * extent), 0, 1);
129
+ return low + (high - low) * u * u * (3 - 2 * u);
130
+ };
115
131
  // Offset (as a fraction of `amplitude`, what the channel encodes) that keeps the source in the room.
116
132
  const within = (p: number, offset: number, lo: number, hi: number) =>
117
133
  clamp((bounded ? clamp(offset, (lo - p) / f, (hi - p) / f) : offset) / unit, -1, 1);
118
134
  for (let j = 0; j < ph; j++) {
119
135
  const py = (j + 0.5) / ry - top - hy;
136
+ const ky = share(shares.y, py, hy);
120
137
  for (let i = 0; i < pw; i++) {
121
138
  const px = (i + 0.5) / rx - left - hx;
139
+ const kx = share(shares.x, px, hx);
122
140
  const s = crystalShape(crystalRadius(px, py, hx, hy));
123
141
  const o = (j * pw + i) * 4;
124
- data[o] = 128 + within(px, (s * px * amplitude) / half, minX, maxX) * 127;
125
- data[o + 1] = 128 + within(py, (s * py * amplitude) / half, minY, maxY) * 127;
142
+ data[o] = 128 + within(px, ((s * px * amplitude) / half) * kx, minX, maxX) * 127;
143
+ data[o + 1] = 128 + within(py, ((s * py * amplitude) / half) * ky, minY, maxY) * 127;
126
144
  data[o + 2] = 255;
127
145
  data[o + 3] = 255;
128
146
  }
@@ -28,6 +28,10 @@ export interface UiStrings {
28
28
  elapsedMinutes: string;
29
29
  /** Visible text of an `ElapsedTime` with `format="minutes"`; `{count}` is replaced. */
30
30
  minutesShort: string;
31
+ hoursShort: string;
32
+ hoursMinutesShort: string;
33
+ elapsedHoursOne: string;
34
+ elapsedHours: string;
31
35
  /** Accessible text of a countdown `ElapsedTime`; `{time}` is the remaining time. */
32
36
  countdownLeft: string;
33
37
  /** Accessible text of a countdown `ElapsedTime` past its target; `{time}` is the overrun. */
@@ -44,6 +48,28 @@ export interface UiStrings {
44
48
  rotate: string;
45
49
  /** Keyboard help of an editable `FloorPlan`. */
46
50
  floorPlanEditHint: string;
51
+ orderTicketNumber: string;
52
+ orderTicketTableAndNumber: string;
53
+ orderTicketGuests: string;
54
+ orderTicketGuestsOne: string;
55
+ orderTicketPart: string;
56
+ orderTicketContinued: string;
57
+ orderTicketOnTime: string;
58
+ orderTicketDueSoon: string;
59
+ orderTicketLate: string;
60
+ orderTicketLateBy: string;
61
+ orderTicketProgress: string;
62
+ orderTicketProgressValue: string;
63
+ orderTicketProgressDuration: string;
64
+ orderTicketItems: string;
65
+ orderTicketPending: string;
66
+ orderTicketInProgress: string;
67
+ orderTicketDone: string;
68
+ orderTicketNote: string;
69
+ orderTicketAllergy: string;
70
+ orderTicketRecovered: string;
71
+ orderTicketStartAll: string;
72
+ orderTicketReadyAll: string;
47
73
  remove: string;
48
74
  noResults: string;
49
75
  clear: string;
@@ -187,6 +213,10 @@ export const uiStrings = {
187
213
  elapsedMinutesOne: "{count} minute",
188
214
  elapsedMinutes: "{count} minutes",
189
215
  minutesShort: "{count} min",
216
+ hoursShort: "{hours} h",
217
+ hoursMinutesShort: "{hours} h {minutes} min",
218
+ elapsedHoursOne: "{count} hour",
219
+ elapsedHours: "{count} hours",
190
220
  countdownLeft: "{time} left",
191
221
  countdownOver: "{time} over",
192
222
  seats: "{count} seats",
@@ -195,6 +225,28 @@ export const uiStrings = {
195
225
  floorPlan: "Floor plan",
196
226
  rotate: "Rotate 90°",
197
227
  floorPlanEditHint: "Alt with arrows moves, Alt and Shift with arrows resizes, R rotates.",
228
+ orderTicketNumber: "No. {number}",
229
+ orderTicketTableAndNumber: "{table} · No. {number}",
230
+ orderTicketGuests: "{count} guests",
231
+ orderTicketGuestsOne: "{count} guest",
232
+ orderTicketPart: "({index} of {count})",
233
+ orderTicketContinued: "(cont.)",
234
+ orderTicketOnTime: "on time",
235
+ orderTicketDueSoon: "due soon",
236
+ orderTicketLate: "late",
237
+ orderTicketLateBy: "Late +{time}",
238
+ orderTicketProgress: "Time against the {target} min target",
239
+ orderTicketProgressValue: "{elapsed} of {target} min",
240
+ orderTicketProgressDuration: "{elapsed} of {target}",
241
+ orderTicketItems: "Items",
242
+ orderTicketPending: "Queued",
243
+ orderTicketInProgress: "Preparing",
244
+ orderTicketDone: "Ready",
245
+ orderTicketNote: "Note: {note}",
246
+ orderTicketAllergy: "Allergy: {allergy}",
247
+ orderTicketRecovered: "Recalled",
248
+ orderTicketStartAll: "Start all",
249
+ orderTicketReadyAll: "All ready",
198
250
  remove: "Remove",
199
251
  noResults: "No results",
200
252
  clear: "Clear",
@@ -288,6 +340,10 @@ export const uiStrings = {
288
340
  elapsedMinutesOne: "{count} minuto",
289
341
  elapsedMinutes: "{count} minutos",
290
342
  minutesShort: "{count} min",
343
+ hoursShort: "{hours} h",
344
+ hoursMinutesShort: "{hours} h {minutes} min",
345
+ elapsedHoursOne: "{count} hora",
346
+ elapsedHours: "{count} horas",
291
347
  countdownLeft: "faltan {time}",
292
348
  countdownOver: "{time} de retraso",
293
349
  seats: "{count} asientos",
@@ -296,6 +352,28 @@ export const uiStrings = {
296
352
  floorPlan: "Plano de sala",
297
353
  rotate: "Girar 90°",
298
354
  floorPlanEditHint: "Alt con flechas mueve, Alt y Mayús con flechas cambia el tamaño, R gira.",
355
+ orderTicketNumber: "N.º {number}",
356
+ orderTicketTableAndNumber: "{table} · N.º {number}",
357
+ orderTicketGuests: "{count} personas",
358
+ orderTicketGuestsOne: "{count} persona",
359
+ orderTicketPart: "({index} de {count})",
360
+ orderTicketContinued: "(cont.)",
361
+ orderTicketOnTime: "a tiempo",
362
+ orderTicketDueSoon: "por vencer",
363
+ orderTicketLate: "demorada",
364
+ orderTicketLateBy: "Demorada +{time}",
365
+ orderTicketProgress: "Tiempo contra los {target} min objetivo",
366
+ orderTicketProgressValue: "{elapsed} de {target} min",
367
+ orderTicketProgressDuration: "{elapsed} de {target}",
368
+ orderTicketItems: "Platos",
369
+ orderTicketPending: "En cola",
370
+ orderTicketInProgress: "Preparando",
371
+ orderTicketDone: "Listo",
372
+ orderTicketNote: "Nota: {note}",
373
+ orderTicketAllergy: "Alergia: {allergy}",
374
+ orderTicketRecovered: "Recuperada",
375
+ orderTicketStartAll: "Empezar todo",
376
+ orderTicketReadyAll: "Listo todo",
299
377
  remove: "Quitar",
300
378
  noResults: "Sin resultados",
301
379
  clear: "Limpiar",
@@ -0,0 +1,16 @@
1
+ // Generated by scripts/build-icons.mjs. Do not edit.
2
+ // Source: icons/svg/alarm-clock.svg
3
+ import { IconBase, type IconProps } from "./icon-base.js";
4
+
5
+ export function AlarmClock(props: IconProps) {
6
+ return (
7
+ <IconBase {...props}>
8
+ <circle cx="12" cy="13" r="8" />
9
+ <path d="M12 9v4l2 2" />
10
+ <path d="M5 3 2 6" />
11
+ <path d="m22 6-3-3" />
12
+ <path d="M6.38 18.7 4 21" />
13
+ <path d="M17.64 18.67 20 21" />
14
+ </IconBase>
15
+ );
16
+ }
@@ -0,0 +1,14 @@
1
+ // Generated by scripts/build-icons.mjs. Do not edit.
2
+ // Source: icons/svg/hourglass.svg
3
+ import { IconBase, type IconProps } from "./icon-base.js";
4
+
5
+ export function Hourglass(props: IconProps) {
6
+ return (
7
+ <IconBase {...props}>
8
+ <path d="M5 22h14" />
9
+ <path d="M5 2h14" />
10
+ <path d="M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22" />
11
+ <path d="M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2" />
12
+ </IconBase>
13
+ );
14
+ }
@@ -1,5 +1,6 @@
1
1
  // Generated by scripts/build-icons.mjs. Do not edit.
2
2
  export { type IconComponent, type IconProps, type LucideIcon } from "./icon-base.js";
3
+ export { AlarmClock } from "./alarm-clock.js";
3
4
  export { AlertTriangle } from "./alert-triangle.js";
4
5
  export { Archive } from "./archive.js";
5
6
  export { Armchair } from "./armchair.js";
@@ -70,6 +71,7 @@ export { Funnel } from "./funnel.js";
70
71
  export { GraduationCap } from "./graduation-cap.js";
71
72
  export { GripVertical } from "./grip-vertical.js";
72
73
  export { Heading2 } from "./heading-2.js";
74
+ export { Hourglass } from "./hourglass.js";
73
75
  export { House } from "./house.js";
74
76
  export { Inbox } from "./inbox.js";
75
77
  export { Info } from "./info.js";
@@ -0,0 +1,96 @@
1
+ import type {
2
+ IntentDataAttributes,
3
+ IntentExpectationInput,
4
+ IntentProps,
5
+ IntentSemanticExpectation,
6
+ IntentTargetRef,
7
+ RoleSource,
8
+ } from "./types.js";
9
+
10
+ export const INTENT_ATTRIBUTE = "data-intent";
11
+ export const INTENT_KEY_ATTRIBUTE = "data-intent-key";
12
+ export const INTENT_HIGHLIGHT_ATTRIBUTE = "data-intent-highlight";
13
+ export const INTENT_CHANGED_ATTRIBUTE = "data-intent-changed";
14
+ export const ROW_ID_ATTRIBUTE = "data-row-id";
15
+ export const COLUMN_ID_ATTRIBUTE = "data-col-id";
16
+
17
+ const INPUT_ROLES: Readonly<Record<string, string>> = {
18
+ checkbox: "checkbox",
19
+ radio: "radio",
20
+ range: "slider",
21
+ number: "spinbutton",
22
+ search: "searchbox",
23
+ button: "button",
24
+ submit: "button",
25
+ reset: "button",
26
+ };
27
+
28
+ const TAG_ROLES: Readonly<Record<string, string>> = {
29
+ button: "button",
30
+ textarea: "textbox",
31
+ tr: "row",
32
+ td: "cell",
33
+ th: "columnheader",
34
+ table: "table",
35
+ article: "article",
36
+ fieldset: "group",
37
+ form: "form",
38
+ dialog: "dialog",
39
+ li: "listitem",
40
+ nav: "navigation",
41
+ section: "region",
42
+ };
43
+
44
+ const GENERIC_ROLE = "generic";
45
+
46
+ const isNonEmpty = (value: string | undefined): value is string =>
47
+ value !== undefined && value !== "";
48
+
49
+ export function intentAttributes(props: IntentProps): IntentDataAttributes {
50
+ if (!isNonEmpty(props.intent)) return {};
51
+ if (!isNonEmpty(props.intentKey)) return { [INTENT_ATTRIBUTE]: props.intent };
52
+ return { [INTENT_ATTRIBUTE]: props.intent, [INTENT_KEY_ATTRIBUTE]: props.intentKey };
53
+ }
54
+
55
+ export function intentTargetRef(props: IntentProps): IntentTargetRef | undefined {
56
+ if (!isNonEmpty(props.intent)) return undefined;
57
+ if (!isNonEmpty(props.intentKey)) return { intent: props.intent };
58
+ return { intent: props.intent, key: props.intentKey };
59
+ }
60
+
61
+ const selectRole = (source: RoleSource): string => {
62
+ const size = Number(source.getAttribute("size"));
63
+ return source.getAttribute("multiple") !== null || size > 1 ? "listbox" : "combobox";
64
+ };
65
+
66
+ const inputRole = (source: RoleSource): string =>
67
+ INPUT_ROLES[(source.getAttribute("type") ?? "").toLowerCase()] ?? "textbox";
68
+
69
+ export function implicitRoleOf(source: RoleSource): string {
70
+ const tag = source.tagName.toLowerCase();
71
+ if (tag === "a" || tag === "area") {
72
+ return source.getAttribute("href") === null ? GENERIC_ROLE : "link";
73
+ }
74
+ if (tag === "input") return inputRole(source);
75
+ if (tag === "select") return selectRole(source);
76
+ return TAG_ROLES[tag] ?? GENERIC_ROLE;
77
+ }
78
+
79
+ const nonEmptyOrUndefined = (value: string | null | undefined): string | undefined =>
80
+ value === null || value === undefined || value.trim() === "" ? undefined : value.trim();
81
+
82
+ const firstRoleToken = (value: string | null): string | undefined =>
83
+ nonEmptyOrUndefined(value?.split(/\s+/)[0]);
84
+
85
+ export function resolveExpectation(
86
+ input: IntentExpectationInput | undefined,
87
+ source: RoleSource,
88
+ ): IntentSemanticExpectation {
89
+ return {
90
+ role:
91
+ nonEmptyOrUndefined(input?.role) ??
92
+ firstRoleToken(source.getAttribute("role")) ??
93
+ implicitRoleOf(source),
94
+ requireName: input?.requireName ?? true,
95
+ };
96
+ }
@@ -0,0 +1,25 @@
1
+ "use client";
2
+
3
+ import { createContext, type ReactElement, type ReactNode, useContext } from "react";
4
+ import type { IntentBridge } from "./types.js";
5
+
6
+ export const noopIntentBridge: IntentBridge = {
7
+ registerTarget: () => () => {},
8
+ };
9
+
10
+ const IntentBridgeContext = createContext<IntentBridge>(noopIntentBridge);
11
+
12
+ export function IntentBridgeProvider(props: {
13
+ bridge: IntentBridge;
14
+ children: ReactNode;
15
+ }): ReactElement {
16
+ return (
17
+ <IntentBridgeContext.Provider value={props.bridge}>
18
+ {props.children}
19
+ </IntentBridgeContext.Provider>
20
+ );
21
+ }
22
+
23
+ export function useIntentBridge(): IntentBridge {
24
+ return useContext(IntentBridgeContext);
25
+ }
@@ -0,0 +1,24 @@
1
+ export {
2
+ COLUMN_ID_ATTRIBUTE,
3
+ INTENT_ATTRIBUTE,
4
+ INTENT_CHANGED_ATTRIBUTE,
5
+ INTENT_HIGHLIGHT_ATTRIBUTE,
6
+ INTENT_KEY_ATTRIBUTE,
7
+ implicitRoleOf,
8
+ intentAttributes,
9
+ intentTargetRef,
10
+ ROW_ID_ATTRIBUTE,
11
+ resolveExpectation,
12
+ } from "./attributes.js";
13
+ export { IntentBridgeProvider, noopIntentBridge, useIntentBridge } from "./bridge.js";
14
+ export type {
15
+ IntentBridge,
16
+ IntentDataAttributes,
17
+ IntentExpectationInput,
18
+ IntentProps,
19
+ IntentSemanticExpectation,
20
+ IntentTargetBinder,
21
+ IntentTargetRef,
22
+ RoleSource,
23
+ } from "./types.js";
24
+ export { useIntentTarget, useIntentTargets } from "./use-intent-target.js";
@@ -0,0 +1,127 @@
1
+ import { isProduction } from "../utils/is-production.js";
2
+ import type { IntentBridge, IntentSemanticExpectation, IntentTargetRef } from "./types.js";
3
+
4
+ const IDENTITY_SEPARATOR = "\u0000";
5
+
6
+ interface Registration {
7
+ readonly identity: string;
8
+ readonly element: Element;
9
+ readonly expectation: IntentSemanticExpectation;
10
+ readonly unregister: () => void;
11
+ released: boolean;
12
+ }
13
+
14
+ export interface BridgeRegistrations {
15
+ readonly byIdentity: Map<string, Registration[]>;
16
+ readonly awaitingSweep: Set<Registration>;
17
+ readonly warnedDuplicates: Set<string>;
18
+ }
19
+
20
+ const registrationsByBridge = new WeakMap<IntentBridge, BridgeRegistrations>();
21
+
22
+ export function registrationsOf(bridge: IntentBridge): BridgeRegistrations {
23
+ const existing = registrationsByBridge.get(bridge);
24
+ if (existing) return existing;
25
+ const created: BridgeRegistrations = {
26
+ byIdentity: new Map(),
27
+ awaitingSweep: new Set(),
28
+ warnedDuplicates: new Set(),
29
+ };
30
+ registrationsByBridge.set(bridge, created);
31
+ return created;
32
+ }
33
+
34
+ const identityOf = (ref: IntentTargetRef): string =>
35
+ `${ref.intent}${IDENTITY_SEPARATOR}${ref.key ?? ""}`;
36
+
37
+ const sameExpectation = (a: IntentSemanticExpectation, b: IntentSemanticExpectation): boolean =>
38
+ a.role === b.role && a.requireName === b.requireName;
39
+
40
+ function reportBridgeError(error: unknown): void {
41
+ if (typeof globalThis.reportError === "function") globalThis.reportError(error);
42
+ else console.error(error);
43
+ }
44
+
45
+ function drop(state: BridgeRegistrations, entry: Registration): void {
46
+ state.awaitingSweep.delete(entry);
47
+ const list = state.byIdentity.get(entry.identity);
48
+ const index = list ? list.indexOf(entry) : -1;
49
+ if (!list || index < 0) return;
50
+ list.splice(index, 1);
51
+ if (list.length === 0) state.byIdentity.delete(entry.identity);
52
+ try {
53
+ entry.unregister();
54
+ } catch (error) {
55
+ reportBridgeError(error);
56
+ }
57
+ }
58
+
59
+ function duplicateTargetWarning(ref: IntentTargetRef): string {
60
+ const key = ref.key === undefined ? "" : ` with key "${ref.key}"`;
61
+ return `Intent target "${ref.intent}"${key} is already registered on another element. An intent and key must name one element at a time.`;
62
+ }
63
+
64
+ function warnOnLiveDuplicate(
65
+ state: BridgeRegistrations,
66
+ ref: IntentTargetRef,
67
+ identity: string,
68
+ element: Element,
69
+ ): void {
70
+ if (isProduction() || state.warnedDuplicates.has(identity)) return;
71
+ const live = state.byIdentity.get(identity) ?? [];
72
+ if (!live.some((entry) => !entry.released && entry.element !== element)) return;
73
+ state.warnedDuplicates.add(identity);
74
+ console.warn(duplicateTargetWarning(ref));
75
+ }
76
+
77
+ function sweepDisconnected(state: BridgeRegistrations): void {
78
+ for (const entry of state.awaitingSweep) {
79
+ if (!entry.element.isConnected) drop(state, entry);
80
+ }
81
+ state.awaitingSweep.clear();
82
+ }
83
+
84
+ function revive(state: BridgeRegistrations, entry: Registration): Registration {
85
+ entry.released = false;
86
+ state.awaitingSweep.delete(entry);
87
+ return entry;
88
+ }
89
+
90
+ function releaseLater(state: BridgeRegistrations, entry: Registration): () => void {
91
+ return () => {
92
+ entry.released = true;
93
+ state.awaitingSweep.add(entry);
94
+ queueMicrotask(() => {
95
+ if (entry.released) drop(state, entry);
96
+ });
97
+ };
98
+ }
99
+
100
+ export function attachTarget(
101
+ bridge: IntentBridge,
102
+ ref: IntentTargetRef,
103
+ element: Element,
104
+ expectation: IntentSemanticExpectation,
105
+ ): () => void {
106
+ const state = registrationsOf(bridge);
107
+ const identity = identityOf(ref);
108
+ const released = (state.byIdentity.get(identity) ?? []).filter((entry) => entry.released);
109
+ const revivable = released.find(
110
+ (entry) => entry.element === element && sameExpectation(entry.expectation, expectation),
111
+ );
112
+ for (const entry of released) if (entry !== revivable) drop(state, entry);
113
+ if (element.isConnected) sweepDisconnected(state);
114
+ warnOnLiveDuplicate(state, ref, identity, element);
115
+ if (revivable) return releaseLater(state, revive(state, revivable));
116
+ const entry: Registration = {
117
+ identity,
118
+ element,
119
+ expectation,
120
+ unregister: bridge.registerTarget(ref, element, expectation),
121
+ released: false,
122
+ };
123
+ const list = state.byIdentity.get(identity);
124
+ if (list) list.push(entry);
125
+ else state.byIdentity.set(identity, [entry]);
126
+ return releaseLater(state, entry);
127
+ }
@@ -0,0 +1,44 @@
1
+ import type { RefCallback } from "react";
2
+
3
+ export interface IntentTargetRef {
4
+ readonly intent: string;
5
+ readonly key?: string;
6
+ }
7
+
8
+ export interface IntentSemanticExpectation {
9
+ readonly role: string;
10
+ readonly requireName: boolean;
11
+ }
12
+
13
+ export interface IntentBridge {
14
+ registerTarget(
15
+ ref: IntentTargetRef,
16
+ element: Element,
17
+ expectation: IntentSemanticExpectation,
18
+ ): () => void;
19
+ }
20
+
21
+ export interface IntentProps {
22
+ intent?: string | undefined;
23
+ intentKey?: string | undefined;
24
+ }
25
+
26
+ export interface IntentDataAttributes {
27
+ "data-intent"?: string;
28
+ "data-intent-key"?: string;
29
+ }
30
+
31
+ export interface IntentExpectationInput {
32
+ role?: string | undefined;
33
+ requireName?: boolean | undefined;
34
+ }
35
+
36
+ export interface RoleSource {
37
+ readonly tagName: string;
38
+ getAttribute(name: string): string | null;
39
+ }
40
+
41
+ export type IntentTargetBinder = <E extends Element = Element>(
42
+ props: IntentProps,
43
+ expectation?: IntentExpectationInput,
44
+ ) => RefCallback<E> | undefined;
@@ -0,0 +1,96 @@
1
+ "use client";
2
+
3
+ import { type RefCallback, useCallback, useMemo } from "react";
4
+ import { intentTargetRef, resolveExpectation } from "./attributes.js";
5
+ import { noopIntentBridge, useIntentBridge } from "./bridge.js";
6
+ import { attachTarget } from "./target-registrations.js";
7
+ import type {
8
+ IntentBridge,
9
+ IntentExpectationInput,
10
+ IntentProps,
11
+ IntentTargetBinder,
12
+ } from "./types.js";
13
+
14
+ const CACHE_SEPARATOR = "\u0000";
15
+
16
+ const ignoreElement: RefCallback<Element> = () => undefined;
17
+
18
+ function createTargetRef<E extends Element>(
19
+ bridge: IntentBridge,
20
+ props: IntentProps,
21
+ expectation: IntentExpectationInput | undefined,
22
+ ): RefCallback<E> | undefined {
23
+ const ref = intentTargetRef(props);
24
+ if (ref === undefined || bridge === noopIntentBridge) return undefined;
25
+ let current: (() => void) | undefined;
26
+ const release = () => {
27
+ const run = current;
28
+ current = undefined;
29
+ run?.();
30
+ };
31
+ return (element) => {
32
+ release();
33
+ if (element === null) return undefined;
34
+ current = attachTarget(bridge, ref, element, resolveExpectation(expectation, element));
35
+ return release;
36
+ };
37
+ }
38
+
39
+ export function useIntentTarget<E extends Element = Element>(
40
+ props: IntentProps,
41
+ expectation?: IntentExpectationInput,
42
+ ): RefCallback<E> {
43
+ const bridge = useIntentBridge();
44
+ const { intent, intentKey } = props;
45
+ const role = expectation?.role;
46
+ const requireName = expectation?.requireName;
47
+ return useMemo(
48
+ () =>
49
+ createTargetRef<E>(bridge, { intent, intentKey }, { role, requireName }) ??
50
+ (ignoreElement as RefCallback<E>),
51
+ [bridge, intent, intentKey, role, requireName],
52
+ );
53
+ }
54
+
55
+ export function useIntentTargets(): IntentTargetBinder {
56
+ const bridge = useIntentBridge();
57
+ const bind = useCallback(
58
+ (cache: Map<string, RefCallback<Element>>): IntentTargetBinder =>
59
+ <E extends Element = Element>(
60
+ props: IntentProps,
61
+ expectation?: IntentExpectationInput,
62
+ ): RefCallback<E> | undefined => {
63
+ const ref = intentTargetRef(props);
64
+ if (ref === undefined) return undefined;
65
+ const cacheKey = [
66
+ ref.intent,
67
+ ref.key ?? "",
68
+ expectation?.role ?? "",
69
+ String(expectation?.requireName ?? true),
70
+ ].join(CACHE_SEPARATOR);
71
+ const cached = cache.get(cacheKey);
72
+ if (cached !== undefined) return cached as RefCallback<E>;
73
+ const inner = createTargetRef<Element>(bridge, props, expectation);
74
+ if (inner === undefined) return undefined;
75
+ const forget = () => {
76
+ if (cache.get(cacheKey) === bound) cache.delete(cacheKey);
77
+ };
78
+ const bound: RefCallback<Element> = (element) => {
79
+ const release = inner(element);
80
+ if (element === null) {
81
+ forget();
82
+ return undefined;
83
+ }
84
+ cache.set(cacheKey, bound);
85
+ return () => {
86
+ forget();
87
+ if (typeof release === "function") release();
88
+ };
89
+ };
90
+ cache.set(cacheKey, bound);
91
+ return bound as RefCallback<E>;
92
+ },
93
+ [bridge],
94
+ );
95
+ return useMemo(() => bind(new Map()), [bind]);
96
+ }