@nldd/design-system 0.8.97 → 0.8.99
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 +192 -46
- package/dist/components/actions/menu/menu.d.ts +39 -5
- package/dist/components/actions/menu/menu.d.ts.map +1 -1
- package/dist/components/actions/menu/menu.js +120 -7
- package/dist/components/actions/menu/menu.js.map +1 -1
- package/dist/components/actions/menu/menu.template.d.ts +4 -3
- package/dist/components/actions/menu/menu.template.d.ts.map +1 -1
- package/dist/components/actions/menu/menu.template.js +10 -5
- package/dist/components/actions/menu/menu.template.js.map +1 -1
- package/dist/components/actions/toolbar/toolbar.d.ts +14 -3
- package/dist/components/actions/toolbar/toolbar.d.ts.map +1 -1
- package/dist/components/actions/toolbar/toolbar.js +45 -7
- package/dist/components/actions/toolbar/toolbar.js.map +1 -1
- package/dist/components/actions/toolbar/toolbar.styles.d.ts.map +1 -1
- package/dist/components/actions/toolbar/toolbar.styles.js +15 -1
- package/dist/components/actions/toolbar/toolbar.styles.js.map +1 -1
- package/dist/components/components.js +1104 -186
- package/dist/components/content/code-viewer/code-viewer.d.ts +4 -1
- package/dist/components/content/code-viewer/code-viewer.d.ts.map +1 -1
- package/dist/components/content/code-viewer/code-viewer.js +43 -5
- package/dist/components/content/code-viewer/code-viewer.js.map +1 -1
- package/dist/components/content/code-viewer/code-viewer.styles.d.ts.map +1 -1
- package/dist/components/content/code-viewer/code-viewer.styles.js +22 -7
- package/dist/components/content/code-viewer/code-viewer.styles.js.map +1 -1
- package/dist/components/content/code-viewer/code-viewer.template.d.ts.map +1 -1
- package/dist/components/content/code-viewer/code-viewer.template.js +1 -0
- package/dist/components/content/code-viewer/code-viewer.template.js.map +1 -1
- package/dist/components/content/tooltip/tooltip.d.ts +7 -0
- package/dist/components/content/tooltip/tooltip.d.ts.map +1 -1
- package/dist/components/content/tooltip/tooltip.js +29 -2
- package/dist/components/content/tooltip/tooltip.js.map +1 -1
- package/dist/components/content/visually-hidden/visually-hidden.d.ts +35 -0
- package/dist/components/content/visually-hidden/visually-hidden.d.ts.map +1 -0
- package/dist/components/content/visually-hidden/visually-hidden.js +45 -0
- package/dist/components/content/visually-hidden/visually-hidden.js.map +1 -0
- package/dist/components/content/visually-hidden/visually-hidden.styles.d.ts +2 -0
- package/dist/components/content/visually-hidden/visually-hidden.styles.d.ts.map +1 -0
- package/dist/components/content/visually-hidden/visually-hidden.styles.js +27 -0
- package/dist/components/content/visually-hidden/visually-hidden.styles.js.map +1 -0
- package/dist/components/content/visually-hidden/visually-hidden.template.d.ts +3 -0
- package/dist/components/content/visually-hidden/visually-hidden.template.d.ts.map +1 -0
- package/dist/components/content/visually-hidden/visually-hidden.template.js +7 -0
- package/dist/components/content/visually-hidden/visually-hidden.template.js.map +1 -0
- package/dist/components/{dist-CH9m014O.js → dist-B2QcygzG.js} +1 -1
- package/dist/components/{dist-DMHTTJRJ.js → dist-BB5mlo7D.js} +2 -2
- package/dist/components/{dist-C3uWRipu.js → dist-Bo5Jeyfn.js} +1 -1
- package/dist/components/{dist-CpW8MF-L.js → dist-Bud_7w5g.js} +232 -214
- package/dist/components/{dist-CvL6_ezZ.js → dist-CA0yDFIt.js} +2 -2
- package/dist/components/{dist-DV6Mp5N1.js → dist-CaxHkqR2.js} +3 -3
- package/dist/components/{dist-BWRYv3Mp.js → dist-Ch3gNAuT.js} +1 -1
- package/dist/components/{dist-PlhQXXtE.js → dist-DbNhCpS5.js} +1 -1
- package/dist/components/{dist-DTOshgo1.js → dist-DkqAbJH8.js} +1 -1
- package/dist/components/{dist-BWEAw34D.js → dist-DnZmcpbQ.js} +1 -1
- package/dist/components/{dist-Bi4EHsFY.js → dist-iC2RTM0V.js} +2 -2
- package/dist/components/forms/validation-list/validation-list.d.ts +19 -9
- package/dist/components/forms/validation-list/validation-list.d.ts.map +1 -1
- package/dist/components/forms/validation-list/validation-list.js +38 -12
- package/dist/components/forms/validation-list/validation-list.js.map +1 -1
- package/dist/components/{icon-button-NN0SrgS3.js → icon-button-CJIikwyu.js} +15 -2
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/inputs/segmented-control/segmented-control.d.ts +1 -1
- package/dist/components/inputs/segmented-control/segmented-control.d.ts.map +1 -1
- package/dist/components/inputs/segmented-control/segmented-control.js +1 -4
- package/dist/components/inputs/segmented-control/segmented-control.js.map +1 -1
- package/dist/components/inputs/toggle-button/toggle-button.d.ts +1 -1
- package/dist/components/inputs/toggle-button/toggle-button.d.ts.map +1 -1
- package/dist/components/inputs/toggle-button/toggle-button.js +1 -4
- package/dist/components/inputs/toggle-button/toggle-button.js.map +1 -1
- package/dist/components/layout/card/card.d.ts +12 -1
- package/dist/components/layout/card/card.d.ts.map +1 -1
- package/dist/components/layout/card/card.js +29 -2
- package/dist/components/layout/card/card.js.map +1 -1
- package/dist/components/layout/card/card.styles.js +2 -2
- package/dist/components/layout/page-sections/sidebar-section/sidebar-section.styles.d.ts.map +1 -1
- package/dist/components/layout/page-sections/sidebar-section/sidebar-section.styles.js +3 -1
- package/dist/components/layout/page-sections/sidebar-section/sidebar-section.styles.js.map +1 -1
- package/dist/components/layout/page-sections/sidebar-section/sidebar-section.template.js +6 -6
- package/dist/components/layout/page-sections/sidebar-section/sidebar-section.template.js.map +1 -1
- package/dist/components/layout/popover/popover.styles.d.ts.map +1 -1
- package/dist/components/layout/popover/popover.styles.js +4 -0
- package/dist/components/layout/popover/popover.styles.js.map +1 -1
- package/dist/components/lists-and-tables/list/list.d.ts +6 -1
- package/dist/components/lists-and-tables/list/list.d.ts.map +1 -1
- package/dist/components/lists-and-tables/list/list.js +7 -2
- package/dist/components/lists-and-tables/list/list.js.map +1 -1
- package/dist/components/lists-and-tables/list-item/list-item.d.ts +16 -1
- package/dist/components/lists-and-tables/list-item/list-item.d.ts.map +1 -1
- package/dist/components/lists-and-tables/list-item/list-item.js +35 -4
- package/dist/components/lists-and-tables/list-item/list-item.js.map +1 -1
- package/dist/components/lists-and-tables/list-item/list-item.template.d.ts +1 -1
- package/dist/components/lists-and-tables/list-item/list-item.template.d.ts.map +1 -1
- package/dist/components/lists-and-tables/list-item/list-item.template.js +7 -6
- package/dist/components/lists-and-tables/list-item/list-item.template.js.map +1 -1
- package/dist/components/navigation/document-tab-bar/document-tab-bar.d.ts +44 -1
- package/dist/components/navigation/document-tab-bar/document-tab-bar.d.ts.map +1 -1
- package/dist/components/navigation/document-tab-bar/document-tab-bar.js +132 -3
- package/dist/components/navigation/document-tab-bar/document-tab-bar.js.map +1 -1
- package/dist/components/navigation/document-tab-bar/document-tab-bar.styles.d.ts.map +1 -1
- package/dist/components/navigation/document-tab-bar/document-tab-bar.styles.js +21 -2
- package/dist/components/navigation/document-tab-bar/document-tab-bar.styles.js.map +1 -1
- package/dist/components/navigation/document-tab-bar/document-tab-bar.template.js +1 -1
- package/dist/components/navigation/document-tab-bar/document-tab-bar.template.js.map +1 -1
- package/dist/components/navigation/menu-bar/menu-bar.d.ts.map +1 -1
- package/dist/components/navigation/menu-bar/menu-bar.js +19 -2
- package/dist/components/navigation/menu-bar/menu-bar.js.map +1 -1
- package/dist/components/navigation/menu-bar-item/menu-bar-item.d.ts +6 -3
- package/dist/components/navigation/menu-bar-item/menu-bar-item.d.ts.map +1 -1
- package/dist/components/navigation/menu-bar-item/menu-bar-item.js +11 -3
- package/dist/components/navigation/menu-bar-item/menu-bar-item.js.map +1 -1
- package/dist/components/navigation/menu-bar-item/menu-bar-item.template.d.ts +1 -0
- package/dist/components/navigation/menu-bar-item/menu-bar-item.template.d.ts.map +1 -1
- package/dist/components/navigation/menu-bar-item/menu-bar-item.template.js +53 -32
- package/dist/components/navigation/menu-bar-item/menu-bar-item.template.js.map +1 -1
- package/dist/components/navigation/skip-link/skip-link.d.ts +58 -5
- package/dist/components/navigation/skip-link/skip-link.d.ts.map +1 -1
- package/dist/components/navigation/skip-link/skip-link.js +148 -14
- package/dist/components/navigation/skip-link/skip-link.js.map +1 -1
- package/dist/components/navigation/skip-link/skip-link.template.d.ts.map +1 -1
- package/dist/components/navigation/skip-link/skip-link.template.js +1 -0
- package/dist/components/navigation/skip-link/skip-link.template.js.map +1 -1
- package/dist/components/navigation/tab-bar/tab-bar.d.ts +70 -1
- package/dist/components/navigation/tab-bar/tab-bar.d.ts.map +1 -1
- package/dist/components/navigation/tab-bar/tab-bar.i18n.d.ts +5 -0
- package/dist/components/navigation/tab-bar/tab-bar.i18n.d.ts.map +1 -0
- package/dist/components/navigation/tab-bar/tab-bar.i18n.js +4 -0
- package/dist/components/navigation/tab-bar/tab-bar.i18n.js.map +1 -0
- package/dist/components/navigation/tab-bar/tab-bar.js +213 -22
- package/dist/components/navigation/tab-bar/tab-bar.js.map +1 -1
- package/dist/components/navigation/tab-bar/tab-bar.styles.d.ts.map +1 -1
- package/dist/components/navigation/tab-bar/tab-bar.styles.js +68 -3
- package/dist/components/navigation/tab-bar/tab-bar.styles.js.map +1 -1
- package/dist/components/navigation/tab-bar/tab-bar.template.d.ts.map +1 -1
- package/dist/components/navigation/tab-bar/tab-bar.template.js +36 -5
- package/dist/components/navigation/tab-bar/tab-bar.template.js.map +1 -1
- package/dist/components/navigation/top-navigation-bar/top-navigation-bar.d.ts +7 -0
- package/dist/components/navigation/top-navigation-bar/top-navigation-bar.d.ts.map +1 -1
- package/dist/components/navigation/top-navigation-bar/top-navigation-bar.js +16 -0
- package/dist/components/navigation/top-navigation-bar/top-navigation-bar.js.map +1 -1
- package/dist/components/navigation/top-navigation-bar/top-navigation-bar.styles.d.ts.map +1 -1
- package/dist/components/navigation/top-navigation-bar/top-navigation-bar.styles.js +7 -0
- package/dist/components/navigation/top-navigation-bar/top-navigation-bar.styles.js.map +1 -1
- package/dist/components/navigation/top-title-bar/top-title-bar.d.ts +8 -1
- package/dist/components/navigation/top-title-bar/top-title-bar.d.ts.map +1 -1
- package/dist/components/navigation/top-title-bar/top-title-bar.js +8 -1
- package/dist/components/navigation/top-title-bar/top-title-bar.js.map +1 -1
- package/dist/components/status-and-feedback/notification/notification.d.ts +62 -1
- package/dist/components/status-and-feedback/notification/notification.d.ts.map +1 -1
- package/dist/components/status-and-feedback/notification/notification.js +86 -2
- package/dist/components/status-and-feedback/notification/notification.js.map +1 -1
- package/dist/components/status-and-feedback/notification/notifications-area.d.ts +6 -0
- package/dist/components/status-and-feedback/notification/notifications-area.d.ts.map +1 -1
- package/dist/components/status-and-feedback/notification/notifications-area.js +16 -0
- package/dist/components/status-and-feedback/notification/notifications-area.js.map +1 -1
- package/dist/nldd.min.js +799 -612
- package/dist/translations/en-US.d.ts.map +1 -1
- package/dist/translations/en-US.js +1 -0
- package/dist/translations/en-US.js.map +1 -1
- package/dist/translations/fy.d.ts.map +1 -1
- package/dist/translations/fy.js +1 -0
- package/dist/translations/fy.js.map +1 -1
- package/dist/translations/nl.generated.d.ts +1 -0
- package/dist/translations/nl.generated.d.ts.map +1 -1
- package/dist/translations/nl.generated.js +2 -0
- package/dist/translations/nl.generated.js.map +1 -1
- package/dist/translations/pap-AW.d.ts.map +1 -1
- package/dist/translations/pap-AW.js +1 -0
- package/dist/translations/pap-AW.js.map +1 -1
- package/dist/translations/pap-CW.d.ts.map +1 -1
- package/dist/translations/pap-CW.js +1 -0
- package/dist/translations/pap-CW.js.map +1 -1
- package/dist/types/vue.d.ts +40 -26
- package/package.json +6 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { LitElement } from 'lit';
|
|
2
|
+
import { type MenuVariant } from './menu.template.js';
|
|
2
3
|
import type { NLDDMenuTranslations } from './menu.i18n.js';
|
|
3
4
|
import type { QueryMarkMode } from '../../../utilities/render-marked.js';
|
|
4
5
|
import '../../lists-and-tables/cells/icon-cell/icon-cell.js';
|
|
@@ -14,6 +15,8 @@ import '../../status-and-feedback/inline-dialog/inline-dialog.js';
|
|
|
14
15
|
*/
|
|
15
16
|
export declare class NLDDMenuDivider extends LitElement {
|
|
16
17
|
static styles: import("lit").CSSResult;
|
|
18
|
+
/** @internal The variant of the menu around it, set by that nldd-menu. */
|
|
19
|
+
menuVariant: MenuVariant | null;
|
|
17
20
|
render(): import("lit-html").TemplateResult<1>;
|
|
18
21
|
}
|
|
19
22
|
/**
|
|
@@ -43,6 +46,9 @@ export declare class NLDDMenuGroup extends LitElement {
|
|
|
43
46
|
text: string;
|
|
44
47
|
private static _idCounter;
|
|
45
48
|
readonly _titleId: string;
|
|
49
|
+
/** @internal The variant of the menu around it, set by that nldd-menu. */
|
|
50
|
+
menuVariant: MenuVariant | null;
|
|
51
|
+
updated(changed: Map<string, unknown>): void;
|
|
46
52
|
render(): import("lit-html").TemplateResult<1>;
|
|
47
53
|
}
|
|
48
54
|
/**
|
|
@@ -95,7 +101,7 @@ export declare class NLDDMenuItem extends LitElement {
|
|
|
95
101
|
* into the real menu when it collapses. The clone is claimed there and the
|
|
96
102
|
* declaration stays what it is.
|
|
97
103
|
*/
|
|
98
|
-
menuVariant:
|
|
104
|
+
menuVariant: MenuVariant | null;
|
|
99
105
|
/** Whether this item keeps the check-mark column free without being
|
|
100
106
|
* checkable, because another item in its menu is. Set by that nldd-menu.
|
|
101
107
|
* Not part of the public API. */
|
|
@@ -134,6 +140,7 @@ export declare class NLDDMenuItem extends LitElement {
|
|
|
134
140
|
*
|
|
135
141
|
* @element nldd-menu
|
|
136
142
|
*
|
|
143
|
+
* @attr {'menu'|'listbox'|'navigation'} variant - What the menu is (default 'menu'). `menu` is a menu of actions: `role="menu"` with menu items, for things you do. `listbox` is the popup of a combobox: `role="listbox"` with options, focus stays in the field. `navigation` is a submenu in a site navigation: a list of links (`role="list"`, each item a list item around a real link), because a screen reader treats a menu as an application and reads a list of links as what it is. Every item takes an `href`. Tab reaches each link, the arrow keys, Home and End move between them, Escape closes and returns focus to the trigger, and the menu closes when focus leaves it. The trigger says `aria-expanded` and promises no menu. Checkbox and radio items, shortcuts and `filter()` belong to actions and warn in development here. A submenu of a navigation menu is a navigation menu too. The variant sets `role="listitem"` on its items and groups, and takes it off again when it changes back, also where you had set that role yourself.
|
|
137
144
|
* @attr {string} width - Explicit width, pinned exactly. Without it the menu sizes to its content between a minimum and a viewport-aware maximum (min(100vw - inset, 640px)).
|
|
138
145
|
* @attr {string} anchor - ID of the anchor element. Positions the menu against it AND makes it a toggle: the menu listens on document click and opens/closes itself when the click lands on the anchor. Use this for a menu hung off a button. For a menu you open yourself (a type-ahead under a text field, say), set the `anchorElement` property instead — same positioning, no toggle.
|
|
139
146
|
* @attr {string} placement - Floating UI placement. Default: 'bottom-start'.
|
|
@@ -151,11 +158,10 @@ export declare class NLDDMenuItem extends LitElement {
|
|
|
151
158
|
export declare class NLDDMenu extends LitElement {
|
|
152
159
|
static styles: import("lit").CSSResult;
|
|
153
160
|
/**
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
* Default: 'menu'.
|
|
161
|
+
* What the menu is, which sets its roles and part of its keyboard. See the
|
|
162
|
+
* `variant` attribute in the docblock above.
|
|
157
163
|
*/
|
|
158
|
-
variant:
|
|
164
|
+
variant: MenuVariant;
|
|
159
165
|
/**
|
|
160
166
|
* Explicit width, pinned exactly (sets --_menu-width and clamps min/max to it).
|
|
161
167
|
* Leave unset to let the menu size to its content between a minimum and a
|
|
@@ -333,6 +339,9 @@ export declare class NLDDMenu extends LitElement {
|
|
|
333
339
|
* update that never arrived.
|
|
334
340
|
*/
|
|
335
341
|
private _resyncAnchorFromPopoverState;
|
|
342
|
+
/** The popup type this menu gave its anchor, so a later variant can take
|
|
343
|
+
* it back without touching one the consumer chose. */
|
|
344
|
+
private _seededPopupType;
|
|
336
345
|
private _syncAnchorPopupState;
|
|
337
346
|
private _handleDocumentClick;
|
|
338
347
|
private _hoverOpenTimer;
|
|
@@ -622,6 +631,27 @@ export declare class NLDDMenu extends LitElement {
|
|
|
622
631
|
/** Recalculate position and size relative to the anchor element. */
|
|
623
632
|
reposition(): Promise<void>;
|
|
624
633
|
private _handleKeydown;
|
|
634
|
+
/**
|
|
635
|
+
* A navigation menu closes when focus leaves it, the way a disclosure in a
|
|
636
|
+
* site navigation does: Tab past the last link and the menu is gone, with
|
|
637
|
+
* nothing left open over the page. An action menu keeps its own rules.
|
|
638
|
+
*
|
|
639
|
+
* Only when focus goes somewhere, or when Tab took it. Without a target it
|
|
640
|
+
* is the window losing focus or a press on something that takes none, and
|
|
641
|
+
* light dismiss covers those. Tab past the last link of the page has no
|
|
642
|
+
* target either, though, and that one does leave the menu.
|
|
643
|
+
*/
|
|
644
|
+
private _handleFocusOut;
|
|
645
|
+
/**
|
|
646
|
+
* Whether focus went to the control that opens this menu. Closing here
|
|
647
|
+
* would hand the click that follows a closed menu, and it would open it
|
|
648
|
+
* again; the toggle on the anchor does the closing. The node arrives
|
|
649
|
+
* retargeted, so an anchor inside a shadow root shows up as its host.
|
|
650
|
+
*/
|
|
651
|
+
private _isAnchor;
|
|
652
|
+
/** True from a Tab keydown until the focus change it causes has happened. */
|
|
653
|
+
private _tabbing;
|
|
654
|
+
private _tabbingTimer?;
|
|
625
655
|
private _typeaheadBuffer;
|
|
626
656
|
private _typeaheadTimer;
|
|
627
657
|
/** Reset the typeahead buffer after this much idle time. 500ms is the
|
|
@@ -659,6 +689,10 @@ export declare class NLDDMenu extends LitElement {
|
|
|
659
689
|
* place. A submenu's items are its own and are left to it.
|
|
660
690
|
*/
|
|
661
691
|
_claimItems: () => void;
|
|
692
|
+
private _warnedActionsInNavigation;
|
|
693
|
+
private _warnedFilterInNavigation;
|
|
694
|
+
/** Checkable items and shortcuts belong to actions, not to a list of links. */
|
|
695
|
+
private _warnOnActionsInNavigation;
|
|
662
696
|
private _handleBeforeToggle;
|
|
663
697
|
private _handleToggle;
|
|
664
698
|
render(): import("lit-html").TemplateResult<1>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu.d.ts","sourceRoot":"","sources":["../../../../src/components/actions/menu/menu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;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GAAG,MAAM,GAAG,IAAI;IAuBtD,+DAA+D;IACxD,cAAc,IAAI,YAAY,GAAG,IAAI;IAI5C,iFAAiF;IAC1E,gBAAgB,IAAI,MAAM;IAIjC;sEACkE;IAClE,OAAO,CAAC,MAAM;IAKd,oEAAoE;IACvD,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAmDxC,OAAO,CAAC,cAAc,CAkGpB;IAEF;;;;;;;;;OASG;IACH,OAAO,CAAC,eAAe,CAMrB;IAEF;;;;;OAKG;IACH,OAAO,CAAC,SAAS;IAMjB,6EAA6E;IAC7E,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,aAAa,CAAC,CAAgC;IAEtD,OAAO,CAAC,gBAAgB,CAAM;IAC9B,OAAO,CAAC,eAAe,CAAuB;IAC9C;;;uBAGmB;IACnB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAO;IAElD;;;;;;;;;;OAUG;IACH,OAAO,CAAC,gBAAgB;IAgCxB;;;;;;;;;;;;;;;;OAgBG;IACI,WAAW,QAAO,IAAI,CAkB3B;IAEF,OAAO,CAAC,0BAA0B,CAAS;IAC3C,OAAO,CAAC,yBAAyB,CAAS;IAE1C,+EAA+E;IAC/E,OAAO,CAAC,0BAA0B;IAQlC,OAAO,CAAC,mBAAmB,CAEzB;IAEF,OAAO,CAAC,aAAa,CAwDnB;IAEO,MAAM;CAGf;AAMD,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,WAAW,EAAE,QAAQ,CAAC;QACtB,gBAAgB,EAAE,YAAY,CAAC;QAC/B,mBAAmB,EAAE,eAAe,CAAC;QACrC,iBAAiB,EAAE,aAAa,CAAC;KACjC;CACD"}
|
|
@@ -20,6 +20,15 @@ import '../../status-and-feedback/inline-dialog/inline-dialog.js';
|
|
|
20
20
|
import { isKeyboardMode, isTouchMode } from '../../../utilities/input-modality.js';
|
|
21
21
|
import { breakpoints } from '../../../assets/styles/breakpoints.js';
|
|
22
22
|
import { translate } from '../../../utilities/translations.js';
|
|
23
|
+
/** Makes `host` a list item while its menu is a navigation menu, and takes
|
|
24
|
+
* that back when it is not. A `listitem` the consumer set by hand on an item
|
|
25
|
+
* goes too when the variant changes back; nothing else uses that role here. */
|
|
26
|
+
function syncListItemRole(host, variant) {
|
|
27
|
+
if (variant === 'navigation')
|
|
28
|
+
host.setAttribute('role', 'listitem');
|
|
29
|
+
else if (host.getAttribute('role') === 'listitem')
|
|
30
|
+
host.removeAttribute('role');
|
|
31
|
+
}
|
|
23
32
|
// # nldd-menu-divider
|
|
24
33
|
/**
|
|
25
34
|
* A horizontal rule between groups of items in an `nldd-menu`.
|
|
@@ -27,11 +36,19 @@ import { translate } from '../../../utilities/translations.js';
|
|
|
27
36
|
* @element nldd-menu-divider
|
|
28
37
|
*/
|
|
29
38
|
export class NLDDMenuDivider extends LitElement {
|
|
39
|
+
constructor() {
|
|
40
|
+
super(...arguments);
|
|
41
|
+
/** @internal The variant of the menu around it, set by that nldd-menu. */
|
|
42
|
+
this.menuVariant = null;
|
|
43
|
+
}
|
|
30
44
|
render() {
|
|
31
|
-
return menuDividerTemplate();
|
|
45
|
+
return menuDividerTemplate(this.menuVariant);
|
|
32
46
|
}
|
|
33
47
|
}
|
|
34
48
|
NLDDMenuDivider.styles = menuDividerStyles;
|
|
49
|
+
__decorate([
|
|
50
|
+
state()
|
|
51
|
+
], NLDDMenuDivider.prototype, "menuVariant", void 0);
|
|
35
52
|
if (!customElements.get('nldd-menu-divider')) {
|
|
36
53
|
customElements.define('nldd-menu-divider', NLDDMenuDivider);
|
|
37
54
|
}
|
|
@@ -63,6 +80,14 @@ export class NLDDMenuGroup extends LitElement {
|
|
|
63
80
|
super(...arguments);
|
|
64
81
|
this.text = '';
|
|
65
82
|
this._titleId = `nldd-menu-group-title-${NLDDMenuGroup._idCounter++}`;
|
|
83
|
+
/** @internal The variant of the menu around it, set by that nldd-menu. */
|
|
84
|
+
this.menuVariant = null;
|
|
85
|
+
}
|
|
86
|
+
updated(changed) {
|
|
87
|
+
// In a navigation menu the group is a list item that holds a list of
|
|
88
|
+
// its own, named by the title: a list may only own list items.
|
|
89
|
+
if (changed.has('menuVariant'))
|
|
90
|
+
syncListItemRole(this, this.menuVariant);
|
|
66
91
|
}
|
|
67
92
|
render() {
|
|
68
93
|
return menuGroupTemplate(this);
|
|
@@ -78,6 +103,9 @@ NLDDMenuGroup._idCounter = 0;
|
|
|
78
103
|
__decorate([
|
|
79
104
|
property({ reflect: true, converter: reflectNonDefault('') })
|
|
80
105
|
], NLDDMenuGroup.prototype, "text", void 0);
|
|
106
|
+
__decorate([
|
|
107
|
+
state()
|
|
108
|
+
], NLDDMenuGroup.prototype, "menuVariant", void 0);
|
|
81
109
|
if (!customElements.get('nldd-menu-group')) {
|
|
82
110
|
customElements.define('nldd-menu-group', NLDDMenuGroup);
|
|
83
111
|
}
|
|
@@ -197,6 +225,10 @@ export class NLDDMenuItem extends LitElement {
|
|
|
197
225
|
this._cachedSubmenuEl = this.querySelector(':scope > nldd-menu');
|
|
198
226
|
}
|
|
199
227
|
updated(changedProperties) {
|
|
228
|
+
// In a navigation menu the item is a list item, and the link inside it
|
|
229
|
+
// is just a link.
|
|
230
|
+
if (changedProperties.has('menuVariant'))
|
|
231
|
+
syncListItemRole(this, this.menuVariant);
|
|
200
232
|
// An item that becomes checkable, or stops being so, changes whether its
|
|
201
233
|
// menu reserves the check-mark column, also while the menu is open.
|
|
202
234
|
if (changedProperties.has('type') && changedProperties.get('type') !== undefined && this.menuVariant) {
|
|
@@ -356,6 +388,7 @@ const defaultFilterFn = (query, item) => {
|
|
|
356
388
|
*
|
|
357
389
|
* @element nldd-menu
|
|
358
390
|
*
|
|
391
|
+
* @attr {'menu'|'listbox'|'navigation'} variant - What the menu is (default 'menu'). `menu` is a menu of actions: `role="menu"` with menu items, for things you do. `listbox` is the popup of a combobox: `role="listbox"` with options, focus stays in the field. `navigation` is a submenu in a site navigation: a list of links (`role="list"`, each item a list item around a real link), because a screen reader treats a menu as an application and reads a list of links as what it is. Every item takes an `href`. Tab reaches each link, the arrow keys, Home and End move between them, Escape closes and returns focus to the trigger, and the menu closes when focus leaves it. The trigger says `aria-expanded` and promises no menu. Checkbox and radio items, shortcuts and `filter()` belong to actions and warn in development here. A submenu of a navigation menu is a navigation menu too. The variant sets `role="listitem"` on its items and groups, and takes it off again when it changes back, also where you had set that role yourself.
|
|
359
392
|
* @attr {string} width - Explicit width, pinned exactly. Without it the menu sizes to its content between a minimum and a viewport-aware maximum (min(100vw - inset, 640px)).
|
|
360
393
|
* @attr {string} anchor - ID of the anchor element. Positions the menu against it AND makes it a toggle: the menu listens on document click and opens/closes itself when the click lands on the anchor. Use this for a menu hung off a button. For a menu you open yourself (a type-ahead under a text field, say), set the `anchorElement` property instead — same positioning, no toggle.
|
|
361
394
|
* @attr {string} placement - Floating UI placement. Default: 'bottom-start'.
|
|
@@ -374,9 +407,8 @@ export class NLDDMenu extends LitElement {
|
|
|
374
407
|
constructor() {
|
|
375
408
|
super(...arguments);
|
|
376
409
|
/**
|
|
377
|
-
*
|
|
378
|
-
*
|
|
379
|
-
* Default: 'menu'.
|
|
410
|
+
* What the menu is, which sets its roles and part of its keyboard. See the
|
|
411
|
+
* `variant` attribute in the docblock above.
|
|
380
412
|
*/
|
|
381
413
|
this.variant = 'menu';
|
|
382
414
|
/**
|
|
@@ -538,6 +570,9 @@ export class NLDDMenu extends LitElement {
|
|
|
538
570
|
this._isOpen = reallyOpen;
|
|
539
571
|
this._syncAnchorPopupState(reallyOpen);
|
|
540
572
|
};
|
|
573
|
+
/** The popup type this menu gave its anchor, so a later variant can take
|
|
574
|
+
* it back without touching one the consumer chose. */
|
|
575
|
+
this._seededPopupType = null;
|
|
541
576
|
// — Event handlers ————————————————————————————————————————————————————————
|
|
542
577
|
this._handleDocumentClick = (event) => {
|
|
543
578
|
if (this.anchorElement)
|
|
@@ -1045,6 +1080,12 @@ export class NLDDMenu extends LitElement {
|
|
|
1045
1080
|
};
|
|
1046
1081
|
// — Private handlers ——————————————————————————————————————————————————————
|
|
1047
1082
|
this._handleKeydown = (event) => {
|
|
1083
|
+
// Only a navigation menu closes on a Tab out; see _handleFocusOut.
|
|
1084
|
+
if (event.key === 'Tab' && this.variant === 'navigation') {
|
|
1085
|
+
this._tabbing = true;
|
|
1086
|
+
clearTimeout(this._tabbingTimer);
|
|
1087
|
+
this._tabbingTimer = setTimeout(() => { this._tabbing = false; });
|
|
1088
|
+
}
|
|
1048
1089
|
const items = this._getVisibleItems();
|
|
1049
1090
|
if (items.length === 0)
|
|
1050
1091
|
return;
|
|
@@ -1128,12 +1169,36 @@ export class NLDDMenu extends LitElement {
|
|
|
1128
1169
|
// Typeahead (ARIA APG menu pattern): typing a single printable
|
|
1129
1170
|
// character jumps to the next item whose visible text starts
|
|
1130
1171
|
// with it. Repeated presses cycle through matches.
|
|
1131
|
-
|
|
1172
|
+
// Not in a navigation menu: there the letter keys are the screen
|
|
1173
|
+
// reader's, for moving through links and headings.
|
|
1174
|
+
if (this.variant !== 'navigation' && event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey) {
|
|
1132
1175
|
this._handleTypeahead(event, items, index);
|
|
1133
1176
|
}
|
|
1134
1177
|
}
|
|
1135
1178
|
}
|
|
1136
1179
|
};
|
|
1180
|
+
/**
|
|
1181
|
+
* A navigation menu closes when focus leaves it, the way a disclosure in a
|
|
1182
|
+
* site navigation does: Tab past the last link and the menu is gone, with
|
|
1183
|
+
* nothing left open over the page. An action menu keeps its own rules.
|
|
1184
|
+
*
|
|
1185
|
+
* Only when focus goes somewhere, or when Tab took it. Without a target it
|
|
1186
|
+
* is the window losing focus or a press on something that takes none, and
|
|
1187
|
+
* light dismiss covers those. Tab past the last link of the page has no
|
|
1188
|
+
* target either, though, and that one does leave the menu.
|
|
1189
|
+
*/
|
|
1190
|
+
this._handleFocusOut = (event) => {
|
|
1191
|
+
if (this.variant !== 'navigation')
|
|
1192
|
+
return;
|
|
1193
|
+
if (!this.matches(':popover-open'))
|
|
1194
|
+
return;
|
|
1195
|
+
const next = event.relatedTarget;
|
|
1196
|
+
if (next ? this.contains(next) || this._isAnchor(next) : !this._tabbing)
|
|
1197
|
+
return;
|
|
1198
|
+
this.hidePopover();
|
|
1199
|
+
};
|
|
1200
|
+
/** True from a Tab keydown until the focus change it causes has happened. */
|
|
1201
|
+
this._tabbing = false;
|
|
1137
1202
|
this._typeaheadBuffer = '';
|
|
1138
1203
|
this._typeaheadTimer = null;
|
|
1139
1204
|
// A popover paints at its default position the instant it opens, before our async
|
|
@@ -1158,16 +1223,26 @@ export class NLDDMenu extends LitElement {
|
|
|
1158
1223
|
* place. A submenu's items are its own and are left to it.
|
|
1159
1224
|
*/
|
|
1160
1225
|
this._claimItems = () => {
|
|
1226
|
+
// A submenu of a navigation menu is navigation too. Set before the
|
|
1227
|
+
// items are claimed, so they get one answer and not two.
|
|
1228
|
+
if (this.variant === 'navigation') {
|
|
1229
|
+
Array.from(this.querySelectorAll('nldd-menu')).forEach(menu => { menu.variant = 'navigation'; });
|
|
1230
|
+
}
|
|
1161
1231
|
const items = Array.from(this.querySelectorAll('nldd-menu-item'));
|
|
1162
1232
|
items.forEach(item => {
|
|
1163
1233
|
item.menuVariant = this.variant;
|
|
1164
1234
|
});
|
|
1235
|
+
Array.from(this.querySelectorAll('nldd-menu-divider, nldd-menu-group'))
|
|
1236
|
+
.forEach(part => { part.menuVariant = this.variant; });
|
|
1237
|
+
this._warnOnActionsInNavigation(items);
|
|
1165
1238
|
const own = items.filter(item => item.closest('nldd-menu') === this);
|
|
1166
1239
|
const checkColumn = this.variant === 'menu' && own.some(item => item.type !== 'button');
|
|
1167
1240
|
own.forEach(item => {
|
|
1168
1241
|
item.checkColumn = checkColumn;
|
|
1169
1242
|
});
|
|
1170
1243
|
};
|
|
1244
|
+
this._warnedActionsInNavigation = false;
|
|
1245
|
+
this._warnedFilterInNavigation = false;
|
|
1171
1246
|
this._handleBeforeToggle = (event) => {
|
|
1172
1247
|
if (event.newState === 'open')
|
|
1173
1248
|
this.removeAttribute('positioned');
|
|
@@ -1303,6 +1378,8 @@ export class NLDDMenu extends LitElement {
|
|
|
1303
1378
|
}
|
|
1304
1379
|
if (changedProperties.has('variant')) {
|
|
1305
1380
|
this._claimItems();
|
|
1381
|
+
if (changedProperties.get('variant') !== undefined)
|
|
1382
|
+
this._syncAnchorPopupState(this._isOpen);
|
|
1306
1383
|
}
|
|
1307
1384
|
// A new anchor arrives closed and unlabeled — seed it right away rather
|
|
1308
1385
|
// than at its first open. Covers the popup slot (where the invoking
|
|
@@ -1360,8 +1437,14 @@ export class NLDDMenu extends LitElement {
|
|
|
1360
1437
|
// of identical "more" buttons hearing plain "button" — exactly the
|
|
1361
1438
|
// moment the type matters most, since nothing has been opened yet.
|
|
1362
1439
|
// nldd-popover already works this way.
|
|
1363
|
-
|
|
1364
|
-
|
|
1440
|
+
// A navigation menu is a disclosure: the trigger says expanded or not,
|
|
1441
|
+
// and promises no menu.
|
|
1442
|
+
// One this menu seeded follows the variant when it changes; one the
|
|
1443
|
+
// consumer set is left alone.
|
|
1444
|
+
if ('popupType' in anchor && (!anchor.popupType || anchor.popupType === this._seededPopupType)) {
|
|
1445
|
+
const wanted = this.variant === 'navigation' ? '' : this.variant === 'listbox' ? 'listbox' : 'menu';
|
|
1446
|
+
anchor.popupType = wanted;
|
|
1447
|
+
this._seededPopupType = wanted || null;
|
|
1365
1448
|
}
|
|
1366
1449
|
if ('popoverTargetAction' in anchor) {
|
|
1367
1450
|
anchor.popoverTargetAction = isOpen ? 'hide' : 'show';
|
|
@@ -1750,6 +1833,7 @@ export class NLDDMenu extends LitElement {
|
|
|
1750
1833
|
this.addEventListener('beforetoggle', this._handleBeforeToggle);
|
|
1751
1834
|
this.addEventListener('toggle', this._handleToggle);
|
|
1752
1835
|
this.addEventListener('keydown', this._handleKeydown);
|
|
1836
|
+
this.addEventListener('focusout', this._handleFocusOut);
|
|
1753
1837
|
this.addEventListener('mouseenter', this._handleMenuItemMouseenter, true);
|
|
1754
1838
|
this.addEventListener('mouseleave', this._handleMouseleave);
|
|
1755
1839
|
this.addEventListener('menu-item-focused', this._handleMenuItemFocused);
|
|
@@ -1794,6 +1878,9 @@ export class NLDDMenu extends LitElement {
|
|
|
1794
1878
|
this._previousAnchorForResync?.removeEventListener('pointerdown', this._resyncAnchorFromPopoverState, true);
|
|
1795
1879
|
this._previousAnchorForResync = null;
|
|
1796
1880
|
this.removeEventListener('keydown', this._handleKeydown);
|
|
1881
|
+
this.removeEventListener('focusout', this._handleFocusOut);
|
|
1882
|
+
clearTimeout(this._tabbingTimer);
|
|
1883
|
+
this._tabbing = false;
|
|
1797
1884
|
this.removeEventListener('mouseenter', this._handleMenuItemMouseenter, true);
|
|
1798
1885
|
this.removeEventListener('mouseleave', this._handleMouseleave);
|
|
1799
1886
|
this.removeEventListener('menu-item-focused', this._handleMenuItemFocused);
|
|
@@ -1935,6 +2022,10 @@ export class NLDDMenu extends LitElement {
|
|
|
1935
2022
|
* keystroke. Text without the query in it is shown as it is.
|
|
1936
2023
|
*/
|
|
1937
2024
|
filter(query, { hide = true } = {}) {
|
|
2025
|
+
if (import.meta.env?.DEV && this.variant === 'navigation' && !this._warnedFilterInNavigation) {
|
|
2026
|
+
this._warnedFilterInNavigation = true;
|
|
2027
|
+
console.warn('nldd-menu: filter() belongs to a menu of actions or options. A navigation menu is a short list of links and is not filtered.');
|
|
2028
|
+
}
|
|
1938
2029
|
const allItems = Array.from(this.querySelectorAll('nldd-menu-item'));
|
|
1939
2030
|
allItems.forEach(item => {
|
|
1940
2031
|
const matches = !hide || !query || this.filterFn(query, item);
|
|
@@ -2068,6 +2159,18 @@ export class NLDDMenu extends LitElement {
|
|
|
2068
2159
|
top: `${y}px`,
|
|
2069
2160
|
});
|
|
2070
2161
|
}
|
|
2162
|
+
/**
|
|
2163
|
+
* Whether focus went to the control that opens this menu. Closing here
|
|
2164
|
+
* would hand the click that follows a closed menu, and it would open it
|
|
2165
|
+
* again; the toggle on the anchor does the closing. The node arrives
|
|
2166
|
+
* retargeted, so an anchor inside a shadow root shows up as its host.
|
|
2167
|
+
*/
|
|
2168
|
+
_isAnchor(node) {
|
|
2169
|
+
const anchor = this._getAnchorEl();
|
|
2170
|
+
if (!anchor)
|
|
2171
|
+
return false;
|
|
2172
|
+
return node === anchor || anchor.contains(node) || anchor.getRootNode().host === node;
|
|
2173
|
+
}
|
|
2071
2174
|
/**
|
|
2072
2175
|
* ARIA APG typeahead: characters typed within 500ms accumulate into a
|
|
2073
2176
|
* buffer; the menu jumps to the first item whose text starts with the
|
|
@@ -2104,6 +2207,16 @@ export class NLDDMenu extends LitElement {
|
|
|
2104
2207
|
}
|
|
2105
2208
|
}
|
|
2106
2209
|
}
|
|
2210
|
+
/** Checkable items and shortcuts belong to actions, not to a list of links. */
|
|
2211
|
+
_warnOnActionsInNavigation(items) {
|
|
2212
|
+
if (!import.meta.env?.DEV || this.variant !== 'navigation' || this._warnedActionsInNavigation)
|
|
2213
|
+
return;
|
|
2214
|
+
const stray = items.find(item => item.type !== 'button' || item.shortcut);
|
|
2215
|
+
if (!stray)
|
|
2216
|
+
return;
|
|
2217
|
+
this._warnedActionsInNavigation = true;
|
|
2218
|
+
console.warn('nldd-menu: variant="navigation" is a list of links. A checkbox or radio item, or a shortcut, belongs to an action menu and has no role to live in here. Use the default variant for actions.', stray);
|
|
2219
|
+
}
|
|
2107
2220
|
render() {
|
|
2108
2221
|
return menuTemplate.call(this, this._isEmpty, this.variant);
|
|
2109
2222
|
}
|