@zeyos/zx 5.7.0 → 5.8.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/CHANGELOG.md +330 -0
- package/README.md +47 -9
- package/dist/types/components/activity-item/activity-item.d.ts +14 -3
- package/dist/types/components/agent-avatar/agent-avatar.d.ts +165 -0
- package/dist/types/components/agent-avatar/agent-face.d.ts +93 -0
- package/dist/types/components/agent-thread/ag-ui.d.ts +21 -9
- package/dist/types/components/agent-thread/agent-thread.d.ts +26 -0
- package/dist/types/components/agent-thread/ui-message-stream.d.ts +3 -1
- package/dist/types/components/approval-card/approval-card.d.ts +31 -2
- package/dist/types/components/aurora/aurora.d.ts +31 -5
- package/dist/types/components/calendar/calendar.d.ts +39 -26
- package/dist/types/components/chart/chart.d.ts +250 -20
- package/dist/types/components/chart/color.d.ts +66 -0
- package/dist/types/components/chart/svg-adapter.d.ts +103 -0
- package/dist/types/components/chart/svg-geometry.d.ts +203 -0
- package/dist/types/components/check-button/check-button.d.ts +1 -4
- package/dist/types/components/checklist/checklist.d.ts +48 -5
- package/dist/types/components/code-editor/code-editor.d.ts +55 -1
- package/dist/types/components/composer/composer.d.ts +41 -6
- package/dist/types/components/context-menu/context-menu.d.ts +36 -8
- package/dist/types/components/copy/copy-button.d.ts +6 -0
- package/dist/types/components/copy/copy-input.d.ts +1 -0
- package/dist/types/components/date-picker/date-picker.d.ts +14 -0
- package/dist/types/components/date-picker/time-picker.d.ts +26 -17
- package/dist/types/components/datebox/datebox.d.ts +8 -4
- package/dist/types/components/dialog/dialog.d.ts +15 -4
- package/dist/types/components/empty-state/empty-state.d.ts +10 -1
- package/dist/types/components/field/field.d.ts +4 -2
- package/dist/types/components/form/form.d.ts +2 -1
- package/dist/types/components/kanban-view/kanban-card.d.ts +7 -0
- package/dist/types/components/kanban-view/kanban-view.d.ts +15 -3
- package/dist/types/components/launcher/launcher.d.ts +26 -0
- package/dist/types/components/master-panel/master-panel.d.ts +9 -4
- package/dist/types/components/menu-button/menu-button.d.ts +29 -5
- package/dist/types/components/message/message.d.ts +308 -5
- package/dist/types/components/modal/modal.d.ts +45 -8
- package/dist/types/components/modal/native-dialog.d.ts +40 -0
- package/dist/types/components/module-bar/module-bar.d.ts +9 -2
- package/dist/types/components/multi-value-editor/multi-value-editor.d.ts +5 -4
- package/dist/types/components/number-field/number-field.d.ts +31 -1
- package/dist/types/components/pagination/pagination.d.ts +341 -19
- package/dist/types/components/run-status/run-status.d.ts +26 -0
- package/dist/types/components/run-trace/run-trace.d.ts +10 -6
- package/dist/types/components/search/search.d.ts +16 -4
- package/dist/types/components/select/select.d.ts +19 -1
- package/dist/types/components/sheet/sheet.d.ts +20 -6
- package/dist/types/components/slider/slider.d.ts +2 -1
- package/dist/types/components/stat-tile/stat-tile.d.ts +20 -3
- package/dist/types/components/stepper/stepper.d.ts +17 -4
- package/dist/types/components/surface/catalog.d.ts +61 -17
- package/dist/types/components/surface/surface.d.ts +6 -4
- package/dist/types/components/table/table.d.ts +207 -5
- package/dist/types/components/table/window.d.ts +25 -1
- package/dist/types/components/toggle/toggle.d.ts +38 -6
- package/dist/types/components/tooltip/tooltip.d.ts +5 -4
- package/dist/types/components/tree/tree.d.ts +43 -6
- package/dist/types/components/truncate/truncate.d.ts +4 -2
- package/dist/types/components/value-list/value-list.d.ts +9 -2
- package/dist/types/core/date.d.ts +2 -1
- package/dist/types/core/dom.d.ts +14 -0
- package/dist/types/core/drag-axis.d.ts +10 -5
- package/dist/types/core/export.d.ts +2 -2
- package/dist/types/core/format.d.ts +3 -1
- package/dist/types/core/icons.d.ts +36 -3
- package/dist/types/core/keyboard.d.ts +7 -3
- package/dist/types/core/messages.d.ts +3 -0
- package/dist/types/core/storage.d.ts +4 -3
- package/dist/types/core/util.d.ts +3 -1
- package/dist/types/elements/define.d.ts +5 -2
- package/dist/types/index.d.ts +6 -4
- package/dist/types/internal/agent-model.d.ts +99 -0
- package/dist/types/internal/app-rail.d.ts +37 -2
- package/dist/types/internal/collections.d.ts +18 -0
- package/dist/types/internal/menu-items.d.ts +27 -0
- package/dist/types/internal/overlay-content.d.ts +23 -0
- package/dist/types/internal/presence-loop.d.ts +5 -2
- package/dist/types/locales/index.d.ts +3 -0
- package/dist/types/zeyos/calendar.d.ts +43 -7
- package/dist/types/zeyos/connect.d.ts +4 -0
- package/dist/types/zeyos/form.d.ts +13 -5
- package/dist/types/zeyos/select.d.ts +5 -2
- package/dist/types/zeyos/table.d.ts +16 -8
- package/dist/types/zeyos/view.d.ts +2 -1
- package/dist/zx-zeyos.esm.js +3161 -515
- package/dist/zx-zeyos.esm.min.js +4 -4
- package/dist/zx.core.css +4 -0
- package/dist/zx.core.min.css +1 -1
- package/dist/zx.css +970 -57
- package/dist/zx.esm.js +6405 -2249
- package/dist/zx.esm.min.js +26 -26
- package/dist/zx.global.js +6405 -2249
- package/dist/zx.global.min.js +26 -26
- package/dist/zx.layered.css +972 -57
- package/dist/zx.layered.min.css +1 -1
- package/dist/zx.min.css +1 -1
- package/docs/agent-catalog.json +159 -1
- package/docs/agent-surfaces.md +21 -21
- package/docs/api.json +3154 -518
- package/docs/components/account-menu.md +24 -0
- package/docs/components/activity-item.md +23 -0
- package/docs/components/activity-list.md +28 -0
- package/docs/components/agent-avatar.md +59 -0
- package/docs/components/agent-thread.md +275 -0
- package/docs/components/app-icon.md +36 -0
- package/docs/components/app-sidebar.md +92 -0
- package/docs/components/approval-card.md +71 -0
- package/docs/components/aurora.md +34 -0
- package/docs/components/avatar.md +37 -0
- package/docs/components/badge.md +36 -0
- package/docs/components/block-view.md +34 -0
- package/docs/components/breadcrumb.md +20 -0
- package/docs/components/button.md +23 -0
- package/docs/components/calendar.md +68 -0
- package/docs/components/card-view.md +73 -0
- package/docs/components/card.md +25 -0
- package/docs/components/chart.md +109 -0
- package/docs/components/check-button.md +16 -0
- package/docs/components/checklist.md +19 -0
- package/docs/components/code-editor.md +38 -0
- package/docs/components/composer.md +107 -0
- package/docs/components/context-menu.md +32 -0
- package/docs/components/copy.md +37 -0
- package/docs/components/data-filter.md +16 -0
- package/docs/components/date-picker.md +31 -0
- package/docs/components/date-range.md +21 -0
- package/docs/components/datebox.md +31 -0
- package/docs/components/dialog.md +25 -0
- package/docs/components/dock.md +57 -0
- package/docs/components/dropdown.md +39 -0
- package/docs/components/elements.md +63 -0
- package/docs/components/empty-state.md +17 -0
- package/docs/components/entity-ref.md +26 -0
- package/docs/components/field-upload.md +18 -0
- package/docs/components/file-item.md +27 -0
- package/docs/components/file-list.md +23 -0
- package/docs/components/filter-panel.md +45 -0
- package/docs/components/filter.md +47 -0
- package/docs/components/finder.md +25 -0
- package/docs/components/form-widgets.md +42 -0
- package/docs/components/form.md +80 -0
- package/docs/components/grid.md +26 -0
- package/docs/components/groupbox.md +11 -0
- package/docs/components/helpers.md +359 -0
- package/docs/components/icons.md +87 -0
- package/docs/components/index.md +99 -0
- package/docs/components/kanban-view.md +42 -0
- package/docs/components/kbd.md +23 -0
- package/docs/components/kernel.md +41 -0
- package/docs/components/launcher.md +66 -0
- package/docs/components/layout.md +33 -0
- package/docs/components/list-toolbar.md +38 -0
- package/docs/components/loading.md +48 -0
- package/docs/components/menu-button.md +47 -0
- package/docs/components/message.md +76 -0
- package/docs/components/modal.md +27 -0
- package/docs/components/module-bar.md +71 -0
- package/docs/components/multi-value-editor.md +16 -0
- package/docs/components/navigation-bar.md +22 -0
- package/docs/components/number-field.md +34 -0
- package/docs/components/pagination.md +73 -0
- package/docs/components/panel.md +28 -0
- package/docs/components/prompt-starters.md +40 -0
- package/docs/components/prose.md +38 -0
- package/docs/components/questionnaire.md +115 -0
- package/docs/components/rating.md +19 -0
- package/docs/components/run-status.md +50 -0
- package/docs/components/run-trace.md +72 -0
- package/docs/components/search.md +11 -0
- package/docs/components/select.md +129 -0
- package/docs/components/sheet-stack.md +39 -0
- package/docs/components/sheet.md +77 -0
- package/docs/components/skeleton.md +27 -0
- package/docs/components/slider.md +29 -0
- package/docs/components/sort-control.md +21 -0
- package/docs/components/source-list.md +30 -0
- package/docs/components/split-view.md +12 -0
- package/docs/components/stat-tile.md +49 -0
- package/docs/components/stepper.md +27 -0
- package/docs/components/surface.md +152 -0
- package/docs/components/tabbox.md +33 -0
- package/docs/components/table-view.md +43 -0
- package/docs/components/table.md +232 -0
- package/docs/components/tag-picker.md +39 -0
- package/docs/components/timebox.md +16 -0
- package/docs/components/toggle.md +21 -0
- package/docs/components/tokens.md +82 -0
- package/docs/components/toolbar.md +26 -0
- package/docs/components/tooltip.md +16 -0
- package/docs/components/tree.md +48 -0
- package/docs/components/truncate.md +21 -0
- package/docs/components/value-list.md +14 -0
- package/docs/components/view-settings.md +56 -0
- package/docs/components/workspace-switcher.md +42 -0
- package/docs/components/zeyos.md +196 -0
- package/docs/llms-small.txt +299 -0
- package/docs/llms.md +725 -109
- package/docs/llms.txt +46 -19
- package/package.json +9 -4
- package/src/components/activity-item/activity-item.js +21 -2
- package/src/components/agent-avatar/agent-avatar.css +195 -0
- package/src/components/agent-avatar/agent-avatar.js +333 -0
- package/src/components/agent-avatar/agent-face.js +292 -0
- package/src/components/agent-thread/ag-ui.js +44 -11
- package/src/components/agent-thread/agent-thread.js +103 -11
- package/src/components/agent-thread/ui-message-stream.js +3 -1
- package/src/components/app-rail/app-rail.css +5 -0
- package/src/components/app-sidebar/app-sidebar.css +3 -0
- package/src/components/app-sidebar/app-sidebar.js +4 -3
- package/src/components/approval-card/approval-card.css +6 -0
- package/src/components/approval-card/approval-card.js +55 -7
- package/src/components/aurora/aurora.css +149 -14
- package/src/components/aurora/aurora.js +49 -6
- package/src/components/button/button.css +24 -11
- package/src/components/calendar/calendar.css +6 -2
- package/src/components/calendar/calendar.js +127 -47
- package/src/components/card-view/card-view.js +5 -6
- package/src/components/chart/chart.css +159 -1
- package/src/components/chart/chart.js +450 -62
- package/src/components/chart/color.js +297 -0
- package/src/components/chart/svg-adapter.js +576 -0
- package/src/components/chart/svg-geometry.js +323 -0
- package/src/components/check-button/check-button.js +3 -18
- package/src/components/checklist/checklist.css +9 -1
- package/src/components/checklist/checklist.js +105 -20
- package/src/components/checklist/field-adapter.js +6 -12
- package/src/components/code-editor/code-editor.css +33 -0
- package/src/components/code-editor/code-editor.js +97 -8
- package/src/components/code-editor/field-adapter.js +3 -0
- package/src/components/composer/composer.css +3 -0
- package/src/components/composer/composer.js +100 -22
- package/src/components/context-menu/context-menu.js +41 -5
- package/src/components/copy/copy-button.js +9 -1
- package/src/components/copy/copy-input.js +5 -0
- package/src/components/data-filter/filter-core.js +0 -1
- package/src/components/date-picker/date-picker.css +8 -0
- package/src/components/date-picker/date-picker.js +47 -8
- package/src/components/date-picker/date-range-picker.js +1 -1
- package/src/components/date-picker/month-picker.js +19 -3
- package/src/components/date-picker/time-picker.js +54 -19
- package/src/components/datebox/date-range-box.js +7 -3
- package/src/components/datebox/datebox.js +32 -6
- package/src/components/dialog/dialog.css +6 -0
- package/src/components/dialog/dialog.js +24 -33
- package/src/components/dropdown/dropdown.js +1 -18
- package/src/components/empty-state/empty-state.js +21 -2
- package/src/components/field/field.js +19 -3
- package/src/components/fieldset/fieldset.js +3 -1
- package/src/components/filter/filter.js +9 -0
- package/src/components/form/form.js +19 -2
- package/src/components/kanban-view/kanban-card.js +15 -2
- package/src/components/kanban-view/kanban-view.css +21 -0
- package/src/components/kanban-view/kanban-view.js +29 -16
- package/src/components/launcher/launcher.css +14 -0
- package/src/components/launcher/launcher.js +54 -9
- package/src/components/master-panel/master-panel.js +24 -22
- package/src/components/menu-button/menu-button.js +26 -4
- package/src/components/message/message.css +228 -29
- package/src/components/message/message.js +664 -30
- package/src/components/modal/modal.js +129 -30
- package/src/components/modal/native-dialog.js +91 -0
- package/src/components/module-bar/module-bar.css +3 -0
- package/src/components/module-bar/module-bar.js +17 -4
- package/src/components/multi-value-editor/multi-value-editor.css +7 -2
- package/src/components/multi-value-editor/multi-value-editor.js +3 -2
- package/src/components/navigation-bar/navigation-bar.js +13 -1
- package/src/components/number-field/field-adapter.js +3 -0
- package/src/components/number-field/number-field.js +70 -16
- package/src/components/pagination/pagination.css +26 -2
- package/src/components/pagination/pagination.js +551 -65
- package/src/components/prose/prose.js +7 -1
- package/src/components/rating/field-adapter.js +3 -0
- package/src/components/run-status/run-status.js +43 -3
- package/src/components/run-trace/run-trace.js +15 -7
- package/src/components/search/search.js +3 -18
- package/src/components/select/field-adapter.js +8 -1
- package/src/components/select/select.js +68 -13
- package/src/components/sheet/sheet.js +39 -13
- package/src/components/slider/field-adapter.js +3 -0
- package/src/components/slider/slider.js +4 -6
- package/src/components/stat-tile/stat-tile.js +24 -9
- package/src/components/stepper/stepper.css +15 -0
- package/src/components/stepper/stepper.js +34 -2
- package/src/components/surface/catalog.js +185 -28
- package/src/components/surface/surface.js +10 -5
- package/src/components/tabbox/tabbox.js +13 -1
- package/src/components/table/table.css +160 -2
- package/src/components/table/table.js +479 -52
- package/src/components/table/window.js +46 -4
- package/src/components/table-view/table-view.js +1 -10
- package/src/components/tag-picker/field-adapter.js +3 -0
- package/src/components/tag-picker/tag-picker.js +2 -0
- package/src/components/timebox/field-adapter.js +3 -0
- package/src/components/toggle/toggle.js +51 -27
- package/src/components/tooltip/tooltip.js +21 -14
- package/src/components/tree/tree.js +87 -14
- package/src/components/truncate/truncate.js +21 -5
- package/src/components/value-list/value-list.js +37 -9
- package/src/components/view-settings/view-settings.js +1 -5
- package/src/core/component.js +34 -2
- package/src/core/date.js +5 -4
- package/src/core/dom.js +45 -2
- package/src/core/drag-axis.js +24 -7
- package/src/core/export.js +4 -4
- package/src/core/fontawesome.js +34 -3
- package/src/core/format.js +3 -1
- package/src/core/http.js +23 -11
- package/src/core/icons.js +60 -8
- package/src/core/keyboard.js +83 -9
- package/src/core/messages.js +3 -0
- package/src/core/position.js +4 -3
- package/src/core/storage.js +80 -31
- package/src/core/util.js +16 -5
- package/src/elements/define.js +82 -47
- package/src/elements/kit.js +46 -35
- package/src/index.js +8 -4
- package/src/internal/agent-model.js +152 -0
- package/src/internal/app-rail.js +53 -2
- package/src/internal/collections.js +25 -0
- package/src/internal/menu-items.js +59 -0
- package/src/internal/overlay-content.js +35 -0
- package/src/internal/presence-loop.js +61 -14
- package/src/locales/de.js +3 -0
- package/src/zeyos/calendar.js +81 -19
- package/src/zeyos/connect.js +5 -1
- package/src/zeyos/form.js +29 -10
- package/src/zeyos/select.js +36 -12
- package/src/zeyos/table.js +43 -11
- package/src/zeyos/view.js +2 -1
- package/styles/tokens/semantic.css +7 -1
- package/styles/zx.css +1 -0
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* events, never through the model.
|
|
10
10
|
*/
|
|
11
11
|
import { formatNumber } from '../core/format.js';
|
|
12
|
+
import { escapeRegExp } from '../core/util.js';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Where a run, or one step of it, stands.
|
|
@@ -101,6 +102,24 @@ import { formatNumber } from '../core/format.js';
|
|
|
101
102
|
* @property {AgentActivity|null} [activity] What an agent is doing now.
|
|
102
103
|
* @property {string} [via] The model an agent answers through, shown in the byline.
|
|
103
104
|
* @property {string} [icon] A glyph drawn in a tinted tile instead of initials — a model's mark.
|
|
105
|
+
* @property {AuthorFace|true} [face] Draws an agent as a generated AgentAvatar face instead of
|
|
106
|
+
* initials or an `icon` tile: its options, or `true` to derive everything from the name. A person
|
|
107
|
+
* ignores it.
|
|
108
|
+
*/
|
|
109
|
+
/**
|
|
110
|
+
* The AgentAvatar options an author's face takes; name, size, label and activity come from the
|
|
111
|
+
* author and the place it is drawn. `seed` is what keeps the face — the agent's stable id; a
|
|
112
|
+
* number is read as text, so `42` and `'42'` are one face. `spacing` is the trait
|
|
113
|
+
* `AgentAvatar.getTraits()` reports, for a look stored once.
|
|
114
|
+
* @typedef {{seed?: string|number, tone?: string, body?: string, eyes?: string, material?: 'flat'|'soft',
|
|
115
|
+
* spacing?: 0|1|2}} AuthorFace
|
|
116
|
+
*/
|
|
117
|
+
/**
|
|
118
|
+
* An agent drawn as its AgentAvatar face where a component would otherwise draw an icon: the
|
|
119
|
+
* face's traits and the agent's name. Size, label, activity and motion come from the place it is
|
|
120
|
+
* drawn. The face is keyed by `seed`, else by `name`; give one of them, since a face drawn without
|
|
121
|
+
* either is named after the place it stands in.
|
|
122
|
+
* @typedef {AuthorFace & {name?: string}} AgentFace
|
|
104
123
|
*/
|
|
105
124
|
|
|
106
125
|
/** @typedef {{name: string, size?: number, type?: string}} Attachment */
|
|
@@ -170,6 +189,23 @@ export const ACTIVITY = Object.freeze({
|
|
|
170
189
|
offline: { tone: 'muted', key: 'agent.activity.offline' }
|
|
171
190
|
});
|
|
172
191
|
|
|
192
|
+
/**
|
|
193
|
+
* The expression an agent's face takes while its run stands in each state: working while it runs,
|
|
194
|
+
* needs-you while it waits for a person, blocked when blocked or failed, and at rest otherwise.
|
|
195
|
+
* @type {Readonly<Record<RunState, AgentActivity>>}
|
|
196
|
+
*/
|
|
197
|
+
export const RUN_ACTIVITY = Object.freeze({
|
|
198
|
+
queued: 'idle',
|
|
199
|
+
running: 'working',
|
|
200
|
+
waiting: 'needs-you',
|
|
201
|
+
paused: 'idle',
|
|
202
|
+
blocked: 'blocked',
|
|
203
|
+
done: 'idle',
|
|
204
|
+
failed: 'blocked',
|
|
205
|
+
stopped: 'idle',
|
|
206
|
+
skipped: 'idle'
|
|
207
|
+
});
|
|
208
|
+
|
|
173
209
|
/**
|
|
174
210
|
* The English words for `STATUS` and `ACTIVITY`, for a component's `msg` defaults.
|
|
175
211
|
* @type {Readonly<Record<string, string>>}
|
|
@@ -486,3 +522,119 @@ export function initialsOf(name) {
|
|
|
486
522
|
const letters = words.length === 1 ? [...words[0]].slice(0, 2) : [[...words[0]][0], [...words.at(-1) ?? ''][0]];
|
|
487
523
|
return letters.join('').toUpperCase();
|
|
488
524
|
}
|
|
525
|
+
|
|
526
|
+
/** The options that say which face an agent has, never how a place draws it. */
|
|
527
|
+
const FACE_KEYS = Object.freeze(['seed', 'tone', 'body', 'eyes', 'material', 'spacing']);
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* What an item's `agent` may set beyond its face where navigation, the Composer and the Launcher
|
|
531
|
+
* draw it: what the agent is doing and how that shows. Size, label and motion stay the place's.
|
|
532
|
+
* @type {ReadonlyArray<string>}
|
|
533
|
+
*/
|
|
534
|
+
export const AGENT_ITEM_KEYS = Object.freeze(['activity', 'activityLabel', 'indicator', 'msg']);
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* Reads a face from what describes it: `true` derives everything, a plain object contributes the
|
|
538
|
+
* `keys` it holds — non-empty strings, a `seed` that is a finite number as text, a `spacing` of 0,
|
|
539
|
+
* 1 or 2 — and anything else is no face.
|
|
540
|
+
* @param {unknown} source
|
|
541
|
+
* @param {ReadonlyArray<string>} keys
|
|
542
|
+
* @returns {Record<string, string|number>|null}
|
|
543
|
+
*/
|
|
544
|
+
function readFace(source, keys) {
|
|
545
|
+
if (source === true) return {};
|
|
546
|
+
if (!source || typeof source !== 'object' || Array.isArray(source)) return null;
|
|
547
|
+
/** @type {Record<string, string|number>} */
|
|
548
|
+
const traits = {};
|
|
549
|
+
for (const key of keys) {
|
|
550
|
+
const value = /** @type {Record<string, unknown>} */ (source)[key];
|
|
551
|
+
if (key === 'spacing') {
|
|
552
|
+
if (value === 0 || value === 1 || value === 2) traits.spacing = value;
|
|
553
|
+
} else if (key === 'seed' && typeof value === 'number' && Number.isFinite(value)) {
|
|
554
|
+
traits.seed = String(value);
|
|
555
|
+
} else if (typeof value === 'string' && value) {
|
|
556
|
+
traits[key] = value;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
return traits;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* The face an author asks for, reduced to the traits it may set, or null for none: `face: true`
|
|
564
|
+
* derives everything, a plain object contributes its `seed`, `tone`, `body`, `eyes`, `material`
|
|
565
|
+
* and `spacing`, and anything else — a person, another value — means initials. Authors may come
|
|
566
|
+
* from an agent's own data, so how the face is drawn and named is never read from it.
|
|
567
|
+
* @param {Partial<Author>|null|undefined} author
|
|
568
|
+
* @returns {AuthorFace|null}
|
|
569
|
+
*/
|
|
570
|
+
export function authorFace(author) {
|
|
571
|
+
if (!author || author.kind === 'person') return null;
|
|
572
|
+
return /** @type {AuthorFace|null} */ (readFace(author.face, FACE_KEYS));
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* What an `agent` option asks for, read as {@link authorFace} reads a `face` — `true` derives
|
|
577
|
+
* everything, a plain object contributes its traits and its `name`, anything else is no face.
|
|
578
|
+
* Size, label, activity and motion always belong to the place the face is drawn.
|
|
579
|
+
* @param {unknown} agent
|
|
580
|
+
* @returns {AgentFace|null}
|
|
581
|
+
*/
|
|
582
|
+
export function agentFaceTraits(agent) {
|
|
583
|
+
return /** @type {AgentFace|null} */ (readFace(agent, [...FACE_KEYS, 'name']));
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* The options of the AgentAvatar a component draws for an agent: the one way every component
|
|
588
|
+
* builds one, so an agent described the same way has the same face wherever it is drawn.
|
|
589
|
+
*
|
|
590
|
+
* Only what says which face it is comes from `source` — its `seed` (a string, or a finite number
|
|
591
|
+
* read as text), its `tone`, `body`, `eyes`, `material` and `name` strings and its `spacing` —
|
|
592
|
+
* plus the `carry` keys a place lets its data set, as navigation lets an item show what its agent
|
|
593
|
+
* is doing ({@link AGENT_ITEM_KEYS}). Nothing else in it is read, so data never decides how a face
|
|
594
|
+
* is sized, labelled or moved. `fallback` fills in what the source leaves out, such as the name of
|
|
595
|
+
* the row it stands in; `fixed` always wins: the place's size, label and motion.
|
|
596
|
+
*
|
|
597
|
+
* The seed keeps a face. A component reads a fallback name once, when it builds the avatar, and
|
|
598
|
+
* keeps that avatar while the source asks for the same traits, so a summary or a title that
|
|
599
|
+
* changes later never changes the face.
|
|
600
|
+
* @param {unknown} source `true`, or a plain object: an `agent` option, an item's `agent`, or an
|
|
601
|
+
* author's face as {@link authorFace} reads it.
|
|
602
|
+
* @param {Record<string, unknown>} [fixed={}] What the place decides; it wins over everything.
|
|
603
|
+
* @param {{fallback?: Record<string, unknown>, carry?: ReadonlyArray<string>}} [options={}]
|
|
604
|
+
* @returns {Record<string, any>|null} The options, or null when the source asks for no face.
|
|
605
|
+
*/
|
|
606
|
+
export function agentAvatarOptions(source, fixed = {}, options = {}) {
|
|
607
|
+
const traits = agentFaceTraits(source);
|
|
608
|
+
if (!traits) return null;
|
|
609
|
+
/** @type {Record<string, unknown>} */
|
|
610
|
+
const carried = {};
|
|
611
|
+
if (source && typeof source === 'object') {
|
|
612
|
+
for (const key of options.carry ?? []) {
|
|
613
|
+
const value = /** @type {Record<string, unknown>} */ (source)[key];
|
|
614
|
+
if (value !== undefined) carried[key] = value;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
return { ...(options.fallback ?? {}), ...traits, ...carried, ...fixed };
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
/* ------------------------------------------------------------------ mentions -- */
|
|
621
|
+
|
|
622
|
+
/** What a mention may not run into on either side: a letter, mark, digit or underscore, in any script. */
|
|
623
|
+
const MENTION_WORD = '[\\p{L}\\p{M}\\p{N}_]';
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* A pattern that finds each `@name` of `names` in a text as a whole mention: the trigger not right
|
|
627
|
+
* after a letter, mark, digit or underscore of any script, so `ann@ledger.example` mentions
|
|
628
|
+
* nobody, and the name not right before one, so `@Annabel` does not mention Ann. Where names
|
|
629
|
+
* overlap the longest one is found. The Composer reads mentions back from its text and AgentThread
|
|
630
|
+
* marks them by this one rule.
|
|
631
|
+
* @param {Iterable<unknown>} names Names without the trigger.
|
|
632
|
+
* @param {string} [trigger='@']
|
|
633
|
+
* @returns {RegExp|null} A global pattern, or null without a name.
|
|
634
|
+
*/
|
|
635
|
+
export function mentionPattern(names, trigger = '@') {
|
|
636
|
+
const list = [...names].map((name) => String(name ?? '')).filter(Boolean)
|
|
637
|
+
.sort((a, b) => b.length - a.length).map(escapeRegExp);
|
|
638
|
+
if (!list.length) return null;
|
|
639
|
+
return new RegExp(`(?<!${MENTION_WORD})${escapeRegExp(String(trigger || '@'))}(?:${list.join('|')})(?!${MENTION_WORD})`, 'gu');
|
|
640
|
+
}
|
package/src/internal/app-rail.js
CHANGED
|
@@ -4,12 +4,19 @@ import { h, safeHref } from '../core/dom.js';
|
|
|
4
4
|
import { icon } from '../core/icons.js';
|
|
5
5
|
import { Dropdown } from '../components/dropdown/dropdown.js';
|
|
6
6
|
import { Tooltip } from '../components/tooltip/tooltip.js';
|
|
7
|
+
import { AgentAvatar } from '../components/agent-avatar/agent-avatar.js';
|
|
8
|
+
import { AGENT_ITEM_KEYS, agentAvatarOptions } from './agent-model.js';
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
11
|
* @typedef {Object} AppNavItem
|
|
10
12
|
* @property {string|number} id Stable item identifier.
|
|
11
13
|
* @property {string} label Visible/accessibility label.
|
|
12
14
|
* @property {string|Node|{toElement: () => Node|null}|((context: Record<string, any>, item: AppNavItem) => Node|null)} [icon] Icon name, node, component, or factory.
|
|
15
|
+
* @property {AppNavAgent|true} [agent] Draws the item as an agent: an AgentAvatar built from these
|
|
16
|
+
* options (`true` for none) in place of `icon`, sized by the slot it sits in. `name` defaults to
|
|
17
|
+
* the item's label. The face shows the agent's `activity` at rest — navigation does not animate —
|
|
18
|
+
* at the small level of detail and flat, whatever the slot measures, and the activity's word
|
|
19
|
+
* joins the control's accessible name ("Ledger, Needs you").
|
|
13
20
|
* @property {string|number} [badge] Count or status badge.
|
|
14
21
|
* @property {unknown} [value] Emitted value; defaults to `id`.
|
|
15
22
|
* @property {string} [href] Native navigation target; executable/data schemes are disabled.
|
|
@@ -25,6 +32,10 @@ import { Tooltip } from '../components/tooltip/tooltip.js';
|
|
|
25
32
|
* danger?}` descriptors or nodes, revealed with the row, in its context menu, and after its
|
|
26
33
|
* control in the Tab order while it holds focus. Minimized flyouts show destinations only.
|
|
27
34
|
*/
|
|
35
|
+
/**
|
|
36
|
+
* The AgentAvatar options a navigation item may carry. Size, label and motion belong to the slot.
|
|
37
|
+
* @typedef {Omit<import('../components/agent-avatar/agent-avatar.js').AgentAvatarOptions, 'size'|'label'|'animate'|'phase'>} AppNavAgent
|
|
38
|
+
*/
|
|
28
39
|
/**
|
|
29
40
|
* @typedef {Object} AppRailPresenterOptions
|
|
30
41
|
* @property {AppNavItem[]} [items=[]] Application navigation tree.
|
|
@@ -202,7 +213,7 @@ export class AppRailPresenter extends Component {
|
|
|
202
213
|
return this;
|
|
203
214
|
}
|
|
204
215
|
|
|
205
|
-
/** Reports whether a node belongs to this rail, including detached flyout panels. @param {Node|null} node @returns {boolean} @
|
|
216
|
+
/** Reports whether a node belongs to this rail, including detached flyout panels. @param {Node|null} node @returns {boolean} @protected */
|
|
206
217
|
_containsNode(node) {
|
|
207
218
|
return Boolean(node && (this.el.contains(node)
|
|
208
219
|
|| [...this._flyouts.values()].some((flyout) => flyout.panel.contains(node))));
|
|
@@ -727,6 +738,19 @@ export function normalizeAppItems(items) {
|
|
|
727
738
|
*/
|
|
728
739
|
export function appNavIcon(item, renderer, context) {
|
|
729
740
|
let visual = typeof renderer === 'function' ? renderer(item, context) : null;
|
|
741
|
+
const agent = visual == null ? agentAvatarOptions(item.agent || null, {
|
|
742
|
+
// Navigation draws every face at the small level of detail, whatever its slot measures (24px
|
|
743
|
+
// rows, a 26px tile, a 34px catalogue tile): one calm, flat look across a menu, so a soft
|
|
744
|
+
// material is drawn flat here by design.
|
|
745
|
+
size: 'sm',
|
|
746
|
+
label: null,
|
|
747
|
+
animate: false
|
|
748
|
+
}, { fallback: { name: item.label }, carry: AGENT_ITEM_KEYS }) : null;
|
|
749
|
+
if (agent) {
|
|
750
|
+
// A fresh avatar per place it is drawn. Navigation draws it at rest, so it holds no listener
|
|
751
|
+
// and no loop entry, and is released with the row that holds it.
|
|
752
|
+
return new AgentAvatar(null, agent).toElement();
|
|
753
|
+
}
|
|
730
754
|
if (visual == null) visual = item.icon;
|
|
731
755
|
if (typeof visual === 'function') visual = visual(context, item);
|
|
732
756
|
if (typeof visual === 'string') return icon(visual);
|
|
@@ -739,9 +763,36 @@ export function appNavIcon(item, renderer, context) {
|
|
|
739
763
|
return null;
|
|
740
764
|
}
|
|
741
765
|
|
|
766
|
+
/**
|
|
767
|
+
* The word for what an agent drawn by {@link appNavIcon} is doing, or null for any other visual.
|
|
768
|
+
* @param {Node|null|undefined} visual
|
|
769
|
+
* @returns {string|null}
|
|
770
|
+
*/
|
|
771
|
+
export function appNavAgentWord(visual) {
|
|
772
|
+
const avatar = visual instanceof Element ? Component.from(visual) : null;
|
|
773
|
+
return avatar instanceof AgentAvatar ? avatar.getActivityWord() : null;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
/**
|
|
777
|
+
* A navigation control's accessible name: its label, followed by an agent's activity when the
|
|
778
|
+
* visual is one. The visible label stays first, so the name still starts with what is shown.
|
|
779
|
+
* A control whose badge is printed inside it, and which this name replaces, passes `withBadge` so
|
|
780
|
+
* the count is not lost: "Ledger, Needs you (2)".
|
|
781
|
+
* @param {AppNavItem} item
|
|
782
|
+
* @param {Node|null|undefined} visual
|
|
783
|
+
* @param {boolean} [withBadge=false] Whether to end the name with the item's badge.
|
|
784
|
+
* @returns {string}
|
|
785
|
+
*/
|
|
786
|
+
export function appNavName(item, visual, withBadge = false) {
|
|
787
|
+
const word = appNavAgentWord(visual);
|
|
788
|
+
const name = word ? `${item.label}, ${word}` : item.label;
|
|
789
|
+
return withBadge && item.badge != null && item.badge !== '' ? `${name} (${item.badge})` : name;
|
|
790
|
+
}
|
|
791
|
+
|
|
742
792
|
/** @param {AppNavItem} item @param {{className: string, index: string, iconOnly: boolean, disclosure: boolean, disclosureIcon: string, visual: Node|null}} options @returns {HTMLElement} */
|
|
743
793
|
function navControl(item, { className, index, iconOnly, disclosure, disclosureIcon, visual }) {
|
|
744
794
|
const href = safeHref(item.href);
|
|
795
|
+
const named = appNavAgentWord(visual) !== null;
|
|
745
796
|
const tag = href && !disclosure ? 'a' : 'button';
|
|
746
797
|
return /** @type {HTMLElement} */ (h(tag, {
|
|
747
798
|
class: className,
|
|
@@ -749,7 +800,7 @@ function navControl(item, { className, index, iconOnly, disclosure, disclosureIc
|
|
|
749
800
|
href: tag === 'a' ? href : null,
|
|
750
801
|
target: tag === 'a' ? item.target ?? null : null,
|
|
751
802
|
rel: tag === 'a' ? 'noopener' : null,
|
|
752
|
-
ariaLabel: iconOnly ? item
|
|
803
|
+
ariaLabel: iconOnly ? appNavName(item, visual) : named ? appNavName(item, visual, true) : null,
|
|
753
804
|
ariaDisabled: item.disabled ? 'true' : null,
|
|
754
805
|
dataset: { appNavId: index, appNavValueId: String(item.id) }
|
|
755
806
|
},
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
/**
|
|
3
|
+
* Equality checks over the small collections components keep for their state — selections,
|
|
4
|
+
* hidden fields, orders — so a setter can tell a real change from a repeat and stay silent.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Whether two sets hold the same members, in any order.
|
|
9
|
+
* @param {Set<unknown>} left One set.
|
|
10
|
+
* @param {Set<unknown>} right The other.
|
|
11
|
+
* @returns {boolean}
|
|
12
|
+
*/
|
|
13
|
+
export function sameSet(left, right) {
|
|
14
|
+
return left.size === right.size && [...left].every((value) => right.has(value));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Whether two arrays hold the same entries in the same order, compared with `Object.is`.
|
|
19
|
+
* @param {unknown[]} left One array.
|
|
20
|
+
* @param {unknown[]} right The other.
|
|
21
|
+
* @returns {boolean}
|
|
22
|
+
*/
|
|
23
|
+
export function sameArray(left, right) {
|
|
24
|
+
return left.length === right.length && left.every((value, index) => Object.is(value, right[index]));
|
|
25
|
+
}
|
|
@@ -81,6 +81,65 @@ export function menuItemRole(item) {
|
|
|
81
81
|
: 'menuitem';
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
/**
|
|
85
|
+
* The checked state choosing an item leaves it in: a `menuitemcheckbox` toggles, a `menuitemradio`
|
|
86
|
+
* becomes checked, and a plain `menuitem` has none.
|
|
87
|
+
* @param {MenuItem} item Chosen item.
|
|
88
|
+
* @param {boolean} current Whether it is checked now.
|
|
89
|
+
* @returns {boolean|undefined}
|
|
90
|
+
*/
|
|
91
|
+
export function nextCheckedState(item, current) {
|
|
92
|
+
const role = menuItemRole(item);
|
|
93
|
+
if (role === 'menuitemradio') return true;
|
|
94
|
+
if (role === 'menuitemcheckbox') return !current;
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* The indices of the `menuitemradio` items in the same group as the entry at `index`: the section
|
|
100
|
+
* of the menu it sits in, between the nearest separators or headings. Empty for any other entry.
|
|
101
|
+
* @param {MenuEntry[]} entries The menu's entries.
|
|
102
|
+
* @param {number} index Index of a radio item.
|
|
103
|
+
* @returns {number[]}
|
|
104
|
+
*/
|
|
105
|
+
export function radioGroupIndices(entries, index) {
|
|
106
|
+
const entry = entries[index];
|
|
107
|
+
if (!isMenuItem(entry) || menuItemRole(entry) !== 'menuitemradio') return [];
|
|
108
|
+
const bounds = (candidate) => candidate === '-' || (Boolean(candidate) && typeof candidate === 'object'
|
|
109
|
+
&& ['separator', 'heading'].includes(String(/** @type {{type?: unknown}} */ (candidate).type ?? '')));
|
|
110
|
+
let start = index;
|
|
111
|
+
while (start > 0 && !bounds(entries[start - 1])) start -= 1;
|
|
112
|
+
let end = index;
|
|
113
|
+
while (end < entries.length - 1 && !bounds(entries[end + 1])) end += 1;
|
|
114
|
+
const group = [];
|
|
115
|
+
for (let position = start; position <= end; position += 1) {
|
|
116
|
+
const candidate = entries[position];
|
|
117
|
+
if (isMenuItem(candidate) && menuItemRole(candidate) === 'menuitemradio') group.push(position);
|
|
118
|
+
}
|
|
119
|
+
return group;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Shows a chosen checkbox or radio item's new state in a menu rendered by `renderMenuEntries()`:
|
|
124
|
+
* its `aria-checked`, and for a radio item that it is now the only checked one of its group. The
|
|
125
|
+
* entries themselves are left as the application gave them.
|
|
126
|
+
* @param {HTMLElement} panel Menu panel holding the rendered entries.
|
|
127
|
+
* @param {MenuEntry[]} entries The entries it was rendered from.
|
|
128
|
+
* @param {number} index Index of the chosen entry.
|
|
129
|
+
* @param {boolean} checked The chosen item's new state.
|
|
130
|
+
* @returns {void}
|
|
131
|
+
*/
|
|
132
|
+
export function applyCheckedState(panel, entries, index, checked) {
|
|
133
|
+
const entry = entries[index];
|
|
134
|
+
if (!isMenuItem(entry) || menuItemRole(entry) === 'menuitem') return;
|
|
135
|
+
const element = (position) => panel.querySelector(`[data-menu-item="${position}"]:not([data-menu-option])`);
|
|
136
|
+
element(index)?.setAttribute('aria-checked', String(checked));
|
|
137
|
+
if (!checked) return;
|
|
138
|
+
for (const position of radioGroupIndices(entries, index)) {
|
|
139
|
+
if (position !== index) element(position)?.setAttribute('aria-checked', 'false');
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
84
143
|
/**
|
|
85
144
|
* Builds one menu's entries with shared structure and link safety.
|
|
86
145
|
* @param {MenuEntry[]} entries Entry definitions.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content an overlay accepts: text, a node, or anything exposing `toElement()`. Strings are never
|
|
3
|
+
* parsed as HTML.
|
|
4
|
+
* @typedef {Node|string|number|{toElement: () => Node|null}|null|undefined} OverlayContent
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Replaces a container's children with overlay content.
|
|
9
|
+
* @param {Element} target Container to fill.
|
|
10
|
+
* @param {OverlayContent} content Content to display; null or undefined leaves it empty.
|
|
11
|
+
* @returns {void}
|
|
12
|
+
*/
|
|
13
|
+
export function replaceContent(target, content) {
|
|
14
|
+
target.replaceChildren();
|
|
15
|
+
appendContent(target, content);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Appends overlay content to a container: a string or number as a text node, the result of
|
|
20
|
+
* `toElement()`, or the node itself. Anything else is ignored.
|
|
21
|
+
* @param {Element} target Container to append to.
|
|
22
|
+
* @param {OverlayContent} content Content to append.
|
|
23
|
+
* @returns {void}
|
|
24
|
+
*/
|
|
25
|
+
export function appendContent(target, content) {
|
|
26
|
+
if (content == null) return;
|
|
27
|
+
if (typeof content === 'string' || typeof content === 'number') {
|
|
28
|
+
target.append(document.createTextNode(String(content)));
|
|
29
|
+
} else if (typeof content.toElement === 'function') {
|
|
30
|
+
const element = content.toElement();
|
|
31
|
+
if (element) target.append(element);
|
|
32
|
+
} else if (typeof content.nodeType === 'number') {
|
|
33
|
+
target.append(content);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
* screen (an `IntersectionObserver`), eases from one pose to the next when an activity changes,
|
|
9
9
|
* clamps its frame step so a long frame never makes an avatar jump, and sleeps while the page is
|
|
10
10
|
* hidden or nothing is moving. Under reduced motion — the system's, or a `data-zx-motion="reduced"`
|
|
11
|
-
* region around an avatar, followed
|
|
12
|
-
* loop stops. It writes `transform` and nothing else.
|
|
11
|
+
* region around an avatar, followed by one watcher per loop however many avatars it moves — every
|
|
12
|
+
* avatar returns to rest and the loop stops. It writes `transform` and nothing else.
|
|
13
13
|
*
|
|
14
14
|
* Motion is never the only signal: an avatar's activity is also its dot and its word.
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
16
|
+
import { MOTION_ATTRIBUTE, prefersReducedMotion } from '../core/motion.js';
|
|
17
17
|
|
|
18
18
|
/** @typedef {import('./agent-model.js').AgentActivity} AgentActivity */
|
|
19
19
|
|
|
@@ -58,6 +58,12 @@ const REST = Object.freeze({ y: 0, r: 0, s: 1, w: 0, blink: 0 });
|
|
|
58
58
|
/** Where the shared loop is kept on its document. */
|
|
59
59
|
const LOOP = Symbol('zx.presenceLoop');
|
|
60
60
|
|
|
61
|
+
/** The operating system's reduced-motion preference. */
|
|
62
|
+
const REDUCED_QUERY = '(prefers-reduced-motion: reduce)';
|
|
63
|
+
|
|
64
|
+
/** What the loop's one motion watcher observes in each tree an avatar lives in. */
|
|
65
|
+
const MOTION_OBSERVED = Object.freeze({ attributes: true, attributeFilter: [MOTION_ATTRIBUTE], subtree: true });
|
|
66
|
+
|
|
61
67
|
/** A handle that does nothing, for an environment the loop cannot run in. */
|
|
62
68
|
const INERT = Object.freeze({ set() {}, untrack() {} });
|
|
63
69
|
|
|
@@ -146,7 +152,6 @@ function settled(pose) {
|
|
|
146
152
|
* @property {boolean} visible
|
|
147
153
|
* @property {boolean} reduced
|
|
148
154
|
* @property {boolean} moved Whether the loop has written a transform it has not cleared.
|
|
149
|
-
* @property {() => void} unwatch
|
|
150
155
|
*/
|
|
151
156
|
|
|
152
157
|
/**
|
|
@@ -154,6 +159,7 @@ function settled(pose) {
|
|
|
154
159
|
* @property {Document} document
|
|
155
160
|
* @property {Map<HTMLElement, Entry>} entries
|
|
156
161
|
* @property {IntersectionObserver} observer
|
|
162
|
+
* @property {MutationObserver|null} motion The one watcher of `data-zx-motion` regions.
|
|
157
163
|
* @property {AbortController} abort
|
|
158
164
|
* @property {number} frame
|
|
159
165
|
* @property {number} last
|
|
@@ -188,15 +194,11 @@ export function trackPresence(element, activity, options = {}) {
|
|
|
188
194
|
pose: { y: 0, r: 0, s: 1, w: 0 },
|
|
189
195
|
visible: false,
|
|
190
196
|
reduced: prefersReducedMotion(element),
|
|
191
|
-
moved: false
|
|
192
|
-
unwatch: () => {}
|
|
197
|
+
moved: false
|
|
193
198
|
};
|
|
194
199
|
loop.entries.set(element, entry);
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
if (reduced) rest(element, entry);
|
|
198
|
-
else schedule(loop);
|
|
199
|
-
});
|
|
200
|
+
// A region can be set in a shadow root the avatar lives in, out of the document's sight.
|
|
201
|
+
for (const root of shadowRootsAbove(element)) loop.motion?.observe(root, MOTION_OBSERVED);
|
|
200
202
|
loop.observer.observe(element);
|
|
201
203
|
return handleFor(loop, element);
|
|
202
204
|
}
|
|
@@ -219,7 +221,6 @@ function handleFor(loop, element) {
|
|
|
219
221
|
const entry = loop.entries.get(element);
|
|
220
222
|
if (!entry) return;
|
|
221
223
|
loop.entries.delete(element);
|
|
222
|
-
entry.unwatch();
|
|
223
224
|
loop.observer.unobserve(element);
|
|
224
225
|
rest(element, entry);
|
|
225
226
|
if (loop.entries.size === 0) teardown(loop);
|
|
@@ -246,11 +247,15 @@ function loopOf(doc) {
|
|
|
246
247
|
if (!entry) continue;
|
|
247
248
|
entry.visible = record.isIntersecting;
|
|
248
249
|
// An avatar built before it was attached could not see the region it landed in.
|
|
249
|
-
if (entry.visible)
|
|
250
|
+
if (entry.visible) {
|
|
251
|
+
entry.reduced = prefersReducedMotion(record.target);
|
|
252
|
+
for (const root of shadowRootsAbove(record.target)) loop.motion?.observe(root, MOTION_OBSERVED);
|
|
253
|
+
}
|
|
250
254
|
if (entry.reduced) rest(/** @type {HTMLElement} */ (record.target), entry);
|
|
251
255
|
}
|
|
252
256
|
schedule(loop);
|
|
253
257
|
}),
|
|
258
|
+
motion: typeof MutationObserver === 'function' ? new MutationObserver(() => recheckMotion(loop)) : null,
|
|
254
259
|
abort: new AbortController(),
|
|
255
260
|
frame: 0,
|
|
256
261
|
last: 0,
|
|
@@ -260,6 +265,11 @@ function loopOf(doc) {
|
|
|
260
265
|
if (doc.hidden) cancel(loop);
|
|
261
266
|
else schedule(loop);
|
|
262
267
|
}, { signal: loop.abort.signal });
|
|
268
|
+
// One watcher for every avatar the loop moves: the system preference, and any region set or
|
|
269
|
+
// cleared in the document.
|
|
270
|
+
if (doc.documentElement) loop.motion?.observe(doc.documentElement, MOTION_OBSERVED);
|
|
271
|
+
const media = typeof globalThis.matchMedia === 'function' ? globalThis.matchMedia(REDUCED_QUERY) : null;
|
|
272
|
+
media?.addEventListener?.('change', () => recheckMotion(loop), { signal: loop.abort.signal });
|
|
263
273
|
host[LOOP] = loop;
|
|
264
274
|
return loop;
|
|
265
275
|
}
|
|
@@ -268,11 +278,46 @@ function loopOf(doc) {
|
|
|
268
278
|
function teardown(loop) {
|
|
269
279
|
cancel(loop);
|
|
270
280
|
loop.observer.disconnect();
|
|
281
|
+
loop.motion?.disconnect();
|
|
271
282
|
loop.abort.abort();
|
|
272
283
|
const host = /** @type {Document & {[LOOP]?: Loop}} */ (loop.document);
|
|
273
284
|
if (host[LOOP] === loop) delete host[LOOP];
|
|
274
285
|
}
|
|
275
286
|
|
|
287
|
+
/**
|
|
288
|
+
* Asks every tracked avatar again whether motion should stop where it is: one that must stop goes
|
|
289
|
+
* to rest at once, and the loop starts again for one that may move.
|
|
290
|
+
* @param {Loop} loop
|
|
291
|
+
* @returns {void}
|
|
292
|
+
*/
|
|
293
|
+
function recheckMotion(loop) {
|
|
294
|
+
for (const [element, entry] of loop.entries) {
|
|
295
|
+
const reduced = prefersReducedMotion(element);
|
|
296
|
+
if (reduced === entry.reduced) continue;
|
|
297
|
+
entry.reduced = reduced;
|
|
298
|
+
if (reduced) rest(element, entry);
|
|
299
|
+
}
|
|
300
|
+
schedule(loop);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* The shadow roots on an element's way up to its document.
|
|
305
|
+
* @param {Element} element
|
|
306
|
+
* @returns {Node[]}
|
|
307
|
+
*/
|
|
308
|
+
function shadowRootsAbove(element) {
|
|
309
|
+
const roots = [];
|
|
310
|
+
/** @type {Element|null} */
|
|
311
|
+
let node = element;
|
|
312
|
+
while (node && typeof node.getRootNode === 'function') {
|
|
313
|
+
const root = node.getRootNode();
|
|
314
|
+
if (!root || root.nodeType !== 11 || !('host' in root)) break;
|
|
315
|
+
roots.push(root);
|
|
316
|
+
node = /** @type {ShadowRoot} */ (root).host;
|
|
317
|
+
}
|
|
318
|
+
return roots;
|
|
319
|
+
}
|
|
320
|
+
|
|
276
321
|
/** @param {Loop} loop @returns {boolean} Whether any avatar could move now. */
|
|
277
322
|
function runnable(loop) {
|
|
278
323
|
if (loop.document.hidden) return false;
|
|
@@ -329,7 +374,9 @@ function step(loop, now) {
|
|
|
329
374
|
pose.r += (target.r - pose.r) * ease;
|
|
330
375
|
pose.s += (target.s - pose.s) * ease;
|
|
331
376
|
pose.w += (target.w - pose.w) * ease;
|
|
332
|
-
|
|
377
|
+
// Only an activity that stays at rest may settle: a moving one passes through rest once a
|
|
378
|
+
// cycle, and resting it there would stop the loop with nothing to start it again.
|
|
379
|
+
if (presencePeriod(entry.activity) === 0 && settled(pose)) {
|
|
333
380
|
rest(element, entry);
|
|
334
381
|
continue;
|
|
335
382
|
}
|
package/src/locales/de.js
CHANGED
|
@@ -577,6 +577,9 @@ export const de = Object.freeze({
|
|
|
577
577
|
|
|
578
578
|
'numberField.empty': 'Leer',
|
|
579
579
|
|
|
580
|
+
'pagination.auto': 'Automatisch',
|
|
581
|
+
'pagination.autoLoad': 'Automatisch laden',
|
|
582
|
+
'pagination.autoSize': 'Automatisch (%1)',
|
|
580
583
|
'pagination.empty': '0 von 0',
|
|
581
584
|
'pagination.label': 'Seitennavigation',
|
|
582
585
|
'pagination.loaded': '%1 von %2',
|