@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
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `switch`: an on/off `<button role=switch aria-checked>` with a track
|
|
3
|
+
* and a thumb; Space, Enter and a click toggle it. Its label is the
|
|
4
|
+
* button's own text, so the name and the switch are one tab stop. A form
|
|
5
|
+
* submits `value` (default `on`) under `name` only while it is on, as a
|
|
6
|
+
* checkbox does (a hidden input).
|
|
7
|
+
*
|
|
8
|
+
* (dark: switch 'Dark theme' (name dark) (checked true))
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
atomOf,
|
|
13
|
+
changesOf,
|
|
14
|
+
commitValue,
|
|
15
|
+
controlOf,
|
|
16
|
+
flagOf,
|
|
17
|
+
partId,
|
|
18
|
+
partOf,
|
|
19
|
+
receive,
|
|
20
|
+
setAttr,
|
|
21
|
+
setText,
|
|
22
|
+
startControl,
|
|
23
|
+
stopControl,
|
|
24
|
+
} from './dom.js';
|
|
25
|
+
|
|
26
|
+
/** Keep the hidden form input in step with the state. */
|
|
27
|
+
function render(control) {
|
|
28
|
+
const { checked, disabled } = control.service.context;
|
|
29
|
+
control.hidden.toggleAttribute(
|
|
30
|
+
'disabled',
|
|
31
|
+
checked !== true || disabled === true
|
|
32
|
+
);
|
|
33
|
+
commitValue(control, 'checked', checked === true);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const SWITCH_KIND = Object.freeze({
|
|
37
|
+
tag: 'ui-switch',
|
|
38
|
+
childrenSlot: null,
|
|
39
|
+
attributes: { disabled: 'boolean' },
|
|
40
|
+
create(el, ctx) {
|
|
41
|
+
const doc = ctx.document;
|
|
42
|
+
const node = doc.createElement('ui-switch');
|
|
43
|
+
const input = partOf(doc, 'button', 'input', {
|
|
44
|
+
type: 'button',
|
|
45
|
+
id: partId(el.id),
|
|
46
|
+
});
|
|
47
|
+
const track = partOf(doc, 'span', 'track', { 'aria-hidden': 'true' });
|
|
48
|
+
const thumb = partOf(doc, 'span', 'thumb');
|
|
49
|
+
const label = partOf(doc, 'span', 'label');
|
|
50
|
+
const hidden = partOf(doc, 'input', null, { type: 'hidden', value: 'on' });
|
|
51
|
+
track.appendChild(thumb);
|
|
52
|
+
input.appendChild(track);
|
|
53
|
+
input.appendChild(label);
|
|
54
|
+
node.appendChild(input);
|
|
55
|
+
node.appendChild(hidden);
|
|
56
|
+
const control = startControl(node, el, ctx, {
|
|
57
|
+
kind: 'switch',
|
|
58
|
+
parts: { input, track, thumb, label },
|
|
59
|
+
target: input,
|
|
60
|
+
render: (c) => render(c),
|
|
61
|
+
});
|
|
62
|
+
control.hidden = hidden;
|
|
63
|
+
return node;
|
|
64
|
+
},
|
|
65
|
+
eventTarget: (node) => node.firstChild,
|
|
66
|
+
update(node, el, changed, ctx) {
|
|
67
|
+
const has = changesOf(node, changed);
|
|
68
|
+
const control = controlOf(node);
|
|
69
|
+
const { input, label } = control.parts;
|
|
70
|
+
if (has('label')) {
|
|
71
|
+
const text = atomOf(el, 'label');
|
|
72
|
+
setText(label, text);
|
|
73
|
+
if (text === undefined || text === '') {
|
|
74
|
+
ctx.diagnostic('missing-label', 'error', { property: 'label' });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (has('name')) {
|
|
78
|
+
setAttr(control.hidden, 'name', atomOf(el, 'name'));
|
|
79
|
+
}
|
|
80
|
+
if (has('value')) {
|
|
81
|
+
setAttr(control.hidden, 'value', atomOf(el, 'value') ?? 'on');
|
|
82
|
+
}
|
|
83
|
+
if (has('disabled')) {
|
|
84
|
+
const disabled = flagOf(el, 'disabled');
|
|
85
|
+
input.toggleAttribute('disabled', disabled);
|
|
86
|
+
control.assign({ disabled });
|
|
87
|
+
}
|
|
88
|
+
if (has('checked')) {
|
|
89
|
+
const checked = flagOf(el, 'checked');
|
|
90
|
+
receive(control, checked, { checked });
|
|
91
|
+
}
|
|
92
|
+
render(control);
|
|
93
|
+
},
|
|
94
|
+
destroy: stopControl,
|
|
95
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `text-area`: a native `<textarea>` with its `<label>`, committed like
|
|
3
|
+
* `text-field` (on the native `change`); `rows` sets its height in lines.
|
|
4
|
+
*
|
|
5
|
+
* (bio: text-area 'About you' (name bio) (rows 4))
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { changesOf, numberOf, setAttr, stopControl, textOf } from './dom.js';
|
|
9
|
+
import {
|
|
10
|
+
createTextControl,
|
|
11
|
+
inputOf,
|
|
12
|
+
receiveText,
|
|
13
|
+
updateTextControl,
|
|
14
|
+
} from './text-field.js';
|
|
15
|
+
|
|
16
|
+
export const TEXT_AREA_KIND = Object.freeze({
|
|
17
|
+
tag: 'ui-text-area',
|
|
18
|
+
childrenSlot: null,
|
|
19
|
+
attributes: { disabled: 'boolean', invalid: 'boolean' },
|
|
20
|
+
create: (el, ctx) =>
|
|
21
|
+
createTextControl(el, ctx, {
|
|
22
|
+
tag: 'ui-text-area',
|
|
23
|
+
kind: 'text-area',
|
|
24
|
+
element: 'textarea',
|
|
25
|
+
}),
|
|
26
|
+
eventTarget: inputOf,
|
|
27
|
+
update(node, el, changed, ctx) {
|
|
28
|
+
const has = changesOf(node, changed);
|
|
29
|
+
const { input, control } = updateTextControl(node, el, ctx, has);
|
|
30
|
+
if (has('rows')) {
|
|
31
|
+
const rows = numberOf(el, 'rows', 0);
|
|
32
|
+
setAttr(input, 'rows', rows >= 1 ? String(Math.round(rows)) : undefined);
|
|
33
|
+
}
|
|
34
|
+
if (has('value')) {
|
|
35
|
+
receiveText(input, control, textOf(el, 'value'));
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
destroy: stopControl,
|
|
39
|
+
});
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `text-field`: a native `<input>` with its `<label>`. The value is
|
|
3
|
+
* committed on the native `change` (Enter or leaving the field): one
|
|
4
|
+
* `ui-change` per new value. Escape restores the last committed value.
|
|
5
|
+
* Typing never reaches a key binding: the machine binds only Escape, and
|
|
6
|
+
* `bindKeys` leaves text fields alone.
|
|
7
|
+
*
|
|
8
|
+
* (email: text-field 'Email' (name email) (type email) (required true))
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
atomOf,
|
|
13
|
+
changesOf,
|
|
14
|
+
commitValue,
|
|
15
|
+
controlOf,
|
|
16
|
+
flagOf,
|
|
17
|
+
partId,
|
|
18
|
+
partOf,
|
|
19
|
+
setAttr,
|
|
20
|
+
setText,
|
|
21
|
+
startControl,
|
|
22
|
+
stopControl,
|
|
23
|
+
textOf,
|
|
24
|
+
updateLabel,
|
|
25
|
+
} from './dom.js';
|
|
26
|
+
|
|
27
|
+
const TYPES = new Set(['text', 'email', 'password', 'search', 'tel', 'url']);
|
|
28
|
+
|
|
29
|
+
/** The input (or textarea) of a text control node (after its label). */
|
|
30
|
+
export const inputOf = (node) => node.children[1];
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Build `<tag><label data-part=label><input data-part=input></tag>` and
|
|
34
|
+
* start the machine of `kind`.
|
|
35
|
+
* @param {{tag: string, kind: string, element?: string,
|
|
36
|
+
* attrs?: Record<string, string>, actions?: Record<string, Function>,
|
|
37
|
+
* ignoreInFields?: boolean, render?: Function, children?: Function}} spec
|
|
38
|
+
*/
|
|
39
|
+
export function createTextControl(el, ctx, spec) {
|
|
40
|
+
const doc = ctx.document;
|
|
41
|
+
const id = partId(el.id);
|
|
42
|
+
const node = doc.createElement(spec.tag);
|
|
43
|
+
const label = partOf(doc, 'label', 'label', { for: id });
|
|
44
|
+
const input = partOf(doc, spec.element ?? 'input', 'input', {
|
|
45
|
+
id,
|
|
46
|
+
...spec.attrs,
|
|
47
|
+
});
|
|
48
|
+
node.appendChild(label);
|
|
49
|
+
node.appendChild(input);
|
|
50
|
+
const extra = spec.children?.(doc, node, () => control) ?? {};
|
|
51
|
+
const control = startControl(node, el, ctx, {
|
|
52
|
+
kind: spec.kind,
|
|
53
|
+
parts: { label, input, ...extra },
|
|
54
|
+
target: input,
|
|
55
|
+
ignoreInFields: spec.ignoreInFields,
|
|
56
|
+
actions: {
|
|
57
|
+
'read-value': (args, meta) => meta.assign({ value: input.value }),
|
|
58
|
+
'restore-value': (args, meta) => {
|
|
59
|
+
input.value = control.value ?? '';
|
|
60
|
+
meta.assign({ value: control.value });
|
|
61
|
+
},
|
|
62
|
+
...spec.actions?.(input, () => control),
|
|
63
|
+
},
|
|
64
|
+
render: spec.render ?? ((c) => commitValue(c)),
|
|
65
|
+
});
|
|
66
|
+
return node;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Apply the properties every text control has. */
|
|
70
|
+
export function updateTextControl(node, el, ctx, has) {
|
|
71
|
+
const control = controlOf(node);
|
|
72
|
+
const { input } = control.parts;
|
|
73
|
+
if (has('label')) {
|
|
74
|
+
updateLabel(node.firstChild, el, ctx);
|
|
75
|
+
}
|
|
76
|
+
for (const name of ['name', 'placeholder', 'autocomplete']) {
|
|
77
|
+
if (has(name)) {
|
|
78
|
+
setAttr(input, name, atomOf(el, name));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
for (const name of ['required', 'readonly', 'disabled', 'invalid']) {
|
|
82
|
+
if (has(name)) {
|
|
83
|
+
const on = flagOf(el, name);
|
|
84
|
+
if (name !== 'invalid') {
|
|
85
|
+
input.toggleAttribute(name, on);
|
|
86
|
+
}
|
|
87
|
+
control.assign({ [name]: on });
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return { input, control };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Show the value of a property in a text input and in the machine. */
|
|
94
|
+
export function receiveText(input, control, value) {
|
|
95
|
+
if (input.value !== value) {
|
|
96
|
+
input.value = value;
|
|
97
|
+
}
|
|
98
|
+
if (input.localName === 'textarea') {
|
|
99
|
+
// The default value of a textarea is its text (also in static HTML).
|
|
100
|
+
setText(input, value);
|
|
101
|
+
} else {
|
|
102
|
+
input.setAttribute('value', value);
|
|
103
|
+
}
|
|
104
|
+
control.value = value;
|
|
105
|
+
control.assign({ value });
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export const TEXT_FIELD_KIND = Object.freeze({
|
|
109
|
+
tag: 'ui-text-field',
|
|
110
|
+
childrenSlot: null,
|
|
111
|
+
attributes: { variant: 'string', disabled: 'boolean', invalid: 'boolean' },
|
|
112
|
+
create: (el, ctx) =>
|
|
113
|
+
createTextControl(el, ctx, {
|
|
114
|
+
tag: 'ui-text-field',
|
|
115
|
+
kind: 'text-field',
|
|
116
|
+
attrs: { type: 'text' },
|
|
117
|
+
}),
|
|
118
|
+
eventTarget: inputOf,
|
|
119
|
+
update(node, el, changed, ctx) {
|
|
120
|
+
const has = changesOf(node, changed);
|
|
121
|
+
const { input, control } = updateTextControl(node, el, ctx, has);
|
|
122
|
+
if (has('type')) {
|
|
123
|
+
const type = atomOf(el, 'type');
|
|
124
|
+
input.setAttribute('type', TYPES.has(type) ? type : 'text');
|
|
125
|
+
}
|
|
126
|
+
if (has('value')) {
|
|
127
|
+
receiveText(input, control, textOf(el, 'value'));
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
destroy: stopControl,
|
|
131
|
+
});
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The vocabulary of the basic controls (kinds.lino), in the shape of
|
|
3
|
+
* docs/spec/vocabulary.lino. Each kind entry also names the behaviour
|
|
4
|
+
* machine of the control (`(machine NAME)`) and its ARIA role
|
|
5
|
+
* (`(role NAME)`): these two are component metadata, not properties, so
|
|
6
|
+
* they are read here and left out of the vocabulary.
|
|
7
|
+
*
|
|
8
|
+
* Parse control documents with `{ vocabulary: controlsVocabulary() }`.
|
|
9
|
+
* The same kinds are declared in docs/spec/vocabulary.lino, so the default
|
|
10
|
+
* vocabulary already knows them; tests/controls/vocabulary.test.js checks
|
|
11
|
+
* that the two stay equal.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
defaultVocabulary,
|
|
16
|
+
parseNested,
|
|
17
|
+
projectLinks,
|
|
18
|
+
} from '@link-foundation/ui-core';
|
|
19
|
+
import { CONTROL_KINDS_TEXT } from './kinds-text.js';
|
|
20
|
+
|
|
21
|
+
export { CONTROL_KINDS_TEXT };
|
|
22
|
+
|
|
23
|
+
/** A bootstrap kind of the given property names (`*`: multi). */
|
|
24
|
+
const kindSpec = (names) => ({
|
|
25
|
+
positional: [],
|
|
26
|
+
children: 'any',
|
|
27
|
+
properties: new Map(
|
|
28
|
+
names.map((name) => {
|
|
29
|
+
const multi = name.endsWith('*');
|
|
30
|
+
return [multi ? name.slice(0, -1) : name, { type: 'any', multi }];
|
|
31
|
+
})
|
|
32
|
+
),
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
/** kinds.lino is read as a document of `kind` elements with metadata. */
|
|
36
|
+
const BOOTSTRAP = Object.freeze({
|
|
37
|
+
version: null,
|
|
38
|
+
kinds: new Map([
|
|
39
|
+
[
|
|
40
|
+
'kind',
|
|
41
|
+
kindSpec([
|
|
42
|
+
'description',
|
|
43
|
+
'positional',
|
|
44
|
+
'property*',
|
|
45
|
+
'children',
|
|
46
|
+
'machine',
|
|
47
|
+
'role',
|
|
48
|
+
]),
|
|
49
|
+
],
|
|
50
|
+
]),
|
|
51
|
+
actions: new Map(),
|
|
52
|
+
multiValued: new Set(),
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const valuesOf = (element, name) =>
|
|
56
|
+
element.properties.filter((p) => p.name === name).map((p) => p.values);
|
|
57
|
+
|
|
58
|
+
/** The single atom of a metadata field, or `null`. */
|
|
59
|
+
const fieldOf = (element, name) => {
|
|
60
|
+
const [values] = valuesOf(element, name);
|
|
61
|
+
return typeof values?.[0] === 'string' ? values[0] : null;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/** A kind entry as a vocabulary kind (as ui-core `loadVocabulary` reads it). */
|
|
65
|
+
function kindOf(element) {
|
|
66
|
+
const [children = ['any']] = valuesOf(element, 'children');
|
|
67
|
+
return {
|
|
68
|
+
positional: valuesOf(element, 'positional').flat(),
|
|
69
|
+
properties: new Map(
|
|
70
|
+
valuesOf(element, 'property').map(([name, type, ...flags]) => [
|
|
71
|
+
name,
|
|
72
|
+
{ type, multi: flags.includes('multi') },
|
|
73
|
+
])
|
|
74
|
+
),
|
|
75
|
+
children: children[0],
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
let cached = null;
|
|
80
|
+
|
|
81
|
+
/** Read kinds.lino once: the vocabulary kinds and the metadata by kind. */
|
|
82
|
+
function read() {
|
|
83
|
+
if (cached !== null) {
|
|
84
|
+
return cached;
|
|
85
|
+
}
|
|
86
|
+
const links = parseNested(CONTROL_KINDS_TEXT);
|
|
87
|
+
const { roots, diagnostics } = projectLinks(links, BOOTSTRAP);
|
|
88
|
+
if (diagnostics.length > 0) {
|
|
89
|
+
throw new Error(
|
|
90
|
+
`Invalid control kinds: ${diagnostics.map((d) => d.message).join('; ')}`
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
const meta = new Map();
|
|
94
|
+
const kinds = new Map();
|
|
95
|
+
for (const element of roots) {
|
|
96
|
+
meta.set(
|
|
97
|
+
element.id,
|
|
98
|
+
Object.freeze({
|
|
99
|
+
machine: fieldOf(element, 'machine'),
|
|
100
|
+
role: fieldOf(element, 'role'),
|
|
101
|
+
})
|
|
102
|
+
);
|
|
103
|
+
kinds.set(element.id, kindOf(element));
|
|
104
|
+
}
|
|
105
|
+
cached = { meta, kinds };
|
|
106
|
+
return cached;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** The control kind names, in kinds.lino order. */
|
|
110
|
+
export const controlKindNames = () => [...read().meta.keys()];
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* The machine and the role of a control kind (`null` when it has none);
|
|
114
|
+
* `undefined` for a kind that is not a control.
|
|
115
|
+
* @param {string} kind
|
|
116
|
+
* @returns {{machine: string|null, role: string|null}|undefined}
|
|
117
|
+
*/
|
|
118
|
+
export const controlKindMeta = (kind) => read().meta.get(kind);
|
|
119
|
+
|
|
120
|
+
/** The common properties shared by every dialect kind. */
|
|
121
|
+
function withCommon(kinds, base) {
|
|
122
|
+
const common = [...(base.kinds.get('document')?.properties ?? [])].filter(
|
|
123
|
+
([name]) =>
|
|
124
|
+
[
|
|
125
|
+
'note',
|
|
126
|
+
'machine',
|
|
127
|
+
'theme',
|
|
128
|
+
'scheme',
|
|
129
|
+
'contrast',
|
|
130
|
+
'motion',
|
|
131
|
+
'sound',
|
|
132
|
+
'volume',
|
|
133
|
+
'transparency',
|
|
134
|
+
'material',
|
|
135
|
+
'text-style',
|
|
136
|
+
'appearance',
|
|
137
|
+
].includes(name)
|
|
138
|
+
);
|
|
139
|
+
for (const kind of kinds.values()) {
|
|
140
|
+
for (const [name, spec] of common) {
|
|
141
|
+
if (!kind.properties.has(name)) {
|
|
142
|
+
kind.properties.set(name, spec);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return kinds;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
let vocabulary = null;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* The ui-dialect vocabulary with the control kinds (cached).
|
|
153
|
+
* @returns {import('@link-foundation/ui-core').Vocabulary}
|
|
154
|
+
*/
|
|
155
|
+
export function controlsVocabulary() {
|
|
156
|
+
if (vocabulary === null) {
|
|
157
|
+
const base = defaultVocabulary();
|
|
158
|
+
vocabulary = Object.freeze({
|
|
159
|
+
...base,
|
|
160
|
+
kinds: new Map([...base.kinds, ...withCommon(read().kinds, base)]),
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
return vocabulary;
|
|
164
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
ui-list,
|
|
2
|
+
ui-tree,
|
|
3
|
+
ui-table {
|
|
4
|
+
display: block;
|
|
5
|
+
min-width: 0;
|
|
6
|
+
color: CanvasText;
|
|
7
|
+
background: Canvas;
|
|
8
|
+
border: 1px solid GrayText;
|
|
9
|
+
border-radius: 6px;
|
|
10
|
+
font: inherit;
|
|
11
|
+
}
|
|
12
|
+
.ui-data-scroll {
|
|
13
|
+
height: 320px;
|
|
14
|
+
overflow: auto;
|
|
15
|
+
position: relative;
|
|
16
|
+
overflow-anchor: none;
|
|
17
|
+
touch-action: pan-x pan-y;
|
|
18
|
+
}
|
|
19
|
+
.ui-data-body {
|
|
20
|
+
position: relative;
|
|
21
|
+
}
|
|
22
|
+
.ui-data-row {
|
|
23
|
+
box-sizing: border-box;
|
|
24
|
+
width: 100%;
|
|
25
|
+
padding: 6px 8px;
|
|
26
|
+
overflow-wrap: anywhere;
|
|
27
|
+
background: Canvas;
|
|
28
|
+
}
|
|
29
|
+
.ui-data-row[aria-selected='true'] {
|
|
30
|
+
background: Highlight;
|
|
31
|
+
color: HighlightText;
|
|
32
|
+
}
|
|
33
|
+
.ui-data-row:focus,
|
|
34
|
+
.ui-data-row [role='gridcell']:focus {
|
|
35
|
+
outline: 2px solid currentColor;
|
|
36
|
+
outline-offset: -3px;
|
|
37
|
+
}
|
|
38
|
+
.ui-data-row[role='treeitem'][aria-expanded]::before {
|
|
39
|
+
content: '▸ ';
|
|
40
|
+
}
|
|
41
|
+
.ui-data-row[role='treeitem'][aria-expanded='true']::before {
|
|
42
|
+
content: '▾ ';
|
|
43
|
+
}
|
|
44
|
+
.ui-data-header,
|
|
45
|
+
.ui-data-row[role='row'] {
|
|
46
|
+
display: grid;
|
|
47
|
+
padding: 0;
|
|
48
|
+
}
|
|
49
|
+
.ui-data-header {
|
|
50
|
+
position: sticky;
|
|
51
|
+
top: 0;
|
|
52
|
+
z-index: 1;
|
|
53
|
+
min-width: max-content;
|
|
54
|
+
background: Canvas;
|
|
55
|
+
border-bottom: 1px solid GrayText;
|
|
56
|
+
}
|
|
57
|
+
.ui-data-header [role='columnheader'] {
|
|
58
|
+
position: relative;
|
|
59
|
+
display: flex;
|
|
60
|
+
}
|
|
61
|
+
.ui-data-header button {
|
|
62
|
+
background: Canvas;
|
|
63
|
+
color: CanvasText;
|
|
64
|
+
border: 0;
|
|
65
|
+
font: inherit;
|
|
66
|
+
font-weight: bold;
|
|
67
|
+
padding: 8px;
|
|
68
|
+
width: 100%;
|
|
69
|
+
text-align: start;
|
|
70
|
+
}
|
|
71
|
+
.ui-data-header button:disabled {
|
|
72
|
+
opacity: 1;
|
|
73
|
+
}
|
|
74
|
+
.ui-data-resize {
|
|
75
|
+
width: 8px;
|
|
76
|
+
flex: 0 0 8px;
|
|
77
|
+
cursor: col-resize;
|
|
78
|
+
touch-action: none;
|
|
79
|
+
border-inline-end: 1px solid GrayText;
|
|
80
|
+
}
|
|
81
|
+
.ui-data-row [role='gridcell'] {
|
|
82
|
+
padding: 6px 8px;
|
|
83
|
+
min-width: 0;
|
|
84
|
+
}
|
|
85
|
+
.ui-data-caption {
|
|
86
|
+
padding: 8px;
|
|
87
|
+
font-weight: bold;
|
|
88
|
+
}
|
|
89
|
+
.ui-data-status:not(:empty) {
|
|
90
|
+
padding: 16px;
|
|
91
|
+
}
|
|
92
|
+
.ui-data-scroll[hidden],
|
|
93
|
+
.ui-data-caption[hidden] {
|
|
94
|
+
display: none;
|
|
95
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export interface DataItem {
|
|
2
|
+
id: string;
|
|
3
|
+
label?: string;
|
|
4
|
+
children?: DataItem[];
|
|
5
|
+
hasChildren?: boolean;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}
|
|
8
|
+
export interface DataSource<T = DataItem> {
|
|
9
|
+
get(): T[];
|
|
10
|
+
set(items: T[]): void;
|
|
11
|
+
subscribe(listener: (items: T[]) => void): () => void;
|
|
12
|
+
}
|
|
13
|
+
export function createDataSource<T = DataItem>(items?: T[]): DataSource<T>;
|
|
14
|
+
export function listOffsets(input: {
|
|
15
|
+
count: number;
|
|
16
|
+
estimate: number;
|
|
17
|
+
measured?: Map<number, number>;
|
|
18
|
+
}): Float64Array;
|
|
19
|
+
export function indexAt(offsets: Float64Array, y: number): number;
|
|
20
|
+
export function listRange(
|
|
21
|
+
offsets: Float64Array,
|
|
22
|
+
scrollTop: number,
|
|
23
|
+
viewportHeight: number,
|
|
24
|
+
overscan?: number
|
|
25
|
+
): { start: number; end: number };
|
|
26
|
+
export interface AnchorSnapshot {
|
|
27
|
+
keys: string[];
|
|
28
|
+
offsets: Float64Array;
|
|
29
|
+
scrollTop: number;
|
|
30
|
+
}
|
|
31
|
+
export function anchorScrollTop(
|
|
32
|
+
before: AnchorSnapshot,
|
|
33
|
+
after: Omit<AnchorSnapshot, 'scrollTop'>,
|
|
34
|
+
anchorKey: string
|
|
35
|
+
): number;
|
|
36
|
+
export function selectItem(input: {
|
|
37
|
+
keys: string[];
|
|
38
|
+
selected?: Set<string>;
|
|
39
|
+
anchor?: string | null;
|
|
40
|
+
key: string;
|
|
41
|
+
mode?: 'single' | 'multi' | 'none';
|
|
42
|
+
shift?: boolean;
|
|
43
|
+
toggle?: boolean;
|
|
44
|
+
}): { selected: Set<string>; anchor: string | null };
|
|
45
|
+
export interface DataSort {
|
|
46
|
+
column: string;
|
|
47
|
+
direction: 'ascending' | 'descending' | 'none';
|
|
48
|
+
}
|
|
49
|
+
export function nextSort(current: DataSort | null, column: string): DataSort;
|
|
50
|
+
export function sortItems<T>(
|
|
51
|
+
items: T[],
|
|
52
|
+
sort?: DataSort,
|
|
53
|
+
compare?: (a: T, b: T) => number
|
|
54
|
+
): T[];
|
|
55
|
+
export function dataVocabulary(): import('@link-foundation/ui-core').Vocabulary;
|
|
56
|
+
export const DATA_VOCABULARY_TEXT: string;
|
|
57
|
+
export function flattenTree(
|
|
58
|
+
items: DataItem[],
|
|
59
|
+
expanded: Set<string>,
|
|
60
|
+
loaded?: Map<string, DataItem[]>
|
|
61
|
+
): DataItem[];
|
|
62
|
+
|
|
63
|
+
/** Host adapters shared by the three registered kinds. */
|
|
64
|
+
export interface DataOptions {
|
|
65
|
+
sources?: Record<string, DataItem[] | Pick<DataSource, 'get' | 'subscribe'>>;
|
|
66
|
+
templates?: Record<
|
|
67
|
+
string,
|
|
68
|
+
(item: DataItem, context: { document: Document }) => string | Node
|
|
69
|
+
>;
|
|
70
|
+
loadChildren?(
|
|
71
|
+
item: DataItem,
|
|
72
|
+
context: { signal: AbortSignal }
|
|
73
|
+
): Promise<DataItem[]>;
|
|
74
|
+
clock?: {
|
|
75
|
+
setTimeout(fn: () => void, ms: number): unknown;
|
|
76
|
+
clearTimeout(handle: unknown): void;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
declare module '@link-foundation/ui-dom' {
|
|
80
|
+
interface RenderOptions {
|
|
81
|
+
data?: DataOptions;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Data display kinds and the DOM-free models reusable by the chat kit. */
|
|
2
|
+
export * from './virtual-range.js';
|
|
3
|
+
export * from './selection-model.js';
|
|
4
|
+
export * from './sort-model.js';
|
|
5
|
+
export { createDataSource } from './source.js';
|
|
6
|
+
export * from './tree-model.js';
|
|
7
|
+
export * from './vocabulary.js';
|
|
8
|
+
import { registerDataKind } from './list.js';
|
|
9
|
+
registerDataKind('tree');
|
|
10
|
+
registerDataKind('table');
|