@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
|
@@ -21,6 +21,9 @@ import { uid } from '../../core/util.js';
|
|
|
21
21
|
* @property {'off'|'soft'|'hard'} [wrap='off'] Textarea wrapping behavior.
|
|
22
22
|
* @property {boolean} [spellcheck=false] Whether browser spellcheck is enabled.
|
|
23
23
|
* @property {boolean} [readOnly=false] Whether content can be selected but not changed.
|
|
24
|
+
* @property {boolean} [readonly=false] The same setting under the spelling every other Zx control
|
|
25
|
+
* uses. The editor starts read-only when either `readOnly` or `readonly` is true, so neither
|
|
26
|
+
* spelling can switch off what the other one turned on.
|
|
24
27
|
* @property {boolean} [disabled=false] Whether the editor is disabled.
|
|
25
28
|
* @property {boolean} [status=true] Whether the line/column status is visible.
|
|
26
29
|
* @property {(event: CustomEvent<{value:string}>) => void} [oninput] Input listener.
|
|
@@ -64,6 +67,7 @@ export class CodeEditor extends Component {
|
|
|
64
67
|
wrap: 'off',
|
|
65
68
|
spellcheck: false,
|
|
66
69
|
readOnly: false,
|
|
70
|
+
readonly: false,
|
|
67
71
|
disabled: false,
|
|
68
72
|
status: true
|
|
69
73
|
};
|
|
@@ -77,6 +81,8 @@ export class CodeEditor extends Component {
|
|
|
77
81
|
this._initialAttributes = new Map(['data-language', 'data-readonly', 'data-disabled', 'data-state']
|
|
78
82
|
.map((name) => [name, root.getAttribute(name)]));
|
|
79
83
|
this._language = normalizeLanguage(this.options.language);
|
|
84
|
+
// Either spelling turns read-only on; see the `readonly` option.
|
|
85
|
+
const readOnly = Boolean(this.options.readOnly || this.options.readonly);
|
|
80
86
|
this._languageLabel = h('span', { class: 'zx-code-editor__language' }, this._language);
|
|
81
87
|
// A visible readout, not a live region: announced on every caret move it would talk over
|
|
82
88
|
// each keystroke.
|
|
@@ -91,7 +97,7 @@ export class CodeEditor extends Component {
|
|
|
91
97
|
rows: normalizeRows(this.options.rows),
|
|
92
98
|
wrap: normalizeWrap(this.options.wrap),
|
|
93
99
|
spellcheck: Boolean(this.options.spellcheck),
|
|
94
|
-
readOnly
|
|
100
|
+
readOnly,
|
|
95
101
|
disabled: Boolean(this.options.disabled),
|
|
96
102
|
autocomplete: 'off',
|
|
97
103
|
autocapitalize: 'off'
|
|
@@ -106,7 +112,7 @@ export class CodeEditor extends Component {
|
|
|
106
112
|
this._committedValue = this._input.value;
|
|
107
113
|
this._indentEditing = false;
|
|
108
114
|
root.dataset.language = this._language;
|
|
109
|
-
root.dataset.readonly = String(
|
|
115
|
+
root.dataset.readonly = String(readOnly);
|
|
110
116
|
root.dataset.disabled = String(Boolean(this.options.disabled));
|
|
111
117
|
root.replaceChildren(this._header, this._input, this._highlight);
|
|
112
118
|
/** Set by Escape: the next Tab moves focus instead of indenting. */
|
|
@@ -216,13 +222,28 @@ export class CodeEditor extends Component {
|
|
|
216
222
|
/** @returns {this} */
|
|
217
223
|
disable() { this._input.disabled = true; this.el.dataset.disabled = 'true'; return this; }
|
|
218
224
|
|
|
219
|
-
/**
|
|
225
|
+
/**
|
|
226
|
+
* Makes the text selectable but not editable, or editable again; reflected as `data-readonly` on
|
|
227
|
+
* the root.
|
|
228
|
+
* @param {boolean} value Read-only state.
|
|
229
|
+
* @returns {this}
|
|
230
|
+
*/
|
|
220
231
|
setReadOnly(value) {
|
|
221
232
|
this._input.readOnly = Boolean(value);
|
|
222
233
|
this.el.dataset.readonly = String(Boolean(value));
|
|
223
234
|
return this;
|
|
224
235
|
}
|
|
225
236
|
|
|
237
|
+
/**
|
|
238
|
+
* `setReadOnly()` under the spelling every other Zx control uses (`Field#setReadonly()`,
|
|
239
|
+
* `NumberField#setReadonly()`, `TagPicker#setReadonly()`); the two are interchangeable.
|
|
240
|
+
* @param {boolean} value Read-only state.
|
|
241
|
+
* @returns {this}
|
|
242
|
+
*/
|
|
243
|
+
setReadonly(value) {
|
|
244
|
+
return this.setReadOnly(value);
|
|
245
|
+
}
|
|
246
|
+
|
|
226
247
|
/** @param {KeyboardEvent} event @returns {void} */
|
|
227
248
|
_handleKeydown(event) {
|
|
228
249
|
if (event.isComposing || MODIFIER_KEYS.has(event.key)) return;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Composer — the message box of an agent conversation. A filled box on the chrome tone with no
|
|
3
|
-
* frame of its own: the context and attachment chips, the text, and a bar of quiet
|
|
4
|
-
*
|
|
3
|
+
* frame of its own: a tray holding the context and attachment chips, the text, and a bar of quiet
|
|
4
|
+
* tools ending in Send. The text is a field with its own edge, and it alone draws the focus ring
|
|
5
|
+
* while it is typed into; the tray, the chips and the bar never light up. The `@` suggestions open
|
|
6
|
+
* above it, in the top layer.
|
|
5
7
|
*/
|
|
6
8
|
.zx-composer {
|
|
7
9
|
position: relative;
|
|
@@ -13,36 +15,34 @@
|
|
|
13
15
|
.zx-composer__frame {
|
|
14
16
|
position: relative;
|
|
15
17
|
display: grid;
|
|
16
|
-
gap: var(--zx-space-
|
|
18
|
+
gap: var(--zx-space-2);
|
|
17
19
|
min-inline-size: 0;
|
|
18
|
-
padding: var(--zx-space-2)
|
|
20
|
+
padding: var(--zx-space-2);
|
|
19
21
|
border-radius: var(--zx-radius-lg);
|
|
20
22
|
background: var(--zx-color-bg-chrome);
|
|
21
23
|
color: var(--zx-color-text);
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
.zx-composer__frame:has(.zx-composer__input:focus) {
|
|
25
|
-
box-shadow: var(--zx-focus-ring);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
26
|
.zx-composer[aria-disabled="true"] .zx-composer__frame {
|
|
29
27
|
opacity: 0.6;
|
|
30
28
|
}
|
|
31
29
|
|
|
32
30
|
/* ------------------------------------------------------------------ text -- */
|
|
33
31
|
|
|
32
|
+
/* The text is drawn as any text area is — the control edge, fill and radius, its padding — so the
|
|
33
|
+
box reads as a tray around a field. Focused, it takes the shared ring from the base styles; a
|
|
34
|
+
quiet-fields region does not take its edge away. */
|
|
34
35
|
.zx-composer .zx-composer__input {
|
|
35
36
|
display: block;
|
|
36
37
|
inline-size: 100%;
|
|
37
38
|
min-block-size: 0;
|
|
38
39
|
margin: 0;
|
|
39
|
-
padding: var(--zx-space-
|
|
40
|
+
padding: var(--zx-space-2) var(--zx-control-pad-x);
|
|
40
41
|
overflow-y: hidden;
|
|
41
|
-
border:
|
|
42
|
-
border-radius:
|
|
43
|
-
background:
|
|
44
|
-
|
|
45
|
-
color: inherit;
|
|
42
|
+
border: 1px solid var(--zx-color-border-control);
|
|
43
|
+
border-radius: var(--zx-control-radius);
|
|
44
|
+
background: var(--zx-color-bg-control);
|
|
45
|
+
color: var(--zx-color-text);
|
|
46
46
|
font: inherit;
|
|
47
47
|
font-size: var(--zx-text-md);
|
|
48
48
|
line-height: 1.5;
|
|
@@ -57,12 +57,6 @@
|
|
|
57
57
|
color: var(--zx-color-text-placeholder);
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
/* The box draws the ring; the text inside it draws none of its own. */
|
|
61
|
-
.zx-composer .zx-composer__input:is(:focus, :focus-visible) {
|
|
62
|
-
outline-color: transparent;
|
|
63
|
-
box-shadow: none;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
60
|
.zx-composer .zx-composer__input:disabled {
|
|
67
61
|
cursor: not-allowed;
|
|
68
62
|
}
|
|
@@ -77,7 +71,6 @@
|
|
|
77
71
|
align-items: center;
|
|
78
72
|
gap: var(--zx-space-1);
|
|
79
73
|
min-inline-size: 0;
|
|
80
|
-
margin-inline-start: calc(-1 * var(--zx-space-1));
|
|
81
74
|
}
|
|
82
75
|
|
|
83
76
|
.zx-composer__tools {
|
|
@@ -224,7 +217,7 @@
|
|
|
224
217
|
flex-wrap: wrap;
|
|
225
218
|
gap: var(--zx-space-2);
|
|
226
219
|
margin: 0;
|
|
227
|
-
padding:
|
|
220
|
+
padding: 0;
|
|
228
221
|
list-style: none;
|
|
229
222
|
}
|
|
230
223
|
|
|
@@ -478,8 +471,4 @@
|
|
|
478
471
|
background-color var(--zx-dur-fast) var(--zx-ease),
|
|
479
472
|
color var(--zx-dur-fast) var(--zx-ease);
|
|
480
473
|
}
|
|
481
|
-
|
|
482
|
-
.zx-composer__frame {
|
|
483
|
-
transition: box-shadow var(--zx-dur-fast) var(--zx-ease);
|
|
484
|
-
}
|
|
485
474
|
}
|
|
@@ -36,7 +36,9 @@
|
|
|
36
36
|
background: var(--zx-color-bg-control);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
/* The box is the field's edge, so it rings while the field has focus; the Copy button inside it
|
|
40
|
+
rings itself, and the box stays quiet then. */
|
|
41
|
+
.zx-copy-input__box:has(.zx-copy-input__field:focus) {
|
|
40
42
|
border-color: var(--zx-color-accent);
|
|
41
43
|
box-shadow: var(--zx-focus-ring);
|
|
42
44
|
}
|
|
@@ -134,7 +134,8 @@ export class Dialog extends Modal {
|
|
|
134
134
|
const close = this._message('dialog.close', 'Close');
|
|
135
135
|
const dialog = /** @type {HTMLDialogElement} */ (h('dialog', {
|
|
136
136
|
class: 'zx-modal zx-dialog',
|
|
137
|
-
ariaLabelledby: titleId
|
|
137
|
+
ariaLabelledby: titleId,
|
|
138
|
+
dataset: { zxFocus: 'container' }
|
|
138
139
|
},
|
|
139
140
|
h('header', { class: 'zx-dialog__header' },
|
|
140
141
|
h('h2', { class: 'zx-dialog__title', id: titleId, ref: 'title' }),
|
|
@@ -171,12 +171,6 @@
|
|
|
171
171
|
block-size: 100%;
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
.zx-dock__panel:focus-visible {
|
|
175
|
-
outline-color: transparent;
|
|
176
|
-
outline-offset: -2px;
|
|
177
|
-
box-shadow: inset var(--zx-focus-ring);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
174
|
/*
|
|
181
175
|
* The hit area is thicker than the line it draws, so the divider is grabbable without a visible
|
|
182
176
|
* gutter — the same trade SplitView makes.
|
|
@@ -6,6 +6,7 @@ import { ICON_SIZE, icon } from '../../core/icons.js';
|
|
|
6
6
|
import { rovingTabindex } from '../../core/keyboard.js';
|
|
7
7
|
import { storage } from '../../core/storage.js';
|
|
8
8
|
import { clamp, uid } from '../../core/util.js';
|
|
9
|
+
import { syncPanelStop } from '../../internal/focus-stops.js';
|
|
9
10
|
|
|
10
11
|
/** Storage namespace shared by every dock that opted into persistence. */
|
|
11
12
|
const STORAGE_NAMESPACE = 'dock';
|
|
@@ -459,7 +460,8 @@ export class Dock extends Component {
|
|
|
459
460
|
if (!collapsible) toggle.disabled = true;
|
|
460
461
|
|
|
461
462
|
const header = h('div', { class: 'zx-dock__header' }, toggle);
|
|
462
|
-
|
|
463
|
+
// A scroller the browser makes a Tab stop when nothing inside it is focusable: a region, not a control.
|
|
464
|
+
const body = h('div', { class: 'zx-dock__body', id: bodyId, dataset: { zxFocus: 'region' } });
|
|
463
465
|
const element = h('section', {
|
|
464
466
|
class: 'zx-dock__pane',
|
|
465
467
|
dataset: { name, state: 'open' }
|
|
@@ -507,13 +509,14 @@ export class Dock extends Component {
|
|
|
507
509
|
ariaSelected: 'false',
|
|
508
510
|
tabindex: -1
|
|
509
511
|
}, String(tabDefinition.title ?? tabName));
|
|
512
|
+
// A Tab stop only while it holds nothing that is one (see `_materialize()`).
|
|
510
513
|
const panel = h('div', {
|
|
511
514
|
class: 'zx-dock__panel',
|
|
512
515
|
role: 'tabpanel',
|
|
513
516
|
id: panelId,
|
|
514
517
|
ariaLabelledby: tabId,
|
|
515
|
-
|
|
516
|
-
|
|
518
|
+
hidden: true,
|
|
519
|
+
dataset: { zxFocus: 'region' }
|
|
517
520
|
});
|
|
518
521
|
list.append(tab);
|
|
519
522
|
body.append(panel);
|
|
@@ -521,6 +524,13 @@ export class Dock extends Component {
|
|
|
521
524
|
}
|
|
522
525
|
header.append(list);
|
|
523
526
|
record.roving = rovingTabindex(list, '.zx-dock__tab', { orientation: 'horizontal' });
|
|
527
|
+
this.listen(list, 'keydown', (event) => {
|
|
528
|
+
// The panel's content may have changed since it was shown; settle its stop before Tab moves.
|
|
529
|
+
const key = /** @type {KeyboardEvent} */ (event);
|
|
530
|
+
if (key.key !== 'Tab' || key.shiftKey) return;
|
|
531
|
+
const active = record.tabs.get(record.active);
|
|
532
|
+
if (active) syncPanelStop(active.panel);
|
|
533
|
+
});
|
|
524
534
|
this.listen(list, 'click', (event) => {
|
|
525
535
|
const button = /** @type {Element} */ (event.target).closest?.('.zx-dock__tab');
|
|
526
536
|
if (!button || !list.contains(button)) return;
|
|
@@ -555,7 +565,8 @@ export class Dock extends Component {
|
|
|
555
565
|
}
|
|
556
566
|
|
|
557
567
|
/**
|
|
558
|
-
* Runs any not-yet-run content factory for whatever the pane currently shows
|
|
568
|
+
* Runs any not-yet-run content factory for whatever the pane currently shows, and settles
|
|
569
|
+
* whether a shown tab panel is a Tab stop itself.
|
|
559
570
|
* @param {Record<string, any>} record Pane record.
|
|
560
571
|
* @returns {void}
|
|
561
572
|
*/
|
|
@@ -563,9 +574,13 @@ export class Dock extends Component {
|
|
|
563
574
|
if (record.collapsed) return;
|
|
564
575
|
if (record.tabs) {
|
|
565
576
|
const active = record.tabs.get(record.active);
|
|
566
|
-
if (!active
|
|
567
|
-
active.built
|
|
568
|
-
|
|
577
|
+
if (!active) return;
|
|
578
|
+
if (!active.built) {
|
|
579
|
+
active.built = true;
|
|
580
|
+
appendContent(active.panel, active.content, true);
|
|
581
|
+
}
|
|
582
|
+
// APG tabs: the panel is a Tab stop only while nothing inside it is one.
|
|
583
|
+
syncPanelStop(active.panel);
|
|
569
584
|
return;
|
|
570
585
|
}
|
|
571
586
|
if (record.built) return;
|
|
@@ -35,7 +35,8 @@ const TABBABLE_SELECTOR = [
|
|
|
35
35
|
* panel is hosted by that dialog, so `showModal()` does not make it inert.
|
|
36
36
|
*
|
|
37
37
|
* The panel follows its trigger in the Tab order: Tab on the anchor of an open panel moves into
|
|
38
|
-
* the panel's first focusable control (or onto the panel itself when it carries a `tabindex
|
|
38
|
+
* the panel's first focusable control (or onto the panel itself when it carries a `tabindex`, where
|
|
39
|
+
* it shows focus with the ring inside its edge),
|
|
39
40
|
* Tab past the panel's last control continues after the anchor, and Shift+Tab from the first goes
|
|
40
41
|
* back to the anchor. Closing while focus is inside returns it to the anchor.
|
|
41
42
|
* @fires Dropdown#open
|
|
@@ -107,12 +108,25 @@ export class Dropdown extends Component {
|
|
|
107
108
|
render() {
|
|
108
109
|
const panel = h('div', {
|
|
109
110
|
id: uid('zx-dropdown'),
|
|
110
|
-
popover: 'manual'
|
|
111
|
+
popover: 'manual',
|
|
112
|
+
// A surface, not a control: it draws no ring when a script focuses it (`#syncFocusMarker()`).
|
|
113
|
+
dataset: { zxFocus: 'container' }
|
|
111
114
|
});
|
|
112
115
|
panel.dataset.state = 'closed';
|
|
113
116
|
return panel;
|
|
114
117
|
}
|
|
115
118
|
|
|
119
|
+
/**
|
|
120
|
+
* A panel the application put in the Tab order (`tabindex` of 0 or more) is reached from its
|
|
121
|
+
* anchor's Tab, so it shows keyboard focus as a region, with the ring inside its edge; otherwise
|
|
122
|
+
* only a script focuses it and it draws no ring.
|
|
123
|
+
* @returns {void}
|
|
124
|
+
*/
|
|
125
|
+
#syncFocusMarker() {
|
|
126
|
+
const reachable = this.el.hasAttribute('tabindex') && this.el.tabIndex >= 0;
|
|
127
|
+
this.el.dataset.zxFocus = reachable ? 'region' : 'container';
|
|
128
|
+
}
|
|
129
|
+
|
|
116
130
|
/**
|
|
117
131
|
* Opens and positions the panel.
|
|
118
132
|
* @returns {this}
|
|
@@ -122,6 +136,7 @@ export class Dropdown extends Component {
|
|
|
122
136
|
if (this.isOpen() || this.#destroyed) return this;
|
|
123
137
|
const host = this.#host();
|
|
124
138
|
if (this.el.parentElement !== host) host.append(this.el);
|
|
139
|
+
this.#syncFocusMarker();
|
|
125
140
|
this.#position = position(this.#anchor, this.el, {
|
|
126
141
|
placement: this.options.placement,
|
|
127
142
|
offset: Number(this.options.offset),
|
|
@@ -439,7 +439,8 @@ function validateAdapter(adapter) {
|
|
|
439
439
|
|
|
440
440
|
/** @param {string} message @param {string} id @returns {FieldAdapter} */
|
|
441
441
|
function errorAdapter(message, id) {
|
|
442
|
-
|
|
442
|
+
// Stands in for a control that could not be built; `focus()` reaches it, Tab does not.
|
|
443
|
+
const el = h('div', { class: 'zx-field__error-control', id, role: 'alert', tabIndex: -1, dataset: { zxFocus: 'container' } }, message);
|
|
443
444
|
return {
|
|
444
445
|
el,
|
|
445
446
|
get: () => null,
|
|
@@ -231,6 +231,21 @@ export class FieldUpload extends Component {
|
|
|
231
231
|
return this;
|
|
232
232
|
}
|
|
233
233
|
|
|
234
|
+
/** Disables file selection and dropping; the same as `setDisabled(true)`. @returns {this} */
|
|
235
|
+
disable() {
|
|
236
|
+
return this.setDisabled(true);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/** Enables file selection and dropping; the same as `setDisabled(false)`. @returns {this} */
|
|
240
|
+
enable() {
|
|
241
|
+
return this.setDisabled(false);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/** Whether file selection and dropping are disabled. @returns {boolean} */
|
|
245
|
+
isDisabled() {
|
|
246
|
+
return this._disabled;
|
|
247
|
+
}
|
|
248
|
+
|
|
234
249
|
/** @param {FileList|File[]|ArrayLike<File>} files @returns {void} */
|
|
235
250
|
_selectFiles(files) {
|
|
236
251
|
if (!this._setFiles(files)) return;
|
|
@@ -128,7 +128,6 @@ export class FilterPanel extends Component {
|
|
|
128
128
|
this._restored = false;
|
|
129
129
|
this._entries = [];
|
|
130
130
|
this._children = [];
|
|
131
|
-
this._writing = false;
|
|
132
131
|
this._draft = {};
|
|
133
132
|
this._applied = {};
|
|
134
133
|
this._appliedDraft = '';
|
|
@@ -335,7 +334,7 @@ export class FilterPanel extends Component {
|
|
|
335
334
|
checklist.on('change', () => this._edited(key, checklist.getValues()));
|
|
336
335
|
this._isolate(checklist);
|
|
337
336
|
this._children.push(checklist);
|
|
338
|
-
this._entries.push({ key, write: (value) => checklist.setValues(/** @type {unknown[]} */ (value ?? [])) });
|
|
337
|
+
this._entries.push({ key, write: (value) => checklist.setValues(/** @type {unknown[]} */ (value ?? []), { silent: true }) });
|
|
339
338
|
return checklist.toElement();
|
|
340
339
|
}
|
|
341
340
|
|
|
@@ -519,7 +518,6 @@ export class FilterPanel extends Component {
|
|
|
519
518
|
|
|
520
519
|
/** @param {string} key Field key. @param {unknown} value Raw draft value. @returns {void} */
|
|
521
520
|
_edited(key, value) {
|
|
522
|
-
if (this._writing) return;
|
|
523
521
|
this._draft[key] = value;
|
|
524
522
|
this._afterEdit(key);
|
|
525
523
|
}
|
|
@@ -531,7 +529,6 @@ export class FilterPanel extends Component {
|
|
|
531
529
|
* @returns {void}
|
|
532
530
|
*/
|
|
533
531
|
_editedEdge(key, edge, value) {
|
|
534
|
-
if (this._writing) return;
|
|
535
532
|
const current = this._draft[key];
|
|
536
533
|
const range = current !== null && typeof current === 'object' && !Array.isArray(current)
|
|
537
534
|
? { .../** @type {Record<string, unknown>} */ (current) }
|
|
@@ -594,14 +591,14 @@ export class FilterPanel extends Component {
|
|
|
594
591
|
return serializeFilterValue(this._draft, this.options.fields, this.options.serialize, this._timeZone);
|
|
595
592
|
}
|
|
596
593
|
|
|
597
|
-
/**
|
|
594
|
+
/**
|
|
595
|
+
* Pushes the draft back into the controls without re-entering the edit path: every entry writes
|
|
596
|
+
* silently (a plain input's `value`, `{silent: true}` to the composed controls), so none of them
|
|
597
|
+
* reports the write back as an edit.
|
|
598
|
+
* @returns {void}
|
|
599
|
+
*/
|
|
598
600
|
_writeControls() {
|
|
599
|
-
this.
|
|
600
|
-
try {
|
|
601
|
-
for (const entry of this._entries) entry.write(this._draft[entry.key]);
|
|
602
|
-
} finally {
|
|
603
|
-
this._writing = false;
|
|
604
|
-
}
|
|
601
|
+
for (const entry of this._entries) entry.write(this._draft[entry.key]);
|
|
605
602
|
}
|
|
606
603
|
|
|
607
604
|
/** @param {Record<string, unknown>} [value] The draft value, when it is already at hand. @returns {void} */
|
|
@@ -78,9 +78,11 @@ export class MasterPanel extends Component {
|
|
|
78
78
|
ariaLabel: this.msg('panel.actions')
|
|
79
79
|
})
|
|
80
80
|
);
|
|
81
|
+
// It scrolls, so with nothing focusable inside the browser makes it a Tab stop: a region.
|
|
81
82
|
const content = h('div', {
|
|
82
83
|
class: 'zx-master-panel__content',
|
|
83
|
-
ref: 'content'
|
|
84
|
+
ref: 'content',
|
|
85
|
+
dataset: { zxFocus: 'region' }
|
|
84
86
|
});
|
|
85
87
|
const footer = h('footer', {
|
|
86
88
|
class: 'zx-master-panel__footer',
|
|
@@ -34,18 +34,9 @@
|
|
|
34
34
|
|
|
35
35
|
/*
|
|
36
36
|
* The panel takes focus itself only as a fallback, when it holds nothing focusable at all. It is a
|
|
37
|
-
* surface rather than a control
|
|
38
|
-
*
|
|
39
|
-
* overlay with nothing on screen saying so.
|
|
37
|
+
* surface rather than a control and carries `data-zx-focus="container"`, so it draws no focus ring
|
|
38
|
+
* and keeps its own elevation while focused: the open dialog is what shows where focus is.
|
|
40
39
|
*/
|
|
41
|
-
.zx-modal:focus {
|
|
42
|
-
outline-color: transparent;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
.zx-modal:focus-visible {
|
|
46
|
-
outline: 2px solid var(--zx-color-ring);
|
|
47
|
-
outline-offset: calc(-1 * var(--zx-space-1));
|
|
48
|
-
}
|
|
49
40
|
|
|
50
41
|
/*
|
|
51
42
|
* `:modal` rather than `[open]`: only a dialog opened with `showModal()` blocks the page, and a
|
|
@@ -397,7 +397,8 @@ export class Modal extends Component {
|
|
|
397
397
|
return;
|
|
398
398
|
}
|
|
399
399
|
// A panel holding nothing focusable has to take focus itself, and is made focusable only for
|
|
400
|
-
// that: `tabindex="-1"` is programmatic focus, so it adds nothing to the Tab order
|
|
400
|
+
// that: `tabindex="-1"` is programmatic focus, so it adds nothing to the Tab order, and
|
|
401
|
+
// `data-zx-focus="container"` (set in `render()`) keeps the focus ring off the surface.
|
|
401
402
|
const panel = /** @type {HTMLElement} */ (this.el);
|
|
402
403
|
if (!panel.hasAttribute('tabindex')) panel.setAttribute('tabindex', '-1');
|
|
403
404
|
panel.focus();
|
|
@@ -409,7 +410,9 @@ export class Modal extends Component {
|
|
|
409
410
|
*/
|
|
410
411
|
render() {
|
|
411
412
|
const dialog = /** @type {HTMLDialogElement} */ (h('dialog', {
|
|
412
|
-
class: 'zx-modal'
|
|
413
|
+
class: 'zx-modal',
|
|
414
|
+
// The panel is a surface, never a control: when it holds focus itself it draws no ring.
|
|
415
|
+
dataset: { zxFocus: 'container' }
|
|
413
416
|
}, h('div', { class: 'zx-modal__content', ref: 'content' })));
|
|
414
417
|
dialog.dataset.state = 'closed';
|
|
415
418
|
this._mountInitial(dialog);
|
|
@@ -409,8 +409,10 @@ export class ModuleBar extends AppRailPresenter {
|
|
|
409
409
|
}
|
|
410
410
|
|
|
411
411
|
/**
|
|
412
|
-
* Shows the tiles that fit, in bar order, and moves the rest behind "All modules".
|
|
413
|
-
* shown first so a bar sized by its content measures as not overflowing
|
|
412
|
+
* Shows the tiles that fit, in bar order, and moves the rest behind "All modules". Every module
|
|
413
|
+
* the bar could place is shown first, so a bar sized by its content measures as not overflowing
|
|
414
|
+
* and never shrinks itself; a module that can only ever be in the catalogue is not, so it takes
|
|
415
|
+
* no room.
|
|
414
416
|
* @returns {void}
|
|
415
417
|
*/
|
|
416
418
|
_layout() {
|
|
@@ -420,15 +422,17 @@ export class ModuleBar extends AppRailPresenter {
|
|
|
420
422
|
const moreRow = list.querySelector(':scope > [data-module-bar-more]');
|
|
421
423
|
const mode = this.el.dataset.allModules;
|
|
422
424
|
const keep = [moduleOf(this._items, this._active)?.id, this._expandedId, this._promoted];
|
|
423
|
-
|
|
425
|
+
// An always-shown button takes its slot whether or not anything overflows.
|
|
426
|
+
const reserve = mode === 'always';
|
|
427
|
+
let partition = partitionModules(this._items, Infinity, keep, reserve);
|
|
424
428
|
if (mode !== 'never' && list.isConnected) {
|
|
425
|
-
|
|
429
|
+
const placeable = new Set(partition.visible.map((item) => String(item.id)));
|
|
430
|
+
for (const row of rows) row.hidden = !placeable.has(row.dataset.moduleId);
|
|
426
431
|
if (moreRow) moreRow.hidden = false;
|
|
427
432
|
syncHeadings(list);
|
|
428
|
-
|
|
433
|
+
const space = measureSpace(list, this.el.dataset.orientation === 'horizontal');
|
|
434
|
+
if (space) partition = fitModules(this._items, space, keep, reserve);
|
|
429
435
|
}
|
|
430
|
-
// An always-shown button takes its slot whether or not anything overflows.
|
|
431
|
-
const partition = partitionModules(this._items, capacity, keep, mode === 'always');
|
|
432
436
|
const visible = new Set(partition.visible.map((item) => String(item.id)));
|
|
433
437
|
for (const row of rows) row.hidden = !visible.has(row.dataset.moduleId);
|
|
434
438
|
syncHeadings(list);
|
|
@@ -885,6 +889,77 @@ export function partitionModules(items, capacity = Infinity, keep = [], reserve
|
|
|
885
889
|
return { visible, overflow, more: overflow.length > 0 };
|
|
886
890
|
}
|
|
887
891
|
|
|
892
|
+
/**
|
|
893
|
+
* The bar's list as measured with every module it could place shown: its rows, section headings,
|
|
894
|
+
* and "All modules" button in document order, each with the length it takes along the bar, its
|
|
895
|
+
* margins included.
|
|
896
|
+
* @typedef {Object} ModuleBarSpace
|
|
897
|
+
* @property {number} room Length of the list's content box along the bar.
|
|
898
|
+
* @property {number} [gap=0] Gap between two shown entries.
|
|
899
|
+
* @property {Array<{id?: string, heading?: boolean, more?: boolean, size: number}>} entries Shown
|
|
900
|
+
* entries: a module row by its `id`, a heading, or the button. A heading takes its room only when
|
|
901
|
+
* a module after it, before the next heading, is on the bar.
|
|
902
|
+
*/
|
|
903
|
+
|
|
904
|
+
/**
|
|
905
|
+
* Splits modules as `partitionModules()` does, giving it the most slots for which what it places
|
|
906
|
+
* fits the measured list: each row at its own length, a section heading only where one of its
|
|
907
|
+
* modules is on the bar, and the "All modules" button when it is shown. So one name that wraps to
|
|
908
|
+
* two lines costs its extra line, not a tile, and no row is ever cut in half. Kept modules stay
|
|
909
|
+
* on the bar even when nothing else fits, as with `partitionModules()`.
|
|
910
|
+
* @param {ModuleItem[]} items Modules.
|
|
911
|
+
* @param {ModuleBarSpace} space The measured list.
|
|
912
|
+
* @param {Array<string|number|null|undefined>|string|number|null} [keep=[]] Module ids that must stay visible.
|
|
913
|
+
* @param {boolean} [reserve=false] The button is shown even when every module fits.
|
|
914
|
+
* @returns {{visible: ModuleItem[], overflow: ModuleItem[], more: boolean}}
|
|
915
|
+
*/
|
|
916
|
+
export function fitModules(items, space, keep = [], reserve = false) {
|
|
917
|
+
const fits = (partition) => barExtent(space, partition.visible, reserve || partition.more) <= space.room + 0.5;
|
|
918
|
+
const all = partitionModules(items, Infinity, keep, reserve);
|
|
919
|
+
if (fits(all)) return all;
|
|
920
|
+
// Less than everything needs the button, so every smaller count reserves its slot; without that,
|
|
921
|
+
// a count equal to the modules would place them all and leave the button out. A smaller count
|
|
922
|
+
// then never places a module a larger one leaves off, so the length grows with the count and the
|
|
923
|
+
// largest count that fits is found by bisection. One slot, the kept modules alone, is the floor.
|
|
924
|
+
let low = 1;
|
|
925
|
+
let high = all.visible.length;
|
|
926
|
+
while (low < high) {
|
|
927
|
+
const middle = Math.ceil((low + high) / 2);
|
|
928
|
+
if (fits(partitionModules(items, middle, keep, true))) low = middle;
|
|
929
|
+
else high = middle - 1;
|
|
930
|
+
}
|
|
931
|
+
return partitionModules(items, low, keep, true);
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
/**
|
|
935
|
+
* The length the list's entries take with these modules on the bar.
|
|
936
|
+
* @param {ModuleBarSpace} space The measured list.
|
|
937
|
+
* @param {ModuleItem[]} visible Modules on the bar.
|
|
938
|
+
* @param {boolean} more Whether the "All modules" button is shown.
|
|
939
|
+
* @returns {number}
|
|
940
|
+
*/
|
|
941
|
+
function barExtent(space, visible, more) {
|
|
942
|
+
const shown = new Set(visible.map((item) => String(item.id)));
|
|
943
|
+
let total = 0;
|
|
944
|
+
let count = 0;
|
|
945
|
+
let heading = null;
|
|
946
|
+
for (const entry of space.entries ?? []) {
|
|
947
|
+
if (entry.heading) {
|
|
948
|
+
heading = entry;
|
|
949
|
+
continue;
|
|
950
|
+
}
|
|
951
|
+
if (entry.more ? !more : !shown.has(String(entry.id))) continue;
|
|
952
|
+
if (heading && !entry.more) {
|
|
953
|
+
total += heading.size;
|
|
954
|
+
count += 1;
|
|
955
|
+
}
|
|
956
|
+
heading = null;
|
|
957
|
+
total += entry.size;
|
|
958
|
+
count += 1;
|
|
959
|
+
}
|
|
960
|
+
return total + Math.max(0, count - 1) * (space.gap ?? 0);
|
|
961
|
+
}
|
|
962
|
+
|
|
888
963
|
/**
|
|
889
964
|
* Resolves a module's identity colour: a valid CSS `color` wins, then a known `tone`.
|
|
890
965
|
* @param {{tone?: unknown, color?: unknown}} item Module.
|
|
@@ -970,31 +1045,40 @@ function barOrder(items) {
|
|
|
970
1045
|
}
|
|
971
1046
|
|
|
972
1047
|
/**
|
|
973
|
-
*
|
|
1048
|
+
* Measures the list along its main axis for `fitModules()`, as it stands: with every module the
|
|
1049
|
+
* bar could place shown. Null when that already fits, or when the list has not been laid out.
|
|
974
1050
|
* @param {HTMLElement} list Bar list.
|
|
975
1051
|
* @param {boolean} horizontal Flow.
|
|
976
|
-
* @
|
|
977
|
-
* @returns {number}
|
|
1052
|
+
* @returns {ModuleBarSpace|null}
|
|
978
1053
|
*/
|
|
979
|
-
function
|
|
1054
|
+
function measureSpace(list, horizontal) {
|
|
980
1055
|
const overflowing = horizontal ? list.scrollWidth > list.clientWidth + 1 : list.scrollHeight > list.clientHeight + 1;
|
|
981
|
-
if (!overflowing) return
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
1056
|
+
if (!overflowing) return null;
|
|
1057
|
+
const axis = horizontal ? 'Inline' : 'Block';
|
|
1058
|
+
/** @param {CSSStyleDeclaration} style @param {string} prefix @param {string} [suffix=''] @returns {number} */
|
|
1059
|
+
const edges = (style, prefix, suffix = '') => (Number.parseFloat(style[`${prefix}${axis}Start${suffix}`]) || 0)
|
|
1060
|
+
+ (Number.parseFloat(style[`${prefix}${axis}End${suffix}`]) || 0);
|
|
1061
|
+
// Lengths are read from the drawn boxes for their fractions, and brought back to layout pixels,
|
|
1062
|
+
// which margins and gaps are in, for a bar drawn scaled (a thumbnail of a layout).
|
|
1063
|
+
const drawn = (element) => element.getBoundingClientRect()[horizontal ? 'width' : 'height'];
|
|
1064
|
+
const laid = horizontal ? list.offsetWidth : list.offsetHeight;
|
|
1065
|
+
const scale = laid > 0 && drawn(list) > 0 ? drawn(list) / laid : 1;
|
|
986
1066
|
const style = getComputedStyle(list);
|
|
1067
|
+
const room = laid - edges(style, 'padding') - edges(style, 'border', 'Width');
|
|
987
1068
|
const gap = Number.parseFloat(horizontal ? style.columnGap : style.rowGap) || 0;
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
1069
|
+
/** @type {ModuleBarSpace['entries']} */
|
|
1070
|
+
const entries = [];
|
|
1071
|
+
for (const child of /** @type {HTMLElement[]} */ ([...list.children])) {
|
|
1072
|
+
const childStyle = getComputedStyle(child);
|
|
1073
|
+
if (child.hidden || childStyle.display === 'none') continue;
|
|
1074
|
+
const size = drawn(child) / scale + edges(childStyle, 'margin');
|
|
1075
|
+
if (child.classList.contains('zx-module-bar__heading')) entries.push({ heading: true, size });
|
|
1076
|
+
else if (child.hasAttribute('data-module-bar-more')) entries.push({ more: true, size });
|
|
1077
|
+
else if (child.dataset.moduleId != null) entries.push({ id: child.dataset.moduleId, size });
|
|
1078
|
+
}
|
|
1079
|
+
// A list with no room, or rows without size, has not been laid out: nothing is moved off the bar.
|
|
1080
|
+
if (room <= 0 || !entries.some((entry) => entry.id != null && entry.size > 0)) return null;
|
|
1081
|
+
return { room, gap, entries };
|
|
998
1082
|
}
|
|
999
1083
|
|
|
1000
1084
|
/** @param {HTMLElement[]} entries @param {HTMLElement} current @param {1|-1} direction @returns {HTMLElement|null} */
|