@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/CHANGELOG.md CHANGED
@@ -8,6 +8,52 @@ and friends remain the complete record.
8
8
 
9
9
  ## Unreleased
10
10
 
11
+ ## 5.9.0 — 2026-11-21
12
+
13
+ Focus rings that mark only the control you operate, tab panels that follow the APG tab sequence, a
14
+ Composer that rings its text field, and a ModuleBar that shows every pinned module that fits.
15
+
16
+ ### Added
17
+
18
+ - **`data-zx-focus` marks a focus target that is not a control.** `"container"` — focused only by a
19
+ script, with `tabindex="-1"` — draws no focus ring, in forced colours either; `"region"` — a Tab
20
+ stop such as a keyboard scroll region — draws the ring inside its edge, as an outline the
21
+ region's content cannot cover. Put it on an application's own view
22
+ roots, headings a route change focuses, and scroll regions.
23
+
24
+ ### Changed
25
+
26
+ - **The focus ring marks controls only.** Chrome shows keyboard focus on any focused element after
27
+ any key press, even Shift, so a click into a panel followed by a keystroke ringed the panel like a
28
+ field. The Modal, Dialog and Sheet panel, a Dropdown panel only a script focuses, the ApprovalCard
29
+ and RunStatus roots, Questionnaire's question and review, Surface's verdict and an emptied Table
30
+ or CardView body no longer draw one. Modal no longer rings its panel when it holds focus itself: it keeps its glass
31
+ elevation instead of an accent outline. Tab panels, code blocks, a Dropdown panel the application
32
+ puts in the Tab order, and the scroll regions of Table, Dock and MasterPanel draw the ring inside
33
+ their edge.
34
+ - **Tab panels are Tab stops only when nothing inside them is.** Tabbox, NavigationBar and Dock
35
+ panels follow the APG tabs pattern: a panel holding a control is no Tab stop of its own, so Tab
36
+ reaches the control, and a panel of plain text stays reachable to read and scroll. BlockView and RunTrace
37
+ code blocks are Tab stops only while their text scrolls.
38
+ - **The Composer rings its text, not its box.** Typing used to ring the whole box, chips, tools and
39
+ Send included. The text is now a field inside the box, with the control edge and fill, lined up
40
+ with the chips above it and the tools below, and it alone draws the focus ring while it is typed
41
+ into. The box stays a tray on the chrome tone; the tools and Send ring only when they hold the
42
+ focus themselves.
43
+
44
+ ### Fixed
45
+
46
+ - **A linked Card draws one focus ring.** Its primary link no longer adds a second ring inside the
47
+ card's own.
48
+ - **CopyInput's box rings only for its field.** With focus on the Copy button, the box rang around
49
+ the button's own ring; the button now rings alone.
50
+ - **ModuleBar shows every pinned module that fits.** With names beside the tiles — AppSidebar's
51
+ `layout: 'modules'`, expanded — pinned modules moved behind "All modules" while a third of the bar
52
+ stood empty. Unpinned modules and their section headings were measured although only the
53
+ catalogue offers them, a heading counted even when none of its modules stayed on the bar, and one
54
+ name wrapping to two lines charged every row its height. Each row now takes its own height, and a
55
+ heading only takes room above a module that is shown; no row is cut off.
56
+
11
57
  ## 5.8.1 — 2026-11-17
12
58
 
13
59
  Placeholder text that meets 4.5:1, the same small API on sibling inputs, cancellable async
@@ -171,8 +171,9 @@ export declare class BlockView extends Component<BlockViewOptions> {
171
171
  /** @private @returns {void} */
172
172
  private _syncState;
173
173
  /**
174
- * A wide table scrolls inside the answer; while it does, its wrapper is a named, focusable
175
- * region so the keyboard can scroll it too. A table that fits is not a tab stop.
174
+ * A wide table or a long code line scrolls inside the answer; while it does, its scroller is a
175
+ * Tab stop so the keyboard can scroll it too — a table's wrapper a named region. One that fits
176
+ * is not a Tab stop.
176
177
  * @private
177
178
  * @returns {void}
178
179
  */
@@ -371,7 +371,8 @@ export declare class Dock extends Component<DockOptions> {
371
371
  */
372
372
  _buildPane(definition: DockPane): Record<string, any>;
373
373
  /**
374
- * Runs any not-yet-run content factory for whatever the pane currently shows.
374
+ * Runs any not-yet-run content factory for whatever the pane currently shows, and settles
375
+ * whether a shown tab panel is a Tab stop itself.
375
376
  * @param {Record<string, any>} record Pane record.
376
377
  * @returns {void}
377
378
  */
@@ -60,7 +60,8 @@ export type DropdownOptions = {
60
60
  * panel is hosted by that dialog, so `showModal()` does not make it inert.
61
61
  *
62
62
  * The panel follows its trigger in the Tab order: Tab on the anchor of an open panel moves into
63
- * the panel's first focusable control (or onto the panel itself when it carries a `tabindex`),
63
+ * the panel's first focusable control (or onto the panel itself when it carries a `tabindex`, where
64
+ * it shows focus with the ring inside its edge),
64
65
  * Tab past the panel's last control continues after the anchor, and Shift+Tab from the first goes
65
66
  * back to the anchor. Closing while focus is inside returns it to the anchor.
66
67
  * @fires Dropdown#open
@@ -299,8 +299,10 @@ export declare class ModuleBar extends AppRailPresenter {
299
299
  /** @returns {void} */
300
300
  _syncActive(): void;
301
301
  /**
302
- * Shows the tiles that fit, in bar order, and moves the rest behind "All modules". Everything is
303
- * shown first so a bar sized by its content measures as not overflowing and never shrinks itself.
302
+ * Shows the tiles that fit, in bar order, and moves the rest behind "All modules". Every module
303
+ * the bar could place is shown first, so a bar sized by its content measures as not overflowing
304
+ * and never shrinks itself; a module that can only ever be in the catalogue is not, so it takes
305
+ * no room.
304
306
  * @returns {void}
305
307
  */
306
308
  _layout(): void;
@@ -369,6 +371,55 @@ export declare function partitionModules(items: ModuleItem[], capacity?: number,
369
371
  overflow: ModuleItem[];
370
372
  more: boolean;
371
373
  };
374
+ export type ModuleBarSpace = {
375
+ /**
376
+ * Length of the list's content box along the bar.
377
+ */
378
+ room: number;
379
+ /**
380
+ * Gap between two shown entries.
381
+ */
382
+ gap?: number;
383
+ /**
384
+ * Shown
385
+ * entries: a module row by its `id`, a heading, or the button. A heading takes its room only when
386
+ * a module after it, before the next heading, is on the bar.
387
+ */
388
+ entries: Array<{
389
+ id?: string;
390
+ heading?: boolean;
391
+ more?: boolean;
392
+ size: number;
393
+ }>;
394
+ };
395
+ /**
396
+ * The bar's list as measured with every module it could place shown: its rows, section headings,
397
+ * and "All modules" button in document order, each with the length it takes along the bar, its
398
+ * margins included.
399
+ * @typedef {Object} ModuleBarSpace
400
+ * @property {number} room Length of the list's content box along the bar.
401
+ * @property {number} [gap=0] Gap between two shown entries.
402
+ * @property {Array<{id?: string, heading?: boolean, more?: boolean, size: number}>} entries Shown
403
+ * entries: a module row by its `id`, a heading, or the button. A heading takes its room only when
404
+ * a module after it, before the next heading, is on the bar.
405
+ */
406
+ /**
407
+ * Splits modules as `partitionModules()` does, giving it the most slots for which what it places
408
+ * fits the measured list: each row at its own length, a section heading only where one of its
409
+ * modules is on the bar, and the "All modules" button when it is shown. So one name that wraps to
410
+ * two lines costs its extra line, not a tile, and no row is ever cut in half. Kept modules stay
411
+ * on the bar even when nothing else fits, as with `partitionModules()`.
412
+ * @param {ModuleItem[]} items Modules.
413
+ * @param {ModuleBarSpace} space The measured list.
414
+ * @param {Array<string|number|null|undefined>|string|number|null} [keep=[]] Module ids that must stay visible.
415
+ * @param {boolean} [reserve=false] The button is shown even when every module fits.
416
+ * @returns {{visible: ModuleItem[], overflow: ModuleItem[], more: boolean}}
417
+ */
418
+ export declare function fitModules(items: ModuleItem[], space: ModuleBarSpace, keep?: Array<string | number | null | undefined> | string | number | null, reserve?: boolean): {
419
+ visible: ModuleItem[];
420
+ overflow: ModuleItem[];
421
+ more: boolean;
422
+ };
372
423
  /**
373
424
  * Resolves a module's identity colour: a valid CSS `color` wins, then a known `tone`.
374
425
  * @param {{tone?: unknown, color?: unknown}} item Module.
@@ -204,7 +204,7 @@ export declare class RunStatus extends Component<RunStatusOptions> {
204
204
  /** @type {AgentAvatar|null} The agent's face, kept across draws while it asks for the same traits. */
205
205
  _avatar: AgentAvatar | null;
206
206
  _faceKey: any;
207
- /** Whether the root took `tabindex="-1"` to hold focus that had nowhere else to go. */
207
+ /** Whether the root took `tabindex="-1"` (and `data-zx-focus`) to hold focus that had nowhere else to go. */
208
208
  _heldFocus: boolean;
209
209
  /** @type {ReturnType<typeof setInterval>|0} */
210
210
  _interval: ReturnType<typeof setInterval> | 0;
@@ -326,6 +326,7 @@ export declare class RunTrace extends Component<RunTraceOptions> {
326
326
  _summaryDoing: HTMLElement;
327
327
  _summary: HTMLElement;
328
328
  _list: HTMLElement;
329
+ _resize: ResizeObserver;
329
330
  static cssName: string;
330
331
  /** @type {Readonly<RunTraceOptions>} */
331
332
  static defaults: Readonly<RunTraceOptions>;
@@ -476,6 +477,13 @@ export declare class RunTrace extends Component<RunTraceOptions> {
476
477
  * @returns {void}
477
478
  */
478
479
  private _setStep;
480
+ /**
481
+ * Makes each code block a Tab stop while, and only while, its text scrolls inside it.
482
+ * @private
483
+ * @param {Element} scope Where to look for code blocks.
484
+ * @returns {void}
485
+ */
486
+ private _syncCodeStops;
479
487
  /**
480
488
  * Redraws the summary from the steps.
481
489
  * @private
@@ -233,6 +233,13 @@ export declare class Tabbox extends Component<TabboxOptions> {
233
233
  _removeTab(name: string, emitClose: boolean): boolean;
234
234
  /** @param {TabRecord} record @returns {void} */
235
235
  _applyActive(record: TabRecord): void;
236
+ /**
237
+ * Makes the active panel a Tab stop only while nothing inside it is one: Tab from the tab goes
238
+ * to the panel's first control when it has one, and onto the panel itself when it holds only
239
+ * text to read or scroll.
240
+ * @returns {void}
241
+ */
242
+ _syncPanelStop(): void;
236
243
  /** @param {TabRecord} record @returns {void} */
237
244
  _ensureContent(record: TabRecord): void;
238
245
  /** @param {TabRecord} record @param {boolean} [focus=true] @returns {void} */
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Tab stops for elements that are not controls: a tab panel and a scrolling block.
3
+ *
4
+ * Both carry `data-zx-focus="region"` (see `styles/base.css`), so when the keyboard does reach them
5
+ * the ring is drawn inset. These helpers decide whether the keyboard reaches them at all.
6
+ */
7
+ /**
8
+ * Keeps a tab panel in the Tab order only while nothing inside it is a Tab stop, as the WAI-ARIA
9
+ * tabs pattern asks: a panel holding controls hands Tab straight to its first control, and a panel
10
+ * of plain text stays reachable from its tab so it can be read and scrolled.
11
+ *
12
+ * The decision is made from the markup — tab indexes, `disabled`, and `hidden`, `inert` or closed
13
+ * `<details>` subtrees inside the panel — and from layout only while the panel is rendered, so it
14
+ * holds for a panel that is not in the document yet. Call it whenever a panel is shown or its
15
+ * content is replaced, and again just before focus can move from the tab list into the panel. A
16
+ * panel that holds focus keeps its stop until a later call. Controls inside a shadow root are not
17
+ * seen, so a panel whose only controls sit in a custom element's shadow tree stays a stop itself.
18
+ * @param {HTMLElement} panel The `role="tabpanel"` element.
19
+ * @returns {boolean} Whether the panel is now a Tab stop itself.
20
+ */
21
+ export declare function syncPanelStop(panel: HTMLElement): boolean;
22
+ /**
23
+ * Whether Tab can stop anywhere inside a container.
24
+ * @param {Element} container Container to search.
25
+ * @returns {boolean}
26
+ */
27
+ export declare function containsTabStop(container: Element): boolean;
28
+ /**
29
+ * Keeps a scrolling block in the Tab order only while its content overflows, so the keyboard can
30
+ * scroll what the pointer can, and a block that fits is no stop at all. A block that is not laid
31
+ * out (detached, or inside something hidden) measures nothing and is left out until it is. A
32
+ * block holding focus keeps its stop, so a resize never drops focus; a later call settles it.
33
+ * @param {HTMLElement} element The scrolling element.
34
+ * @returns {boolean} Whether the element now overflows.
35
+ */
36
+ export declare function syncScrollStop(element: HTMLElement): boolean;
37
+ /**
38
+ * Whether an element's content is larger than its box on either axis.
39
+ * @param {Element} element Element to measure.
40
+ * @returns {boolean}
41
+ */
42
+ export declare function isOverflowing(element: Element): boolean;
@@ -2620,7 +2620,7 @@ function validateAdapter(adapter) {
2620
2620
  );
2621
2621
  }
2622
2622
  function errorAdapter(message4, id) {
2623
- const el = h("div", { class: "zx-field__error-control", id, role: "alert", tabIndex: -1 }, message4);
2623
+ const el = h("div", { class: "zx-field__error-control", id, role: "alert", tabIndex: -1, dataset: { zxFocus: "container" } }, message4);
2624
2624
  return {
2625
2625
  el,
2626
2626
  get: () => null,
@@ -14027,6 +14027,9 @@ var Table = class extends Component {
14027
14027
  this._scroll = h("div", {
14028
14028
  class: "zx-table__scroll",
14029
14029
  dataset: {
14030
+ // A scroller with nothing focusable inside is a Tab stop of the browser's making: it keeps
14031
+ // an inset ring there, and none while it holds focus for a table with no rows.
14032
+ zxFocus: "region",
14030
14033
  stickyHeader: String(Boolean(this.options.stickyHeader)),
14031
14034
  // Stripes follow the row's place in the data while windowed: `:nth-child` would count the
14032
14035
  // spacers, and the stripes would swap as the window moved.
@@ -16378,11 +16381,13 @@ var Table = class extends Component {
16378
16381
  if (!frame.hasAttribute("tabindex")) {
16379
16382
  frame.tabIndex = -1;
16380
16383
  frame.setAttribute("data-empty-focus", "");
16384
+ frame.dataset.zxFocus = "container";
16381
16385
  }
16382
16386
  frame.focus({ preventScroll: true });
16383
16387
  } else if (frame.hasAttribute("data-empty-focus")) {
16384
16388
  frame.removeAttribute("tabindex");
16385
16389
  frame.removeAttribute("data-empty-focus");
16390
+ frame.dataset.zxFocus = "region";
16386
16391
  }
16387
16392
  }
16388
16393
  /** @param {Event} event @returns {void} */
@@ -20198,11 +20203,23 @@ var Dropdown = class extends Component {
20198
20203
  render() {
20199
20204
  const panel = h("div", {
20200
20205
  id: uid("zx-dropdown"),
20201
- popover: "manual"
20206
+ popover: "manual",
20207
+ // A surface, not a control: it draws no ring when a script focuses it (`#syncFocusMarker()`).
20208
+ dataset: { zxFocus: "container" }
20202
20209
  });
20203
20210
  panel.dataset.state = "closed";
20204
20211
  return panel;
20205
20212
  }
20213
+ /**
20214
+ * A panel the application put in the Tab order (`tabindex` of 0 or more) is reached from its
20215
+ * anchor's Tab, so it shows keyboard focus as a region, with the ring inside its edge; otherwise
20216
+ * only a script focuses it and it draws no ring.
20217
+ * @returns {void}
20218
+ */
20219
+ #syncFocusMarker() {
20220
+ const reachable = this.el.hasAttribute("tabindex") && this.el.tabIndex >= 0;
20221
+ this.el.dataset.zxFocus = reachable ? "region" : "container";
20222
+ }
20206
20223
  /**
20207
20224
  * Opens and positions the panel.
20208
20225
  * @returns {this}
@@ -20212,6 +20229,7 @@ var Dropdown = class extends Component {
20212
20229
  if (this.isOpen() || this.#destroyed) return this;
20213
20230
  const host = this.#host();
20214
20231
  if (this.el.parentElement !== host) host.append(this.el);
20232
+ this.#syncFocusMarker();
20215
20233
  this.#position = position(this.#anchor, this.el, {
20216
20234
  placement: this.options.placement,
20217
20235
  offset: Number(this.options.offset),
@@ -21573,8 +21591,10 @@ var ModuleBar = class extends AppRailPresenter {
21573
21591
  this._layout();
21574
21592
  }
21575
21593
  /**
21576
- * Shows the tiles that fit, in bar order, and moves the rest behind "All modules". Everything is
21577
- * shown first so a bar sized by its content measures as not overflowing and never shrinks itself.
21594
+ * Shows the tiles that fit, in bar order, and moves the rest behind "All modules". Every module
21595
+ * the bar could place is shown first, so a bar sized by its content measures as not overflowing
21596
+ * and never shrinks itself; a module that can only ever be in the catalogue is not, so it takes
21597
+ * no room.
21578
21598
  * @returns {void}
21579
21599
  */
21580
21600
  _layout() {
@@ -21584,14 +21604,16 @@ var ModuleBar = class extends AppRailPresenter {
21584
21604
  const moreRow = list.querySelector(":scope > [data-module-bar-more]");
21585
21605
  const mode = this.el.dataset.allModules;
21586
21606
  const keep = [moduleOf(this._items, this._active)?.id, this._expandedId, this._promoted];
21587
- let capacity = Infinity;
21607
+ const reserve = mode === "always";
21608
+ let partition = partitionModules(this._items, Infinity, keep, reserve);
21588
21609
  if (mode !== "never" && list.isConnected) {
21589
- for (const row of rows) row.hidden = false;
21610
+ const placeable = new Set(partition.visible.map((item) => String(item.id)));
21611
+ for (const row of rows) row.hidden = !placeable.has(row.dataset.moduleId);
21590
21612
  if (moreRow) moreRow.hidden = false;
21591
21613
  syncHeadings(list);
21592
- capacity = measureCapacity(list, this.el.dataset.orientation === "horizontal", rows.length + 1);
21614
+ const space = measureSpace(list, this.el.dataset.orientation === "horizontal");
21615
+ if (space) partition = fitModules(this._items, space, keep, reserve);
21593
21616
  }
21594
- const partition = partitionModules(this._items, capacity, keep, mode === "always");
21595
21617
  const visible = new Set(partition.visible.map((item) => String(item.id)));
21596
21618
  for (const row of rows) row.hidden = !visible.has(row.dataset.moduleId);
21597
21619
  syncHeadings(list);
@@ -22055,6 +22077,40 @@ function partitionModules(items, capacity = Infinity, keep = [], reserve = false
22055
22077
  const overflow = list.filter((item) => !visible.includes(item));
22056
22078
  return { visible, overflow, more: overflow.length > 0 };
22057
22079
  }
22080
+ function fitModules(items, space, keep = [], reserve = false) {
22081
+ const fits = (partition) => barExtent(space, partition.visible, reserve || partition.more) <= space.room + 0.5;
22082
+ const all = partitionModules(items, Infinity, keep, reserve);
22083
+ if (fits(all)) return all;
22084
+ let low = 1;
22085
+ let high = all.visible.length;
22086
+ while (low < high) {
22087
+ const middle = Math.ceil((low + high) / 2);
22088
+ if (fits(partitionModules(items, middle, keep, true))) low = middle;
22089
+ else high = middle - 1;
22090
+ }
22091
+ return partitionModules(items, low, keep, true);
22092
+ }
22093
+ function barExtent(space, visible, more) {
22094
+ const shown = new Set(visible.map((item) => String(item.id)));
22095
+ let total = 0;
22096
+ let count = 0;
22097
+ let heading = null;
22098
+ for (const entry of space.entries ?? []) {
22099
+ if (entry.heading) {
22100
+ heading = entry;
22101
+ continue;
22102
+ }
22103
+ if (entry.more ? !more : !shown.has(String(entry.id))) continue;
22104
+ if (heading && !entry.more) {
22105
+ total += heading.size;
22106
+ count += 1;
22107
+ }
22108
+ heading = null;
22109
+ total += entry.size;
22110
+ count += 1;
22111
+ }
22112
+ return total + Math.max(0, count - 1) * (space.gap ?? 0);
22113
+ }
22058
22114
  function resolveModuleColor(item) {
22059
22115
  const color = isCssColor(item?.color) ? String(item.color).trim() : null;
22060
22116
  if (color) return { tone: null, color };
@@ -22112,26 +22168,32 @@ function barOrder(items) {
22112
22168
  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;
22113
22169
  return items.map((item, index) => ({ item, index })).sort((first, second) => rank(first.item) - rank(second.item) || first.index - second.index).map(({ item }) => item);
22114
22170
  }
22115
- function measureCapacity(list, horizontal, count) {
22171
+ function measureSpace(list, horizontal) {
22116
22172
  const overflowing = horizontal ? list.scrollWidth > list.clientWidth + 1 : list.scrollHeight > list.clientHeight + 1;
22117
- if (!overflowing) return Infinity;
22118
- const rows = (
22119
- /** @type {HTMLElement[]} */
22120
- [...list.querySelectorAll(":scope > li:not([hidden]):not(.zx-module-bar__heading)")]
22121
- );
22122
- if (!rows.length) return Infinity;
22123
- const headings = (
22124
- /** @type {HTMLElement[]} */
22125
- [...list.querySelectorAll(":scope > li.zx-module-bar__heading:not([hidden])")]
22126
- );
22173
+ if (!overflowing) return null;
22174
+ const axis = horizontal ? "Inline" : "Block";
22175
+ const edges = (style2, prefix, suffix = "") => (Number.parseFloat(style2[`${prefix}${axis}Start${suffix}`]) || 0) + (Number.parseFloat(style2[`${prefix}${axis}End${suffix}`]) || 0);
22176
+ const drawn = (element) => element.getBoundingClientRect()[horizontal ? "width" : "height"];
22177
+ const laid = horizontal ? list.offsetWidth : list.offsetHeight;
22178
+ const scale = laid > 0 && drawn(list) > 0 ? drawn(list) / laid : 1;
22127
22179
  const style = getComputedStyle(list);
22180
+ const room = laid - edges(style, "padding") - edges(style, "border", "Width");
22128
22181
  const gap = Number.parseFloat(horizontal ? style.columnGap : style.rowGap) || 0;
22129
- const padding = horizontal ? (Number.parseFloat(style.paddingInlineStart) || 0) + (Number.parseFloat(style.paddingInlineEnd) || 0) : (Number.parseFloat(style.paddingBlockStart) || 0) + (Number.parseFloat(style.paddingBlockEnd) || 0);
22130
- const size = Math.max(...rows.map((row) => horizontal ? row.offsetWidth : row.offsetHeight));
22131
- 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);
22132
- const available = (horizontal ? list.clientWidth : list.clientHeight) - padding - headingSpace;
22133
- if (size <= 0 || available <= 0) return count;
22134
- return Math.max(1, Math.floor((available + gap) / (size + gap)));
22182
+ const entries = [];
22183
+ for (
22184
+ const child of
22185
+ /** @type {HTMLElement[]} */
22186
+ [...list.children]
22187
+ ) {
22188
+ const childStyle = getComputedStyle(child);
22189
+ if (child.hidden || childStyle.display === "none") continue;
22190
+ const size = drawn(child) / scale + edges(childStyle, "margin");
22191
+ if (child.classList.contains("zx-module-bar__heading")) entries.push({ heading: true, size });
22192
+ else if (child.hasAttribute("data-module-bar-more")) entries.push({ more: true, size });
22193
+ else if (child.dataset.moduleId != null) entries.push({ id: child.dataset.moduleId, size });
22194
+ }
22195
+ if (room <= 0 || !entries.some((entry) => entry.id != null && entry.size > 0)) return null;
22196
+ return { room, gap, entries };
22135
22197
  }
22136
22198
  function nearestInRow(entries, current, direction) {
22137
22199
  const origin = current.getBoundingClientRect();