@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,122 @@
|
|
|
1
|
+
select-machine: machine
|
|
2
|
+
initial closed
|
|
3
|
+
context
|
|
4
|
+
disabled false
|
|
5
|
+
invalid false
|
|
6
|
+
action open-list
|
|
7
|
+
activate selected
|
|
8
|
+
action close-list
|
|
9
|
+
activate none
|
|
10
|
+
state closed
|
|
11
|
+
on toggle
|
|
12
|
+
target open
|
|
13
|
+
do open-list
|
|
14
|
+
when not-disabled
|
|
15
|
+
on open
|
|
16
|
+
target open
|
|
17
|
+
do open-list
|
|
18
|
+
when not-disabled
|
|
19
|
+
on next
|
|
20
|
+
target open
|
|
21
|
+
do open-list
|
|
22
|
+
when not-disabled
|
|
23
|
+
on previous
|
|
24
|
+
target open
|
|
25
|
+
do open-list
|
|
26
|
+
when not-disabled
|
|
27
|
+
on first
|
|
28
|
+
target open
|
|
29
|
+
do open-list
|
|
30
|
+
activate first
|
|
31
|
+
when not-disabled
|
|
32
|
+
on last
|
|
33
|
+
target open
|
|
34
|
+
do open-list
|
|
35
|
+
activate last
|
|
36
|
+
when not-disabled
|
|
37
|
+
on page-next
|
|
38
|
+
target open
|
|
39
|
+
do open-list
|
|
40
|
+
activate pageNext
|
|
41
|
+
when not-disabled
|
|
42
|
+
on page-previous
|
|
43
|
+
target open
|
|
44
|
+
do open-list
|
|
45
|
+
activate pagePrevious
|
|
46
|
+
when not-disabled
|
|
47
|
+
on commit
|
|
48
|
+
target open
|
|
49
|
+
do open-list
|
|
50
|
+
when not-disabled
|
|
51
|
+
on typeahead
|
|
52
|
+
target open
|
|
53
|
+
do open-list typeahead
|
|
54
|
+
when not-disabled
|
|
55
|
+
state open
|
|
56
|
+
on toggle
|
|
57
|
+
target closed
|
|
58
|
+
do close-list
|
|
59
|
+
on close
|
|
60
|
+
target closed
|
|
61
|
+
do close-list
|
|
62
|
+
on blur
|
|
63
|
+
target closed
|
|
64
|
+
do select-active close-list
|
|
65
|
+
on next
|
|
66
|
+
do
|
|
67
|
+
activate next
|
|
68
|
+
on previous
|
|
69
|
+
do
|
|
70
|
+
activate previous
|
|
71
|
+
on first
|
|
72
|
+
do
|
|
73
|
+
activate first
|
|
74
|
+
on last
|
|
75
|
+
do
|
|
76
|
+
activate last
|
|
77
|
+
on page-next
|
|
78
|
+
do
|
|
79
|
+
activate pageNext
|
|
80
|
+
on page-previous
|
|
81
|
+
do
|
|
82
|
+
activate pagePrevious
|
|
83
|
+
on typeahead
|
|
84
|
+
do typeahead
|
|
85
|
+
on commit
|
|
86
|
+
target closed
|
|
87
|
+
do select-active close-list
|
|
88
|
+
on pick
|
|
89
|
+
target closed
|
|
90
|
+
do select-picked close-list
|
|
91
|
+
part input
|
|
92
|
+
attr role combobox
|
|
93
|
+
attr aria-haspopup listbox
|
|
94
|
+
attr aria-expanded
|
|
95
|
+
in open
|
|
96
|
+
attr aria-activedescendant
|
|
97
|
+
context active
|
|
98
|
+
attr aria-invalid
|
|
99
|
+
context invalid
|
|
100
|
+
attr data-state
|
|
101
|
+
state
|
|
102
|
+
key ArrowDown next
|
|
103
|
+
key ArrowUp previous
|
|
104
|
+
key Alt+ArrowDown open
|
|
105
|
+
key Alt+ArrowUp commit
|
|
106
|
+
key Home first
|
|
107
|
+
key End last
|
|
108
|
+
key PageDown page-next
|
|
109
|
+
key PageUp page-previous
|
|
110
|
+
key Enter commit
|
|
111
|
+
key Space commit
|
|
112
|
+
key Escape close
|
|
113
|
+
on press toggle
|
|
114
|
+
on focusout blur
|
|
115
|
+
part listbox
|
|
116
|
+
attr role listbox
|
|
117
|
+
attr hidden
|
|
118
|
+
present
|
|
119
|
+
in closed
|
|
120
|
+
attr data-state
|
|
121
|
+
state
|
|
122
|
+
on click pick
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
slider-machine: machine
|
|
2
|
+
initial idle
|
|
3
|
+
context
|
|
4
|
+
disabled false
|
|
5
|
+
orientation horizontal
|
|
6
|
+
state idle
|
|
7
|
+
on grab
|
|
8
|
+
target dragging
|
|
9
|
+
do move-to-pointer
|
|
10
|
+
when not-disabled
|
|
11
|
+
on arrow-up
|
|
12
|
+
do
|
|
13
|
+
numeric-key ArrowUp
|
|
14
|
+
when not-disabled
|
|
15
|
+
on arrow-right
|
|
16
|
+
do
|
|
17
|
+
numeric-key ArrowRight
|
|
18
|
+
when not-disabled
|
|
19
|
+
on arrow-down
|
|
20
|
+
do
|
|
21
|
+
numeric-key ArrowDown
|
|
22
|
+
when not-disabled
|
|
23
|
+
on arrow-left
|
|
24
|
+
do
|
|
25
|
+
numeric-key ArrowLeft
|
|
26
|
+
when not-disabled
|
|
27
|
+
on shift-arrow-up
|
|
28
|
+
do
|
|
29
|
+
numeric-key ArrowUp shift
|
|
30
|
+
when not-disabled
|
|
31
|
+
on shift-arrow-right
|
|
32
|
+
do
|
|
33
|
+
numeric-key ArrowRight shift
|
|
34
|
+
when not-disabled
|
|
35
|
+
on shift-arrow-down
|
|
36
|
+
do
|
|
37
|
+
numeric-key ArrowDown shift
|
|
38
|
+
when not-disabled
|
|
39
|
+
on shift-arrow-left
|
|
40
|
+
do
|
|
41
|
+
numeric-key ArrowLeft shift
|
|
42
|
+
when not-disabled
|
|
43
|
+
on page-up
|
|
44
|
+
do
|
|
45
|
+
numeric-key PageUp
|
|
46
|
+
when not-disabled
|
|
47
|
+
on page-down
|
|
48
|
+
do
|
|
49
|
+
numeric-key PageDown
|
|
50
|
+
when not-disabled
|
|
51
|
+
on home
|
|
52
|
+
do
|
|
53
|
+
numeric-key Home
|
|
54
|
+
when not-disabled
|
|
55
|
+
on end
|
|
56
|
+
do
|
|
57
|
+
numeric-key End
|
|
58
|
+
when not-disabled
|
|
59
|
+
state dragging
|
|
60
|
+
on drag
|
|
61
|
+
do move-to-pointer
|
|
62
|
+
on release
|
|
63
|
+
target idle
|
|
64
|
+
do move-to-pointer
|
|
65
|
+
part thumb
|
|
66
|
+
attr role slider
|
|
67
|
+
attr aria-valuenow
|
|
68
|
+
context value
|
|
69
|
+
attr aria-valuemin
|
|
70
|
+
context min
|
|
71
|
+
attr aria-valuemax
|
|
72
|
+
context max
|
|
73
|
+
attr aria-valuetext
|
|
74
|
+
context text
|
|
75
|
+
attr aria-orientation
|
|
76
|
+
context orientation
|
|
77
|
+
attr aria-disabled
|
|
78
|
+
context disabled
|
|
79
|
+
attr data-state
|
|
80
|
+
state
|
|
81
|
+
key ArrowUp arrow-up
|
|
82
|
+
key ArrowRight arrow-right
|
|
83
|
+
key ArrowDown arrow-down
|
|
84
|
+
key ArrowLeft arrow-left
|
|
85
|
+
key Shift+ArrowUp shift-arrow-up
|
|
86
|
+
key Shift+ArrowRight shift-arrow-right
|
|
87
|
+
key Shift+ArrowDown shift-arrow-down
|
|
88
|
+
key Shift+ArrowLeft shift-arrow-left
|
|
89
|
+
key PageUp page-up
|
|
90
|
+
key PageDown page-down
|
|
91
|
+
key Home home
|
|
92
|
+
key End end
|
|
93
|
+
part track
|
|
94
|
+
attr data-state
|
|
95
|
+
state
|
|
96
|
+
on pointerdown grab
|
|
97
|
+
on pointermove drag
|
|
98
|
+
on pointerup release
|
|
99
|
+
on lostpointercapture release
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
switch-machine: machine
|
|
2
|
+
initial ready
|
|
3
|
+
context
|
|
4
|
+
checked false
|
|
5
|
+
disabled false
|
|
6
|
+
state ready
|
|
7
|
+
on toggle
|
|
8
|
+
do
|
|
9
|
+
toggle checked
|
|
10
|
+
when not-disabled
|
|
11
|
+
part input
|
|
12
|
+
attr role switch
|
|
13
|
+
attr aria-checked
|
|
14
|
+
context checked
|
|
15
|
+
attr data-state
|
|
16
|
+
context checked
|
|
17
|
+
key Enter toggle
|
|
18
|
+
key Space toggle
|
|
19
|
+
on press toggle
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
text-area-machine: machine
|
|
2
|
+
initial idle
|
|
3
|
+
context
|
|
4
|
+
disabled false
|
|
5
|
+
readonly false
|
|
6
|
+
invalid false
|
|
7
|
+
state idle
|
|
8
|
+
on focus
|
|
9
|
+
target editing
|
|
10
|
+
state editing
|
|
11
|
+
on blur
|
|
12
|
+
target idle
|
|
13
|
+
on commit
|
|
14
|
+
do read-value
|
|
15
|
+
on revert
|
|
16
|
+
do restore-value
|
|
17
|
+
when editable
|
|
18
|
+
part input
|
|
19
|
+
attr aria-invalid
|
|
20
|
+
context invalid
|
|
21
|
+
attr data-state
|
|
22
|
+
state
|
|
23
|
+
on focusin focus
|
|
24
|
+
on focusout blur
|
|
25
|
+
on change commit
|
|
26
|
+
key Escape revert
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
text-field-machine: machine
|
|
2
|
+
initial idle
|
|
3
|
+
context
|
|
4
|
+
disabled false
|
|
5
|
+
readonly false
|
|
6
|
+
invalid false
|
|
7
|
+
state idle
|
|
8
|
+
on focus
|
|
9
|
+
target editing
|
|
10
|
+
state editing
|
|
11
|
+
on blur
|
|
12
|
+
target idle
|
|
13
|
+
on commit
|
|
14
|
+
do read-value
|
|
15
|
+
on revert
|
|
16
|
+
do restore-value
|
|
17
|
+
when editable
|
|
18
|
+
part input
|
|
19
|
+
attr aria-invalid
|
|
20
|
+
context invalid
|
|
21
|
+
attr data-state
|
|
22
|
+
state
|
|
23
|
+
on focusin focus
|
|
24
|
+
on focusout blur
|
|
25
|
+
on change commit
|
|
26
|
+
key Escape revert
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `number-field`: a text input with the `spinbutton` role (not
|
|
3
|
+
* `type=number`, whose wheel and locale handling differ between
|
|
4
|
+
* browsers). ArrowUp/ArrowDown step (×10 with Shift), PageUp/PageDown
|
|
5
|
+
* move ten steps; Home/End and Shift+Page retain native text navigation.
|
|
6
|
+
* Typed text commits on `input`, clamped to the range (and step unless
|
|
7
|
+
* `normalization clamp`), while
|
|
8
|
+
* the exact draft survives store echoes until the native `change`. Text
|
|
9
|
+
* that is not a number makes the field invalid and keeps the last value.
|
|
10
|
+
*
|
|
11
|
+
* (age: number-field 'Age' (name age) (min 0) (max 130) (value 30))
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
changesOf,
|
|
16
|
+
partOf,
|
|
17
|
+
setText,
|
|
18
|
+
flagOf,
|
|
19
|
+
commitValue,
|
|
20
|
+
maybeNumber,
|
|
21
|
+
numberOf,
|
|
22
|
+
textOf,
|
|
23
|
+
receive,
|
|
24
|
+
stopControl,
|
|
25
|
+
} from './dom.js';
|
|
26
|
+
import { clampStep, nextValue } from './numeric-keys.js';
|
|
27
|
+
import { createTextControl, inputOf, updateTextControl } from './text-field.js';
|
|
28
|
+
|
|
29
|
+
/** The range of a number control's context. */
|
|
30
|
+
const rangeOf = (context) => ({
|
|
31
|
+
min: context.min ?? undefined,
|
|
32
|
+
max: context.max ?? undefined,
|
|
33
|
+
step: context.step ?? undefined,
|
|
34
|
+
snapping: context.snapping,
|
|
35
|
+
normalization: context.normalization,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
/** A number written back to the input (`''` for none). */
|
|
39
|
+
export const formatNumber = (value) =>
|
|
40
|
+
typeof value === 'number' && Number.isFinite(value) ? String(value) : '';
|
|
41
|
+
|
|
42
|
+
/** Read the typed text: `{value}` (`null` when empty) or `{invalid}`. */
|
|
43
|
+
export function readNumber(text, range) {
|
|
44
|
+
const trimmed = text.trim();
|
|
45
|
+
if (trimmed === '') {
|
|
46
|
+
return { value: null, invalid: false };
|
|
47
|
+
}
|
|
48
|
+
const number = Number(trimmed.replace(',', '.'));
|
|
49
|
+
if (!Number.isFinite(number)) {
|
|
50
|
+
return { invalid: true };
|
|
51
|
+
}
|
|
52
|
+
const value =
|
|
53
|
+
range?.normalization === 'clamp'
|
|
54
|
+
? Math.min(
|
|
55
|
+
Number.isFinite(range.max) ? range.max : Infinity,
|
|
56
|
+
Math.max(Number.isFinite(range.min) ? range.min : -Infinity, number)
|
|
57
|
+
)
|
|
58
|
+
: clampStep(number, range);
|
|
59
|
+
return { value, invalid: false };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const actions = (input, getControl) => ({
|
|
63
|
+
'read-draft': (args, meta) => {
|
|
64
|
+
getControl().draft = input.value;
|
|
65
|
+
const read = readNumber(input.value, rangeOf(meta.context));
|
|
66
|
+
meta.assign(
|
|
67
|
+
read.invalid
|
|
68
|
+
? { invalid: true }
|
|
69
|
+
: read.value === null && meta.context.inherit
|
|
70
|
+
? { invalid: false }
|
|
71
|
+
: read
|
|
72
|
+
);
|
|
73
|
+
},
|
|
74
|
+
'read-value': (args, meta) => {
|
|
75
|
+
getControl().draft = undefined;
|
|
76
|
+
const read = readNumber(input.value, rangeOf(meta.context));
|
|
77
|
+
meta.assign(
|
|
78
|
+
read.invalid
|
|
79
|
+
? { invalid: true }
|
|
80
|
+
: read.value === null && meta.context.inherit
|
|
81
|
+
? { invalid: false }
|
|
82
|
+
: read
|
|
83
|
+
);
|
|
84
|
+
},
|
|
85
|
+
'restore-value': (args, meta) => {
|
|
86
|
+
getControl().draft = undefined;
|
|
87
|
+
meta.assign({ invalid: false });
|
|
88
|
+
input.value = formatNumber(meta.context.value);
|
|
89
|
+
},
|
|
90
|
+
'numeric-key': ([key, shift], meta) => {
|
|
91
|
+
getControl().draft = undefined;
|
|
92
|
+
const value = nextValue(key, {
|
|
93
|
+
...rangeOf(meta.context),
|
|
94
|
+
value: meta.context.value ?? meta.context.fallback ?? Number.NaN,
|
|
95
|
+
shift: shift === 'shift',
|
|
96
|
+
});
|
|
97
|
+
if (value !== null) {
|
|
98
|
+
meta.assign({ value, invalid: false });
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
/** Show the value (not over invalid text being fixed), then commit it. */
|
|
104
|
+
function render(control) {
|
|
105
|
+
const { context } = control.service;
|
|
106
|
+
const input = control.parts.input;
|
|
107
|
+
if (context.invalid !== true && control.draft === undefined) {
|
|
108
|
+
const text = formatNumber(context.value);
|
|
109
|
+
if (input.value !== text) {
|
|
110
|
+
input.value = text;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
renderSteppers(context, control.parts);
|
|
114
|
+
const inherited = context.inherit && context.value === null;
|
|
115
|
+
if (inherited) {
|
|
116
|
+
input.setAttribute('aria-valuetext', context.inheritedLabel || 'inherited');
|
|
117
|
+
} else {
|
|
118
|
+
input.removeAttribute('aria-valuetext');
|
|
119
|
+
}
|
|
120
|
+
control.parts.reset.hidden = !context.inherit;
|
|
121
|
+
control.parts.reset.disabled = Boolean(
|
|
122
|
+
inherited || context.disabled || context.readonly
|
|
123
|
+
);
|
|
124
|
+
commitValue(control);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export const NUMBER_FIELD_KIND = Object.freeze({
|
|
128
|
+
tag: 'ui-number-field',
|
|
129
|
+
childrenSlot: null,
|
|
130
|
+
attributes: { disabled: 'boolean', invalid: 'boolean' },
|
|
131
|
+
create: (el, ctx) =>
|
|
132
|
+
createTextControl(el, ctx, {
|
|
133
|
+
tag: 'ui-number-field',
|
|
134
|
+
kind: 'number-field',
|
|
135
|
+
attrs: { type: 'text', inputmode: 'decimal', autocomplete: 'off' },
|
|
136
|
+
ignoreInFields: false,
|
|
137
|
+
children: (doc, node, getControl) => {
|
|
138
|
+
const parts = {};
|
|
139
|
+
for (const [name, label] of [
|
|
140
|
+
['decrement', 'Decrease'],
|
|
141
|
+
['increment', 'Increase'],
|
|
142
|
+
]) {
|
|
143
|
+
const button = partOf(doc, 'button', name, {
|
|
144
|
+
type: 'button',
|
|
145
|
+
'aria-label': label,
|
|
146
|
+
});
|
|
147
|
+
setText(button, name === 'increment' ? '+' : '−');
|
|
148
|
+
button.addEventListener('pointerdown', (event) =>
|
|
149
|
+
event.preventDefault()
|
|
150
|
+
);
|
|
151
|
+
button.addEventListener(
|
|
152
|
+
'click',
|
|
153
|
+
(event) => {
|
|
154
|
+
event.stopImmediatePropagation();
|
|
155
|
+
if (!button.disabled) {
|
|
156
|
+
const direction =
|
|
157
|
+
name === 'increment' ? 'arrow-up' : 'arrow-down';
|
|
158
|
+
getControl().service.send(
|
|
159
|
+
`${event.shiftKey ? 'shift-' : ''}${direction}`
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
true
|
|
164
|
+
);
|
|
165
|
+
node.appendChild(button);
|
|
166
|
+
parts[name] = button;
|
|
167
|
+
}
|
|
168
|
+
const reset = partOf(doc, 'button', 'reset', {
|
|
169
|
+
type: 'button',
|
|
170
|
+
hidden: '',
|
|
171
|
+
});
|
|
172
|
+
setText(reset, 'Inherit');
|
|
173
|
+
reset.addEventListener('click', () => {
|
|
174
|
+
if (!reset.disabled) {
|
|
175
|
+
getControl().draft = undefined;
|
|
176
|
+
getControl().assign({ value: null, invalid: false });
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
node.appendChild(reset);
|
|
180
|
+
return { ...parts, reset };
|
|
181
|
+
},
|
|
182
|
+
actions,
|
|
183
|
+
render,
|
|
184
|
+
}),
|
|
185
|
+
eventTarget: inputOf,
|
|
186
|
+
update(node, el, changed, ctx) {
|
|
187
|
+
const has = changesOf(node, changed);
|
|
188
|
+
const { input, control } = updateTextControl(node, el, ctx, has);
|
|
189
|
+
const range = {};
|
|
190
|
+
for (const name of ['min', 'max', 'step', 'fallback']) {
|
|
191
|
+
if (has(name)) {
|
|
192
|
+
range[name] = maybeNumber(el, name);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
for (const name of ['snapping', 'normalization']) {
|
|
196
|
+
if (has(name)) {
|
|
197
|
+
range[name] = textOf(el, name);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
for (const name of ['increment', 'decrement']) {
|
|
201
|
+
control.parts[name].setAttribute(
|
|
202
|
+
'aria-label',
|
|
203
|
+
textOf(el, `${name}-label`) ||
|
|
204
|
+
(name === 'increment' ? 'Increase' : 'Decrease')
|
|
205
|
+
);
|
|
206
|
+
control.parts[name].toggleAttribute(
|
|
207
|
+
'disabled',
|
|
208
|
+
flagOf(el, 'disabled') || flagOf(el, 'readonly')
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
range.inherit = flagOf(el, 'inherit');
|
|
212
|
+
range.inheritedLabel = textOf(el, 'inherited-label');
|
|
213
|
+
setText(control.parts.reset, textOf(el, 'inherit-label') || 'Inherit');
|
|
214
|
+
control.assign(range);
|
|
215
|
+
if (has('value')) {
|
|
216
|
+
const value = numberOf(el, 'value', Number.NaN);
|
|
217
|
+
const number = Number.isFinite(value) ? value : null;
|
|
218
|
+
input.setAttribute('value', formatNumber(number));
|
|
219
|
+
if (number !== control.value) {
|
|
220
|
+
control.draft = undefined;
|
|
221
|
+
}
|
|
222
|
+
receive(control, number);
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
destroy: stopControl,
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
function renderSteppers(context, parts) {
|
|
229
|
+
const effective = context.value ?? context.fallback;
|
|
230
|
+
for (const name of ['increment', 'decrement']) {
|
|
231
|
+
const bounded =
|
|
232
|
+
name === 'increment'
|
|
233
|
+
? effective >= context.max && context.max !== null
|
|
234
|
+
: effective <= context.min && context.min !== null;
|
|
235
|
+
const disabled = context.disabled || context.readonly || bounded;
|
|
236
|
+
parts[name].disabled = Boolean(disabled);
|
|
237
|
+
parts[name].tabIndex = -1;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The keys of the numeric controls (`slider`, `number-field`), DOM-free:
|
|
3
|
+
* `nextValue(key, state)` is the value a key moves to, and `clampStep`
|
|
4
|
+
* keeps a value inside its range and on its step grid.
|
|
5
|
+
*
|
|
6
|
+
* | Key | Change |
|
|
7
|
+
* | ------------------------ | ------------------------------- |
|
|
8
|
+
* | ArrowUp, ArrowRight | one step up (×10 with Shift) |
|
|
9
|
+
* | ArrowDown, ArrowLeft | one step down (×10 with Shift) |
|
|
10
|
+
* | PageUp, PageDown | ten steps (×10 with Shift) |
|
|
11
|
+
* | Home, End | the minimum, the maximum |
|
|
12
|
+
*
|
|
13
|
+
* In a right-to-left horizontal slider (`rtl: true`) ArrowRight steps
|
|
14
|
+
* down and ArrowLeft steps up, as the track runs the other way.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/** How many steps PageUp and PageDown move. */
|
|
18
|
+
export const PAGE_STEPS = 10;
|
|
19
|
+
|
|
20
|
+
/** How much Shift multiplies a step. */
|
|
21
|
+
export const SHIFT_FACTOR = 10;
|
|
22
|
+
|
|
23
|
+
/** The number of decimals of a finite number (`0.25` → 2, `1e-7` → 7). */
|
|
24
|
+
export function decimalsOf(value) {
|
|
25
|
+
if (!Number.isFinite(value)) {
|
|
26
|
+
return 0;
|
|
27
|
+
}
|
|
28
|
+
const [mantissa, exponent] = String(value).toLowerCase().split('e');
|
|
29
|
+
const fraction = mantissa.split('.')[1]?.length ?? 0;
|
|
30
|
+
return Math.max(0, fraction - Number(exponent ?? 0));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const finite = (value, fallback) =>
|
|
34
|
+
typeof value === 'number' && Number.isFinite(value) ? value : fallback;
|
|
35
|
+
|
|
36
|
+
/** A positive step; anything else is 1. */
|
|
37
|
+
const stepOf = (step) => (finite(step, 0) > 0 ? step : 1);
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Round `value` to the nearest multiple of `step` from `min` (or 0) and
|
|
41
|
+
* clamp it to `[min, max]`. A bound that is not a finite number is open.
|
|
42
|
+
* The result has no more decimals than the step and the minimum, so
|
|
43
|
+
* `clampStep(0.1 + 0.2, {step: 0.1})` is `0.3`.
|
|
44
|
+
* @param {number} value
|
|
45
|
+
* @param {{min?: number, max?: number, step?: number}} [range]
|
|
46
|
+
* @returns {number}
|
|
47
|
+
*/
|
|
48
|
+
export function clampStep(value, range = {}) {
|
|
49
|
+
const min = finite(range.min, -Infinity);
|
|
50
|
+
const max = finite(range.max, Infinity);
|
|
51
|
+
const step = stepOf(range.step);
|
|
52
|
+
const base = Number.isFinite(min) ? min : 0;
|
|
53
|
+
const start = finite(value, base);
|
|
54
|
+
const digits = Math.min(
|
|
55
|
+
20,
|
|
56
|
+
Math.max(decimalsOf(step), decimalsOf(Number.isFinite(min) ? min : 0))
|
|
57
|
+
);
|
|
58
|
+
const rounded = Number(
|
|
59
|
+
(base + Math.round((start - base) / step) * step).toFixed(digits)
|
|
60
|
+
);
|
|
61
|
+
if (rounded > max) {
|
|
62
|
+
return max;
|
|
63
|
+
}
|
|
64
|
+
return rounded < min ? min : rounded;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** The step multiple of each stepping key (before Shift). */
|
|
68
|
+
const STEPS = Object.freeze({
|
|
69
|
+
ArrowUp: 1,
|
|
70
|
+
ArrowRight: 1,
|
|
71
|
+
ArrowDown: -1,
|
|
72
|
+
ArrowLeft: -1,
|
|
73
|
+
PageUp: PAGE_STEPS,
|
|
74
|
+
PageDown: -PAGE_STEPS,
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* The value a key moves a numeric control to; `null` for a key that does
|
|
79
|
+
* not change the value (the caller lets it through).
|
|
80
|
+
* @param {string} key a `KeyboardEvent.key`
|
|
81
|
+
* @param {{value?: number, min?: number, max?: number, step?: number,
|
|
82
|
+
* shift?: boolean, rtl?: boolean, snapping?: 'nearest'|'directional'}} state `value` NaN (an empty field)
|
|
83
|
+
* starts from the minimum, else 0
|
|
84
|
+
* @returns {number|null}
|
|
85
|
+
*/
|
|
86
|
+
export function nextValue(key, state = {}) {
|
|
87
|
+
const range = { min: state.min, max: state.max, step: state.step };
|
|
88
|
+
if (key === 'Home') {
|
|
89
|
+
return Number.isFinite(state.min) ? state.min : null;
|
|
90
|
+
}
|
|
91
|
+
if (key === 'End') {
|
|
92
|
+
return Number.isFinite(state.max) ? state.max : null;
|
|
93
|
+
}
|
|
94
|
+
if (!Object.hasOwn(STEPS, key)) {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
let multiple = STEPS[key];
|
|
98
|
+
if (state.rtl === true && (key === 'ArrowLeft' || key === 'ArrowRight')) {
|
|
99
|
+
multiple = -multiple;
|
|
100
|
+
}
|
|
101
|
+
if (state.shift === true) {
|
|
102
|
+
multiple *= SHIFT_FACTOR;
|
|
103
|
+
}
|
|
104
|
+
const base = Number.isFinite(state.min) ? state.min : 0;
|
|
105
|
+
const raw = finite(state.value, base);
|
|
106
|
+
if (state.snapping === 'directional') {
|
|
107
|
+
const step = stepOf(state.step);
|
|
108
|
+
const bounded = Math.min(
|
|
109
|
+
finite(state.max, Infinity),
|
|
110
|
+
Math.max(finite(state.min, -Infinity), raw)
|
|
111
|
+
);
|
|
112
|
+
const ticks = (bounded - base) / step;
|
|
113
|
+
const tolerance = Math.min(
|
|
114
|
+
1e-7,
|
|
115
|
+
Number.EPSILON * Math.max(1, Math.abs(ticks)) * 8
|
|
116
|
+
);
|
|
117
|
+
const origin =
|
|
118
|
+
multiple > 0
|
|
119
|
+
? Math.floor(ticks + tolerance)
|
|
120
|
+
: Math.ceil(ticks - tolerance);
|
|
121
|
+
return clampStep(base + (origin + multiple) * step, range);
|
|
122
|
+
}
|
|
123
|
+
const value = clampStep(raw, range);
|
|
124
|
+
return clampStep(value + multiple * stepOf(state.step), range);
|
|
125
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `option`: one choice of a `select` or a `combobox` (`role=option`). Its
|
|
3
|
+
* `value` defaults to its ID, its label to the value.
|
|
4
|
+
*
|
|
5
|
+
* (m: option 'Medium' (value m))
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { choiceLabel, choiceValue, wasChosen } from './choices.js';
|
|
9
|
+
import {
|
|
10
|
+
atomOf,
|
|
11
|
+
changesOf,
|
|
12
|
+
flagOf,
|
|
13
|
+
partId,
|
|
14
|
+
partOf,
|
|
15
|
+
setAttr,
|
|
16
|
+
setText,
|
|
17
|
+
} from './dom.js';
|
|
18
|
+
|
|
19
|
+
export const OPTION_KIND = Object.freeze({
|
|
20
|
+
tag: 'ui-option',
|
|
21
|
+
childrenSlot: null,
|
|
22
|
+
attributes: { disabled: 'boolean' },
|
|
23
|
+
create(el, ctx) {
|
|
24
|
+
const doc = ctx.document;
|
|
25
|
+
const node = doc.createElement('ui-option');
|
|
26
|
+
node.setAttribute('role', 'option');
|
|
27
|
+
node.setAttribute('id', partId(el.id, 'option'));
|
|
28
|
+
node.setAttribute('aria-selected', String(wasChosen(ctx, el.id)));
|
|
29
|
+
node.appendChild(
|
|
30
|
+
partOf(doc, 'span', 'indicator', { 'aria-hidden': 'true' })
|
|
31
|
+
);
|
|
32
|
+
node.appendChild(partOf(doc, 'span', 'label'));
|
|
33
|
+
return node;
|
|
34
|
+
},
|
|
35
|
+
update(node, el, changed, ctx) {
|
|
36
|
+
const has = changesOf(node, changed);
|
|
37
|
+
if (has('label') || has('value')) {
|
|
38
|
+
setText(node.children[1], choiceLabel(el));
|
|
39
|
+
if (atomOf(el, 'label') === undefined) {
|
|
40
|
+
ctx.diagnostic('missing-label', 'warning', { property: 'label' });
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (has('value')) {
|
|
44
|
+
node.setAttribute('data-value', choiceValue(el));
|
|
45
|
+
}
|
|
46
|
+
if (has('disabled')) {
|
|
47
|
+
setAttr(
|
|
48
|
+
node,
|
|
49
|
+
'aria-disabled',
|
|
50
|
+
flagOf(el, 'disabled') ? 'true' : undefined
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
});
|