@zeyos/zx 5.8.1 → 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 (68) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/dist/types/components/block-view/block-view.d.ts +3 -2
  3. package/dist/types/components/dock/dock.d.ts +2 -1
  4. package/dist/types/components/dropdown/dropdown.d.ts +2 -1
  5. package/dist/types/components/module-bar/module-bar.d.ts +53 -2
  6. package/dist/types/components/run-status/run-status.d.ts +1 -1
  7. package/dist/types/components/run-trace/run-trace.d.ts +8 -0
  8. package/dist/types/components/tabbox/tabbox.d.ts +7 -0
  9. package/dist/types/internal/focus-stops.d.ts +42 -0
  10. package/dist/zx-zeyos.esm.js +87 -25
  11. package/dist/zx-zeyos.esm.min.js +4 -4
  12. package/dist/zx.core.css +9 -2
  13. package/dist/zx.core.min.css +1 -1
  14. package/dist/zx.css +22 -84
  15. package/dist/zx.esm.js +258 -51
  16. package/dist/zx.esm.min.js +26 -26
  17. package/dist/zx.global.js +258 -51
  18. package/dist/zx.global.min.js +26 -26
  19. package/dist/zx.layered.css +22 -84
  20. package/dist/zx.layered.min.css +1 -1
  21. package/dist/zx.min.css +1 -1
  22. package/docs/components/approval-card.md +2 -2
  23. package/docs/components/block-view.md +2 -1
  24. package/docs/components/composer.md +4 -0
  25. package/docs/components/dock.md +4 -1
  26. package/docs/components/dropdown.md +3 -1
  27. package/docs/components/modal.md +3 -0
  28. package/docs/components/navigation-bar.md +5 -0
  29. package/docs/components/questionnaire.md +2 -2
  30. package/docs/components/run-status.md +2 -1
  31. package/docs/components/run-trace.md +2 -1
  32. package/docs/components/tabbox.md +6 -0
  33. package/docs/components/tokens.md +20 -0
  34. package/docs/llms.md +57 -9
  35. package/package.json +1 -1
  36. package/src/components/approval-card/approval-card.css +0 -5
  37. package/src/components/approval-card/approval-card.js +2 -0
  38. package/src/components/block-view/block-view.css +0 -10
  39. package/src/components/block-view/block-view.js +11 -6
  40. package/src/components/card/card.css +3 -0
  41. package/src/components/card-view/card-view.css +5 -5
  42. package/src/components/card-view/card-view.js +3 -1
  43. package/src/components/composer/composer.css +15 -26
  44. package/src/components/copy/copy-input.css +3 -1
  45. package/src/components/dialog/dialog.js +2 -1
  46. package/src/components/dock/dock.css +0 -6
  47. package/src/components/dock/dock.js +22 -7
  48. package/src/components/dropdown/dropdown.js +17 -2
  49. package/src/components/field/field.js +2 -1
  50. package/src/components/master-panel/master-panel.js +3 -1
  51. package/src/components/modal/modal.css +2 -11
  52. package/src/components/modal/modal.js +5 -2
  53. package/src/components/module-bar/module-bar.js +110 -26
  54. package/src/components/navigation-bar/navigation-bar.css +0 -4
  55. package/src/components/navigation-bar/navigation-bar.js +11 -2
  56. package/src/components/questionnaire/questionnaire.css +0 -14
  57. package/src/components/questionnaire/questionnaire.js +4 -2
  58. package/src/components/run-status/run-status.css +0 -7
  59. package/src/components/run-status/run-status.js +3 -1
  60. package/src/components/run-trace/run-trace.css +0 -5
  61. package/src/components/run-trace/run-trace.js +23 -2
  62. package/src/components/surface/surface.css +0 -6
  63. package/src/components/surface/surface.js +1 -1
  64. package/src/components/tabbox/tabbox.css +0 -6
  65. package/src/components/tabbox/tabbox.js +20 -2
  66. package/src/components/table/table.js +5 -0
  67. package/src/internal/focus-stops.js +108 -0
  68. package/styles/base.css +27 -3
package/dist/zx.global.js CHANGED
@@ -2651,7 +2651,7 @@ var zx = (() => {
2651
2651
  );
2652
2652
  }
2653
2653
  function errorAdapter(message4, id) {
2654
- 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);
2655
2655
  return {
2656
2656
  el,
2657
2657
  get: () => null,
@@ -14594,7 +14594,9 @@ var zx = (() => {
14594
14594
  const dialog = (
14595
14595
  /** @type {HTMLDialogElement} */
14596
14596
  h("dialog", {
14597
- 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" }
14598
14600
  }, h("div", { class: "zx-modal__content", ref: "content" }))
14599
14601
  );
14600
14602
  dialog.dataset.state = "closed";
@@ -14985,7 +14987,8 @@ var zx = (() => {
14985
14987
  "dialog",
14986
14988
  {
14987
14989
  class: "zx-modal zx-dialog",
14988
- ariaLabelledby: titleId
14990
+ ariaLabelledby: titleId,
14991
+ dataset: { zxFocus: "container" }
14989
14992
  },
14990
14993
  h(
14991
14994
  "header",
@@ -15687,6 +15690,78 @@ var zx = (() => {
15687
15690
  }
15688
15691
  };
15689
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
+
15690
15765
  // src/components/tabbox/tabbox.js
15691
15766
  var VARIANTS2 = /* @__PURE__ */ new Set(["divided", "bracket", "line", "segmented"]);
15692
15767
  var Tabbox = class extends Component {
@@ -15824,9 +15899,9 @@ var zx = (() => {
15824
15899
  class: "zx-tabbox__panel",
15825
15900
  id: panelId,
15826
15901
  role: "tabpanel",
15827
- tabindex: "0",
15828
15902
  ariaLabelledby: tabId,
15829
- hidden: true
15903
+ hidden: true,
15904
+ dataset: { zxFocus: "region" }
15830
15905
  });
15831
15906
  const record = { definition: normalized, tab, title, badge: badge2, panel, built: false };
15832
15907
  const numericIndex = Number.isFinite(insert.index) ? Math.trunc(insert.index) : this._tabs.length;
@@ -15961,6 +16036,10 @@ var zx = (() => {
15961
16036
  if (!tab || !this.refs.tablist.contains(tab)) return;
15962
16037
  const current = this._recordForTab(tab);
15963
16038
  if (!current) return;
16039
+ if (event.key === "Tab" && !event.shiftKey) {
16040
+ this._syncPanelStop();
16041
+ return;
16042
+ }
15964
16043
  const enabled = this._enabledTabs();
15965
16044
  if (event.key === "ArrowLeft" || event.key === "ArrowRight") {
15966
16045
  event.preventDefault();
@@ -16042,8 +16121,18 @@ var zx = (() => {
16042
16121
  record.tab.setAttribute("aria-selected", "true");
16043
16122
  record.panel.hidden = false;
16044
16123
  if (record.panel.parentNode !== this.refs.panels) this.refs.panels.append(record.panel);
16124
+ this._syncPanelStop();
16045
16125
  this._setFocused(record, false);
16046
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
+ }
16047
16136
  /** @param {TabRecord} record @returns {void} */
16048
16137
  _ensureContent(record) {
16049
16138
  if (record.built) return;
@@ -16535,6 +16624,9 @@ var zx = (() => {
16535
16624
  this._scroll = h("div", {
16536
16625
  class: "zx-table__scroll",
16537
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",
16538
16630
  stickyHeader: String(Boolean(this.options.stickyHeader)),
16539
16631
  // Stripes follow the row's place in the data while windowed: `:nth-child` would count the
16540
16632
  // spacers, and the stripes would swap as the window moved.
@@ -18886,11 +18978,13 @@ var zx = (() => {
18886
18978
  if (!frame.hasAttribute("tabindex")) {
18887
18979
  frame.tabIndex = -1;
18888
18980
  frame.setAttribute("data-empty-focus", "");
18981
+ frame.dataset.zxFocus = "container";
18889
18982
  }
18890
18983
  frame.focus({ preventScroll: true });
18891
18984
  } else if (frame.hasAttribute("data-empty-focus")) {
18892
18985
  frame.removeAttribute("tabindex");
18893
18986
  frame.removeAttribute("data-empty-focus");
18987
+ frame.dataset.zxFocus = "region";
18894
18988
  }
18895
18989
  }
18896
18990
  /** @param {Event} event @returns {void} */
@@ -21692,7 +21786,7 @@ ${block.code}
21692
21786
  this._nodes.push(node);
21693
21787
  if (this._stoppedNote) this._stoppedNote.before(node);
21694
21788
  else this.el.append(node);
21695
- if (copy.type === "table") this._syncScrollers();
21789
+ if (copy.type === "table" || copy.type === "code") this._syncScrollers();
21696
21790
  }
21697
21791
  /** @private @returns {void} */
21698
21792
  _redrawLast() {
@@ -21736,12 +21830,20 @@ ${block.code}
21736
21830
  else root.removeAttribute("aria-busy");
21737
21831
  }
21738
21832
  /**
21739
- * A wide table scrolls inside the answer; while it does, its wrapper is a named, focusable
21740
- * 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.
21741
21836
  * @private
21742
21837
  * @returns {void}
21743
21838
  */
21744
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
+ }
21745
21847
  for (
21746
21848
  const wrap of
21747
21849
  /** @type {NodeListOf<HTMLElement>} */
@@ -21875,14 +21977,14 @@ ${block.code}
21875
21977
  h("span", { class: "zx-block-view__code-language" }, language2 || msg("blockView.code")),
21876
21978
  copyButton({ text: String(block.code ?? ""), title: msg("blockView.copyCode"), size: "sm" })
21877
21979
  ),
21878
- 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(
21879
21981
  "code",
21880
21982
  {},
21881
21983
  String(block.code ?? "").split("\n").map((line) => h("span", {
21882
21984
  class: "zx-block-view__line",
21883
21985
  style: { "--zx-block-view-indent": `${/^\s*/.exec(line)?.[0].length ?? 0}ch` }
21884
21986
  }, codeSegments(language2, line)))
21885
- )) : 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)))
21886
21988
  );
21887
21989
  }
21888
21990
  function codeSegments(language2, code) {
@@ -21895,7 +21997,7 @@ ${block.code}
21895
21997
  const value = block.align?.[index];
21896
21998
  return value === "end" || value === "center" ? value : null;
21897
21999
  };
21898
- return h("div", { class: "zx-block-view__table" }, h(
22000
+ return h("div", { class: "zx-block-view__table", dataset: { zxFocus: "region" } }, h(
21899
22001
  "table",
21900
22002
  {},
21901
22003
  h("thead", {}, h("tr", {}, columns.map((column, index) => h(
@@ -22584,6 +22686,7 @@ ${block.code}
22584
22686
  root.setAttribute("role", "group");
22585
22687
  root.setAttribute("aria-labelledby", titleId);
22586
22688
  root.tabIndex = -1;
22689
+ root.dataset.zxFocus = "container";
22587
22690
  this._titleEl = h(`h${level}`, { class: "zx-approval-card__title", id: titleId }, this._title);
22588
22691
  this._noteEl = h("p", { class: "zx-approval-card__note", id: uid("zx-approval-card-note") });
22589
22692
  this._statusEl = h("span", { class: "zx-approval-card__status" });
@@ -23809,6 +23912,8 @@ ${block.code}
23809
23912
  }
23810
23913
  });
23811
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);
23812
23917
  this._build(this.options.steps);
23813
23918
  return root;
23814
23919
  }
@@ -23931,6 +24036,8 @@ ${block.code}
23931
24036
  this._revealTimer = null;
23932
24037
  if (this._clock) clearInterval(this._clock);
23933
24038
  this._clock = null;
24039
+ this._resize?.disconnect();
24040
+ this._resize = null;
23934
24041
  for (const entry of this._entries.values()) this._releaseAvatars(entry);
23935
24042
  this._entries.clear();
23936
24043
  super.destroy();
@@ -24076,6 +24183,7 @@ ${block.code}
24076
24183
  entry.row = row2;
24077
24184
  entry.refs = refs;
24078
24185
  entry.body = body;
24186
+ if (body) this._syncCodeStops(body);
24079
24187
  const again = focusedRef === null ? null : (
24080
24188
  /** @type {HTMLElement|null} */
24081
24189
  refs?.querySelector(`[data-ref-index="${focusedRef}"]`) ?? null
@@ -24233,11 +24341,11 @@ ${block.code}
24233
24341
  h("span", { class: "zx-run-trace__section-title", id: titleId }, this.msg(keys.title)),
24234
24342
  copyButton({ text: full, title: this.msg(keys.copy), feedback: this.msg("runTrace.copied"), size: "sm" })
24235
24343
  ),
24344
+ // A Tab stop only while its text scrolls (`_syncCodeStops()`).
24236
24345
  h("pre", {
24237
24346
  class: "zx-run-trace__code",
24238
- tabindex: "0",
24239
24347
  "aria-labelledby": titleId,
24240
- dataset: { tone: kind === "error" ? "danger" : null }
24348
+ dataset: { tone: kind === "error" ? "danger" : null, zxFocus: "region" }
24241
24349
  }, shown.text),
24242
24350
  shown.cut ? h("button", {
24243
24351
  type: "button",
@@ -24257,6 +24365,7 @@ ${block.code}
24257
24365
  this._open = open;
24258
24366
  this._summary.setAttribute("aria-expanded", String(open));
24259
24367
  this._list.hidden = !open;
24368
+ if (open) this._syncCodeStops(this._list);
24260
24369
  this._syncClock();
24261
24370
  this.emit("toggle", { id: null, open });
24262
24371
  }
@@ -24273,8 +24382,24 @@ ${block.code}
24273
24382
  else this._expanded.delete(id);
24274
24383
  entry.row.setAttribute("aria-expanded", String(open));
24275
24384
  entry.body.hidden = !open;
24385
+ if (open) this._syncCodeStops(entry.body);
24276
24386
  this.emit("toggle", { id, open });
24277
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
+ }
24278
24403
  /**
24279
24404
  * Redraws the summary from the steps.
24280
24405
  * @private
@@ -28217,9 +28342,10 @@ ${block.code}
28217
28342
  this._progressHost = h("div", { class: "zx-questionnaire__progress", hidden: !this.options.progress });
28218
28343
  this._itemHost = h("fieldset", {
28219
28344
  class: "zx-questionnaire__item",
28220
- tabIndex: -1
28345
+ tabIndex: -1,
28346
+ dataset: { zxFocus: "container" }
28221
28347
  });
28222
- 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" } });
28223
28349
  this._actionsHost = h("div", { class: "zx-questionnaire__actions" });
28224
28350
  this.refs.item = this._itemHost;
28225
28351
  this.refs.review = this._reviewHost;
@@ -35082,7 +35208,7 @@ ${block.code}
35082
35208
  const verdict = verdictText(reply.action, this._model.actions ?? [], (key, ...args) => this.msg(key, ...args));
35083
35209
  this._verdict = h(
35084
35210
  "p",
35085
- { class: "zx-surface__verdict", tabIndex: -1, dataset: { action: reply.action } },
35211
+ { class: "zx-surface__verdict", tabIndex: -1, dataset: { action: reply.action, zxFocus: "container" } },
35086
35212
  h(
35087
35213
  "span",
35088
35214
  { class: "zx-surface__verdict-icon", "aria-hidden": "true" },
@@ -38780,11 +38906,13 @@ ${block.code}
38780
38906
  if (!content.hasAttribute("tabindex")) {
38781
38907
  content.tabIndex = -1;
38782
38908
  content.setAttribute("data-empty-focus", "");
38909
+ content.setAttribute("data-zx-focus", "container");
38783
38910
  }
38784
38911
  content.focus({ preventScroll: true });
38785
38912
  } else if (content.hasAttribute("data-empty-focus")) {
38786
38913
  content.removeAttribute("tabindex");
38787
38914
  content.removeAttribute("data-empty-focus");
38915
+ content.removeAttribute("data-zx-focus");
38788
38916
  }
38789
38917
  }
38790
38918
  /** @private @returns {HTMLElement[]} Roving items in display order. */
@@ -38924,7 +39052,7 @@ ${block.code}
38924
39052
  for (let index = 0; index < this._cardLoadingCount; index += 1) {
38925
39053
  list.append(h(
38926
39054
  "li",
38927
- { class: "zx-record-card zx-card-view__skeleton", tabindex: -1 },
39055
+ { class: "zx-record-card zx-card-view__skeleton", tabindex: -1, dataset: { zxFocus: "container" } },
38928
39056
  h("span", { class: "zx-card-view__skeleton-preview zx-skeleton" }),
38929
39057
  h("span", { class: "zx-card-view__skeleton-line zx-skeleton" }),
38930
39058
  h("span", { class: "zx-card-view__skeleton-line zx-skeleton" }),
@@ -42153,11 +42281,23 @@ ${this._sendLabel}`;
42153
42281
  render() {
42154
42282
  const panel = h("div", {
42155
42283
  id: uid("zx-dropdown"),
42156
- 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" }
42157
42287
  });
42158
42288
  panel.dataset.state = "closed";
42159
42289
  return panel;
42160
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
+ }
42161
42301
  /**
42162
42302
  * Opens and positions the panel.
42163
42303
  * @returns {this}
@@ -42167,6 +42307,7 @@ ${this._sendLabel}`;
42167
42307
  if (this.isOpen() || this.#destroyed) return this;
42168
42308
  const host = this.#host();
42169
42309
  if (this.el.parentElement !== host) host.append(this.el);
42310
+ this.#syncFocusMarker();
42170
42311
  this.#position = position(this.#anchor, this.el, {
42171
42312
  placement: this.options.placement,
42172
42313
  offset: Number(this.options.offset),
@@ -45780,6 +45921,7 @@ ${this._sendLabel}`;
45780
45921
  }
45781
45922
  if (!root.hasAttribute("tabindex")) {
45782
45923
  root.tabIndex = -1;
45924
+ root.dataset.zxFocus = "container";
45783
45925
  this._heldFocus = true;
45784
45926
  }
45785
45927
  root.focus({ preventScroll: true });
@@ -45789,6 +45931,7 @@ ${this._sendLabel}`;
45789
45931
  if (!this._heldFocus) return;
45790
45932
  this._heldFocus = false;
45791
45933
  this.el.removeAttribute("tabindex");
45934
+ this.el.removeAttribute("data-zx-focus");
45792
45935
  }
45793
45936
  /**
45794
45937
  * The agent's face with the run's expression: the one drawn before, while the traits it asks for
@@ -50181,7 +50324,8 @@ ${this._sendLabel}`;
50181
50324
  );
50182
50325
  const content = h("div", {
50183
50326
  class: "zx-master-panel__content",
50184
- ref: "content"
50327
+ ref: "content",
50328
+ dataset: { zxFocus: "region" }
50185
50329
  });
50186
50330
  const footer = h("footer", {
50187
50331
  class: "zx-master-panel__footer",
@@ -51186,7 +51330,7 @@ ${this._sendLabel}`;
51186
51330
  }, chevron, hasTabs ? null : h("span", { class: "zx-dock__title" }, title));
51187
51331
  if (!collapsible) toggle.disabled = true;
51188
51332
  const header = h("div", { class: "zx-dock__header" }, toggle);
51189
- const body = h("div", { class: "zx-dock__body", id: bodyId });
51333
+ const body = h("div", { class: "zx-dock__body", id: bodyId, dataset: { zxFocus: "region" } });
51190
51334
  const element = h("section", {
51191
51335
  class: "zx-dock__pane",
51192
51336
  dataset: { name: name2, state: "open" }
@@ -51237,8 +51381,8 @@ ${this._sendLabel}`;
51237
51381
  role: "tabpanel",
51238
51382
  id: panelId,
51239
51383
  ariaLabelledby: tabId,
51240
- tabindex: 0,
51241
- hidden: true
51384
+ hidden: true,
51385
+ dataset: { zxFocus: "region" }
51242
51386
  });
51243
51387
  list.append(tab);
51244
51388
  body.append(panel);
@@ -51246,6 +51390,15 @@ ${this._sendLabel}`;
51246
51390
  }
51247
51391
  header.append(list);
51248
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
+ });
51249
51402
  this.listen(list, "click", (event) => {
51250
51403
  const button2 = (
51251
51404
  /** @type {Element} */
@@ -51280,7 +51433,8 @@ ${this._sendLabel}`;
51280
51433
  return record;
51281
51434
  }
51282
51435
  /**
51283
- * 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.
51284
51438
  * @param {Record<string, any>} record Pane record.
51285
51439
  * @returns {void}
51286
51440
  */
@@ -51288,9 +51442,12 @@ ${this._sendLabel}`;
51288
51442
  if (record.collapsed) return;
51289
51443
  if (record.tabs) {
51290
51444
  const active = record.tabs.get(record.active);
51291
- if (!active || active.built) return;
51292
- active.built = true;
51293
- 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);
51294
51451
  return;
51295
51452
  }
51296
51453
  if (record.built) return;
@@ -51906,9 +52063,9 @@ ${this._sendLabel}`;
51906
52063
  class: "zx-navigation-bar__panel",
51907
52064
  id: panelId,
51908
52065
  role: "tabpanel",
51909
- tabindex: "0",
51910
52066
  ariaLabelledby: tabId,
51911
- hidden: true
52067
+ hidden: true,
52068
+ dataset: { zxFocus: "region" }
51912
52069
  });
51913
52070
  this.refs.panels.append(panel);
51914
52071
  }
@@ -51933,6 +52090,7 @@ ${this._sendLabel}`;
51933
52090
  item.item.setAttribute("aria-selected", String(active));
51934
52091
  item.item.tabIndex = active ? 0 : -1;
51935
52092
  if (item.panel) item.panel.hidden = !active;
52093
+ if (active && item.panel) syncPanelStop(item.panel);
51936
52094
  } else if (active) {
51937
52095
  item.item.setAttribute("aria-current", "page");
51938
52096
  } else {
@@ -51960,6 +52118,11 @@ ${this._sendLabel}`;
51960
52118
  if (!item || !this.refs.items.contains(item)) return;
51961
52119
  const current = this._items.find((record) => record.item === item);
51962
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
+ }
51963
52126
  const enabled = this._enabledItems();
51964
52127
  if (event.key === "ArrowLeft" || event.key === "ArrowRight") {
51965
52128
  event.preventDefault();
@@ -59076,8 +59239,10 @@ ${delta}` : delta);
59076
59239
  this._layout();
59077
59240
  }
59078
59241
  /**
59079
- * Shows the tiles that fit, in bar order, and moves the rest behind "All modules". Everything is
59080
- * 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.
59081
59246
  * @returns {void}
59082
59247
  */
59083
59248
  _layout() {
@@ -59087,14 +59252,16 @@ ${delta}` : delta);
59087
59252
  const moreRow = list.querySelector(":scope > [data-module-bar-more]");
59088
59253
  const mode = this.el.dataset.allModules;
59089
59254
  const keep = [moduleOf(this._items, this._active)?.id, this._expandedId, this._promoted];
59090
- let capacity = Infinity;
59255
+ const reserve = mode === "always";
59256
+ let partition = partitionModules(this._items, Infinity, keep, reserve);
59091
59257
  if (mode !== "never" && list.isConnected) {
59092
- 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);
59093
59260
  if (moreRow) moreRow.hidden = false;
59094
59261
  syncHeadings(list);
59095
- 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);
59096
59264
  }
59097
- const partition = partitionModules(this._items, capacity, keep, mode === "always");
59098
59265
  const visible = new Set(partition.visible.map((item) => String(item.id)));
59099
59266
  for (const row2 of rows) row2.hidden = !visible.has(row2.dataset.moduleId);
59100
59267
  syncHeadings(list);
@@ -59558,6 +59725,40 @@ ${delta}` : delta);
59558
59725
  const overflow = list.filter((item) => !visible.includes(item));
59559
59726
  return { visible, overflow, more: overflow.length > 0 };
59560
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
+ }
59561
59762
  function resolveModuleColor(item) {
59562
59763
  const color = isCssColor(item?.color) ? String(item.color).trim() : null;
59563
59764
  if (color) return { tone: null, color };
@@ -59615,26 +59816,32 @@ ${delta}` : delta);
59615
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;
59616
59817
  return items.map((item, index) => ({ item, index })).sort((first, second) => rank(first.item) - rank(second.item) || first.index - second.index).map(({ item }) => item);
59617
59818
  }
59618
- function measureCapacity(list, horizontal, count2) {
59819
+ function measureSpace(list, horizontal) {
59619
59820
  const overflowing = horizontal ? list.scrollWidth > list.clientWidth + 1 : list.scrollHeight > list.clientHeight + 1;
59620
- if (!overflowing) return Infinity;
59621
- const rows = (
59622
- /** @type {HTMLElement[]} */
59623
- [...list.querySelectorAll(":scope > li:not([hidden]):not(.zx-module-bar__heading)")]
59624
- );
59625
- if (!rows.length) return Infinity;
59626
- const headings = (
59627
- /** @type {HTMLElement[]} */
59628
- [...list.querySelectorAll(":scope > li.zx-module-bar__heading:not([hidden])")]
59629
- );
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;
59630
59827
  const style = getComputedStyle(list);
59828
+ const room = laid - edges(style, "padding") - edges(style, "border", "Width");
59631
59829
  const gap = Number.parseFloat(horizontal ? style.columnGap : style.rowGap) || 0;
59632
- const padding = horizontal ? (Number.parseFloat(style.paddingInlineStart) || 0) + (Number.parseFloat(style.paddingInlineEnd) || 0) : (Number.parseFloat(style.paddingBlockStart) || 0) + (Number.parseFloat(style.paddingBlockEnd) || 0);
59633
- const size2 = Math.max(...rows.map((row2) => horizontal ? row2.offsetWidth : row2.offsetHeight));
59634
- 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);
59635
- const available = (horizontal ? list.clientWidth : list.clientHeight) - padding - headingSpace;
59636
- if (size2 <= 0 || available <= 0) return count2;
59637
- 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 };
59638
59845
  }
59639
59846
  function nearestInRow(entries, current, direction) {
59640
59847
  const origin = current.getBoundingClientRect();