@fusion.dev/helix-headless 0.235.1 → 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 (126) 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 +15 -7
  19. package/dist/data-table/root/data-table-root.js +9 -2
  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 +16 -2
  64. package/dist/option/root/option-root.js +7 -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/radio/root/radio-root.js +4 -0
  71. package/dist/rating/root/rating-root.d.ts +1 -0
  72. package/dist/rating/root/rating-root.js +1 -0
  73. package/dist/scatter-chart/root/scatter-chart-root.d.ts +6 -0
  74. package/dist/select/root/select-root.d.ts +27 -1
  75. package/dist/select/root/select-root.js +34 -3
  76. package/dist/shortcut-overlay/root/shortcut-overlay-root.d.ts +5 -0
  77. package/dist/shortcut-overlay/root/shortcut-overlay-root.js +15 -1
  78. package/dist/skeleton/root/skeleton-root.d.ts +1 -0
  79. package/dist/skeleton/root/skeleton-root.js +3 -0
  80. package/dist/sparkline/root/sparkline-root.d.ts +53 -0
  81. package/dist/sparkline/root/sparkline-root.js +37 -1
  82. package/dist/spatial-bar-chart/root/spatial-bar-chart-root.d.ts +4 -1
  83. package/dist/spatial-bar-chart/root/spatial-bar-chart-root.js +2 -2
  84. package/dist/spatial-ribbon-chart/root/spatial-ribbon-chart-root.d.ts +3 -0
  85. package/dist/spatial-ribbon-chart/root/spatial-ribbon-chart-root.js +2 -2
  86. package/dist/spatial-scatter-chart/root/spatial-scatter-chart-root.d.ts +3 -0
  87. package/dist/spatial-scatter-chart/root/spatial-scatter-chart-root.js +2 -2
  88. package/dist/spatial-scatter-chart/view.d.ts +17 -8
  89. package/dist/spatial-scatter-chart/view.js +7 -6
  90. package/dist/spatial-surface-chart/root/spatial-surface-chart-root.d.ts +3 -0
  91. package/dist/spatial-surface-chart/root/spatial-surface-chart-root.js +2 -2
  92. package/dist/spatial-treemap/root/spatial-treemap-root.d.ts +3 -0
  93. package/dist/spatial-treemap/root/spatial-treemap-root.js +2 -2
  94. package/dist/splitter/root/splitter-root.js +3 -1
  95. package/dist/stat/group/stat-group.d.ts +13 -0
  96. package/dist/stat/group/stat-group.js +22 -1
  97. package/dist/stat/root/stat-root.d.ts +62 -1
  98. package/dist/stat/root/stat-root.js +146 -4
  99. package/dist/table/cell/table-cell.d.ts +1 -0
  100. package/dist/table/cell/table-cell.js +4 -0
  101. package/dist/table/column/table-column.d.ts +11 -0
  102. package/dist/table/column/table-column.js +4 -0
  103. package/dist/table/root/table-root.d.ts +7 -6
  104. package/dist/table/root/table-root.js +1 -1
  105. package/dist/tabs/panel/tab-panel.d.ts +30 -0
  106. package/dist/tabs/panel/tab-panel.js +28 -3
  107. package/dist/tabs/root/tabs-root.d.ts +8 -0
  108. package/dist/tabs/root/tabs-root.js +8 -2
  109. package/dist/tabs/tab/tab.js +2 -2
  110. package/dist/tag/root/tag-root.js +2 -2
  111. package/dist/timeline/root/timeline-root.d.ts +2 -2
  112. package/dist/timeline/root/timeline-root.js +1 -1
  113. package/dist/toast/root/toast-root.d.ts +53 -6
  114. package/dist/toast/root/toast-root.js +158 -1
  115. package/dist/toggle/root/toggle-root.d.ts +1 -0
  116. package/dist/toggle/root/toggle-root.js +1 -1
  117. package/dist/video-playlist/root/video-playlist-root.d.ts +1 -0
  118. package/dist/video-playlist/root/video-playlist-root.js +2 -0
  119. package/dist/virtual-list/root/virtual-list-root.d.ts +2 -2
  120. package/dist/virtual-list/root/virtual-list-root.js +1 -1
  121. package/examples.json +1 -1
  122. package/lint.json +1 -1
  123. package/package.json +5 -5
  124. package/types/jsx.d.ts +693 -169
  125. package/types/vue.d.ts +423 -96
  126. package/types/words.d.ts +51 -12
@@ -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) {
@@ -244,6 +244,17 @@ export declare class HelixHeadlessTableColumn extends HelixElement {
244
244
  * state instead. No default, so an unset column writes nothing onto its host.
245
245
  */
246
246
  textAlign?: 'center' | 'end' | 'start';
247
+ /**
248
+ * Where the content of this column's cells sits from top to bottom, when a
249
+ * row is taller than it: `start`, `center` or `end`.
250
+ *
251
+ * **Unset follows the table**, which centers, so a line of text beside a
252
+ * taller grip, tag or button sits on the row's middle rather than riding at
253
+ * its top. `start` keeps a column of long, wrapping text against the top
254
+ * edge, where a reader begins it. Reflected and written to each cell as
255
+ * `text-align` is, for the same reasons.
256
+ */
257
+ verticalAlign?: 'center' | 'end' | 'start';
247
258
  /**
248
259
  * The track this column takes, as CSS.
249
260
  *
@@ -154,6 +154,7 @@ let HelixHeadlessTableColumn = class HelixHeadlessTableColumn extends HelixEleme
154
154
  if (changed.has('menu') ||
155
155
  changed.has('minTableWidth') ||
156
156
  changed.has('textAlign') ||
157
+ changed.has('verticalAlign') ||
157
158
  changed.has('width')) {
158
159
  this.tellHolder();
159
160
  }
@@ -275,6 +276,9 @@ __decorate([
275
276
  __decorate([
276
277
  property({ attribute: 'text-align', reflect: true })
277
278
  ], HelixHeadlessTableColumn.prototype, "textAlign", void 0);
279
+ __decorate([
280
+ property({ attribute: 'vertical-align', reflect: true })
281
+ ], HelixHeadlessTableColumn.prototype, "verticalAlign", void 0);
278
282
  __decorate([
279
283
  property()
280
284
  ], HelixHeadlessTableColumn.prototype, "width", void 0);
@@ -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()}`;
@@ -8,6 +8,15 @@ import { type PropertyValues, type TemplateResult } from 'lit';
8
8
  * still there when the person comes back, and the content of every panel is in
9
9
  * the server-rendered markup for crawlers, whichever tab is open.
10
10
  *
11
+ * The browser's find in page searches an inactive panel, and a match selects
12
+ * its tab, with `helix-before-activate` first, as a match in a closed
13
+ * accordion section opens it. An inactive panel is `hidden="until-found"`,
14
+ * which hides it with no stylesheet loaded and keeps it out of the tab order
15
+ * and the accessibility tree. Set `hidden-until-found="false"` on the panel,
16
+ * or on the tabs for every panel, and an inactive panel is `hidden` instead,
17
+ * and find in page skips it. A `lazy` panel that has not been shown holds only
18
+ * its template, so there is nothing in it to find.
19
+ *
11
20
  * The host is the `tabpanel` while its tab is selected, through
12
21
  * `ElementInternals`, so the tab's `aria-controls` can reach it from the tab's
13
22
  * shadow root. The box inside is a tab stop only while the panel holds nothing
@@ -36,6 +45,15 @@ import { type PropertyValues, type TemplateResult } from 'lit';
36
45
  * @cssstate selected - While its tab is the one selected.
37
46
  */
38
47
  export declare class HelixHeadlessTabPanel extends HelixElement {
48
+ /**
49
+ * Whether find in page searches the panel while its tab is not selected, and
50
+ * selects the tab on a match.
51
+ *
52
+ * Unset takes the tabs' `hidden-until-found`, which is on. Write
53
+ * `hidden-until-found="false"` to keep find in page out of this panel: an
54
+ * inactive panel is then `hidden`.
55
+ */
56
+ hiddenUntilFound?: boolean;
39
57
  /**
40
58
  * Whether the panel's content waits in a `<template>` until the panel is
41
59
  * first shown.
@@ -66,6 +84,18 @@ export declare class HelixHeadlessTabPanel extends HelixElement {
66
84
  private readonly readStops;
67
85
  connectedCallback(): void;
68
86
  disconnectedCallback(): void;
87
+ /** Whether find in page searches this panel while it is not selected. */
88
+ private get findable();
89
+ /**
90
+ * Selects this panel's tab when find in page matches inside it, before the
91
+ * match is shown.
92
+ *
93
+ * A refusal puts `hidden` back, so the tab and the panel still agree. The
94
+ * browser removes the attribute after this event's listeners have returned,
95
+ * and after the microtasks they queued, so a mutation observer is what hears
96
+ * the removal, as on the accordion item.
97
+ */
98
+ private readonly handleBeforeMatch;
69
99
  protected updated(changed: PropertyValues): void;
70
100
  /**
71
101
  * Mirrors the chosen state where a stylesheet can select on it.
@@ -1,10 +1,11 @@
1
1
  import { __decorate } from "tslib";
2
- import { customElement, focusableElements, HelixElement, HelixLoadEvent, hostAria, internalsOf, } from '@fusion.dev/helix-core';
2
+ import { customElement, focusableElements, HelixElement, HelixLoadEvent, hostAria, internalsOf, onUnlessFalse, } from '@fusion.dev/helix-core';
3
3
  import { html, nothing } from 'lit';
4
4
  import { property, state } from 'lit/decorators.js';
5
5
  let HelixHeadlessTabPanel = class HelixHeadlessTabPanel extends HelixElement {
6
6
  constructor() {
7
7
  super(...arguments);
8
+ this.groupHiddenUntilFound = true;
8
9
  this.label = '';
9
10
  this.lazy = false;
10
11
  this.loaded = false;
@@ -17,6 +18,19 @@ let HelixHeadlessTabPanel = class HelixHeadlessTabPanel extends HelixElement {
17
18
  this.readStops = () => {
18
19
  this.holdsStop = this.selected && focusableElements(this).length > 0;
19
20
  };
21
+ this.handleBeforeMatch = (event) => {
22
+ if (this.selected || this.requestShow?.() === true) {
23
+ return;
24
+ }
25
+ const panel = event.currentTarget;
26
+ const observer = new MutationObserver(() => {
27
+ observer.disconnect();
28
+ if (!this.selected && !panel.hasAttribute('hidden')) {
29
+ panel.setAttribute('hidden', this.findable ? 'until-found' : '');
30
+ }
31
+ });
32
+ observer.observe(panel, { attributeFilter: ['hidden'] });
33
+ };
20
34
  }
21
35
  load() {
22
36
  if (!this.lazy || !this.selected || this.loaded) {
@@ -44,6 +58,9 @@ let HelixHeadlessTabPanel = class HelixHeadlessTabPanel extends HelixElement {
44
58
  super.disconnectedCallback();
45
59
  this.watcher?.disconnect();
46
60
  }
61
+ get findable() {
62
+ return this.hiddenUntilFound ?? this.groupHiddenUntilFound;
63
+ }
47
64
  updated(changed) {
48
65
  super.updated(changed);
49
66
  if (changed.has('selected') || changed.has('lazy')) {
@@ -61,13 +78,21 @@ let HelixHeadlessTabPanel = class HelixHeadlessTabPanel extends HelixElement {
61
78
  render() {
62
79
  return html `<div
63
80
  part="panel"
64
- ?hidden=${!this.selected}
65
- tabindex=${this.holdsStop ? nothing : '0'}
81
+ aria-hidden=${this.selected ? nothing : 'true'}
82
+ hidden=${this.selected ? nothing : this.findable ? 'until-found' : ''}
83
+ tabindex=${!this.selected || this.holdsStop ? nothing : '0'}
84
+ @beforematch=${this.handleBeforeMatch}
66
85
  >
67
86
  <slot @slotchange=${this.readStops}></slot>
68
87
  </div>`;
69
88
  }
70
89
  };
90
+ __decorate([
91
+ property({ attribute: false })
92
+ ], HelixHeadlessTabPanel.prototype, "groupHiddenUntilFound", void 0);
93
+ __decorate([
94
+ property({ attribute: 'hidden-until-found', converter: onUnlessFalse })
95
+ ], HelixHeadlessTabPanel.prototype, "hiddenUntilFound", void 0);
71
96
  __decorate([
72
97
  property({ attribute: false })
73
98
  ], HelixHeadlessTabPanel.prototype, "label", void 0);
@@ -107,6 +107,14 @@ export declare class HelixHeadlessTabs extends HelixHeadlessTabs_base {
107
107
  private readonly indicator;
108
108
  /** Carries a host `aria-label` and `aria-labelledby` to the tab list. */
109
109
  protected readonly aria: AriaForwardController;
110
+ /**
111
+ * Whether find in page searches the panels whose tabs are not selected, and
112
+ * selects the tab on a match. On by default.
113
+ *
114
+ * Write `hidden-until-found="false"` to turn it off for every panel; a
115
+ * panel's own `hidden-until-found` wins for that panel.
116
+ */
117
+ hiddenUntilFound: boolean;
110
118
  /**
111
119
  * The tab list's name, read by screen readers.
112
120
  *
@@ -1,5 +1,5 @@
1
1
  import { __decorate } from "tslib";
2
- import { AriaForwardController, auditName, customElement, deepActiveElement, glyphPath, HelixActivateEvent, HelixElement, IndicatorController, isRtl, KeyboardNavigationController, MIRROR_RULE, MixinControllerActive, scrollWithin, whenHydrated, } from '@fusion.dev/helix-core';
2
+ import { AriaForwardController, auditName, customElement, deepActiveElement, glyphPath, HelixActivateEvent, HelixElement, IndicatorController, isRtl, KeyboardNavigationController, MIRROR_RULE, MixinControllerActive, onUnlessFalse, scrollWithin, whenHydrated, } from '@fusion.dev/helix-core';
3
3
  import { caretDown, caretLeft, caretRight, caretUp } from '@fusion.dev/helix-icons';
4
4
  import { html, nothing } from 'lit';
5
5
  import { property, state } from 'lit/decorators.js';
@@ -23,6 +23,7 @@ let HelixHeadlessTabs = class HelixHeadlessTabs extends MixinControllerActive(He
23
23
  label: true,
24
24
  target: () => this.partNamed('tabs'),
25
25
  });
26
+ this.hiddenUntilFound = true;
26
27
  this.label = '';
27
28
  this.manual = false;
28
29
  this.scrollControls = false;
@@ -126,7 +127,9 @@ let HelixHeadlessTabs = class HelixHeadlessTabs extends MixinControllerActive(He
126
127
  for (const panel of this.panels) {
127
128
  const selected = panel.value === value;
128
129
  const label = names.get(panel.value) ?? '';
130
+ panel.requestShow = () => this.requestActive(panel.value);
129
131
  whenHydrated(panel, () => {
132
+ panel.groupHiddenUntilFound = this.hiddenUntilFound;
130
133
  panel.selected = selected;
131
134
  panel.label = label;
132
135
  });
@@ -197,7 +200,7 @@ let HelixHeadlessTabs = class HelixHeadlessTabs extends MixinControllerActive(He
197
200
  }
198
201
  updated(changed) {
199
202
  super.updated(changed);
200
- if (changed.has('active')) {
203
+ if (changed.has('active') || (this.hasUpdated && changed.has('hiddenUntilFound'))) {
201
204
  this.sync();
202
205
  if (changed.get('active') !== undefined) {
203
206
  void this.updateComplete.then(() => this.reveal());
@@ -242,6 +245,9 @@ let HelixHeadlessTabs = class HelixHeadlessTabs extends MixinControllerActive(He
242
245
  <div part="panels"><slot name="panels" @slotchange=${this.handleSlotChange}></slot></div>`;
243
246
  }
244
247
  };
248
+ __decorate([
249
+ property({ attribute: 'hidden-until-found', converter: onUnlessFalse })
250
+ ], HelixHeadlessTabs.prototype, "hiddenUntilFound", void 0);
245
251
  __decorate([
246
252
  property()
247
253
  ], HelixHeadlessTabs.prototype, "label", void 0);
@@ -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;