@zeyos/zx 5.8.0 → 5.9.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 +93 -0
- package/dist/types/components/block-view/block-view.d.ts +3 -2
- package/dist/types/components/check-button/check-button.d.ts +10 -2
- package/dist/types/components/checklist/checklist.d.ts +28 -6
- package/dist/types/components/code-editor/code-editor.d.ts +19 -1
- package/dist/types/components/dock/dock.d.ts +2 -1
- package/dist/types/components/dropdown/dropdown.d.ts +2 -1
- package/dist/types/components/field-upload/field-upload.d.ts +6 -0
- package/dist/types/components/filter-panel/filter-panel.d.ts +6 -2
- package/dist/types/components/module-bar/module-bar.d.ts +53 -2
- package/dist/types/components/multi-value-editor/multi-value-editor.d.ts +28 -0
- package/dist/types/components/run-status/run-status.d.ts +1 -1
- package/dist/types/components/run-trace/run-trace.d.ts +8 -0
- package/dist/types/components/select/select.d.ts +18 -5
- package/dist/types/components/tabbox/tabbox.d.ts +7 -0
- package/dist/types/components/tag-picker/tag-picker.d.ts +21 -5
- package/dist/types/components/timebox/timebox.d.ts +9 -0
- package/dist/types/core/component.d.ts +4 -1
- package/dist/types/internal/focus-stops.d.ts +42 -0
- package/dist/zx-zeyos.esm.js +296 -97
- package/dist/zx-zeyos.esm.min.js +4 -4
- package/dist/zx.core.css +13 -6
- package/dist/zx.core.min.css +1 -1
- package/dist/zx.css +26 -88
- package/dist/zx.esm.js +516 -159
- package/dist/zx.esm.min.js +26 -26
- package/dist/zx.global.js +516 -159
- package/dist/zx.global.min.js +26 -26
- package/dist/zx.layered.css +26 -88
- package/dist/zx.layered.min.css +1 -1
- package/dist/zx.min.css +1 -1
- package/docs/api.json +97 -9
- package/docs/components/approval-card.md +2 -2
- package/docs/components/block-view.md +2 -1
- package/docs/components/check-button.md +3 -1
- package/docs/components/checklist.md +2 -1
- package/docs/components/code-editor.md +4 -3
- package/docs/components/composer.md +4 -0
- package/docs/components/dock.md +4 -1
- package/docs/components/dropdown.md +3 -1
- package/docs/components/field-upload.md +2 -1
- package/docs/components/modal.md +3 -0
- package/docs/components/multi-value-editor.md +5 -2
- package/docs/components/navigation-bar.md +5 -0
- package/docs/components/questionnaire.md +2 -2
- package/docs/components/run-status.md +2 -1
- package/docs/components/run-trace.md +2 -1
- package/docs/components/select.md +6 -2
- package/docs/components/tabbox.md +6 -0
- package/docs/components/tag-picker.md +3 -1
- package/docs/components/timebox.md +2 -1
- package/docs/components/tokens.md +20 -0
- package/docs/llms.md +84 -21
- package/package.json +1 -1
- package/src/components/app-sidebar/app-sidebar.js +1 -1
- package/src/components/approval-card/approval-card.css +0 -5
- package/src/components/approval-card/approval-card.js +2 -0
- package/src/components/block-view/block-view.css +0 -10
- package/src/components/block-view/block-view.js +11 -6
- package/src/components/card/card.css +3 -0
- package/src/components/card/card.js +2 -2
- package/src/components/card-view/card-view.css +5 -5
- package/src/components/card-view/card-view.js +3 -1
- package/src/components/check-button/check-button.js +5 -1
- package/src/components/checklist/checklist.js +26 -10
- package/src/components/checklist/field-adapter.js +5 -13
- package/src/components/code-editor/code-editor.js +24 -3
- package/src/components/composer/composer.css +15 -26
- package/src/components/copy/copy-input.css +3 -1
- package/src/components/dialog/dialog.js +2 -1
- package/src/components/dock/dock.css +0 -6
- package/src/components/dock/dock.js +22 -7
- package/src/components/dropdown/dropdown.js +17 -2
- package/src/components/field/field.js +2 -1
- package/src/components/field-upload/field-upload.js +15 -0
- package/src/components/filter-panel/filter-panel.js +8 -11
- package/src/components/master-panel/master-panel.js +3 -1
- package/src/components/modal/modal.css +2 -11
- package/src/components/modal/modal.js +5 -2
- package/src/components/module-bar/module-bar.js +110 -26
- package/src/components/multi-value-editor/field-adapter.js +8 -23
- package/src/components/multi-value-editor/multi-value-editor.js +63 -5
- package/src/components/navigation-bar/navigation-bar.css +0 -4
- package/src/components/navigation-bar/navigation-bar.js +11 -2
- package/src/components/questionnaire/questionnaire.css +0 -14
- package/src/components/questionnaire/questionnaire.js +4 -2
- package/src/components/run-status/run-status.css +0 -7
- package/src/components/run-status/run-status.js +3 -1
- package/src/components/run-trace/run-trace.css +0 -5
- package/src/components/run-trace/run-trace.js +23 -2
- package/src/components/select/select.js +43 -5
- package/src/components/skeleton/skeleton.js +16 -3
- package/src/components/surface/surface.css +0 -6
- package/src/components/surface/surface.js +1 -1
- package/src/components/tabbox/tabbox.css +0 -6
- package/src/components/tabbox/tabbox.js +20 -2
- package/src/components/table/table.js +5 -0
- package/src/components/tag-picker/tag-picker.js +35 -6
- package/src/components/timebox/timebox.js +17 -1
- package/src/components/view-settings/view-settings.js +1 -1
- package/src/core/component.js +22 -2
- package/src/core/date.js +1 -4
- package/src/core/drag-axis.js +22 -6
- package/src/internal/focus-stops.js +108 -0
- package/src/zeyos/connect.js +7 -3
- package/src/zeyos/icons.js +7 -2
- package/styles/base.css +27 -3
- package/styles/tokens/dark.css +2 -2
- package/styles/tokens/semantic.css +2 -2
|
@@ -11,34 +11,19 @@ export function registerMultiValueEditorFieldAdapter() {
|
|
|
11
11
|
...(options.props ?? {}),
|
|
12
12
|
values: Array.isArray(options.value) ? options.value : []
|
|
13
13
|
}));
|
|
14
|
-
const originalDisabled = new WeakMap();
|
|
15
|
-
let disabled = false;
|
|
16
|
-
const syncDisabled = () => {
|
|
17
|
-
editor.el.setAttribute('aria-disabled', String(disabled));
|
|
18
|
-
for (const control of editor.el.querySelectorAll('input, button, select, textarea')) {
|
|
19
|
-
if (disabled) {
|
|
20
|
-
if (!originalDisabled.has(control)) originalDisabled.set(control, Boolean(control.disabled));
|
|
21
|
-
control.disabled = true;
|
|
22
|
-
} else if (originalDisabled.has(control)) {
|
|
23
|
-
control.disabled = originalDisabled.get(control);
|
|
24
|
-
originalDisabled.delete(control);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
14
|
field.listen(editor.el, 'change', (event) => event.stopImmediatePropagation());
|
|
29
15
|
editor.on('change', (event) => field.emit('change', { value: event.detail.values }));
|
|
30
16
|
return {
|
|
31
17
|
el: editor.el,
|
|
32
18
|
get: () => editor.getValues(),
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
19
|
+
// Rows the editor renders while disabled are rendered disabled, so a value set on a
|
|
20
|
+
// disabled field needs nothing more.
|
|
21
|
+
set: (value) => editor.setValues(Array.isArray(value) ? value : [], { silent: true }),
|
|
22
|
+
// The first value, else the first control: a selector list matches in document order, which
|
|
23
|
+
// would put the drag handle ahead of the value it belongs to.
|
|
24
|
+
focus: () => (editor.el.querySelector('.zx-multi-value-editor__value:not([disabled])')
|
|
25
|
+
?? editor.el.querySelector('button:not([disabled])'))?.focus(),
|
|
26
|
+
setDisabled: (value) => { editor.setDisabled(value); }
|
|
42
27
|
};
|
|
43
28
|
});
|
|
44
29
|
}
|
|
@@ -10,6 +10,8 @@ import { ICON_SIZE, icon } from '../../core/icons.js';
|
|
|
10
10
|
* message ("Add value").
|
|
11
11
|
* @property {'both'|'buttons'|'drag'|'none'} [reorder='both'] Reordering affordances each row gets:
|
|
12
12
|
* a drag handle, the up/down buttons, both, or neither.
|
|
13
|
+
* @property {boolean} [disabled=false] Whether every row control (values, handles, move and remove
|
|
14
|
+
* buttons) and the add button are disabled; values can still be set from code.
|
|
13
15
|
* @property {(event: CustomEvent<{values: string[]}>) => void} [onchange] Values change listener.
|
|
14
16
|
*/
|
|
15
17
|
|
|
@@ -43,7 +45,7 @@ export class MultiValueEditor extends Component {
|
|
|
43
45
|
static cssName = 'multi-value-editor';
|
|
44
46
|
|
|
45
47
|
/** @type {MultiValueEditorOptions} */
|
|
46
|
-
static defaults = { values: [], options: null, addLabel: null, reorder: 'both' };
|
|
48
|
+
static defaults = { values: [], options: null, addLabel: null, reorder: 'both', disabled: false };
|
|
47
49
|
|
|
48
50
|
/** @returns {HTMLElement} */
|
|
49
51
|
render() {
|
|
@@ -52,6 +54,8 @@ export class MultiValueEditor extends Component {
|
|
|
52
54
|
this._values = Array.isArray(this.options.values) ? this.options.values.map(String) : [];
|
|
53
55
|
this._ownedNodes = [];
|
|
54
56
|
this._initialState = root.getAttribute('data-state');
|
|
57
|
+
this._initialAriaDisabled = root.getAttribute('aria-disabled');
|
|
58
|
+
this._disabled = Boolean(this.options.disabled);
|
|
55
59
|
this._dragIndex = -1;
|
|
56
60
|
/** @type {HTMLElement|null} Row made draggable by a pointer press on its handle. */
|
|
57
61
|
this._armed = null;
|
|
@@ -79,6 +83,7 @@ export class MultiValueEditor extends Component {
|
|
|
79
83
|
this.listen(document, 'pointercancel', () => this._disarm());
|
|
80
84
|
}
|
|
81
85
|
this._renderRows();
|
|
86
|
+
this._syncDisabled();
|
|
82
87
|
return root;
|
|
83
88
|
}
|
|
84
89
|
|
|
@@ -103,6 +108,51 @@ export class MultiValueEditor extends Component {
|
|
|
103
108
|
return this;
|
|
104
109
|
}
|
|
105
110
|
|
|
111
|
+
/**
|
|
112
|
+
* Disables or enables the editor. Disabled, every value input or select, drag handle, move and
|
|
113
|
+
* remove button and the add button is disabled, the root carries `aria-disabled="true"`, and
|
|
114
|
+
* neither a pointer nor the handle's keys reorder anything. `setValues()` still works, and rows
|
|
115
|
+
* it renders stay disabled.
|
|
116
|
+
* @param {boolean} disabled Disabled state.
|
|
117
|
+
* @returns {this}
|
|
118
|
+
*/
|
|
119
|
+
setDisabled(disabled) {
|
|
120
|
+
this._disabled = Boolean(disabled);
|
|
121
|
+
this._syncDisabled();
|
|
122
|
+
return this;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** Disables the editor; see `setDisabled()`. @returns {this} */
|
|
126
|
+
disable() {
|
|
127
|
+
return this.setDisabled(true);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** Enables the editor. @returns {this} */
|
|
131
|
+
enable() {
|
|
132
|
+
return this.setDisabled(false);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** Whether the editor is disabled. @returns {boolean} */
|
|
136
|
+
isDisabled() {
|
|
137
|
+
return this._disabled;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Applies the disabled state to the controls in place rather than re-rendering them, so a value
|
|
142
|
+
* typed into a row and not yet committed survives.
|
|
143
|
+
* @returns {void}
|
|
144
|
+
*/
|
|
145
|
+
_syncDisabled() {
|
|
146
|
+
if (this._disabled) {
|
|
147
|
+
this.el.setAttribute('aria-disabled', 'true');
|
|
148
|
+
this._disarm();
|
|
149
|
+
} else this.el.removeAttribute('aria-disabled');
|
|
150
|
+
this._add.disabled = this._disabled;
|
|
151
|
+
for (const control of this._rows.querySelectorAll('input, select, button')) {
|
|
152
|
+
/** @type {HTMLInputElement|HTMLSelectElement|HTMLButtonElement} */ (control).disabled = this._disabled;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
106
156
|
/** @returns {{drag: boolean, buttons: boolean}} */
|
|
107
157
|
_reorder() {
|
|
108
158
|
return REORDER[this.options.reorder] ?? REORDER.both;
|
|
@@ -127,6 +177,7 @@ export class MultiValueEditor extends Component {
|
|
|
127
177
|
const control = useSelect ? h('select', {
|
|
128
178
|
class: 'zx-multi-value-editor__value',
|
|
129
179
|
ariaLabel: this.msg('multiValueEditor.value', index + 1),
|
|
180
|
+
disabled: this._disabled,
|
|
130
181
|
dataset: { index }
|
|
131
182
|
}, entries.map(([optionValue, label]) => h('option', {
|
|
132
183
|
value: optionValue,
|
|
@@ -136,6 +187,7 @@ export class MultiValueEditor extends Component {
|
|
|
136
187
|
type: 'text',
|
|
137
188
|
value,
|
|
138
189
|
ariaLabel: this.msg('multiValueEditor.value', index + 1),
|
|
190
|
+
disabled: this._disabled,
|
|
139
191
|
dataset: { index }
|
|
140
192
|
});
|
|
141
193
|
return h('div', { class: 'zx-multi-value-editor__row', dataset: { row: index } },
|
|
@@ -143,6 +195,7 @@ export class MultiValueEditor extends Component {
|
|
|
143
195
|
class: 'zx-multi-value-editor__handle',
|
|
144
196
|
type: 'button',
|
|
145
197
|
ariaLabel: this.msg('multiValueEditor.reorder', index + 1),
|
|
198
|
+
disabled: this._disabled,
|
|
146
199
|
dataset: { action: 'grab', index }
|
|
147
200
|
}, icon('drag', { size: 12 })) : null,
|
|
148
201
|
control,
|
|
@@ -154,6 +207,7 @@ export class MultiValueEditor extends Component {
|
|
|
154
207
|
// control that disables itself under the reader's finger drops focus to the document.
|
|
155
208
|
ariaDisabled: String(index === 0),
|
|
156
209
|
ariaLabel: this.msg('multiValueEditor.moveUp', index + 1),
|
|
210
|
+
disabled: this._disabled,
|
|
157
211
|
dataset: { action: 'up', index }
|
|
158
212
|
}, icon('chevron-up', { size: ICON_SIZE.chevron })) : null,
|
|
159
213
|
buttons ? h('button', {
|
|
@@ -161,12 +215,14 @@ export class MultiValueEditor extends Component {
|
|
|
161
215
|
type: 'button',
|
|
162
216
|
ariaDisabled: String(index === last),
|
|
163
217
|
ariaLabel: this.msg('multiValueEditor.moveDown', index + 1),
|
|
218
|
+
disabled: this._disabled,
|
|
164
219
|
dataset: { action: 'down', index }
|
|
165
220
|
}, icon('chevron-down', { size: ICON_SIZE.chevron })) : null,
|
|
166
221
|
h('button', {
|
|
167
222
|
class: 'zx-btn',
|
|
168
223
|
type: 'button',
|
|
169
224
|
ariaLabel: this.msg('multiValueEditor.remove', index + 1),
|
|
225
|
+
disabled: this._disabled,
|
|
170
226
|
dataset: { action: 'remove', index }
|
|
171
227
|
}, icon('x', { size: ICON_SIZE.dismiss }))
|
|
172
228
|
)
|
|
@@ -183,7 +239,7 @@ export class MultiValueEditor extends Component {
|
|
|
183
239
|
/** @param {MouseEvent} event @returns {void} */
|
|
184
240
|
_handleClick(event) {
|
|
185
241
|
const button = event.target instanceof Element ? event.target.closest('[data-action]') : null;
|
|
186
|
-
if (!button || !this.el.contains(button)) return;
|
|
242
|
+
if (this._disabled || !button || !this.el.contains(button)) return;
|
|
187
243
|
if (button.getAttribute('aria-disabled') === 'true') return;
|
|
188
244
|
const action = button.dataset.action;
|
|
189
245
|
const index = Number(button.dataset.index);
|
|
@@ -222,7 +278,7 @@ export class MultiValueEditor extends Component {
|
|
|
222
278
|
const handle = event.target instanceof Element
|
|
223
279
|
? event.target.closest('.zx-multi-value-editor__handle')
|
|
224
280
|
: null;
|
|
225
|
-
if (!handle) return;
|
|
281
|
+
if (!handle || this._disabled) return;
|
|
226
282
|
const index = Number(handle.dataset.index);
|
|
227
283
|
const target = event.key === 'ArrowUp' ? index - 1
|
|
228
284
|
: event.key === 'ArrowDown' ? index + 1
|
|
@@ -245,7 +301,7 @@ export class MultiValueEditor extends Component {
|
|
|
245
301
|
? event.target.closest('.zx-multi-value-editor__handle')
|
|
246
302
|
: null;
|
|
247
303
|
this._disarm();
|
|
248
|
-
if (!handle || handle.disabled) return;
|
|
304
|
+
if (!handle || handle.disabled || this._disabled) return;
|
|
249
305
|
const row = /** @type {HTMLElement|null} */ (handle.closest('.zx-multi-value-editor__row'));
|
|
250
306
|
if (!row) return;
|
|
251
307
|
row.draggable = true;
|
|
@@ -352,7 +408,7 @@ export class MultiValueEditor extends Component {
|
|
|
352
408
|
*/
|
|
353
409
|
_move(from, to, part) {
|
|
354
410
|
const size = this._values.length;
|
|
355
|
-
if (from === to || from < 0 || to < 0 || from >= size || to >= size) return false;
|
|
411
|
+
if (this._disabled || from === to || from < 0 || to < 0 || from >= size || to >= size) return false;
|
|
356
412
|
const [value] = this._values.splice(from, 1);
|
|
357
413
|
this._values.splice(to, 0, value);
|
|
358
414
|
this._renderRows(to, part);
|
|
@@ -369,6 +425,8 @@ export class MultiValueEditor extends Component {
|
|
|
369
425
|
destroy() {
|
|
370
426
|
if (this._initialState === null) this.el?.removeAttribute('data-state');
|
|
371
427
|
else this.el?.setAttribute('data-state', this._initialState);
|
|
428
|
+
if (this._initialAriaDisabled === null) this.el?.removeAttribute('aria-disabled');
|
|
429
|
+
else this.el?.setAttribute('aria-disabled', this._initialAriaDisabled);
|
|
372
430
|
for (const node of this._ownedNodes ?? []) node.remove();
|
|
373
431
|
super.destroy();
|
|
374
432
|
}
|
|
@@ -2,6 +2,7 @@ import { Component } from '../../core/component.js';
|
|
|
2
2
|
import { h } from '../../core/dom.js';
|
|
3
3
|
import { rovingStep } from '../../core/keyboard.js';
|
|
4
4
|
import { isElement, uid } from '../../core/util.js';
|
|
5
|
+
import { syncPanelStop } from '../../internal/focus-stops.js';
|
|
5
6
|
import { button } from '../button/button.js';
|
|
6
7
|
import { MenuButton } from '../menu-button/menu-button.js';
|
|
7
8
|
|
|
@@ -330,13 +331,14 @@ export class NavigationBar extends Component {
|
|
|
330
331
|
|
|
331
332
|
let panel = null;
|
|
332
333
|
if (this._tabMode) {
|
|
334
|
+
// A Tab stop only while it holds nothing that is one (see `_applyActive()`).
|
|
333
335
|
panel = h('div', {
|
|
334
336
|
class: 'zx-navigation-bar__panel',
|
|
335
337
|
id: panelId,
|
|
336
338
|
role: 'tabpanel',
|
|
337
|
-
tabindex: '0',
|
|
338
339
|
ariaLabelledby: tabId,
|
|
339
|
-
hidden: true
|
|
340
|
+
hidden: true,
|
|
341
|
+
dataset: { zxFocus: 'region' }
|
|
340
342
|
});
|
|
341
343
|
this.refs.panels.append(panel);
|
|
342
344
|
}
|
|
@@ -363,6 +365,7 @@ export class NavigationBar extends Component {
|
|
|
363
365
|
item.item.setAttribute('aria-selected', String(active));
|
|
364
366
|
item.item.tabIndex = active ? 0 : -1;
|
|
365
367
|
if (item.panel) item.panel.hidden = !active;
|
|
368
|
+
if (active && item.panel) syncPanelStop(item.panel);
|
|
366
369
|
} else if (active) {
|
|
367
370
|
item.item.setAttribute('aria-current', 'page');
|
|
368
371
|
} else {
|
|
@@ -392,6 +395,12 @@ export class NavigationBar extends Component {
|
|
|
392
395
|
if (!item || !this.refs.items.contains(item)) return;
|
|
393
396
|
const current = this._items.find((record) => record.item === item);
|
|
394
397
|
if (!current) return;
|
|
398
|
+
if (event.key === 'Tab' && !event.shiftKey) {
|
|
399
|
+
// The panel's content may have changed since it was shown; settle its stop before Tab moves.
|
|
400
|
+
const active = this._activeName === null ? null : this._find(this._activeName);
|
|
401
|
+
if (active?.panel) syncPanelStop(active.panel);
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
395
404
|
const enabled = this._enabledItems();
|
|
396
405
|
if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') {
|
|
397
406
|
event.preventDefault();
|
|
@@ -50,16 +50,6 @@
|
|
|
50
50
|
min-inline-size: 0;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
.zx-questionnaire__item:focus {
|
|
54
|
-
outline-color: transparent;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.zx-questionnaire__item:focus-visible {
|
|
58
|
-
outline-color: transparent;
|
|
59
|
-
box-shadow: var(--zx-focus-ring);
|
|
60
|
-
border-radius: var(--zx-questionnaire-radius);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
53
|
/* `<legend>` is laid out by the fieldset rather than by its own display, so it is taken out of
|
|
64
54
|
that flow and placed as an ordinary block before the answers. */
|
|
65
55
|
.zx-questionnaire__prompt {
|
|
@@ -290,10 +280,6 @@
|
|
|
290
280
|
gap: var(--zx-space-3);
|
|
291
281
|
}
|
|
292
282
|
|
|
293
|
-
.zx-questionnaire__review:focus {
|
|
294
|
-
outline-color: transparent;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
283
|
|
|
298
284
|
.zx-questionnaire__review-title {
|
|
299
285
|
margin: 0;
|
|
@@ -205,11 +205,13 @@ export class Questionnaire extends Component {
|
|
|
205
205
|
this._form.setAttribute('novalidate', '');
|
|
206
206
|
|
|
207
207
|
this._progressHost = h('div', { class: 'zx-questionnaire__progress', hidden: !this.options.progress });
|
|
208
|
+
// Both take focus only from a script, when a step changes under the reader; neither is a Tab stop.
|
|
208
209
|
this._itemHost = h('fieldset', {
|
|
209
210
|
class: 'zx-questionnaire__item',
|
|
210
|
-
tabIndex: -1
|
|
211
|
+
tabIndex: -1,
|
|
212
|
+
dataset: { zxFocus: 'container' }
|
|
211
213
|
});
|
|
212
|
-
this._reviewHost = h('div', { class: 'zx-questionnaire__review', tabIndex: -1, hidden: true });
|
|
214
|
+
this._reviewHost = h('div', { class: 'zx-questionnaire__review', tabIndex: -1, hidden: true, dataset: { zxFocus: 'container' } });
|
|
213
215
|
this._actionsHost = h('div', { class: 'zx-questionnaire__actions' });
|
|
214
216
|
this.refs.item = this._itemHost;
|
|
215
217
|
this.refs.review = this._reviewHost;
|
|
@@ -12,13 +12,6 @@
|
|
|
12
12
|
font-size: var(--zx-text-sm);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
/* The panel holds focus itself only when an update took away the control that had it. */
|
|
16
|
-
.zx-run-status:focus-visible {
|
|
17
|
-
border-radius: var(--zx-radius-md);
|
|
18
|
-
outline-color: transparent;
|
|
19
|
-
box-shadow: var(--zx-focus-ring);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
15
|
/* ------------------------------------------------------------------ state -- */
|
|
23
16
|
|
|
24
17
|
.zx-run-status__state {
|
|
@@ -221,7 +221,7 @@ export class RunStatus extends Component {
|
|
|
221
221
|
/** @type {AgentAvatar|null} The agent's face, kept across draws while it asks for the same traits. */
|
|
222
222
|
this._avatar = null;
|
|
223
223
|
this._faceKey = '';
|
|
224
|
-
/** Whether the root took `tabindex="-1"` to hold focus that had nowhere else to go. */
|
|
224
|
+
/** Whether the root took `tabindex="-1"` (and `data-zx-focus`) to hold focus that had nowhere else to go. */
|
|
225
225
|
this._heldFocus = false;
|
|
226
226
|
/** @type {ReturnType<typeof setInterval>|0} */
|
|
227
227
|
this._interval = 0;
|
|
@@ -424,6 +424,7 @@ export class RunStatus extends Component {
|
|
|
424
424
|
}
|
|
425
425
|
if (!root.hasAttribute('tabindex')) {
|
|
426
426
|
root.tabIndex = -1;
|
|
427
|
+
root.dataset.zxFocus = 'container';
|
|
427
428
|
this._heldFocus = true;
|
|
428
429
|
}
|
|
429
430
|
root.focus({ preventScroll: true });
|
|
@@ -434,6 +435,7 @@ export class RunStatus extends Component {
|
|
|
434
435
|
if (!this._heldFocus) return;
|
|
435
436
|
this._heldFocus = false;
|
|
436
437
|
this.el.removeAttribute('tabindex');
|
|
438
|
+
this.el.removeAttribute('data-zx-focus');
|
|
437
439
|
}
|
|
438
440
|
|
|
439
441
|
/**
|
|
@@ -398,11 +398,6 @@ button.zx-run-trace__row:hover {
|
|
|
398
398
|
background: var(--zx-color-danger-bg);
|
|
399
399
|
}
|
|
400
400
|
|
|
401
|
-
.zx-run-trace__code:focus-visible {
|
|
402
|
-
outline-color: transparent;
|
|
403
|
-
box-shadow: var(--zx-focus-ring);
|
|
404
|
-
}
|
|
405
|
-
|
|
406
401
|
.zx-run-trace__more {
|
|
407
402
|
justify-self: start;
|
|
408
403
|
}
|
|
@@ -5,6 +5,7 @@ import { icon } from '../../core/icons.js';
|
|
|
5
5
|
import { formatNumber } from '../../core/format.js';
|
|
6
6
|
import { prefersReducedMotion } from '../../core/motion.js';
|
|
7
7
|
import { uid } from '../../core/util.js';
|
|
8
|
+
import { syncScrollStop } from '../../internal/focus-stops.js';
|
|
8
9
|
import {
|
|
9
10
|
AGENT_MESSAGES, STATUS, agentAvatarOptions, authorFace, formatDuration, formatElapsed, initialsOf, normalizeRunState, traceSummary
|
|
10
11
|
} from '../../internal/agent-model.js';
|
|
@@ -263,6 +264,9 @@ export class RunTrace extends Component {
|
|
|
263
264
|
}
|
|
264
265
|
});
|
|
265
266
|
if (this.options.ticking) this.listen(root.ownerDocument, 'visibilitychange', () => this._syncClock());
|
|
267
|
+
// A width change rewraps the code blocks, which can start or stop them scrolling.
|
|
268
|
+
this._resize = typeof ResizeObserver === 'function' ? new ResizeObserver(() => this._syncCodeStops(root)) : null;
|
|
269
|
+
this._resize?.observe(root);
|
|
266
270
|
this._build(this.options.steps);
|
|
267
271
|
return root;
|
|
268
272
|
}
|
|
@@ -391,6 +395,8 @@ export class RunTrace extends Component {
|
|
|
391
395
|
this._revealTimer = null;
|
|
392
396
|
if (this._clock) clearInterval(this._clock);
|
|
393
397
|
this._clock = null;
|
|
398
|
+
this._resize?.disconnect();
|
|
399
|
+
this._resize = null;
|
|
394
400
|
for (const entry of this._entries.values()) this._releaseAvatars(entry);
|
|
395
401
|
this._entries.clear();
|
|
396
402
|
super.destroy();
|
|
@@ -531,6 +537,7 @@ export class RunTrace extends Component {
|
|
|
531
537
|
entry.row = row;
|
|
532
538
|
entry.refs = refs;
|
|
533
539
|
entry.body = body;
|
|
540
|
+
if (body) this._syncCodeStops(body);
|
|
534
541
|
const again = focusedRef === null ? null
|
|
535
542
|
: /** @type {HTMLElement|null} */ (refs?.querySelector(`[data-ref-index="${focusedRef}"]`) ?? null);
|
|
536
543
|
if (again) again.focus({ preventScroll: true });
|
|
@@ -666,11 +673,11 @@ export class RunTrace extends Component {
|
|
|
666
673
|
h('div', { class: 'zx-run-trace__section-head' },
|
|
667
674
|
h('span', { class: 'zx-run-trace__section-title', id: titleId }, this.msg(keys.title)),
|
|
668
675
|
copyButton({ text: full, title: this.msg(keys.copy), feedback: this.msg('runTrace.copied'), size: 'sm' })),
|
|
676
|
+
// A Tab stop only while its text scrolls (`_syncCodeStops()`).
|
|
669
677
|
h('pre', {
|
|
670
678
|
class: 'zx-run-trace__code',
|
|
671
|
-
tabindex: '0',
|
|
672
679
|
'aria-labelledby': titleId,
|
|
673
|
-
dataset: { tone: kind === 'error' ? 'danger' : null }
|
|
680
|
+
dataset: { tone: kind === 'error' ? 'danger' : null, zxFocus: 'region' }
|
|
674
681
|
}, shown.text),
|
|
675
682
|
shown.cut ? h('button', {
|
|
676
683
|
type: 'button', class: 'zx-btn zx-run-trace__more', dataset: { kind: 'ghost', size: 'sm', action: 'show-all' }
|
|
@@ -689,6 +696,7 @@ export class RunTrace extends Component {
|
|
|
689
696
|
this._open = open;
|
|
690
697
|
this._summary.setAttribute('aria-expanded', String(open));
|
|
691
698
|
this._list.hidden = !open;
|
|
699
|
+
if (open) this._syncCodeStops(this._list);
|
|
692
700
|
this._syncClock();
|
|
693
701
|
this.emit('toggle', { id: null, open });
|
|
694
702
|
}
|
|
@@ -706,9 +714,22 @@ export class RunTrace extends Component {
|
|
|
706
714
|
else this._expanded.delete(id);
|
|
707
715
|
entry.row.setAttribute('aria-expanded', String(open));
|
|
708
716
|
entry.body.hidden = !open;
|
|
717
|
+
if (open) this._syncCodeStops(entry.body);
|
|
709
718
|
this.emit('toggle', { id, open });
|
|
710
719
|
}
|
|
711
720
|
|
|
721
|
+
/**
|
|
722
|
+
* Makes each code block a Tab stop while, and only while, its text scrolls inside it.
|
|
723
|
+
* @private
|
|
724
|
+
* @param {Element} scope Where to look for code blocks.
|
|
725
|
+
* @returns {void}
|
|
726
|
+
*/
|
|
727
|
+
_syncCodeStops(scope) {
|
|
728
|
+
for (const code of /** @type {NodeListOf<HTMLElement>} */ (scope.querySelectorAll('.zx-run-trace__code'))) {
|
|
729
|
+
syncScrollStop(code);
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
|
|
712
733
|
/**
|
|
713
734
|
* Redraws the summary from the steps.
|
|
714
735
|
* @private
|
|
@@ -36,7 +36,9 @@ import {
|
|
|
36
36
|
* @property {string} [placeholder=''] Empty control text.
|
|
37
37
|
* @property {string} [label=''] Accessible combobox name; falls back to the placeholder.
|
|
38
38
|
* @property {boolean} [clearable=false] Whether selection may be cleared.
|
|
39
|
-
* @property {false|'local'|
|
|
39
|
+
* @property {false|'local'|SelectFilter} [filter=false] Filtering mode: no filtering (a read-only
|
|
40
|
+
* input that opens the list), `'local'` matching against `items`, or a function that returns the
|
|
41
|
+
* items for a query (see `SelectFilter`).
|
|
40
42
|
* @property {Array<SelectValueReader>|null} [searchKeys=null] Fields searched by local filtering.
|
|
41
43
|
* @property {number} [minQuery=0] Minimum async query length.
|
|
42
44
|
* @property {number} [debounce=200] Async query delay in milliseconds.
|
|
@@ -69,6 +71,15 @@ import {
|
|
|
69
71
|
/** @typedef {{id: string|number, action: SelectAction, query: string, select: Select}} SelectActionDetail */
|
|
70
72
|
/** @typedef {{item: SelectItem|null, clear: boolean, action: SelectAction|null, element: HTMLElement}} SelectOptionEntry */
|
|
71
73
|
/** @typedef {{silent?: boolean}} SelectSetOptions */
|
|
74
|
+
/**
|
|
75
|
+
* An asynchronous filter: returns the items for a query, or a promise of them. The second argument
|
|
76
|
+
* carries an `AbortSignal` that aborts as soon as the answer would be ignored — a newer query
|
|
77
|
+
* starts, the list closes (or the Select is disabled), or the Select is destroyed — so the request
|
|
78
|
+
* can be cancelled by passing the signal on, e.g. `fetch(url, { signal })`. A result that arrives
|
|
79
|
+
* after its query was superseded is discarded whether or not the request honoured the signal, so
|
|
80
|
+
* the rejection an aborted request ends in changes nothing.
|
|
81
|
+
* @typedef {(query: string, context: {signal: AbortSignal}) => Promise<SelectItem[]>|SelectItem[]} SelectFilter
|
|
82
|
+
*/
|
|
72
83
|
|
|
73
84
|
// Internal factory configuration; ordinary Select instances keep their IDs unchanged.
|
|
74
85
|
const NORMALIZE_VALUE = Symbol('normalizeSelectValue');
|
|
@@ -126,7 +137,7 @@ export class Select extends Component {
|
|
|
126
137
|
render() {
|
|
127
138
|
// Instance state initialized here because render() runs inside the base
|
|
128
139
|
// constructor, before class-field initializers would run (and clobber it).
|
|
129
|
-
this._items = []; this._visibleItems = []; this._fixedItems = []; this._visibleFixed = []; this._actions = []; this._selected = null; this._optionEntries = []; this._activeIndex = -1; this._open = false; this._disabled = false; this._loading = false; this._requestSequence = 0; this._queryTimer = null; this._position = null; this._createdRoot = false; this._root = null; this._snapshot = null; this._pointerModality = false;
|
|
140
|
+
this._items = []; this._visibleItems = []; this._fixedItems = []; this._visibleFixed = []; this._actions = []; this._selected = null; this._optionEntries = []; this._activeIndex = -1; this._open = false; this._disabled = false; this._loading = false; this._requestSequence = 0; this._queryTimer = null; this._queryController = null; this._position = null; this._createdRoot = false; this._root = null; this._snapshot = null; this._pointerModality = false;
|
|
130
141
|
/** @private @type {(value: string) => string} */
|
|
131
142
|
this._normalizeValue = this.options[NORMALIZE_VALUE] ?? ((value) => value);
|
|
132
143
|
this._createdRoot = this.el === null;
|
|
@@ -645,9 +656,10 @@ export class Select extends Component {
|
|
|
645
656
|
* `true` for public, or a group ID — so the control binds straight to the record field.
|
|
646
657
|
*
|
|
647
658
|
* @param {Element|string|null} target Component target.
|
|
648
|
-
* @param {SelectOptions & {groups?: SelectItem[]|
|
|
659
|
+
* @param {SelectOptions & {groups?: SelectItem[]|SelectFilter}} [options={}]
|
|
649
660
|
* Select overrides other than the fixed choices; `groups` holds the shareable groups, either as
|
|
650
|
-
* an array (filtered locally) or as a loader function (queried remotely
|
|
661
|
+
* an array (filtered locally) or as a loader function (queried remotely, and handed the same
|
|
662
|
+
* `{signal}` as any `filter` function).
|
|
651
663
|
* @returns {Select}
|
|
652
664
|
*/
|
|
653
665
|
static permission(target, options = {}) {
|
|
@@ -930,6 +942,9 @@ export class Select extends Component {
|
|
|
930
942
|
if (this._queryTimer !== null) clearTimeout(this._queryTimer);
|
|
931
943
|
this._requestSequence += 1;
|
|
932
944
|
const sequence = this._requestSequence;
|
|
945
|
+
this._abortQuery();
|
|
946
|
+
// An abort listener of the application's that started another query has superseded this one.
|
|
947
|
+
if (sequence !== this._requestSequence) return;
|
|
933
948
|
this._visibleFixed = this._matchFixed(query);
|
|
934
949
|
if (query.length < Math.max(0, Number(this.options.minQuery) || 0)) {
|
|
935
950
|
this._setLoading(false);
|
|
@@ -950,9 +965,17 @@ export class Select extends Component {
|
|
|
950
965
|
/** @param {string} query @param {number} sequence @returns {Promise<void>} */
|
|
951
966
|
async _runAsyncQuery(query, sequence) {
|
|
952
967
|
if (sequence !== this._requestSequence || typeof this.options.filter !== 'function') return;
|
|
968
|
+
// The controller is in place before `query` is reported, so a listener that closes or destroys
|
|
969
|
+
// the Select aborts it; and a query it superseded or cancelled never starts.
|
|
970
|
+
const controller = new AbortController();
|
|
971
|
+
this._queryController = controller;
|
|
953
972
|
this.emit('query', { query });
|
|
973
|
+
if (sequence !== this._requestSequence || controller.signal.aborted) {
|
|
974
|
+
if (this._queryController === controller) this._queryController = null;
|
|
975
|
+
return;
|
|
976
|
+
}
|
|
954
977
|
try {
|
|
955
|
-
const result = await this.options.filter(query);
|
|
978
|
+
const result = await this.options.filter(query, { signal: controller.signal });
|
|
956
979
|
if (sequence !== this._requestSequence || !this._open) return;
|
|
957
980
|
this._items = Array.isArray(result) ? result.slice() : [];
|
|
958
981
|
this._visibleItems = this._items.slice();
|
|
@@ -968,6 +991,9 @@ export class Select extends Component {
|
|
|
968
991
|
this._setLoading(false);
|
|
969
992
|
this._renderOptions();
|
|
970
993
|
this._position?.update();
|
|
994
|
+
} finally {
|
|
995
|
+
// A settled request has nothing left to cancel.
|
|
996
|
+
if (this._queryController === controller) this._queryController = null;
|
|
971
997
|
}
|
|
972
998
|
}
|
|
973
999
|
|
|
@@ -976,6 +1002,18 @@ export class Select extends Component {
|
|
|
976
1002
|
if (this._queryTimer !== null) clearTimeout(this._queryTimer);
|
|
977
1003
|
this._queryTimer = null;
|
|
978
1004
|
this._requestSequence += 1;
|
|
1005
|
+
this._abortQuery();
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
/**
|
|
1009
|
+
* Aborts the signal handed to the filter for the request in flight. Callers move the sequence on
|
|
1010
|
+
* first, so whatever the aborted request resolves or rejects with is already stale.
|
|
1011
|
+
* @returns {void}
|
|
1012
|
+
*/
|
|
1013
|
+
_abortQuery() {
|
|
1014
|
+
const controller = this._queryController;
|
|
1015
|
+
this._queryController = null;
|
|
1016
|
+
controller?.abort();
|
|
979
1017
|
}
|
|
980
1018
|
|
|
981
1019
|
/** @param {boolean} loading @returns {void} */
|
|
@@ -37,7 +37,7 @@ import { clamp } from '../../core/util.js';
|
|
|
37
37
|
* @returns {HTMLSpanElement}
|
|
38
38
|
*/
|
|
39
39
|
export function skeleton(opts = {}) {
|
|
40
|
-
const options = { width: '100%', height: '1rem', radius: 'sm', ...opts };
|
|
40
|
+
const options = { width: '100%', height: '1rem', radius: 'sm', ...given(opts) };
|
|
41
41
|
return /** @type {HTMLSpanElement} */ (h('span', {
|
|
42
42
|
class: 'zx-skeleton',
|
|
43
43
|
ariaHidden: 'true',
|
|
@@ -52,7 +52,7 @@ export function skeleton(opts = {}) {
|
|
|
52
52
|
* @returns {HTMLDivElement}
|
|
53
53
|
*/
|
|
54
54
|
export function skeletonText(opts = {}) {
|
|
55
|
-
const options = { lines: 3, width: '100%', heading: false, lastLineWidth: '60%', ...opts };
|
|
55
|
+
const options = { lines: 3, width: '100%', heading: false, lastLineWidth: '60%', ...given(opts) };
|
|
56
56
|
const lines = clamp(Math.trunc(Number(options.lines) || 0), 1, 20);
|
|
57
57
|
const element = /** @type {HTMLDivElement} */ (h('div', {
|
|
58
58
|
class: 'zx-skeleton-text',
|
|
@@ -81,7 +81,7 @@ export function skeletonText(opts = {}) {
|
|
|
81
81
|
* @returns {HTMLDivElement}
|
|
82
82
|
*/
|
|
83
83
|
export function skeletonTable(opts = {}) {
|
|
84
|
-
const options = { rows: 5, columns: 4, header: true, ...opts };
|
|
84
|
+
const options = { rows: 5, columns: 4, header: true, ...given(opts) };
|
|
85
85
|
const rows = clamp(Math.trunc(Number(options.rows) || 0), 1, 50);
|
|
86
86
|
const columns = clamp(Math.trunc(Number(options.columns) || 0), 1, 20);
|
|
87
87
|
const element = /** @type {HTMLDivElement} */ (h('div', {
|
|
@@ -129,6 +129,19 @@ function cellWidth(index, columns) {
|
|
|
129
129
|
return index % 2 === 0 ? '80%' : '65%';
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
+
/**
|
|
133
|
+
* The options actually passed: one passed as `undefined` is an option not passed, so its default
|
|
134
|
+
* applies — the way component options and destructuring defaults read it. `null` is still a value.
|
|
135
|
+
* @template {object} T
|
|
136
|
+
* @param {T|null|undefined} opts Options as passed.
|
|
137
|
+
* @returns {Partial<T>}
|
|
138
|
+
*/
|
|
139
|
+
function given(opts) {
|
|
140
|
+
return /** @type {Partial<T>} */ (Object.fromEntries(
|
|
141
|
+
Object.entries(opts ?? {}).filter(([, value]) => value !== undefined)
|
|
142
|
+
));
|
|
143
|
+
}
|
|
144
|
+
|
|
132
145
|
/**
|
|
133
146
|
* Normalizes a CSS length, reading a bare number as pixels.
|
|
134
147
|
* @param {string|number} value Width or height.
|
|
@@ -291,12 +291,6 @@
|
|
|
291
291
|
font-size: var(--zx-text-sm);
|
|
292
292
|
}
|
|
293
293
|
|
|
294
|
-
.zx-surface__verdict:focus-visible {
|
|
295
|
-
border-radius: var(--zx-radius-sm);
|
|
296
|
-
outline-color: transparent;
|
|
297
|
-
box-shadow: var(--zx-focus-ring);
|
|
298
|
-
}
|
|
299
|
-
|
|
300
294
|
.zx-surface__verdict-icon {
|
|
301
295
|
display: inline-flex;
|
|
302
296
|
}
|
|
@@ -1829,7 +1829,7 @@ export class Surface extends Component {
|
|
|
1829
1829
|
for (const [id, node] of this._model.nodes) if (this._entry(node.type)?.input) this._dirty.add(id);
|
|
1830
1830
|
const time = formatTime(reply.at, this.options.locale);
|
|
1831
1831
|
const verdict = verdictText(reply.action, this._model.actions ?? [], (key, ...args) => this.msg(key, ...args));
|
|
1832
|
-
this._verdict = h('p', { class: 'zx-surface__verdict', tabIndex: -1, dataset: { action: reply.action } },
|
|
1832
|
+
this._verdict = h('p', { class: 'zx-surface__verdict', tabIndex: -1, dataset: { action: reply.action, zxFocus: 'container' } },
|
|
1833
1833
|
h('span', { class: 'zx-surface__verdict-icon', 'aria-hidden': 'true' },
|
|
1834
1834
|
icon(CLOSING_ACTIONS.includes(reply.action) || reply.action === 'reject' ? 'x' : 'check', { size: 14 })),
|
|
1835
1835
|
h('span', {}, time ? this.msg('surface.verdictAt', verdict, time) : verdict));
|