@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.
Files changed (109) hide show
  1. package/CHANGELOG.md +93 -0
  2. package/dist/types/components/block-view/block-view.d.ts +3 -2
  3. package/dist/types/components/check-button/check-button.d.ts +10 -2
  4. package/dist/types/components/checklist/checklist.d.ts +28 -6
  5. package/dist/types/components/code-editor/code-editor.d.ts +19 -1
  6. package/dist/types/components/dock/dock.d.ts +2 -1
  7. package/dist/types/components/dropdown/dropdown.d.ts +2 -1
  8. package/dist/types/components/field-upload/field-upload.d.ts +6 -0
  9. package/dist/types/components/filter-panel/filter-panel.d.ts +6 -2
  10. package/dist/types/components/module-bar/module-bar.d.ts +53 -2
  11. package/dist/types/components/multi-value-editor/multi-value-editor.d.ts +28 -0
  12. package/dist/types/components/run-status/run-status.d.ts +1 -1
  13. package/dist/types/components/run-trace/run-trace.d.ts +8 -0
  14. package/dist/types/components/select/select.d.ts +18 -5
  15. package/dist/types/components/tabbox/tabbox.d.ts +7 -0
  16. package/dist/types/components/tag-picker/tag-picker.d.ts +21 -5
  17. package/dist/types/components/timebox/timebox.d.ts +9 -0
  18. package/dist/types/core/component.d.ts +4 -1
  19. package/dist/types/internal/focus-stops.d.ts +42 -0
  20. package/dist/zx-zeyos.esm.js +296 -97
  21. package/dist/zx-zeyos.esm.min.js +4 -4
  22. package/dist/zx.core.css +13 -6
  23. package/dist/zx.core.min.css +1 -1
  24. package/dist/zx.css +26 -88
  25. package/dist/zx.esm.js +516 -159
  26. package/dist/zx.esm.min.js +26 -26
  27. package/dist/zx.global.js +516 -159
  28. package/dist/zx.global.min.js +26 -26
  29. package/dist/zx.layered.css +26 -88
  30. package/dist/zx.layered.min.css +1 -1
  31. package/dist/zx.min.css +1 -1
  32. package/docs/api.json +97 -9
  33. package/docs/components/approval-card.md +2 -2
  34. package/docs/components/block-view.md +2 -1
  35. package/docs/components/check-button.md +3 -1
  36. package/docs/components/checklist.md +2 -1
  37. package/docs/components/code-editor.md +4 -3
  38. package/docs/components/composer.md +4 -0
  39. package/docs/components/dock.md +4 -1
  40. package/docs/components/dropdown.md +3 -1
  41. package/docs/components/field-upload.md +2 -1
  42. package/docs/components/modal.md +3 -0
  43. package/docs/components/multi-value-editor.md +5 -2
  44. package/docs/components/navigation-bar.md +5 -0
  45. package/docs/components/questionnaire.md +2 -2
  46. package/docs/components/run-status.md +2 -1
  47. package/docs/components/run-trace.md +2 -1
  48. package/docs/components/select.md +6 -2
  49. package/docs/components/tabbox.md +6 -0
  50. package/docs/components/tag-picker.md +3 -1
  51. package/docs/components/timebox.md +2 -1
  52. package/docs/components/tokens.md +20 -0
  53. package/docs/llms.md +84 -21
  54. package/package.json +1 -1
  55. package/src/components/app-sidebar/app-sidebar.js +1 -1
  56. package/src/components/approval-card/approval-card.css +0 -5
  57. package/src/components/approval-card/approval-card.js +2 -0
  58. package/src/components/block-view/block-view.css +0 -10
  59. package/src/components/block-view/block-view.js +11 -6
  60. package/src/components/card/card.css +3 -0
  61. package/src/components/card/card.js +2 -2
  62. package/src/components/card-view/card-view.css +5 -5
  63. package/src/components/card-view/card-view.js +3 -1
  64. package/src/components/check-button/check-button.js +5 -1
  65. package/src/components/checklist/checklist.js +26 -10
  66. package/src/components/checklist/field-adapter.js +5 -13
  67. package/src/components/code-editor/code-editor.js +24 -3
  68. package/src/components/composer/composer.css +15 -26
  69. package/src/components/copy/copy-input.css +3 -1
  70. package/src/components/dialog/dialog.js +2 -1
  71. package/src/components/dock/dock.css +0 -6
  72. package/src/components/dock/dock.js +22 -7
  73. package/src/components/dropdown/dropdown.js +17 -2
  74. package/src/components/field/field.js +2 -1
  75. package/src/components/field-upload/field-upload.js +15 -0
  76. package/src/components/filter-panel/filter-panel.js +8 -11
  77. package/src/components/master-panel/master-panel.js +3 -1
  78. package/src/components/modal/modal.css +2 -11
  79. package/src/components/modal/modal.js +5 -2
  80. package/src/components/module-bar/module-bar.js +110 -26
  81. package/src/components/multi-value-editor/field-adapter.js +8 -23
  82. package/src/components/multi-value-editor/multi-value-editor.js +63 -5
  83. package/src/components/navigation-bar/navigation-bar.css +0 -4
  84. package/src/components/navigation-bar/navigation-bar.js +11 -2
  85. package/src/components/questionnaire/questionnaire.css +0 -14
  86. package/src/components/questionnaire/questionnaire.js +4 -2
  87. package/src/components/run-status/run-status.css +0 -7
  88. package/src/components/run-status/run-status.js +3 -1
  89. package/src/components/run-trace/run-trace.css +0 -5
  90. package/src/components/run-trace/run-trace.js +23 -2
  91. package/src/components/select/select.js +43 -5
  92. package/src/components/skeleton/skeleton.js +16 -3
  93. package/src/components/surface/surface.css +0 -6
  94. package/src/components/surface/surface.js +1 -1
  95. package/src/components/tabbox/tabbox.css +0 -6
  96. package/src/components/tabbox/tabbox.js +20 -2
  97. package/src/components/table/table.js +5 -0
  98. package/src/components/tag-picker/tag-picker.js +35 -6
  99. package/src/components/timebox/timebox.js +17 -1
  100. package/src/components/view-settings/view-settings.js +1 -1
  101. package/src/core/component.js +22 -2
  102. package/src/core/date.js +1 -4
  103. package/src/core/drag-axis.js +22 -6
  104. package/src/internal/focus-stops.js +108 -0
  105. package/src/zeyos/connect.js +7 -3
  106. package/src/zeyos/icons.js +7 -2
  107. package/styles/base.css +27 -3
  108. package/styles/tokens/dark.css +2 -2
  109. package/styles/tokens/semantic.css +2 -2
package/dist/zx.global.js CHANGED
@@ -2122,7 +2122,10 @@ var zx = (() => {
2122
2122
  return componentEvent;
2123
2123
  }
2124
2124
  /**
2125
- * Adds an automatically cleaned-up DOM event listener.
2125
+ * Adds an automatically cleaned-up DOM event listener. It goes when the component is destroyed;
2126
+ * a `signal` in the options shortens its life further, for a listener that belongs to one
2127
+ * rendering of a part — it then goes when that signal aborts or the component is destroyed,
2128
+ * whichever comes first.
2126
2129
  * @param {EventTarget} element DOM event target.
2127
2130
  * @param {string} type Event name.
2128
2131
  * @param {EventListenerOrEventListenerObject} fn Listener.
@@ -2131,7 +2134,23 @@ var zx = (() => {
2131
2134
  */
2132
2135
  listen(element, type, fn, opts = {}) {
2133
2136
  const options = typeof opts === "boolean" ? { capture: opts } : { ...opts };
2134
- element.addEventListener(type, fn, { ...options, signal: this.#abort.signal });
2137
+ const shorter = options.signal;
2138
+ if (shorter?.aborted || this.#abort.signal.aborted) return this;
2139
+ if (!shorter || shorter === this.#abort.signal) {
2140
+ element.addEventListener(type, fn, { ...options, signal: this.#abort.signal });
2141
+ return this;
2142
+ }
2143
+ const link = new AbortController();
2144
+ element.addEventListener(type, fn, { ...options, signal: link.signal });
2145
+ if (options.once) {
2146
+ element.addEventListener(
2147
+ type,
2148
+ () => link.abort(),
2149
+ { once: true, capture: Boolean(options.capture), signal: link.signal }
2150
+ );
2151
+ }
2152
+ shorter.addEventListener("abort", () => link.abort(), { once: true, signal: link.signal });
2153
+ this.#abort.signal.addEventListener("abort", () => link.abort(), { once: true, signal: link.signal });
2135
2154
  return this;
2136
2155
  }
2137
2156
  /**
@@ -2632,7 +2651,7 @@ var zx = (() => {
2632
2651
  );
2633
2652
  }
2634
2653
  function errorAdapter(message4, id) {
2635
- const el = h("div", { class: "zx-field__error-control", id, role: "alert", tabIndex: -1 }, message4);
2654
+ const el = h("div", { class: "zx-field__error-control", id, role: "alert", tabIndex: -1, dataset: { zxFocus: "container" } }, message4);
2636
2655
  return {
2637
2656
  el,
2638
2657
  get: () => null,
@@ -3003,25 +3022,36 @@ var zx = (() => {
3003
3022
  * and checked as soon as items carrying them arrive — through `setItems()` or the `load`
3004
3023
  * loader — so a value set before the items load is not lost.
3005
3024
  * @param {Iterable<unknown>|unknown[]} ids Checked item IDs.
3025
+ * @param {ChecklistSetOptions} [options={}] Set `silent` to suppress `change`.
3006
3026
  * @returns {this}
3007
3027
  * @fires Checklist#change
3008
3028
  */
3009
- setValues(ids) {
3029
+ setValues(ids, { silent = false } = {}) {
3010
3030
  const requested = new Set(ids == null ? [] : Array.from(ids));
3011
3031
  const known = new Set(this._items.map((item) => this._itemValue(item)));
3012
3032
  const next = new Set([...known].filter((value) => requested.has(value)));
3013
3033
  const missing = [...requested].filter((value) => !known.has(value));
3014
- this._replaceChecked(next, missing.length || this._items.length === 0 ? missing : null);
3034
+ this._replaceChecked(next, missing.length || this._items.length === 0 ? missing : null, silent);
3015
3035
  return this;
3016
3036
  }
3017
- /** Checks every item. @returns {this} @fires Checklist#change */
3018
- checkAll() {
3019
- this._replaceChecked(new Set(this._items.map((item) => this._itemValue(item))), null);
3037
+ /**
3038
+ * Checks every item.
3039
+ * @param {ChecklistSetOptions} [options={}] Set `silent` to suppress `change`.
3040
+ * @returns {this}
3041
+ * @fires Checklist#change
3042
+ */
3043
+ checkAll({ silent = false } = {}) {
3044
+ this._replaceChecked(new Set(this._items.map((item) => this._itemValue(item))), null, silent);
3020
3045
  return this;
3021
3046
  }
3022
- /** Unchecks every item. @returns {this} @fires Checklist#change */
3023
- uncheckAll() {
3024
- this._replaceChecked(/* @__PURE__ */ new Set(), null);
3047
+ /**
3048
+ * Unchecks every item.
3049
+ * @param {ChecklistSetOptions} [options={}] Set `silent` to suppress `change`.
3050
+ * @returns {this}
3051
+ * @fires Checklist#change
3052
+ */
3053
+ uncheckAll({ silent = false } = {}) {
3054
+ this._replaceChecked(/* @__PURE__ */ new Set(), null, silent);
3025
3055
  return this;
3026
3056
  }
3027
3057
  /**
@@ -3137,9 +3167,10 @@ var zx = (() => {
3137
3167
  * @param {Set<unknown>} next
3138
3168
  * @param {unknown[]|null} pending Requested IDs no item carries yet, or null when no request waits
3139
3169
  * for items; an empty array is a request made before any item existed.
3170
+ * @param {boolean} [silent=false] Whether to leave out the `change` event.
3140
3171
  * @returns {void}
3141
3172
  */
3142
- _replaceChecked(next, pending) {
3173
+ _replaceChecked(next, pending, silent = false) {
3143
3174
  const nextPending = pending;
3144
3175
  const pendingChanged = !setsEqual(new Set(this._pending ?? []), new Set(nextPending ?? []));
3145
3176
  const unchanged = setsEqual(this._checked, next) && !pendingChanged;
@@ -3147,7 +3178,7 @@ var zx = (() => {
3147
3178
  if (unchanged) return;
3148
3179
  this._checked = next;
3149
3180
  this._renderItems();
3150
- this.emit("change", { values: this.getValues() });
3181
+ if (!silent) this.emit("change", { values: this.getValues() });
3151
3182
  }
3152
3183
  /** @param {ChecklistItem} item @returns {unknown} */
3153
3184
  _itemValue(item) {
@@ -3184,22 +3215,14 @@ var zx = (() => {
3184
3215
  function registerChecklistFieldAdapter() {
3185
3216
  Field.register("checklist", (field, options) => {
3186
3217
  const checklist = field.own(new Checklist(null, { hideLabel: true, ...options.props ?? {} }));
3187
- let setting = false;
3188
3218
  field.listen(checklist.el, "change", (event) => event.stopImmediatePropagation());
3189
- checklist.on("change", (event) => {
3190
- if (!setting) field.emit("change", { value: event.detail.values });
3191
- });
3219
+ checklist.on("change", (event) => field.emit("change", { value: event.detail.values }));
3192
3220
  return {
3193
3221
  el: checklist.el,
3194
3222
  get: () => checklist.getValues(),
3195
3223
  set: (value) => {
3196
- setting = true;
3197
- try {
3198
- if (Array.isArray(value)) checklist.setValues(value);
3199
- else checklist.uncheckAll();
3200
- } finally {
3201
- setting = false;
3202
- }
3224
+ if (Array.isArray(value)) checklist.setValues(value, { silent: true });
3225
+ else checklist.uncheckAll({ silent: true });
3203
3226
  },
3204
3227
  focus: () => {
3205
3228
  const search = checklist.el.querySelector(".zx-checklist__search:not([hidden]):not([disabled])");
@@ -3229,6 +3252,7 @@ var zx = (() => {
3229
3252
  wrap: "off",
3230
3253
  spellcheck: false,
3231
3254
  readOnly: false,
3255
+ readonly: false,
3232
3256
  disabled: false,
3233
3257
  status: true
3234
3258
  };
@@ -3243,6 +3267,7 @@ var zx = (() => {
3243
3267
  this._initialChildren = this._createdRoot ? [] : [...root.childNodes];
3244
3268
  this._initialAttributes = new Map(["data-language", "data-readonly", "data-disabled", "data-state"].map((name2) => [name2, root.getAttribute(name2)]));
3245
3269
  this._language = normalizeLanguage(this.options.language);
3270
+ const readOnly = Boolean(this.options.readOnly || this.options.readonly);
3246
3271
  this._languageLabel = h("span", { class: "zx-code-editor__language" }, this._language);
3247
3272
  this._position = h("span", { class: "zx-code-editor__position" });
3248
3273
  this._header = h(
@@ -3260,7 +3285,7 @@ var zx = (() => {
3260
3285
  rows: normalizeRows(this.options.rows),
3261
3286
  wrap: normalizeWrap(this.options.wrap),
3262
3287
  spellcheck: Boolean(this.options.spellcheck),
3263
- readOnly: Boolean(this.options.readOnly),
3288
+ readOnly,
3264
3289
  disabled: Boolean(this.options.disabled),
3265
3290
  autocomplete: "off",
3266
3291
  autocapitalize: "off"
@@ -3275,7 +3300,7 @@ var zx = (() => {
3275
3300
  this._committedValue = this._input.value;
3276
3301
  this._indentEditing = false;
3277
3302
  root.dataset.language = this._language;
3278
- root.dataset.readonly = String(Boolean(this.options.readOnly));
3303
+ root.dataset.readonly = String(readOnly);
3279
3304
  root.dataset.disabled = String(Boolean(this.options.disabled));
3280
3305
  root.replaceChildren(this._header, this._input, this._highlight);
3281
3306
  this._tabReleased = false;
@@ -3388,12 +3413,26 @@ var zx = (() => {
3388
3413
  this.el.dataset.disabled = "true";
3389
3414
  return this;
3390
3415
  }
3391
- /** @param {boolean} value Read-only state. @returns {this} */
3416
+ /**
3417
+ * Makes the text selectable but not editable, or editable again; reflected as `data-readonly` on
3418
+ * the root.
3419
+ * @param {boolean} value Read-only state.
3420
+ * @returns {this}
3421
+ */
3392
3422
  setReadOnly(value) {
3393
3423
  this._input.readOnly = Boolean(value);
3394
3424
  this.el.dataset.readonly = String(Boolean(value));
3395
3425
  return this;
3396
3426
  }
3427
+ /**
3428
+ * `setReadOnly()` under the spelling every other Zx control uses (`Field#setReadonly()`,
3429
+ * `NumberField#setReadonly()`, `TagPicker#setReadonly()`); the two are interchangeable.
3430
+ * @param {boolean} value Read-only state.
3431
+ * @returns {this}
3432
+ */
3433
+ setReadonly(value) {
3434
+ return this.setReadOnly(value);
3435
+ }
3397
3436
  /** @param {KeyboardEvent} event @returns {void} */
3398
3437
  _handleKeydown(event) {
3399
3438
  if (event.isComposing || MODIFIER_KEYS.has(event.key)) return;
@@ -3650,7 +3689,7 @@ var zx = (() => {
3650
3689
  let pattern = "^";
3651
3690
  let cursor = 0;
3652
3691
  for (const match of String(fmt).matchAll(TOKEN_PATTERN)) {
3653
- pattern += escapeRegExp2(String(fmt).slice(cursor, match.index));
3692
+ pattern += escapeRegExp(String(fmt).slice(cursor, match.index));
3654
3693
  const token = match[0];
3655
3694
  const tokenPattern = numericPattern(token);
3656
3695
  if (tokenPattern === null) return null;
@@ -3658,7 +3697,7 @@ var zx = (() => {
3658
3697
  fields.push(token);
3659
3698
  cursor = match.index + token.length;
3660
3699
  }
3661
- pattern += escapeRegExp2(String(fmt).slice(cursor)) + "$";
3700
+ pattern += escapeRegExp(String(fmt).slice(cursor)) + "$";
3662
3701
  const matched = new RegExp(pattern).exec(String(str));
3663
3702
  if (!matched) return null;
3664
3703
  const values = /* @__PURE__ */ Object.create(null);
@@ -3775,9 +3814,6 @@ var zx = (() => {
3775
3814
  if (year === void 0) return void 0;
3776
3815
  return year >= 69 ? 1900 + year : 2e3 + year;
3777
3816
  }
3778
- function escapeRegExp2(value) {
3779
- return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
3780
- }
3781
3817
 
3782
3818
  // src/core/fontawesome.js
3783
3819
  var faStyles = Object.freeze({
@@ -7450,6 +7486,18 @@ var zx = (() => {
7450
7486
  this.el.dataset.disabled = String(this._disabled);
7451
7487
  return this;
7452
7488
  }
7489
+ /** Disables file selection and dropping; the same as `setDisabled(true)`. @returns {this} */
7490
+ disable() {
7491
+ return this.setDisabled(true);
7492
+ }
7493
+ /** Enables file selection and dropping; the same as `setDisabled(false)`. @returns {this} */
7494
+ enable() {
7495
+ return this.setDisabled(false);
7496
+ }
7497
+ /** Whether file selection and dropping are disabled. @returns {boolean} */
7498
+ isDisabled() {
7499
+ return this._disabled;
7500
+ }
7453
7501
  /** @param {FileList|File[]|ArrayLike<File>} files @returns {void} */
7454
7502
  _selectFiles(files) {
7455
7503
  if (!this._setFiles(files)) return;
@@ -7726,7 +7774,7 @@ var zx = (() => {
7726
7774
  var MultiValueEditor = class extends Component {
7727
7775
  static cssName = "multi-value-editor";
7728
7776
  /** @type {MultiValueEditorOptions} */
7729
- static defaults = { values: [], options: null, addLabel: null, reorder: "both" };
7777
+ static defaults = { values: [], options: null, addLabel: null, reorder: "both", disabled: false };
7730
7778
  /** @returns {HTMLElement} */
7731
7779
  render() {
7732
7780
  const root = (
@@ -7737,6 +7785,8 @@ var zx = (() => {
7737
7785
  this._values = Array.isArray(this.options.values) ? this.options.values.map(String) : [];
7738
7786
  this._ownedNodes = [];
7739
7787
  this._initialState = root.getAttribute("data-state");
7788
+ this._initialAriaDisabled = root.getAttribute("aria-disabled");
7789
+ this._disabled = Boolean(this.options.disabled);
7740
7790
  this._dragIndex = -1;
7741
7791
  this._armed = null;
7742
7792
  this._rows = h("div", { class: "zx-multi-value-editor__rows" });
@@ -7761,6 +7811,7 @@ var zx = (() => {
7761
7811
  this.listen(document, "pointercancel", () => this._disarm());
7762
7812
  }
7763
7813
  this._renderRows();
7814
+ this._syncDisabled();
7764
7815
  return root;
7765
7816
  }
7766
7817
  /**
@@ -7782,6 +7833,46 @@ var zx = (() => {
7782
7833
  if (!silent) this.emit("change", { values: this.getValues() });
7783
7834
  return this;
7784
7835
  }
7836
+ /**
7837
+ * Disables or enables the editor. Disabled, every value input or select, drag handle, move and
7838
+ * remove button and the add button is disabled, the root carries `aria-disabled="true"`, and
7839
+ * neither a pointer nor the handle's keys reorder anything. `setValues()` still works, and rows
7840
+ * it renders stay disabled.
7841
+ * @param {boolean} disabled Disabled state.
7842
+ * @returns {this}
7843
+ */
7844
+ setDisabled(disabled) {
7845
+ this._disabled = Boolean(disabled);
7846
+ this._syncDisabled();
7847
+ return this;
7848
+ }
7849
+ /** Disables the editor; see `setDisabled()`. @returns {this} */
7850
+ disable() {
7851
+ return this.setDisabled(true);
7852
+ }
7853
+ /** Enables the editor. @returns {this} */
7854
+ enable() {
7855
+ return this.setDisabled(false);
7856
+ }
7857
+ /** Whether the editor is disabled. @returns {boolean} */
7858
+ isDisabled() {
7859
+ return this._disabled;
7860
+ }
7861
+ /**
7862
+ * Applies the disabled state to the controls in place rather than re-rendering them, so a value
7863
+ * typed into a row and not yet committed survives.
7864
+ * @returns {void}
7865
+ */
7866
+ _syncDisabled() {
7867
+ if (this._disabled) {
7868
+ this.el.setAttribute("aria-disabled", "true");
7869
+ this._disarm();
7870
+ } else this.el.removeAttribute("aria-disabled");
7871
+ this._add.disabled = this._disabled;
7872
+ for (const control of this._rows.querySelectorAll("input, select, button")) {
7873
+ control.disabled = this._disabled;
7874
+ }
7875
+ }
7785
7876
  /** @returns {{drag: boolean, buttons: boolean}} */
7786
7877
  _reorder() {
7787
7878
  return REORDER[this.options.reorder] ?? REORDER.both;
@@ -7801,6 +7892,7 @@ var zx = (() => {
7801
7892
  const control = useSelect ? h("select", {
7802
7893
  class: "zx-multi-value-editor__value",
7803
7894
  ariaLabel: this.msg("multiValueEditor.value", index + 1),
7895
+ disabled: this._disabled,
7804
7896
  dataset: { index }
7805
7897
  }, entries.map(([optionValue, label]) => h("option", {
7806
7898
  value: optionValue,
@@ -7810,6 +7902,7 @@ var zx = (() => {
7810
7902
  type: "text",
7811
7903
  value,
7812
7904
  ariaLabel: this.msg("multiValueEditor.value", index + 1),
7905
+ disabled: this._disabled,
7813
7906
  dataset: { index }
7814
7907
  });
7815
7908
  return h(
@@ -7819,6 +7912,7 @@ var zx = (() => {
7819
7912
  class: "zx-multi-value-editor__handle",
7820
7913
  type: "button",
7821
7914
  ariaLabel: this.msg("multiValueEditor.reorder", index + 1),
7915
+ disabled: this._disabled,
7822
7916
  dataset: { action: "grab", index }
7823
7917
  }, icon("drag", { size: 12 })) : null,
7824
7918
  control,
@@ -7832,6 +7926,7 @@ var zx = (() => {
7832
7926
  // control that disables itself under the reader's finger drops focus to the document.
7833
7927
  ariaDisabled: String(index === 0),
7834
7928
  ariaLabel: this.msg("multiValueEditor.moveUp", index + 1),
7929
+ disabled: this._disabled,
7835
7930
  dataset: { action: "up", index }
7836
7931
  }, icon("chevron-up", { size: ICON_SIZE.chevron })) : null,
7837
7932
  buttons ? h("button", {
@@ -7839,12 +7934,14 @@ var zx = (() => {
7839
7934
  type: "button",
7840
7935
  ariaDisabled: String(index === last),
7841
7936
  ariaLabel: this.msg("multiValueEditor.moveDown", index + 1),
7937
+ disabled: this._disabled,
7842
7938
  dataset: { action: "down", index }
7843
7939
  }, icon("chevron-down", { size: ICON_SIZE.chevron })) : null,
7844
7940
  h("button", {
7845
7941
  class: "zx-btn",
7846
7942
  type: "button",
7847
7943
  ariaLabel: this.msg("multiValueEditor.remove", index + 1),
7944
+ disabled: this._disabled,
7848
7945
  dataset: { action: "remove", index }
7849
7946
  }, icon("x", { size: ICON_SIZE.dismiss }))
7850
7947
  )
@@ -7859,7 +7956,7 @@ var zx = (() => {
7859
7956
  /** @param {MouseEvent} event @returns {void} */
7860
7957
  _handleClick(event) {
7861
7958
  const button2 = event.target instanceof Element ? event.target.closest("[data-action]") : null;
7862
- if (!button2 || !this.el.contains(button2)) return;
7959
+ if (this._disabled || !button2 || !this.el.contains(button2)) return;
7863
7960
  if (button2.getAttribute("aria-disabled") === "true") return;
7864
7961
  const action = button2.dataset.action;
7865
7962
  const index = Number(button2.dataset.index);
@@ -7893,7 +7990,7 @@ var zx = (() => {
7893
7990
  */
7894
7991
  _handleKeydown(event) {
7895
7992
  const handle = event.target instanceof Element ? event.target.closest(".zx-multi-value-editor__handle") : null;
7896
- if (!handle) return;
7993
+ if (!handle || this._disabled) return;
7897
7994
  const index = Number(handle.dataset.index);
7898
7995
  const target = event.key === "ArrowUp" ? index - 1 : event.key === "ArrowDown" ? index + 1 : event.key === "Home" ? 0 : event.key === "End" ? this._values.length - 1 : -1;
7899
7996
  if (target < 0 || target >= this._values.length) return;
@@ -7909,7 +8006,7 @@ var zx = (() => {
7909
8006
  _handlePointerDown(event) {
7910
8007
  const handle = event.target instanceof Element ? event.target.closest(".zx-multi-value-editor__handle") : null;
7911
8008
  this._disarm();
7912
- if (!handle || handle.disabled) return;
8009
+ if (!handle || handle.disabled || this._disabled) return;
7913
8010
  const row2 = (
7914
8011
  /** @type {HTMLElement|null} */
7915
8012
  handle.closest(".zx-multi-value-editor__row")
@@ -8008,7 +8105,7 @@ var zx = (() => {
8008
8105
  */
8009
8106
  _move(from, to, part) {
8010
8107
  const size2 = this._values.length;
8011
- if (from === to || from < 0 || to < 0 || from >= size2 || to >= size2) return false;
8108
+ if (this._disabled || from === to || from < 0 || to < 0 || from >= size2 || to >= size2) return false;
8012
8109
  const [value] = this._values.splice(from, 1);
8013
8110
  this._values.splice(to, 0, value);
8014
8111
  this._renderRows(to, part);
@@ -8023,6 +8120,8 @@ var zx = (() => {
8023
8120
  destroy() {
8024
8121
  if (this._initialState === null) this.el?.removeAttribute("data-state");
8025
8122
  else this.el?.setAttribute("data-state", this._initialState);
8123
+ if (this._initialAriaDisabled === null) this.el?.removeAttribute("aria-disabled");
8124
+ else this.el?.setAttribute("aria-disabled", this._initialAriaDisabled);
8026
8125
  for (const node of this._ownedNodes ?? []) node.remove();
8027
8126
  super.destroy();
8028
8127
  }
@@ -8042,33 +8141,19 @@ var zx = (() => {
8042
8141
  ...options.props ?? {},
8043
8142
  values: Array.isArray(options.value) ? options.value : []
8044
8143
  }));
8045
- const originalDisabled = /* @__PURE__ */ new WeakMap();
8046
- let disabled = false;
8047
- const syncDisabled = () => {
8048
- editor.el.setAttribute("aria-disabled", String(disabled));
8049
- for (const control of editor.el.querySelectorAll("input, button, select, textarea")) {
8050
- if (disabled) {
8051
- if (!originalDisabled.has(control)) originalDisabled.set(control, Boolean(control.disabled));
8052
- control.disabled = true;
8053
- } else if (originalDisabled.has(control)) {
8054
- control.disabled = originalDisabled.get(control);
8055
- originalDisabled.delete(control);
8056
- }
8057
- }
8058
- };
8059
8144
  field.listen(editor.el, "change", (event) => event.stopImmediatePropagation());
8060
8145
  editor.on("change", (event) => field.emit("change", { value: event.detail.values }));
8061
8146
  return {
8062
8147
  el: editor.el,
8063
8148
  get: () => editor.getValues(),
8064
- set: (value) => {
8065
- editor.setValues(Array.isArray(value) ? value : [], { silent: true });
8066
- syncDisabled();
8067
- },
8068
- focus: () => editor.el.querySelector(".zx-multi-value-editor__value:not([disabled]), button:not([disabled])")?.focus(),
8149
+ // Rows the editor renders while disabled are rendered disabled, so a value set on a
8150
+ // disabled field needs nothing more.
8151
+ set: (value) => editor.setValues(Array.isArray(value) ? value : [], { silent: true }),
8152
+ // The first value, else the first control: a selector list matches in document order, which
8153
+ // would put the drag handle ahead of the value it belongs to.
8154
+ focus: () => (editor.el.querySelector(".zx-multi-value-editor__value:not([disabled])") ?? editor.el.querySelector("button:not([disabled])"))?.focus(),
8069
8155
  setDisabled: (value) => {
8070
- disabled = Boolean(value);
8071
- syncDisabled();
8156
+ editor.setDisabled(value);
8072
8157
  }
8073
8158
  };
8074
8159
  });
@@ -9850,6 +9935,7 @@ var zx = (() => {
9850
9935
  this._loading = false;
9851
9936
  this._requestSequence = 0;
9852
9937
  this._queryTimer = null;
9938
+ this._queryController = null;
9853
9939
  this._position = null;
9854
9940
  this._createdRoot = false;
9855
9941
  this._root = null;
@@ -10378,9 +10464,10 @@ var zx = (() => {
10378
10464
  * `true` for public, or a group ID — so the control binds straight to the record field.
10379
10465
  *
10380
10466
  * @param {Element|string|null} target Component target.
10381
- * @param {SelectOptions & {groups?: SelectItem[]|((query: string) => Promise<SelectItem[]>|SelectItem[])}} [options={}]
10467
+ * @param {SelectOptions & {groups?: SelectItem[]|SelectFilter}} [options={}]
10382
10468
  * Select overrides other than the fixed choices; `groups` holds the shareable groups, either as
10383
- * an array (filtered locally) or as a loader function (queried remotely).
10469
+ * an array (filtered locally) or as a loader function (queried remotely, and handed the same
10470
+ * `{signal}` as any `filter` function).
10384
10471
  * @returns {Select}
10385
10472
  */
10386
10473
  static permission(target, options = {}) {
@@ -10665,6 +10752,8 @@ var zx = (() => {
10665
10752
  if (this._queryTimer !== null) clearTimeout(this._queryTimer);
10666
10753
  this._requestSequence += 1;
10667
10754
  const sequence = this._requestSequence;
10755
+ this._abortQuery();
10756
+ if (sequence !== this._requestSequence) return;
10668
10757
  this._visibleFixed = this._matchFixed(query);
10669
10758
  if (query.length < Math.max(0, Number(this.options.minQuery) || 0)) {
10670
10759
  this._setLoading(false);
@@ -10684,9 +10773,15 @@ var zx = (() => {
10684
10773
  /** @param {string} query @param {number} sequence @returns {Promise<void>} */
10685
10774
  async _runAsyncQuery(query, sequence) {
10686
10775
  if (sequence !== this._requestSequence || typeof this.options.filter !== "function") return;
10776
+ const controller = new AbortController();
10777
+ this._queryController = controller;
10687
10778
  this.emit("query", { query });
10779
+ if (sequence !== this._requestSequence || controller.signal.aborted) {
10780
+ if (this._queryController === controller) this._queryController = null;
10781
+ return;
10782
+ }
10688
10783
  try {
10689
- const result = await this.options.filter(query);
10784
+ const result = await this.options.filter(query, { signal: controller.signal });
10690
10785
  if (sequence !== this._requestSequence || !this._open) return;
10691
10786
  this._items = Array.isArray(result) ? result.slice() : [];
10692
10787
  this._visibleItems = this._items.slice();
@@ -10702,6 +10797,8 @@ var zx = (() => {
10702
10797
  this._setLoading(false);
10703
10798
  this._renderOptions();
10704
10799
  this._position?.update();
10800
+ } finally {
10801
+ if (this._queryController === controller) this._queryController = null;
10705
10802
  }
10706
10803
  }
10707
10804
  /** @returns {void} */
@@ -10709,6 +10806,17 @@ var zx = (() => {
10709
10806
  if (this._queryTimer !== null) clearTimeout(this._queryTimer);
10710
10807
  this._queryTimer = null;
10711
10808
  this._requestSequence += 1;
10809
+ this._abortQuery();
10810
+ }
10811
+ /**
10812
+ * Aborts the signal handed to the filter for the request in flight. Callers move the sequence on
10813
+ * first, so whatever the aborted request resolves or rejects with is already stale.
10814
+ * @returns {void}
10815
+ */
10816
+ _abortQuery() {
10817
+ const controller = this._queryController;
10818
+ this._queryController = null;
10819
+ controller?.abort();
10712
10820
  }
10713
10821
  /** @param {boolean} loading @returns {void} */
10714
10822
  _setLoading(loading) {
@@ -11449,6 +11557,7 @@ var zx = (() => {
11449
11557
  this._loading = false;
11450
11558
  this._requestSequence = 0;
11451
11559
  this._queryTimer = null;
11560
+ this._queryController = null;
11452
11561
  this._position = null;
11453
11562
  this._activeId = null;
11454
11563
  this._createdRoot = this.el === null;
@@ -12009,7 +12118,7 @@ var zx = (() => {
12009
12118
  }
12010
12119
  /** @param {string} query @returns {void} */
12011
12120
  _scheduleAsyncQuery(query) {
12012
- this._cancelQuery();
12121
+ if (this._cancelQuery() !== this._requestSequence) return;
12013
12122
  const text6 = String(query ?? "");
12014
12123
  if (text6.length < Number(this.options.minQuery ?? 0)) {
12015
12124
  this._visible = [];
@@ -12030,10 +12139,16 @@ var zx = (() => {
12030
12139
  const sequence = this._requestSequence + 1;
12031
12140
  this._requestSequence = sequence;
12032
12141
  this._setLoading(true);
12142
+ const controller = new AbortController();
12143
+ this._queryController = controller;
12033
12144
  this.emit("query", { query });
12145
+ if (sequence !== this._requestSequence || controller.signal.aborted) {
12146
+ if (this._queryController === controller) this._queryController = null;
12147
+ return;
12148
+ }
12034
12149
  try {
12035
- const result = await /** @type {Function} */
12036
- this.options.filter(query);
12150
+ const result = await /** @type {TagPickerFilter} */
12151
+ this.options.filter(query, { signal: controller.signal });
12037
12152
  if (sequence !== this._requestSequence) return;
12038
12153
  this._items = Array.isArray(result) ? result.slice() : [];
12039
12154
  this._visible = this._items.slice();
@@ -12048,16 +12163,21 @@ var zx = (() => {
12048
12163
  this._setActive(this._entries.length > 0 ? 0 : -1);
12049
12164
  this._position?.update();
12050
12165
  }
12166
+ if (this._queryController === controller) this._queryController = null;
12051
12167
  }
12052
12168
  }
12053
- /** @returns {void} */
12169
+ /** @returns {number} The request generation this cancellation started. */
12054
12170
  _cancelQuery() {
12055
12171
  if (this._queryTimer !== null) {
12056
12172
  clearTimeout(this._queryTimer);
12057
12173
  this._queryTimer = null;
12058
12174
  }
12059
- this._requestSequence += 1;
12060
- this._setLoading(false);
12175
+ const sequence = ++this._requestSequence;
12176
+ const controller = this._queryController;
12177
+ this._queryController = null;
12178
+ controller?.abort();
12179
+ if (sequence === this._requestSequence) this._setLoading(false);
12180
+ return sequence;
12061
12181
  }
12062
12182
  /** @param {boolean} loading @returns {void} */
12063
12183
  _setLoading(loading) {
@@ -12355,6 +12475,16 @@ var zx = (() => {
12355
12475
  if (!options.silent) this._emitChange();
12356
12476
  return this;
12357
12477
  }
12478
+ /**
12479
+ * Moves focus to the hours segment, the first one a duration is typed into (the sign toggle of a
12480
+ * `signed` timebox sits before it and stays one Shift+Tab away). Focusing selects the segment's
12481
+ * digits, as a click into it does. A disabled timebox does not take focus.
12482
+ * @returns {this}
12483
+ */
12484
+ focus() {
12485
+ this._inputs[0]?.focus();
12486
+ return this;
12487
+ }
12358
12488
  /** Enables the timebox. @returns {this} */
12359
12489
  enable() {
12360
12490
  this._disabled = false;
@@ -12415,9 +12545,10 @@ var zx = (() => {
12415
12545
  }
12416
12546
  /** @returns {void} */
12417
12547
  _commitSegments() {
12548
+ const before = this._committed;
12418
12549
  this._parts = this._readParts();
12419
12550
  this._writeParts();
12420
- this._emitChange();
12551
+ if (this._committed !== before) this._emitChange();
12421
12552
  }
12422
12553
  /** @returns {void} */
12423
12554
  _writeParts() {
@@ -12425,6 +12556,7 @@ var zx = (() => {
12425
12556
  const name2 = input.dataset.segment;
12426
12557
  input.value = name2 === "hours" ? String(this._parts[name2]) : pad3(this._parts[name2]);
12427
12558
  }
12559
+ this._committed = joinTime(this._parts, this.options.unit);
12428
12560
  if (this.refs.sign) {
12429
12561
  this.refs.sign.textContent = this._parts.negative ? "-" : "+";
12430
12562
  this.refs.sign.setAttribute("aria-pressed", String(this._parts.negative));
@@ -14462,7 +14594,9 @@ var zx = (() => {
14462
14594
  const dialog = (
14463
14595
  /** @type {HTMLDialogElement} */
14464
14596
  h("dialog", {
14465
- class: "zx-modal"
14597
+ class: "zx-modal",
14598
+ // The panel is a surface, never a control: when it holds focus itself it draws no ring.
14599
+ dataset: { zxFocus: "container" }
14466
14600
  }, h("div", { class: "zx-modal__content", ref: "content" }))
14467
14601
  );
14468
14602
  dialog.dataset.state = "closed";
@@ -14853,7 +14987,8 @@ var zx = (() => {
14853
14987
  "dialog",
14854
14988
  {
14855
14989
  class: "zx-modal zx-dialog",
14856
- ariaLabelledby: titleId
14990
+ ariaLabelledby: titleId,
14991
+ dataset: { zxFocus: "container" }
14857
14992
  },
14858
14993
  h(
14859
14994
  "header",
@@ -15555,6 +15690,78 @@ var zx = (() => {
15555
15690
  }
15556
15691
  };
15557
15692
 
15693
+ // src/internal/focus-stops.js
15694
+ var NATIVE_STOPS = [
15695
+ "a[href]",
15696
+ "area[href]",
15697
+ "button",
15698
+ 'input:not([type="hidden"])',
15699
+ "select",
15700
+ "textarea",
15701
+ "iframe",
15702
+ "object",
15703
+ "embed",
15704
+ "audio[controls]",
15705
+ "video[controls]",
15706
+ "details > summary:first-of-type",
15707
+ '[contenteditable]:not([contenteditable="false"])'
15708
+ ].join(",");
15709
+ var CANDIDATES = `${NATIVE_STOPS},[tabindex]`;
15710
+ function syncPanelStop(panel) {
15711
+ const stop = !containsTabStop(panel);
15712
+ if (stop && panel.getAttribute("tabindex") !== "0") panel.tabIndex = 0;
15713
+ else if (!stop && panel.hasAttribute("tabindex") && panel.ownerDocument.activeElement !== panel) {
15714
+ panel.removeAttribute("tabindex");
15715
+ }
15716
+ return stop;
15717
+ }
15718
+ function containsTabStop(container) {
15719
+ const rendered = isRendered2(container);
15720
+ for (const element of container.querySelectorAll(CANDIDATES)) {
15721
+ if (isTabStop(element, container, rendered)) return true;
15722
+ }
15723
+ return false;
15724
+ }
15725
+ function syncScrollStop(element) {
15726
+ const overflowing = isOverflowing(element);
15727
+ if (overflowing && !element.hasAttribute("tabindex")) element.tabIndex = 0;
15728
+ else if (!overflowing && element.hasAttribute("tabindex") && element.ownerDocument.activeElement !== element) {
15729
+ element.removeAttribute("tabindex");
15730
+ }
15731
+ return overflowing;
15732
+ }
15733
+ function isOverflowing(element) {
15734
+ return element.scrollWidth > element.clientWidth + 1 || element.scrollHeight > element.clientHeight + 1;
15735
+ }
15736
+ function isTabStop(element, container, rendered) {
15737
+ const html = (
15738
+ /** @type {HTMLElement} */
15739
+ element
15740
+ );
15741
+ if (typeof html.focus !== "function") return false;
15742
+ const index = Number.parseInt(element.getAttribute("tabindex") ?? "", 10);
15743
+ if (Number.isNaN(index) ? !element.matches(NATIVE_STOPS) : index < 0) return false;
15744
+ if (element.matches(":disabled")) return false;
15745
+ for (let node = (
15746
+ /** @type {Element|null} */
15747
+ element
15748
+ ); node && node !== container; node = node.parentElement) {
15749
+ if (
15750
+ /** @type {HTMLElement} */
15751
+ node.hidden || node.hasAttribute("inert")
15752
+ ) return false;
15753
+ const parent = node.parentElement;
15754
+ if (parent?.localName === "details" && !/** @type {HTMLDetailsElement} */
15755
+ parent.open && node !== parent.querySelector(":scope > summary")) return false;
15756
+ }
15757
+ if (!rendered) return true;
15758
+ if (typeof html.checkVisibility === "function") return html.checkVisibility({ visibilityProperty: true });
15759
+ return html.getClientRects().length > 0;
15760
+ }
15761
+ function isRendered2(element) {
15762
+ return element.isConnected && element.getClientRects().length > 0;
15763
+ }
15764
+
15558
15765
  // src/components/tabbox/tabbox.js
15559
15766
  var VARIANTS2 = /* @__PURE__ */ new Set(["divided", "bracket", "line", "segmented"]);
15560
15767
  var Tabbox = class extends Component {
@@ -15692,9 +15899,9 @@ var zx = (() => {
15692
15899
  class: "zx-tabbox__panel",
15693
15900
  id: panelId,
15694
15901
  role: "tabpanel",
15695
- tabindex: "0",
15696
15902
  ariaLabelledby: tabId,
15697
- hidden: true
15903
+ hidden: true,
15904
+ dataset: { zxFocus: "region" }
15698
15905
  });
15699
15906
  const record = { definition: normalized, tab, title, badge: badge2, panel, built: false };
15700
15907
  const numericIndex = Number.isFinite(insert.index) ? Math.trunc(insert.index) : this._tabs.length;
@@ -15829,6 +16036,10 @@ var zx = (() => {
15829
16036
  if (!tab || !this.refs.tablist.contains(tab)) return;
15830
16037
  const current = this._recordForTab(tab);
15831
16038
  if (!current) return;
16039
+ if (event.key === "Tab" && !event.shiftKey) {
16040
+ this._syncPanelStop();
16041
+ return;
16042
+ }
15832
16043
  const enabled = this._enabledTabs();
15833
16044
  if (event.key === "ArrowLeft" || event.key === "ArrowRight") {
15834
16045
  event.preventDefault();
@@ -15910,8 +16121,18 @@ var zx = (() => {
15910
16121
  record.tab.setAttribute("aria-selected", "true");
15911
16122
  record.panel.hidden = false;
15912
16123
  if (record.panel.parentNode !== this.refs.panels) this.refs.panels.append(record.panel);
16124
+ this._syncPanelStop();
15913
16125
  this._setFocused(record, false);
15914
16126
  }
16127
+ /**
16128
+ * Makes the active panel a Tab stop only while nothing inside it is one: Tab from the tab goes
16129
+ * to the panel's first control when it has one, and onto the panel itself when it holds only
16130
+ * text to read or scroll.
16131
+ * @returns {void}
16132
+ */
16133
+ _syncPanelStop() {
16134
+ if (this._active) syncPanelStop(this._active.panel);
16135
+ }
15915
16136
  /** @param {TabRecord} record @returns {void} */
15916
16137
  _ensureContent(record) {
15917
16138
  if (record.built) return;
@@ -16403,6 +16624,9 @@ var zx = (() => {
16403
16624
  this._scroll = h("div", {
16404
16625
  class: "zx-table__scroll",
16405
16626
  dataset: {
16627
+ // A scroller with nothing focusable inside is a Tab stop of the browser's making: it keeps
16628
+ // an inset ring there, and none while it holds focus for a table with no rows.
16629
+ zxFocus: "region",
16406
16630
  stickyHeader: String(Boolean(this.options.stickyHeader)),
16407
16631
  // Stripes follow the row's place in the data while windowed: `:nth-child` would count the
16408
16632
  // spacers, and the stripes would swap as the window moved.
@@ -18754,11 +18978,13 @@ var zx = (() => {
18754
18978
  if (!frame.hasAttribute("tabindex")) {
18755
18979
  frame.tabIndex = -1;
18756
18980
  frame.setAttribute("data-empty-focus", "");
18981
+ frame.dataset.zxFocus = "container";
18757
18982
  }
18758
18983
  frame.focus({ preventScroll: true });
18759
18984
  } else if (frame.hasAttribute("data-empty-focus")) {
18760
18985
  frame.removeAttribute("tabindex");
18761
18986
  frame.removeAttribute("data-empty-focus");
18987
+ frame.dataset.zxFocus = "region";
18762
18988
  }
18763
18989
  }
18764
18990
  /** @param {Event} event @returns {void} */
@@ -21560,7 +21786,7 @@ ${block.code}
21560
21786
  this._nodes.push(node);
21561
21787
  if (this._stoppedNote) this._stoppedNote.before(node);
21562
21788
  else this.el.append(node);
21563
- if (copy.type === "table") this._syncScrollers();
21789
+ if (copy.type === "table" || copy.type === "code") this._syncScrollers();
21564
21790
  }
21565
21791
  /** @private @returns {void} */
21566
21792
  _redrawLast() {
@@ -21604,12 +21830,20 @@ ${block.code}
21604
21830
  else root.removeAttribute("aria-busy");
21605
21831
  }
21606
21832
  /**
21607
- * A wide table scrolls inside the answer; while it does, its wrapper is a named, focusable
21608
- * region so the keyboard can scroll it too. A table that fits is not a tab stop.
21833
+ * A wide table or a long code line scrolls inside the answer; while it does, its scroller is a
21834
+ * Tab stop so the keyboard can scroll it too — a table's wrapper a named region. One that fits
21835
+ * is not a Tab stop.
21609
21836
  * @private
21610
21837
  * @returns {void}
21611
21838
  */
21612
21839
  _syncScrollers() {
21840
+ for (
21841
+ const pre of
21842
+ /** @type {NodeListOf<HTMLElement>} */
21843
+ this.el.querySelectorAll(".zx-block-view__pre")
21844
+ ) {
21845
+ syncScrollStop(pre);
21846
+ }
21613
21847
  for (
21614
21848
  const wrap of
21615
21849
  /** @type {NodeListOf<HTMLElement>} */
@@ -21743,14 +21977,14 @@ ${block.code}
21743
21977
  h("span", { class: "zx-block-view__code-language" }, language2 || msg("blockView.code")),
21744
21978
  copyButton({ text: String(block.code ?? ""), title: msg("blockView.copyCode"), size: "sm" })
21745
21979
  ),
21746
- block.lines ? h("pre", { class: "zx-block-view__pre", dataset: { lines: "" }, tabindex: "0" }, h(
21980
+ block.lines ? h("pre", { class: "zx-block-view__pre", dataset: { lines: "", zxFocus: "region" } }, h(
21747
21981
  "code",
21748
21982
  {},
21749
21983
  String(block.code ?? "").split("\n").map((line) => h("span", {
21750
21984
  class: "zx-block-view__line",
21751
21985
  style: { "--zx-block-view-indent": `${/^\s*/.exec(line)?.[0].length ?? 0}ch` }
21752
21986
  }, codeSegments(language2, line)))
21753
- )) : h("pre", { class: "zx-block-view__pre", tabindex: "0" }, h("code", {}, codeSegments(language2, block.code)))
21987
+ )) : h("pre", { class: "zx-block-view__pre", dataset: { zxFocus: "region" } }, h("code", {}, codeSegments(language2, block.code)))
21754
21988
  );
21755
21989
  }
21756
21990
  function codeSegments(language2, code) {
@@ -21763,7 +21997,7 @@ ${block.code}
21763
21997
  const value = block.align?.[index];
21764
21998
  return value === "end" || value === "center" ? value : null;
21765
21999
  };
21766
- return h("div", { class: "zx-block-view__table" }, h(
22000
+ return h("div", { class: "zx-block-view__table", dataset: { zxFocus: "region" } }, h(
21767
22001
  "table",
21768
22002
  {},
21769
22003
  h("thead", {}, h("tr", {}, columns.map((column, index) => h(
@@ -22452,6 +22686,7 @@ ${block.code}
22452
22686
  root.setAttribute("role", "group");
22453
22687
  root.setAttribute("aria-labelledby", titleId);
22454
22688
  root.tabIndex = -1;
22689
+ root.dataset.zxFocus = "container";
22455
22690
  this._titleEl = h(`h${level}`, { class: "zx-approval-card__title", id: titleId }, this._title);
22456
22691
  this._noteEl = h("p", { class: "zx-approval-card__note", id: uid("zx-approval-card-note") });
22457
22692
  this._statusEl = h("span", { class: "zx-approval-card__status" });
@@ -23458,7 +23693,7 @@ ${block.code}
23458
23693
 
23459
23694
  // src/components/skeleton/skeleton.js
23460
23695
  function skeleton(opts = {}) {
23461
- const options = { width: "100%", height: "1rem", radius: "sm", ...opts };
23696
+ const options = { width: "100%", height: "1rem", radius: "sm", ...given(opts) };
23462
23697
  return (
23463
23698
  /** @type {HTMLSpanElement} */
23464
23699
  h("span", {
@@ -23470,7 +23705,7 @@ ${block.code}
23470
23705
  );
23471
23706
  }
23472
23707
  function skeletonText(opts = {}) {
23473
- const options = { lines: 3, width: "100%", heading: false, lastLineWidth: "60%", ...opts };
23708
+ const options = { lines: 3, width: "100%", heading: false, lastLineWidth: "60%", ...given(opts) };
23474
23709
  const lines = clamp(Math.trunc(Number(options.lines) || 0), 1, 20);
23475
23710
  const element = (
23476
23711
  /** @type {HTMLDivElement} */
@@ -23491,7 +23726,7 @@ ${block.code}
23491
23726
  return element;
23492
23727
  }
23493
23728
  function skeletonTable(opts = {}) {
23494
- const options = { rows: 5, columns: 4, header: true, ...opts };
23729
+ const options = { rows: 5, columns: 4, header: true, ...given(opts) };
23495
23730
  const rows = clamp(Math.trunc(Number(options.rows) || 0), 1, 50);
23496
23731
  const columns = clamp(Math.trunc(Number(options.columns) || 0), 1, 20);
23497
23732
  const element = (
@@ -23530,6 +23765,14 @@ ${block.code}
23530
23765
  if (index === columns - 1) return "55%";
23531
23766
  return index % 2 === 0 ? "80%" : "65%";
23532
23767
  }
23768
+ function given(opts) {
23769
+ return (
23770
+ /** @type {Partial<T>} */
23771
+ Object.fromEntries(
23772
+ Object.entries(opts ?? {}).filter(([, value]) => value !== void 0)
23773
+ )
23774
+ );
23775
+ }
23533
23776
  function size(value) {
23534
23777
  return typeof value === "number" ? `${value}px` : String(value ?? "");
23535
23778
  }
@@ -23669,6 +23912,8 @@ ${block.code}
23669
23912
  }
23670
23913
  });
23671
23914
  if (this.options.ticking) this.listen(root.ownerDocument, "visibilitychange", () => this._syncClock());
23915
+ this._resize = typeof ResizeObserver === "function" ? new ResizeObserver(() => this._syncCodeStops(root)) : null;
23916
+ this._resize?.observe(root);
23672
23917
  this._build(this.options.steps);
23673
23918
  return root;
23674
23919
  }
@@ -23791,6 +24036,8 @@ ${block.code}
23791
24036
  this._revealTimer = null;
23792
24037
  if (this._clock) clearInterval(this._clock);
23793
24038
  this._clock = null;
24039
+ this._resize?.disconnect();
24040
+ this._resize = null;
23794
24041
  for (const entry of this._entries.values()) this._releaseAvatars(entry);
23795
24042
  this._entries.clear();
23796
24043
  super.destroy();
@@ -23936,6 +24183,7 @@ ${block.code}
23936
24183
  entry.row = row2;
23937
24184
  entry.refs = refs;
23938
24185
  entry.body = body;
24186
+ if (body) this._syncCodeStops(body);
23939
24187
  const again = focusedRef === null ? null : (
23940
24188
  /** @type {HTMLElement|null} */
23941
24189
  refs?.querySelector(`[data-ref-index="${focusedRef}"]`) ?? null
@@ -24093,11 +24341,11 @@ ${block.code}
24093
24341
  h("span", { class: "zx-run-trace__section-title", id: titleId }, this.msg(keys.title)),
24094
24342
  copyButton({ text: full, title: this.msg(keys.copy), feedback: this.msg("runTrace.copied"), size: "sm" })
24095
24343
  ),
24344
+ // A Tab stop only while its text scrolls (`_syncCodeStops()`).
24096
24345
  h("pre", {
24097
24346
  class: "zx-run-trace__code",
24098
- tabindex: "0",
24099
24347
  "aria-labelledby": titleId,
24100
- dataset: { tone: kind === "error" ? "danger" : null }
24348
+ dataset: { tone: kind === "error" ? "danger" : null, zxFocus: "region" }
24101
24349
  }, shown.text),
24102
24350
  shown.cut ? h("button", {
24103
24351
  type: "button",
@@ -24117,6 +24365,7 @@ ${block.code}
24117
24365
  this._open = open;
24118
24366
  this._summary.setAttribute("aria-expanded", String(open));
24119
24367
  this._list.hidden = !open;
24368
+ if (open) this._syncCodeStops(this._list);
24120
24369
  this._syncClock();
24121
24370
  this.emit("toggle", { id: null, open });
24122
24371
  }
@@ -24133,8 +24382,24 @@ ${block.code}
24133
24382
  else this._expanded.delete(id);
24134
24383
  entry.row.setAttribute("aria-expanded", String(open));
24135
24384
  entry.body.hidden = !open;
24385
+ if (open) this._syncCodeStops(entry.body);
24136
24386
  this.emit("toggle", { id, open });
24137
24387
  }
24388
+ /**
24389
+ * Makes each code block a Tab stop while, and only while, its text scrolls inside it.
24390
+ * @private
24391
+ * @param {Element} scope Where to look for code blocks.
24392
+ * @returns {void}
24393
+ */
24394
+ _syncCodeStops(scope2) {
24395
+ for (
24396
+ const code of
24397
+ /** @type {NodeListOf<HTMLElement>} */
24398
+ scope2.querySelectorAll(".zx-run-trace__code")
24399
+ ) {
24400
+ syncScrollStop(code);
24401
+ }
24402
+ }
24138
24403
  /**
24139
24404
  * Redraws the summary from the steps.
24140
24405
  * @private
@@ -28077,9 +28342,10 @@ ${block.code}
28077
28342
  this._progressHost = h("div", { class: "zx-questionnaire__progress", hidden: !this.options.progress });
28078
28343
  this._itemHost = h("fieldset", {
28079
28344
  class: "zx-questionnaire__item",
28080
- tabIndex: -1
28345
+ tabIndex: -1,
28346
+ dataset: { zxFocus: "container" }
28081
28347
  });
28082
- this._reviewHost = h("div", { class: "zx-questionnaire__review", tabIndex: -1, hidden: true });
28348
+ this._reviewHost = h("div", { class: "zx-questionnaire__review", tabIndex: -1, hidden: true, dataset: { zxFocus: "container" } });
28083
28349
  this._actionsHost = h("div", { class: "zx-questionnaire__actions" });
28084
28350
  this.refs.item = this._itemHost;
28085
28351
  this.refs.review = this._reviewHost;
@@ -28935,6 +29201,7 @@ ${block.code}
28935
29201
  let sign2 = 1;
28936
29202
  let moved = false;
28937
29203
  let frame = 0;
29204
+ let uncaptured = null;
28938
29205
  const axis = (event) => vertical ? event.clientY : event.clientX;
28939
29206
  const blocked = () => Boolean(options.disabled?.());
28940
29207
  const rightToLeft = () => {
@@ -28964,6 +29231,8 @@ ${block.code}
28964
29231
  moved = false;
28965
29232
  cancelFrame2();
28966
29233
  releasePointer();
29234
+ uncaptured?.abort();
29235
+ uncaptured = null;
28967
29236
  };
28968
29237
  handle.addEventListener("pointerdown", (event) => {
28969
29238
  const pointer = (
@@ -28981,9 +29250,17 @@ ${block.code}
28981
29250
  try {
28982
29251
  handle.setPointerCapture(pointer.pointerId);
28983
29252
  } catch {
29253
+ const target = handle.ownerDocument;
29254
+ if (target) {
29255
+ uncaptured = new AbortController();
29256
+ const watch = { signal: uncaptured.signal };
29257
+ target.addEventListener("pointermove", move, watch);
29258
+ target.addEventListener("pointerup", end, watch);
29259
+ target.addEventListener("pointercancel", end, watch);
29260
+ }
28984
29261
  }
28985
29262
  }, { signal });
28986
- handle.addEventListener("pointermove", (event) => {
29263
+ function move(event) {
28987
29264
  const pointer = (
28988
29265
  /** @type {PointerEvent} */
28989
29266
  event
@@ -28996,8 +29273,9 @@ ${block.code}
28996
29273
  frame = 0;
28997
29274
  if (dragging) options.onMove(sign2 * (client - startClient));
28998
29275
  });
28999
- }, { signal });
29000
- const end = (event) => {
29276
+ }
29277
+ handle.addEventListener("pointermove", move, { signal });
29278
+ function end(event) {
29001
29279
  const pointer = (
29002
29280
  /** @type {PointerEvent} */
29003
29281
  event
@@ -29009,7 +29287,7 @@ ${block.code}
29009
29287
  const delta = sign2 * (client - startClient);
29010
29288
  finish();
29011
29289
  options.onEnd?.(delta, travelled);
29012
- };
29290
+ }
29013
29291
  handle.addEventListener("pointerup", end, { signal });
29014
29292
  handle.addEventListener("pointercancel", end, { signal });
29015
29293
  handle.addEventListener("keydown", (event) => {
@@ -33025,16 +33303,16 @@ ${block.code}
33025
33303
  function createReply(document2, details) {
33026
33304
  const action = String(details.action);
33027
33305
  const intent = document2.intent;
33028
- const given = isObject5(details.values) ? details.values : {};
33306
+ const given2 = isObject5(details.values) ? details.values : {};
33029
33307
  let values = {};
33030
33308
  if (!intent || VALUELESS_INTENTS.has(intent) || VALUELESS_ACTIONS.has(action)) {
33031
33309
  values = {};
33032
33310
  } else if (intent === "questionnaire") {
33033
- values = isObject5(given.answers) ? visibleSteps(questionnaireSteps(document2), given.answers, Array.isArray(given.path) ? given.path : []) : {};
33311
+ values = isObject5(given2.answers) ? visibleSteps(questionnaireSteps(document2), given2.answers, Array.isArray(given2.path) ? given2.path : []) : {};
33034
33312
  } else {
33035
- const { names } = surfaceVisibility(document2, given);
33313
+ const { names } = surfaceVisibility(document2, given2);
33036
33314
  for (const name2 of names) {
33037
- if (Object.hasOwn(given, name2) && given[name2] !== void 0) values[name2] = clone2(given[name2]);
33315
+ if (Object.hasOwn(given2, name2) && given2[name2] !== void 0) values[name2] = clone2(given2[name2]);
33038
33316
  }
33039
33317
  }
33040
33318
  const reply = {
@@ -33073,8 +33351,8 @@ ${block.code}
33073
33351
  ) && !VALUELESS_ACTIONS.has(action);
33074
33352
  if (answered && doc.intent === "questionnaire") {
33075
33353
  const steps = questionnaireSteps(doc);
33076
- const given = isObject5(values.answers) ? values.answers : {};
33077
- const { answers, path } = visibleSteps(steps, given, Array.isArray(values.path) ? values.path : Object.keys(given));
33354
+ const given2 = isObject5(values.answers) ? values.answers : {};
33355
+ const { answers, path } = visibleSteps(steps, given2, Array.isArray(values.path) ? values.path : Object.keys(given2));
33078
33356
  for (const name2 of path) {
33079
33357
  const step2 = steps.find((entry) => isObject5(entry) && entry.name === name2);
33080
33358
  if (!step2 || !Object.hasOwn(answers, name2)) continue;
@@ -33516,9 +33794,9 @@ ${block.code}
33516
33794
  { op: "end", surface: valid.surface, ...sources ? { sources } : {} }
33517
33795
  );
33518
33796
  }
33519
- const given = this.options.reply;
33520
- if (valid && given && typeof given === "object" && given.surface === valid.surface) {
33521
- this._reply = structuredClone(given);
33797
+ const given2 = this.options.reply;
33798
+ if (valid && given2 && typeof given2 === "object" && given2.surface === valid.surface) {
33799
+ this._reply = structuredClone(given2);
33522
33800
  }
33523
33801
  this._draw();
33524
33802
  this._report(errors);
@@ -34314,15 +34592,15 @@ ${block.code}
34314
34592
  break;
34315
34593
  }
34316
34594
  case "questionnaire": {
34317
- const given = (
34595
+ const given2 = (
34318
34596
  /** @type {Record<string, unknown>} */
34319
34597
  values.answers ?? {}
34320
34598
  );
34321
34599
  const { answers, path } = visibleSteps(
34322
34600
  props.steps,
34323
- given,
34601
+ given2,
34324
34602
  /** @type {string[]} */
34325
- Array.isArray(values.path) ? values.path : Object.keys(given)
34603
+ Array.isArray(values.path) ? values.path : Object.keys(given2)
34326
34604
  );
34327
34605
  for (const name2 of path) {
34328
34606
  const step2 = props.steps.find((entry) => entry.name === name2);
@@ -34930,7 +35208,7 @@ ${block.code}
34930
35208
  const verdict = verdictText(reply.action, this._model.actions ?? [], (key, ...args) => this.msg(key, ...args));
34931
35209
  this._verdict = h(
34932
35210
  "p",
34933
- { class: "zx-surface__verdict", tabIndex: -1, dataset: { action: reply.action } },
35211
+ { class: "zx-surface__verdict", tabIndex: -1, dataset: { action: reply.action, zxFocus: "container" } },
34934
35212
  h(
34935
35213
  "span",
34936
35214
  { class: "zx-surface__verdict-icon", "aria-hidden": "true" },
@@ -35038,9 +35316,9 @@ ${block.code}
35038
35316
  signal.addEventListener("abort", withdraw, { once: true });
35039
35317
  surface2.on("reply", () => signal.removeEventListener("abort", withdraw));
35040
35318
  };
35041
- const given = surfaceOptions.reply;
35042
- if (given && typeof given === "object" && /** @type {SurfaceReply} */
35043
- given.surface === preview.surface) {
35319
+ const given2 = surfaceOptions.reply;
35320
+ if (given2 && typeof given2 === "object" && /** @type {SurfaceReply} */
35321
+ given2.surface === preview.surface) {
35044
35322
  const host = typeof target === "string" ? globalThis.document.querySelector(target) : target;
35045
35323
  if (host) {
35046
35324
  const receipt = new Surface(null, { ...surfaceOptions, document: document2 });
@@ -35049,7 +35327,7 @@ ${block.code}
35049
35327
  }
35050
35328
  resolve(structuredClone(
35051
35329
  /** @type {SurfaceReply} */
35052
- given
35330
+ given2
35053
35331
  ));
35054
35332
  return;
35055
35333
  }
@@ -36933,10 +37211,10 @@ ${block.code}
36933
37211
  if (item.reply && !old.surface?.getReply()) return false;
36934
37212
  if ((item.token ?? null) !== (before.token ?? null) || (item.catalog ?? null) !== (before.catalog ?? null)) return false;
36935
37213
  if (item.document == null) return true;
36936
- const given = JSON.stringify(item.document);
36937
- if (given === JSON.stringify(before.document ?? null)) return true;
37214
+ const given2 = JSON.stringify(item.document);
37215
+ if (given2 === JSON.stringify(before.document ?? null)) return true;
36938
37216
  const drawn = old.surface?.toDocument();
36939
- return Boolean(drawn) && given === JSON.stringify(drawn);
37217
+ return Boolean(drawn) && given2 === JSON.stringify(drawn);
36940
37218
  }
36941
37219
  function actionButton2(glyph, label, data2, disabled = false) {
36942
37220
  return (
@@ -38628,11 +38906,13 @@ ${block.code}
38628
38906
  if (!content.hasAttribute("tabindex")) {
38629
38907
  content.tabIndex = -1;
38630
38908
  content.setAttribute("data-empty-focus", "");
38909
+ content.setAttribute("data-zx-focus", "container");
38631
38910
  }
38632
38911
  content.focus({ preventScroll: true });
38633
38912
  } else if (content.hasAttribute("data-empty-focus")) {
38634
38913
  content.removeAttribute("tabindex");
38635
38914
  content.removeAttribute("data-empty-focus");
38915
+ content.removeAttribute("data-zx-focus");
38636
38916
  }
38637
38917
  }
38638
38918
  /** @private @returns {HTMLElement[]} Roving items in display order. */
@@ -38772,7 +39052,7 @@ ${block.code}
38772
39052
  for (let index = 0; index < this._cardLoadingCount; index += 1) {
38773
39053
  list.append(h(
38774
39054
  "li",
38775
- { class: "zx-record-card zx-card-view__skeleton", tabindex: -1 },
39055
+ { class: "zx-record-card zx-card-view__skeleton", tabindex: -1, dataset: { zxFocus: "container" } },
38776
39056
  h("span", { class: "zx-card-view__skeleton-preview zx-skeleton" }),
38777
39057
  h("span", { class: "zx-card-view__skeleton-line zx-skeleton" }),
38778
39058
  h("span", { class: "zx-card-view__skeleton-line zx-skeleton" }),
@@ -42001,11 +42281,23 @@ ${this._sendLabel}`;
42001
42281
  render() {
42002
42282
  const panel = h("div", {
42003
42283
  id: uid("zx-dropdown"),
42004
- popover: "manual"
42284
+ popover: "manual",
42285
+ // A surface, not a control: it draws no ring when a script focuses it (`#syncFocusMarker()`).
42286
+ dataset: { zxFocus: "container" }
42005
42287
  });
42006
42288
  panel.dataset.state = "closed";
42007
42289
  return panel;
42008
42290
  }
42291
+ /**
42292
+ * A panel the application put in the Tab order (`tabindex` of 0 or more) is reached from its
42293
+ * anchor's Tab, so it shows keyboard focus as a region, with the ring inside its edge; otherwise
42294
+ * only a script focuses it and it draws no ring.
42295
+ * @returns {void}
42296
+ */
42297
+ #syncFocusMarker() {
42298
+ const reachable = this.el.hasAttribute("tabindex") && this.el.tabIndex >= 0;
42299
+ this.el.dataset.zxFocus = reachable ? "region" : "container";
42300
+ }
42009
42301
  /**
42010
42302
  * Opens and positions the panel.
42011
42303
  * @returns {this}
@@ -42015,6 +42307,7 @@ ${this._sendLabel}`;
42015
42307
  if (this.isOpen() || this.#destroyed) return this;
42016
42308
  const host = this.#host();
42017
42309
  if (this.el.parentElement !== host) host.append(this.el);
42310
+ this.#syncFocusMarker();
42018
42311
  this.#position = position(this.#anchor, this.el, {
42019
42312
  placement: this.options.placement,
42020
42313
  offset: Number(this.options.offset),
@@ -45628,6 +45921,7 @@ ${this._sendLabel}`;
45628
45921
  }
45629
45922
  if (!root.hasAttribute("tabindex")) {
45630
45923
  root.tabIndex = -1;
45924
+ root.dataset.zxFocus = "container";
45631
45925
  this._heldFocus = true;
45632
45926
  }
45633
45927
  root.focus({ preventScroll: true });
@@ -45637,6 +45931,7 @@ ${this._sendLabel}`;
45637
45931
  if (!this._heldFocus) return;
45638
45932
  this._heldFocus = false;
45639
45933
  this.el.removeAttribute("tabindex");
45934
+ this.el.removeAttribute("data-zx-focus");
45640
45935
  }
45641
45936
  /**
45642
45937
  * The agent's face with the run's expression: the one drawn before, while the traits it asks for
@@ -49397,7 +49692,7 @@ ${this._sendLabel}`;
49397
49692
  if (onclick !== void 0 && typeof onclick !== "function") {
49398
49693
  throw new TypeError("Card action onclick must be a function");
49399
49694
  }
49400
- if (onclick) control.addEventListener("click", onclick, { signal: nextAbort.signal });
49695
+ if (onclick) this.listen(control, "click", onclick, { signal: nextAbort.signal });
49401
49696
  return control;
49402
49697
  });
49403
49698
  } catch (error2) {
@@ -49445,7 +49740,7 @@ ${this._sendLabel}`;
49445
49740
  target: this._link.target,
49446
49741
  rel: this._link.rel
49447
49742
  }, title) : h("span", { class: "zx-card__title" }, title);
49448
- if (this._link?.onclick) node.addEventListener("click", this._link.onclick, { signal: nextAbort.signal });
49743
+ if (this._link?.onclick) this.listen(node, "click", this._link.onclick, { signal: nextAbort.signal });
49449
49744
  this._linkAbort?.abort();
49450
49745
  this._linkAbort = nextAbort;
49451
49746
  this.refs.heading.replaceChildren(node);
@@ -50029,7 +50324,8 @@ ${this._sendLabel}`;
50029
50324
  );
50030
50325
  const content = h("div", {
50031
50326
  class: "zx-master-panel__content",
50032
- ref: "content"
50327
+ ref: "content",
50328
+ dataset: { zxFocus: "region" }
50033
50329
  });
50034
50330
  const footer = h("footer", {
50035
50331
  class: "zx-master-panel__footer",
@@ -51034,7 +51330,7 @@ ${this._sendLabel}`;
51034
51330
  }, chevron, hasTabs ? null : h("span", { class: "zx-dock__title" }, title));
51035
51331
  if (!collapsible) toggle.disabled = true;
51036
51332
  const header = h("div", { class: "zx-dock__header" }, toggle);
51037
- const body = h("div", { class: "zx-dock__body", id: bodyId });
51333
+ const body = h("div", { class: "zx-dock__body", id: bodyId, dataset: { zxFocus: "region" } });
51038
51334
  const element = h("section", {
51039
51335
  class: "zx-dock__pane",
51040
51336
  dataset: { name: name2, state: "open" }
@@ -51085,8 +51381,8 @@ ${this._sendLabel}`;
51085
51381
  role: "tabpanel",
51086
51382
  id: panelId,
51087
51383
  ariaLabelledby: tabId,
51088
- tabindex: 0,
51089
- hidden: true
51384
+ hidden: true,
51385
+ dataset: { zxFocus: "region" }
51090
51386
  });
51091
51387
  list.append(tab);
51092
51388
  body.append(panel);
@@ -51094,6 +51390,15 @@ ${this._sendLabel}`;
51094
51390
  }
51095
51391
  header.append(list);
51096
51392
  record.roving = rovingTabindex(list, ".zx-dock__tab", { orientation: "horizontal" });
51393
+ this.listen(list, "keydown", (event) => {
51394
+ const key = (
51395
+ /** @type {KeyboardEvent} */
51396
+ event
51397
+ );
51398
+ if (key.key !== "Tab" || key.shiftKey) return;
51399
+ const active = record.tabs.get(record.active);
51400
+ if (active) syncPanelStop(active.panel);
51401
+ });
51097
51402
  this.listen(list, "click", (event) => {
51098
51403
  const button2 = (
51099
51404
  /** @type {Element} */
@@ -51128,7 +51433,8 @@ ${this._sendLabel}`;
51128
51433
  return record;
51129
51434
  }
51130
51435
  /**
51131
- * Runs any not-yet-run content factory for whatever the pane currently shows.
51436
+ * Runs any not-yet-run content factory for whatever the pane currently shows, and settles
51437
+ * whether a shown tab panel is a Tab stop itself.
51132
51438
  * @param {Record<string, any>} record Pane record.
51133
51439
  * @returns {void}
51134
51440
  */
@@ -51136,9 +51442,12 @@ ${this._sendLabel}`;
51136
51442
  if (record.collapsed) return;
51137
51443
  if (record.tabs) {
51138
51444
  const active = record.tabs.get(record.active);
51139
- if (!active || active.built) return;
51140
- active.built = true;
51141
- appendContent3(active.panel, active.content, true);
51445
+ if (!active) return;
51446
+ if (!active.built) {
51447
+ active.built = true;
51448
+ appendContent3(active.panel, active.content, true);
51449
+ }
51450
+ syncPanelStop(active.panel);
51142
51451
  return;
51143
51452
  }
51144
51453
  if (record.built) return;
@@ -51754,9 +52063,9 @@ ${this._sendLabel}`;
51754
52063
  class: "zx-navigation-bar__panel",
51755
52064
  id: panelId,
51756
52065
  role: "tabpanel",
51757
- tabindex: "0",
51758
52066
  ariaLabelledby: tabId,
51759
- hidden: true
52067
+ hidden: true,
52068
+ dataset: { zxFocus: "region" }
51760
52069
  });
51761
52070
  this.refs.panels.append(panel);
51762
52071
  }
@@ -51781,6 +52090,7 @@ ${this._sendLabel}`;
51781
52090
  item.item.setAttribute("aria-selected", String(active));
51782
52091
  item.item.tabIndex = active ? 0 : -1;
51783
52092
  if (item.panel) item.panel.hidden = !active;
52093
+ if (active && item.panel) syncPanelStop(item.panel);
51784
52094
  } else if (active) {
51785
52095
  item.item.setAttribute("aria-current", "page");
51786
52096
  } else {
@@ -51808,6 +52118,11 @@ ${this._sendLabel}`;
51808
52118
  if (!item || !this.refs.items.contains(item)) return;
51809
52119
  const current = this._items.find((record) => record.item === item);
51810
52120
  if (!current) return;
52121
+ if (event.key === "Tab" && !event.shiftKey) {
52122
+ const active = this._activeName === null ? null : this._find(this._activeName);
52123
+ if (active?.panel) syncPanelStop(active.panel);
52124
+ return;
52125
+ }
51811
52126
  const enabled = this._enabledItems();
51812
52127
  if (event.key === "ArrowLeft" || event.key === "ArrowRight") {
51813
52128
  event.preventDefault();
@@ -58924,8 +59239,10 @@ ${delta}` : delta);
58924
59239
  this._layout();
58925
59240
  }
58926
59241
  /**
58927
- * Shows the tiles that fit, in bar order, and moves the rest behind "All modules". Everything is
58928
- * shown first so a bar sized by its content measures as not overflowing and never shrinks itself.
59242
+ * Shows the tiles that fit, in bar order, and moves the rest behind "All modules". Every module
59243
+ * the bar could place is shown first, so a bar sized by its content measures as not overflowing
59244
+ * and never shrinks itself; a module that can only ever be in the catalogue is not, so it takes
59245
+ * no room.
58929
59246
  * @returns {void}
58930
59247
  */
58931
59248
  _layout() {
@@ -58935,14 +59252,16 @@ ${delta}` : delta);
58935
59252
  const moreRow = list.querySelector(":scope > [data-module-bar-more]");
58936
59253
  const mode = this.el.dataset.allModules;
58937
59254
  const keep = [moduleOf(this._items, this._active)?.id, this._expandedId, this._promoted];
58938
- let capacity = Infinity;
59255
+ const reserve = mode === "always";
59256
+ let partition = partitionModules(this._items, Infinity, keep, reserve);
58939
59257
  if (mode !== "never" && list.isConnected) {
58940
- for (const row2 of rows) row2.hidden = false;
59258
+ const placeable = new Set(partition.visible.map((item) => String(item.id)));
59259
+ for (const row2 of rows) row2.hidden = !placeable.has(row2.dataset.moduleId);
58941
59260
  if (moreRow) moreRow.hidden = false;
58942
59261
  syncHeadings(list);
58943
- capacity = measureCapacity(list, this.el.dataset.orientation === "horizontal", rows.length + 1);
59262
+ const space = measureSpace(list, this.el.dataset.orientation === "horizontal");
59263
+ if (space) partition = fitModules(this._items, space, keep, reserve);
58944
59264
  }
58945
- const partition = partitionModules(this._items, capacity, keep, mode === "always");
58946
59265
  const visible = new Set(partition.visible.map((item) => String(item.id)));
58947
59266
  for (const row2 of rows) row2.hidden = !visible.has(row2.dataset.moduleId);
58948
59267
  syncHeadings(list);
@@ -59406,6 +59725,40 @@ ${delta}` : delta);
59406
59725
  const overflow = list.filter((item) => !visible.includes(item));
59407
59726
  return { visible, overflow, more: overflow.length > 0 };
59408
59727
  }
59728
+ function fitModules(items, space, keep = [], reserve = false) {
59729
+ const fits2 = (partition) => barExtent(space, partition.visible, reserve || partition.more) <= space.room + 0.5;
59730
+ const all = partitionModules(items, Infinity, keep, reserve);
59731
+ if (fits2(all)) return all;
59732
+ let low = 1;
59733
+ let high = all.visible.length;
59734
+ while (low < high) {
59735
+ const middle = Math.ceil((low + high) / 2);
59736
+ if (fits2(partitionModules(items, middle, keep, true))) low = middle;
59737
+ else high = middle - 1;
59738
+ }
59739
+ return partitionModules(items, low, keep, true);
59740
+ }
59741
+ function barExtent(space, visible, more) {
59742
+ const shown = new Set(visible.map((item) => String(item.id)));
59743
+ let total = 0;
59744
+ let count2 = 0;
59745
+ let heading = null;
59746
+ for (const entry of space.entries ?? []) {
59747
+ if (entry.heading) {
59748
+ heading = entry;
59749
+ continue;
59750
+ }
59751
+ if (entry.more ? !more : !shown.has(String(entry.id))) continue;
59752
+ if (heading && !entry.more) {
59753
+ total += heading.size;
59754
+ count2 += 1;
59755
+ }
59756
+ heading = null;
59757
+ total += entry.size;
59758
+ count2 += 1;
59759
+ }
59760
+ return total + Math.max(0, count2 - 1) * (space.gap ?? 0);
59761
+ }
59409
59762
  function resolveModuleColor(item) {
59410
59763
  const color = isCssColor(item?.color) ? String(item.color).trim() : null;
59411
59764
  if (color) return { tone: null, color };
@@ -59463,26 +59816,32 @@ ${delta}` : delta);
59463
59816
  const rank = (item) => typeof item.pinned === "number" && Number.isFinite(item.pinned) ? item.pinned : item.pinned === true ? Number.MAX_SAFE_INTEGER - 1 : Number.MAX_SAFE_INTEGER;
59464
59817
  return items.map((item, index) => ({ item, index })).sort((first, second) => rank(first.item) - rank(second.item) || first.index - second.index).map(({ item }) => item);
59465
59818
  }
59466
- function measureCapacity(list, horizontal, count2) {
59819
+ function measureSpace(list, horizontal) {
59467
59820
  const overflowing = horizontal ? list.scrollWidth > list.clientWidth + 1 : list.scrollHeight > list.clientHeight + 1;
59468
- if (!overflowing) return Infinity;
59469
- const rows = (
59470
- /** @type {HTMLElement[]} */
59471
- [...list.querySelectorAll(":scope > li:not([hidden]):not(.zx-module-bar__heading)")]
59472
- );
59473
- if (!rows.length) return Infinity;
59474
- const headings = (
59475
- /** @type {HTMLElement[]} */
59476
- [...list.querySelectorAll(":scope > li.zx-module-bar__heading:not([hidden])")]
59477
- );
59821
+ if (!overflowing) return null;
59822
+ const axis = horizontal ? "Inline" : "Block";
59823
+ const edges = (style2, prefix, suffix = "") => (Number.parseFloat(style2[`${prefix}${axis}Start${suffix}`]) || 0) + (Number.parseFloat(style2[`${prefix}${axis}End${suffix}`]) || 0);
59824
+ const drawn = (element) => element.getBoundingClientRect()[horizontal ? "width" : "height"];
59825
+ const laid = horizontal ? list.offsetWidth : list.offsetHeight;
59826
+ const scale = laid > 0 && drawn(list) > 0 ? drawn(list) / laid : 1;
59478
59827
  const style = getComputedStyle(list);
59828
+ const room = laid - edges(style, "padding") - edges(style, "border", "Width");
59479
59829
  const gap = Number.parseFloat(horizontal ? style.columnGap : style.rowGap) || 0;
59480
- const padding = horizontal ? (Number.parseFloat(style.paddingInlineStart) || 0) + (Number.parseFloat(style.paddingInlineEnd) || 0) : (Number.parseFloat(style.paddingBlockStart) || 0) + (Number.parseFloat(style.paddingBlockEnd) || 0);
59481
- const size2 = Math.max(...rows.map((row2) => horizontal ? row2.offsetWidth : row2.offsetHeight));
59482
- const headingSpace = headings.reduce((sum, heading) => sum + gap + (horizontal ? heading.offsetWidth : heading.offsetHeight) + (Number.parseFloat(horizontal ? getComputedStyle(heading).marginInlineStart : getComputedStyle(heading).marginBlockStart) || 0) + (Number.parseFloat(horizontal ? getComputedStyle(heading).marginInlineEnd : getComputedStyle(heading).marginBlockEnd) || 0), 0);
59483
- const available = (horizontal ? list.clientWidth : list.clientHeight) - padding - headingSpace;
59484
- if (size2 <= 0 || available <= 0) return count2;
59485
- return Math.max(1, Math.floor((available + gap) / (size2 + gap)));
59830
+ const entries = [];
59831
+ for (
59832
+ const child of
59833
+ /** @type {HTMLElement[]} */
59834
+ [...list.children]
59835
+ ) {
59836
+ const childStyle = getComputedStyle(child);
59837
+ if (child.hidden || childStyle.display === "none") continue;
59838
+ const size2 = drawn(child) / scale + edges(childStyle, "margin");
59839
+ if (child.classList.contains("zx-module-bar__heading")) entries.push({ heading: true, size: size2 });
59840
+ else if (child.hasAttribute("data-module-bar-more")) entries.push({ more: true, size: size2 });
59841
+ else if (child.dataset.moduleId != null) entries.push({ id: child.dataset.moduleId, size: size2 });
59842
+ }
59843
+ if (room <= 0 || !entries.some((entry) => entry.id != null && entry.size > 0)) return null;
59844
+ return { room, gap, entries };
59486
59845
  }
59487
59846
  function nearestInRow(entries, current, direction) {
59488
59847
  const origin = current.getBoundingClientRect();
@@ -60384,7 +60743,7 @@ ${delta}` : delta);
60384
60743
  }
60385
60744
  /** @param {EventTarget} target @param {string} type @param {EventListener} listener @returns {void} */
60386
60745
  _listenMode(target, type, listener) {
60387
- target.addEventListener(type, listener, { signal: this._modeAbort.signal });
60746
+ this.listen(target, type, listener, { signal: this._modeAbort.signal });
60388
60747
  }
60389
60748
  /** @returns {void} */
60390
60749
  _renderTree() {
@@ -65365,7 +65724,6 @@ ${delta}` : delta);
65365
65724
  this._restored = false;
65366
65725
  this._entries = [];
65367
65726
  this._children = [];
65368
- this._writing = false;
65369
65727
  this._draft = {};
65370
65728
  this._applied = {};
65371
65729
  this._appliedDraft = "";
@@ -65568,7 +65926,8 @@ ${delta}` : delta);
65568
65926
  this._children.push(checklist);
65569
65927
  this._entries.push({ key, write: (value) => checklist.setValues(
65570
65928
  /** @type {unknown[]} */
65571
- value ?? []
65929
+ value ?? [],
65930
+ { silent: true }
65572
65931
  ) });
65573
65932
  return checklist.toElement();
65574
65933
  }
@@ -65796,7 +66155,6 @@ ${delta}` : delta);
65796
66155
  }
65797
66156
  /** @param {string} key Field key. @param {unknown} value Raw draft value. @returns {void} */
65798
66157
  _edited(key, value) {
65799
- if (this._writing) return;
65800
66158
  this._draft[key] = value;
65801
66159
  this._afterEdit(key);
65802
66160
  }
@@ -65807,7 +66165,6 @@ ${delta}` : delta);
65807
66165
  * @returns {void}
65808
66166
  */
65809
66167
  _editedEdge(key, edge, value) {
65810
- if (this._writing) return;
65811
66168
  const current = this._draft[key];
65812
66169
  const range = current !== null && typeof current === "object" && !Array.isArray(current) ? { .../** @type {Record<string, unknown>} */
65813
66170
  current } : {};
@@ -65860,14 +66217,14 @@ ${delta}` : delta);
65860
66217
  _draftValue() {
65861
66218
  return serializeFilterValue(this._draft, this.options.fields, this.options.serialize, this._timeZone);
65862
66219
  }
65863
- /** Pushes the draft back into the controls without re-entering the edit path. @returns {void} */
66220
+ /**
66221
+ * Pushes the draft back into the controls without re-entering the edit path: every entry writes
66222
+ * silently (a plain input's `value`, `{silent: true}` to the composed controls), so none of them
66223
+ * reports the write back as an edit.
66224
+ * @returns {void}
66225
+ */
65864
66226
  _writeControls() {
65865
- this._writing = true;
65866
- try {
65867
- for (const entry of this._entries) entry.write(this._draft[entry.key]);
65868
- } finally {
65869
- this._writing = false;
65870
- }
66227
+ for (const entry of this._entries) entry.write(this._draft[entry.key]);
65871
66228
  }
65872
66229
  /** @param {Record<string, unknown>} [value] The draft value, when it is already at hand. @returns {void} */
65873
66230
  _syncActions(value = this._draftValue()) {
@@ -67312,7 +67669,7 @@ ${delta}` : delta);
67312
67669
  this.unbind();
67313
67670
  const controller = new AbortController();
67314
67671
  this._bound = { view: candidate, controller };
67315
- candidate.addEventListener("statechange", (event) => {
67672
+ this.listen(candidate, "statechange", (event) => {
67316
67673
  if (this._syncing) return;
67317
67674
  const reason = (
67318
67675
  /** @type {CustomEvent} */