@fusion.dev/helix-headless 0.171.0 → 0.172.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.
- package/custom-elements.json +439 -65
- package/dist/chat/composer/chat-composer.d.ts +28 -1
- package/dist/chat/composer/chat-composer.js +22 -3
- package/dist/chat/root/chat-root.d.ts +38 -2
- package/dist/chat/root/chat-root.js +38 -1
- package/dist/color-input/root/color-input-root.d.ts +15 -1
- package/dist/color-input/root/color-input-root.js +19 -1
- package/dist/color-picker/root/color-picker-root.d.ts +5 -1
- package/dist/color-picker/root/color-picker-root.js +1 -1
- package/dist/data-table/root/data-table-root.d.ts +5 -1
- package/dist/data-table/root/data-table-root.js +1 -0
- package/dist/dialog/root/dialog-root.js +1 -0
- package/dist/drawer/root/drawer-root.d.ts +4 -0
- package/dist/drawer/root/drawer-root.js +1 -0
- package/dist/element-events.generated.js +1 -0
- package/dist/lightbox/root/lightbox-root.js +1 -0
- package/dist/listbox/root/listbox-root.d.ts +2 -1
- package/dist/listbox/root/listbox-root.js +3 -2
- package/dist/menu/item/menu-item.d.ts +2 -0
- package/dist/menu/item/menu-item.js +2 -0
- package/dist/menu/root/menu-root.d.ts +73 -12
- package/dist/menu/root/menu-root.js +103 -7
- package/dist/popover/root/popover-root.d.ts +59 -6
- package/dist/popover/root/popover-root.js +51 -3
- package/dist/select/root/select-root.d.ts +2 -2
- package/dist/select/root/select-root.js +2 -2
- package/dist/textarea/root/textarea-root.d.ts +8 -0
- package/dist/textarea/root/textarea-root.js +16 -0
- package/lint.json +1 -1
- package/package.json +5 -5
- package/types/jsx.d.ts +312 -30
- package/types/vue.d.ts +59 -8
- package/types/words.d.ts +8 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AriaForwardController, HelixElement, KeyboardNavigationController, type Placement } from '@fusion.dev/helix-core';
|
|
1
|
+
import { AriaForwardController, HelixElement, KeyboardNavigationController, OpenPhaseController, type Placement } from '@fusion.dev/helix-core';
|
|
2
2
|
import { type PropertyValues, type TemplateResult } from 'lit';
|
|
3
3
|
declare const HelixHeadlessMenu_base: (new (...args: any[]) => import("@fusion.dev/helix-core").CollectionElement) & (new (...args: any[]) => import("@fusion.dev/helix-core").MixinControllerOpenInterface) & typeof HelixElement;
|
|
4
4
|
/**
|
|
@@ -18,7 +18,9 @@ declare const HelixHeadlessMenu_base: (new (...args: any[]) => import("@fusion.d
|
|
|
18
18
|
*
|
|
19
19
|
* Submenus drill down by default. A submenu replaces the panel's content, and a
|
|
20
20
|
* back row returns to the previous page. One panel stays inside a narrow
|
|
21
|
-
* window, and works on touch screens, which have no hover.
|
|
21
|
+
* window, and works on touch screens, which have no hover. Focus follows a
|
|
22
|
+
* mouse resting on a row in either mode, and a drilled page is a `menu` named
|
|
23
|
+
* by the row that opened it.
|
|
22
24
|
*
|
|
23
25
|
* **`submenus="flyout"` opens each submenu in a panel of its own beside its
|
|
24
26
|
* row**, as React Aria's `SubmenuTrigger` and Radix's `Sub` do. Resting the
|
|
@@ -52,6 +54,11 @@ declare const HelixHeadlessMenu_base: (new (...args: any[]) => import("@fusion.d
|
|
|
52
54
|
* trigger's width, for a menu as wide as its trigger:
|
|
53
55
|
* `helix-menu::part(surface) { min-inline-size: var(--floating-anchor-inline-size) }`.
|
|
54
56
|
*
|
|
57
|
+
* **The choices in one place.** `checkedValues` holds the values of the rows
|
|
58
|
+
* that are checked, anywhere in the menu, and setting it checks exactly
|
|
59
|
+
* those rows, as React Aria's `selectedKeys` does. `change` is sent on the
|
|
60
|
+
* menu when a reader's choice changes it.
|
|
61
|
+
*
|
|
55
62
|
* With `context`, the trigger is an area and the menu is its context menu: a
|
|
56
63
|
* right-click, a long press, Shift+F10 or the menu key over the area opens it
|
|
57
64
|
* at the pointer, or at the area's corner from the keyboard, as Radix's context
|
|
@@ -74,7 +81,8 @@ declare const HelixHeadlessMenu_base: (new (...args: any[]) => import("@fusion.d
|
|
|
74
81
|
* field: Up and Down Arrow move the highlight through the rows that are left,
|
|
75
82
|
* Enter chooses the highlighted row, Right Arrow opens its submenu, Left Arrow
|
|
76
83
|
* on a submenu goes back, and Escape clears the filter and then closes the
|
|
77
|
-
* menu.
|
|
84
|
+
* menu. A screen reader hears how many rows the filter keeps
|
|
85
|
+
* (`results-label`). Home, End and the other keys move the caret and type. The field names
|
|
78
86
|
* the highlighted row with `aria-activedescendant`, and the rows are a `menu`
|
|
79
87
|
* after the field. Cancel `helix-filter` to keep every row
|
|
80
88
|
* showing and narrow the rows yourself, such as by replacing them with rows
|
|
@@ -87,9 +95,12 @@ declare const HelixHeadlessMenu_base: (new (...args: any[]) => import("@fusion.d
|
|
|
87
95
|
* @documentation https://fusion.dev/helix/components/menu
|
|
88
96
|
*
|
|
89
97
|
* @slot - The items.
|
|
98
|
+
* @slot empty - What the menu shows when it has no items, for content richer than `empty-text`.
|
|
99
|
+
* @slot loading - What the menu shows while its items load, for content richer than `loading-text`.
|
|
90
100
|
* @slot no-results - What the menu shows when the filter keeps no rows, for content richer than `no-results-text`.
|
|
91
101
|
* @slot trigger - The control that opens the menu, or with `context` the area a context menu opens over.
|
|
92
102
|
*
|
|
103
|
+
* @event {Event} change - A reader's choice checked or unchecked rows. Read `checkedValues` for the rows that are checked now.
|
|
93
104
|
* @event {HelixBeforeCloseEvent} helix-before-close - The menu is about to close. Cancelable: cancel it to keep it open.
|
|
94
105
|
* @event {HelixBeforeOpenEvent} helix-before-open - The menu is about to open. Cancelable: cancel it to keep it closed.
|
|
95
106
|
* @event {HelixFilterEvent} helix-filter - The text in the filter field changed, with the new text in `detail.value`. Cancelable: cancel it to keep every row showing and narrow the rows yourself.
|
|
@@ -110,6 +121,8 @@ declare const HelixHeadlessMenu_base: (new (...args: any[]) => import("@fusion.d
|
|
|
110
121
|
* @cssproperty --floating-available-block-size - The room between the panel and the edge of the screen it opens toward, written on the panel while it is open. Read it; a value set here is written over.
|
|
111
122
|
*
|
|
112
123
|
* @cssstate drilled - A submenu's page is showing, so content that is not a row can hide with the top page.
|
|
124
|
+
* @cssstate entering - From the moment the panel shows until its entrance has finished.
|
|
125
|
+
* @cssstate exiting - From the moment the panel hides until its exit has finished.
|
|
113
126
|
* @cssstate mark - A row on the current page has a checkbox or a link, so every row keeps the trailing column.
|
|
114
127
|
* @cssstate open - While the menu is open.
|
|
115
128
|
* @cssstate placed-bottom - While the open panel sits below its trigger.
|
|
@@ -124,6 +137,7 @@ export declare class HelixHeadlessMenu extends HelixHeadlessMenu_base {
|
|
|
124
137
|
* `registerWords('de', { 'helix-menu': { backLabel: 'Zurück' } })`.
|
|
125
138
|
*/
|
|
126
139
|
static words: string;
|
|
140
|
+
protected statusSlots: boolean;
|
|
127
141
|
/**
|
|
128
142
|
* The text of the row that returns from a submenu.
|
|
129
143
|
*/
|
|
@@ -204,6 +218,12 @@ export declare class HelixHeadlessMenu extends HelixHeadlessMenu_base {
|
|
|
204
218
|
* Space between the trigger and the surface, in pixels.
|
|
205
219
|
*/
|
|
206
220
|
offset: number;
|
|
221
|
+
/**
|
|
222
|
+
* What opens the menu from its trigger. `long-press` leaves a press to the
|
|
223
|
+
* trigger's own action and opens the menu on a press held for half a second,
|
|
224
|
+
* or on Alt+Down or Alt+Up.
|
|
225
|
+
*/
|
|
226
|
+
openOn: 'click' | 'long-press';
|
|
207
227
|
/** Whether the trigger opens the menu only on a held press. */
|
|
208
228
|
private get pressHeld();
|
|
209
229
|
/**
|
|
@@ -213,18 +233,18 @@ export declare class HelixHeadlessMenu extends HelixHeadlessMenu_base {
|
|
|
213
233
|
private readonly longPress;
|
|
214
234
|
/** Where a held press on a context menu's area is, to open the menu there. */
|
|
215
235
|
private heldAt;
|
|
216
|
-
/**
|
|
217
|
-
* What opens the menu from its trigger. `long-press` leaves a press to the
|
|
218
|
-
* trigger's own action and opens the menu on a press held for half a second,
|
|
219
|
-
* or on Alt+Down or Alt+Up.
|
|
220
|
-
*/
|
|
221
|
-
openOn: 'click' | 'long-press';
|
|
222
236
|
/**
|
|
223
237
|
* The side the menu opens on, when there is room.
|
|
224
238
|
*
|
|
225
239
|
* It moves if that side does not fit.
|
|
226
240
|
*/
|
|
227
241
|
placement: Placement;
|
|
242
|
+
/**
|
|
243
|
+
* What a screen reader hears when the filter narrows the rows. `{count}` is
|
|
244
|
+
* how many rows are left, written in the locale, and each language writes
|
|
245
|
+
* the forms it has, as Listbox's `results-label` does.
|
|
246
|
+
*/
|
|
247
|
+
resultsLabel: string;
|
|
228
248
|
/**
|
|
229
249
|
* How a submenu opens. `drill` shows it in place of the page showing, with
|
|
230
250
|
* a way back. `flyout` opens it in a panel of its own beside its row.
|
|
@@ -257,6 +277,7 @@ export declare class HelixHeadlessMenu extends HelixHeadlessMenu_base {
|
|
|
257
277
|
* menu that drills, so those keys are spoken for here rather than unhandled.
|
|
258
278
|
*/
|
|
259
279
|
protected readonly keys: KeyboardNavigationController;
|
|
280
|
+
protected readonly phases: OpenPhaseController;
|
|
260
281
|
/** Carries a host `aria-label` and `aria-labelledby` to the surface. */
|
|
261
282
|
protected readonly aria: AriaForwardController;
|
|
262
283
|
/** Where a context menu was asked for, in the viewport, while it is open. */
|
|
@@ -310,6 +331,21 @@ export declare class HelixHeadlessMenu extends HelixHeadlessMenu_base {
|
|
|
310
331
|
* it, the one direction a reference crosses.
|
|
311
332
|
*/
|
|
312
333
|
private reach;
|
|
334
|
+
/** Watches for rows taken away while the menu is open. */
|
|
335
|
+
private rowWatch;
|
|
336
|
+
/**
|
|
337
|
+
* Moves the reader to a neighbor when the page takes away the row they were
|
|
338
|
+
* on: the row that took its place, or the one before it where it was the
|
|
339
|
+
* last. A menu with no rows left closes and gives focus to its trigger.
|
|
340
|
+
*
|
|
341
|
+
* **Focus went to the body**, and the menu then ignored every key, its
|
|
342
|
+
* listener being on the host: measured in Chromium, removing the focused
|
|
343
|
+
* row and pressing ArrowUp did nothing. List and Virtual List move focus to
|
|
344
|
+
* a neighbor the same way, as React Aria's collections do. With `filterable`,
|
|
345
|
+
* focus stays in the field and the highlight moves. Focus a reader put
|
|
346
|
+
* anywhere but the body is left there.
|
|
347
|
+
*/
|
|
348
|
+
private readonly followRemoved;
|
|
313
349
|
/** Opens the menu. */
|
|
314
350
|
show(): void;
|
|
315
351
|
/** Opens the menu with focus on its first or its last row. */
|
|
@@ -327,6 +363,23 @@ export declare class HelixHeadlessMenu extends HelixHeadlessMenu_base {
|
|
|
327
363
|
private enter;
|
|
328
364
|
/** Returns to the page above, or closes when there is none. */
|
|
329
365
|
private leave;
|
|
366
|
+
/** The choice rows anywhere in the menu, in document order. */
|
|
367
|
+
private get choiceRows();
|
|
368
|
+
/**
|
|
369
|
+
* The values of the choice rows that are checked, anywhere in the menu, in
|
|
370
|
+
* document order.
|
|
371
|
+
*
|
|
372
|
+
* Set it to check exactly those rows and uncheck every other choice row, as
|
|
373
|
+
* React Aria's `selectedKeys` controls a menu's selection from one place.
|
|
374
|
+
* Each row keeps its own `checked` too, which this reads and writes. `change`
|
|
375
|
+
* is sent on the menu when a reader's choice changes it.
|
|
376
|
+
*/
|
|
377
|
+
get checkedValues(): string[];
|
|
378
|
+
set checkedValues(values: readonly string[]);
|
|
379
|
+
/** The checked values `change` last said, joined, so a choice that moved nothing says nothing. */
|
|
380
|
+
private toldChecked;
|
|
381
|
+
/** Sends `change` when a reader's choice has changed which rows are checked. */
|
|
382
|
+
private tellChecked;
|
|
330
383
|
private readonly handleSelect;
|
|
331
384
|
/**
|
|
332
385
|
* Keeps whatever has focus in sight, however it got there.
|
|
@@ -390,9 +443,14 @@ export declare class HelixHeadlessMenu extends HelixHeadlessMenu_base {
|
|
|
390
443
|
private grace;
|
|
391
444
|
private stopHover;
|
|
392
445
|
/**
|
|
393
|
-
* A mouse resting on a row
|
|
394
|
-
* moment the row's submenu opens, or the submenus below the row's own page
|
|
446
|
+
* A mouse resting on a row: focus follows it, and under `flyout`, after a
|
|
447
|
+
* moment, the row's submenu opens, or the submenus below the row's own page
|
|
395
448
|
* close. Not while the pointer is crossing toward an open submenu.
|
|
449
|
+
*
|
|
450
|
+
* **In every mode**, as the APG's menus, React Aria's and Radix's have it.
|
|
451
|
+
* Under `drill` the pointer did not move focus, so the row under the
|
|
452
|
+
* pointer and the row the keys moved from were two rows, measured in
|
|
453
|
+
* Chromium: hovering Delete left focus on Cut.
|
|
396
454
|
*/
|
|
397
455
|
private readonly handleHover;
|
|
398
456
|
/** The pointer leaving a row whose submenu is open, which starts the grace area. */
|
|
@@ -402,8 +460,11 @@ export declare class HelixHeadlessMenu extends HelixHeadlessMenu_base {
|
|
|
402
460
|
connectedCallback(): void;
|
|
403
461
|
disconnectedCallback(): void;
|
|
404
462
|
protected updated(changed: PropertyValues): void;
|
|
463
|
+
/** Whether the surface is named by a submenu's page, which `nameSurface` undoes at the top. */
|
|
464
|
+
private namedByPage;
|
|
405
465
|
/**
|
|
406
|
-
* Names the surface by its trigger, where nothing else names it
|
|
466
|
+
* Names the surface by its trigger, where nothing else names it, and a
|
|
467
|
+
* submenu's page by its title.
|
|
407
468
|
*
|
|
408
469
|
* By element reference, which is the one direction that crosses: the surface
|
|
409
470
|
* is in this shadow root and the trigger is in the tree around it. A host
|
|
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { AriaForwardController, anchorElement, customElement, DrilldownController, deepActiveElement, deepContains, filterKeeps, focusTarget, HelixElement, HelixFilterEvent, inlineStep, KeyboardNavigationController, linkDescription, MixinCollection, MixinControllerOpen, markMatches, onUnlessFalse, PopoverController, scrollItemIntoView, sideOf, slottedWords, tellDisclosure, typeaheadBy, unlinkDescription, words, } from '@fusion.dev/helix-core';
|
|
7
|
+
import { AriaForwardController, anchorElement, customElement, DrilldownController, deepActiveElement, deepContains, filterKeeps, focusTarget, formatWords, HelixElement, HelixFilterEvent, inlineStep, KeyboardNavigationController, linkDescription, MixinCollection, MixinControllerOpen, markMatches, OpenPhaseController, onUnlessFalse, PopoverController, scrollItemIntoView, sideOf, slottedWords, tellDisclosure, typeaheadBy, unlinkDescription, words, } from '@fusion.dev/helix-core';
|
|
8
8
|
import { caretLeft } from '@fusion.dev/helix-icons';
|
|
9
9
|
import { html, nothing } from 'lit';
|
|
10
10
|
import { property } from 'lit/decorators.js';
|
|
@@ -30,6 +30,7 @@ const isSection = (element) => 'isMenuSection' in element && element.isMenuSecti
|
|
|
30
30
|
let HelixHeadlessMenu = class HelixHeadlessMenu extends MixinCollection(MixinControllerOpen(HelixElement)) {
|
|
31
31
|
constructor() {
|
|
32
32
|
super(...arguments);
|
|
33
|
+
this.statusSlots = true;
|
|
33
34
|
this.backLabel = 'Back';
|
|
34
35
|
this.closeOnSelect = true;
|
|
35
36
|
this.context = false;
|
|
@@ -40,6 +41,7 @@ let HelixHeadlessMenu = class HelixHeadlessMenu extends MixinCollection(MixinCon
|
|
|
40
41
|
this.longPressLabel = 'Long press or press Alt+Down to show the menu';
|
|
41
42
|
this.noResultsText = 'No matches';
|
|
42
43
|
this.offset = 4;
|
|
44
|
+
this.openOn = 'click';
|
|
43
45
|
this.longPress = new LongPress(this, {
|
|
44
46
|
onLongPress: () => {
|
|
45
47
|
if (this.context) {
|
|
@@ -54,8 +56,8 @@ let HelixHeadlessMenu = class HelixHeadlessMenu extends MixinCollection(MixinCon
|
|
|
54
56
|
}
|
|
55
57
|
},
|
|
56
58
|
});
|
|
57
|
-
this.openOn = 'click';
|
|
58
59
|
this.placement = 'bottom-start';
|
|
60
|
+
this.resultsLabel = '{count, plural, one {# result} other {# results}}';
|
|
59
61
|
this.submenus = 'drill';
|
|
60
62
|
this.drilldown = new DrilldownController(this, {
|
|
61
63
|
isRow: (element) => 'isMenuItem' in element && element.isMenuItem === true,
|
|
@@ -70,6 +72,14 @@ let HelixHeadlessMenu = class HelixHeadlessMenu extends MixinCollection(MixinCon
|
|
|
70
72
|
selects: () => false,
|
|
71
73
|
typeahead: typeaheadBy((item) => slottedWords(item, [''])),
|
|
72
74
|
});
|
|
75
|
+
this.phases = new OpenPhaseController(this, {
|
|
76
|
+
mark: {
|
|
77
|
+
entering: (on) => this.toggleState('entering', on),
|
|
78
|
+
exiting: (on) => this.toggleState('exiting', on),
|
|
79
|
+
},
|
|
80
|
+
open: () => this.open,
|
|
81
|
+
surface: () => this.partNamed('surface'),
|
|
82
|
+
});
|
|
73
83
|
this.aria = new AriaForwardController(this, {
|
|
74
84
|
label: true,
|
|
75
85
|
target: () => this.menuBox,
|
|
@@ -98,6 +108,37 @@ let HelixHeadlessMenu = class HelixHeadlessMenu extends MixinCollection(MixinCon
|
|
|
98
108
|
event.stopPropagation();
|
|
99
109
|
this.filterBy(event.target.value);
|
|
100
110
|
};
|
|
111
|
+
this.followRemoved = (records) => {
|
|
112
|
+
if (!this.open) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const active = deepActiveElement();
|
|
116
|
+
const lost = active === null || active === document.body || !active.isConnected;
|
|
117
|
+
const record = records.find((one) => [...one.removedNodes].some((node) => isItem(node) && (this.filterable ? node === this.highlighted : lost)));
|
|
118
|
+
if (!record) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const items = this.items;
|
|
122
|
+
const after = (from, step) => {
|
|
123
|
+
for (let node = from; node; node = node[step]) {
|
|
124
|
+
if (items.includes(node)) {
|
|
125
|
+
return node;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return undefined;
|
|
129
|
+
};
|
|
130
|
+
const next = after(record.nextSibling, 'nextSibling') ??
|
|
131
|
+
after(record.previousSibling, 'previousSibling') ??
|
|
132
|
+
items.at(-1);
|
|
133
|
+
if (this.filterable || next) {
|
|
134
|
+
this.reach(next);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
this.hide();
|
|
138
|
+
if (!this.context) {
|
|
139
|
+
this.trigger.focus();
|
|
140
|
+
}
|
|
141
|
+
};
|
|
101
142
|
this.handleContextMenu = (event) => {
|
|
102
143
|
if (!this.context) {
|
|
103
144
|
return;
|
|
@@ -124,6 +165,7 @@ let HelixHeadlessMenu = class HelixHeadlessMenu extends MixinCollection(MixinCon
|
|
|
124
165
|
return;
|
|
125
166
|
}
|
|
126
167
|
const chosen = item;
|
|
168
|
+
this.tellChecked();
|
|
127
169
|
if (chosen.hasSubmenu) {
|
|
128
170
|
event.stopPropagation();
|
|
129
171
|
this.enter(chosen);
|
|
@@ -141,6 +183,7 @@ let HelixHeadlessMenu = class HelixHeadlessMenu extends MixinCollection(MixinCon
|
|
|
141
183
|
if (item) {
|
|
142
184
|
this.revealRow(item);
|
|
143
185
|
}
|
|
186
|
+
this.nameSurface();
|
|
144
187
|
};
|
|
145
188
|
this.handleKeydown = (event) => {
|
|
146
189
|
if (!this.open) {
|
|
@@ -235,7 +278,7 @@ let HelixHeadlessMenu = class HelixHeadlessMenu extends MixinCollection(MixinCon
|
|
|
235
278
|
}
|
|
236
279
|
};
|
|
237
280
|
this.handleHover = (event) => {
|
|
238
|
-
if (!
|
|
281
|
+
if (!this.open || event.pointerType !== 'mouse') {
|
|
239
282
|
return;
|
|
240
283
|
}
|
|
241
284
|
const row = event
|
|
@@ -293,6 +336,7 @@ let HelixHeadlessMenu = class HelixHeadlessMenu extends MixinCollection(MixinCon
|
|
|
293
336
|
until: Date.now() + GRACE,
|
|
294
337
|
};
|
|
295
338
|
};
|
|
339
|
+
this.namedByPage = false;
|
|
296
340
|
}
|
|
297
341
|
static { this.words = 'helix-menu'; }
|
|
298
342
|
get flies() {
|
|
@@ -487,6 +531,27 @@ let HelixHeadlessMenu = class HelixHeadlessMenu extends MixinCollection(MixinCon
|
|
|
487
531
|
this.drilldown.back();
|
|
488
532
|
this.updateComplete.then(() => this.reach(leaving ?? undefined));
|
|
489
533
|
}
|
|
534
|
+
get choiceRows() {
|
|
535
|
+
return [...this.querySelectorAll('*')].filter((node) => isItem(node) && node.choice);
|
|
536
|
+
}
|
|
537
|
+
get checkedValues() {
|
|
538
|
+
return this.choiceRows.filter((row) => row.checked).map((row) => row.value);
|
|
539
|
+
}
|
|
540
|
+
set checkedValues(values) {
|
|
541
|
+
const wanted = new Set(values);
|
|
542
|
+
for (const row of this.choiceRows) {
|
|
543
|
+
row.checked = wanted.has(row.value);
|
|
544
|
+
}
|
|
545
|
+
this.toldChecked = this.checkedValues.join('\u0000');
|
|
546
|
+
}
|
|
547
|
+
tellChecked() {
|
|
548
|
+
const now = this.checkedValues.join('\u0000');
|
|
549
|
+
const before = this.toldChecked;
|
|
550
|
+
this.toldChecked = now;
|
|
551
|
+
if (before !== undefined && before !== now) {
|
|
552
|
+
this.dispatchEvent(new Event('change', { bubbles: true }));
|
|
553
|
+
}
|
|
554
|
+
}
|
|
490
555
|
revealRow(item) {
|
|
491
556
|
const holder = this.flies ? this.holderOf(item) : null;
|
|
492
557
|
const surface = holder
|
|
@@ -555,6 +620,8 @@ let HelixHeadlessMenu = class HelixHeadlessMenu extends MixinCollection(MixinCon
|
|
|
555
620
|
this.addEventListener('pointercancel', this.handlePointerCancel);
|
|
556
621
|
this.addEventListener('click', this.handleHeldClick, true);
|
|
557
622
|
this.addEventListener('focusin', this.handleTriggerFocusIn);
|
|
623
|
+
this.rowWatch = new MutationObserver(this.followRemoved);
|
|
624
|
+
this.rowWatch.observe(this, { childList: true, subtree: true });
|
|
558
625
|
void this.whenSettled.then(() => {
|
|
559
626
|
this.settledOnce = true;
|
|
560
627
|
if (!this.context) {
|
|
@@ -581,6 +648,8 @@ let HelixHeadlessMenu = class HelixHeadlessMenu extends MixinCollection(MixinCon
|
|
|
581
648
|
this.removeEventListener('pointercancel', this.handlePointerCancel);
|
|
582
649
|
this.removeEventListener('click', this.handleHeldClick, true);
|
|
583
650
|
this.removeEventListener('focusin', this.handleTriggerFocusIn);
|
|
651
|
+
this.rowWatch?.disconnect();
|
|
652
|
+
this.rowWatch = undefined;
|
|
584
653
|
if (this.described) {
|
|
585
654
|
unlinkDescription(this.described, this);
|
|
586
655
|
this.described = undefined;
|
|
@@ -588,6 +657,9 @@ let HelixHeadlessMenu = class HelixHeadlessMenu extends MixinCollection(MixinCon
|
|
|
588
657
|
}
|
|
589
658
|
updated(changed) {
|
|
590
659
|
super.updated(changed);
|
|
660
|
+
if (changed.has('open') && this.open) {
|
|
661
|
+
this.toldChecked = this.checkedValues.join('\u0000');
|
|
662
|
+
}
|
|
591
663
|
if (!this.context) {
|
|
592
664
|
this.tellTrigger();
|
|
593
665
|
}
|
|
@@ -628,7 +700,20 @@ let HelixHeadlessMenu = class HelixHeadlessMenu extends MixinCollection(MixinCon
|
|
|
628
700
|
}
|
|
629
701
|
nameSurface() {
|
|
630
702
|
const surface = this.menuBox;
|
|
631
|
-
if (!surface
|
|
703
|
+
if (!surface) {
|
|
704
|
+
return;
|
|
705
|
+
}
|
|
706
|
+
if (!this.flies && !this.drilldown.atRoot && this.partNamed('title')) {
|
|
707
|
+
surface.setAttribute('aria-labelledby', 'title');
|
|
708
|
+
this.namedByPage = true;
|
|
709
|
+
return;
|
|
710
|
+
}
|
|
711
|
+
if (this.namedByPage) {
|
|
712
|
+
this.namedByPage = false;
|
|
713
|
+
surface.removeAttribute('aria-labelledby');
|
|
714
|
+
this.aria.forward();
|
|
715
|
+
}
|
|
716
|
+
if (!('ariaLabelledByElements' in surface)) {
|
|
632
717
|
return;
|
|
633
718
|
}
|
|
634
719
|
if (this.hasAttribute('aria-labelledby')) {
|
|
@@ -673,8 +758,15 @@ let HelixHeadlessMenu = class HelixHeadlessMenu extends MixinCollection(MixinCon
|
|
|
673
758
|
render() {
|
|
674
759
|
const point = this.context && this.point;
|
|
675
760
|
const filtering = this.filtering;
|
|
676
|
-
const
|
|
677
|
-
|
|
761
|
+
const count = filtering
|
|
762
|
+
? this.rowsOf(this.filterPage).filter((row) => this.kept(row)).length
|
|
763
|
+
: 0;
|
|
764
|
+
const none = filtering && count === 0;
|
|
765
|
+
this.announced = none
|
|
766
|
+
? this.noResultsText
|
|
767
|
+
: filtering
|
|
768
|
+
? formatWords(this, 'resultsLabel', { count })
|
|
769
|
+
: '';
|
|
678
770
|
const rows = html `${this.flies || this.drilldown.atRoot
|
|
679
771
|
? nothing
|
|
680
772
|
: html `<div part="header">
|
|
@@ -690,7 +782,7 @@ let HelixHeadlessMenu = class HelixHeadlessMenu extends MixinCollection(MixinCon
|
|
|
690
782
|
${unsafeSVG(caretLeft.content)}
|
|
691
783
|
</svg>
|
|
692
784
|
</button>
|
|
693
|
-
<span part="title">${this.drilldown.label}</span>
|
|
785
|
+
<span part="title" id="title">${this.drilldown.label}</span>
|
|
694
786
|
</div>`}
|
|
695
787
|
<slot @slotchange=${(event) => this.countRows(event)}></slot>
|
|
696
788
|
${none
|
|
@@ -775,6 +867,10 @@ __decorate([
|
|
|
775
867
|
__decorate([
|
|
776
868
|
property()
|
|
777
869
|
], HelixHeadlessMenu.prototype, "placement", void 0);
|
|
870
|
+
__decorate([
|
|
871
|
+
words,
|
|
872
|
+
property({ attribute: 'results-label' })
|
|
873
|
+
], HelixHeadlessMenu.prototype, "resultsLabel", void 0);
|
|
778
874
|
__decorate([
|
|
779
875
|
property()
|
|
780
876
|
], HelixHeadlessMenu.prototype, "submenus", void 0);
|
|
@@ -22,7 +22,9 @@ declare const HelixHeadlessPopover_base: (new (...args: any[]) => import("@fusio
|
|
|
22
22
|
*
|
|
23
23
|
* It opens on click and from a command. `command="--show"` and the related
|
|
24
24
|
* commands work as they do on `Dialog` and `Drawer`, so a button anywhere on
|
|
25
|
-
* the page can open the popover with no script.
|
|
25
|
+
* the page can open the popover with no script. From its first press, a
|
|
26
|
+
* button that opens it this way says whether the popover is open: a Helix
|
|
27
|
+
* button through `expanded`, and any other element with `aria-expanded`.
|
|
26
28
|
*
|
|
27
29
|
* **Opening moves focus into the panel**, to the first control in it, or to the
|
|
28
30
|
* panel itself where it holds none, and closing from inside gives it back to
|
|
@@ -32,8 +34,12 @@ declare const HelixHeadlessPopover_base: (new (...args: any[]) => import("@fusio
|
|
|
32
34
|
* `modal` keeps `Tab` inside the panel while it is open and says so with
|
|
33
35
|
* `aria-modal`, for a panel that has to be answered before the page goes on.
|
|
34
36
|
* The rest of the page is hidden from screen readers with `aria-hidden` while
|
|
35
|
-
* it is open, so the virtual cursor stays in the panel too
|
|
36
|
-
* popover does not trap focus.
|
|
37
|
+
* it is open, so the virtual cursor stays in the panel too, and the page does
|
|
38
|
+
* not scroll behind it. Without it the popover does not trap focus.
|
|
39
|
+
*
|
|
40
|
+
* A press outside closes the panel and leaves focus where the press put it.
|
|
41
|
+
* Where it put focus nowhere, as a press on text or on the page's background
|
|
42
|
+
* does, focus goes back to the trigger.
|
|
37
43
|
*
|
|
38
44
|
* The panel's name is `label` when you set it. Otherwise it is the first
|
|
39
45
|
* heading in the panel, or the elements an `aria-labelledby` on the host names.
|
|
@@ -49,10 +55,17 @@ declare const HelixHeadlessPopover_base: (new (...args: any[]) => import("@fusio
|
|
|
49
55
|
* | Escape | Closes the panel and puts focus back on the trigger. |
|
|
50
56
|
* | Tab, Shift+Tab | Moves through the controls in the panel. Leaving the panel and the trigger closes it. With `modal`, moves from the last control round to the first and from the first round to the last. |
|
|
51
57
|
*
|
|
58
|
+
* The panel opens against the trigger, or against the element `anchor` names,
|
|
59
|
+
* such as a field beside the button that opens it. `offset` moves it away from
|
|
60
|
+
* that element, `cross-offset` slides it along the side it is on,
|
|
61
|
+
* `container-padding` keeps it that far from the window's edges, and
|
|
62
|
+
* `flip="false"` keeps it on its side where the other side has more room.
|
|
63
|
+
*
|
|
52
64
|
* `arrow` draws a point on the panel's edge facing the trigger. The side the
|
|
53
|
-
* panel landed on is on the host as `:state(placed-top)` and its kin,
|
|
54
|
-
*
|
|
55
|
-
*
|
|
65
|
+
* panel landed on is on the host as `:state(placed-top)` and its kin, its
|
|
66
|
+
* alignment along that side as `:state(aligned-start)` or
|
|
67
|
+
* `:state(aligned-end)`, and the trigger's width is on the panel as
|
|
68
|
+
* `--floating-anchor-inline-size`, for a panel as wide as its trigger:
|
|
56
69
|
*
|
|
57
70
|
* ```css
|
|
58
71
|
* helix-popover::part(popover) {
|
|
@@ -84,6 +97,8 @@ declare const HelixHeadlessPopover_base: (new (...args: any[]) => import("@fusio
|
|
|
84
97
|
* @cssproperty --floating-anchor-inline-size - The trigger's width, written on the panel while it is open, as in `min-inline-size: var(--floating-anchor-inline-size)`. Read it; a value set here is written over.
|
|
85
98
|
* @cssproperty --floating-available-block-size - The room between the panel and the edge of the screen it opens toward, written on the panel while it is open. Read it; a value set here is written over.
|
|
86
99
|
*
|
|
100
|
+
* @cssstate aligned-end - While the panel is aligned to the end of the side it sits on.
|
|
101
|
+
* @cssstate aligned-start - While the panel is aligned to the start of the side it sits on.
|
|
87
102
|
* @cssstate entering - From the moment the panel shows until its entrance has finished.
|
|
88
103
|
* @cssstate exiting - From the moment the panel hides until its exit has finished.
|
|
89
104
|
* @cssstate open - While the popover is open.
|
|
@@ -98,6 +113,13 @@ export declare class HelixHeadlessPopover extends HelixHeadlessPopover_base {
|
|
|
98
113
|
* `registerWords('de', { 'helix-popover': { fallbackLabel: 'Popup' } })`.
|
|
99
114
|
*/
|
|
100
115
|
static words: string;
|
|
116
|
+
/**
|
|
117
|
+
* The element the panel opens against, where that is not the trigger: its
|
|
118
|
+
* `id` in the same document or shadow root, or the element itself. Left
|
|
119
|
+
* empty, the panel opens against the trigger, or against the button whose
|
|
120
|
+
* command opened it.
|
|
121
|
+
*/
|
|
122
|
+
anchor: Element | string;
|
|
101
123
|
/**
|
|
102
124
|
* Draws a point on the panel's edge facing the trigger.
|
|
103
125
|
*
|
|
@@ -105,11 +127,29 @@ export declare class HelixHeadlessPopover extends HelixHeadlessPopover_base {
|
|
|
105
127
|
* trigger already reads as belonging to it.
|
|
106
128
|
*/
|
|
107
129
|
arrow: boolean;
|
|
130
|
+
/**
|
|
131
|
+
* How close to the window's edges the panel may come, in pixels, when it
|
|
132
|
+
* slides, shrinks or moves to the other side to fit. Left unset, it slides
|
|
133
|
+
* and shrinks to 8 pixels from an edge and moves to the other side only
|
|
134
|
+
* once it would cross one.
|
|
135
|
+
*/
|
|
136
|
+
containerPadding?: number;
|
|
137
|
+
/**
|
|
138
|
+
* How far to slide the panel along the side it is on, in pixels: to the
|
|
139
|
+
* right on the top or the bottom, and down on the left or the right.
|
|
140
|
+
*/
|
|
141
|
+
crossOffset: number;
|
|
108
142
|
/**
|
|
109
143
|
* The panel's name where nothing else names it: no `label`, no heading in
|
|
110
144
|
* the panel, and no `aria-labelledby` on the host.
|
|
111
145
|
*/
|
|
112
146
|
fallbackLabel: string;
|
|
147
|
+
/**
|
|
148
|
+
* Whether the panel moves to the other side of the trigger when its own
|
|
149
|
+
* side has no room. On by default. Write `flip="false"` to keep it on its
|
|
150
|
+
* side, where it shrinks to fit, as React Aria's `shouldFlip` turns off.
|
|
151
|
+
*/
|
|
152
|
+
flip: boolean;
|
|
113
153
|
/**
|
|
114
154
|
* The panel's name, read by screen readers. Left empty, the first heading in
|
|
115
155
|
* the panel names it, and then `fallback-label`.
|
|
@@ -166,7 +206,20 @@ export declare class HelixHeadlessPopover extends HelixHeadlessPopover_base {
|
|
|
166
206
|
private invoker;
|
|
167
207
|
protected readonly commands: CommandController;
|
|
168
208
|
/** The element the panel opens against. */
|
|
209
|
+
private get placedAgainst();
|
|
210
|
+
/** The element that opened the panel, which focus goes back to. */
|
|
169
211
|
private get trigger();
|
|
212
|
+
/**
|
|
213
|
+
* A press outside, or Escape, closing the panel.
|
|
214
|
+
*
|
|
215
|
+
* **Focus goes back to the trigger where the press put it nowhere.** The
|
|
216
|
+
* press is heard on `pointerdown`, and the browser moves focus a moment
|
|
217
|
+
* later: onto what was pressed where that takes focus, and to the body where
|
|
218
|
+
* it does not. A popover dismissed by a press on text was left with focus on
|
|
219
|
+
* the body, measured in Chromium, where React Aria's returns it to the
|
|
220
|
+
* trigger. Read after the press, once the browser has moved it.
|
|
221
|
+
*/
|
|
222
|
+
private dismiss;
|
|
170
223
|
/** Opens the panel. */
|
|
171
224
|
show(): void;
|
|
172
225
|
/** Closes the panel and puts focus back on the trigger. */
|
|
@@ -4,15 +4,18 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { AriaForwardController, anchorElement, arrowReach, auditName, CommandController, customElement, deepActiveElement, FocusScopeController, HelixElement, headingIn, MixinControllerOpen, OpenPhaseController, PopoverController, reflectElements, sideOf, tellDisclosure, words, } from '@fusion.dev/helix-core';
|
|
7
|
+
import { AriaForwardController, anchorElement, arrowReach, auditName, CommandController, customElement, deepActiveElement, FocusScopeController, HelixElement, headingIn, lockScroll, MixinControllerOpen, OpenPhaseController, onUnlessFalse, PopoverController, reflectElements, sideOf, tellDisclosure, unlockScroll, words, } from '@fusion.dev/helix-core';
|
|
8
8
|
import { html, nothing } from 'lit';
|
|
9
9
|
import { property, state } from 'lit/decorators.js';
|
|
10
10
|
import { hideOutside } from '../hide-outside.js';
|
|
11
11
|
let HelixHeadlessPopover = class HelixHeadlessPopover extends MixinControllerOpen(HelixElement) {
|
|
12
12
|
constructor() {
|
|
13
13
|
super(...arguments);
|
|
14
|
+
this.anchor = '';
|
|
14
15
|
this.arrow = false;
|
|
16
|
+
this.crossOffset = 0;
|
|
15
17
|
this.fallbackLabel = 'Popover';
|
|
18
|
+
this.flip = true;
|
|
16
19
|
this.label = '';
|
|
17
20
|
this.modal = false;
|
|
18
21
|
this.aria = new AriaForwardController(this, {
|
|
@@ -29,13 +32,17 @@ let HelixHeadlessPopover = class HelixHeadlessPopover extends MixinControllerOpe
|
|
|
29
32
|
surface: () => this.partNamed('popover'),
|
|
30
33
|
});
|
|
31
34
|
this.panel = new PopoverController(this, {
|
|
32
|
-
anchor: () => this.
|
|
35
|
+
anchor: () => this.placedAgainst,
|
|
33
36
|
arrow: () => this.partNamed('arrow'),
|
|
34
37
|
boundary: () => [this, this.invoker],
|
|
38
|
+
crossOffset: () => this.crossOffset,
|
|
39
|
+
flip: () => this.flip,
|
|
35
40
|
offset: () => this.offset + arrowReach(this.partNamed('arrow')),
|
|
36
|
-
onDismiss: () => this.
|
|
41
|
+
onDismiss: () => this.dismiss(),
|
|
37
42
|
onPlace: (placement) => {
|
|
38
43
|
const side = sideOf(placement);
|
|
44
|
+
this.toggleState('aligned-end', placement.endsWith('-end'));
|
|
45
|
+
this.toggleState('aligned-start', placement.endsWith('-start'));
|
|
39
46
|
this.toggleState('placed-bottom', side === 'bottom');
|
|
40
47
|
this.toggleState('placed-left', side === 'left');
|
|
41
48
|
this.toggleState('placed-right', side === 'right');
|
|
@@ -43,6 +50,7 @@ let HelixHeadlessPopover = class HelixHeadlessPopover extends MixinControllerOpe
|
|
|
43
50
|
this.side = side;
|
|
44
51
|
},
|
|
45
52
|
open: () => this.open,
|
|
53
|
+
padding: () => this.containerPadding,
|
|
46
54
|
placement: () => this.placement,
|
|
47
55
|
surface: () => this.partNamed('popover'),
|
|
48
56
|
});
|
|
@@ -69,6 +77,7 @@ let HelixHeadlessPopover = class HelixHeadlessPopover extends MixinControllerOpe
|
|
|
69
77
|
}
|
|
70
78
|
},
|
|
71
79
|
},
|
|
80
|
+
expanded: () => this.open,
|
|
72
81
|
});
|
|
73
82
|
this.closingFromInside = false;
|
|
74
83
|
this.handleFocusOut = (event) => {
|
|
@@ -111,10 +120,31 @@ let HelixHeadlessPopover = class HelixHeadlessPopover extends MixinControllerOpe
|
|
|
111
120
|
const heading = asked ? null : headingIn(this.slotted);
|
|
112
121
|
this.namedByHeading = reflectElements(this.partNamed('popover'), 'ariaLabelledByElements', heading ? [heading] : [], this.namedByHeading);
|
|
113
122
|
}
|
|
123
|
+
get placedAgainst() {
|
|
124
|
+
const named = typeof this.anchor === 'string'
|
|
125
|
+
? this.anchor === ''
|
|
126
|
+
? null
|
|
127
|
+
: this.getRootNode().getElementById?.(this.anchor)
|
|
128
|
+
: this.anchor;
|
|
129
|
+
return named instanceof HTMLElement ? named : this.trigger;
|
|
130
|
+
}
|
|
114
131
|
get trigger() {
|
|
115
132
|
return (this.invoker ??
|
|
116
133
|
anchorElement(this.renderRoot?.querySelector('slot[name="trigger"]'), this));
|
|
117
134
|
}
|
|
135
|
+
dismiss() {
|
|
136
|
+
const inside = this.focusInside;
|
|
137
|
+
this.hide();
|
|
138
|
+
if (!inside) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
setTimeout(() => {
|
|
142
|
+
const active = deepActiveElement();
|
|
143
|
+
if (!this.open && (active === null || active === document.body)) {
|
|
144
|
+
this.trigger.focus();
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
118
148
|
show() {
|
|
119
149
|
if (this.open || !this.requestOpen(true)) {
|
|
120
150
|
return;
|
|
@@ -179,6 +209,12 @@ let HelixHeadlessPopover = class HelixHeadlessPopover extends MixinControllerOpe
|
|
|
179
209
|
this.showOutside();
|
|
180
210
|
this.showOutside = undefined;
|
|
181
211
|
}
|
|
212
|
+
if (hide) {
|
|
213
|
+
lockScroll(this);
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
unlockScroll(this);
|
|
217
|
+
}
|
|
182
218
|
}
|
|
183
219
|
updated(changed) {
|
|
184
220
|
super.updated(changed);
|
|
@@ -220,13 +256,25 @@ let HelixHeadlessPopover = class HelixHeadlessPopover extends MixinControllerOpe
|
|
|
220
256
|
</div>`;
|
|
221
257
|
}
|
|
222
258
|
};
|
|
259
|
+
__decorate([
|
|
260
|
+
property()
|
|
261
|
+
], HelixHeadlessPopover.prototype, "anchor", void 0);
|
|
223
262
|
__decorate([
|
|
224
263
|
property({ type: Boolean })
|
|
225
264
|
], HelixHeadlessPopover.prototype, "arrow", void 0);
|
|
265
|
+
__decorate([
|
|
266
|
+
property({ attribute: 'container-padding', type: Number })
|
|
267
|
+
], HelixHeadlessPopover.prototype, "containerPadding", void 0);
|
|
268
|
+
__decorate([
|
|
269
|
+
property({ attribute: 'cross-offset', type: Number })
|
|
270
|
+
], HelixHeadlessPopover.prototype, "crossOffset", void 0);
|
|
226
271
|
__decorate([
|
|
227
272
|
words,
|
|
228
273
|
property({ attribute: 'fallback-label' })
|
|
229
274
|
], HelixHeadlessPopover.prototype, "fallbackLabel", void 0);
|
|
275
|
+
__decorate([
|
|
276
|
+
property({ converter: onUnlessFalse })
|
|
277
|
+
], HelixHeadlessPopover.prototype, "flip", void 0);
|
|
230
278
|
__decorate([
|
|
231
279
|
property()
|
|
232
280
|
], HelixHeadlessPopover.prototype, "label", void 0);
|