@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
|
@@ -126,7 +126,13 @@ export function proseAnchors(root, options = {}) {
|
|
|
126
126
|
settings.oncopy?.(url, copied);
|
|
127
127
|
if (!copied) return;
|
|
128
128
|
clearTimeout(timer);
|
|
129
|
-
|
|
129
|
+
// One confirmation at a time: a link still showing its tick from an earlier copy, whose timer
|
|
130
|
+
// was just cleared, gets its own glyph back now.
|
|
131
|
+
for (const other of anchors.keys()) {
|
|
132
|
+
if (other === anchor || other.dataset.copied !== 'true') continue;
|
|
133
|
+
delete other.dataset.copied;
|
|
134
|
+
other.replaceChildren(icon('link-2'));
|
|
135
|
+
}
|
|
130
136
|
anchor.dataset.copied = 'true';
|
|
131
137
|
anchor.replaceChildren(icon('check'));
|
|
132
138
|
if (!status.isConnected) target.append(status);
|
|
@@ -17,6 +17,9 @@ export function registerRatingFieldAdapter() {
|
|
|
17
17
|
});
|
|
18
18
|
return {
|
|
19
19
|
el: rating.el,
|
|
20
|
+
// The radiogroup is what the label names and what the field's description and validity
|
|
21
|
+
// belong to.
|
|
22
|
+
labelTarget: rating.refs.symbols,
|
|
20
23
|
// Unrated reads as null rather than 0, so Form's required check treats it as empty.
|
|
21
24
|
get: () => rating.get() || null,
|
|
22
25
|
set: (value) => {
|
|
@@ -4,11 +4,13 @@ import { formatDate, isSameDay } from '../../core/date.js';
|
|
|
4
4
|
import { h, restoreTarget, snapshotTarget } from '../../core/dom.js';
|
|
5
5
|
import { formatCurrency, formatNumber } from '../../core/format.js';
|
|
6
6
|
import { getLanguage, printf } from '../../core/i18n.js';
|
|
7
|
-
import { AGENT_MESSAGES, STATUS, formatElapsed, normalizeRunState } from '../../internal/agent-model.js';
|
|
7
|
+
import { AGENT_MESSAGES, RUN_ACTIVITY, STATUS, agentAvatarOptions, formatElapsed, normalizeRunState } from '../../internal/agent-model.js';
|
|
8
|
+
import { AgentAvatar } from '../agent-avatar/agent-avatar.js';
|
|
8
9
|
import { button } from '../button/button.js';
|
|
9
10
|
import { statusIcon } from '../select/glyphs.js';
|
|
10
11
|
|
|
11
12
|
/** @typedef {import('../../internal/agent-model.js').RunState} RunState */
|
|
13
|
+
/** @typedef {import('../../internal/agent-model.js').AgentFace} AgentFace */
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* A button beside the run's state, for what the reader can do about it now: "Review the request"
|
|
@@ -75,6 +77,13 @@ import { statusIcon } from '../select/glyphs.js';
|
|
|
75
77
|
* tone from 80% and to the danger tone at 100%. Without one they stay text.
|
|
76
78
|
* @property {RunCost|null} [cost=null] What the run has cost, against its budget.
|
|
77
79
|
* @property {string|null} [model=null] The model the agent runs on.
|
|
80
|
+
* @property {AgentFace|true|null} [agent=null] The agent whose run this is, drawn as its AgentAvatar
|
|
81
|
+
* face before the state: its traits and name, or `true` to derive the face from the summary. The
|
|
82
|
+
* face is keyed by the agent's `seed`, else its `name`; without either it is named after the
|
|
83
|
+
* summary it is first drawn with, and it keeps its face while `agent` asks for the same traits,
|
|
84
|
+
* so a summary that changes as the run goes on never changes it. The face takes the run's
|
|
85
|
+
* expression — working while it runs, looking up at you while it waits, blocked when blocked or
|
|
86
|
+
* failed, at rest otherwise. It is decorative, and the compact pill leaves it out.
|
|
78
87
|
* @property {RunStatusAction[]} [actions=[]] Buttons under the summary.
|
|
79
88
|
* @property {boolean} [ticking=true] While the state is `running`, the working time counts on
|
|
80
89
|
* once a second from `workMs` and the moment of the last `update()`. One interval, which sleeps
|
|
@@ -106,6 +115,7 @@ import { statusIcon } from '../select/glyphs.js';
|
|
|
106
115
|
* @property {number|null} tokenBudget
|
|
107
116
|
* @property {RunCost|null} cost
|
|
108
117
|
* @property {string|null} model
|
|
118
|
+
* @property {AgentFace|true|null} agent
|
|
109
119
|
* @property {RunStatusAction[]} actions
|
|
110
120
|
*/
|
|
111
121
|
|
|
@@ -132,7 +142,7 @@ const MESSAGES = Object.freeze({
|
|
|
132
142
|
|
|
133
143
|
/** The values `update()` merges; everything else is fixed at construction. */
|
|
134
144
|
const VALUE_KEYS = Object.freeze(['state', 'summary', 'steps', 'started', 'finished', 'workMs', 'waitingSince',
|
|
135
|
-
'tokens', 'tokenBudget', 'cost', 'model', 'actions', 'ticking', 'compact']);
|
|
145
|
+
'tokens', 'tokenBudget', 'cost', 'model', 'agent', 'actions', 'ticking', 'compact']);
|
|
136
146
|
|
|
137
147
|
/** The label of the "finished" row for each state that ends a run. */
|
|
138
148
|
const FINISHED_KEYS = Object.freeze({
|
|
@@ -183,6 +193,7 @@ export class RunStatus extends Component {
|
|
|
183
193
|
tokenBudget: null,
|
|
184
194
|
cost: null,
|
|
185
195
|
model: null,
|
|
196
|
+
agent: null,
|
|
186
197
|
actions: [],
|
|
187
198
|
ticking: true,
|
|
188
199
|
compact: false,
|
|
@@ -207,6 +218,9 @@ export class RunStatus extends Component {
|
|
|
207
218
|
/** @type {HTMLElement|null} The action row as drawn, kept across updates that leave it unchanged. */
|
|
208
219
|
this._actionsEl = null;
|
|
209
220
|
this._actionsKey = '';
|
|
221
|
+
/** @type {AgentAvatar|null} The agent's face, kept across draws while it asks for the same traits. */
|
|
222
|
+
this._avatar = null;
|
|
223
|
+
this._faceKey = '';
|
|
210
224
|
/** Whether the root took `tabindex="-1"` to hold focus that had nowhere else to go. */
|
|
211
225
|
this._heldFocus = false;
|
|
212
226
|
/** @type {ReturnType<typeof setInterval>|0} */
|
|
@@ -258,6 +272,7 @@ export class RunStatus extends Component {
|
|
|
258
272
|
tokenBudget: finiteOrNull(values.tokenBudget),
|
|
259
273
|
cost: copyValue(values.cost) ?? null,
|
|
260
274
|
model: values.model ?? null,
|
|
275
|
+
agent: copyValue(values.agent) ?? null,
|
|
261
276
|
actions: Array.isArray(values.actions) ? [...values.actions] : []
|
|
262
277
|
};
|
|
263
278
|
}
|
|
@@ -268,6 +283,8 @@ export class RunStatus extends Component {
|
|
|
268
283
|
this._destroyed = true;
|
|
269
284
|
this._stopTicker();
|
|
270
285
|
this._releaseFocus();
|
|
286
|
+
this._avatar?.destroy();
|
|
287
|
+
this._avatar = null;
|
|
271
288
|
super.destroy();
|
|
272
289
|
if (this._original) restoreTarget(this.el, this._original);
|
|
273
290
|
}
|
|
@@ -310,7 +327,7 @@ export class RunStatus extends Component {
|
|
|
310
327
|
const summary = values.summary == null ? '' : String(values.summary);
|
|
311
328
|
const rows = this._rows(state);
|
|
312
329
|
this._place([
|
|
313
|
-
h('p', { class: 'zx-run-status__state' }, ...this._stateParts(state)),
|
|
330
|
+
h('p', { class: 'zx-run-status__state' }, this._face(state, summary), ...this._stateParts(state)),
|
|
314
331
|
summary ? h('p', { class: 'zx-run-status__summary' }, summary) : null,
|
|
315
332
|
steps ? this._steps(steps) : null,
|
|
316
333
|
this._actions(),
|
|
@@ -419,6 +436,29 @@ export class RunStatus extends Component {
|
|
|
419
436
|
this.el.removeAttribute('tabindex');
|
|
420
437
|
}
|
|
421
438
|
|
|
439
|
+
/**
|
|
440
|
+
* The agent's face with the run's expression: the one drawn before, while the traits it asks for
|
|
441
|
+
* stay the same, so a redraw never re-creates it. The summary is not part of what it asks for:
|
|
442
|
+
* it names a face that has no seed or name when the face is built, and never changes it after.
|
|
443
|
+
* @private
|
|
444
|
+
* @param {RunState} state
|
|
445
|
+
* @param {string} summary What names the face when the agent option gives no seed or name.
|
|
446
|
+
* @returns {Element|null}
|
|
447
|
+
*/
|
|
448
|
+
_face(state, summary) {
|
|
449
|
+
const face = agentAvatarOptions(this._values.agent);
|
|
450
|
+
const key = face ? JSON.stringify(face) : '';
|
|
451
|
+
if (key !== this._faceKey) {
|
|
452
|
+
this._avatar?.destroy();
|
|
453
|
+
this._avatar = face ? new AgentAvatar(null, agentAvatarOptions(face,
|
|
454
|
+
{ size: 'sm', label: null, indicator: false, animate: false }, { fallback: { name: summary } })) : null;
|
|
455
|
+
this._faceKey = key;
|
|
456
|
+
}
|
|
457
|
+
if (!this._avatar) return null;
|
|
458
|
+
this._avatar.setActivity(RUN_ACTIVITY[state]);
|
|
459
|
+
return this._avatar.toElement();
|
|
460
|
+
}
|
|
461
|
+
|
|
422
462
|
/** @private @param {RunState} state @returns {Node[]} The state's glyph and its word. */
|
|
423
463
|
_stateParts(state) {
|
|
424
464
|
const entry = STATUS[state];
|
|
@@ -6,14 +6,16 @@ import { formatNumber } from '../../core/format.js';
|
|
|
6
6
|
import { prefersReducedMotion } from '../../core/motion.js';
|
|
7
7
|
import { uid } from '../../core/util.js';
|
|
8
8
|
import {
|
|
9
|
-
AGENT_MESSAGES, STATUS, formatDuration, formatElapsed, initialsOf, normalizeRunState, traceSummary
|
|
9
|
+
AGENT_MESSAGES, STATUS, agentAvatarOptions, authorFace, formatDuration, formatElapsed, initialsOf, normalizeRunState, traceSummary
|
|
10
10
|
} from '../../internal/agent-model.js';
|
|
11
|
+
import { AgentAvatar } from '../agent-avatar/agent-avatar.js';
|
|
11
12
|
import { Avatar } from '../avatar/avatar.js';
|
|
12
13
|
import { copyButton } from '../copy/copy-button.js';
|
|
13
14
|
import { statusIcon } from '../select/glyphs.js';
|
|
14
15
|
|
|
15
16
|
/** @typedef {import('../../internal/agent-model.js').TraceStep} TraceStep */
|
|
16
17
|
/** @typedef {import('../../internal/agent-model.js').Author} Author */
|
|
18
|
+
/** @typedef {import('../../internal/agent-model.js').AuthorFace} AuthorFace */
|
|
17
19
|
/** @typedef {import('../../internal/agent-model.js').ItemRef} ItemRef */
|
|
18
20
|
/** @typedef {import('../../internal/agent-model.js').RunState} RunState */
|
|
19
21
|
/** @typedef {import('../avatar/avatar.js').AvatarTone} AvatarTone */
|
|
@@ -92,7 +94,7 @@ import { statusIcon } from '../select/glyphs.js';
|
|
|
92
94
|
* @property {HTMLElement|null} refs The step's links, after its row.
|
|
93
95
|
* @property {HTMLElement|null} body The disclosure's content, when the step has any.
|
|
94
96
|
* @property {HTMLElement|null} retries The nested list of the steps that repeat this one.
|
|
95
|
-
* @property {Avatar
|
|
97
|
+
* @property {Array<Avatar|AgentAvatar>} avatars Avatars the row owns.
|
|
96
98
|
* @property {string|null} rootId The top-level step a retry is drawn under; null for a top-level step.
|
|
97
99
|
* @property {string|null} bodyId Id of the disclosure content.
|
|
98
100
|
*/
|
|
@@ -805,7 +807,7 @@ export class RunTrace extends Component {
|
|
|
805
807
|
/**
|
|
806
808
|
* @private
|
|
807
809
|
* @param {unknown} key
|
|
808
|
-
* @returns {{name: string, initials: string, tone: AvatarTone|null, person: boolean}}
|
|
810
|
+
* @returns {{name: string, initials: string, tone: AvatarTone|null, person: boolean, face: AuthorFace|null}}
|
|
809
811
|
*/
|
|
810
812
|
_author(key) {
|
|
811
813
|
const authors = this.options.authors && typeof this.options.authors === 'object' ? this.options.authors : {};
|
|
@@ -816,19 +818,25 @@ export class RunTrace extends Component {
|
|
|
816
818
|
name,
|
|
817
819
|
initials: text(author?.initials) || initialsOf(name),
|
|
818
820
|
tone: /** @type {AvatarTone|null} */ (author?.tone ?? null),
|
|
819
|
-
person: author?.kind === 'person'
|
|
821
|
+
person: author?.kind === 'person',
|
|
822
|
+
face: authorFace(author)
|
|
820
823
|
};
|
|
821
824
|
}
|
|
822
825
|
|
|
823
826
|
/**
|
|
824
|
-
* A hand-off avatar,
|
|
825
|
-
* rounded square for an agent or
|
|
827
|
+
* A hand-off avatar, drawn like the author's avatar everywhere else: an agent with a `face` as its
|
|
828
|
+
* AgentAvatar, still; otherwise initials, round for a person and a rounded square for an agent or
|
|
829
|
+
* a model.
|
|
826
830
|
* @private
|
|
827
831
|
* @param {unknown} key
|
|
828
|
-
* @returns {Avatar}
|
|
832
|
+
* @returns {Avatar|AgentAvatar}
|
|
829
833
|
*/
|
|
830
834
|
_avatar(key) {
|
|
831
835
|
const author = this._author(key);
|
|
836
|
+
if (author.face) {
|
|
837
|
+
return new AgentAvatar(null, agentAvatarOptions(author.face,
|
|
838
|
+
{ name: author.name, size: 'sm', label: null, animate: false }, { fallback: { tone: author.tone } }));
|
|
839
|
+
}
|
|
832
840
|
return new Avatar(null, {
|
|
833
841
|
name: author.name, initials: author.initials, tone: author.tone, size: 'sm', shape: author.person ? 'circle' : 'rounded'
|
|
834
842
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Component } from '../../core/component.js';
|
|
2
|
-
import { h } from '../../core/dom.js';
|
|
2
|
+
import { h, restoreTarget, snapshotTarget } from '../../core/dom.js';
|
|
3
3
|
import { ICON_SIZE, icon } from '../../core/icons.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -36,7 +36,7 @@ export class Search extends Component {
|
|
|
36
36
|
const created = !this.el;
|
|
37
37
|
const root = /** @type {HTMLElement} */ (this.el ?? h('form'));
|
|
38
38
|
this._createdRoot = created;
|
|
39
|
-
this._original = created ? null :
|
|
39
|
+
this._original = created ? null : snapshotTarget(root);
|
|
40
40
|
this._inputTimer = null;
|
|
41
41
|
root.setAttribute('role', 'search');
|
|
42
42
|
const clearLabel = this._message('search.clear', 'Clear search');
|
|
@@ -139,7 +139,7 @@ export class Search extends Component {
|
|
|
139
139
|
this._cleaned = true;
|
|
140
140
|
if (this._inputTimer !== null) clearTimeout(this._inputTimer);
|
|
141
141
|
super.destroy();
|
|
142
|
-
if (!this._createdRoot && this._original)
|
|
142
|
+
if (!this._createdRoot && this._original) restoreTarget(this.el, this._original);
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
/** @returns {void} */
|
|
@@ -188,18 +188,3 @@ export class Search extends Component {
|
|
|
188
188
|
* @event Search#clear
|
|
189
189
|
* @type {CustomEvent<Record<string, never>>}
|
|
190
190
|
*/
|
|
191
|
-
|
|
192
|
-
/** @param {Element} element @returns {{attributes: [string, string][], children: Node[]}} */
|
|
193
|
-
function snapshot(element) {
|
|
194
|
-
return {
|
|
195
|
-
attributes: Array.from(element.attributes, (attribute) => [attribute.name, attribute.value]),
|
|
196
|
-
children: Array.from(element.childNodes)
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/** @param {Element} element @param {{attributes: [string, string][], children: Node[]}} state */
|
|
201
|
-
function restore(element, state) {
|
|
202
|
-
for (const attribute of Array.from(element.attributes)) element.removeAttribute(attribute.name);
|
|
203
|
-
for (const [name, value] of state.attributes) element.setAttribute(name, value);
|
|
204
|
-
element.replaceChildren(...state.children);
|
|
205
|
-
}
|
|
@@ -11,8 +11,12 @@ export function registerSelectFieldAdapter() {
|
|
|
11
11
|
const props = options.props ?? {};
|
|
12
12
|
const preset = props.preset;
|
|
13
13
|
const selectOptions = { ...props, value: options.value, label: options.label || props.label, placeholder: props.placeholder ?? options.placeholder };
|
|
14
|
+
// A click on the label focuses the combobox without opening it: the label's own activation
|
|
15
|
+
// would click the input, which opens the list.
|
|
14
16
|
field.listen(field.el, 'click', (event) => {
|
|
15
|
-
if (event.target.closest?.('.zx-field__label'))
|
|
17
|
+
if (!event.target.closest?.('.zx-field__label')) return;
|
|
18
|
+
event.preventDefault();
|
|
19
|
+
field.adapter.focus();
|
|
16
20
|
});
|
|
17
21
|
delete selectOptions.preset;
|
|
18
22
|
// The priority preset offers "No priority" (null) by default; a required field cannot hold it.
|
|
@@ -30,6 +34,9 @@ export function registerSelectFieldAdapter() {
|
|
|
30
34
|
select.on('change', (event) => field.emit('change', { value: event.detail.value }));
|
|
31
35
|
return {
|
|
32
36
|
el: select.el,
|
|
37
|
+
// The combobox input is what the label names and what the field's description and validity
|
|
38
|
+
// belong to.
|
|
39
|
+
labelTarget: select.refs.input,
|
|
33
40
|
get: () => select.value,
|
|
34
41
|
set: (value) => select.set(value, { silent: true }),
|
|
35
42
|
focus: () => select.focus(),
|
|
@@ -275,7 +275,9 @@ export class Select extends Component {
|
|
|
275
275
|
}
|
|
276
276
|
|
|
277
277
|
/**
|
|
278
|
-
* Selects an item or item ID.
|
|
278
|
+
* Selects an item or item ID. An ID none of the items carries selects nothing; a whole item
|
|
279
|
+
* that is not among them — the current record of an async-filtered Select, whose results have
|
|
280
|
+
* not been loaded — is selected as given.
|
|
279
281
|
* @param {unknown} idOrItem Item ID, item, or null.
|
|
280
282
|
* @param {SelectSetOptions} [options={}] Update behavior.
|
|
281
283
|
* @returns {this}
|
|
@@ -284,7 +286,11 @@ export class Select extends Component {
|
|
|
284
286
|
set(idOrItem, { silent = false } = {}) {
|
|
285
287
|
const previousValue = this.value;
|
|
286
288
|
const candidate = typeof idOrItem === 'string' ? this._normalizeValue(idOrItem) : idOrItem;
|
|
287
|
-
|
|
289
|
+
let item = candidate == null ? null : this._findItem(candidate);
|
|
290
|
+
if (item === null && candidate !== null && typeof candidate === 'object'
|
|
291
|
+
&& this._itemValue(/** @type {SelectItem} */ (candidate)) != null) {
|
|
292
|
+
item = /** @type {SelectItem} */ (candidate);
|
|
293
|
+
}
|
|
288
294
|
this._selected = item;
|
|
289
295
|
this._syncInputValue();
|
|
290
296
|
this._renderOptions();
|
|
@@ -302,14 +308,13 @@ export class Select extends Component {
|
|
|
302
308
|
*/
|
|
303
309
|
setItems(items) {
|
|
304
310
|
const selectedValue = this.value;
|
|
311
|
+
const query = this._typedQuery();
|
|
305
312
|
this._cancelQuery();
|
|
306
313
|
this._setLoading(false);
|
|
307
314
|
this._items = Array.isArray(items) ? items.slice() : [];
|
|
308
315
|
this._visibleItems = this._items.slice();
|
|
309
316
|
this._selected = selectedValue == null ? null : this._findItem(selectedValue);
|
|
310
|
-
this.
|
|
311
|
-
this._renderOptions();
|
|
312
|
-
this._position?.update();
|
|
317
|
+
this._refreshAfterItemChange(query);
|
|
313
318
|
return this;
|
|
314
319
|
}
|
|
315
320
|
|
|
@@ -320,15 +325,54 @@ export class Select extends Component {
|
|
|
320
325
|
*/
|
|
321
326
|
setFixedItems(items) {
|
|
322
327
|
const selectedValue = this.value;
|
|
328
|
+
const query = this._typedQuery();
|
|
323
329
|
this._fixedItems = Array.isArray(items) ? items.slice() : [];
|
|
324
330
|
this._visibleFixed = this._fixedItems.slice();
|
|
325
331
|
this._selected = selectedValue == null ? null : this._findItem(selectedValue);
|
|
326
|
-
this.
|
|
327
|
-
this._renderOptions();
|
|
328
|
-
this._position?.update();
|
|
332
|
+
this._refreshAfterItemChange(query);
|
|
329
333
|
return this;
|
|
330
334
|
}
|
|
331
335
|
|
|
336
|
+
/**
|
|
337
|
+
* What the reader has typed into the open list, or null when the input just shows the
|
|
338
|
+
* selection (or the list is closed, or the Select does not filter).
|
|
339
|
+
* @returns {string|null}
|
|
340
|
+
*/
|
|
341
|
+
_typedQuery() {
|
|
342
|
+
if (!this._open || !this.options.filter) return null;
|
|
343
|
+
const query = /** @type {HTMLInputElement} */ (this.refs.input).value;
|
|
344
|
+
return query === this._selectedLabel() ? null : query;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Redraws after the items were replaced. A query the reader typed into the open list stays in
|
|
349
|
+
* the input and narrows the new items — locally filtered items by matching, pinned choices
|
|
350
|
+
* always — instead of the full list replacing what they typed.
|
|
351
|
+
* @param {string|null} query Typed query from before the change (see `_typedQuery()`).
|
|
352
|
+
* @returns {void}
|
|
353
|
+
*/
|
|
354
|
+
_refreshAfterItemChange(query) {
|
|
355
|
+
if (query !== null) {
|
|
356
|
+
this._visibleFixed = this._matchFixed(query);
|
|
357
|
+
if (this.options.filter === 'local') this._visibleItems = matchItems(this._items, query, this._searchKeys());
|
|
358
|
+
this._syncValueAdornment();
|
|
359
|
+
this.refs.clear.hidden = !this.options.clearable || this._selected === null;
|
|
360
|
+
this._renderOptions();
|
|
361
|
+
this._setActive(this._optionEntries.length > 0 ? 0 : -1);
|
|
362
|
+
} else {
|
|
363
|
+
this._syncInputValue();
|
|
364
|
+
this._renderOptions();
|
|
365
|
+
}
|
|
366
|
+
this._position?.update();
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/** The text the input shows for the selection: '' when nothing is selected. @returns {string} */
|
|
370
|
+
_selectedLabel() {
|
|
371
|
+
if (this._selected === null) return '';
|
|
372
|
+
return typeof this.options.renderValue === 'function'
|
|
373
|
+
? String(this.options.renderValue(this._selected) ?? '') : this._itemLabel(this._selected);
|
|
374
|
+
}
|
|
375
|
+
|
|
332
376
|
/** Replaces command rows without changing the selected value. @param {SelectAction[]} actions @returns {this} */
|
|
333
377
|
setActions(actions) {
|
|
334
378
|
this._actions = normalizeSelectActions(actions);
|
|
@@ -490,10 +534,12 @@ export class Select extends Component {
|
|
|
490
534
|
// the setItems() below, which renders it again.
|
|
491
535
|
const noneLabel = () => options.noneLabel
|
|
492
536
|
?? (select ? select._message('priority.none', 'No priority') : 'No priority');
|
|
537
|
+
// The requested value is the configured one, so reset() returns to it; it is applied below,
|
|
538
|
+
// once the items exist.
|
|
493
539
|
select = new Select(target, {
|
|
494
540
|
...options,
|
|
495
541
|
clearable,
|
|
496
|
-
value:
|
|
542
|
+
value: requestedValue,
|
|
497
543
|
items: [],
|
|
498
544
|
renderItem(item) {
|
|
499
545
|
return priorityContent(item, true);
|
|
@@ -523,9 +569,11 @@ export class Select extends Component {
|
|
|
523
569
|
*/
|
|
524
570
|
static status(target, options = {}) {
|
|
525
571
|
const { items = null, value = null, ...rest } = options;
|
|
572
|
+
// The requested value is the configured one, so reset() returns to it; it is applied below,
|
|
573
|
+
// once the items exist.
|
|
526
574
|
const select = new Select(target, {
|
|
527
575
|
...rest,
|
|
528
|
-
value
|
|
576
|
+
value,
|
|
529
577
|
items: [],
|
|
530
578
|
renderItem(item) { return statusContent(item); },
|
|
531
579
|
renderValueAdornment(item) { return statusIndicator(item); }
|
|
@@ -614,7 +662,9 @@ export class Select extends Component {
|
|
|
614
662
|
// `filter` override. Array-backed groups still honor local/disabled filtering.
|
|
615
663
|
filter: loader ?? filter,
|
|
616
664
|
...rest,
|
|
617
|
-
value
|
|
665
|
+
// The requested value is the configured one, so reset() returns to it; it is applied
|
|
666
|
+
// below, once the fixed choices exist.
|
|
667
|
+
value,
|
|
618
668
|
items: shareable,
|
|
619
669
|
fixedItems: [],
|
|
620
670
|
// The two choices carry their own ID and label, so a caller's group readers stay untouched.
|
|
@@ -642,6 +692,8 @@ export class Select extends Component {
|
|
|
642
692
|
/** @param {KeyboardEvent} event @returns {void} */
|
|
643
693
|
_onKeydown(event) {
|
|
644
694
|
if (this._disabled) return;
|
|
695
|
+
// Keys that confirm or steer an IME composition (Enter, arrows) belong to the IME.
|
|
696
|
+
if (event.isComposing || event.keyCode === 229) return;
|
|
645
697
|
if (this._open && isPrintable(event)) {
|
|
646
698
|
const shortcut = this._optionEntries.findIndex((entry) => !entry.clear && !entry.action
|
|
647
699
|
&& String((/** @type {Record<string, any>|null} */ (entry.item))?.shortcut ?? '') === event.key);
|
|
@@ -666,12 +718,15 @@ export class Select extends Component {
|
|
|
666
718
|
} else this._moveActive(-1);
|
|
667
719
|
return;
|
|
668
720
|
}
|
|
669
|
-
|
|
721
|
+
// Home and End move the caret through a query the reader typed; they move through the options
|
|
722
|
+
// of a read-only input, an empty one, or one that still just shows the selection.
|
|
723
|
+
const listKeys = this._open && !this._typedQuery();
|
|
724
|
+
if (event.key === 'Home' && listKeys) {
|
|
670
725
|
event.preventDefault();
|
|
671
726
|
this._setActive(0);
|
|
672
727
|
return;
|
|
673
728
|
}
|
|
674
|
-
if (event.key === 'End' &&
|
|
729
|
+
if (event.key === 'End' && listKeys) {
|
|
675
730
|
event.preventDefault();
|
|
676
731
|
this._setActive(this._optionEntries.length - 1);
|
|
677
732
|
return;
|
|
@@ -3,6 +3,7 @@ import { focusTrap } from '../../core/keyboard.js';
|
|
|
3
3
|
import { h, resolveElement } from '../../core/dom.js';
|
|
4
4
|
import { clamp } from '../../core/util.js';
|
|
5
5
|
import { Dialog } from '../dialog/dialog.js';
|
|
6
|
+
import { matchesState, showDialog } from '../modal/native-dialog.js';
|
|
6
7
|
|
|
7
8
|
/** @typedef {'start'|'end'|'top'|'bottom'} SheetSide */
|
|
8
9
|
/** @typedef {true|'trap-focus'|false} SheetModality */
|
|
@@ -29,7 +30,8 @@ const GROW_SIGN = Object.freeze({ start: 1, end: -1, top: 1, bottom: -1 });
|
|
|
29
30
|
* `start`/`end`, height for `top`/`bottom`. A number is pixels, a string is any CSS length. Null
|
|
30
31
|
* keeps the per-side default.
|
|
31
32
|
* @property {boolean} [closeButton=true] Whether the header shows its close control. Independent of
|
|
32
|
-
* `closable`, so a sheet can offer Escape without an ✕, or the reverse.
|
|
33
|
+
* `closable`, so a sheet can offer Escape without an ✕, or the reverse. When false the control is
|
|
34
|
+
* not displayed, not focusable, and closes nothing.
|
|
33
35
|
* @property {boolean} [resizable=false] Whether the inner edge may be dragged to resize the sheet.
|
|
34
36
|
* @property {number} [min=160] Smallest the sheet may be dragged to, in pixels.
|
|
35
37
|
* @property {number|null} [max=null] Largest it may be dragged to; null means the viewport.
|
|
@@ -48,7 +50,7 @@ const GROW_SIGN = Object.freeze({ start: 1, end: -1, top: 1, bottom: -1 });
|
|
|
48
50
|
* @property {Element|string|null} [scope=null] Element whose nearest Zx theme scope owns a floating sheet; defaults to the opener.
|
|
49
51
|
* @property {(event: CustomEvent<Record<string, never>>) => void} [onopen] Open event listener.
|
|
50
52
|
* @property {(event: CustomEvent<{result: unknown}>) => void} [onclose] Close event listener.
|
|
51
|
-
* @property {(event: CustomEvent<
|
|
53
|
+
* @property {(event: CustomEvent<import('../modal/modal.js').ModalCancelDetail>) => void} [oncancel] Cancel event listener.
|
|
52
54
|
* @property {(event: CustomEvent<{size: number, ratio: number}>) => void} [onresize] Resize listener.
|
|
53
55
|
* @property {(event: CustomEvent<{docked: boolean, dock: import('../dock/dock.js').Dock|null}>) => void} [ondockchange] Dock-state listener.
|
|
54
56
|
*/
|
|
@@ -76,7 +78,11 @@ const GROW_SIGN = Object.freeze({ start: 1, end: -1, top: 1, bottom: -1 });
|
|
|
76
78
|
export class Sheet extends Dialog {
|
|
77
79
|
static cssName = 'sheet';
|
|
78
80
|
|
|
79
|
-
/**
|
|
81
|
+
/**
|
|
82
|
+
* A sheet's `size` is any CSS length along its axis, wider than Dialog's presets, so the static
|
|
83
|
+
* side is typed loosely there to stay assignable to Dialog's.
|
|
84
|
+
* @type {Readonly<SheetOptions & {size?: any}>}
|
|
85
|
+
*/
|
|
80
86
|
static defaults = {
|
|
81
87
|
side: 'end',
|
|
82
88
|
modal: true,
|
|
@@ -117,7 +123,6 @@ export class Sheet extends Dialog {
|
|
|
117
123
|
this.setSide(this.options.side);
|
|
118
124
|
this.el.dataset.backdrop = BACKDROPS.has(this.options.backdrop) ? this.options.backdrop : 'dim';
|
|
119
125
|
this.el.dataset.modality = modality(this.options.modal);
|
|
120
|
-
this.refs.close.hidden = !this.options.closeButton;
|
|
121
126
|
|
|
122
127
|
/*
|
|
123
128
|
* Registered after Dialog's own restore listener, so focus lands on the opener either way:
|
|
@@ -213,8 +218,10 @@ export class Sheet extends Dialog {
|
|
|
213
218
|
return;
|
|
214
219
|
}
|
|
215
220
|
if (this.options.closable && next < min / 2) {
|
|
221
|
+
// Restored first, so a prevented dismissal leaves the sheet at the size it had.
|
|
216
222
|
this._applySize(this.#dragStart);
|
|
217
|
-
this
|
|
223
|
+
this.#syncHandleAria();
|
|
224
|
+
this._requestDismiss('drag');
|
|
218
225
|
return;
|
|
219
226
|
}
|
|
220
227
|
const detents = this.#detents(total);
|
|
@@ -256,6 +263,15 @@ export class Sheet extends Dialog {
|
|
|
256
263
|
return vertical ? rect.height : rect.width;
|
|
257
264
|
}
|
|
258
265
|
|
|
266
|
+
/**
|
|
267
|
+
* A sheet's header button follows `closeButton`, not `closable`: Escape and the ✕ are separate.
|
|
268
|
+
* @returns {boolean}
|
|
269
|
+
* @protected
|
|
270
|
+
*/
|
|
271
|
+
_hasCloseButton() {
|
|
272
|
+
return Boolean(this.options.closeButton);
|
|
273
|
+
}
|
|
274
|
+
|
|
259
275
|
/**
|
|
260
276
|
* Resolves a translated string, falling back to English when no translator knows the key.
|
|
261
277
|
* @param {string} key Message key.
|
|
@@ -386,15 +402,20 @@ export class Sheet extends Dialog {
|
|
|
386
402
|
...entry,
|
|
387
403
|
// An Escape pressed outside the sheet and everything it opened is not addressed to it.
|
|
388
404
|
onEscape: (event) => {
|
|
389
|
-
if (!this.
|
|
390
|
-
|
|
405
|
+
if (!this._overlayContains(/** @type {Node|null} */ (event.target))) return false;
|
|
406
|
+
// Refused, but still reported — and the key stays free for whatever is underneath.
|
|
407
|
+
if (!this.options.closable) {
|
|
408
|
+
this.emit('cancel', { reason: 'escape' });
|
|
409
|
+
return false;
|
|
410
|
+
}
|
|
411
|
+
this._requestDismiss('escape');
|
|
391
412
|
return undefined;
|
|
392
413
|
},
|
|
393
|
-
onOutsidePointer: this.options.lightDismiss ? () => { this.
|
|
414
|
+
onOutsidePointer: this.options.lightDismiss ? () => { this._requestDismiss('outside'); } : undefined,
|
|
394
415
|
// Hosted inside a modal that has now closed, the sheet would stay open but never be seen.
|
|
395
416
|
onParentClose: () => {
|
|
396
417
|
const holder = this.el.parentElement?.closest('dialog');
|
|
397
|
-
if (holder && !holder.open && !holder
|
|
418
|
+
if (holder && !holder.open && !matchesState(holder, ':popover-open')) this.close();
|
|
398
419
|
}
|
|
399
420
|
};
|
|
400
421
|
}
|
|
@@ -499,9 +520,14 @@ export class Sheet extends Dialog {
|
|
|
499
520
|
return;
|
|
500
521
|
}
|
|
501
522
|
this.el.setAttribute('aria-modal', 'false');
|
|
502
|
-
|
|
523
|
+
/*
|
|
524
|
+
* Docked, the sheet is a native non-modal dialog in flow. Floating, it wants the popover top
|
|
525
|
+
* layer; where the platform has no `showPopover()` it is presented the same in-flow way, and
|
|
526
|
+
* without the `popover` attribute, which would otherwise keep it hidden.
|
|
527
|
+
*/
|
|
528
|
+
if (this._dock || typeof (/** @type {HTMLElement} */ (this.el)).showPopover !== 'function') {
|
|
503
529
|
this.el.removeAttribute('popover');
|
|
504
|
-
|
|
530
|
+
showDialog(this.el);
|
|
505
531
|
return;
|
|
506
532
|
}
|
|
507
533
|
this.el.setAttribute('popover', 'manual');
|
|
@@ -515,7 +541,7 @@ export class Sheet extends Dialog {
|
|
|
515
541
|
* @returns {void}
|
|
516
542
|
*/
|
|
517
543
|
_hide(result = '', presentation) {
|
|
518
|
-
if (!this.el
|
|
544
|
+
if (!matchesState(this.el, ':popover-open')) {
|
|
519
545
|
super._hide(result, presentation);
|
|
520
546
|
return;
|
|
521
547
|
}
|
|
@@ -526,7 +552,7 @@ export class Sheet extends Dialog {
|
|
|
526
552
|
|
|
527
553
|
/** @returns {boolean} */
|
|
528
554
|
_isShown() {
|
|
529
|
-
return this.el
|
|
555
|
+
return matchesState(this.el, ':popover-open') || super._isShown();
|
|
530
556
|
}
|
|
531
557
|
|
|
532
558
|
/**
|
|
@@ -24,6 +24,9 @@ export function registerSliderFieldAdapter() {
|
|
|
24
24
|
slider.on('input', (event) => field.emit('input', { value: event.detail.value }));
|
|
25
25
|
return {
|
|
26
26
|
el: slider.el,
|
|
27
|
+
// The range input is what the label names and what the field's description and validity
|
|
28
|
+
// belong to; the field's label replaces the slider's own hidden one as its name.
|
|
29
|
+
labelTarget: slider.refs.input,
|
|
27
30
|
get: () => slider.get(),
|
|
28
31
|
set: (value) => {
|
|
29
32
|
setting = true;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Component } from '../../core/component.js';
|
|
2
2
|
import { h, restoreTarget, snapshotTarget } from '../../core/dom.js';
|
|
3
3
|
import { clamp, uid } from '../../core/util.js';
|
|
4
|
-
import { snapNumber } from '../number-field/number-field.js';
|
|
4
|
+
import { decimalsOf, snapNumber } from '../number-field/number-field.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @typedef {Object} SliderMark
|
|
@@ -387,15 +387,13 @@ const CHANGE_KEYS = new Set([
|
|
|
387
387
|
]);
|
|
388
388
|
|
|
389
389
|
/**
|
|
390
|
-
* Decimal places a step carries, so a 0.1 step snaps to 0.3 rather than 0.30000000000000004
|
|
390
|
+
* Decimal places a step carries, so a 0.1 step snaps to 0.3 rather than 0.30000000000000004 —
|
|
391
|
+
* exponent form included (`1.5e-7` carries 8).
|
|
391
392
|
* @param {number} step Step size.
|
|
392
393
|
* @returns {number}
|
|
393
394
|
*/
|
|
394
395
|
export function stepPrecision(step) {
|
|
395
|
-
|
|
396
|
-
const exponent = /e-(\d+)$/i.exec(text);
|
|
397
|
-
if (exponent) return Number(exponent[1]);
|
|
398
|
-
return (text.split('.')[1] ?? '').length;
|
|
396
|
+
return decimalsOf(step);
|
|
399
397
|
}
|
|
400
398
|
|
|
401
399
|
/** @param {number} value @returns {string} */
|