@link-foundation/ui-components 0.0.0-stage → 0.0.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 (402) hide show
  1. package/CONFIGURATIONS.md +74 -0
  2. package/ICONS.md +76 -0
  3. package/LICENSE +24 -0
  4. package/README.md +1499 -2
  5. package/bin/lino-network.mjs +71 -0
  6. package/dist/icons/ATTRIBUTION.md +602 -0
  7. package/dist/icons/NOTICE.lino +1261 -0
  8. package/dist/icons/brand.js +31 -0
  9. package/dist/icons/brand.svg +3 -0
  10. package/dist/icons/licenses/brand/DISCLAIMER.md +51 -0
  11. package/dist/icons/licenses/brand/LICENSE.md +30 -0
  12. package/dist/icons/licenses/lucide/LICENSE +43 -0
  13. package/dist/icons/licenses/material-symbols/LICENSE +202 -0
  14. package/dist/icons/licenses/material-symbols/NOTICE +12 -0
  15. package/dist/icons/licenses/tabler/LICENSE +21 -0
  16. package/dist/icons/lucide.js +681 -0
  17. package/dist/icons/lucide.svg +34 -0
  18. package/dist/icons/material-symbols.js +681 -0
  19. package/dist/icons/material-symbols.svg +34 -0
  20. package/dist/icons/own.js +521 -0
  21. package/dist/icons/own.svg +34 -0
  22. package/dist/icons/tabler.js +681 -0
  23. package/dist/icons/tabler.svg +34 -0
  24. package/dist/network-layout-NOTICE.md +6 -0
  25. package/dist/network-layout-d3-dispatch-LICENSE.txt +13 -0
  26. package/dist/network-layout-d3-force-LICENSE.txt +13 -0
  27. package/dist/network-layout-d3-quadtree-LICENSE.txt +13 -0
  28. package/dist/network-layout-d3-timer-LICENSE.txt +13 -0
  29. package/dist/network-layout-dagre-LICENSE.txt +19 -0
  30. package/dist/network-layout.worker.mjs +2 -0
  31. package/package.json +246 -4
  32. package/src/a11y/announce.js +88 -0
  33. package/src/a11y/bind-machine.js +181 -0
  34. package/src/a11y/focus.js +169 -0
  35. package/src/a11y/index.d.ts +89 -0
  36. package/src/a11y/index.js +19 -0
  37. package/src/a11y/keys.js +182 -0
  38. package/src/a11y/roving.js +167 -0
  39. package/src/a11y/typeahead.js +82 -0
  40. package/src/behavior/actions.js +235 -0
  41. package/src/behavior/diagnostics.js +73 -0
  42. package/src/behavior/dom.d.ts +38 -0
  43. package/src/behavior/dom.js +420 -0
  44. package/src/behavior/index.d.ts +211 -0
  45. package/src/behavior/index.js +29 -0
  46. package/src/behavior/interpret.js +454 -0
  47. package/src/behavior/machines/disclosure.lino +46 -0
  48. package/src/behavior/machines/index.js +91 -0
  49. package/src/behavior/machines/toggle.lino +25 -0
  50. package/src/behavior/parse-machine.js +367 -0
  51. package/src/charts/README.md +78 -0
  52. package/src/charts/activity-layout.js +350 -0
  53. package/src/charts/activity-model.js +130 -0
  54. package/src/charts/activity-validation.js +31 -0
  55. package/src/charts/chart-model.js +667 -0
  56. package/src/charts/chart.js +518 -0
  57. package/src/charts/echarts-adapter.d.ts +23 -0
  58. package/src/charts/echarts-adapter.js +240 -0
  59. package/src/charts/element.js +330 -0
  60. package/src/charts/errors.js +62 -0
  61. package/src/charts/gauge.js +27 -0
  62. package/src/charts/index.d.ts +344 -0
  63. package/src/charts/index.js +59 -0
  64. package/src/charts/layout.js +542 -0
  65. package/src/charts/lino.js +158 -0
  66. package/src/charts/mark-options.js +78 -0
  67. package/src/charts/read.js +101 -0
  68. package/src/charts/renderer-features.js +8 -0
  69. package/src/charts/scales.js +223 -0
  70. package/src/charts/small-model.js +223 -0
  71. package/src/charts/small-svg.js +269 -0
  72. package/src/charts/sparkline.js +27 -0
  73. package/src/charts/stat-tile.js +37 -0
  74. package/src/charts/summary.js +193 -0
  75. package/src/charts/svg-renderer.js +226 -0
  76. package/src/charts/svg.js +69 -0
  77. package/src/charts/tag-cloud.js +129 -0
  78. package/src/charts/tokens.js +171 -0
  79. package/src/charts/tooltip.js +47 -0
  80. package/src/charts/values.js +146 -0
  81. package/src/chat/README.md +142 -0
  82. package/src/chat/actions.js +75 -0
  83. package/src/chat/chat-contract.js +95 -0
  84. package/src/chat/chat-list.js +42 -0
  85. package/src/chat/chat-model.js +125 -0
  86. package/src/chat/chat.css +228 -0
  87. package/src/chat/composer.js +131 -0
  88. package/src/chat/day-separator.js +12 -0
  89. package/src/chat/dom.js +33 -0
  90. package/src/chat/follow.js +49 -0
  91. package/src/chat/index.d.ts +142 -0
  92. package/src/chat/index.js +13 -0
  93. package/src/chat/message-bubble.js +191 -0
  94. package/src/chat/message-stream.js +331 -0
  95. package/src/chat/reasoning-trace.js +70 -0
  96. package/src/chat/selection.js +39 -0
  97. package/src/chat/skins/bubbles.lino +2 -0
  98. package/src/chat/skins/cards.lino +4 -0
  99. package/src/chat/skins/compact.lino +4 -0
  100. package/src/chat/skins/signal.lino +25 -0
  101. package/src/chat/skins/t3.lino +25 -0
  102. package/src/chat/skins/telegram.lino +31 -0
  103. package/src/chat/skins/whatsapp.lino +25 -0
  104. package/src/chat/stream-keys.js +57 -0
  105. package/src/chat/stream-window.js +159 -0
  106. package/src/chat/vocabulary.js +19 -0
  107. package/src/controls/accordion.js +160 -0
  108. package/src/controls/avatar.js +80 -0
  109. package/src/controls/badge.js +48 -0
  110. package/src/controls/button-template.js +32 -0
  111. package/src/controls/button.js +97 -0
  112. package/src/controls/catalog.lino +84 -0
  113. package/src/controls/checkbox.js +112 -0
  114. package/src/controls/chip.js +140 -0
  115. package/src/controls/choices.js +45 -0
  116. package/src/controls/color-field.js +217 -0
  117. package/src/controls/color-popover.js +135 -0
  118. package/src/controls/color-rgb.js +80 -0
  119. package/src/controls/color.js +67 -0
  120. package/src/controls/combobox.js +192 -0
  121. package/src/controls/dom.js +261 -0
  122. package/src/controls/icon-button.js +33 -0
  123. package/src/controls/index.d.ts +163 -0
  124. package/src/controls/index.js +182 -0
  125. package/src/controls/kinds-text.js +358 -0
  126. package/src/controls/kinds.lino +350 -0
  127. package/src/controls/label.js +52 -0
  128. package/src/controls/link.js +101 -0
  129. package/src/controls/listbox.js +144 -0
  130. package/src/controls/machines/button.lino +20 -0
  131. package/src/controls/machines/checkbox.lino +17 -0
  132. package/src/controls/machines/chip.lino +20 -0
  133. package/src/controls/machines/color-field.lino +23 -0
  134. package/src/controls/machines/combobox.lino +82 -0
  135. package/src/controls/machines/icon-button.lino +20 -0
  136. package/src/controls/machines/index.js +586 -0
  137. package/src/controls/machines/number-field.lino +71 -0
  138. package/src/controls/machines/radio-group.lino +17 -0
  139. package/src/controls/machines/select.lino +122 -0
  140. package/src/controls/machines/slider.lino +99 -0
  141. package/src/controls/machines/switch.lino +19 -0
  142. package/src/controls/machines/text-area.lino +26 -0
  143. package/src/controls/machines/text-field.lino +26 -0
  144. package/src/controls/number-field.js +239 -0
  145. package/src/controls/numeric-keys.js +125 -0
  146. package/src/controls/option.js +54 -0
  147. package/src/controls/progress.js +76 -0
  148. package/src/controls/radio-group.js +234 -0
  149. package/src/controls/select.js +229 -0
  150. package/src/controls/slider.js +234 -0
  151. package/src/controls/stories.js +172 -0
  152. package/src/controls/styles.css +1060 -0
  153. package/src/controls/switch.js +95 -0
  154. package/src/controls/text-area.js +39 -0
  155. package/src/controls/text-field.js +131 -0
  156. package/src/controls/vocabulary.js +164 -0
  157. package/src/data/data.css +95 -0
  158. package/src/data/index.d.ts +83 -0
  159. package/src/data/index.js +10 -0
  160. package/src/data/keyboard.js +189 -0
  161. package/src/data/list.js +215 -0
  162. package/src/data/render-data.js +116 -0
  163. package/src/data/selection-dom.js +39 -0
  164. package/src/data/selection-model.js +43 -0
  165. package/src/data/sort-model.js +42 -0
  166. package/src/data/source.js +45 -0
  167. package/src/data/table.js +160 -0
  168. package/src/data/tree-model.js +41 -0
  169. package/src/data/tree.js +55 -0
  170. package/src/data/viewport.js +216 -0
  171. package/src/data/virtual-range.js +92 -0
  172. package/src/data/vocabulary.js +67 -0
  173. package/src/diagrams/diagram-model.js +511 -0
  174. package/src/diagrams/diagram.js +204 -0
  175. package/src/diagrams/index.d.ts +225 -0
  176. package/src/diagrams/index.js +48 -0
  177. package/src/diagrams/layout-dagre.js +164 -0
  178. package/src/diagrams/layout-plugins.js +131 -0
  179. package/src/diagrams/mermaid-export.js +232 -0
  180. package/src/diagrams/mermaid-view.js +229 -0
  181. package/src/diagrams/svg-diagram.js +215 -0
  182. package/src/editor/code-editor.js +206 -0
  183. package/src/editor/documents-model.js +170 -0
  184. package/src/editor/documents-persistence.js +85 -0
  185. package/src/editor/editor-engine.js +22 -0
  186. package/src/editor/editor-ui.js +203 -0
  187. package/src/editor/editor.css +106 -0
  188. package/src/editor/engines/codemirror.js +227 -0
  189. package/src/editor/engines/monaco.js +219 -0
  190. package/src/editor/index.d.ts +111 -0
  191. package/src/editor/index.js +14 -0
  192. package/src/editor/lino-highlight.js +106 -0
  193. package/src/editor/lino-structure.js +85 -0
  194. package/src/editor/validate-lino.js +43 -0
  195. package/src/embed/README.md +161 -0
  196. package/src/embed/controller.js +223 -0
  197. package/src/embed/element.js +141 -0
  198. package/src/embed/index.d.ts +75 -0
  199. package/src/embed/index.js +9 -0
  200. package/src/embed/providers/telegram.d.ts +3 -0
  201. package/src/embed/providers/telegram.js +38 -0
  202. package/src/embed/providers/vk.d.ts +3 -0
  203. package/src/embed/providers/vk.js +42 -0
  204. package/src/embed/providers/x.d.ts +3 -0
  205. package/src/embed/providers/x.js +31 -0
  206. package/src/embed/registry.js +35 -0
  207. package/src/embed/script.js +73 -0
  208. package/src/embed/view.js +122 -0
  209. package/src/icons/adapters/lucide.d.ts +15 -0
  210. package/src/icons/adapters/lucide.js +142 -0
  211. package/src/icons/adapters/material-symbols.d.ts +13 -0
  212. package/src/icons/adapters/material-symbols.js +113 -0
  213. package/src/icons/adapters/shared.d.ts +38 -0
  214. package/src/icons/adapters/shared.js +157 -0
  215. package/src/icons/adapters/simple-icons.d.ts +9 -0
  216. package/src/icons/adapters/simple-icons.js +38 -0
  217. package/src/icons/adapters/tabler.d.ts +9 -0
  218. package/src/icons/adapters/tabler.js +86 -0
  219. package/src/icons/icon-registry.js +215 -0
  220. package/src/icons/icon.js +356 -0
  221. package/src/icons/index.d.ts +123 -0
  222. package/src/icons/index.js +30 -0
  223. package/src/icons/names.js +51 -0
  224. package/src/icons/own-icons.js +521 -0
  225. package/src/icons/presentation.js +55 -0
  226. package/src/icons/svg.js +136 -0
  227. package/src/index.d.ts +14 -0
  228. package/src/index.js +40 -0
  229. package/src/layout/README.md +102 -0
  230. package/src/layout/app-shell.js +150 -0
  231. package/src/layout/catalog.lino +27 -0
  232. package/src/layout/dock-model.js +576 -0
  233. package/src/layout/dock-view.js +312 -0
  234. package/src/layout/dock.js +352 -0
  235. package/src/layout/dom.js +312 -0
  236. package/src/layout/grid.js +192 -0
  237. package/src/layout/index.d.ts +267 -0
  238. package/src/layout/index.js +60 -0
  239. package/src/layout/layer-manager.js +120 -0
  240. package/src/layout/layout.css +760 -0
  241. package/src/layout/menu.js +141 -0
  242. package/src/layout/nav-strip.js +174 -0
  243. package/src/layout/page-links.js +166 -0
  244. package/src/layout/panel.js +26 -0
  245. package/src/layout/pref-switches.js +209 -0
  246. package/src/layout/split-model.js +270 -0
  247. package/src/layout/split.js +430 -0
  248. package/src/layout/stack.js +86 -0
  249. package/src/layout/surfaces.js +119 -0
  250. package/src/layout/tab-group.js +151 -0
  251. package/src/layout/tab-strip.js +277 -0
  252. package/src/layout/vocabulary.js +229 -0
  253. package/src/layout/window-frame.js +222 -0
  254. package/src/layout/window.js +146 -0
  255. package/src/links-view/animator.js +144 -0
  256. package/src/links-view/configuration-classes.js +150 -0
  257. package/src/links-view/configuration-model.js +191 -0
  258. package/src/links-view/configuration-notations.js +230 -0
  259. package/src/links-view/configurations.d.ts +73 -0
  260. package/src/links-view/configurations.js +33 -0
  261. package/src/links-view/create-layout-runner.js +79 -0
  262. package/src/links-view/doublet-curves.js +239 -0
  263. package/src/links-view/doublet-layout.js +148 -0
  264. package/src/links-view/doublet-markers.js +109 -0
  265. package/src/links-view/doublet-options.js +369 -0
  266. package/src/links-view/doublet-svg.js +156 -0
  267. package/src/links-view/doublet.js +230 -0
  268. package/src/links-view/export.js +146 -0
  269. package/src/links-view/geometry.js +409 -0
  270. package/src/links-view/index.d.ts +1029 -0
  271. package/src/links-view/index.js +140 -0
  272. package/src/links-view/labels.js +28 -0
  273. package/src/links-view/layout-worker-entry.mjs +2 -0
  274. package/src/links-view/layout-worker.js +28 -0
  275. package/src/links-view/layouts/circle.js +7 -0
  276. package/src/links-view/layouts/force.js +76 -0
  277. package/src/links-view/layouts/grid.js +7 -0
  278. package/src/links-view/layouts/hex.js +8 -0
  279. package/src/links-view/layouts/index.js +15 -0
  280. package/src/links-view/layouts/layered.js +29 -0
  281. package/src/links-view/layouts/regular.js +27 -0
  282. package/src/links-view/layouts/spiral.js +10 -0
  283. package/src/links-view/link-view.js +494 -0
  284. package/src/links-view/links-gallery.js +306 -0
  285. package/src/links-view/links-network.js +496 -0
  286. package/src/links-view/lino-network-source.js +122 -0
  287. package/src/links-view/lino-network.js +233 -0
  288. package/src/links-view/lino-to-network.js +252 -0
  289. package/src/links-view/markers.js +192 -0
  290. package/src/links-view/model.js +233 -0
  291. package/src/links-view/network-editor/dom.js +36 -0
  292. package/src/links-view/network-editor/editor.js +202 -0
  293. package/src/links-view/network-editor/model.js +163 -0
  294. package/src/links-view/network-editor/options.js +265 -0
  295. package/src/links-view/network-editor/panels.js +423 -0
  296. package/src/links-view/network-editor/presets.js +76 -0
  297. package/src/links-view/network-editor/provider.js +93 -0
  298. package/src/links-view/network-editor/remap.js +45 -0
  299. package/src/links-view/network-editor/schema.js +224 -0
  300. package/src/links-view/network-editor/share.js +232 -0
  301. package/src/links-view/network-editor/styles.js +19 -0
  302. package/src/links-view/network-editor/url-sync.js +131 -0
  303. package/src/links-view/network-interaction.js +228 -0
  304. package/src/links-view/network-model.js +85 -0
  305. package/src/links-view/network-renderer.js +259 -0
  306. package/src/links-view/network-scene.js +245 -0
  307. package/src/links-view/network-source.js +82 -0
  308. package/src/links-view/network-vocabulary.js +18 -0
  309. package/src/links-view/presentation.js +199 -0
  310. package/src/links-view/render-canvas.js +102 -0
  311. package/src/links-view/render-svg.js +118 -0
  312. package/src/links-view/scene.js +233 -0
  313. package/src/links-view/solver-job.js +106 -0
  314. package/src/links-view/tokens.js +114 -0
  315. package/src/links-view/zoom-pan.js +203 -0
  316. package/src/overlays/catalog.lino +89 -0
  317. package/src/overlays/context-menu.js +110 -0
  318. package/src/overlays/dialog.js +117 -0
  319. package/src/overlays/dom.js +168 -0
  320. package/src/overlays/drawer.js +8 -0
  321. package/src/overlays/index.d.ts +80 -0
  322. package/src/overlays/index.js +25 -0
  323. package/src/overlays/kinds.lino +137 -0
  324. package/src/overlays/list-popover.js +129 -0
  325. package/src/overlays/machines/index.js +71 -0
  326. package/src/overlays/machines/surface.lino +11 -0
  327. package/src/overlays/machines/tabs.lino +7 -0
  328. package/src/overlays/machines/toast.lino +16 -0
  329. package/src/overlays/machines/tooltip.lino +29 -0
  330. package/src/overlays/menu.js +240 -0
  331. package/src/overlays/popover.js +194 -0
  332. package/src/overlays/position.js +84 -0
  333. package/src/overlays/radial-geometry.js +38 -0
  334. package/src/overlays/radial-menu.js +50 -0
  335. package/src/overlays/styles.css +155 -0
  336. package/src/overlays/tabs.js +125 -0
  337. package/src/overlays/toast-queue.js +105 -0
  338. package/src/overlays/toast.js +163 -0
  339. package/src/overlays/tooltip.js +110 -0
  340. package/src/overlays/vocabulary.js +3 -0
  341. package/src/settings/conditions.js +44 -0
  342. package/src/settings/control-for.js +62 -0
  343. package/src/settings/field-control.js +201 -0
  344. package/src/settings/index.d.ts +201 -0
  345. package/src/settings/index.js +3 -0
  346. package/src/settings/messages.js +112 -0
  347. package/src/settings/miniature.js +26 -0
  348. package/src/settings/panel-actions.js +234 -0
  349. package/src/settings/panel-model.js +49 -0
  350. package/src/settings/panel-refresh.js +56 -0
  351. package/src/settings/panel-rows.js +200 -0
  352. package/src/settings/preset-cards.js +43 -0
  353. package/src/settings/saved-looks.js +227 -0
  354. package/src/settings/section-layout.js +95 -0
  355. package/src/settings/section-tabs.js +175 -0
  356. package/src/settings/settings-panel.js +192 -0
  357. package/src/settings/settings.css +178 -0
  358. package/stories/accordion.lino +14 -0
  359. package/stories/alert-dialog.lino +4 -0
  360. package/stories/app-bar.lino +10 -0
  361. package/stories/avatar.lino +7 -0
  362. package/stories/badge.lino +12 -0
  363. package/stories/button.lino +17 -0
  364. package/stories/card.lino +10 -0
  365. package/stories/checkbox.lino +14 -0
  366. package/stories/chip.lino +19 -0
  367. package/stories/color-field.lino +9 -0
  368. package/stories/combobox.lino +10 -0
  369. package/stories/container.lino +11 -0
  370. package/stories/context-menu.lino +15 -0
  371. package/stories/dialog.lino +16 -0
  372. package/stories/drawer.lino +12 -0
  373. package/stories/icon-button.lino +13 -0
  374. package/stories/label.lino +7 -0
  375. package/stories/link-cards.lino +9 -0
  376. package/stories/link.lino +9 -0
  377. package/stories/menu-item.lino +6 -0
  378. package/stories/menu-separator.lino +7 -0
  379. package/stories/menu.lino +30 -0
  380. package/stories/nav-strip.lino +11 -0
  381. package/stories/number-field.lino +16 -0
  382. package/stories/option.lino +10 -0
  383. package/stories/paper.lino +11 -0
  384. package/stories/popover.lino +4 -0
  385. package/stories/pref-switches.lino +4 -0
  386. package/stories/progress.lino +14 -0
  387. package/stories/radial-menu.lino +19 -0
  388. package/stories/radio-group.lino +22 -0
  389. package/stories/radio.lino +10 -0
  390. package/stories/section-nav.lino +9 -0
  391. package/stories/select.lino +16 -0
  392. package/stories/slider.lino +14 -0
  393. package/stories/switch.lino +10 -0
  394. package/stories/tab-panel.lino +7 -0
  395. package/stories/tab.lino +7 -0
  396. package/stories/tabs.lino +25 -0
  397. package/stories/text-area.lino +12 -0
  398. package/stories/text-field.lino +23 -0
  399. package/stories/titled-section.lino +7 -0
  400. package/stories/toast.lino +3 -0
  401. package/stories/toaster.lino +2 -0
  402. package/stories/tooltip.lino +3 -0
@@ -0,0 +1,31 @@
1
+ telegram: theme
2
+ token chat.bg '#dbddbb'
3
+ token chat.bg.second '#6ba587'
4
+ token chat.bg.third '#d5d88d'
5
+ token chat.bg.fourth '#88b884'
6
+ token chat.sidebar '#ffffff'
7
+ token chat.bubble.in '#ffffff'
8
+ token chat.bubble.in.text '#000000'
9
+ token chat.bubble.out '#effdde'
10
+ token chat.bubble.out.text '#000000'
11
+ token chat.bubble.radius 15px
12
+ token chat.bubble.tail 15px
13
+ token chat.bubble.padding.block 0.4rem
14
+ token chat.bubble.padding.inline 0.7rem
15
+ token chat.text '#17212b'
16
+ token chat.column 44rem
17
+ token chat.selection.bg '#164e63'
18
+ token chat.selection.text '#ffffff'
19
+ mode dark
20
+ token chat.bg '#0e1621'
21
+ token chat.bg.second '#0e1621'
22
+ token chat.bg.third '#0e1621'
23
+ token chat.bg.fourth '#0e1621'
24
+ token chat.sidebar '#17212b'
25
+ token chat.bubble.in '#182533'
26
+ token chat.bubble.in.text '#f5f5f5'
27
+ token chat.bubble.out '#2b5278'
28
+ token chat.bubble.out.text '#f5f5f5'
29
+ token chat.text '#f4f6f8'
30
+ token chat.selection.bg '#b9e6fb'
31
+ token chat.selection.text '#102b39'
@@ -0,0 +1,25 @@
1
+ whatsapp: theme
2
+ token chat.bg '#efeae2'
3
+ token chat.sidebar '#ffffff'
4
+ token chat.bubble.in '#ffffff'
5
+ token chat.bubble.in.text '#111b21'
6
+ token chat.bubble.out '#d9fdd3'
7
+ token chat.bubble.out.text '#111b21'
8
+ token chat.bubble.radius 7.5px
9
+ token chat.bubble.tail 11.5px
10
+ token chat.bubble.padding.block 0.35rem
11
+ token chat.bubble.padding.inline 0.6rem
12
+ token chat.text '#17212b'
13
+ token chat.column 44rem
14
+ token chat.selection.bg '#164e63'
15
+ token chat.selection.text '#ffffff'
16
+ mode dark
17
+ token chat.bg '#0b141a'
18
+ token chat.sidebar '#111b21'
19
+ token chat.bubble.in '#202c33'
20
+ token chat.bubble.in.text '#e9edef'
21
+ token chat.bubble.out '#005c4b'
22
+ token chat.bubble.out.text '#e9edef'
23
+ token chat.text '#f4f6f8'
24
+ token chat.selection.bg '#b9e6fb'
25
+ token chat.selection.text '#102b39'
@@ -0,0 +1,57 @@
1
+ function focusMessage(at, event, state, keys) {
2
+ const { messages, viewport, selection } = state;
3
+ const next = Math.max(0, Math.min(messages.length - 1, at));
4
+ state.active = keys[next];
5
+ viewport.setActive(state.active);
6
+ viewport.scrollTo(next);
7
+ viewport.render();
8
+ viewport.row(state.active)?.focus({ preventScroll: true });
9
+ if (event.shiftKey) {
10
+ selection.select(state.active, { range: true, keys });
11
+ viewport.render();
12
+ }
13
+ }
14
+
15
+ /** Keyboard actions never intercept keys from the composer or bubble controls. */
16
+ export function streamKeydown(event, state) {
17
+ const { viewport, messages, selection, root, actions } = state;
18
+ const row = event.target.closest?.('[data-message]');
19
+ if (!row || event.target !== row) {
20
+ return;
21
+ }
22
+ const keys = messages.map((m) => m.id);
23
+ const index = keys.indexOf(row.dataset.message);
24
+ const direction = { ArrowDown: 1, ArrowUp: -1 }[event.key];
25
+ if (direction) {
26
+ event.preventDefault();
27
+ focusMessage(index + direction, event, state, keys);
28
+ } else if (event.key === 'Home' || event.key === 'End') {
29
+ event.preventDefault();
30
+ focusMessage(
31
+ event.key === 'Home' ? 0 : messages.length - 1,
32
+ event,
33
+ state,
34
+ keys
35
+ );
36
+ } else if (
37
+ event.key === 'Enter' ||
38
+ event.key === 'ContextMenu' ||
39
+ (event.key === 'F10' && event.shiftKey)
40
+ ) {
41
+ event.preventDefault();
42
+ actions.open(messages[index], row);
43
+ } else if (event.key === ' ') {
44
+ event.preventDefault();
45
+ selection.select(row.dataset.message, {
46
+ toggle: event.ctrlKey || event.metaKey,
47
+ range: event.shiftKey,
48
+ keys,
49
+ });
50
+ viewport.render();
51
+ } else if (event.key === 'Escape') {
52
+ event.preventDefault();
53
+ selection.clear();
54
+ viewport.render();
55
+ }
56
+ root.setAttribute('aria-label', state.label);
57
+ }
@@ -0,0 +1,159 @@
1
+ function validatePage(page, id, pageSize) {
2
+ if (
3
+ !Array.isArray(page.messages) ||
4
+ page.messages.some((m) => typeof m.id !== 'string') ||
5
+ page.messages.length > pageSize ||
6
+ new Set(page.messages.map((m) => m.id)).size !== page.messages.length
7
+ ) {
8
+ throw new TypeError('Invalid stream page');
9
+ }
10
+ if (id !== undefined && !page.messages.some((m) => m.id === id)) {
11
+ throw new Error(`Message not found: ${id}`);
12
+ }
13
+ }
14
+
15
+ function mergePage(current, page, direction, id, pageSize, ceiling) {
16
+ validatePage(page, id, pageSize);
17
+ const replace = direction === 'around' || !current.messages.length;
18
+ const incoming = new Set(page.messages.map((m) => m.id));
19
+ const kept = current.messages.filter((m) => !incoming.has(m.id));
20
+ let messages = replace
21
+ ? page.messages
22
+ : direction === 'before'
23
+ ? [...page.messages, ...kept]
24
+ : [...kept, ...page.messages];
25
+ let hasOlder =
26
+ replace || direction === 'before' ? page.hasOlder : current.hasOlder;
27
+ let hasNewer =
28
+ replace || direction === 'after' ? page.hasNewer : current.hasNewer;
29
+ if (messages.length > ceiling) {
30
+ if (direction === 'before') {
31
+ messages = messages.slice(0, ceiling);
32
+ hasNewer = true;
33
+ } else {
34
+ messages = messages.slice(-ceiling);
35
+ hasOlder = true;
36
+ }
37
+ }
38
+ return {
39
+ messages,
40
+ hasOlder,
41
+ hasNewer,
42
+ highlighted: id ?? current.highlighted,
43
+ loading: false,
44
+ error: null,
45
+ };
46
+ }
47
+
48
+ /**
49
+ * Bidirectional contiguous history. The source owns ordering and cursors.
50
+ * @typedef {{messages: object[], hasOlder: boolean, hasNewer: boolean,
51
+ * highlighted: string|null, loading: boolean, error: Error|null}} StreamState
52
+ * @typedef {{before?: string, after?: string, around?: string, limit: number,
53
+ * signal: AbortSignal}} StreamQuery
54
+ * @typedef {{load(query: StreamQuery): Promise<{messages: object[], hasOlder: boolean, hasNewer: boolean}>}} StreamSource
55
+ */
56
+
57
+ /**
58
+ * @param {StreamSource} source
59
+ * @param {{pageSize?: number, prefetch?: number, ceiling?: number}} [options]
60
+ * @returns {{loadOlder(): Promise<void>, loadNewer(): Promise<void>, jumpTo(id: string): Promise<void>, state(): StreamState, subscribe(fn: Function): Function, disconnect(): void, prefetch: number}}
61
+ */
62
+ export function createStreamWindow(
63
+ source,
64
+ { pageSize = 50, prefetch = 30, ceiling = 500 } = {}
65
+ ) {
66
+ if (
67
+ ![pageSize, prefetch, ceiling].every(
68
+ (n) => Number.isSafeInteger(n) && n > 0
69
+ ) ||
70
+ ceiling < pageSize
71
+ ) {
72
+ throw new RangeError(
73
+ 'Positive integer limits required; ceiling must fit one page'
74
+ );
75
+ }
76
+ let current = {
77
+ messages: [],
78
+ hasOlder: true,
79
+ hasNewer: false,
80
+ highlighted: null,
81
+ loading: false,
82
+ error: null,
83
+ };
84
+ let generation = 0;
85
+ let pending;
86
+ let abort;
87
+ let disposed = false;
88
+ const listeners = new Set();
89
+ const state = () => ({ ...current, messages: [...current.messages] });
90
+ const notify = () => listeners.forEach((fn) => fn(state()));
91
+
92
+ async function load(direction, id) {
93
+ if (disposed) {
94
+ return;
95
+ }
96
+ if (direction !== 'around' && pending) {
97
+ return pending;
98
+ }
99
+ if (
100
+ direction === 'before' &&
101
+ current.messages.length &&
102
+ !current.hasOlder
103
+ ) {
104
+ return;
105
+ }
106
+ const token = ++generation;
107
+ abort?.abort();
108
+ abort = new AbortController();
109
+ current = { ...current, loading: true, error: null };
110
+ notify();
111
+ const query = { limit: pageSize, signal: abort.signal };
112
+ if (id !== undefined) {
113
+ query.around = id;
114
+ } else if (current.messages.length) {
115
+ query[direction] = (
116
+ direction === 'before' ? current.messages[0] : current.messages.at(-1)
117
+ ).id;
118
+ }
119
+ const task = (async () => {
120
+ try {
121
+ const page = await Promise.resolve().then(() => source.load(query));
122
+ if (token !== generation || disposed) {
123
+ return;
124
+ }
125
+ current = mergePage(current, page, direction, id, pageSize, ceiling);
126
+ } catch (error) {
127
+ if (token !== generation || disposed) {
128
+ return;
129
+ }
130
+ current = { ...current, loading: false, error };
131
+ throw error;
132
+ } finally {
133
+ if (token === generation && !disposed) {
134
+ pending = null;
135
+ notify();
136
+ }
137
+ }
138
+ })();
139
+ pending = task;
140
+ return await task;
141
+ }
142
+ return {
143
+ prefetch,
144
+ state,
145
+ loadOlder: () => load('before'),
146
+ loadNewer: () => load('after'),
147
+ jumpTo: (id) => load('around', id),
148
+ subscribe(fn) {
149
+ listeners.add(fn);
150
+ return () => listeners.delete(fn);
151
+ },
152
+ disconnect() {
153
+ disposed = true;
154
+ generation++;
155
+ abort?.abort();
156
+ listeners.clear();
157
+ },
158
+ };
159
+ }
@@ -0,0 +1,19 @@
1
+ import { defaultVocabulary, loadVocabulary } from '@link-foundation/ui-core';
2
+ export const CHAT_KINDS = Object.freeze([
3
+ 'chat-list',
4
+ 'message-stream',
5
+ 'message-bubble',
6
+ 'day-separator',
7
+ 'composer',
8
+ 'reasoning-trace',
9
+ ]);
10
+ export function chatVocabulary() {
11
+ const extra = loadVocabulary(
12
+ CHAT_KINDS.map(
13
+ (kind) =>
14
+ `${kind}: kind\n property label string\n property record string\n property chat string\n property source string\n property time string\n property disabled boolean\n children none`
15
+ ).join('\n')
16
+ ).kinds;
17
+ const base = defaultVocabulary();
18
+ return { ...base, kinds: new Map([...base.kinds, ...extra]) };
19
+ }
@@ -0,0 +1,160 @@
1
+ /**
2
+ * `accordion`: one disclosure, as a heading with a native button
3
+ * (`aria-expanded`, `aria-controls`) over a labelled `region`. It runs the
4
+ * `disclosure-machine` of the behaviour layer and keeps that machine's
5
+ * events and attributes; focus is the one thing it decides itself, as the
6
+ * APG accordion pattern asks: opening leaves focus on the header, and
7
+ * closing brings focus back only from inside the section (Escape).
8
+ *
9
+ * Enter, Space and a click toggle it. ArrowDown, ArrowUp, Home and End move
10
+ * between the headers of the sibling accordions, which form a group.
11
+ * Every change commits `open` as a `ui-change` event. Only a change after
12
+ * mounting animates (`data-animated`): a section that mounts open has its
13
+ * text at full contrast from the first frame.
14
+ *
15
+ * (shipping: accordion Shipping (open true) (heading-level 2)
16
+ * (details: text 'Two to five days.'))
17
+ */
18
+
19
+ import { createMachine } from '../behavior/parse-machine.js';
20
+ import { DISCLOSURE_MACHINE } from '../behavior/machines/index.js';
21
+ import {
22
+ changesOf,
23
+ commitValue,
24
+ controlOf,
25
+ driveControl,
26
+ flagOf,
27
+ numberOf,
28
+ partId,
29
+ partOf,
30
+ setAttr,
31
+ startControl,
32
+ stopControl,
33
+ updateLabel,
34
+ } from './dom.js';
35
+
36
+ const machine = createMachine(DISCLOSURE_MACHINE);
37
+
38
+ /** The header button a key moves to, among the sibling accordions. */
39
+ function headerFor(key, trigger, host) {
40
+ const headers = [...(host.parentElement?.children ?? [])]
41
+ .filter((child) => child.localName === 'ui-accordion')
42
+ .map((child) => child.querySelector(':scope [data-part="trigger"]'))
43
+ .filter((header) => !header.disabled);
44
+ const at = headers.indexOf(trigger);
45
+ const count = headers.length;
46
+ const index = {
47
+ ArrowDown: (at + 1) % count,
48
+ ArrowUp: (at - 1 + count) % count,
49
+ Home: 0,
50
+ End: count - 1,
51
+ }[key];
52
+ return headers[index];
53
+ }
54
+
55
+ function onHeaderKey(event) {
56
+ const { altKey, ctrlKey, metaKey, shiftKey, currentTarget } = event;
57
+ if (event.defaultPrevented || altKey || ctrlKey || metaKey || shiftKey) {
58
+ return;
59
+ }
60
+ const next = headerFor(
61
+ event.key,
62
+ currentTarget,
63
+ currentTarget.closest('ui-accordion')
64
+ );
65
+ if (next) {
66
+ event.preventDefault();
67
+ next.focus();
68
+ }
69
+ }
70
+
71
+ function render(control) {
72
+ if (control.mounted) {
73
+ setAttr(control.parts.content, 'data-animated', true);
74
+ }
75
+ if (!control.driven) {
76
+ commitValue(control, 'open', control.service.state === 'open');
77
+ }
78
+ }
79
+
80
+ export const ACCORDION_KIND = Object.freeze({
81
+ tag: 'ui-accordion',
82
+ childrenSlot: (node) => node.children[1],
83
+ attributes: { disabled: 'boolean' },
84
+ eventTarget: (node) => node.firstChild.firstChild,
85
+ create(el, ctx) {
86
+ const doc = ctx.document;
87
+ const node = doc.createElement('ui-accordion');
88
+ const triggerId = partId(el.id, 'trigger');
89
+ const contentId = partId(el.id, 'content');
90
+ const heading = partOf(doc, 'div', 'heading', { role: 'heading' });
91
+ const trigger = partOf(doc, 'button', 'trigger', {
92
+ type: 'button',
93
+ id: triggerId,
94
+ 'aria-controls': contentId,
95
+ });
96
+ const label = partOf(doc, 'span', 'label');
97
+ const indicator = partOf(doc, 'span', 'indicator', {
98
+ 'aria-hidden': 'true',
99
+ });
100
+ const content = partOf(doc, 'div', 'content', {
101
+ id: contentId,
102
+ role: 'region',
103
+ 'aria-labelledby': triggerId,
104
+ });
105
+ trigger.appendChild(label);
106
+ trigger.appendChild(indicator);
107
+ heading.appendChild(trigger);
108
+ node.appendChild(heading);
109
+ node.appendChild(content);
110
+ trigger.addEventListener('keydown', onHeaderKey);
111
+ const control = startControl(node, el, ctx, {
112
+ machine,
113
+ parts: { trigger, content },
114
+ target: trigger,
115
+ render,
116
+ });
117
+ control.label = label;
118
+ control.heading = heading;
119
+ control.value = false;
120
+ control.service.use({
121
+ focus(target) {
122
+ if (target === 'trigger' && content.contains(doc.activeElement)) {
123
+ trigger.focus();
124
+ }
125
+ return true;
126
+ },
127
+ });
128
+ return node;
129
+ },
130
+ update(node, el, changed, ctx) {
131
+ const has = changesOf(node, changed);
132
+ const control = controlOf(node);
133
+ const { trigger } = control.parts;
134
+ if (has('label')) {
135
+ updateLabel(control.label, el, ctx);
136
+ }
137
+ if (has('heading-level')) {
138
+ const level = Math.trunc(numberOf(el, 'heading-level', 3));
139
+ setAttr(
140
+ control.heading,
141
+ 'aria-level',
142
+ String(Math.min(6, Math.max(1, level)))
143
+ );
144
+ }
145
+ const disabled = flagOf(el, 'disabled');
146
+ if (has('disabled')) {
147
+ trigger.toggleAttribute('disabled', disabled);
148
+ control.assign({ disabled });
149
+ }
150
+ if (has('open')) {
151
+ const open = flagOf(el, 'open');
152
+ driveControl(control, open ? 'open' : 'close', open, disabled);
153
+ }
154
+ control.mounted = true;
155
+ },
156
+ destroy(node) {
157
+ controlOf(node)?.parts.trigger.removeEventListener('keydown', onHeaderKey);
158
+ stopControl(node);
159
+ },
160
+ });
@@ -0,0 +1,80 @@
1
+ /**
2
+ * `avatar`: a person's picture, or their initials when there is no
3
+ * picture (or it fails to load). The picture is an `<img alt=NAME>`; the
4
+ * initials are `role=img` with the name as `aria-label`, so the name is
5
+ * read once either way. A `source` with an unsafe scheme is never loaded.
6
+ *
7
+ * (me: avatar 'Ada Lovelace' (source 'https://example.com/ada.png'))
8
+ * (you: avatar 'Grace Hopper')
9
+ */
10
+
11
+ import { isUnsafeUrl } from '@link-foundation/ui-dom';
12
+ import { atomOf, changesOf, isLive, partOf, setAttr, setText } from './dom.js';
13
+
14
+ /** The initials of a name: the first letters of its first and last words. */
15
+ export function initialsOf(name) {
16
+ const words = String(name ?? '')
17
+ .trim()
18
+ .split(/[\s\-_.]+/u)
19
+ .filter(Boolean);
20
+ if (words.length === 0) {
21
+ return '';
22
+ }
23
+ const first = [...words[0]][0];
24
+ const last = words.length > 1 ? [...words.at(-1)][0] : '';
25
+ return (first + last).toLocaleUpperCase();
26
+ }
27
+
28
+ /** Show the picture, or the initials when it is missing or broken. */
29
+ function show(node, picture) {
30
+ const [root] = node.children;
31
+ const [image, initials] = root.children;
32
+ const name = node.getAttribute('data-name') ?? '';
33
+ image.toggleAttribute('hidden', !picture);
34
+ initials.toggleAttribute('hidden', picture);
35
+ setAttr(root, 'role', picture ? undefined : 'img');
36
+ setAttr(root, 'aria-label', picture ? undefined : name);
37
+ }
38
+
39
+ export const AVATAR_KIND = Object.freeze({
40
+ tag: 'ui-avatar',
41
+ childrenSlot: null,
42
+ attributes: { size: 'string' },
43
+ create(el, ctx) {
44
+ const doc = ctx.document;
45
+ const node = doc.createElement('ui-avatar');
46
+ const root = partOf(doc, 'span', 'root');
47
+ const image = partOf(doc, 'img', 'image', { alt: '', hidden: '' });
48
+ const initials = partOf(doc, 'span', 'label', { 'aria-hidden': 'true' });
49
+ root.appendChild(image);
50
+ root.appendChild(initials);
51
+ node.appendChild(root);
52
+ if (isLive(ctx)) {
53
+ image.addEventListener('error', () => show(node, false));
54
+ }
55
+ return node;
56
+ },
57
+ update(node, el, changed, ctx) {
58
+ const has = changesOf(node, changed);
59
+ const [image, initials] = node.firstChild.children;
60
+ const name = atomOf(el, 'name') ?? '';
61
+ if (has('name')) {
62
+ node.setAttribute('data-name', name);
63
+ setAttr(image, 'alt', name);
64
+ setText(initials, initialsOf(name));
65
+ if (name === '') {
66
+ ctx.diagnostic('missing-label', 'error', { property: 'name' });
67
+ }
68
+ }
69
+ if (has('name') || has('source')) {
70
+ const src = atomOf(el, 'source');
71
+ const unsafe = src !== undefined && isUnsafeUrl(src);
72
+ if (unsafe) {
73
+ ctx.diagnostic('unsafe-url', 'error', { property: 'source' });
74
+ }
75
+ const picture = src !== undefined && !unsafe;
76
+ setAttr(image, 'src', picture ? src : undefined);
77
+ show(node, picture);
78
+ }
79
+ },
80
+ });
@@ -0,0 +1,48 @@
1
+ /**
2
+ * `badge`: a short status or count shown next to something. The value is
3
+ * visible; the label, when there is one, completes it for assistive
4
+ * technology only ("3" → "3 unread messages"). `tone` is `neutral`
5
+ * (default), `primary` or `error`.
6
+ *
7
+ * (unread: badge 3 (label 'unread messages') (tone primary))
8
+ */
9
+
10
+ import { atomOf, changesOf, partOf, setAttr, setText } from './dom.js';
11
+
12
+ export const BADGE_TONES = Object.freeze(['neutral', 'primary', 'error']);
13
+
14
+ export const BADGE_KIND = Object.freeze({
15
+ tag: 'ui-badge',
16
+ childrenSlot: null,
17
+ attributes: {},
18
+ create(el, ctx) {
19
+ const doc = ctx.document;
20
+ const node = doc.createElement('ui-badge');
21
+ const root = partOf(doc, 'span', 'root');
22
+ root.appendChild(partOf(doc, 'span', 'indicator'));
23
+ root.appendChild(partOf(doc, 'span', 'label'));
24
+ node.appendChild(root);
25
+ return node;
26
+ },
27
+ update(node, el, changed, ctx) {
28
+ const has = changesOf(node, changed);
29
+ const [value, label] = node.firstChild.children;
30
+ if (has('value') || has('label')) {
31
+ const text = atomOf(el, 'value');
32
+ const name = atomOf(el, 'label');
33
+ setText(value, text ?? name);
34
+ setText(
35
+ label,
36
+ text === undefined || name === undefined ? '' : ` ${name}`
37
+ );
38
+ label.toggleAttribute('hidden', text === undefined || name === undefined);
39
+ if (text === undefined && name === undefined) {
40
+ ctx.diagnostic('missing-label', 'warning', { property: 'value' });
41
+ }
42
+ }
43
+ if (has('tone')) {
44
+ const tone = atomOf(el, 'tone');
45
+ setAttr(node, 'tone', BADGE_TONES.includes(tone) ? tone : 'neutral');
46
+ }
47
+ },
48
+ });
@@ -0,0 +1,32 @@
1
+ /** Template data replaces the visual part tree; the native button keeps its semantics. */
2
+ import { resolveTemplate } from '@link-foundation/ui-tokens/themes';
3
+ import { partOf } from './dom.js';
4
+
5
+ export function buttonParts(button, ctx, kind) {
6
+ const template = resolveTemplate(ctx.theme?.(), kind);
7
+ if (!template) {
8
+ return false;
9
+ }
10
+ const doc = ctx.document;
11
+ const append = (part, parent) => {
12
+ const tag =
13
+ part.name === 'icon' ? 'ui-icon' : part.kind === 'box' ? 'div' : 'span';
14
+ const node = partOf(doc, tag, part.name);
15
+ if (part.name === 'icon' || part.name === 'indicator') {
16
+ node.setAttribute('aria-hidden', 'true');
17
+ }
18
+ for (const child of part.children) {
19
+ append(child, node);
20
+ }
21
+ parent.appendChild(node);
22
+ };
23
+ for (const child of template.children) {
24
+ append(child, button);
25
+ }
26
+ if (!button.querySelector('[data-part="icon"]')) {
27
+ button.appendChild(
28
+ partOf(doc, 'ui-icon', 'icon', { hidden: '', 'aria-hidden': 'true' })
29
+ );
30
+ }
31
+ return true;
32
+ }