@fusion.dev/helix-headless 0.236.0 → 0.237.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 (119) hide show
  1. package/api.json +1 -1
  2. package/custom-elements.json +1 -1
  3. package/dist/app-header/root/app-header-root.d.ts +9 -0
  4. package/dist/app-header/root/app-header-root.js +21 -0
  5. package/dist/area-chart/root/area-chart-root.d.ts +29 -15
  6. package/dist/area-chart/root/area-chart-root.js +10 -7
  7. package/dist/bar-chart/root/bar-chart-root.d.ts +41 -23
  8. package/dist/bar-chart/root/bar-chart-root.js +15 -10
  9. package/dist/button/root/button-root.js +1 -1
  10. package/dist/canvas/root/canvas-root.d.ts +10 -3
  11. package/dist/canvas/root/canvas-root.js +31 -14
  12. package/dist/color-input/root/color-input-root.d.ts +4 -2
  13. package/dist/color-input/root/color-input-root.js +1 -1
  14. package/dist/combobox/root/combobox-root.d.ts +8 -7
  15. package/dist/combobox/root/combobox-root.js +7 -3
  16. package/dist/command/root/command-root.d.ts +22 -2
  17. package/dist/command/root/command-root.js +39 -5
  18. package/dist/data-table/root/data-table-root.d.ts +10 -7
  19. package/dist/data-table/root/data-table-root.js +6 -1
  20. package/dist/date-picker/root/date-picker-root.d.ts +1 -1
  21. package/dist/date-picker/root/date-picker-root.js +9 -2
  22. package/dist/dialog/root/dialog-root.d.ts +13 -3
  23. package/dist/dialog/root/dialog-root.js +33 -2
  24. package/dist/donut-chart/root/donut-chart-root.d.ts +23 -1
  25. package/dist/donut-chart/root/donut-chart-root.js +41 -13
  26. package/dist/drawer/root/drawer-root.d.ts +10 -2
  27. package/dist/drawer/root/drawer-root.js +34 -1
  28. package/dist/filter-input/chip/filter-chip.js +2 -2
  29. package/dist/find/root/find-root.d.ts +11 -1
  30. package/dist/find/root/find-root.js +11 -0
  31. package/dist/heatmap/root/heatmap-root.d.ts +11 -8
  32. package/dist/heatmap/root/heatmap-root.js +27 -2
  33. package/dist/kbd/root/kbd-root.d.ts +4 -0
  34. package/dist/kbd/root/kbd-root.js +2 -1
  35. package/dist/lightbox/root/lightbox-root.js +3 -2
  36. package/dist/line-chart/root/line-chart-root.d.ts +36 -23
  37. package/dist/line-chart/root/line-chart-root.js +20 -13
  38. package/dist/list/item/list-item.d.ts +2 -1
  39. package/dist/list/item/list-item.js +4 -1
  40. package/dist/list/root/list-root.d.ts +33 -8
  41. package/dist/list/root/list-root.js +17 -3
  42. package/dist/listbox/root/listbox-root.d.ts +48 -15
  43. package/dist/listbox/root/listbox-root.js +65 -6
  44. package/dist/map/root/map-root.js +7 -7
  45. package/dist/markdown/tree.d.ts +6 -1
  46. package/dist/markdown/tree.js +1 -1
  47. package/dist/megamenu/root/megamenu-root.d.ts +19 -0
  48. package/dist/megamenu/root/megamenu-root.js +24 -0
  49. package/dist/menu/filter/menu-filter.js +3 -1
  50. package/dist/menu/item/menu-item.d.ts +12 -0
  51. package/dist/menu/item/menu-item.js +3 -0
  52. package/dist/menu/root/menu-root.d.ts +7 -1
  53. package/dist/menu/root/menu-root.js +6 -3
  54. package/dist/motion-toggle/root/motion-toggle-root.js +2 -2
  55. package/dist/notifications/notification/notification.d.ts +1 -0
  56. package/dist/notifications/notification/notification.js +1 -0
  57. package/dist/notifications/root/notifications-root.d.ts +7 -5
  58. package/dist/notifications/root/notifications-root.js +1 -1
  59. package/dist/number-input/root/number-input-root.d.ts +6 -0
  60. package/dist/number-input/root/number-input-root.js +14 -4
  61. package/dist/object-inspector/root/object-inspector-root.d.ts +6 -5
  62. package/dist/object-inspector/root/object-inspector-root.js +9 -3
  63. package/dist/option/root/option-root.d.ts +14 -0
  64. package/dist/option/root/option-root.js +3 -0
  65. package/dist/pagination/root/pagination-root.d.ts +36 -0
  66. package/dist/pagination/root/pagination-root.js +55 -2
  67. package/dist/pin-input/code.js +1 -1
  68. package/dist/qr-code/root/qr-code-root.d.ts +1 -0
  69. package/dist/qr-code/root/qr-code-root.js +1 -0
  70. package/dist/rating/root/rating-root.d.ts +1 -0
  71. package/dist/rating/root/rating-root.js +1 -0
  72. package/dist/scatter-chart/root/scatter-chart-root.d.ts +6 -0
  73. package/dist/select/root/select-root.d.ts +27 -1
  74. package/dist/select/root/select-root.js +34 -3
  75. package/dist/shortcut-overlay/root/shortcut-overlay-root.d.ts +5 -0
  76. package/dist/shortcut-overlay/root/shortcut-overlay-root.js +15 -1
  77. package/dist/skeleton/root/skeleton-root.d.ts +1 -0
  78. package/dist/skeleton/root/skeleton-root.js +3 -0
  79. package/dist/sparkline/root/sparkline-root.d.ts +53 -0
  80. package/dist/sparkline/root/sparkline-root.js +37 -1
  81. package/dist/spatial-bar-chart/root/spatial-bar-chart-root.d.ts +4 -1
  82. package/dist/spatial-bar-chart/root/spatial-bar-chart-root.js +2 -2
  83. package/dist/spatial-ribbon-chart/root/spatial-ribbon-chart-root.d.ts +3 -0
  84. package/dist/spatial-ribbon-chart/root/spatial-ribbon-chart-root.js +2 -2
  85. package/dist/spatial-scatter-chart/root/spatial-scatter-chart-root.d.ts +3 -0
  86. package/dist/spatial-scatter-chart/root/spatial-scatter-chart-root.js +2 -2
  87. package/dist/spatial-scatter-chart/view.d.ts +17 -8
  88. package/dist/spatial-scatter-chart/view.js +7 -6
  89. package/dist/spatial-surface-chart/root/spatial-surface-chart-root.d.ts +3 -0
  90. package/dist/spatial-surface-chart/root/spatial-surface-chart-root.js +2 -2
  91. package/dist/spatial-treemap/root/spatial-treemap-root.d.ts +3 -0
  92. package/dist/spatial-treemap/root/spatial-treemap-root.js +2 -2
  93. package/dist/splitter/root/splitter-root.js +3 -1
  94. package/dist/stat/group/stat-group.d.ts +13 -0
  95. package/dist/stat/group/stat-group.js +22 -1
  96. package/dist/stat/root/stat-root.d.ts +62 -1
  97. package/dist/stat/root/stat-root.js +146 -4
  98. package/dist/table/cell/table-cell.d.ts +1 -0
  99. package/dist/table/cell/table-cell.js +4 -0
  100. package/dist/table/root/table-root.d.ts +7 -6
  101. package/dist/table/root/table-root.js +1 -1
  102. package/dist/tabs/tab/tab.js +2 -2
  103. package/dist/tag/root/tag-root.js +2 -2
  104. package/dist/timeline/root/timeline-root.d.ts +2 -2
  105. package/dist/timeline/root/timeline-root.js +1 -1
  106. package/dist/toast/root/toast-root.d.ts +53 -6
  107. package/dist/toast/root/toast-root.js +158 -1
  108. package/dist/toggle/root/toggle-root.d.ts +1 -0
  109. package/dist/toggle/root/toggle-root.js +1 -1
  110. package/dist/video-playlist/root/video-playlist-root.d.ts +1 -0
  111. package/dist/video-playlist/root/video-playlist-root.js +2 -0
  112. package/dist/virtual-list/root/virtual-list-root.d.ts +2 -2
  113. package/dist/virtual-list/root/virtual-list-root.js +1 -1
  114. package/examples.json +1 -1
  115. package/lint.json +1 -1
  116. package/package.json +5 -5
  117. package/types/jsx.d.ts +633 -168
  118. package/types/vue.d.ts +379 -95
  119. package/types/words.d.ts +51 -12
@@ -1,5 +1,5 @@
1
1
  import { __decorate } from "tslib";
2
- import { AriaForwardController, CHART_PLOT, customElement, drawTooltip, formatWords, HelixElement, HelixPlotChangeEvent, HelixPlotTurnEvent, HelixReadingChangeEvent, HelixReadingPressEvent, isRtl, MixinChartSource, MixinChartStatus, spokenReading, words, } from '@fusion.dev/helix-core';
2
+ import { AriaForwardController, CHART_PLOT, customElement, drawTooltip, formatWords, HelixElement, HelixPlotChangeEvent, HelixPlotTurnEvent, HelixReadingChangeEvent, HelixReadingPressEvent, isRtl, MixinChartSource, MixinChartStatus, spokenReading, words, wordsLocale, } from '@fusion.dev/helix-core';
3
3
  import { html, nothing, svg, } from 'lit';
4
4
  import { property, state } from 'lit/decorators.js';
5
5
  import '../../tooltip/index.js';
@@ -163,7 +163,7 @@ let HelixHeadlessSpatialSurfaceChart = class HelixHeadlessSpatialSurfaceChart ex
163
163
  ${readable ? this.renderSummary(field) : this.renderStatus()}${this.renderSonify()}${this.renderTable()}`;
164
164
  }
165
165
  renderFallback(field, at) {
166
- const view = wordsFitted(this.plotRoom.room, (words) => boxView(field.axes, this.camera, [], this.noBox, words));
166
+ const view = wordsFitted(this.plotRoom.room, (words) => boxView(field.axes, this.camera, [], this.noBox, words, wordsLocale(this)));
167
167
  const depths = field.depths.length;
168
168
  const boxed = field.cells.map((cell) => cell.value === undefined
169
169
  ? undefined
@@ -65,6 +65,7 @@ declare const HelixHeadlessSpatialTreemap_base: typeof HelixElement & (new (...a
65
65
  *
66
66
  * @slot - The renderer's box, which the 3D drawing is made in.
67
67
  * @slot empty - Content shown when the table has no readings. Falls back to `empty-text`.
68
+ * @slot error - Content shown after `error-text` while it is set and there are no readings, such as a button that tries again.
68
69
  * @slot loading - Content shown while `loading` is set and there are no readings yet. Falls back to `loading-text`.
69
70
  *
70
71
  * @event {HelixPlotChangeEvent} helix-plot-change - The blocks or the block the keys rest on changed, which the renderer is told. It stays on the chart.
@@ -77,6 +78,7 @@ declare const HelixHeadlessSpatialTreemap_base: typeof HelixElement & (new (...a
77
78
  * @csspart block-active - The block the pointer or the keys rest on. Set alongside `block`.
78
79
  * @csspart drawing - The chart's own drawing in SVG: the box, its grid and numbers, and the blocks.
79
80
  * @csspart empty - The words when the table has no readings: the `empty` slot, falling back to `empty-text`.
81
+ * @csspart error - The words while `error-text` is set and there are no readings, followed by the `error` slot. Announced as it appears.
80
82
  * @csspart face - One face of a block the view shows, shaded by which way it faces.
81
83
  * @csspart fallback - The box the chart's own drawing fills, shown until a renderer has drawn and where none is connected. Hidden from screen readers.
82
84
  * @csspart grid - The box's edges and its grid, in the chart's own drawing.
@@ -113,6 +115,7 @@ declare const HelixHeadlessSpatialTreemap_base: typeof HelixElement & (new (...a
113
115
  * @cssstate active - While a block is shown, under the pointer or the keys.
114
116
  * @cssstate drawn - While a renderer has drawn the blocks, and the chart's own drawing is hidden.
115
117
  * @cssstate empty - While the `empty` part stands in place of the readings.
118
+ * @cssstate error - While the `error` part stands in place of the readings.
116
119
  * @cssstate loading - While the `loading` part stands in place of the readings.
117
120
  */
118
121
  export declare class HelixHeadlessSpatialTreemap extends HelixHeadlessSpatialTreemap_base {
@@ -1,5 +1,5 @@
1
1
  import { __decorate } from "tslib";
2
- import { AriaForwardController, CHART_PLOT, customElement, drawTooltip, formatWords, HelixElement, HelixPlotChangeEvent, HelixPlotTurnEvent, HelixReadingChangeEvent, HelixReadingPressEvent, isRtl, MixinChartSource, MixinChartStatus, spokenReading, words, } from '@fusion.dev/helix-core';
2
+ import { AriaForwardController, CHART_PLOT, customElement, drawTooltip, formatWords, HelixElement, HelixPlotChangeEvent, HelixPlotTurnEvent, HelixReadingChangeEvent, HelixReadingPressEvent, isRtl, MixinChartSource, MixinChartStatus, spokenReading, words, wordsLocale, } from '@fusion.dev/helix-core';
3
3
  import { html, nothing, svg, } from 'lit';
4
4
  import { property, state } from 'lit/decorators.js';
5
5
  import '../../tooltip/index.js';
@@ -156,7 +156,7 @@ let HelixHeadlessSpatialTreemap = class HelixHeadlessSpatialTreemap extends Mixi
156
156
  ${readable ? this.renderSummary(field) : this.renderStatus()}${this.renderSonify()}${this.renderTable()}`;
157
157
  }
158
158
  renderFallback(field, at) {
159
- const view = wordsFitted(this.plotRoom.room, (words) => boxView(field.axes, this.camera, [], this.noBox, words));
159
+ const view = wordsFitted(this.plotRoom.room, (words) => boxView(field.axes, this.camera, [], this.noBox, words, wordsLocale(this)));
160
160
  const blocks = blocksDrawn(field, view.projection);
161
161
  const active = blocks[at];
162
162
  const bounds = this.drag.frame(this.noBox
@@ -604,10 +604,12 @@ let HelixHeadlessSplitter = class HelixHeadlessSplitter extends HelixElement {
604
604
  }
605
605
  render() {
606
606
  const position = this.showing;
607
+ const shut = this.flush ? this.shutAt(position) : undefined;
607
608
  return html `<div
608
609
  part="start"
609
610
  id="start"
610
611
  ?data-dragging=${this.dragging}
612
+ ?inert=${shut === 'start'}
611
613
  style="--splitter-position: ${position}%"
612
614
  >
613
615
  <slot name="start"></slot>
@@ -638,7 +640,7 @@ let HelixHeadlessSplitter = class HelixHeadlessSplitter extends HelixElement {
638
640
  >
639
641
  <slot name="handle"></slot>
640
642
  </div>
641
- <div part="end" ?data-dragging=${this.dragging}>
643
+ <div part="end" ?data-dragging=${this.dragging} ?inert=${shut === 'end'}>
642
644
  <slot name="end"></slot>
643
645
  </div>
644
646
  ${this.crossings.map((crossing, index) => html `<div
@@ -40,6 +40,19 @@ export declare class HelixHeadlessStatGroup extends HelixElement {
40
40
  */
41
41
  attributeChangedCallback(name: string, old: string | null, value: string | null): void;
42
42
  protected willUpdate(changed: PropertyValues): void;
43
+ /**
44
+ * The step a stat's figure takes: its own outside columns, and in columns the
45
+ * largest any stat in the group needs, so a row of figures shares one size.
46
+ * The others are set at that step as it changes.
47
+ *
48
+ * **Only in columns**, where a stat is as wide as its column whatever its
49
+ * figure. Stats that flow take the width of their figures, so a stat set a
50
+ * step down shrank and then needed the step it was given, and the group never
51
+ * stepped back up.
52
+ */
53
+ stepFor(stat: Element): number;
54
+ /** Sets every stat at the step the group shares, once one comes or goes. */
55
+ private readonly share;
43
56
  protected render(): TemplateResult;
44
57
  }
45
58
  declare global {
@@ -2,10 +2,19 @@ import { __decorate } from "tslib";
2
2
  import { customElement, HelixElement, hostAria, internalsOf } from '@fusion.dev/helix-core';
3
3
  import { html } from 'lit';
4
4
  import { property } from 'lit/decorators.js';
5
+ function steps(child) {
6
+ return 'stepNeeded' in child && 'showStep' in child ? child : undefined;
7
+ }
5
8
  let HelixHeadlessStatGroup = class HelixHeadlessStatGroup extends HelixElement {
6
9
  constructor() {
7
10
  super(...arguments);
8
11
  this.label = '';
12
+ this.share = () => {
13
+ const first = [...this.children].find((child) => steps(child) !== undefined);
14
+ if (first) {
15
+ steps(first)?.showStep(this.stepFor(first));
16
+ }
17
+ };
9
18
  }
10
19
  static get observedAttributes() {
11
20
  return [...super.observedAttributes, 'aria-label', 'aria-labelledby'];
@@ -23,8 +32,20 @@ let HelixHeadlessStatGroup = class HelixHeadlessStatGroup extends HelixElement {
23
32
  Boolean(this.getAttribute?.('aria-labelledby')?.trim());
24
33
  hostAria(internalsOf(this), { label: this.label, role: named ? 'group' : '' });
25
34
  }
35
+ stepFor(stat) {
36
+ const own = steps(stat)?.stepNeeded ?? 0;
37
+ if (!this.hasAttribute('columns')) {
38
+ return own;
39
+ }
40
+ const stats = [...this.children].filter((child) => child !== stat && steps(child));
41
+ const shared = Math.max(own, ...stats.map((one) => steps(one)?.stepNeeded ?? 0));
42
+ for (const one of stats) {
43
+ steps(one)?.showStep(shared);
44
+ }
45
+ return shared;
46
+ }
26
47
  render() {
27
- return html `<slot></slot>`;
48
+ return html `<slot @slotchange=${this.share}></slot>`;
28
49
  }
29
50
  };
30
51
  __decorate([
@@ -25,6 +25,12 @@ import { type PropertyValues, type TemplateResult } from 'lit';
25
25
  * a server writes it as the browser does. A number in `value` takes the place
26
26
  * of a slotted figure.
27
27
  *
28
+ * **A figure too wide for its column breaks after a group separator**, slotted
29
+ * or written from `value`, so "$1,284,567" breaks as "$1,284," over "567" and
30
+ * never between two digits. A slotted figure that is text alone is written by
31
+ * the stat with those breaks, and the slot is hidden while it is. A figure
32
+ * holding an element is shown as it is.
33
+ *
28
34
  * **Each slot is a part of the same name**, and `value` for the figure, so a
29
35
  * page reaches the label, the unit and the trend from outside. A slot draws no
30
36
  * box, so a part passes inherited properties to what is slotted. **The stat
@@ -46,11 +52,14 @@ import { type PropertyValues, type TemplateResult } from 'lit';
46
52
  * @csspart label - The slot the label arrives through, drawing no box, as `value` does.
47
53
  * @csspart trend - The slot the trend arrives through, drawing no box, as `value` does.
48
54
  * @csspart unit - The slot the unit arrives through, drawing no box, as `value` does.
49
- * @csspart value - The slot the value is written in, or the figure `value` writes. A slot draws no box, so it takes the inherited properties, such as color and font, and passes them to the value.
55
+ * @csspart value - The slot the value is written in, or the figure the stat writes from `value` or from slotted text. A slot draws no box, so it takes the inherited properties, such as color and font, and passes them to the value.
50
56
  *
51
57
  * @cssstate has-label - Something is slotted into `label`.
52
58
  * @cssstate has-trend - Something is slotted into `trend`.
53
59
  * @cssstate has-unit - Something is slotted into `unit`.
60
+ * @cssstate number - The slotted figure is text that reads as a number, such as `1284392118` or `$8,402`, so it breaks only after a group separator and never between two digits.
61
+ * @cssstate stepped - The figure is set a step smaller, because at full size it does not fit the stat's width on one line.
62
+ * @cssstate stepped-twice - The figure is set two steps smaller, because one step smaller it still does not fit. `stepped` holds as well.
54
63
  */
55
64
  export declare class HelixHeadlessStat extends HelixElement {
56
65
  /**
@@ -106,7 +115,59 @@ export declare class HelixHeadlessStat extends HelixElement {
106
115
  value?: number;
107
116
  protected willUpdate(changed: PropertyValues): void;
108
117
  protected firstUpdated(changed: PropertyValues): void;
118
+ /** Watches the stat's own width, to step the figure down where it does not fit. */
119
+ private widths;
120
+ /**
121
+ * A slotted figure that is text alone, cut into the runs it may break
122
+ * after. Empty where the slot holds an element, or text with no group
123
+ * separator, which the slot then shows as it is.
124
+ */
125
+ private slottedRuns;
126
+ /** Whether the figure has been read since the children were known. */
127
+ private figureRead;
128
+ /** Watches the slotted text, which a framework edits in place with no `slotchange`. */
129
+ private edits;
130
+ connectedCallback(): void;
131
+ disconnectedCallback(): void;
132
+ private readonly refit;
133
+ /**
134
+ * Sets the figure a step or two smaller where it does not fit on one line.
135
+ *
136
+ * **A figure is read whole, so it is never broken between digits first.** At
137
+ * full size "1,284" measured 104.5 pixels against a 6rem column and wrapped as
138
+ * "1,28" over "4". Decided by the owner on November 3, 2026: step a long value
139
+ * down the type scale, a second step where one is not enough, and break it only
140
+ * where even that does not fit, and then only after a group separator. One step
141
+ * left "$8,402" as "$8," over "402" at 6rem.
142
+ *
143
+ * Each size is measured on one line, with no wrapping, against the stat's own
144
+ * width rather than the screen's, smallest step last. Measured afresh on every
145
+ * resize, so the figure steps back up once the room is there.
146
+ */
147
+ private fit;
148
+ /**
149
+ * The steps down this stat's own figure needs to fit its width, from 0 to 2,
150
+ * measured at full size whatever step it shows. A group in columns reads it
151
+ * to set every figure at the same step.
152
+ */
153
+ stepNeeded: number;
154
+ /** Sets the figure at a step, 0 for full size, without measuring it again. */
155
+ showStep(step: number): void;
156
+ /** The width of what a part shows, slotted or its own, on the lines it takes. */
157
+ private widthOf;
109
158
  protected updated(changed: PropertyValues): void;
159
+ /**
160
+ * Reads a slotted figure that is text alone into the runs it may break
161
+ * after: each ends at a group separator between two digits.
162
+ *
163
+ * **A slotted figure broke between digits.** A slot offers no break of its
164
+ * own, so it took `overflow-wrap: anywhere`, and "12,345,678" in a 120 pixel
165
+ * stat broke as "12,345,67" over "8". The separators are the locale's own
166
+ * group character and the ones figures are written with, a comma, a point, an
167
+ * apostrophe, or a space, less the locale's decimal sign, so "1.284.567,89"
168
+ * breaks after its points in German and "1,284.5" never after its point.
169
+ */
170
+ private readonly readFigure;
110
171
  /** Says which pieces the stat holds, one call apiece so each pairs with its `@cssstate`. */
111
172
  private readonly readPieces;
112
173
  protected render(): TemplateResult;
@@ -1,11 +1,50 @@
1
1
  import { __decorate } from "tslib";
2
- import { customElement, formatNumber, HelixElement, hostAria, internalsOf, numberConverter, reportRuntime, slotFilled, slottedWords, wordsLocale, } from '@fusion.dev/helix-core';
3
- import { html } from 'lit';
4
- import { property } from 'lit/decorators.js';
2
+ import { customElement, formatNumber, formatNumberParts, HelixElement, hostAria, internalsOf, numberConverter, reportRuntime, slotFilled, slottedWords, wordsLocale, } from '@fusion.dev/helix-core';
3
+ import { html, nothing } from 'lit';
4
+ import { property, state } from 'lit/decorators.js';
5
+ const SEPARATORS = new Set([',', '.', "'", '\u2019', ' ', '\u00a0', '\u2009', '\u202f']);
6
+ const FIGURE = /^[\p{N}\p{Sc}\p{Zs}.,'\u2019+\-\u2212%\u2030]+$/u;
5
7
  let HelixHeadlessStat = class HelixHeadlessStat extends HelixElement {
6
8
  constructor() {
7
9
  super(...arguments);
8
10
  this.locale = '';
11
+ this.slottedRuns = [];
12
+ this.figureRead = false;
13
+ this.refit = () => this.fit();
14
+ this.stepNeeded = 0;
15
+ this.readFigure = () => {
16
+ const slot = this.renderRoot?.querySelector('slot:not([name])');
17
+ const nodes = slot?.assignedNodes({ flatten: true }) ??
18
+ [...this.childNodes].filter((node) => !(node instanceof Element && node.hasAttribute('slot')));
19
+ const text = nodes.every((node) => node.nodeType === Node.TEXT_NODE)
20
+ ? nodes
21
+ .map((node) => node.textContent ?? '')
22
+ .join('')
23
+ .trim()
24
+ : '';
25
+ const parts = formatNumberParts(1234.5, wordsLocale(this));
26
+ const group = parts.find((part) => part.type === 'group')?.value ?? ',';
27
+ const decimal = parts.find((part) => part.type === 'decimal')?.value ?? '.';
28
+ const characters = [...text];
29
+ const runs = [];
30
+ let run = '';
31
+ for (const [at, character] of characters.entries()) {
32
+ run += character;
33
+ const between = /\d/.test(characters[at - 1] ?? '') && /\d/.test(characters[at + 1] ?? '');
34
+ if (between && character !== decimal && (character === group || SEPARATORS.has(character))) {
35
+ runs.push(run);
36
+ run = '';
37
+ }
38
+ }
39
+ runs.push(run);
40
+ this.toggleState('number', /\d/.test(text) && FIGURE.test(text));
41
+ const next = runs.length > 1 ? runs : [];
42
+ const same = next.length === this.slottedRuns.length &&
43
+ next.every((piece, at) => piece === this.slottedRuns[at]);
44
+ if (!same) {
45
+ this.slottedRuns = next;
46
+ }
47
+ };
9
48
  this.readPieces = () => {
10
49
  const filled = (name) => slotFilled(this.renderRoot?.querySelector(`slot[name="${name}"]`));
11
50
  this.toggleState('has-label', filled('label'));
@@ -15,6 +54,10 @@ let HelixHeadlessStat = class HelixHeadlessStat extends HelixElement {
15
54
  }
16
55
  willUpdate(changed) {
17
56
  super.willUpdate(changed);
57
+ if (this.childrenKnown && (!this.figureRead || changed.has('locale'))) {
58
+ this.figureRead = true;
59
+ this.readFigure();
60
+ }
18
61
  const labels = this.knownChildren.filter((child) => child.slot === 'label');
19
62
  hostAria(internalsOf(this), {
20
63
  label: labels.length > 0 && !('ariaLabelledByElements' in internalsOf(this))
@@ -28,9 +71,88 @@ let HelixHeadlessStat = class HelixHeadlessStat extends HelixElement {
28
71
  super.firstUpdated(changed);
29
72
  this.finishHydration();
30
73
  }
74
+ connectedCallback() {
75
+ super.connectedCallback();
76
+ if (typeof ResizeObserver === 'undefined' || this.widths) {
77
+ return;
78
+ }
79
+ this.widths = new ResizeObserver(() => this.fit());
80
+ this.widths.observe(this);
81
+ if (typeof MutationObserver !== 'undefined') {
82
+ this.edits = new MutationObserver(this.readFigure);
83
+ this.edits.observe(this, { characterData: true, subtree: true });
84
+ }
85
+ this.ownerDocument.fonts?.addEventListener('loadingdone', this.refit);
86
+ }
87
+ disconnectedCallback() {
88
+ super.disconnectedCallback();
89
+ this.widths?.disconnect();
90
+ this.widths = undefined;
91
+ this.edits?.disconnect();
92
+ this.edits = undefined;
93
+ this.ownerDocument.fonts?.removeEventListener('loadingdone', this.refit);
94
+ }
95
+ fit() {
96
+ const part = this.renderRoot?.querySelector('[part="value"]');
97
+ if (!part) {
98
+ return;
99
+ }
100
+ const box = getComputedStyle(this);
101
+ const unit = this.renderRoot.querySelector('[part="unit"]');
102
+ const room = this.clientWidth -
103
+ (Number.parseFloat(box.paddingInlineStart) || 0) -
104
+ (Number.parseFloat(box.paddingInlineEnd) || 0) -
105
+ (Number.parseFloat(box.columnGap) || 0) -
106
+ this.widthOf(unit);
107
+ if (room <= 0) {
108
+ return;
109
+ }
110
+ const wrap = part.style.whiteSpace;
111
+ part.style.whiteSpace = 'nowrap';
112
+ const breaks = [...part.querySelectorAll('wbr')];
113
+ for (const one of breaks) {
114
+ one.style.display = 'none';
115
+ }
116
+ const fits = () => this.widthOf(part) <= room + 0.5;
117
+ this.showStep(0);
118
+ let need = 0;
119
+ if (!fits()) {
120
+ need = 1;
121
+ this.showStep(1);
122
+ if (!fits()) {
123
+ need = 2;
124
+ }
125
+ }
126
+ part.style.whiteSpace = wrap;
127
+ for (const one of breaks) {
128
+ one.style.removeProperty('display');
129
+ }
130
+ this.stepNeeded = need;
131
+ const group = this.parentElement;
132
+ this.showStep(group?.stepFor ? group.stepFor(this) : need);
133
+ }
134
+ showStep(step) {
135
+ this.toggleState('stepped', step >= 1);
136
+ this.toggleState('stepped-twice', step >= 2);
137
+ }
138
+ widthOf(part) {
139
+ if (!part) {
140
+ return 0;
141
+ }
142
+ const nodes = part instanceof HTMLSlotElement ? part.assignedNodes({ flatten: true }) : [...part.childNodes];
143
+ const shown = nodes.filter((node) => node.nodeType !== Node.TEXT_NODE || node.textContent?.trim());
144
+ if (shown.length === 0) {
145
+ return 0;
146
+ }
147
+ const range = document.createRange();
148
+ range.setStartBefore(shown[0]);
149
+ range.setEndAfter(shown.at(-1));
150
+ return range.getBoundingClientRect().width;
151
+ }
31
152
  updated(changed) {
32
153
  super.updated(changed);
33
154
  this.readPieces();
155
+ this.fit();
34
156
  const given = this.direction;
35
157
  if (changed.has('direction') && (given === 'up' || given === 'down' || given === 'neutral')) {
36
158
  reportRuntime({
@@ -47,8 +169,25 @@ let HelixHeadlessStat = class HelixHeadlessStat extends HelixElement {
47
169
  const figure = value === undefined || !Number.isFinite(value)
48
170
  ? ''
49
171
  : formatNumber(value, wordsLocale(this), this.formatOptions);
172
+ const pieces = [];
173
+ const slotted = figure === '' ? this.slottedRuns : [];
174
+ for (const [at, run] of slotted.entries()) {
175
+ pieces.push(at < slotted.length - 1 ? html `${run}<wbr />` : run);
176
+ }
177
+ if (figure !== '') {
178
+ let run = '';
179
+ for (const piece of formatNumberParts(value, wordsLocale(this), this.formatOptions)) {
180
+ run += piece.value;
181
+ if (piece.type === 'group') {
182
+ pieces.push(html `${run}<wbr />`);
183
+ run = '';
184
+ }
185
+ }
186
+ pieces.push(run);
187
+ }
188
+ const written = figure !== '' || slotted.length > 0;
50
189
  return html `<slot name="label" part="label" @slotchange=${() => this.requestUpdate()}></slot>
51
- ${figure === '' ? html `<slot part="value"></slot>` : html `<span part="value">${figure}</span>`}
190
+ ${figure === '' ? html `${written ? html `<span part="value">${pieces}</span>` : nothing}<slot part=${written ? nothing : 'value'} ?hidden=${written} @slotchange=${this.readFigure}></slot>` : html `<span part="value">${pieces}</span>`}
52
191
  <slot name="unit" part="unit" @slotchange=${this.readPieces}></slot>
53
192
  <slot name="trend" part="trend" @slotchange=${this.readPieces}></slot>`;
54
193
  }
@@ -65,6 +204,9 @@ __decorate([
65
204
  __decorate([
66
205
  property({ converter: numberConverter('value', undefined) })
67
206
  ], HelixHeadlessStat.prototype, "value", void 0);
207
+ __decorate([
208
+ state()
209
+ ], HelixHeadlessStat.prototype, "slottedRuns", void 0);
68
210
  HelixHeadlessStat = __decorate([
69
211
  customElement('helix-headless-stat')
70
212
  ], HelixHeadlessStat);
@@ -45,6 +45,7 @@ export declare class HelixHeadlessTableCell extends HelixElement {
45
45
  */
46
46
  private get headsRow();
47
47
  protected willUpdate(changed: PropertyValues): void;
48
+ protected firstUpdated(changed: PropertyValues): void;
48
49
  protected updated(changed: PropertyValues): void;
49
50
  /**
50
51
  * Sets the `text` state from the cell's own content.
@@ -27,6 +27,10 @@ let HelixHeadlessTableCell = class HelixHeadlessTableCell extends HelixElement {
27
27
  role: this.header ? header : this.gridCell ? 'gridcell' : 'cell',
28
28
  });
29
29
  }
30
+ firstUpdated(changed) {
31
+ super.firstUpdated(changed);
32
+ this.handleSlotChange();
33
+ }
30
34
  updated(changed) {
31
35
  super.updated(changed);
32
36
  if (changed.has('header') && changed.get('header') !== undefined) {
@@ -137,8 +137,9 @@ declare const HelixHeadlessTable_base: (new (...args: any[]) => import("@fusion.
137
137
  *
138
138
  * When the rows did not load, set `error-text`, such as "The orders did not
139
139
  * load", and put a button that tries again in the `error` slot. The line shows
140
- * after the rows in place of the empty and loading lines, the live region says
141
- * it, and the table takes the `error` state. Clear it once you try again.
140
+ * the words and then the button, after the rows in place of the empty and
141
+ * loading lines, the live region says it, and the table takes the `error`
142
+ * state. Clear it once you try again.
142
143
  *
143
144
  * The CSS custom properties listed for this component are written by it and
144
145
  * read by the stylesheet that draws it. Do not set them. Each holds a number
@@ -154,7 +155,7 @@ declare const HelixHeadlessTable_base: (new (...args: any[]) => import("@fusion.
154
155
  * @slot - The table's rows.
155
156
  * @slot columns - The columns, as `TableColumn` elements. The table moves each column here itself, so markup that runs in a browser leaves it out; a server-rendered page writes `slot="columns"` on each column so the headings sit in place before the table upgrades.
156
157
  * @slot empty - Content shown when there are no rows and none are loading, such as a picture and a link. Falls back to `empty-text`, which the live region still says.
157
- * @slot error - Content shown while `error-text` is set, such as a button that tries again. Falls back to `error-text`, which the live region still says.
158
+ * @slot error - Content shown after `error-text` while it is set, such as a button that tries again.
158
159
  * @slot heading - Words that name the table, shown above it, such as a heading.
159
160
  * @slot loading - Content shown while the rows load, such as a spinner. Falls back to `loading-text`, which the live region still says.
160
161
  *
@@ -280,9 +281,9 @@ export declare class HelixHeadlessTable extends HelixHeadlessTable_base {
280
281
  * fetch fails, and clear it once you try again. Empty, the default, shows
281
282
  * nothing.
282
283
  *
283
- * While it is set, a line after the rows shows it, or your own content in the
284
- * `error` slot, in place of the empty and loading lines, and the live region
285
- * says it.
284
+ * While it is set, a line after the rows shows it, followed by your own
285
+ * content in the `error` slot, in place of the empty and loading lines, and
286
+ * the live region says it.
286
287
  */
287
288
  errorText: string;
288
289
  /** The name of the heading over the disclosure buttons. */
@@ -909,7 +909,7 @@ let HelixHeadlessTable = class HelixHeadlessTable extends MixinCollection(HelixE
909
909
  ${room ? html `<div part="after" role="presentation" style="block-size: ${room.after}px"></div>` : nothing}
910
910
  ${this.errorText === ''
911
911
  ? this.renderStatus(this.hasRows, grid ? 'gridcell' : 'cell')
912
- : html `<p part="error" role="row"><span role=${grid ? 'gridcell' : 'cell'}><slot name="error">${this.errorText}</slot></span></p>`}
912
+ : html `<p part="error" role="row"><span role=${grid ? 'gridcell' : 'cell'}>${this.errorText}<slot name="error"></slot></span></p>`}
913
913
  </div>${end}${this.loadMore ? html `<span data-end aria-hidden="true"></span>` : nothing}${this.errorText === ''
914
914
  ? this.renderLive(this.hasRows)
915
915
  : html `<span part="live" role="status">${this.errorText}</span>`}${this.reorder.drawDragPreview()}`;
@@ -88,7 +88,7 @@ let HelixHeadlessTab = class HelixHeadlessTab extends MixinDismissible(MixinSele
88
88
  @click=${this.handleLinkClick}
89
89
  @keydown=${this.handleKeydown}
90
90
  >
91
- <slot part="label"></slot>${this.renderDismiss()}
91
+ <slot part="label" dir="auto"></slot>${this.renderDismiss()}
92
92
  </a>`;
93
93
  }
94
94
  return html `<button
@@ -102,7 +102,7 @@ let HelixHeadlessTab = class HelixHeadlessTab extends MixinDismissible(MixinSele
102
102
  @click=${() => this.select()}
103
103
  @keydown=${this.handleKeydown}
104
104
  >
105
- <slot part="label"></slot>${this.renderDismiss()}
105
+ <slot part="label" dir="auto"></slot>${this.renderDismiss()}
106
106
  </button>`;
107
107
  }
108
108
  };
@@ -80,14 +80,14 @@ let HelixHeadlessTag = class HelixHeadlessTag extends MixinDismissible(HelixElem
80
80
  }
81
81
  renderLabel() {
82
82
  if (this.href === '') {
83
- return html `<slot part="label"></slot>`;
83
+ return html `<slot part="label" dir="auto"></slot>`;
84
84
  }
85
85
  return html `<a
86
86
  aria-disabled=${this.disabled ? 'true' : nothing}
87
87
  href=${this.disabled ? nothing : this.href}
88
88
  part="link"
89
89
  tabindex=${this.grouped ? '-1' : nothing}
90
- ><slot part="label"></slot
90
+ ><slot part="label" dir="auto"></slot
91
91
  ></a>`;
92
92
  }
93
93
  renderDismiss() {
@@ -27,8 +27,8 @@ import { type PropertyValues, type TemplateResult } from 'lit';
27
27
  * and the layout only moves where they are drawn.
28
28
  *
29
29
  * **A feed that loads more entries sets `loading` while it fetches.** The
30
- * timeline is busy, and an entry after the last says "Loading more"
31
- * (`loading-text`, or your own content in the `loading` slot). Put a button
30
+ * timeline is busy, and an entry after the last says "Loading", the word every
31
+ * collection uses (`loading-text`, or your own content in the `loading` slot). Put a button
32
32
  * that asks for more after the timeline, and move focus to the first new
33
33
  * entry when they arrive.
34
34
  *
@@ -7,7 +7,7 @@ let HelixHeadlessTimeline = class HelixHeadlessTimeline extends HelixElement {
7
7
  super(...arguments);
8
8
  this.label = '';
9
9
  this.loading = false;
10
- this.loadingText = 'Loading more';
10
+ this.loadingText = 'Loading';
11
11
  }
12
12
  static { this.words = 'helix-timeline'; }
13
13
  render() {
@@ -51,12 +51,15 @@ import '../../button/index.js';
51
51
  *
52
52
  * **The stack is in the top layer.** The `region` part is a `popover="manual"`
53
53
  * shown while a message is showing, and shown again above a modal dialog that
54
- * opened after it. Position the `region` part, which is the box in the top
55
- * layer. While a modal `Dialog`, `Drawer` or `Lightbox` is open, the browser
56
- * makes everything outside it inert, the stack included, so a message stays
57
- * visible and its actions cannot be pressed. Where the browser has
58
- * `ariaNotify`, a message that arrives then is announced through it. For a
59
- * message with an action, render a second region inside the dialog.
54
+ * opened after it, and above a modal `Dialog`, `Drawer` or `Lightbox` that
55
+ * opened while it showed. Position the `region` part, which is the box in the
56
+ * top layer. While a modal is open, the browser makes everything outside it
57
+ * inert, the stack included, so a message stays visible and its actions cannot
58
+ * be pressed, and a press on a message reaches nothing under it. The stack
59
+ * moves off the modal's surface, above, below or beside it by its own inset,
60
+ * and is hidden while the window has no room outside the surface. Where the
61
+ * browser has `ariaNotify`, a message that arrives then is announced through
62
+ * it. For a message with an action, render a second region inside the dialog.
60
63
  *
61
64
  * When a message with focus inside it is dismissed, focus moves to the next
62
65
  * message, then the one before it, then back to where it was before it entered
@@ -300,6 +303,40 @@ export declare class HelixHeadlessToast extends HelixElement {
300
303
  * because showing it again starts every message's entrance over.
301
304
  */
302
305
  private place;
306
+ /**
307
+ * Moves the stack off a modal surface it would cover, or hides it where the
308
+ * window has no room outside the surface.
309
+ *
310
+ * **The stack is inert under a modal**, so a press on a message passes
311
+ * through it to what the modal holds. Measured at 390 by 844, two messages
312
+ * stood over a bottom sheet's Delete at 288,779, and a tap on the message
313
+ * fired Delete. The move that fits and is shortest wins: up or down past the
314
+ * surface's edge, or sideways past it, keeping the stack's own inset from
315
+ * the window's edge as its gap from the surface.
316
+ */
317
+ private clear;
318
+ /**
319
+ * The boxes of the open modal surfaces this stack is not inside: the
320
+ * `<dialog>` of each `Dialog`, `Drawer` and `Lightbox` holding the page, and
321
+ * an open modal `<dialog>` in the document.
322
+ */
323
+ private modalSurfaces;
324
+ /**
325
+ * Keeps a press on a message from reaching what a modal holds under it.
326
+ *
327
+ * A message under a modal is inert, so the browser hands the press to the
328
+ * element beneath. Taken in the capture phase on the window, before anything
329
+ * on the page sees it. Read only while a modal makes the stack inert.
330
+ */
331
+ private readonly handleCoveredPress;
332
+ /** Measures the stack again against a window that has changed size. */
333
+ private readonly handleResize;
334
+ /**
335
+ * Measures the stack against the modal surfaces once they have come to
336
+ * rest. A bottom sheet rises into place, and measured while it moved, the
337
+ * sheet's top was lower than where it stops.
338
+ */
339
+ private clearWhenStill;
303
340
  /**
304
341
  * Takes the stack out of the top layer once the last message has finished
305
342
  * leaving. Hidden at once, the stack would cut the exit short.
@@ -335,6 +372,16 @@ export declare class HelixHeadlessToast extends HelixElement {
335
372
  connectedCallback(): void;
336
373
  /** Takes the hotkey off the page's list of shortcuts. */
337
374
  private unregister;
375
+ /** Stops keeping the stack above the modal surfaces opened after it. */
376
+ private lower;
377
+ /**
378
+ * The stack as a box kept above every modal surface. A modal opened while a
379
+ * message showed covered the stack with its backdrop until the next message
380
+ * arrived, measured in Dialog and in Drawer, so the modal raises it again
381
+ * once it has opened, and steps over a press that lands on a message. The
382
+ * stack moves off the surface once it has opened and back once it lets go.
383
+ */
384
+ private readonly raised;
338
385
  disconnectedCallback(): void;
339
386
  protected firstUpdated(changed: PropertyValues): void;
340
387
  protected updated(changed: PropertyValues): void;