@link-foundation/ui-components 0.0.0-stage → 0.1.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,142 @@
1
+ /**
2
+ * Lucide (https://lucide.dev, ISC; icons derived from Feather are also
3
+ * MIT): the icon data comes from the official `lucide` npm package, an
4
+ * optional peer dependency.
5
+ *
6
+ * import { registerIconSet } from '@link-foundation/ui-components';
7
+ * import { createLucideSource } from '@link-foundation/ui-components/icons/adapters/lucide';
8
+ * registerIconSet('lucide', createLucideSource());
9
+ */
10
+
11
+ import { iconNodeToSvg } from '../svg.js';
12
+ import { createAdapterSource, thirdPartyRecord } from './shared.js';
13
+
14
+ const NOTICE = 'https://github.com/lucide-icons/lucide/blob/main/LICENSE';
15
+
16
+ /** @type {Readonly<Record<string, string>>} logical name → Lucide name */
17
+ export const LUCIDE_NAMES = Object.freeze({
18
+ close: 'x',
19
+ menu: 'menu',
20
+ more: 'ellipsis',
21
+ 'chevron-up': 'chevron-up',
22
+ 'chevron-down': 'chevron-down',
23
+ 'chevron-left': 'chevron-left',
24
+ 'chevron-right': 'chevron-right',
25
+ check: 'check',
26
+ plus: 'plus',
27
+ minus: 'minus',
28
+ search: 'search',
29
+ settings: 'settings',
30
+ reset: 'rotate-ccw',
31
+ copy: 'copy',
32
+ paste: 'clipboard',
33
+ send: 'send',
34
+ attach: 'paperclip',
35
+ 'drag-handle': 'grip-vertical',
36
+ 'dock-left': 'panel-left',
37
+ 'dock-right': 'panel-right',
38
+ 'dock-bottom': 'panel-bottom',
39
+ float: 'picture-in-picture-2',
40
+ 'zoom-in': 'zoom-in',
41
+ 'zoom-out': 'zoom-out',
42
+ fit: 'maximize',
43
+ play: 'play',
44
+ pause: 'pause',
45
+ record: 'circle-dot',
46
+ warning: 'triangle-alert',
47
+ error: 'circle-x',
48
+ info: 'info',
49
+ link: 'link',
50
+ });
51
+
52
+ /**
53
+ * The mapped Lucide icons that the Lucide LICENSE lists as derived from
54
+ * Feather (MIT, Cole Bemis), under their current Lucide names
55
+ * (`alert-triangle` is now `triangle-alert`). The icon tests check this
56
+ * list against the LICENSE of the installed package.
57
+ */
58
+ export const FEATHER_DERIVED = Object.freeze(
59
+ new Set([
60
+ 'x',
61
+ 'ellipsis',
62
+ 'chevron-up',
63
+ 'chevron-down',
64
+ 'chevron-left',
65
+ 'chevron-right',
66
+ 'check',
67
+ 'plus',
68
+ 'minus',
69
+ 'search',
70
+ 'clipboard',
71
+ 'panel-left',
72
+ 'zoom-in',
73
+ 'zoom-out',
74
+ 'maximize',
75
+ 'triangle-alert',
76
+ 'circle-x',
77
+ 'info',
78
+ 'link',
79
+ ])
80
+ );
81
+
82
+ /** The root attributes of every Lucide icon (lucide/dist/esm/defaultAttributes.mjs). */
83
+ export const LUCIDE_ATTRIBUTES = Object.freeze({
84
+ xmlns: 'http://www.w3.org/2000/svg',
85
+ width: 24,
86
+ height: 24,
87
+ viewBox: '0 0 24 24',
88
+ fill: 'none',
89
+ stroke: 'currentColor',
90
+ 'stroke-width': 2,
91
+ 'stroke-linecap': 'round',
92
+ 'stroke-linejoin': 'round',
93
+ });
94
+
95
+ /**
96
+ * The asset record of a Lucide icon.
97
+ * @param {string} name a Lucide name
98
+ * @param {{featherDerived?: boolean}} [options]
99
+ */
100
+ export function lucideRecord(
101
+ name,
102
+ { featherDerived = FEATHER_DERIVED.has(name) } = {}
103
+ ) {
104
+ return thirdPartyRecord({
105
+ set: 'lucide',
106
+ name,
107
+ title: 'Lucide',
108
+ license: featherDerived ? 'ISC AND MIT' : 'ISC',
109
+ copyright: featherDerived
110
+ ? 'Lucide Icons and Contributors; Cole Bemis'
111
+ : 'Lucide Icons and Contributors',
112
+ source: `https://lucide.dev/icons/${name}`,
113
+ notice: NOTICE,
114
+ });
115
+ }
116
+
117
+ /**
118
+ * The SVG document of a Lucide icon, built from the icon node the
119
+ * package exports (`lucide/dist/esm/icons/<name>.mjs`).
120
+ * @param {string} name
121
+ */
122
+ export async function loadLucideSvg(name) {
123
+ const module = await import(`lucide/dist/esm/icons/${name}.mjs`);
124
+ return iconNodeToSvg(module.default, LUCIDE_ATTRIBUTES);
125
+ }
126
+
127
+ /** @type {import('./shared.js').IconAdapter} */
128
+ export const LUCIDE = Object.freeze({
129
+ set: 'lucide',
130
+ title: 'Lucide',
131
+ packageName: 'lucide',
132
+ names: LUCIDE_NAMES,
133
+ loadSvg: loadLucideSvg,
134
+ record: (name) => lucideRecord(name),
135
+ licenseFiles: ['LICENSE'],
136
+ });
137
+
138
+ /**
139
+ * @param {import('./shared.js').AdapterOptions} [options]
140
+ */
141
+ export const createLucideSource = (options) =>
142
+ createAdapterSource(LUCIDE, options);
@@ -0,0 +1,13 @@
1
+ import type { AssetRecord } from '../index.js';
2
+ import type { AdapterOptions, AdapterSource, IconAdapter } from './shared.js';
3
+
4
+ export type { AdapterOptions, AdapterSource, IconAdapter } from './shared.js';
5
+ export const MATERIAL_SYMBOLS_NAMES: Readonly<Record<string, string>>;
6
+ /** The NOTICE shipped with the icons (Apache-2.0 section 4). */
7
+ export const MATERIAL_SYMBOLS_NOTICE: string;
8
+ export function materialSymbolsRecord(name: string): AssetRecord;
9
+ export function loadMaterialSymbolsSvg(name: string): Promise<string>;
10
+ export const MATERIAL_SYMBOLS: Readonly<IconAdapter>;
11
+ export function createMaterialSymbolsSource(
12
+ options?: AdapterOptions
13
+ ): AdapterSource;
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Material Symbols (https://fonts.google.com/icons, Apache-2.0): the
3
+ * outlined weight-400 icons of the `@material-symbols/svg-400` npm
4
+ * package, an optional peer dependency. Apache-2.0 asks for the licence
5
+ * text and a notice of the changes to ship with the icons: the icon build
6
+ * writes both to dist/icons/licenses/material-symbols/.
7
+ *
8
+ * import { registerIconSet } from '@link-foundation/ui-components';
9
+ * import { createMaterialSymbolsSource } from '@link-foundation/ui-components/icons/adapters/material-symbols';
10
+ * registerIconSet('material-symbols', createMaterialSymbolsSource());
11
+ */
12
+
13
+ import {
14
+ createAdapterSource,
15
+ readPackageFile,
16
+ thirdPartyRecord,
17
+ } from './shared.js';
18
+
19
+ /** @type {Readonly<Record<string, string>>} logical name → Material name */
20
+ export const MATERIAL_SYMBOLS_NAMES = Object.freeze({
21
+ close: 'close',
22
+ menu: 'menu',
23
+ more: 'more_horiz',
24
+ 'chevron-up': 'keyboard_arrow_up',
25
+ 'chevron-down': 'keyboard_arrow_down',
26
+ 'chevron-left': 'chevron_left',
27
+ 'chevron-right': 'chevron_right',
28
+ check: 'check',
29
+ plus: 'add',
30
+ minus: 'remove',
31
+ search: 'search',
32
+ settings: 'settings',
33
+ reset: 'restart_alt',
34
+ copy: 'content_copy',
35
+ paste: 'content_paste',
36
+ send: 'send',
37
+ attach: 'attach_file',
38
+ 'drag-handle': 'drag_indicator',
39
+ // Material names the action: dock_to_right draws the panel on the left.
40
+ 'dock-left': 'dock_to_right',
41
+ 'dock-right': 'dock_to_left',
42
+ 'dock-bottom': 'dock_to_bottom',
43
+ float: 'picture_in_picture',
44
+ 'zoom-in': 'zoom_in',
45
+ 'zoom-out': 'zoom_out',
46
+ fit: 'fit_screen',
47
+ play: 'play_arrow',
48
+ pause: 'pause',
49
+ record: 'fiber_manual_record',
50
+ warning: 'warning',
51
+ error: 'error',
52
+ info: 'info',
53
+ link: 'link',
54
+ });
55
+
56
+ /**
57
+ * The NOTICE shipped with the Material Symbols icons. Upstream has no
58
+ * NOTICE file; Apache-2.0 section 4 asks to keep the attribution and to
59
+ * state the changes made to the files.
60
+ */
61
+ export const MATERIAL_SYMBOLS_NOTICE = `Material Symbols
62
+ Copyright Google LLC
63
+
64
+ Licensed under the Apache License, Version 2.0 (see LICENSE in this
65
+ folder, or https://www.apache.org/licenses/LICENSE-2.0).
66
+
67
+ Source: https://github.com/google/material-design-icons
68
+ Package: @material-symbols/svg-400 (outlined)
69
+
70
+ Changes made by @link-foundation/ui-components: the SVG files were
71
+ optimised with SVGO, their width and height were removed, and their
72
+ colour was set to currentColor so that they follow the text colour.
73
+ `;
74
+
75
+ /**
76
+ * The asset record of a Material Symbols icon.
77
+ * @param {string} name a Material Symbols name
78
+ */
79
+ export const materialSymbolsRecord = (name) =>
80
+ thirdPartyRecord({
81
+ set: 'material-symbols',
82
+ name,
83
+ title: 'Material Symbols',
84
+ license: 'Apache-2.0',
85
+ copyright: 'Google LLC',
86
+ source: `https://fonts.google.com/icons?selected=Material+Symbols+Outlined:${name}`,
87
+ notice:
88
+ 'https://github.com/google/material-design-icons/blob/master/LICENSE',
89
+ });
90
+
91
+ /** @param {string} name */
92
+ export const loadMaterialSymbolsSvg = (name) =>
93
+ readPackageFile(`@material-symbols/svg-400/outlined/${name}.svg`);
94
+
95
+ /** @type {import('./shared.js').IconAdapter} */
96
+ export const MATERIAL_SYMBOLS = Object.freeze({
97
+ set: 'material-symbols',
98
+ title: 'Material Symbols',
99
+ packageName: '@material-symbols/svg-400',
100
+ names: MATERIAL_SYMBOLS_NAMES,
101
+ loadSvg: loadMaterialSymbolsSvg,
102
+ record: materialSymbolsRecord,
103
+ licenseFiles: ['LICENSE'],
104
+ notices: { NOTICE: MATERIAL_SYMBOLS_NOTICE },
105
+ // Material Symbols paths have no fill: the SVG default is black.
106
+ defaults: { fill: 'currentColor' },
107
+ });
108
+
109
+ /**
110
+ * @param {import('./shared.js').AdapterOptions} [options]
111
+ */
112
+ export const createMaterialSymbolsSource = (options) =>
113
+ createAdapterSource(MATERIAL_SYMBOLS, options);
@@ -0,0 +1,38 @@
1
+ import type { AssetRecord, IconSource } from '../index.js';
2
+
3
+ export interface IconAdapter {
4
+ set: string;
5
+ packageName: string;
6
+ title: string;
7
+ /** Logical name → name in the library. */
8
+ names: Readonly<Record<string, string>>;
9
+ loadSvg(name: string): Promise<string>;
10
+ record(name: string): AssetRecord;
11
+ licenseFiles: string[];
12
+ notices?: Record<string, string>;
13
+ defaults?: Record<string, string>;
14
+ }
15
+
16
+ export interface AdapterOptions {
17
+ /** Replace the loader, for example to read your own copy of the package. */
18
+ load?: (name: string) => Promise<string>;
19
+ /** Extra or replaced logical names. */
20
+ names?: Record<string, string>;
21
+ onDiagnostic?: (diagnostic: {
22
+ code: string;
23
+ set: string;
24
+ name: string;
25
+ message: string;
26
+ }) => void;
27
+ }
28
+
29
+ export type AdapterSource = Readonly<
30
+ IconSource & { set: string; adapter: IconAdapter; names(): string[] }
31
+ >;
32
+
33
+ export function isIconName(name: unknown): boolean;
34
+ export function readPackageFile(specifier: string): Promise<string>;
35
+ export function createAdapterSource(
36
+ adapter: IconAdapter,
37
+ options?: AdapterOptions
38
+ ): AdapterSource;
@@ -0,0 +1,157 @@
1
+ /**
2
+ * What the icon set adapters share: loading a file of an optional peer
3
+ * package, and turning an adapter (a name map, a loader and a record
4
+ * factory) into an icon source for registerIconSet().
5
+ */
6
+
7
+ import { MIRROR_IN_RTL } from '../names.js';
8
+ import { splitSvg } from '../svg.js';
9
+
10
+ /**
11
+ * @typedef {import('../icon-registry.js').AssetRecord} AssetRecord
12
+ * @typedef {import('../icon-registry.js').IconData} IconData
13
+ *
14
+ * @typedef {object} IconAdapter
15
+ * @property {string} set the set name (`lucide`)
16
+ * @property {string} packageName the npm package with the icon data
17
+ * @property {string} title a human name (`Lucide`)
18
+ * @property {Readonly<Record<string, string>>} names logical name →
19
+ * name in the library
20
+ * @property {(name: string) => Promise<string>} loadSvg the SVG document
21
+ * of a library icon, read from the package
22
+ * @property {(name: string) => AssetRecord} record the asset record of a
23
+ * library icon
24
+ * @property {string[]} licenseFiles files of the package to ship with the
25
+ * icons (`LICENSE`)
26
+ * @property {Record<string, string>} [notices] generated texts to ship
27
+ * with the icons (file name → text)
28
+ * @property {Record<string, string>} [defaults] presentation attributes
29
+ * the library leaves to the SVG defaults
30
+ *
31
+ * @typedef {object} AdapterOptions
32
+ * @property {(name: string) => Promise<string>} [load] replace the
33
+ * loader, for example to fetch from your own copy of the package
34
+ * @property {Record<string, string>} [names] extra or replaced logical
35
+ * names
36
+ * @property {(diagnostic: {code: string, set: string, name: string, message: string}) => void} [onDiagnostic]
37
+ */
38
+
39
+ /** Library icon names are plain words: nothing can climb out of the package. */
40
+ export const isIconName = (name) =>
41
+ typeof name === 'string' && /^[a-z0-9][a-z0-9_-]*$/.test(name);
42
+
43
+ /**
44
+ * The text of a file in an npm package, through the module resolver
45
+ * (Node, Deno, Bun, or a browser import map).
46
+ * @param {string} specifier `@tabler/icons/outline/x.svg`
47
+ * @returns {Promise<string>}
48
+ */
49
+ export async function readPackageFile(specifier) {
50
+ const url = import.meta.resolve(specifier);
51
+ if (url.startsWith('file:')) {
52
+ const { readFile } = await import('node:fs/promises');
53
+ return readFile(new globalThis.URL(url), 'utf8');
54
+ }
55
+ const response = await fetch(url);
56
+ if (!response.ok) {
57
+ throw new Error(`${specifier}: HTTP ${response.status}`);
58
+ }
59
+ return response.text();
60
+ }
61
+
62
+ /**
63
+ * The common fields of a third-party icon record.
64
+ * @param {{set: string, name: string, license: string, copyright: string,
65
+ * source: string, notice: string, title: string}} fields
66
+ * @returns {AssetRecord}
67
+ */
68
+ export function thirdPartyRecord({
69
+ set,
70
+ name,
71
+ license,
72
+ copyright,
73
+ source,
74
+ notice,
75
+ title,
76
+ }) {
77
+ return Object.freeze({
78
+ id: `${set}-${name}`,
79
+ kind: 'icon',
80
+ files: [],
81
+ license,
82
+ copyright,
83
+ source,
84
+ notice,
85
+ attribution: 'required',
86
+ attributionText: `${title} icon "${name}", © ${copyright}, ${license}`,
87
+ modified: 'yes',
88
+ });
89
+ }
90
+
91
+ /**
92
+ * An icon source of an adapter. Logical names (`close`) go through the
93
+ * name map; any other library name (`rocket`) is used as is.
94
+ * @param {IconAdapter} adapter
95
+ * @param {AdapterOptions} [options]
96
+ * @returns {import('../icon-registry.js').IconSource & {set: string,
97
+ * adapter: IconAdapter, names: () => string[]}}
98
+ */
99
+ export function createAdapterSource(adapter, options = {}) {
100
+ const load = options.load ?? adapter.loadSvg;
101
+ const names = { ...adapter.names, ...options.names };
102
+ /** @type {Map<string, Promise<{viewBox: string, body: string}|undefined>>} */
103
+ const cache = new Map();
104
+ /** @type {Map<string, AssetRecord>} */
105
+ const used = new Map();
106
+ const libraryName = (name) =>
107
+ Object.hasOwn(names, name) ? names[name] : name;
108
+ const loadIcon = (name) => {
109
+ if (!cache.has(name)) {
110
+ cache.set(
111
+ name,
112
+ Promise.resolve()
113
+ .then(() => load(name))
114
+ .then((text) => splitSvg(text, { defaults: adapter.defaults }))
115
+ .catch((error) => {
116
+ const diagnostic = {
117
+ code: 'missing-icon',
118
+ set: adapter.set,
119
+ name,
120
+ message: `${adapter.set}:${name} could not be loaded: ${error.message}`,
121
+ };
122
+ if (options.onDiagnostic) {
123
+ options.onDiagnostic(diagnostic);
124
+ } else {
125
+ console.warn(diagnostic.message);
126
+ }
127
+ return undefined;
128
+ })
129
+ );
130
+ }
131
+ return cache.get(name);
132
+ };
133
+ return Object.freeze({
134
+ set: adapter.set,
135
+ adapter,
136
+ async resolve(name) {
137
+ const library = libraryName(name);
138
+ if (!isIconName(library)) {
139
+ return undefined;
140
+ }
141
+ const data = await loadIcon(library);
142
+ if (data === undefined) {
143
+ return undefined;
144
+ }
145
+ const record = adapter.record(library);
146
+ used.set(record.id, record);
147
+ return { ...data, mirrorInRtl: MIRROR_IN_RTL.has(name), record };
148
+ },
149
+ records() {
150
+ const mapped = Object.values(names).map((name) => adapter.record(name));
151
+ const all = new Map(mapped.map((record) => [record.id, record]));
152
+ used.forEach((record, id) => all.set(id, record));
153
+ return [...all.values()];
154
+ },
155
+ names: () => Object.keys(names),
156
+ });
157
+ }
@@ -0,0 +1,9 @@
1
+ import type { AssetRecord } from '../index.js';
2
+ import type { AdapterOptions, AdapterSource, IconAdapter } from './shared.js';
3
+ export type { AdapterOptions, AdapterSource, IconAdapter } from './shared.js';
4
+ export const SIMPLE_ICONS_TRADEMARK_NOTICE: string;
5
+ export function simpleIconsRecord(name: string): AssetRecord;
6
+ export const SIMPLE_ICONS: Readonly<IconAdapter>;
7
+ export function createSimpleIconsSource(
8
+ options?: AdapterOptions
9
+ ): AdapterSource;
@@ -0,0 +1,38 @@
1
+ /** Optional Simple Icons adapter. Register with registerIconSet('brand', source). */
2
+ import {
3
+ createAdapterSource,
4
+ readPackageFile,
5
+ thirdPartyRecord,
6
+ } from './shared.js';
7
+
8
+ export const SIMPLE_ICONS_TRADEMARK_NOTICE =
9
+ 'Simple Icons is distributed under CC0-1.0. Brand names and marks are trademarks of their respective owners; CC0 does not grant trademark rights. See the Simple Icons disclaimer and each brand’s guidelines.';
10
+
11
+ export const simpleIconsRecord = (name) => ({
12
+ ...thirdPartyRecord({
13
+ set: 'brand',
14
+ name,
15
+ title: 'Simple Icons',
16
+ license: 'CC0-1.0',
17
+ copyright: 'Simple Icons contributors',
18
+ source: `https://simpleicons.org/?q=${encodeURIComponent(name)}`,
19
+ notice:
20
+ 'https://github.com/simple-icons/simple-icons/blob/develop/DISCLAIMER.md',
21
+ }),
22
+ attributionText: `Simple Icons "${name}" (CC0-1.0). ${SIMPLE_ICONS_TRADEMARK_NOTICE}`,
23
+ });
24
+
25
+ export const SIMPLE_ICONS = Object.freeze({
26
+ set: 'brand',
27
+ title: 'Simple Icons',
28
+ packageName: 'simple-icons',
29
+ names: Object.freeze({ github: 'github' }),
30
+ defaults: { fill: 'currentColor' },
31
+ loadSvg: (name) => readPackageFile(`simple-icons/icons/${name}.svg`),
32
+ record: simpleIconsRecord,
33
+ licenseFiles: ['LICENSE.md', 'DISCLAIMER.md'],
34
+ });
35
+
36
+ /** Missing/withdrawn marks are diagnosed by name; the registry supplies a placeholder. */
37
+ export const createSimpleIconsSource = (options) =>
38
+ createAdapterSource(SIMPLE_ICONS, options);
@@ -0,0 +1,9 @@
1
+ import type { AssetRecord } from '../index.js';
2
+ import type { AdapterOptions, AdapterSource, IconAdapter } from './shared.js';
3
+
4
+ export type { AdapterOptions, AdapterSource, IconAdapter } from './shared.js';
5
+ export const TABLER_NAMES: Readonly<Record<string, string>>;
6
+ export function tablerRecord(name: string): AssetRecord;
7
+ export function loadTablerSvg(name: string): Promise<string>;
8
+ export const TABLER: Readonly<IconAdapter>;
9
+ export function createTablerSource(options?: AdapterOptions): AdapterSource;
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Tabler Icons (https://tabler.io/icons, MIT): the outline icons of the
3
+ * official `@tabler/icons` npm package, an optional peer dependency.
4
+ *
5
+ * import { registerIconSet } from '@link-foundation/ui-components';
6
+ * import { createTablerSource } from '@link-foundation/ui-components/icons/adapters/tabler';
7
+ * registerIconSet('tabler', createTablerSource());
8
+ */
9
+
10
+ import {
11
+ createAdapterSource,
12
+ readPackageFile,
13
+ thirdPartyRecord,
14
+ } from './shared.js';
15
+
16
+ /** @type {Readonly<Record<string, string>>} logical name → Tabler name */
17
+ export const TABLER_NAMES = Object.freeze({
18
+ close: 'x',
19
+ menu: 'menu-2',
20
+ more: 'dots',
21
+ 'chevron-up': 'chevron-up',
22
+ 'chevron-down': 'chevron-down',
23
+ 'chevron-left': 'chevron-left',
24
+ 'chevron-right': 'chevron-right',
25
+ check: 'check',
26
+ plus: 'plus',
27
+ minus: 'minus',
28
+ search: 'search',
29
+ settings: 'settings',
30
+ reset: 'rotate',
31
+ copy: 'copy',
32
+ paste: 'clipboard',
33
+ send: 'send',
34
+ attach: 'paperclip',
35
+ 'drag-handle': 'grip-vertical',
36
+ 'dock-left': 'layout-sidebar',
37
+ 'dock-right': 'layout-sidebar-right',
38
+ 'dock-bottom': 'layout-bottombar',
39
+ float: 'picture-in-picture',
40
+ 'zoom-in': 'zoom-in',
41
+ 'zoom-out': 'zoom-out',
42
+ fit: 'maximize',
43
+ play: 'player-play',
44
+ pause: 'player-pause',
45
+ record: 'player-record',
46
+ warning: 'alert-triangle',
47
+ error: 'circle-x',
48
+ info: 'info-circle',
49
+ link: 'link',
50
+ });
51
+
52
+ /**
53
+ * The asset record of a Tabler icon.
54
+ * @param {string} name a Tabler name
55
+ */
56
+ export const tablerRecord = (name) =>
57
+ thirdPartyRecord({
58
+ set: 'tabler',
59
+ name,
60
+ title: 'Tabler Icons',
61
+ license: 'MIT',
62
+ copyright: 'Paweł Kuna',
63
+ source: `https://tabler.io/icons/icon/${name}`,
64
+ notice: 'https://github.com/tabler/tabler-icons/blob/main/LICENSE',
65
+ });
66
+
67
+ /** @param {string} name */
68
+ export const loadTablerSvg = (name) =>
69
+ readPackageFile(`@tabler/icons/outline/${name}.svg`);
70
+
71
+ /** @type {import('./shared.js').IconAdapter} */
72
+ export const TABLER = Object.freeze({
73
+ set: 'tabler',
74
+ title: 'Tabler Icons',
75
+ packageName: '@tabler/icons',
76
+ names: TABLER_NAMES,
77
+ loadSvg: loadTablerSvg,
78
+ record: tablerRecord,
79
+ licenseFiles: ['LICENSE'],
80
+ });
81
+
82
+ /**
83
+ * @param {import('./shared.js').AdapterOptions} [options]
84
+ */
85
+ export const createTablerSource = (options) =>
86
+ createAdapterSource(TABLER, options);