@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.
- package/CONFIGURATIONS.md +74 -0
- package/ICONS.md +76 -0
- package/LICENSE +24 -0
- package/README.md +1499 -2
- package/bin/lino-network.mjs +71 -0
- package/dist/icons/ATTRIBUTION.md +602 -0
- package/dist/icons/NOTICE.lino +1261 -0
- package/dist/icons/brand.js +31 -0
- package/dist/icons/brand.svg +3 -0
- package/dist/icons/licenses/brand/DISCLAIMER.md +51 -0
- package/dist/icons/licenses/brand/LICENSE.md +30 -0
- package/dist/icons/licenses/lucide/LICENSE +43 -0
- package/dist/icons/licenses/material-symbols/LICENSE +202 -0
- package/dist/icons/licenses/material-symbols/NOTICE +12 -0
- package/dist/icons/licenses/tabler/LICENSE +21 -0
- package/dist/icons/lucide.js +681 -0
- package/dist/icons/lucide.svg +34 -0
- package/dist/icons/material-symbols.js +681 -0
- package/dist/icons/material-symbols.svg +34 -0
- package/dist/icons/own.js +521 -0
- package/dist/icons/own.svg +34 -0
- package/dist/icons/tabler.js +681 -0
- package/dist/icons/tabler.svg +34 -0
- package/dist/network-layout-NOTICE.md +6 -0
- package/dist/network-layout-d3-dispatch-LICENSE.txt +13 -0
- package/dist/network-layout-d3-force-LICENSE.txt +13 -0
- package/dist/network-layout-d3-quadtree-LICENSE.txt +13 -0
- package/dist/network-layout-d3-timer-LICENSE.txt +13 -0
- package/dist/network-layout-dagre-LICENSE.txt +19 -0
- package/dist/network-layout.worker.mjs +2 -0
- package/package.json +246 -4
- package/src/a11y/announce.js +88 -0
- package/src/a11y/bind-machine.js +181 -0
- package/src/a11y/focus.js +169 -0
- package/src/a11y/index.d.ts +89 -0
- package/src/a11y/index.js +19 -0
- package/src/a11y/keys.js +182 -0
- package/src/a11y/roving.js +167 -0
- package/src/a11y/typeahead.js +82 -0
- package/src/behavior/actions.js +235 -0
- package/src/behavior/diagnostics.js +73 -0
- package/src/behavior/dom.d.ts +38 -0
- package/src/behavior/dom.js +420 -0
- package/src/behavior/index.d.ts +211 -0
- package/src/behavior/index.js +29 -0
- package/src/behavior/interpret.js +454 -0
- package/src/behavior/machines/disclosure.lino +46 -0
- package/src/behavior/machines/index.js +91 -0
- package/src/behavior/machines/toggle.lino +25 -0
- package/src/behavior/parse-machine.js +367 -0
- package/src/charts/README.md +78 -0
- package/src/charts/activity-layout.js +350 -0
- package/src/charts/activity-model.js +130 -0
- package/src/charts/activity-validation.js +31 -0
- package/src/charts/chart-model.js +667 -0
- package/src/charts/chart.js +518 -0
- package/src/charts/echarts-adapter.d.ts +23 -0
- package/src/charts/echarts-adapter.js +240 -0
- package/src/charts/element.js +330 -0
- package/src/charts/errors.js +62 -0
- package/src/charts/gauge.js +27 -0
- package/src/charts/index.d.ts +344 -0
- package/src/charts/index.js +59 -0
- package/src/charts/layout.js +542 -0
- package/src/charts/lino.js +158 -0
- package/src/charts/mark-options.js +78 -0
- package/src/charts/read.js +101 -0
- package/src/charts/renderer-features.js +8 -0
- package/src/charts/scales.js +223 -0
- package/src/charts/small-model.js +223 -0
- package/src/charts/small-svg.js +269 -0
- package/src/charts/sparkline.js +27 -0
- package/src/charts/stat-tile.js +37 -0
- package/src/charts/summary.js +193 -0
- package/src/charts/svg-renderer.js +226 -0
- package/src/charts/svg.js +69 -0
- package/src/charts/tag-cloud.js +129 -0
- package/src/charts/tokens.js +171 -0
- package/src/charts/tooltip.js +47 -0
- package/src/charts/values.js +146 -0
- package/src/chat/README.md +142 -0
- package/src/chat/actions.js +75 -0
- package/src/chat/chat-contract.js +95 -0
- package/src/chat/chat-list.js +42 -0
- package/src/chat/chat-model.js +125 -0
- package/src/chat/chat.css +228 -0
- package/src/chat/composer.js +131 -0
- package/src/chat/day-separator.js +12 -0
- package/src/chat/dom.js +33 -0
- package/src/chat/follow.js +49 -0
- package/src/chat/index.d.ts +142 -0
- package/src/chat/index.js +13 -0
- package/src/chat/message-bubble.js +191 -0
- package/src/chat/message-stream.js +331 -0
- package/src/chat/reasoning-trace.js +70 -0
- package/src/chat/selection.js +39 -0
- package/src/chat/skins/bubbles.lino +2 -0
- package/src/chat/skins/cards.lino +4 -0
- package/src/chat/skins/compact.lino +4 -0
- package/src/chat/skins/signal.lino +25 -0
- package/src/chat/skins/t3.lino +25 -0
- package/src/chat/skins/telegram.lino +31 -0
- package/src/chat/skins/whatsapp.lino +25 -0
- package/src/chat/stream-keys.js +57 -0
- package/src/chat/stream-window.js +159 -0
- package/src/chat/vocabulary.js +19 -0
- package/src/controls/accordion.js +160 -0
- package/src/controls/avatar.js +80 -0
- package/src/controls/badge.js +48 -0
- package/src/controls/button-template.js +32 -0
- package/src/controls/button.js +97 -0
- package/src/controls/catalog.lino +84 -0
- package/src/controls/checkbox.js +112 -0
- package/src/controls/chip.js +140 -0
- package/src/controls/choices.js +45 -0
- package/src/controls/color-field.js +217 -0
- package/src/controls/color-popover.js +135 -0
- package/src/controls/color-rgb.js +80 -0
- package/src/controls/color.js +67 -0
- package/src/controls/combobox.js +192 -0
- package/src/controls/dom.js +261 -0
- package/src/controls/icon-button.js +33 -0
- package/src/controls/index.d.ts +163 -0
- package/src/controls/index.js +182 -0
- package/src/controls/kinds-text.js +358 -0
- package/src/controls/kinds.lino +350 -0
- package/src/controls/label.js +52 -0
- package/src/controls/link.js +101 -0
- package/src/controls/listbox.js +144 -0
- package/src/controls/machines/button.lino +20 -0
- package/src/controls/machines/checkbox.lino +17 -0
- package/src/controls/machines/chip.lino +20 -0
- package/src/controls/machines/color-field.lino +23 -0
- package/src/controls/machines/combobox.lino +82 -0
- package/src/controls/machines/icon-button.lino +20 -0
- package/src/controls/machines/index.js +586 -0
- package/src/controls/machines/number-field.lino +71 -0
- package/src/controls/machines/radio-group.lino +17 -0
- package/src/controls/machines/select.lino +122 -0
- package/src/controls/machines/slider.lino +99 -0
- package/src/controls/machines/switch.lino +19 -0
- package/src/controls/machines/text-area.lino +26 -0
- package/src/controls/machines/text-field.lino +26 -0
- package/src/controls/number-field.js +239 -0
- package/src/controls/numeric-keys.js +125 -0
- package/src/controls/option.js +54 -0
- package/src/controls/progress.js +76 -0
- package/src/controls/radio-group.js +234 -0
- package/src/controls/select.js +229 -0
- package/src/controls/slider.js +234 -0
- package/src/controls/stories.js +172 -0
- package/src/controls/styles.css +1060 -0
- package/src/controls/switch.js +95 -0
- package/src/controls/text-area.js +39 -0
- package/src/controls/text-field.js +131 -0
- package/src/controls/vocabulary.js +164 -0
- package/src/data/data.css +95 -0
- package/src/data/index.d.ts +83 -0
- package/src/data/index.js +10 -0
- package/src/data/keyboard.js +189 -0
- package/src/data/list.js +215 -0
- package/src/data/render-data.js +116 -0
- package/src/data/selection-dom.js +39 -0
- package/src/data/selection-model.js +43 -0
- package/src/data/sort-model.js +42 -0
- package/src/data/source.js +45 -0
- package/src/data/table.js +160 -0
- package/src/data/tree-model.js +41 -0
- package/src/data/tree.js +55 -0
- package/src/data/viewport.js +216 -0
- package/src/data/virtual-range.js +92 -0
- package/src/data/vocabulary.js +67 -0
- package/src/diagrams/diagram-model.js +511 -0
- package/src/diagrams/diagram.js +204 -0
- package/src/diagrams/index.d.ts +225 -0
- package/src/diagrams/index.js +48 -0
- package/src/diagrams/layout-dagre.js +164 -0
- package/src/diagrams/layout-plugins.js +131 -0
- package/src/diagrams/mermaid-export.js +232 -0
- package/src/diagrams/mermaid-view.js +229 -0
- package/src/diagrams/svg-diagram.js +215 -0
- package/src/editor/code-editor.js +206 -0
- package/src/editor/documents-model.js +170 -0
- package/src/editor/documents-persistence.js +85 -0
- package/src/editor/editor-engine.js +22 -0
- package/src/editor/editor-ui.js +203 -0
- package/src/editor/editor.css +106 -0
- package/src/editor/engines/codemirror.js +227 -0
- package/src/editor/engines/monaco.js +219 -0
- package/src/editor/index.d.ts +111 -0
- package/src/editor/index.js +14 -0
- package/src/editor/lino-highlight.js +106 -0
- package/src/editor/lino-structure.js +85 -0
- package/src/editor/validate-lino.js +43 -0
- package/src/embed/README.md +161 -0
- package/src/embed/controller.js +223 -0
- package/src/embed/element.js +141 -0
- package/src/embed/index.d.ts +75 -0
- package/src/embed/index.js +9 -0
- package/src/embed/providers/telegram.d.ts +3 -0
- package/src/embed/providers/telegram.js +38 -0
- package/src/embed/providers/vk.d.ts +3 -0
- package/src/embed/providers/vk.js +42 -0
- package/src/embed/providers/x.d.ts +3 -0
- package/src/embed/providers/x.js +31 -0
- package/src/embed/registry.js +35 -0
- package/src/embed/script.js +73 -0
- package/src/embed/view.js +122 -0
- package/src/icons/adapters/lucide.d.ts +15 -0
- package/src/icons/adapters/lucide.js +142 -0
- package/src/icons/adapters/material-symbols.d.ts +13 -0
- package/src/icons/adapters/material-symbols.js +113 -0
- package/src/icons/adapters/shared.d.ts +38 -0
- package/src/icons/adapters/shared.js +157 -0
- package/src/icons/adapters/simple-icons.d.ts +9 -0
- package/src/icons/adapters/simple-icons.js +38 -0
- package/src/icons/adapters/tabler.d.ts +9 -0
- package/src/icons/adapters/tabler.js +86 -0
- package/src/icons/icon-registry.js +215 -0
- package/src/icons/icon.js +356 -0
- package/src/icons/index.d.ts +123 -0
- package/src/icons/index.js +30 -0
- package/src/icons/names.js +51 -0
- package/src/icons/own-icons.js +521 -0
- package/src/icons/presentation.js +55 -0
- package/src/icons/svg.js +136 -0
- package/src/index.d.ts +14 -0
- package/src/index.js +40 -0
- package/src/layout/README.md +102 -0
- package/src/layout/app-shell.js +150 -0
- package/src/layout/catalog.lino +27 -0
- package/src/layout/dock-model.js +576 -0
- package/src/layout/dock-view.js +312 -0
- package/src/layout/dock.js +352 -0
- package/src/layout/dom.js +312 -0
- package/src/layout/grid.js +192 -0
- package/src/layout/index.d.ts +267 -0
- package/src/layout/index.js +60 -0
- package/src/layout/layer-manager.js +120 -0
- package/src/layout/layout.css +760 -0
- package/src/layout/menu.js +141 -0
- package/src/layout/nav-strip.js +174 -0
- package/src/layout/page-links.js +166 -0
- package/src/layout/panel.js +26 -0
- package/src/layout/pref-switches.js +209 -0
- package/src/layout/split-model.js +270 -0
- package/src/layout/split.js +430 -0
- package/src/layout/stack.js +86 -0
- package/src/layout/surfaces.js +119 -0
- package/src/layout/tab-group.js +151 -0
- package/src/layout/tab-strip.js +277 -0
- package/src/layout/vocabulary.js +229 -0
- package/src/layout/window-frame.js +222 -0
- package/src/layout/window.js +146 -0
- package/src/links-view/animator.js +144 -0
- package/src/links-view/configuration-classes.js +150 -0
- package/src/links-view/configuration-model.js +191 -0
- package/src/links-view/configuration-notations.js +230 -0
- package/src/links-view/configurations.d.ts +73 -0
- package/src/links-view/configurations.js +33 -0
- package/src/links-view/create-layout-runner.js +79 -0
- package/src/links-view/doublet-curves.js +239 -0
- package/src/links-view/doublet-layout.js +148 -0
- package/src/links-view/doublet-markers.js +109 -0
- package/src/links-view/doublet-options.js +369 -0
- package/src/links-view/doublet-svg.js +156 -0
- package/src/links-view/doublet.js +230 -0
- package/src/links-view/export.js +146 -0
- package/src/links-view/geometry.js +409 -0
- package/src/links-view/index.d.ts +1029 -0
- package/src/links-view/index.js +140 -0
- package/src/links-view/labels.js +28 -0
- package/src/links-view/layout-worker-entry.mjs +2 -0
- package/src/links-view/layout-worker.js +28 -0
- package/src/links-view/layouts/circle.js +7 -0
- package/src/links-view/layouts/force.js +76 -0
- package/src/links-view/layouts/grid.js +7 -0
- package/src/links-view/layouts/hex.js +8 -0
- package/src/links-view/layouts/index.js +15 -0
- package/src/links-view/layouts/layered.js +29 -0
- package/src/links-view/layouts/regular.js +27 -0
- package/src/links-view/layouts/spiral.js +10 -0
- package/src/links-view/link-view.js +494 -0
- package/src/links-view/links-gallery.js +306 -0
- package/src/links-view/links-network.js +496 -0
- package/src/links-view/lino-network-source.js +122 -0
- package/src/links-view/lino-network.js +233 -0
- package/src/links-view/lino-to-network.js +252 -0
- package/src/links-view/markers.js +192 -0
- package/src/links-view/model.js +233 -0
- package/src/links-view/network-editor/dom.js +36 -0
- package/src/links-view/network-editor/editor.js +202 -0
- package/src/links-view/network-editor/model.js +163 -0
- package/src/links-view/network-editor/options.js +265 -0
- package/src/links-view/network-editor/panels.js +423 -0
- package/src/links-view/network-editor/presets.js +76 -0
- package/src/links-view/network-editor/provider.js +93 -0
- package/src/links-view/network-editor/remap.js +45 -0
- package/src/links-view/network-editor/schema.js +224 -0
- package/src/links-view/network-editor/share.js +232 -0
- package/src/links-view/network-editor/styles.js +19 -0
- package/src/links-view/network-editor/url-sync.js +131 -0
- package/src/links-view/network-interaction.js +228 -0
- package/src/links-view/network-model.js +85 -0
- package/src/links-view/network-renderer.js +259 -0
- package/src/links-view/network-scene.js +245 -0
- package/src/links-view/network-source.js +82 -0
- package/src/links-view/network-vocabulary.js +18 -0
- package/src/links-view/presentation.js +199 -0
- package/src/links-view/render-canvas.js +102 -0
- package/src/links-view/render-svg.js +118 -0
- package/src/links-view/scene.js +233 -0
- package/src/links-view/solver-job.js +106 -0
- package/src/links-view/tokens.js +114 -0
- package/src/links-view/zoom-pan.js +203 -0
- package/src/overlays/catalog.lino +89 -0
- package/src/overlays/context-menu.js +110 -0
- package/src/overlays/dialog.js +117 -0
- package/src/overlays/dom.js +168 -0
- package/src/overlays/drawer.js +8 -0
- package/src/overlays/index.d.ts +80 -0
- package/src/overlays/index.js +25 -0
- package/src/overlays/kinds.lino +137 -0
- package/src/overlays/list-popover.js +129 -0
- package/src/overlays/machines/index.js +71 -0
- package/src/overlays/machines/surface.lino +11 -0
- package/src/overlays/machines/tabs.lino +7 -0
- package/src/overlays/machines/toast.lino +16 -0
- package/src/overlays/machines/tooltip.lino +29 -0
- package/src/overlays/menu.js +240 -0
- package/src/overlays/popover.js +194 -0
- package/src/overlays/position.js +84 -0
- package/src/overlays/radial-geometry.js +38 -0
- package/src/overlays/radial-menu.js +50 -0
- package/src/overlays/styles.css +155 -0
- package/src/overlays/tabs.js +125 -0
- package/src/overlays/toast-queue.js +105 -0
- package/src/overlays/toast.js +163 -0
- package/src/overlays/tooltip.js +110 -0
- package/src/overlays/vocabulary.js +3 -0
- package/src/settings/conditions.js +44 -0
- package/src/settings/control-for.js +62 -0
- package/src/settings/field-control.js +201 -0
- package/src/settings/index.d.ts +201 -0
- package/src/settings/index.js +3 -0
- package/src/settings/messages.js +112 -0
- package/src/settings/miniature.js +26 -0
- package/src/settings/panel-actions.js +234 -0
- package/src/settings/panel-model.js +49 -0
- package/src/settings/panel-refresh.js +56 -0
- package/src/settings/panel-rows.js +200 -0
- package/src/settings/preset-cards.js +43 -0
- package/src/settings/saved-looks.js +227 -0
- package/src/settings/section-layout.js +95 -0
- package/src/settings/section-tabs.js +175 -0
- package/src/settings/settings-panel.js +192 -0
- package/src/settings/settings.css +178 -0
- package/stories/accordion.lino +14 -0
- package/stories/alert-dialog.lino +4 -0
- package/stories/app-bar.lino +10 -0
- package/stories/avatar.lino +7 -0
- package/stories/badge.lino +12 -0
- package/stories/button.lino +17 -0
- package/stories/card.lino +10 -0
- package/stories/checkbox.lino +14 -0
- package/stories/chip.lino +19 -0
- package/stories/color-field.lino +9 -0
- package/stories/combobox.lino +10 -0
- package/stories/container.lino +11 -0
- package/stories/context-menu.lino +15 -0
- package/stories/dialog.lino +16 -0
- package/stories/drawer.lino +12 -0
- package/stories/icon-button.lino +13 -0
- package/stories/label.lino +7 -0
- package/stories/link-cards.lino +9 -0
- package/stories/link.lino +9 -0
- package/stories/menu-item.lino +6 -0
- package/stories/menu-separator.lino +7 -0
- package/stories/menu.lino +30 -0
- package/stories/nav-strip.lino +11 -0
- package/stories/number-field.lino +16 -0
- package/stories/option.lino +10 -0
- package/stories/paper.lino +11 -0
- package/stories/popover.lino +4 -0
- package/stories/pref-switches.lino +4 -0
- package/stories/progress.lino +14 -0
- package/stories/radial-menu.lino +19 -0
- package/stories/radio-group.lino +22 -0
- package/stories/radio.lino +10 -0
- package/stories/section-nav.lino +9 -0
- package/stories/select.lino +16 -0
- package/stories/slider.lino +14 -0
- package/stories/switch.lino +10 -0
- package/stories/tab-panel.lino +7 -0
- package/stories/tab.lino +7 -0
- package/stories/tabs.lino +25 -0
- package/stories/text-area.lino +12 -0
- package/stories/text-field.lino +23 -0
- package/stories/titled-section.lino +7 -0
- package/stories/toast.lino +3 -0
- package/stories/toaster.lino +2 -0
- package/stories/tooltip.lino +3 -0
package/src/icons/svg.js
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SVG text helpers shared by the runtime adapters and the icon build
|
|
3
|
+
* (scripts/build-icons.mjs): split an `<svg>` document into the viewBox and
|
|
4
|
+
* a self-contained body, and turn icon data back into an `<svg>`.
|
|
5
|
+
*
|
|
6
|
+
* The body keeps the presentation attributes of the root (`fill`,
|
|
7
|
+
* `stroke`, …) on a wrapping `<g>`, so it renders the same inside any
|
|
8
|
+
* `<svg viewBox>` the element creates.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** Root attributes that style the drawing and move to the wrapping `<g>`. */
|
|
12
|
+
export const PRESENTATION_ATTRIBUTES = Object.freeze([
|
|
13
|
+
'fill',
|
|
14
|
+
'fill-rule',
|
|
15
|
+
'clip-rule',
|
|
16
|
+
'stroke',
|
|
17
|
+
'stroke-width',
|
|
18
|
+
'stroke-linecap',
|
|
19
|
+
'stroke-linejoin',
|
|
20
|
+
'stroke-miterlimit',
|
|
21
|
+
]);
|
|
22
|
+
|
|
23
|
+
const SVG_NS = 'http://www.w3.org/2000/svg';
|
|
24
|
+
|
|
25
|
+
/** Escape a value for a double-quoted XML attribute. */
|
|
26
|
+
export const escapeAttribute = (value) =>
|
|
27
|
+
String(value)
|
|
28
|
+
.replace(/&/g, '&')
|
|
29
|
+
.replace(/"/g, '"')
|
|
30
|
+
.replace(/</g, '<');
|
|
31
|
+
|
|
32
|
+
/** The end of the start tag that begins at `start` (quotes respected). */
|
|
33
|
+
function tagEnd(text, start) {
|
|
34
|
+
let quote = null;
|
|
35
|
+
for (let i = start; i < text.length; i += 1) {
|
|
36
|
+
const c = text[i];
|
|
37
|
+
if (quote !== null) {
|
|
38
|
+
quote = c === quote ? null : quote;
|
|
39
|
+
} else if (c === '"' || c === "'") {
|
|
40
|
+
quote = c;
|
|
41
|
+
} else if (c === '>') {
|
|
42
|
+
return i;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return -1;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The attributes of a start tag (`<svg a="1" b='2'>` → Map).
|
|
50
|
+
* @param {string} tag
|
|
51
|
+
* @returns {Map<string, string>}
|
|
52
|
+
*/
|
|
53
|
+
export function readAttributes(tag) {
|
|
54
|
+
const attributes = new Map();
|
|
55
|
+
const pattern = /([^\s=/<>"']+)\s*=\s*("([^"]*)"|'([^']*)')/g;
|
|
56
|
+
for (const match of tag.matchAll(pattern)) {
|
|
57
|
+
attributes.set(match[1], match[3] ?? match[4]);
|
|
58
|
+
}
|
|
59
|
+
return attributes;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @typedef {object} SplitSvg
|
|
64
|
+
* @property {string} viewBox
|
|
65
|
+
* @property {string} body the drawing, wrapped in a `<g>` with the root
|
|
66
|
+
* presentation attributes when it has any
|
|
67
|
+
* @property {string} [title] the source's accessible title, when present
|
|
68
|
+
*/
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Split an SVG document into its viewBox and a self-contained body.
|
|
72
|
+
* @param {string} text an `<svg>…</svg>` document
|
|
73
|
+
* @param {{defaults?: Record<string, string>}} [options] presentation
|
|
74
|
+
* attributes the root lacks (Material Symbols fill with the text colour)
|
|
75
|
+
* @returns {SplitSvg}
|
|
76
|
+
*/
|
|
77
|
+
export function splitSvg(text, { defaults = {} } = {}) {
|
|
78
|
+
const start = text.indexOf('<svg');
|
|
79
|
+
const end = start === -1 ? -1 : tagEnd(text, start);
|
|
80
|
+
const close = text.lastIndexOf('</svg>');
|
|
81
|
+
if (end === -1 || close < end) {
|
|
82
|
+
throw new Error('splitSvg: not an <svg> document');
|
|
83
|
+
}
|
|
84
|
+
const root = readAttributes(text.slice(start, end));
|
|
85
|
+
const width = root.get('width') ?? '24';
|
|
86
|
+
const height = root.get('height') ?? '24';
|
|
87
|
+
const viewBox = root.get('viewBox') ?? `0 0 ${width} ${height}`;
|
|
88
|
+
const inner = text.slice(end + 1, close).trim();
|
|
89
|
+
const style = PRESENTATION_ATTRIBUTES.map((name) => [
|
|
90
|
+
name,
|
|
91
|
+
root.get(name) ?? defaults[name],
|
|
92
|
+
]).filter(([, value]) => value !== undefined);
|
|
93
|
+
const body =
|
|
94
|
+
style.length === 0
|
|
95
|
+
? inner
|
|
96
|
+
: `<g ${style.map(([n, v]) => `${n}="${escapeAttribute(v)}"`).join(' ')}>${inner}</g>`;
|
|
97
|
+
const title = /<title(?:\s[^>]*)?>([^<]*)<\/title>/.exec(inner)?.[1];
|
|
98
|
+
const decoded = title?.replace(
|
|
99
|
+
/&(amp|lt|gt|quot|apos);/g,
|
|
100
|
+
(_, entity) =>
|
|
101
|
+
({ amp: '&', lt: '<', gt: '>', quot: '"', apos: "'" })[entity]
|
|
102
|
+
);
|
|
103
|
+
return { viewBox, body, ...(decoded ? { title: decoded } : {}) };
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* An `<svg>` document of icon data, for sprites, downloads and tests.
|
|
108
|
+
* @param {{viewBox: string, body: string}} icon
|
|
109
|
+
* @param {Record<string, string>} [attributes] extra root attributes
|
|
110
|
+
* @returns {string}
|
|
111
|
+
*/
|
|
112
|
+
export function iconToSvg(icon, attributes = {}) {
|
|
113
|
+
const extra = Object.entries(attributes)
|
|
114
|
+
.map(([name, value]) => ` ${name}="${escapeAttribute(value)}"`)
|
|
115
|
+
.join('');
|
|
116
|
+
return `<svg xmlns="${SVG_NS}" viewBox="${escapeAttribute(icon.viewBox)}"${extra}>${icon.body}</svg>`;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* An `<svg>` document of a Lucide-style icon node
|
|
121
|
+
* (`[['path', {d: '…'}], …]`) with the given root attributes.
|
|
122
|
+
* @param {[string, Record<string, string|number>][]} node
|
|
123
|
+
* @param {Record<string, string|number>} root
|
|
124
|
+
* @returns {string}
|
|
125
|
+
*/
|
|
126
|
+
export function iconNodeToSvg(node, root) {
|
|
127
|
+
const attrs = (map) =>
|
|
128
|
+
Object.entries(map)
|
|
129
|
+
.filter(([name]) => name !== 'key')
|
|
130
|
+
.map(([name, value]) => ` ${name}="${escapeAttribute(value)}"`)
|
|
131
|
+
.join('');
|
|
132
|
+
const children = node
|
|
133
|
+
.map(([tag, attributes]) => `<${tag}${attrs(attributes)}/>`)
|
|
134
|
+
.join('');
|
|
135
|
+
return `<svg${attrs(root)}>${children}</svg>`;
|
|
136
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from '@link-foundation/ui-components/behavior';
|
|
2
|
+
export * from '@link-foundation/ui-components/a11y';
|
|
3
|
+
export * from '@link-foundation/ui-components/charts';
|
|
4
|
+
export * from '@link-foundation/ui-components/diagrams';
|
|
5
|
+
export * from '@link-foundation/ui-components/links-view';
|
|
6
|
+
export * from '@link-foundation/ui-components/layout';
|
|
7
|
+
export * from '@link-foundation/ui-components/icons';
|
|
8
|
+
export * from '@link-foundation/ui-components/overlays';
|
|
9
|
+
export * from '@link-foundation/ui-components/controls';
|
|
10
|
+
export * from '@link-foundation/ui-components/data';
|
|
11
|
+
export * from '@link-foundation/ui-components/editor';
|
|
12
|
+
export * from '@link-foundation/ui-components/chat';
|
|
13
|
+
export * from '@link-foundation/ui-components/settings';
|
|
14
|
+
export * from '@link-foundation/ui-components/embed';
|
package/src/index.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@link-foundation/ui-components`: components of the associative UI
|
|
3
|
+
* framework, each in its own folder and also exported on its own:
|
|
4
|
+
*
|
|
5
|
+
* - `./behavior`: behaviour state machines written in Links Notation with a
|
|
6
|
+
* DOM-free interpreter and an actions registry (the ui-dom integration is
|
|
7
|
+
* `./behavior/dom`);
|
|
8
|
+
* - `./a11y`: DOM accessibility helpers;
|
|
9
|
+
* - `./charts`: charts drawn as deterministic SVG (the ECharts adapter is
|
|
10
|
+
* `./charts/echarts`);
|
|
11
|
+
* - `./diagrams`: a diagram written in Links Notation, laid out by Dagre,
|
|
12
|
+
* drawn as accessible SVG or by a lazily loaded Mermaid adapter;
|
|
13
|
+
* - `./layout`: the layout elements rendered by ui-dom (it registers its
|
|
14
|
+
* kinds when imported);
|
|
15
|
+
* - `./icons`: the own CC0-1.0 set, the icon registry and `ui-icon` (the
|
|
16
|
+
* icon set adapters are `./icons/adapters/<set>`);
|
|
17
|
+
* - `./links-view`: `link-view`, one link drawn from links-visuals geometry;
|
|
18
|
+
* - `./data`: measured virtual lists, trees and tables (`./data.css` styles
|
|
19
|
+
* them), plus pure range, selection and sorting models;
|
|
20
|
+
* - `./controls`: the basic controls (button, text field, checkbox, select,
|
|
21
|
+
* ...) rendered by ui-dom, their stories and catalog (`./controls.css`
|
|
22
|
+
* styles them).
|
|
23
|
+
*
|
|
24
|
+
* See README.md.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
export * from './behavior/index.js';
|
|
28
|
+
export * from './a11y/index.js';
|
|
29
|
+
export * from './charts/index.js';
|
|
30
|
+
export * from './diagrams/index.js';
|
|
31
|
+
export * from './layout/index.js';
|
|
32
|
+
export * from './links-view/index.js';
|
|
33
|
+
export * from './icons/index.js';
|
|
34
|
+
export * from './overlays/index.js';
|
|
35
|
+
export * from './controls/index.js';
|
|
36
|
+
export * from './data/index.js';
|
|
37
|
+
export * from './editor/index.js';
|
|
38
|
+
export * from './chat/index.js';
|
|
39
|
+
export * from './settings/index.js';
|
|
40
|
+
export * from './embed/index.js';
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Page navigation and quick preferences
|
|
2
|
+
|
|
3
|
+
Import `@link-foundation/ui-components/layout` and its `layout.css`. Parse with
|
|
4
|
+
`layoutVocabulary()` (combined with other vocabularies as needed). The kinds also
|
|
5
|
+
work through the DOM, React and Vue renderers.
|
|
6
|
+
|
|
7
|
+
```lino
|
|
8
|
+
header: app-bar 'My site'
|
|
9
|
+
pages: nav-strip
|
|
10
|
+
label Pages
|
|
11
|
+
active docs
|
|
12
|
+
wrap-below 600px
|
|
13
|
+
home: nav-link Home
|
|
14
|
+
href /
|
|
15
|
+
docs: nav-link Documentation
|
|
16
|
+
href /docs
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
`nav-strip` renders a native labelled navigation landmark, list and anchors.
|
|
20
|
+
Set `active` to a child ID or its href when the route changes. Only the first
|
|
21
|
+
matching link receives `aria-current="page"`; ordinary Tab order is preserved.
|
|
22
|
+
The overflowing current link is centred without moving page scroll or focus.
|
|
23
|
+
`nav[data-more]` contains logical `start`, `end`, or both, with a 1px tolerance.
|
|
24
|
+
Passive scroll and resize update it. The mask follows those edges in LTR and
|
|
25
|
+
RTL. Override `--ui-nav-fade` (default `2rem`) and `--ui-nav-gap` as tokens.
|
|
26
|
+
`wrap-below` accepts a CSS length in px, rem or em; below it, the strip occupies
|
|
27
|
+
a full row in its app-bar slot.
|
|
28
|
+
|
|
29
|
+
```lino
|
|
30
|
+
sections: section-nav
|
|
31
|
+
label 'On this page'
|
|
32
|
+
back-to-top '#introduction'
|
|
33
|
+
back-label 'Back to top'
|
|
34
|
+
intro-link: nav-link Introduction
|
|
35
|
+
href '#introduction'
|
|
36
|
+
introduction: titled-section Introduction
|
|
37
|
+
kicker Welcome
|
|
38
|
+
level 2
|
|
39
|
+
body: text 'Page content.'
|
|
40
|
+
cards: link-cards
|
|
41
|
+
min 240px
|
|
42
|
+
guide: link-card Guide
|
|
43
|
+
href /guide
|
|
44
|
+
glyph '↗'
|
|
45
|
+
summary 'Start building with Links UI.'
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
`section-nav` shares scrolling and fades, uses `aria-current="location"`, and
|
|
49
|
+
moves keyboard focus to local anchor targets (native IDs or store IDs). Its
|
|
50
|
+
optional back link has a configurable accessible name. `titled-section` renders
|
|
51
|
+
a labelled native section, an optional kicker and a heading (`level` 1–6,
|
|
52
|
+
default 2). `link-cards` uses auto-fill columns, with a minimum of 240px by
|
|
53
|
+
default, constrained to the available width. Each `link-card` contains one
|
|
54
|
+
anchor with one accessible name from its title and summary. `glyph` (also `icon`) is a
|
|
55
|
+
text icon slot, hidden from the accessible name. Links use the controls' URL
|
|
56
|
+
policy and cancelable `ui-navigate` event, including modifier-click semantics.
|
|
57
|
+
Lift on hover and keyboard focus is disabled under reduced motion.
|
|
58
|
+
|
|
59
|
+
## Preferences
|
|
60
|
+
|
|
61
|
+
Use `createPrefSwitches(options)` directly or put a `pref-switches` in an
|
|
62
|
+
`app-bar` and pass `options.layout.preferences` to the renderer:
|
|
63
|
+
|
|
64
|
+
```js
|
|
65
|
+
const { schema } = readSchema(PREF_SWITCHES_SCHEMA);
|
|
66
|
+
const target = bindConfig(config, schema, { target: 'settings' });
|
|
67
|
+
persistLayer(config, 'user', localStorage);
|
|
68
|
+
const preferences = {
|
|
69
|
+
target,
|
|
70
|
+
localizer, // ui-i18n createLocalizer; setLocale is called on locale changes
|
|
71
|
+
languages: [
|
|
72
|
+
{ locale: 'en', label: 'English' },
|
|
73
|
+
{ locale: 'ru', label: 'Русский' },
|
|
74
|
+
],
|
|
75
|
+
scope: document.documentElement,
|
|
76
|
+
message: (key, params) => translatePreferenceLabel(key, params),
|
|
77
|
+
};
|
|
78
|
+
// mountDocument(container, text, { layout: { preferences }, ... });
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
The exported schema defines comfort fields `locale`, `sound.enabled`,
|
|
82
|
+
`motion.mode` (`auto` → `on` → `off`) and `theme.mode`
|
|
83
|
+
(`system` → `light` → `dark`). Merge these fields into an application's larger
|
|
84
|
+
schema and share its binding with the sound adapter; no competing storage is
|
|
85
|
+
created by the switches. The host owns `persistLayer` and stops it at teardown.
|
|
86
|
+
A missing target gives an in-memory preview, useful for component stories.
|
|
87
|
+
|
|
88
|
+
Language labels carry `lang`, and their buttons carry `aria-pressed`. The sound
|
|
89
|
+
button has separate on/off icons and an explicit pressed state. Auto motion
|
|
90
|
+
tracks the system media query live; the scope receives effective `data-motion`
|
|
91
|
+
`on`/`off`. Theme writes effective `data-scheme` and native `color-scheme`.
|
|
92
|
+
`onChange(values)` lets a host forward choices to its renderer/theme boundary
|
|
93
|
+
or animation player. Labels use `message('theme', {current, next})`,
|
|
94
|
+
`message('motion', {current, next})`, and `message('sound', {enabled})`;
|
|
95
|
+
return localized strings, including translated state names. English fallbacks
|
|
96
|
+
include “Theme: system, next light”. `label` and `languageLabel` name groups.
|
|
97
|
+
Config subscriptions reflect external edits. Call `destroy()` to release the
|
|
98
|
+
binding subscription and media listeners when using the factory directly.
|
|
99
|
+
|
|
100
|
+
The browser fixture at `packages/ui-components/e2e/pages/page-layout.html`
|
|
101
|
+
demonstrates wrapping, anchor focus, cards and persistent preferences. Run
|
|
102
|
+
`npx playwright test packages/ui-components/e2e/page-layout.e2e.mjs --workers 1`.
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `app-shell`: the frame of an application whose navigation follows the
|
|
3
|
+
* width of the viewport — a bottom bar on phones, a rail on tablets and a
|
|
4
|
+
* drawer on wide screens.
|
|
5
|
+
*
|
|
6
|
+
* (app: app-shell (label Main) (breakpoints 640 1024)
|
|
7
|
+
* (bottom-bar tabs) (rail rail-nav) (drawer drawer-nav)
|
|
8
|
+
* (tabs: stack ...) (rail-nav: stack ...) (drawer-nav: stack ...)
|
|
9
|
+
* (main: stack ...))
|
|
10
|
+
*
|
|
11
|
+
* `breakpoints` are data: up to the first one (640 by default) the shell
|
|
12
|
+
* shows the `bottom-bar` child, below the second one (1024) the `rail`
|
|
13
|
+
* child, and from it on the `drawer` child. The three slots may name the
|
|
14
|
+
* same child. The shown navigation is a `navigation` landmark; the other
|
|
15
|
+
* navigation children are hidden and every other child is content. The
|
|
16
|
+
* shell writes its mode as the `mode` attribute and sends `shell-mode`
|
|
17
|
+
* (`detail.mode`) when it changes.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { defineKind } from '@link-foundation/ui-dom';
|
|
21
|
+
import {
|
|
22
|
+
atomOf,
|
|
23
|
+
controllerOf,
|
|
24
|
+
dropController,
|
|
25
|
+
emit,
|
|
26
|
+
findController,
|
|
27
|
+
isLive,
|
|
28
|
+
linkId,
|
|
29
|
+
renderedChildren,
|
|
30
|
+
valuesOf,
|
|
31
|
+
watchChildren,
|
|
32
|
+
} from './dom.js';
|
|
33
|
+
import { viewportOf } from './window-frame.js';
|
|
34
|
+
|
|
35
|
+
/** The slots of the shell, from the narrowest viewport to the widest. */
|
|
36
|
+
export const SHELL_MODES = Object.freeze(['bottom-bar', 'rail', 'drawer']);
|
|
37
|
+
|
|
38
|
+
/** The default breakpoints, in CSS pixels. */
|
|
39
|
+
export const SHELL_BREAKPOINTS = Object.freeze([640, 1024]);
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The mode of the shell at a viewport width: `bottom-bar` up to the first
|
|
43
|
+
* breakpoint, `rail` below the second one, `drawer` from it on.
|
|
44
|
+
* @param {number} width
|
|
45
|
+
* @param {readonly number[]} [breakpoints]
|
|
46
|
+
* @returns {'bottom-bar'|'rail'|'drawer'}
|
|
47
|
+
*/
|
|
48
|
+
export function shellMode(width, breakpoints = SHELL_BREAKPOINTS) {
|
|
49
|
+
const [narrow, wide] = breakpoints;
|
|
50
|
+
if (width <= narrow) {
|
|
51
|
+
return 'bottom-bar';
|
|
52
|
+
}
|
|
53
|
+
return width < wide ? 'rail' : 'drawer';
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** The breakpoints of an element: two increasing numbers, else defaults. */
|
|
57
|
+
function breakpointsOf(el, ctx) {
|
|
58
|
+
const values = valuesOf(el, 'breakpoints').map(Number);
|
|
59
|
+
if (values.length === 0) {
|
|
60
|
+
return SHELL_BREAKPOINTS;
|
|
61
|
+
}
|
|
62
|
+
const valid =
|
|
63
|
+
values.length === 2 &&
|
|
64
|
+
values.every((v) => Number.isFinite(v) && v > 0) &&
|
|
65
|
+
values[0] < values[1];
|
|
66
|
+
if (!valid) {
|
|
67
|
+
ctx.diagnostic('invalid-value', 'error', { property: 'breakpoints' });
|
|
68
|
+
return SHELL_BREAKPOINTS;
|
|
69
|
+
}
|
|
70
|
+
return values;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Mark the navigation of a mode and the content of the shell. */
|
|
74
|
+
function assignSlots(node, el, mode) {
|
|
75
|
+
const navs = new Map(
|
|
76
|
+
SHELL_MODES.map((slot) => [slot, atomOf(el, slot)]).filter(
|
|
77
|
+
([, id]) => id !== undefined
|
|
78
|
+
)
|
|
79
|
+
);
|
|
80
|
+
const shown = navs.get(mode);
|
|
81
|
+
const navIds = new Set(navs.values());
|
|
82
|
+
const label = atomOf(el, 'label') ?? 'Main';
|
|
83
|
+
for (const child of renderedChildren(node)) {
|
|
84
|
+
const id = linkId(child);
|
|
85
|
+
if (id === shown) {
|
|
86
|
+
child.setAttribute('data-slot', mode);
|
|
87
|
+
child.setAttribute('role', 'navigation');
|
|
88
|
+
child.setAttribute('aria-label', label);
|
|
89
|
+
child.removeAttribute('hidden');
|
|
90
|
+
} else if (navIds.has(id)) {
|
|
91
|
+
child.setAttribute('data-slot', 'navigation');
|
|
92
|
+
child.removeAttribute('role');
|
|
93
|
+
child.setAttribute('hidden', '');
|
|
94
|
+
} else {
|
|
95
|
+
child.setAttribute('data-slot', 'content');
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function createShell(node, ctx) {
|
|
101
|
+
const win = ctx.document.defaultView;
|
|
102
|
+
const state = { el: null, mode: null };
|
|
103
|
+
|
|
104
|
+
const refresh = () => {
|
|
105
|
+
const width = viewportOf(ctx.document).width;
|
|
106
|
+
const mode = shellMode(width, breakpointsOf(state.el, ctx));
|
|
107
|
+
assignSlots(node, state.el, mode);
|
|
108
|
+
observer.takeRecords();
|
|
109
|
+
if (mode !== state.mode) {
|
|
110
|
+
const first = state.mode === null;
|
|
111
|
+
state.mode = mode;
|
|
112
|
+
node.setAttribute('mode', mode);
|
|
113
|
+
if (!first) {
|
|
114
|
+
emit(node, 'shell-mode', { mode });
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const observer = watchChildren(node, refresh);
|
|
120
|
+
win.addEventListener('resize', refresh);
|
|
121
|
+
return {
|
|
122
|
+
state,
|
|
123
|
+
update(el) {
|
|
124
|
+
state.el = el;
|
|
125
|
+
refresh();
|
|
126
|
+
},
|
|
127
|
+
disconnect() {
|
|
128
|
+
observer.disconnect();
|
|
129
|
+
win.removeEventListener('resize', refresh);
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
defineKind('app-shell', {
|
|
135
|
+
tag: 'ui-app-shell',
|
|
136
|
+
create: (el, ctx) => ctx.document.createElement('ui-app-shell'),
|
|
137
|
+
update(node, el, changed, ctx) {
|
|
138
|
+
if (isLive(ctx)) {
|
|
139
|
+
controllerOf(node, () => createShell(node, ctx)).update(el);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
// Without a viewport the static page shows the widest layout; the
|
|
143
|
+
// slots of the children are marked when they are rendered.
|
|
144
|
+
node.setAttribute('mode', 'drawer');
|
|
145
|
+
},
|
|
146
|
+
destroy: (node) => dropController(node),
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
/** The mode of a rendered shell (for tests and tools). */
|
|
150
|
+
export const appShellMode = (node) => findController(node)?.state.mode ?? null;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
container-catalog: component-entry
|
|
2
|
+
kind container
|
|
3
|
+
story 'packages/ui-components/stories/container.lino'
|
|
4
|
+
paper-catalog: component-entry
|
|
5
|
+
kind paper
|
|
6
|
+
story 'packages/ui-components/stories/paper.lino'
|
|
7
|
+
card-catalog: component-entry
|
|
8
|
+
kind card
|
|
9
|
+
story 'packages/ui-components/stories/card.lino'
|
|
10
|
+
app-bar-catalog: component-entry
|
|
11
|
+
kind app-bar
|
|
12
|
+
story 'packages/ui-components/stories/app-bar.lino'
|
|
13
|
+
nav-strip-catalog: component-entry
|
|
14
|
+
kind nav-strip
|
|
15
|
+
story 'packages/ui-components/stories/nav-strip.lino'
|
|
16
|
+
section-nav-catalog: component-entry
|
|
17
|
+
kind section-nav
|
|
18
|
+
story 'packages/ui-components/stories/section-nav.lino'
|
|
19
|
+
titled-section-catalog: component-entry
|
|
20
|
+
kind titled-section
|
|
21
|
+
story 'packages/ui-components/stories/titled-section.lino'
|
|
22
|
+
link-cards-catalog: component-entry
|
|
23
|
+
kind link-cards
|
|
24
|
+
story 'packages/ui-components/stories/link-cards.lino'
|
|
25
|
+
pref-switches-catalog: component-entry
|
|
26
|
+
kind pref-switches
|
|
27
|
+
story 'packages/ui-components/stories/pref-switches.lino'
|