@zeyos/zx 5.7.1 → 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 +296 -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 +19 -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 +13 -2
- 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 +11 -0
- 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 +7 -0
- 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 +18 -4
- 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/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 +2998 -451
- 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 +948 -48
- package/dist/zx.esm.js +7432 -3408
- package/dist/zx.esm.min.js +26 -26
- package/dist/zx.global.js +7432 -3408
- package/dist/zx.global.min.js +26 -26
- package/dist/zx.layered.css +950 -48
- 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 +3122 -528
- 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 +697 -100
- 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/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.js +46 -17
- package/src/components/checklist/field-adapter.js +4 -1
- 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 +22 -30
- 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 +70 -25
- 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 +2 -1
- 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 +27 -8
- 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/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 +51 -10
- package/src/core/keyboard.js +83 -9
- package/src/core/messages.js +3 -0
- package/src/core/position.js +2 -2
- 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.
|
|
@@ -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:
|
|
@@ -258,6 +263,15 @@ export class Sheet extends Dialog {
|
|
|
258
263
|
return vertical ? rect.height : rect.width;
|
|
259
264
|
}
|
|
260
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
|
+
|
|
261
275
|
/**
|
|
262
276
|
* Resolves a translated string, falling back to English when no translator knows the key.
|
|
263
277
|
* @param {string} key Message key.
|
|
@@ -401,7 +415,7 @@ export class Sheet extends Dialog {
|
|
|
401
415
|
// Hosted inside a modal that has now closed, the sheet would stay open but never be seen.
|
|
402
416
|
onParentClose: () => {
|
|
403
417
|
const holder = this.el.parentElement?.closest('dialog');
|
|
404
|
-
if (holder && !holder.open && !holder
|
|
418
|
+
if (holder && !holder.open && !matchesState(holder, ':popover-open')) this.close();
|
|
405
419
|
}
|
|
406
420
|
};
|
|
407
421
|
}
|
|
@@ -506,9 +520,14 @@ export class Sheet extends Dialog {
|
|
|
506
520
|
return;
|
|
507
521
|
}
|
|
508
522
|
this.el.setAttribute('aria-modal', 'false');
|
|
509
|
-
|
|
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') {
|
|
510
529
|
this.el.removeAttribute('popover');
|
|
511
|
-
|
|
530
|
+
showDialog(this.el);
|
|
512
531
|
return;
|
|
513
532
|
}
|
|
514
533
|
this.el.setAttribute('popover', 'manual');
|
|
@@ -522,7 +541,7 @@ export class Sheet extends Dialog {
|
|
|
522
541
|
* @returns {void}
|
|
523
542
|
*/
|
|
524
543
|
_hide(result = '', presentation) {
|
|
525
|
-
if (!this.el
|
|
544
|
+
if (!matchesState(this.el, ':popover-open')) {
|
|
526
545
|
super._hide(result, presentation);
|
|
527
546
|
return;
|
|
528
547
|
}
|
|
@@ -533,7 +552,7 @@ export class Sheet extends Dialog {
|
|
|
533
552
|
|
|
534
553
|
/** @returns {boolean} */
|
|
535
554
|
_isShown() {
|
|
536
|
-
return this.el
|
|
555
|
+
return matchesState(this.el, ':popover-open') || super._isShown();
|
|
537
556
|
}
|
|
538
557
|
|
|
539
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} */
|
|
@@ -62,12 +62,17 @@ import { skeleton } from '../skeleton/skeleton.js';
|
|
|
62
62
|
* display size while the others stay smaller, on a framed tile one step above the display size.
|
|
63
63
|
* Give it to one tile per row. Reflected as `data-emphasis="true"`.
|
|
64
64
|
* @property {string|null} [href=null] Destination. A tile with an href is an `<a>`.
|
|
65
|
-
* @property {boolean} [clickable=false] Renders a `<button>` without an href. Passing
|
|
66
|
-
* sets this implicitly; set it
|
|
65
|
+
* @property {boolean} [clickable=false] Renders a `<button>` without an href. Passing a function
|
|
66
|
+
* as `onclick` sets this implicitly; set it to `true` to subscribe with `on('click', …)` instead.
|
|
67
|
+
* An explicit `false` wins over `onclick`: the tile stays a `<div>` and the handler is never
|
|
68
|
+
* called — for a caller that always passes a handler and decides per tile whether it applies.
|
|
69
|
+
* It does not turn a tile with an `href` into anything but a link.
|
|
67
70
|
* @property {boolean} [loading=false] Renders a skeleton shaped like the tile.
|
|
68
71
|
* @property {Record<string, unknown>} [msg] Message overrides, keyed as `statTile.*`.
|
|
69
72
|
* @property {(event: CustomEvent<{event: MouseEvent}>) => void} [onclick] Activation listener; its
|
|
70
|
-
* presence is what turns a tile with no href into a button
|
|
73
|
+
* presence is what turns a tile with no href into a button, unless `clickable` is `false`. Leave
|
|
74
|
+
* it out — rather than passing an empty function — for a tile that does nothing. It is the
|
|
75
|
+
* tile's `click` event, as
|
|
71
76
|
* every Zx component's `on*` option is, so it receives the `CustomEvent` carrying the native
|
|
72
77
|
* event in `detail.event`.
|
|
73
78
|
*/
|
|
@@ -153,10 +158,7 @@ export class StatTile extends Component {
|
|
|
153
158
|
// `Component` consumes every function-valued `on*` option into a component event listener, so
|
|
154
159
|
// `options.onclick` no longer exists by the time `render()` chooses the element's tag. The
|
|
155
160
|
// shape decision is taken here, before the base constructor, and carried across as a flag.
|
|
156
|
-
super(target, {
|
|
157
|
-
...options,
|
|
158
|
-
clickable: options?.clickable === true || typeof options?.onclick === 'function'
|
|
159
|
-
});
|
|
161
|
+
super(target, { ...options, clickable: statTileClickable(options ?? {}) });
|
|
160
162
|
}
|
|
161
163
|
|
|
162
164
|
/**
|
|
@@ -325,8 +327,21 @@ export function normalizeStatTileVariant(value) {
|
|
|
325
327
|
*/
|
|
326
328
|
export function statTileTag(options = {}) {
|
|
327
329
|
if (safeHref(options.href)) return 'a';
|
|
328
|
-
|
|
329
|
-
|
|
330
|
+
return statTileClickable(options) ? 'button' : 'div';
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Whether a tile without a destination is an action. `clickable` decides when it is given as a
|
|
335
|
+
* boolean; left out (or nullish), a function-valued `onclick` does. So an explicit
|
|
336
|
+
* `clickable: false` wins over a handler, and a handler that is not a function is not behaviour.
|
|
337
|
+
* @param {{clickable?: boolean|null, onclick?: unknown}} [options={}] The options that carry
|
|
338
|
+
* behaviour.
|
|
339
|
+
* @returns {boolean}
|
|
340
|
+
*/
|
|
341
|
+
export function statTileClickable(options = {}) {
|
|
342
|
+
if (options.clickable === true) return true;
|
|
343
|
+
if (options.clickable === false) return false;
|
|
344
|
+
return typeof options.onclick === 'function';
|
|
330
345
|
}
|
|
331
346
|
|
|
332
347
|
/**
|
|
@@ -202,6 +202,21 @@ button.zx-stepper__control:disabled {
|
|
|
202
202
|
background: var(--zx-color-border);
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
+
/* A rail too wide for its container wraps. The last step of a row has no next step beside it, so
|
|
206
|
+
its connector would run to the container's edge and point at nothing; the component marks that
|
|
207
|
+
step (it is a fact of layout, not of the markup) and the connector is not painted. It keeps its
|
|
208
|
+
box — at the minimum width the step was measured with, so the mark cannot move the row break it
|
|
209
|
+
was read from — and the step stops growing, so the row's slack goes to the connectors that are
|
|
210
|
+
drawn. */
|
|
211
|
+
.zx-stepper[data-orientation="horizontal"] .zx-stepper__step[data-row-end] {
|
|
212
|
+
flex-grow: 0;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
.zx-stepper[data-orientation="horizontal"] .zx-stepper__step[data-row-end]::after {
|
|
216
|
+
flex: 0 0 var(--zx-space-4);
|
|
217
|
+
visibility: hidden;
|
|
218
|
+
}
|
|
219
|
+
|
|
205
220
|
/* ---------------------------------------------------------------------- vertical -- */
|
|
206
221
|
|
|
207
222
|
.zx-stepper[data-orientation="vertical"] .zx-stepper__list {
|