@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,46 @@
1
+ disclosure-machine: machine
2
+ initial closed
3
+ context
4
+ disabled false
5
+ action focus-content
6
+ focus content
7
+ action restore-focus
8
+ focus trigger
9
+ state closed
10
+ on toggle
11
+ target open
12
+ when not-disabled
13
+ on open
14
+ target open
15
+ when not-disabled
16
+ state open
17
+ entry focus-content
18
+ exit restore-focus
19
+ on toggle
20
+ target closing
21
+ on close
22
+ target closing
23
+ state closing
24
+ after 500ms
25
+ target closed
26
+ on toggle
27
+ target open
28
+ when not-disabled
29
+ on open
30
+ target open
31
+ when not-disabled
32
+ part trigger
33
+ attr aria-expanded
34
+ in open
35
+ attr data-state
36
+ state
37
+ key Enter toggle
38
+ key Space toggle
39
+ on press toggle
40
+ part content
41
+ attr hidden
42
+ present
43
+ in closed
44
+ attr data-state
45
+ state
46
+ key Escape close
@@ -0,0 +1,91 @@
1
+ /**
2
+ * The reference machines as text, so they load without a file system or a
3
+ * bundler. They are byte-equal to the `.lino` files next to this module;
4
+ * tests/behavior/parse-machine.test.js checks that they stay in sync.
5
+ */
6
+
7
+ /** A two-state toggle button (`aria-pressed`). */
8
+ export const TOGGLE_MACHINE = `toggle-machine: machine
9
+ initial off
10
+ context
11
+ pressed false
12
+ disabled false
13
+ action set-pressed
14
+ set pressed true
15
+ action clear-pressed
16
+ set pressed false
17
+ state off
18
+ on toggle
19
+ target on
20
+ do set-pressed
21
+ when not-disabled
22
+ state on
23
+ on toggle
24
+ target off
25
+ do clear-pressed
26
+ when not-disabled
27
+ part root
28
+ attr aria-pressed
29
+ context pressed
30
+ key Enter toggle
31
+ key Space toggle
32
+ on press toggle
33
+ `;
34
+
35
+ /**
36
+ * A disclosure (`aria-expanded`): opening focuses the content, closing
37
+ * restores focus to the trigger and hides the content after 500 ms.
38
+ */
39
+ export const DISCLOSURE_MACHINE = `disclosure-machine: machine
40
+ initial closed
41
+ context
42
+ disabled false
43
+ action focus-content
44
+ focus content
45
+ action restore-focus
46
+ focus trigger
47
+ state closed
48
+ on toggle
49
+ target open
50
+ when not-disabled
51
+ on open
52
+ target open
53
+ when not-disabled
54
+ state open
55
+ entry focus-content
56
+ exit restore-focus
57
+ on toggle
58
+ target closing
59
+ on close
60
+ target closing
61
+ state closing
62
+ after 500ms
63
+ target closed
64
+ on toggle
65
+ target open
66
+ when not-disabled
67
+ on open
68
+ target open
69
+ when not-disabled
70
+ part trigger
71
+ attr aria-expanded
72
+ in open
73
+ attr data-state
74
+ state
75
+ key Enter toggle
76
+ key Space toggle
77
+ on press toggle
78
+ part content
79
+ attr hidden
80
+ present
81
+ in closed
82
+ attr data-state
83
+ state
84
+ key Escape close
85
+ `;
86
+
87
+ /** The reference machines by their element ID. */
88
+ export const REFERENCE_MACHINES = Object.freeze({
89
+ 'toggle-machine': TOGGLE_MACHINE,
90
+ 'disclosure-machine': DISCLOSURE_MACHINE,
91
+ });
@@ -0,0 +1,25 @@
1
+ toggle-machine: machine
2
+ initial off
3
+ context
4
+ pressed false
5
+ disabled false
6
+ action set-pressed
7
+ set pressed true
8
+ action clear-pressed
9
+ set pressed false
10
+ state off
11
+ on toggle
12
+ target on
13
+ do set-pressed
14
+ when not-disabled
15
+ state on
16
+ on toggle
17
+ target off
18
+ do clear-pressed
19
+ when not-disabled
20
+ part root
21
+ attr aria-pressed
22
+ context pressed
23
+ key Enter toggle
24
+ key Space toggle
25
+ on press toggle
@@ -0,0 +1,367 @@
1
+ /**
2
+ * Read a behaviour state machine written in Links Notation into a plain,
3
+ * serialisable machine object. Text is read only by ui-core `parse` (the
4
+ * official `links-notation` parser); this module walks the links it
5
+ * returns and never evaluates any value.
6
+ *
7
+ * ```lino
8
+ * (toggle-machine: machine
9
+ * (initial off)
10
+ * (context (pressed false))
11
+ * (action set-pressed (set pressed true))
12
+ * (state off (on toggle (target on) (do set-pressed) (when not-disabled)))
13
+ * (state on (on toggle (target off) (do (set pressed false))))
14
+ * (part root (attr aria-pressed (context pressed)) (key Enter toggle)))
15
+ * ```
16
+ *
17
+ * States are flat: nested, parallel and history states are future work.
18
+ */
19
+
20
+ import { parse } from '@link-foundation/ui-core';
21
+ import { diagnostic } from './diagnostics.js';
22
+
23
+ /**
24
+ * @typedef {string | RawValue[]} RawValue a ui-core raw value
25
+ *
26
+ * @typedef {object} Action a step of a transition, an entry or an exit
27
+ * @property {string} type the action name (`set`, `toggle`, a machine
28
+ * action or a registry name)
29
+ * @property {RawValue[]} args
30
+ *
31
+ * @typedef {object} Transition
32
+ * @property {string|null} target the next state; `null` keeps the state
33
+ * (an internal transition: actions only, no exit or entry)
34
+ * @property {Action[]} actions the `(do ...)` actions, in order
35
+ * @property {string[]} guards the `(when ...)` guard names; all must pass
36
+ *
37
+ * @typedef {Transition & {delay: number}} DelayedTransition
38
+ *
39
+ * @typedef {object} StateNode
40
+ * @property {Action[]} entry
41
+ * @property {Action[]} exit
42
+ * @property {Record<string, Transition[]>} on transitions by event; the
43
+ * first one whose guards pass is taken
44
+ * @property {DelayedTransition[]} after
45
+ *
46
+ * @typedef {object} PartSpec
47
+ * @property {{name: string, value: RawValue}[]} attrs `(attr NAME VALUE)`
48
+ * @property {{key: string, event: string}[]} keys `(key KEY EVENT)`
49
+ * @property {{event: string, send: string}[]} events `(on EVENT SEND)`:
50
+ * a UI event of the part element (`press`, `focus`, ...) sends a
51
+ * machine event
52
+ *
53
+ * @typedef {object} Machine
54
+ * @property {string|null} id
55
+ * @property {string|null} initial
56
+ * @property {Record<string, unknown>} context the initial context
57
+ * @property {Record<string, Action[]>} actions machine actions:
58
+ * `(action NAME STEP...)`, a name for a list of steps
59
+ * @property {Record<string, StateNode>} states
60
+ * @property {Record<string, PartSpec>} parts
61
+ *
62
+ * @typedef {ReturnType<typeof diagnostic>} Diagnostic
63
+ */
64
+
65
+ /**
66
+ * The value of a context atom: `true`, `false` and decimal numbers are
67
+ * typed, every other atom stays text, and a link stays a list.
68
+ * @param {RawValue} raw
69
+ * @returns {unknown}
70
+ */
71
+ export function toValue(raw) {
72
+ if (Array.isArray(raw)) {
73
+ return raw.map(toValue);
74
+ }
75
+ if (typeof raw !== 'string') {
76
+ return raw;
77
+ }
78
+ if (raw === 'true' || raw === 'false') {
79
+ return raw === 'true';
80
+ }
81
+ const number = raw.trim() === '' ? NaN : Number(raw);
82
+ return Number.isFinite(number) ? number : raw;
83
+ }
84
+
85
+ const UNITS = [
86
+ ['ms', 1],
87
+ ['s', 1000],
88
+ ];
89
+
90
+ /**
91
+ * A delay in milliseconds: `500ms`, `2s` or a number of milliseconds;
92
+ * `NaN` when it is none of these.
93
+ * @param {RawValue} raw
94
+ */
95
+ export function parseDelay(raw) {
96
+ if (typeof raw !== 'string') {
97
+ return NaN;
98
+ }
99
+ for (const [unit, factor] of UNITS) {
100
+ if (raw.endsWith(unit)) {
101
+ const amount = raw.slice(0, -unit.length);
102
+ return amount === '' ? NaN : toDelay(Number(amount) * factor);
103
+ }
104
+ }
105
+ return raw === '' ? NaN : toDelay(Number(raw));
106
+ }
107
+
108
+ const toDelay = (ms) => (Number.isFinite(ms) && ms >= 0 ? ms : NaN);
109
+
110
+ /** Every sublink of a node as `[head, ...values]`, properties first. */
111
+ function entriesOf(node) {
112
+ const entries = (node.properties ?? []).map((p) => [p.name, ...p.values]);
113
+ for (const raw of node.unknown ?? []) {
114
+ if (Array.isArray(raw) && typeof raw[0] === 'string') {
115
+ entries.push(raw);
116
+ }
117
+ }
118
+ return entries;
119
+ }
120
+
121
+ /** Split `[head, ...values]` sublinks of a link (atoms are skipped). */
122
+ const linksOf = (values) =>
123
+ values.filter((v) => Array.isArray(v) && typeof v[0] === 'string');
124
+
125
+ /** Read the actions of a `(do ...)`, `(entry ...)` or `(exit ...)`. */
126
+ function readActions(values, report) {
127
+ const actions = [];
128
+ for (const value of values) {
129
+ if (typeof value === 'string') {
130
+ actions.push({ type: value, args: [] });
131
+ } else if (Array.isArray(value) && typeof value[0] === 'string') {
132
+ actions.push({ type: value[0], args: value.slice(1) });
133
+ } else {
134
+ report('invalid-action', 'error', {});
135
+ }
136
+ }
137
+ return actions;
138
+ }
139
+
140
+ /** Read `(target T)`, `(do ...)` and `(when ...)` of a transition. */
141
+ function readTransition(links, report, at) {
142
+ const transition = { target: null, actions: [], guards: [] };
143
+ for (const [head, ...values] of links) {
144
+ if (head === 'target' && typeof values[0] === 'string') {
145
+ transition.target = values[0];
146
+ } else if (head === 'do') {
147
+ transition.actions.push(...readActions(values, report));
148
+ } else if (head === 'when') {
149
+ transition.guards.push(...values.filter((v) => typeof v === 'string'));
150
+ } else {
151
+ report('unknown-field', 'warning', { ...at, field: head });
152
+ }
153
+ }
154
+ return transition;
155
+ }
156
+
157
+ /** Read `(state NAME (on ...) (entry ...) (exit ...) (after ...))`. */
158
+ function readState(name, values, report) {
159
+ const state = { entry: [], exit: [], on: {}, after: [] };
160
+ const at = { state: name };
161
+ for (const [head, ...rest] of linksOf(values)) {
162
+ if (head === 'entry' || head === 'exit') {
163
+ state[head].push(...readActions(rest, report));
164
+ } else if (head === 'on') {
165
+ const [event, ...links] = rest;
166
+ if (typeof event !== 'string') {
167
+ report('invalid-transition', 'error', at);
168
+ continue;
169
+ }
170
+ const transition = readTransition(linksOf(links), report, at);
171
+ (state.on[event] ??= []).push(transition);
172
+ } else if (head === 'after') {
173
+ const [delay, ...links] = rest;
174
+ const ms = parseDelay(delay);
175
+ if (Number.isNaN(ms)) {
176
+ report('invalid-delay', 'error', { ...at, delay: String(delay) });
177
+ continue;
178
+ }
179
+ state.after.push({
180
+ delay: ms,
181
+ ...readTransition(linksOf(links), report, at),
182
+ });
183
+ } else {
184
+ report('unknown-field', 'warning', { ...at, field: head });
185
+ }
186
+ }
187
+ return state;
188
+ }
189
+
190
+ /** Read `(part NAME (attr ...) (key ...) (on ...))`. */
191
+ function readPart(values, report) {
192
+ const part = { attrs: [], keys: [], events: [] };
193
+ for (const [head, ...rest] of linksOf(values)) {
194
+ const [first, second] = rest;
195
+ if (head === 'attr' && typeof first === 'string' && rest.length === 2) {
196
+ part.attrs.push({ name: first, value: second });
197
+ } else if (
198
+ (head === 'key' || head === 'on') &&
199
+ typeof first === 'string' &&
200
+ typeof second === 'string'
201
+ ) {
202
+ if (head === 'key') {
203
+ part.keys.push({ key: first, event: second });
204
+ } else {
205
+ part.events.push({ event: first, send: second });
206
+ }
207
+ } else {
208
+ report('unknown-field', 'warning', { field: head });
209
+ }
210
+ }
211
+ return part;
212
+ }
213
+
214
+ /** Read `(context (name value) ...)` into an object. */
215
+ function readContext(values, context) {
216
+ for (const link of linksOf(values)) {
217
+ const [name, ...rest] = link;
218
+ context[name] =
219
+ rest.length === 1 ? toValue(rest[0]) : rest.map((v) => toValue(v));
220
+ }
221
+ }
222
+
223
+ /** Report transitions to states that do not exist. */
224
+ function checkTargets(machine, report) {
225
+ for (const [name, state] of Object.entries(machine.states)) {
226
+ const transitions = [...Object.values(state.on).flat(), ...state.after];
227
+ for (const { target } of transitions) {
228
+ if (target !== null && !Object.hasOwn(machine.states, target)) {
229
+ report('unknown-target', 'error', { state: name, target });
230
+ }
231
+ }
232
+ }
233
+ if (machine.initial === null) {
234
+ report('missing-initial', 'error', {});
235
+ } else if (!Object.hasOwn(machine.states, machine.initial)) {
236
+ report('unknown-initial', 'error', { state: machine.initial });
237
+ }
238
+ }
239
+
240
+ /** The fields that declare a named state, action or part. */
241
+ const NAMED = new Set(['state', 'action', 'part']);
242
+
243
+ /** Read `(state NAME ...)`, `(action NAME ...)` or `(part NAME ...)`. */
244
+ function readNamed(machine, head, [name, ...rest], report) {
245
+ if (head === 'state') {
246
+ if (Object.hasOwn(machine.states, name)) {
247
+ report('duplicate-state', 'error', { state: name });
248
+ } else {
249
+ machine.states[name] = readState(name, rest, report);
250
+ }
251
+ } else if (head === 'action') {
252
+ if (Object.hasOwn(machine.actions, name)) {
253
+ report('duplicate-action', 'error', { action: name });
254
+ }
255
+ machine.actions[name] = readActions(rest, report);
256
+ } else {
257
+ machine.parts[name] = readPart(rest, report);
258
+ }
259
+ }
260
+
261
+ /** Read one machine element (a ui-core node or a store element view). */
262
+ function readMachine(node, diagnostics) {
263
+ const id = node.id ?? null;
264
+ const report = (code, severity, at) =>
265
+ diagnostics.push(diagnostic(code, severity, { machine: id, ...at }));
266
+ /** @type {Machine} */
267
+ const machine = {
268
+ id,
269
+ initial: null,
270
+ context: {},
271
+ actions: {},
272
+ states: {},
273
+ parts: {},
274
+ };
275
+ for (const [head, ...values] of entriesOf(node)) {
276
+ if (head === 'initial' && typeof values[0] === 'string') {
277
+ machine.initial = values[0];
278
+ } else if (head === 'context') {
279
+ readContext(values, machine.context);
280
+ } else if (NAMED.has(head) && typeof values[0] === 'string') {
281
+ readNamed(machine, head, values, report);
282
+ } else if (head !== 'note' && head !== 'machine') {
283
+ report('unknown-field', 'warning', { field: head });
284
+ }
285
+ }
286
+ checkTargets(machine, report);
287
+ return machine;
288
+ }
289
+
290
+ /** The candidate nodes of a source: text, a ui-core document or a node. */
291
+ function nodesOf(source, diagnostics, options) {
292
+ if (typeof source === 'string') {
293
+ const document = parse(source, options.parseOptions);
294
+ diagnostics.push(...document.diagnostics);
295
+ return document.roots;
296
+ }
297
+ if (source !== null && typeof source === 'object') {
298
+ return Array.isArray(source.roots) ? source.roots : [source];
299
+ }
300
+ return [];
301
+ }
302
+
303
+ /**
304
+ * Read every `machine` element of a source.
305
+ * @param {string | object} source LiNo text, a ui-core document, or one
306
+ * node (a ui-core node or a ui-store element view of kind `machine`)
307
+ * @param {{parseOptions?: object}} [options]
308
+ * @returns {{machines: Map<string, Machine>, diagnostics: Diagnostic[]}}
309
+ */
310
+ export function parseMachines(source, options = {}) {
311
+ const diagnostics = [];
312
+ const machines = new Map();
313
+ const visit = (node) => {
314
+ if (node?.kind === 'machine') {
315
+ const machine = readMachine(node, diagnostics);
316
+ machines.set(machine.id ?? `_${machines.size}`, machine);
317
+ }
318
+ (node?.children ?? []).forEach(visit);
319
+ };
320
+ nodesOf(source, diagnostics, options).forEach(visit);
321
+ return { machines, diagnostics };
322
+ }
323
+
324
+ /**
325
+ * Read the first `machine` element of a source.
326
+ * @param {string | object} source LiNo text, a ui-core document or node
327
+ * @param {{parseOptions?: object}} [options]
328
+ * @returns {{machine: Machine|null, diagnostics: Diagnostic[]}}
329
+ */
330
+ export function parseMachine(source, options = {}) {
331
+ const { machines, diagnostics } = parseMachines(source, options);
332
+ const [machine = null] = machines.values();
333
+ if (machine === null) {
334
+ diagnostics.push(
335
+ diagnostic('invalid-machine', 'error', {
336
+ reason: 'no element of kind machine',
337
+ })
338
+ );
339
+ }
340
+ return { machine, diagnostics };
341
+ }
342
+
343
+ /** Thrown by `createMachine` for a machine with errors. */
344
+ export class MachineError extends Error {
345
+ /** @param {Diagnostic[]} diagnostics */
346
+ constructor(diagnostics) {
347
+ super(diagnostics.map((d) => d.message).join('; '));
348
+ this.name = 'MachineError';
349
+ this.diagnostics = diagnostics;
350
+ }
351
+ }
352
+
353
+ /**
354
+ * A machine from LiNo text or a node; throws a `MachineError` listing the
355
+ * error diagnostics when there are any (warnings are ignored).
356
+ * @param {string | object} source
357
+ * @param {{parseOptions?: object}} [options]
358
+ * @returns {Machine}
359
+ */
360
+ export function createMachine(source, options) {
361
+ const { machine, diagnostics } = parseMachine(source, options);
362
+ const errors = diagnostics.filter((d) => d.severity === 'error');
363
+ if (errors.length > 0) {
364
+ throw new MachineError(errors);
365
+ }
366
+ return machine;
367
+ }
@@ -0,0 +1,78 @@
1
+ # Activity charts
2
+
3
+ Serve `packages/ui-components/examples/activity-charts.html` with
4
+ `node scripts/serve-static.mjs` from the repository root. The gallery reads
5
+ [activity-charts.lino](../../examples/activity-charts.lino); data fetching and
6
+ consumer text stay with the application.
7
+
8
+ All options round-trip through `parseChart` / `chartToLino`. Object properties
9
+ use camelCase; LiNo uses kebab-case. Assign objects to `uiChart.spec`. The
10
+ `tooltip.content` callback stays in memory; serialization writes only its layer.
11
+
12
+ | Object option | LiNo | Behavior |
13
+ | ------------------------------------------- | -------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
14
+ | `encoding.y.scale: {type: 'log', base: 10}` | `scale` with `type log`, `base 10` under the field | Positive powers are ticks. Nonpositive values clamp to the positive domain minimum; `layoutChart().diagnostics` and the element's `chart-diagnostic` event report each row. Original values remain in the table and tooltip. |
15
+ | `cornerRadius: 4` | `corner-radius 4` | Round the two corners at the value end of vertical or horizontal bars, including negative values. |
16
+ | `labels: 'peaks'` or `'last'` | `labels peaks` or `labels last` | Label interior local maxima or the final point of each Cartesian series. |
17
+ | `emphasis: 'favourite'` | `emphasis favourite` | Values `true`, `1`, `'true'`, `'1'` add a star and accessible emphasis text. |
18
+ | `topN: 5` | `top-n 5` | Composition retains five largest categories and aggregates the remainder as muted Other, last. Shares use the total including Other. |
19
+ | `weekStart: 1` | `week-start 1` | Calendar weekday origin, 0 Sunday through 6 Saturday; default Sunday. |
20
+ | `thresholds: [1,3,5,7]` | `thresholds 1 3 5 7` | Four increasing boundaries produce five calendar levels; omitted boundaries use data quantiles. |
21
+ | `ongoingEnd: '2026-01-01'` | `ongoing-end 2026-01-01` | Timeline snapshot date for absent or `ongoing` ends. Default is January 1 of the year after the latest supplied date, keeping rendering deterministic. |
22
+
23
+ A calendar encodes `x` as a temporal date and `y` as a quantitative value. It
24
+ lays out supplied days in UTC week columns and weekday rows, with month labels,
25
+ Mon/Wed/Fri labels and a Less–More legend. A full year such as 2025 spans 53
26
+ columns (alignment can require 54 for a leap year). The scroll region opens at
27
+ the newest week. Up/Down move one day, Left/Right one week when that day exists;
28
+ Home/End reach the first/last supplied day. The table retains every supplied day.
29
+
30
+ A range encodes temporal `x` (start), temporal `x2` (end), nominal `y` (row name)
31
+ and optional `color` (category). End fields can be omitted or contain `ongoing`.
32
+ Ends before starts are rejected. Solid, hatched and dotted patterns cycle with
33
+ categories in both bars and legend. Tab focuses bars; arrows and Home/End
34
+ navigate and announce rows. A composition uses quantitative `theta` and nominal
35
+ `color`, aggregates repeated categories and draws one horizontal 100% bar with a
36
+ name/percentage legend. Tables retain original rows rather than aggregated ones.
37
+
38
+ ```js
39
+ chart.spec = {
40
+ ...spec,
41
+ tooltip: {
42
+ layer: 'top',
43
+ content: (datum) => ({
44
+ title: datum.name,
45
+ value: datum.count,
46
+ rows: [['Source', 'Snapshot']],
47
+ }),
48
+ },
49
+ };
50
+ ```
51
+
52
+ Top tooltips use the shared `positionFloating` helper and a manual popover,
53
+ escaping `overflow` and `clip-path` ancestors. They anchor to the pointer or the
54
+ keyboard mark's top centre, and prefer the left side in the rightmost 40% of
55
+ the plot. Viewport collision handling still applies. Escape, blur, rerender and
56
+ disconnection dismiss the tooltip and release positioning listeners. Content is
57
+ rendered as text, including callback values. `layer: 'inline'` retains the inline
58
+ layer. Existing charts without tooltip configuration retain plain text tooltips.
59
+
60
+ A `tag-cloud` has `label`, `min-size` (default 12), `max-size` (default 36) and
61
+ `items` containing `item NAME` with optional `count`, `color` and `emphasis true`.
62
+ Object items use `{name, count, color, emphasis}`. Sizes interpolate with
63
+ `log(1 + count)` relative to the largest count; missing/zero counts use the
64
+ minimum. DOM output is a semantic list with counts in accessible names and stars
65
+ for emphasized items. SVG export keeps a title for each item.
66
+
67
+ A stat tile accepts `notation compact`, `compact-threshold 10000`, `hint TEXT`
68
+ and `footnote` with `label` and `href`. Object options are `notation`,
69
+ `compactThreshold`, `hint`, `footnote: {label, href}`. Compact formatting starts
70
+ at the absolute threshold using English short notation, so 123456 becomes 123K;
71
+ the exact value stays in the SVG title, accessible name and table. The footnote
72
+ is a real keyboard-focusable link. HTTP(S), mailto, root-relative and fragment
73
+ links are accepted.
74
+
75
+ These extensions use SVG even when `renderer: 'echarts'` is requested, preserving
76
+ the same geometry, tooltips and keyboard behavior. The standalone ECharts adapter
77
+ rejects extended specs with an explicit error; original chart specs keep their
78
+ existing optional ECharts renderer.