@fusion.dev/helix-headless 0.235.0 → 0.236.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.
@@ -298,6 +298,7 @@ declare const HelixHeadlessDataTable_base: (new (...args: any[]) => import("@fus
298
298
  * @csspart toolbar - The region above the grid.
299
299
  *
300
300
  * @cssproperty --data-table-cell-align - The alignment of the cell's column: `start`, `center`, or `end`. Unset when the column sets none. The component writes it on each cell it draws, and the stylesheet reads it. `Table` sets `--table-cell-align` for the same purpose.
301
+ * @cssproperty --data-table-cell-block-align - Where a cell's content sits from top to bottom in a row taller than it: `start`, `center` or `end`. `center` by default. Set it on the table, or on a row through `::part(row)`; a column's `vertical-align` writes it on each of that column's cells, and wins.
301
302
  * @cssproperty --data-table-level - How deep a row is in a tree grid, from 1. The component writes it on each row header cell, and the stylesheet indents by it.
302
303
  * @cssproperty --data-table-template - The column track list, worked out from the columns. The component writes it inline on the element that reads it, so setting it has no effect. Set a column's `width` to change it.
303
304
  *
@@ -633,6 +634,10 @@ export declare class HelixHeadlessDataTable extends HelixHeadlessDataTable_base
633
634
  *
634
635
  * Wants `row-key`: a selection is a set of identities, and without one the rows
635
636
  * are known by their place in the result, which a sort changes.
637
+ *
638
+ * Reflected, because the styled tier lays the headings out by whether a
639
+ * checkbox column leads them: set as a property, as React sets it, the
640
+ * table's first heading took the inset a leading column already gives.
636
641
  */
637
642
  selectable: boolean;
638
643
  /** The name of the checkbox in the heading that selects every row. */
@@ -1288,9 +1288,11 @@ let HelixHeadlessDataTable = class HelixHeadlessDataTable extends MixinCollectio
1288
1288
  }
1289
1289
  renderCell(column, row, picked, place, stop, header, id) {
1290
1290
  const edge = edgeOf(column.textAlign);
1291
+ const block = edgeOf(column.verticalAlign);
1291
1292
  const placed = header && this.childField ? this.tree().placed.get(row) : undefined;
1292
1293
  const style = [
1293
1294
  edge ? `--data-table-cell-align: ${edge}` : '',
1295
+ block ? `--data-table-cell-block-align: ${block}` : '',
1294
1296
  placed ? `--data-table-level: ${placed.level}` : '',
1295
1297
  ]
1296
1298
  .filter(Boolean)
@@ -1996,7 +1998,7 @@ __decorate([
1996
1998
  property({ attribute: false })
1997
1999
  ], HelixHeadlessDataTable.prototype, "rows", void 0);
1998
2000
  __decorate([
1999
- property({ type: Boolean })
2001
+ property({ reflect: true, type: Boolean })
2000
2002
  ], HelixHeadlessDataTable.prototype, "selectable", void 0);
2001
2003
  __decorate([
2002
2004
  words,
@@ -284,8 +284,8 @@ export declare class HelixHeadlessOption extends HelixElement {
284
284
  */
285
285
  protected willUpdate(changed: PropertyValues): void;
286
286
  /**
287
- * Reads whether `media` holds anything once the row is drawn, whether this
288
- * element drew it or hydrated a server's.
287
+ * Reads whether `media` and `indicator` hold anything once the row is drawn,
288
+ * whether this element drew it or hydrated a server's.
289
289
  *
290
290
  * **`slotchange` alone misses a hydrated option.** A server's shadow root is
291
291
  * parsed with the page, so its slots are filled before Lit binds the
@@ -74,6 +74,10 @@ let HelixHeadlessOption = class HelixHeadlessOption extends HelixElement {
74
74
  if (media) {
75
75
  this.toggleState('has-media', slotFilled(media));
76
76
  }
77
+ const indicator = this.renderRoot.querySelector('slot[name="indicator"]');
78
+ if (indicator) {
79
+ this.toggleState('has-indicator', slotFilled(indicator));
80
+ }
77
81
  }
78
82
  updated(changed) {
79
83
  super.updated(changed);
@@ -16,6 +16,10 @@ let HelixHeadlessRadio = class HelixHeadlessRadio extends MixinSelectableItem(He
16
16
  firstUpdated(changed) {
17
17
  super.firstUpdated(changed);
18
18
  this.finishHydration();
19
+ const indicator = this.renderRoot.querySelector('slot[name="indicator"]');
20
+ if (indicator) {
21
+ this.toggleState('has-indicator', slotFilled(indicator));
22
+ }
19
23
  }
20
24
  click() {
21
25
  if (!this.clicks.click()) {
@@ -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);
@@ -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);