@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.
- 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
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `label`: the visible name of a form control. `(for ID)` names the
|
|
3
|
+
* control of the store element `ID` (its input, `<label for>`);
|
|
4
|
+
* `(required true)` adds a required marker that assistive technology
|
|
5
|
+
* does not read (the control itself is `required`).
|
|
6
|
+
*
|
|
7
|
+
* (email-label: label 'Email' (for email) (required true))
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
atomOf,
|
|
12
|
+
changesOf,
|
|
13
|
+
flagOf,
|
|
14
|
+
partId,
|
|
15
|
+
partOf,
|
|
16
|
+
setAttr,
|
|
17
|
+
setText,
|
|
18
|
+
} from './dom.js';
|
|
19
|
+
|
|
20
|
+
export const LABEL_KIND = Object.freeze({
|
|
21
|
+
tag: 'ui-label',
|
|
22
|
+
childrenSlot: null,
|
|
23
|
+
attributes: { required: 'boolean' },
|
|
24
|
+
create(el, ctx) {
|
|
25
|
+
const doc = ctx.document;
|
|
26
|
+
const node = doc.createElement('ui-label');
|
|
27
|
+
const label = partOf(doc, 'label', 'label');
|
|
28
|
+
label.appendChild(doc.createElement('span'));
|
|
29
|
+
const indicator = partOf(doc, 'span', 'indicator', {
|
|
30
|
+
'aria-hidden': 'true',
|
|
31
|
+
});
|
|
32
|
+
indicator.appendChild(doc.createTextNode('*'));
|
|
33
|
+
label.appendChild(indicator);
|
|
34
|
+
node.appendChild(label);
|
|
35
|
+
return node;
|
|
36
|
+
},
|
|
37
|
+
update(node, el, changed) {
|
|
38
|
+
const has = changesOf(node, changed);
|
|
39
|
+
const label = node.firstChild;
|
|
40
|
+
const [text, indicator] = label.children;
|
|
41
|
+
if (has('value')) {
|
|
42
|
+
setText(text, atomOf(el, 'value'));
|
|
43
|
+
}
|
|
44
|
+
if (has('for')) {
|
|
45
|
+
const target = atomOf(el, 'for');
|
|
46
|
+
setAttr(label, 'for', target === undefined ? undefined : partId(target));
|
|
47
|
+
}
|
|
48
|
+
if (has('required')) {
|
|
49
|
+
indicator.toggleAttribute('hidden', !flagOf(el, 'required'));
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
});
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `link`: an `<a>` to a URL or to a store element. A plain click
|
|
3
|
+
* dispatches a cancelable `ui-navigate` event `{source, href}`;
|
|
4
|
+
* `mountControls` sends it through the `navigate` action of the actions
|
|
5
|
+
* registry, which rejects `javascript:`, `data:` and `vbscript:` URLs and
|
|
6
|
+
* calls the host's `navigate` (without one the browser follows the
|
|
7
|
+
* link). An unsafe `href` is never written to the DOM (`unsafe-url`).
|
|
8
|
+
*
|
|
9
|
+
* (docs: link 'Read the docs' (href 'https://example.com/docs') (external true))
|
|
10
|
+
* (top: link 'Back to top' (href app))
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { isUnsafeUrl } from '@link-foundation/ui-dom';
|
|
14
|
+
import {
|
|
15
|
+
atomOf,
|
|
16
|
+
changesOf,
|
|
17
|
+
flagOf,
|
|
18
|
+
isLive,
|
|
19
|
+
partOf,
|
|
20
|
+
setAttr,
|
|
21
|
+
setText,
|
|
22
|
+
} from './dom.js';
|
|
23
|
+
|
|
24
|
+
/** Whether an `href` is a URL (not the ID of a store element). */
|
|
25
|
+
export const isUrl = (href) => /[:/#.?]/.test(href);
|
|
26
|
+
|
|
27
|
+
const hrefs = new WeakMap();
|
|
28
|
+
|
|
29
|
+
/** Dispatch `ui-navigate` for a plain primary click; cancel it if handled. */
|
|
30
|
+
function onClick(event) {
|
|
31
|
+
const a = event.currentTarget;
|
|
32
|
+
if (
|
|
33
|
+
event.defaultPrevented ||
|
|
34
|
+
event.button !== 0 ||
|
|
35
|
+
event.ctrlKey ||
|
|
36
|
+
event.metaKey ||
|
|
37
|
+
event.shiftKey ||
|
|
38
|
+
event.altKey
|
|
39
|
+
) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const win = a.ownerDocument.defaultView;
|
|
43
|
+
const go = new win.CustomEvent('ui-navigate', {
|
|
44
|
+
bubbles: true,
|
|
45
|
+
composed: true,
|
|
46
|
+
cancelable: true,
|
|
47
|
+
detail: Object.freeze({
|
|
48
|
+
source: a.parentNode?.getAttribute('data-link-id') ?? null,
|
|
49
|
+
href: hrefs.get(a) ?? '',
|
|
50
|
+
}),
|
|
51
|
+
});
|
|
52
|
+
if (!a.dispatchEvent(go) || !a.hasAttribute('href')) {
|
|
53
|
+
event.preventDefault();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const LINK_KIND = Object.freeze({
|
|
58
|
+
tag: 'ui-link',
|
|
59
|
+
childrenSlot: null,
|
|
60
|
+
attributes: { external: 'boolean' },
|
|
61
|
+
create(el, ctx) {
|
|
62
|
+
const doc = ctx.document;
|
|
63
|
+
const node = doc.createElement('ui-link');
|
|
64
|
+
const a = partOf(doc, 'a', 'root');
|
|
65
|
+
node.appendChild(a);
|
|
66
|
+
if (isLive(ctx)) {
|
|
67
|
+
a.addEventListener('click', onClick);
|
|
68
|
+
}
|
|
69
|
+
return node;
|
|
70
|
+
},
|
|
71
|
+
eventTarget: (node) => node.firstChild,
|
|
72
|
+
update(node, el, changed, ctx) {
|
|
73
|
+
const has = changesOf(node, changed);
|
|
74
|
+
const a = node.firstChild;
|
|
75
|
+
if (has('label')) {
|
|
76
|
+
setText(a, atomOf(el, 'label') ?? atomOf(el, 'href'));
|
|
77
|
+
}
|
|
78
|
+
if (has('href')) {
|
|
79
|
+
const href = atomOf(el, 'href');
|
|
80
|
+
hrefs.set(a, href);
|
|
81
|
+
const unsafe = href !== undefined && isUnsafeUrl(href);
|
|
82
|
+
if (unsafe) {
|
|
83
|
+
ctx.diagnostic('unsafe-url', 'error', { property: 'href' });
|
|
84
|
+
}
|
|
85
|
+
const target =
|
|
86
|
+
href === undefined || unsafe
|
|
87
|
+
? undefined
|
|
88
|
+
: isUrl(href)
|
|
89
|
+
? href
|
|
90
|
+
: `#${href}`;
|
|
91
|
+
setAttr(a, 'href', target);
|
|
92
|
+
setAttr(a, 'aria-disabled', target === undefined ? 'true' : undefined);
|
|
93
|
+
setAttr(a, 'role', target === undefined ? 'link' : undefined);
|
|
94
|
+
}
|
|
95
|
+
if (has('external')) {
|
|
96
|
+
const external = flagOf(el, 'external');
|
|
97
|
+
setAttr(a, 'target', external ? '_blank' : undefined);
|
|
98
|
+
setAttr(a, 'rel', external ? 'noopener noreferrer' : undefined);
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
});
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The popup list of `select` and `combobox`: a `listbox` of `option`
|
|
3
|
+
* children, its active option (`aria-activedescendant` of the input, the
|
|
4
|
+
* focus stays in the input) and the actions both machines share.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { createTypeahead } from '../a11y/typeahead.js';
|
|
8
|
+
import { watchChildren } from '../layout/dom.js';
|
|
9
|
+
import { choiceLabel, choiceValue } from './choices.js';
|
|
10
|
+
import { setAttr } from './dom.js';
|
|
11
|
+
|
|
12
|
+
/** Every option node of a listbox. */
|
|
13
|
+
export const optionsOf = (listbox) =>
|
|
14
|
+
[...listbox.children].filter((n) => n.localName === 'ui-option');
|
|
15
|
+
|
|
16
|
+
/** Whether an option can be activated (shown, enabled). */
|
|
17
|
+
const isAvailable = (option) =>
|
|
18
|
+
!option.hasAttribute('hidden') && !option.hasAttribute('disabled');
|
|
19
|
+
|
|
20
|
+
/** The options the keys move through. */
|
|
21
|
+
export const availableOf = (listbox) => optionsOf(listbox).filter(isAvailable);
|
|
22
|
+
|
|
23
|
+
/** The value and the label of an option node. */
|
|
24
|
+
export const optionValue = (option) => option.getAttribute('data-value');
|
|
25
|
+
export const optionLabel = (option) => option.textContent.trim();
|
|
26
|
+
|
|
27
|
+
/** The option of a value, or `null`. */
|
|
28
|
+
export const optionFor = (listbox, value) =>
|
|
29
|
+
value === null || value === undefined
|
|
30
|
+
? null
|
|
31
|
+
: (optionsOf(listbox).find((o) => optionValue(o) === value) ?? null);
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The listbox actions: `(activate WHICH)` with WHICH one of `selected`,
|
|
35
|
+
* `none`, `first`, `last`, `next`, `previous`; `select-active`,
|
|
36
|
+
* `select-picked` (the option clicked) and `typeahead` (the key typed).
|
|
37
|
+
* @param {{listbox: HTMLElement, picked: HTMLElement|null,
|
|
38
|
+
* typed: string|null, typeahead: object}} list
|
|
39
|
+
*/
|
|
40
|
+
export function listboxActions(list) {
|
|
41
|
+
const pick = (option, meta) => {
|
|
42
|
+
if (option && isAvailable(option)) {
|
|
43
|
+
meta.assign({ value: optionValue(option) });
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const activeOf = (meta) =>
|
|
47
|
+
availableOf(list.listbox).find((o) => o.id === meta.context.active) ?? null;
|
|
48
|
+
return {
|
|
49
|
+
activate: ([which], meta) => {
|
|
50
|
+
const options = availableOf(list.listbox);
|
|
51
|
+
const current = options.indexOf(activeOf(meta));
|
|
52
|
+
const target = {
|
|
53
|
+
selected: () =>
|
|
54
|
+
options.find((o) => optionValue(o) === meta.context.value) ??
|
|
55
|
+
options[0],
|
|
56
|
+
none: () => null,
|
|
57
|
+
first: () => options[0],
|
|
58
|
+
last: () => options.at(-1),
|
|
59
|
+
next: () =>
|
|
60
|
+
options[
|
|
61
|
+
current === -1 ? 0 : Math.min(current + 1, options.length - 1)
|
|
62
|
+
],
|
|
63
|
+
pageNext: () =>
|
|
64
|
+
options[Math.min(Math.max(current, 0) + 10, options.length - 1)],
|
|
65
|
+
pagePrevious: () => options[Math.max(current - 10, 0)],
|
|
66
|
+
previous: () =>
|
|
67
|
+
options[
|
|
68
|
+
current === -1 ? options.length - 1 : Math.max(current - 1, 0)
|
|
69
|
+
],
|
|
70
|
+
}[which]?.();
|
|
71
|
+
meta.assign({ active: target?.id ?? null });
|
|
72
|
+
},
|
|
73
|
+
'select-active': (args, meta) => pick(activeOf(meta), meta),
|
|
74
|
+
'select-picked': (args, meta) => pick(list.picked, meta),
|
|
75
|
+
typeahead: (args, meta) => {
|
|
76
|
+
const options = availableOf(list.listbox);
|
|
77
|
+
const current = options.indexOf(activeOf(meta));
|
|
78
|
+
const index = list.typeahead.handleKey(list.typed ?? '', current);
|
|
79
|
+
if (index !== -1) {
|
|
80
|
+
meta.assign({ active: options[index].id });
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** A listbox state: the clicked option and the typed key of an event. */
|
|
87
|
+
export function createListState(listbox) {
|
|
88
|
+
const list = { listbox, picked: null, typed: null };
|
|
89
|
+
list.typeahead = createTypeahead(() => availableOf(listbox).map(optionLabel));
|
|
90
|
+
return list;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Mark the selected and the active options; keep the active one in view. */
|
|
94
|
+
export function renderOptions(listbox, { value, active }) {
|
|
95
|
+
for (const option of optionsOf(listbox)) {
|
|
96
|
+
setAttr(option, 'aria-selected', String(optionValue(option) === value));
|
|
97
|
+
const on = option.id === active;
|
|
98
|
+
if (on !== option.hasAttribute('data-active')) {
|
|
99
|
+
option.toggleAttribute('data-active', on);
|
|
100
|
+
if (on) {
|
|
101
|
+
option.scrollIntoView?.({ block: 'nearest' });
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Connect a listbox to its control: a click on an option picks it (sent
|
|
109
|
+
* as `pick`), a mousedown keeps the focus in the input, and option changes
|
|
110
|
+
* re-render the control.
|
|
111
|
+
* @returns {() => void} disconnect
|
|
112
|
+
*/
|
|
113
|
+
export function connectListbox(list, control, refresh) {
|
|
114
|
+
const { listbox } = list;
|
|
115
|
+
const onClick = (event) => {
|
|
116
|
+
list.picked = event.target.closest?.('ui-option') ?? null;
|
|
117
|
+
if (
|
|
118
|
+
!list.picked ||
|
|
119
|
+
!listbox.contains(list.picked) ||
|
|
120
|
+
!isAvailable(list.picked)
|
|
121
|
+
) {
|
|
122
|
+
event.stopImmediatePropagation();
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
const keepFocus = (event) => event.preventDefault();
|
|
126
|
+
listbox.addEventListener('click', onClick, true);
|
|
127
|
+
listbox.addEventListener('mousedown', keepFocus);
|
|
128
|
+
const observer = watchChildren(listbox, refresh, [
|
|
129
|
+
'data-value',
|
|
130
|
+
'disabled',
|
|
131
|
+
'data-label',
|
|
132
|
+
]);
|
|
133
|
+
return () => {
|
|
134
|
+
listbox.removeEventListener('click', onClick, true);
|
|
135
|
+
listbox.removeEventListener('mousedown', keepFocus);
|
|
136
|
+
observer.disconnect();
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** The label of a value among the child elements (static rendering). */
|
|
141
|
+
export function labelAmong(children, value) {
|
|
142
|
+
const child = children.find((c) => choiceValue(c) === value);
|
|
143
|
+
return child === undefined ? null : choiceLabel(child);
|
|
144
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
button-machine: machine
|
|
2
|
+
initial idle
|
|
3
|
+
context
|
|
4
|
+
disabled false
|
|
5
|
+
state idle
|
|
6
|
+
on down
|
|
7
|
+
target pressed
|
|
8
|
+
when not-disabled
|
|
9
|
+
state pressed
|
|
10
|
+
on up
|
|
11
|
+
target idle
|
|
12
|
+
on leave
|
|
13
|
+
target idle
|
|
14
|
+
part root
|
|
15
|
+
attr data-state
|
|
16
|
+
state
|
|
17
|
+
on pointerdown down
|
|
18
|
+
on pointerup up
|
|
19
|
+
on pointerleave leave
|
|
20
|
+
on pointercancel leave
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
checkbox-machine: machine
|
|
2
|
+
initial ready
|
|
3
|
+
context
|
|
4
|
+
checked false
|
|
5
|
+
disabled false
|
|
6
|
+
invalid false
|
|
7
|
+
state ready
|
|
8
|
+
on toggle
|
|
9
|
+
do
|
|
10
|
+
toggle checked
|
|
11
|
+
when not-disabled
|
|
12
|
+
part input
|
|
13
|
+
attr aria-invalid
|
|
14
|
+
context invalid
|
|
15
|
+
attr data-state
|
|
16
|
+
context checked
|
|
17
|
+
on change toggle
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
chip-machine: machine
|
|
2
|
+
initial present
|
|
3
|
+
context
|
|
4
|
+
disabled false
|
|
5
|
+
state present
|
|
6
|
+
on remove
|
|
7
|
+
target removed
|
|
8
|
+
when not-disabled
|
|
9
|
+
state removed
|
|
10
|
+
on restore
|
|
11
|
+
target present
|
|
12
|
+
part root
|
|
13
|
+
attr data-state
|
|
14
|
+
state
|
|
15
|
+
part remove
|
|
16
|
+
key Enter remove
|
|
17
|
+
key Space remove
|
|
18
|
+
key Delete remove
|
|
19
|
+
key Backspace remove
|
|
20
|
+
on press remove
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
color-field-machine: machine
|
|
2
|
+
initial idle
|
|
3
|
+
context
|
|
4
|
+
disabled false
|
|
5
|
+
invalid false
|
|
6
|
+
state idle
|
|
7
|
+
on commit
|
|
8
|
+
do read-value
|
|
9
|
+
when not-disabled
|
|
10
|
+
on pick
|
|
11
|
+
do read-picker
|
|
12
|
+
when not-disabled
|
|
13
|
+
on revert
|
|
14
|
+
do restore-value
|
|
15
|
+
when not-disabled
|
|
16
|
+
part input
|
|
17
|
+
attr aria-invalid
|
|
18
|
+
context invalid
|
|
19
|
+
on input commit
|
|
20
|
+
on change commit
|
|
21
|
+
key Escape revert
|
|
22
|
+
part indicator
|
|
23
|
+
on change pick
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
combobox-machine: machine
|
|
2
|
+
initial closed
|
|
3
|
+
context
|
|
4
|
+
disabled false
|
|
5
|
+
readonly false
|
|
6
|
+
invalid false
|
|
7
|
+
action close-list
|
|
8
|
+
activate none
|
|
9
|
+
state closed
|
|
10
|
+
on type
|
|
11
|
+
target open
|
|
12
|
+
do filter
|
|
13
|
+
when editable
|
|
14
|
+
on next
|
|
15
|
+
target open
|
|
16
|
+
do
|
|
17
|
+
filter all
|
|
18
|
+
activate first
|
|
19
|
+
when editable
|
|
20
|
+
on previous
|
|
21
|
+
target open
|
|
22
|
+
do
|
|
23
|
+
filter all
|
|
24
|
+
activate last
|
|
25
|
+
when editable
|
|
26
|
+
on open
|
|
27
|
+
target open
|
|
28
|
+
do
|
|
29
|
+
filter all
|
|
30
|
+
when editable
|
|
31
|
+
on commit
|
|
32
|
+
do read-value
|
|
33
|
+
on close
|
|
34
|
+
do clear-value
|
|
35
|
+
when editable
|
|
36
|
+
state open
|
|
37
|
+
on type
|
|
38
|
+
do filter
|
|
39
|
+
on next
|
|
40
|
+
do
|
|
41
|
+
activate next
|
|
42
|
+
on previous
|
|
43
|
+
do
|
|
44
|
+
activate previous
|
|
45
|
+
on commit
|
|
46
|
+
target closed
|
|
47
|
+
do select-active close-list
|
|
48
|
+
on pick
|
|
49
|
+
target closed
|
|
50
|
+
do select-picked close-list
|
|
51
|
+
on close
|
|
52
|
+
target closed
|
|
53
|
+
do close-list
|
|
54
|
+
on blur
|
|
55
|
+
target closed
|
|
56
|
+
do read-value close-list
|
|
57
|
+
part input
|
|
58
|
+
attr role combobox
|
|
59
|
+
attr aria-autocomplete list
|
|
60
|
+
attr aria-expanded
|
|
61
|
+
in open
|
|
62
|
+
attr aria-activedescendant
|
|
63
|
+
context active
|
|
64
|
+
attr aria-invalid
|
|
65
|
+
context invalid
|
|
66
|
+
attr data-state
|
|
67
|
+
state
|
|
68
|
+
key ArrowDown next
|
|
69
|
+
key ArrowUp previous
|
|
70
|
+
key Alt+ArrowDown open
|
|
71
|
+
key Enter commit
|
|
72
|
+
key Escape close
|
|
73
|
+
on input type
|
|
74
|
+
on focusout blur
|
|
75
|
+
part listbox
|
|
76
|
+
attr role listbox
|
|
77
|
+
attr hidden
|
|
78
|
+
present
|
|
79
|
+
in closed
|
|
80
|
+
attr data-state
|
|
81
|
+
state
|
|
82
|
+
on click pick
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
icon-button-machine: machine
|
|
2
|
+
initial idle
|
|
3
|
+
context
|
|
4
|
+
disabled false
|
|
5
|
+
state idle
|
|
6
|
+
on down
|
|
7
|
+
target pressed
|
|
8
|
+
when not-disabled
|
|
9
|
+
state pressed
|
|
10
|
+
on up
|
|
11
|
+
target idle
|
|
12
|
+
on leave
|
|
13
|
+
target idle
|
|
14
|
+
part root
|
|
15
|
+
attr data-state
|
|
16
|
+
state
|
|
17
|
+
on pointerdown down
|
|
18
|
+
on pointerup up
|
|
19
|
+
on pointerleave leave
|
|
20
|
+
on pointercancel leave
|