@fusion.dev/helix-headless 0.234.0 → 0.235.1
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.
- package/api.json +1 -1
- package/custom-elements.json +1 -1
- package/dist/listbox/root/listbox-root.d.ts +3 -0
- package/dist/menu/item/menu-item.d.ts +1 -1
- package/dist/menu/root/menu-root.d.ts +17 -0
- package/dist/menu/root/menu-root.js +19 -1
- package/dist/option/root/option-root.d.ts +21 -2
- package/dist/option/root/option-root.js +11 -0
- package/examples.json +1 -1
- package/lint.json +1 -1
- package/package.json +5 -5
- package/types/jsx.d.ts +23 -4
- package/types/vue.d.ts +20 -3
|
@@ -263,6 +263,9 @@ export declare class HelixHeadlessListbox extends HelixHeadlessListbox_base {
|
|
|
263
263
|
* `::part(items)` as it likes, since the keys read where each option is
|
|
264
264
|
* drawn. A list of `items` stays a stack. Left out, the list is a stack,
|
|
265
265
|
* and the host carries no attribute for it.
|
|
266
|
+
*
|
|
267
|
+
* An option with an image in its `media` slot is drawn as a tile, the image
|
|
268
|
+
* above the label, for a picker of photos or products.
|
|
266
269
|
*/
|
|
267
270
|
layout?: 'grid' | 'stack';
|
|
268
271
|
/**
|
|
@@ -64,7 +64,7 @@ import '../../kbd/index.js';
|
|
|
64
64
|
* @slot description - A line under the label that describes the row. It describes the row to a screen reader and is not part of its name.
|
|
65
65
|
* @slot end - Words after the label, such as a count or a detail, beside any `shortcut`. They describe the row and are not part of its name.
|
|
66
66
|
* @slot start - Content before the label, such as an icon.
|
|
67
|
-
* @slot submenu - The rows of a submenu that this row opens.
|
|
67
|
+
* @slot submenu - The rows of a submenu that this row opens, each a menu item placed directly in the slot.
|
|
68
68
|
*
|
|
69
69
|
* @event {HelixBeforeCheckEvent} helix-before-check - A choice row is about to be checked or unchecked, carrying the state asked for. Cancelable: cancel it to keep the row as it is.
|
|
70
70
|
* @event {HelixBeforeSelectEvent} helix-before-select - The row was chosen. Cancelable: cancel it to keep the menu open.
|
|
@@ -40,6 +40,14 @@ declare const HelixHeadlessMenu_base: (new (...args: any[]) => import("@fusion.d
|
|
|
40
40
|
* its heading. Between runs of rows, a `<helix-divider>` is a separator a
|
|
41
41
|
* screen reader announces.
|
|
42
42
|
*
|
|
43
|
+
* **A row goes directly in the menu, in a `Menu.Section`, or in another row's
|
|
44
|
+
* `submenu` slot.** The menu reads rows in those places only. A row inside an
|
|
45
|
+
* element of your own, such as a `<div>` or a component's host element, is
|
|
46
|
+
* skipped by the arrow keys, and a drilled page hides that element with the
|
|
47
|
+
* rest of the top page, so the row's submenu shows none of its rows. A
|
|
48
|
+
* development build warns about it as `wrapped-row`. In a framework, render a
|
|
49
|
+
* component's rows without a wrapper element, such as with a fragment.
|
|
50
|
+
*
|
|
43
51
|
* Keys: Enter, Space or Down Arrow on the trigger opens the menu on its first
|
|
44
52
|
* row, and Up Arrow on its last. In the menu, Up and Down Arrow move between
|
|
45
53
|
* rows, Home and End go to the first and the last, a typed letter moves to
|
|
@@ -227,6 +235,15 @@ export declare class HelixHeadlessMenu extends HelixHeadlessMenu_base {
|
|
|
227
235
|
private get topRows();
|
|
228
236
|
/** The rows of a submenu, or of the top page for null. */
|
|
229
237
|
private rowsOf;
|
|
238
|
+
/** Every row the menu reads: the top page's, and each submenu's below them. */
|
|
239
|
+
private reachedRows;
|
|
240
|
+
/**
|
|
241
|
+
* Says, in development builds, when a row sits inside an element of the
|
|
242
|
+
* page's own. The menu reads only its children, its sections' rows and each
|
|
243
|
+
* row's `submenu` slot, and a drilled page hides every child that is not a
|
|
244
|
+
* row, wrapper and all.
|
|
245
|
+
*/
|
|
246
|
+
private auditRows;
|
|
230
247
|
/** The row whose submenu holds a row, or null for a row of the top page. */
|
|
231
248
|
private holderOf;
|
|
232
249
|
/** The submenus open, from the top page down to the deepest. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { AriaForwardController, anchorElement, auditEntry, customElement, DrilldownController, deepActiveElement, deepContains, elementById, focusTarget, HelixElement, inlineStep, internalsOf, KeyboardNavigationController, linkDescription, MIRROR_RULE, MixinCollection, MixinControllerOpen, numberConverter, OpenPhaseController, onUnlessFalse, PopoverController, scrollItemIntoView, sideOf, slottedWords, tellDisclosure, typeaheadBy, unlinkDescription, untilReactHydrated, words, } from '@fusion.dev/helix-core';
|
|
2
|
+
import { AriaForwardController, anchorElement, auditEntry, auditWrapped, customElement, DrilldownController, deepActiveElement, deepContains, elementById, focusTarget, HelixElement, inlineStep, internalsOf, KeyboardNavigationController, linkDescription, MIRROR_RULE, MixinCollection, MixinControllerOpen, numberConverter, OpenPhaseController, onUnlessFalse, PopoverController, scrollItemIntoView, sideOf, slottedWords, tellDisclosure, typeaheadBy, unlinkDescription, untilReactHydrated, words, } from '@fusion.dev/helix-core';
|
|
3
3
|
import { caretLeft } from '@fusion.dev/helix-icons';
|
|
4
4
|
import { html, nothing } from 'lit';
|
|
5
5
|
import { property } from 'lit/decorators.js';
|
|
@@ -339,6 +339,23 @@ let HelixHeadlessMenu = class HelixHeadlessMenu extends MixinCollection(MixinCon
|
|
|
339
339
|
? [...holder.children].filter((child) => child.slot === 'submenu' && isItem(child))
|
|
340
340
|
: this.topRows;
|
|
341
341
|
}
|
|
342
|
+
reachedRows() {
|
|
343
|
+
const rows = [];
|
|
344
|
+
const walk = (holder) => {
|
|
345
|
+
for (const row of this.rowsOf(holder)) {
|
|
346
|
+
rows.push(row);
|
|
347
|
+
walk(row);
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
walk(null);
|
|
351
|
+
return rows;
|
|
352
|
+
}
|
|
353
|
+
auditRows() {
|
|
354
|
+
const tier = this.constructor.tier;
|
|
355
|
+
auditWrapped(this, `${tier}menu-item`, () => this.reachedRows(), (stray) => this.drilldown.hasPage(stray)
|
|
356
|
+
? 'its submenu shows none of its rows and the arrow keys skip it'
|
|
357
|
+
: 'the arrow keys skip it', `Place each <${tier}menu-item> directly in the menu, in a <${tier}menu-section>, or in the submenu slot of another row.`);
|
|
358
|
+
}
|
|
342
359
|
holderOf(row) {
|
|
343
360
|
const parent = row.parentElement;
|
|
344
361
|
return row.slot === 'submenu' && parent && isItem(parent) ? parent : null;
|
|
@@ -681,6 +698,7 @@ let HelixHeadlessMenu = class HelixHeadlessMenu extends MixinCollection(MixinCon
|
|
|
681
698
|
}
|
|
682
699
|
if (changed.has('open') && this.open) {
|
|
683
700
|
this.toldChecked = this.checkedValues.join('\u0000');
|
|
701
|
+
this.auditRows();
|
|
684
702
|
}
|
|
685
703
|
if (!this.context) {
|
|
686
704
|
this.tellTrigger();
|
|
@@ -22,11 +22,17 @@ export { isOption, optionsAmong } from '../among.js';
|
|
|
22
22
|
* nothing, as an entry in a command palette that goes to a page does.
|
|
23
23
|
*
|
|
24
24
|
* The option's name is its label alone, as React Aria's `slot="label"` makes
|
|
25
|
-
* it: what is in `start` and `
|
|
26
|
-
* drawn and not read as part of the name. The description is read as the
|
|
25
|
+
* it: what is in `start`, `end` and `media`, an avatar's initials, a shortcut
|
|
26
|
+
* or a photo, is drawn and not read as part of the name. The description is read as the
|
|
27
27
|
* option's description. A name you give with `aria-label` or
|
|
28
28
|
* `aria-labelledby` wins over both.
|
|
29
29
|
*
|
|
30
|
+
* **An image goes in `media`, above the label**, for an option drawn as a
|
|
31
|
+
* tile, such as a photo or a product in a listbox with `layout="grid"`. The
|
|
32
|
+
* row is still the option: choosing, the arrow keys and the highlight work as
|
|
33
|
+
* they do on a row with no image, and the label stays its name, so give the
|
|
34
|
+
* image an empty `alt`.
|
|
35
|
+
*
|
|
30
36
|
* @since 0.1.0
|
|
31
37
|
* @status stable
|
|
32
38
|
* @category forms
|
|
@@ -37,6 +43,7 @@ export { isOption, optionsAmong } from '../among.js';
|
|
|
37
43
|
* @slot description - A second line under the label, for content richer than the `description` text.
|
|
38
44
|
* @slot end - Content after the label, such as a shortcut or a count.
|
|
39
45
|
* @slot indicator - An icon shown while the option is chosen, in place of the check the styled option draws.
|
|
46
|
+
* @slot media - An image above the label, for an option drawn as a tile.
|
|
40
47
|
* @slot start - Content before the label, such as an icon or an avatar.
|
|
41
48
|
*
|
|
42
49
|
* @event {HelixBeforeSelectEvent} helix-before-select - The option was chosen. Cancelable: canceling it leaves the selection as it was, and keeps the browser from following an option's `href`.
|
|
@@ -51,6 +58,7 @@ export { isOption, optionsAmong } from '../among.js';
|
|
|
51
58
|
* @cssstate active - While the keyboard is on the option, which is the option `aria-activedescendant` names.
|
|
52
59
|
* @cssstate disabled - While the option cannot be chosen.
|
|
53
60
|
* @cssstate has-indicator - An icon is slotted into `indicator`.
|
|
61
|
+
* @cssstate has-media - Something is slotted into `media`.
|
|
54
62
|
* @cssstate hovered - While a mouse or a pen is over the option. A touch sets no hover, as React Aria's `data-hovered` does not.
|
|
55
63
|
* @cssstate pressing - While a pointer presses the option, from the press to the release.
|
|
56
64
|
* @cssstate selected - While the option is chosen.
|
|
@@ -275,6 +283,17 @@ export declare class HelixHeadlessOption extends HelixElement {
|
|
|
275
283
|
* consumer's markup means. What stops is the write back.
|
|
276
284
|
*/
|
|
277
285
|
protected willUpdate(changed: PropertyValues): void;
|
|
286
|
+
/**
|
|
287
|
+
* Reads whether `media` holds anything once the row is drawn, whether this
|
|
288
|
+
* element drew it or hydrated a server's.
|
|
289
|
+
*
|
|
290
|
+
* **`slotchange` alone misses a hydrated option.** A server's shadow root is
|
|
291
|
+
* parsed with the page, so its slots are filled before Lit binds the
|
|
292
|
+
* listener and the event has already gone. Measured on the hydration check in CI:
|
|
293
|
+
* a tile served that way drew its image beside the label, 569 pixels off
|
|
294
|
+
* the same tile drawn by a client.
|
|
295
|
+
*/
|
|
296
|
+
protected firstUpdated(changed: PropertyValues): void;
|
|
278
297
|
/**
|
|
279
298
|
* The name is the label part and the description the description part, by
|
|
280
299
|
* reference, because the host's own content runs `start` and `end` into its
|
|
@@ -68,6 +68,13 @@ let HelixHeadlessOption = class HelixHeadlessOption extends HelixElement {
|
|
|
68
68
|
this.toggleState('active', this.active);
|
|
69
69
|
this.toggleState('disabled', this.disabled);
|
|
70
70
|
}
|
|
71
|
+
firstUpdated(changed) {
|
|
72
|
+
super.firstUpdated(changed);
|
|
73
|
+
const media = this.renderRoot.querySelector('slot[name="media"]');
|
|
74
|
+
if (media) {
|
|
75
|
+
this.toggleState('has-media', slotFilled(media));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
71
78
|
updated(changed) {
|
|
72
79
|
super.updated(changed);
|
|
73
80
|
const named = this.hasAttribute('aria-label') || this.hasAttribute('aria-labelledby');
|
|
@@ -102,6 +109,10 @@ let HelixHeadlessOption = class HelixHeadlessOption extends HelixElement {
|
|
|
102
109
|
@pointerleave=${this.handlePointerLeave}
|
|
103
110
|
@pointerup=${this.handlePointerUp}
|
|
104
111
|
>
|
|
112
|
+
<slot
|
|
113
|
+
name="media"
|
|
114
|
+
@slotchange=${(event) => this.toggleState('has-media', slotFilled(event.target))}
|
|
115
|
+
></slot>
|
|
105
116
|
<slot name="start"></slot>
|
|
106
117
|
<span part="text">
|
|
107
118
|
<span part="label"><slot>${this.label}</slot></span>
|