@material/web 2.5.1-nightly.b4de401.0 → 2.5.1-nightly.bd360db.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/button/internal/button.d.ts +10 -0
- package/button/internal/button.js +23 -2
- package/button/internal/button.js.map +1 -1
- package/chips/internal/assist-chip.d.ts +10 -0
- package/chips/internal/assist-chip.js +20 -1
- package/chips/internal/assist-chip.js.map +1 -1
- package/chips/internal/chip.js +3 -1
- package/chips/internal/chip.js.map +1 -1
- package/chips/internal/input-chip.d.ts +10 -0
- package/chips/internal/input-chip.js +20 -1
- package/chips/internal/input-chip.js.map +1 -1
- package/custom-elements.json +25295 -20106
- package/iconbutton/internal/icon-button.d.ts +10 -0
- package/iconbutton/internal/icon-button.js +21 -2
- package/iconbutton/internal/icon-button.js.map +1 -1
- package/internal/directives/safe-href.d.ts +23 -0
- package/internal/directives/safe-href.js +44 -0
- package/internal/directives/safe-href.js.map +1 -0
- package/labs/aria/buttons/keyboard_click_handler.d.ts +25 -0
- package/labs/aria/buttons/keyboard_click_handler.js +74 -0
- package/labs/aria/buttons/keyboard_click_handler.js.map +1 -0
- package/labs/aria/buttons/md-aria-toggle.d.ts +29 -0
- package/labs/aria/buttons/md-aria-toggle.js +67 -0
- package/labs/aria/buttons/md-aria-toggle.js.map +1 -0
- package/labs/aria/buttons/toggle.d.ts +40 -0
- package/labs/aria/buttons/toggle.js +100 -0
- package/labs/aria/buttons/toggle.js.map +1 -0
- package/labs/aria/command.d.ts +18 -0
- package/labs/aria/command.js +204 -0
- package/labs/aria/command.js.map +1 -0
- package/labs/aria/menu/fieldset.d.ts +36 -0
- package/labs/aria/menu/fieldset.js +103 -0
- package/labs/aria/menu/fieldset.js.map +1 -0
- package/labs/aria/menu/internal.d.ts +15 -0
- package/labs/aria/menu/internal.js +16 -0
- package/labs/aria/menu/internal.js.map +1 -0
- package/labs/aria/menu/md-aria-fieldset.d.ts +11 -0
- package/labs/aria/menu/md-aria-fieldset.js +8 -0
- package/labs/aria/menu/md-aria-fieldset.js.map +1 -0
- package/labs/aria/menu/md-aria-menuitem.d.ts +11 -0
- package/labs/aria/menu/md-aria-menuitem.js +8 -0
- package/labs/aria/menu/md-aria-menuitem.js.map +1 -0
- package/labs/aria/menu/md-aria-menulist.d.ts +11 -0
- package/labs/aria/menu/md-aria-menulist.js +8 -0
- package/labs/aria/menu/md-aria-menulist.js.map +1 -0
- package/labs/aria/menu/menuitem.d.ts +59 -0
- package/labs/aria/menu/menuitem.js +237 -0
- package/labs/aria/menu/menuitem.js.map +1 -0
- package/labs/aria/menu/menulist.d.ts +21 -0
- package/labs/aria/menu/menulist.js +102 -0
- package/labs/aria/menu/menulist.js.map +1 -0
- package/labs/aria/menu/shared-slotted-content.d.ts +10 -0
- package/labs/aria/menu/shared-slotted-content.js +51 -0
- package/labs/aria/menu/shared-slotted-content.js.map +1 -0
- package/labs/aria/pseudo-classes.d.ts +19 -0
- package/labs/aria/pseudo-classes.js +22 -0
- package/labs/aria/pseudo-classes.js.map +1 -0
- package/labs/aria/query-associated.d.ts +23 -0
- package/labs/aria/query-associated.js +36 -0
- package/labs/aria/query-associated.js.map +1 -0
- package/labs/aria/tabs/md-aria-tab.d.ts +11 -0
- package/labs/aria/tabs/md-aria-tab.js +8 -0
- package/labs/aria/tabs/md-aria-tab.js.map +1 -0
- package/labs/aria/tabs/md-aria-tablist.d.ts +11 -0
- package/labs/aria/tabs/md-aria-tablist.js +8 -0
- package/labs/aria/tabs/md-aria-tablist.js.map +1 -0
- package/labs/aria/tabs/md-aria-tabpanel.d.ts +11 -0
- package/labs/aria/tabs/md-aria-tabpanel.js +8 -0
- package/labs/aria/tabs/md-aria-tabpanel.js.map +1 -0
- package/labs/aria/tabs/tab.d.ts +33 -0
- package/labs/aria/tabs/tab.js +93 -0
- package/labs/aria/tabs/tab.js.map +1 -0
- package/labs/aria/tabs/tablist.d.ts +65 -0
- package/labs/aria/tabs/tablist.js +206 -0
- package/labs/aria/tabs/tablist.js.map +1 -0
- package/labs/aria/tabs/tabpanel.d.ts +26 -0
- package/labs/aria/tabs/tabpanel.js +53 -0
- package/labs/aria/tabs/tabpanel.js.map +1 -0
- package/labs/gb/components/appbar/_app-bar-tokens.scss +136 -0
- package/labs/gb/components/appbar/app-bar-element.d.ts +54 -0
- package/labs/gb/components/appbar/app-bar-element.js +145 -0
- package/labs/gb/components/appbar/app-bar-element.js.map +1 -0
- package/labs/gb/components/appbar/app-bar.css +4 -0
- package/labs/gb/components/appbar/app-bar.css.map +1 -0
- package/labs/gb/components/appbar/app-bar.cssresult.d.ts +3 -0
- package/labs/gb/components/appbar/app-bar.cssresult.js +14 -0
- package/labs/gb/components/appbar/app-bar.cssresult.js.map +1 -0
- package/labs/gb/components/appbar/app-bar.d.ts +71 -0
- package/labs/gb/components/appbar/app-bar.js +96 -0
- package/labs/gb/components/appbar/app-bar.js.map +1 -0
- package/labs/gb/components/appbar/app-bar.scss +168 -0
- package/labs/gb/components/appbar/md-gb-app-bar.d.ts +12 -0
- package/labs/gb/components/appbar/md-gb-app-bar.js +8 -0
- package/labs/gb/components/appbar/md-gb-app-bar.js.map +1 -0
- package/labs/gb/components/badge/badge-element.d.ts +1 -0
- package/labs/gb/components/badge/badge-element.js +1 -0
- package/labs/gb/components/badge/badge-element.js.map +1 -1
- package/labs/gb/components/badge/badge.css +1 -1
- package/labs/gb/components/badge/badge.css.map +1 -1
- package/labs/gb/components/badge/badge.cssresult.js +1 -1
- package/labs/gb/components/badge/badge.cssresult.js.map +1 -1
- package/labs/gb/components/badge/badge.scss +1 -0
- package/labs/gb/components/button/_button-tokens.scss +28 -22
- package/labs/gb/components/button/button-element.d.ts +20 -5
- package/labs/gb/components/button/button-element.js +43 -8
- package/labs/gb/components/button/button-element.js.map +1 -1
- package/labs/gb/components/button/button.css +1 -1
- package/labs/gb/components/button/button.css.map +1 -1
- package/labs/gb/components/button/button.cssresult.js +1 -1
- package/labs/gb/components/button/button.cssresult.js.map +1 -1
- package/labs/gb/components/button/button.js +1 -1
- package/labs/gb/components/button/button.js.map +1 -1
- package/labs/gb/components/button/button.scss +5 -6
- package/labs/gb/components/card/card-element.d.ts +1 -0
- package/labs/gb/components/card/card-element.js +1 -0
- package/labs/gb/components/card/card-element.js.map +1 -1
- package/labs/gb/components/checkbox/checkbox-element.d.ts +1 -0
- package/labs/gb/components/checkbox/checkbox-element.js +1 -0
- package/labs/gb/components/checkbox/checkbox-element.js.map +1 -1
- package/labs/gb/components/chip/_chip-tokens.scss +167 -0
- package/labs/gb/components/chip/chip-element.d.ts +84 -0
- package/labs/gb/components/chip/chip-element.js +255 -0
- package/labs/gb/components/chip/chip-element.js.map +1 -0
- package/labs/gb/components/chip/chip.css +4 -0
- package/labs/gb/components/chip/chip.css.map +1 -0
- package/labs/gb/components/chip/chip.cssresult.d.ts +3 -0
- package/labs/gb/components/chip/chip.cssresult.js +14 -0
- package/labs/gb/components/chip/chip.cssresult.js.map +1 -0
- package/labs/gb/components/chip/chip.d.ts +77 -0
- package/labs/gb/components/chip/chip.js +99 -0
- package/labs/gb/components/chip/chip.js.map +1 -0
- package/labs/gb/components/chip/chip.scss +100 -0
- package/labs/gb/components/chip/md-gb-chip.d.ts +13 -0
- package/labs/gb/components/chip/md-gb-chip.js +9 -0
- package/labs/gb/components/chip/md-gb-chip.js.map +1 -0
- package/labs/gb/components/divider/divider-element.d.ts +1 -0
- package/labs/gb/components/divider/divider-element.js +1 -0
- package/labs/gb/components/divider/divider-element.js.map +1 -1
- package/labs/gb/components/fab/_fab-tokens.scss +4 -1
- package/labs/gb/components/fab/fab-element.d.ts +2 -0
- package/labs/gb/components/fab/fab-element.js +2 -0
- package/labs/gb/components/fab/fab-element.js.map +1 -1
- package/labs/gb/components/fab/fab.css +1 -1
- package/labs/gb/components/fab/fab.css.map +1 -1
- package/labs/gb/components/fab/fab.cssresult.js +1 -1
- package/labs/gb/components/fab/fab.cssresult.js.map +1 -1
- package/labs/gb/components/fab/fab.scss +2 -0
- package/labs/gb/components/iconbutton/_icon-button-tokens.scss +13 -4
- package/labs/gb/components/iconbutton/icon-button-element.d.ts +15 -1
- package/labs/gb/components/iconbutton/icon-button-element.js +38 -4
- package/labs/gb/components/iconbutton/icon-button-element.js.map +1 -1
- package/labs/gb/components/iconbutton/icon-button.css +1 -1
- package/labs/gb/components/iconbutton/icon-button.css.map +1 -1
- package/labs/gb/components/iconbutton/icon-button.cssresult.js +1 -1
- package/labs/gb/components/iconbutton/icon-button.cssresult.js.map +1 -1
- package/labs/gb/components/iconbutton/icon-button.js +1 -1
- package/labs/gb/components/iconbutton/icon-button.js.map +1 -1
- package/labs/gb/components/iconbutton/icon-button.scss +8 -0
- package/labs/gb/components/list/_list-tokens.scss +11 -14
- package/labs/gb/components/list/list-element.d.ts +1 -0
- package/labs/gb/components/list/list-element.js +1 -0
- package/labs/gb/components/list/list-element.js.map +1 -1
- package/labs/gb/components/list/list-item-element.d.ts +5 -0
- package/labs/gb/components/list/list-item-element.js +5 -0
- package/labs/gb/components/list/list-item-element.js.map +1 -1
- package/labs/gb/components/list/list.css +1 -1
- package/labs/gb/components/list/list.css.map +1 -1
- package/labs/gb/components/list/list.cssresult.js +1 -1
- package/labs/gb/components/list/list.cssresult.js.map +1 -1
- package/labs/gb/components/list/list.scss +6 -0
- package/labs/gb/components/menu/_menu-tokens.scss +45 -16
- package/labs/gb/components/menu/menu-element.d.ts +1 -0
- package/labs/gb/components/menu/menu-element.js +1 -0
- package/labs/gb/components/menu/menu-element.js.map +1 -1
- package/labs/gb/components/menu/menu-group-element.d.ts +1 -0
- package/labs/gb/components/menu/menu-group-element.js +1 -0
- package/labs/gb/components/menu/menu-group-element.js.map +1 -1
- package/labs/gb/components/menu/menu-item-element.d.ts +5 -1
- package/labs/gb/components/menu/menu-item-element.js +5 -1
- package/labs/gb/components/menu/menu-item-element.js.map +1 -1
- package/labs/gb/components/menu/menu.css +1 -1
- package/labs/gb/components/menu/menu.css.map +1 -1
- package/labs/gb/components/menu/menu.cssresult.js +1 -1
- package/labs/gb/components/menu/menu.cssresult.js.map +1 -1
- package/labs/gb/components/menu/menu.scss +4 -0
- package/labs/gb/components/radio/radio-element.d.ts +1 -0
- package/labs/gb/components/radio/radio-element.js +1 -0
- package/labs/gb/components/radio/radio-element.js.map +1 -1
- package/labs/gb/components/shared/pseudo-classes.d.ts +1 -7
- package/labs/gb/components/shared/pseudo-classes.js +1 -9
- package/labs/gb/components/shared/pseudo-classes.js.map +1 -1
- package/labs/gb/components/shared/update-class-list.d.ts +22 -0
- package/labs/gb/components/shared/update-class-list.js +26 -0
- package/labs/gb/components/shared/update-class-list.js.map +1 -0
- package/labs/gb/components/splitbutton/split-button-element.d.ts +1 -0
- package/labs/gb/components/splitbutton/split-button-element.js +1 -0
- package/labs/gb/components/splitbutton/split-button-element.js.map +1 -1
- package/labs/gb/components/switch/switch-element.d.ts +1 -0
- package/labs/gb/components/switch/switch-element.js +1 -0
- package/labs/gb/components/switch/switch-element.js.map +1 -1
- package/labs/gb/components/switch/switch.js +5 -2
- package/labs/gb/components/switch/switch.js.map +1 -1
- package/labs/gb/components/tabs/_tabs-tokens.scss +177 -0
- package/labs/gb/components/tabs/md-gb-tab.d.ts +12 -0
- package/labs/gb/components/tabs/md-gb-tab.js +8 -0
- package/labs/gb/components/tabs/md-gb-tab.js.map +1 -0
- package/labs/gb/components/tabs/md-gb-tabs.d.ts +12 -0
- package/labs/gb/components/tabs/md-gb-tabs.js +8 -0
- package/labs/gb/components/tabs/md-gb-tabs.js.map +1 -0
- package/labs/gb/components/tabs/tab-element.d.ts +42 -0
- package/labs/gb/components/tabs/tab-element.js +75 -0
- package/labs/gb/components/tabs/tab-element.js.map +1 -0
- package/labs/gb/components/tabs/tabs-element.d.ts +37 -0
- package/labs/gb/components/tabs/tabs-element.js +67 -0
- package/labs/gb/components/tabs/tabs-element.js.map +1 -0
- package/labs/gb/components/tabs/tabs.css +4 -0
- package/labs/gb/components/tabs/tabs.css.map +1 -0
- package/labs/gb/components/tabs/tabs.cssresult.d.ts +3 -0
- package/labs/gb/components/tabs/tabs.cssresult.js +14 -0
- package/labs/gb/components/tabs/tabs.cssresult.js.map +1 -0
- package/labs/gb/components/tabs/tabs.d.ts +98 -0
- package/labs/gb/components/tabs/tabs.js +112 -0
- package/labs/gb/components/tabs/tabs.js.map +1 -0
- package/labs/gb/components/tabs/tabs.scss +301 -0
- package/labs/gb/components/toolbar/_toolbar-tokens.scss +70 -0
- package/labs/gb/components/toolbar/md-gb-toolbar.d.ts +12 -0
- package/labs/gb/components/toolbar/md-gb-toolbar.js +8 -0
- package/labs/gb/components/toolbar/md-gb-toolbar.js.map +1 -0
- package/labs/gb/components/toolbar/toolbar-element.d.ts +56 -0
- package/labs/gb/components/toolbar/toolbar-element.js +120 -0
- package/labs/gb/components/toolbar/toolbar-element.js.map +1 -0
- package/labs/gb/components/toolbar/toolbar.css +4 -0
- package/labs/gb/components/toolbar/toolbar.css.map +1 -0
- package/labs/gb/components/toolbar/toolbar.cssresult.d.ts +3 -0
- package/labs/gb/components/toolbar/toolbar.cssresult.js +14 -0
- package/labs/gb/components/toolbar/toolbar.cssresult.js.map +1 -0
- package/labs/gb/components/toolbar/toolbar.d.ts +56 -0
- package/labs/gb/components/toolbar/toolbar.js +60 -0
- package/labs/gb/components/toolbar/toolbar.js.map +1 -0
- package/labs/gb/components/toolbar/toolbar.scss +240 -0
- package/labs/gb/styles/icon/icon-element.d.ts +1 -0
- package/labs/gb/styles/icon/icon-element.js +1 -0
- package/labs/gb/styles/icon/icon-element.js.map +1 -1
- package/labs/gb/styles/tailwind.css +1 -1
- package/labs/gb/styles/tailwind.css.map +1 -1
- package/labs/gb/styles/tailwind.cssresult.js +1 -1
- package/labs/gb/styles/tailwind.cssresult.js.map +1 -1
- package/labs/gb/styles/tailwind.scss +2 -0
- package/list/internal/listitem/list-item.d.ts +10 -0
- package/list/internal/listitem/list-item.js +20 -1
- package/list/internal/listitem/list-item.js.map +1 -1
- package/menu/internal/menuitem/menu-item.d.ts +10 -0
- package/menu/internal/menuitem/menu-item.js +20 -1
- package/menu/internal/menuitem/menu-item.js.map +1 -1
- package/package.json +2 -1
- package/radio/internal/single-selection-controller.js +4 -1
- package/radio/internal/single-selection-controller.js.map +1 -1
- package/testing/harness.js +3 -0
- package/testing/harness.js.map +1 -1
- package/types/command-event.d.ts +34 -0
- package/types/popover.d.ts +25 -0
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { __decorate } from "tslib";
|
|
7
|
+
import { LitElement, css, html } from 'lit';
|
|
8
|
+
import { property } from 'lit/decorators.js';
|
|
9
|
+
import { afterDispatch, setupDispatchHooks, } from '../../../internal/events/dispatch-hooks.js';
|
|
10
|
+
import { mixinCustomStateSet, toggleState, } from '../../behaviors/custom-state-set.js';
|
|
11
|
+
import { internals, mixinElementInternals, } from '../../behaviors/element-internals.js';
|
|
12
|
+
import { mixinFocusable } from '../../behaviors/focusable.js';
|
|
13
|
+
import { sharedCommandInvokerActivationSteps } from '../command.js';
|
|
14
|
+
import { resetMenuitemCheckedness, setCheckedness, updateUsedValues, } from './internal.js';
|
|
15
|
+
const baseClass = mixinCustomStateSet(mixinFocusable(mixinElementInternals(LitElement)));
|
|
16
|
+
/**
|
|
17
|
+
* An element implementing the proposed `<menuitem>` built-in element.
|
|
18
|
+
*
|
|
19
|
+
* @fires {Event} checked - Fired when the item is checked or unchecked.
|
|
20
|
+
* @cssstate enabled - True when the item is enabled.
|
|
21
|
+
* @cssstate disabled - True when the item is disabled.
|
|
22
|
+
* @cssstate checked - True when the item is checked.
|
|
23
|
+
*/
|
|
24
|
+
export class AriaMenuitemElement extends baseClass {
|
|
25
|
+
get usedCheckable() {
|
|
26
|
+
if (this.cachedAncestorMenulist === null ||
|
|
27
|
+
this.cachedAncestorFieldset === null) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
return this.cachedAncestorFieldset.checkable;
|
|
31
|
+
}
|
|
32
|
+
get usedDisabled() {
|
|
33
|
+
return this.cachedAncestorFieldset?.disabled || this.internalDisabled;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Recomputes this element's used `disabled` and `checkable` values and
|
|
37
|
+
* projects them onto its ARIA attributes and custom states.
|
|
38
|
+
*
|
|
39
|
+
* `<md-aria-fieldset>` calls this on its items when a value they inherit from
|
|
40
|
+
* it changes.
|
|
41
|
+
*/
|
|
42
|
+
[updateUsedValues]() {
|
|
43
|
+
const usedDisabled = this.usedDisabled;
|
|
44
|
+
this[internals].ariaDisabled = String(usedDisabled);
|
|
45
|
+
this[toggleState]('disabled', usedDisabled);
|
|
46
|
+
this[toggleState]('enabled', !usedDisabled);
|
|
47
|
+
const usedCheckable = this.usedCheckable;
|
|
48
|
+
switch (usedCheckable) {
|
|
49
|
+
case null:
|
|
50
|
+
this[internals].role = 'menuitem';
|
|
51
|
+
this[toggleState]('_checkable', false);
|
|
52
|
+
break;
|
|
53
|
+
case 'single':
|
|
54
|
+
this[internals].role = 'menuitemradio';
|
|
55
|
+
this[toggleState]('_checkable', true);
|
|
56
|
+
break;
|
|
57
|
+
case 'multiple':
|
|
58
|
+
default:
|
|
59
|
+
this[internals].role = 'menuitemcheckbox';
|
|
60
|
+
this[toggleState]('_checkable', true);
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
const usedChecked = usedCheckable !== null ? this.checkedness : null;
|
|
64
|
+
if (usedChecked === null) {
|
|
65
|
+
this[internals].ariaChecked = null;
|
|
66
|
+
this[toggleState]('checked', false);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
this[internals].ariaChecked = String(usedChecked);
|
|
70
|
+
this[toggleState]('checked', usedChecked);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
resetAncestorElementCache() {
|
|
74
|
+
this.cachedAncestorMenulist = null;
|
|
75
|
+
this.cachedAncestorFieldset = null;
|
|
76
|
+
for (let node = this.parentNode; node instanceof HTMLElement; node = node.parentNode) {
|
|
77
|
+
if (node.localName === 'md-aria-menulist') {
|
|
78
|
+
this.cachedAncestorMenulist = node;
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
if (node.localName === 'md-aria-fieldset') {
|
|
82
|
+
this.cachedAncestorFieldset = node;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
this[updateUsedValues]();
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Sets this element's checkedness directly, without running the rest of the
|
|
89
|
+
* 'check a menuitem element' steps.
|
|
90
|
+
*
|
|
91
|
+
* `<md-aria-fieldset>` calls this to reset the items excluded by a newly
|
|
92
|
+
* checked item.
|
|
93
|
+
*
|
|
94
|
+
* @param value The new checkedness.
|
|
95
|
+
*/
|
|
96
|
+
[setCheckedness](value) {
|
|
97
|
+
this.checkedness = value;
|
|
98
|
+
this[updateUsedValues]();
|
|
99
|
+
}
|
|
100
|
+
checkAMenuitemElement(isChecked, fireEvents) {
|
|
101
|
+
if (this.usedCheckable === null) {
|
|
102
|
+
// TODO: Handle the invoked submenu.
|
|
103
|
+
return 'close-menulist';
|
|
104
|
+
}
|
|
105
|
+
this[setCheckedness](isChecked);
|
|
106
|
+
this.dirtyCheckedness = true;
|
|
107
|
+
if (fireEvents) {
|
|
108
|
+
this.dispatchEvent(new Event('checked'));
|
|
109
|
+
}
|
|
110
|
+
if (this.checkedness && this.usedCheckable === 'single') {
|
|
111
|
+
this.cachedAncestorFieldset?.[resetMenuitemCheckedness](this);
|
|
112
|
+
}
|
|
113
|
+
return this.usedCheckable === 'single' ? 'close-menulist' : 'stay-open';
|
|
114
|
+
}
|
|
115
|
+
get disabled() {
|
|
116
|
+
return this.internalDisabled;
|
|
117
|
+
}
|
|
118
|
+
set disabled(value) {
|
|
119
|
+
value = Boolean(value);
|
|
120
|
+
const oldValue = this.internalDisabled;
|
|
121
|
+
this.internalDisabled = value;
|
|
122
|
+
this[updateUsedValues]();
|
|
123
|
+
this.requestUpdate('disabled', oldValue);
|
|
124
|
+
}
|
|
125
|
+
get checked() {
|
|
126
|
+
return this.checkedness;
|
|
127
|
+
}
|
|
128
|
+
set checked(value) {
|
|
129
|
+
this.checkAMenuitemElement(value, false);
|
|
130
|
+
}
|
|
131
|
+
get defaultChecked() {
|
|
132
|
+
return this.internalDefaultChecked;
|
|
133
|
+
}
|
|
134
|
+
set defaultChecked(value) {
|
|
135
|
+
value = Boolean(value);
|
|
136
|
+
const oldValue = this.internalDefaultChecked;
|
|
137
|
+
this.internalDefaultChecked = value;
|
|
138
|
+
if (!this.dirtyCheckedness) {
|
|
139
|
+
// The proposed spec DOES NOT call into the full 'check a menuitem
|
|
140
|
+
// element' steps - it only sets checkedness - but this seems like the
|
|
141
|
+
// only reasonable behavior when the element is part of a single-checkable
|
|
142
|
+
// fieldset. Otherwise, multiple elements with `defaultchecked` could
|
|
143
|
+
// become checked.
|
|
144
|
+
this.checkAMenuitemElement(value, false);
|
|
145
|
+
this.dirtyCheckedness = false;
|
|
146
|
+
}
|
|
147
|
+
this.requestUpdate('defaultChecked', oldValue);
|
|
148
|
+
}
|
|
149
|
+
constructor() {
|
|
150
|
+
super();
|
|
151
|
+
this.internalDisabled = false;
|
|
152
|
+
this.checkedness = false;
|
|
153
|
+
this.dirtyCheckedness = false;
|
|
154
|
+
this.internalDefaultChecked = false;
|
|
155
|
+
this.cachedAncestorMenulist = null;
|
|
156
|
+
this.cachedAncestorFieldset = null;
|
|
157
|
+
this[updateUsedValues]();
|
|
158
|
+
setupDispatchHooks(this, 'keydown', 'click');
|
|
159
|
+
this.addEventListener('keydown', (event) => {
|
|
160
|
+
afterDispatch(event, () => {
|
|
161
|
+
if (event.defaultPrevented) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
165
|
+
this.click();
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
this.addEventListener('click', (event) => {
|
|
170
|
+
afterDispatch(event, () => {
|
|
171
|
+
if (event.defaultPrevented || this.usedDisabled) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
const newChecked = !this.checkedness;
|
|
175
|
+
const closeBehavior = this.checkAMenuitemElement(newChecked, true);
|
|
176
|
+
// TODO: Handle the invoked submenu.
|
|
177
|
+
if (closeBehavior === 'close-menulist') {
|
|
178
|
+
// TODO: This should be the 'outermost containing menulist', not just
|
|
179
|
+
// the cached ancestor menulist.
|
|
180
|
+
this.cachedAncestorMenulist?.hidePopover();
|
|
181
|
+
}
|
|
182
|
+
sharedCommandInvokerActivationSteps(this, event);
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
render() {
|
|
187
|
+
return html `<span part="checkmark"></span><slot></slot>`;
|
|
188
|
+
}
|
|
189
|
+
connectedCallback() {
|
|
190
|
+
super.connectedCallback();
|
|
191
|
+
this.resetAncestorElementCache();
|
|
192
|
+
if (this.internalDefaultChecked && !this.dirtyCheckedness) {
|
|
193
|
+
this.checkAMenuitemElement(true, false);
|
|
194
|
+
this.dirtyCheckedness = false;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
disconnectedCallback() {
|
|
198
|
+
super.disconnectedCallback();
|
|
199
|
+
this.resetAncestorElementCache();
|
|
200
|
+
}
|
|
201
|
+
click() {
|
|
202
|
+
if (!this.usedDisabled) {
|
|
203
|
+
super.click();
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
AriaMenuitemElement.styles = [
|
|
208
|
+
css `
|
|
209
|
+
:host {
|
|
210
|
+
display: inline-flex;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
[part='checkmark'] {
|
|
214
|
+
&::before {
|
|
215
|
+
content: '\\2713' / '';
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
:host(:not(:state(_checkable))) & {
|
|
219
|
+
display: none;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
:host(:not(:state(checked))) & {
|
|
223
|
+
visibility: hidden;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
`,
|
|
227
|
+
];
|
|
228
|
+
__decorate([
|
|
229
|
+
property({ type: Boolean, reflect: true })
|
|
230
|
+
], AriaMenuitemElement.prototype, "disabled", null);
|
|
231
|
+
__decorate([
|
|
232
|
+
property({ type: Boolean, attribute: false })
|
|
233
|
+
], AriaMenuitemElement.prototype, "checked", null);
|
|
234
|
+
__decorate([
|
|
235
|
+
property({ type: Boolean, reflect: true })
|
|
236
|
+
], AriaMenuitemElement.prototype, "defaultChecked", null);
|
|
237
|
+
//# sourceMappingURL=menuitem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menuitem.js","sourceRoot":"","sources":["menuitem.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAoB,UAAU,EAAE,GAAG,EAAE,IAAI,EAAC,MAAM,KAAK,CAAC;AAC7D,OAAO,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EACL,aAAa,EACb,kBAAkB,GACnB,MAAM,4CAA4C,CAAC;AACpD,OAAO,EACL,mBAAmB,EACnB,WAAW,GACZ,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,SAAS,EACT,qBAAqB,GACtB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAC,cAAc,EAAC,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAC,mCAAmC,EAAC,MAAM,eAAe,CAAC;AAElE,OAAO,EACL,wBAAwB,EACxB,cAAc,EACd,gBAAgB,GACjB,MAAM,eAAe,CAAC;AAGvB,MAAM,SAAS,GAAG,mBAAmB,CACnC,cAAc,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC,CAClD,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,OAAO,mBAAoB,SAAQ,SAAS;IA8BhD,IAAY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AE,OAAO,EAAE,IAAI,EAAC,CAAC;mDAGxC;AAYD;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAC,CAAC;kDAG3C;AAMD;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;yDAGxC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {CSSResultOrNative, LitElement, css, html} from 'lit';\nimport {property} from 'lit/decorators.js';\nimport {\n afterDispatch,\n setupDispatchHooks,\n} from '../../../internal/events/dispatch-hooks.js';\nimport {\n mixinCustomStateSet,\n toggleState,\n} from '../../behaviors/custom-state-set.js';\nimport {\n internals,\n mixinElementInternals,\n} from '../../behaviors/element-internals.js';\nimport {mixinFocusable} from '../../behaviors/focusable.js';\nimport {sharedCommandInvokerActivationSteps} from '../command.js';\nimport type {AriaFieldsetElement, CheckableState} from './fieldset.js';\nimport {\n resetMenuitemCheckedness,\n setCheckedness,\n updateUsedValues,\n} from './internal.js';\nimport type {AriaMenulistElement} from './menulist.js';\n\nconst baseClass = mixinCustomStateSet(\n mixinFocusable(mixinElementInternals(LitElement)),\n);\n\n/**\n * An element implementing the proposed `<menuitem>` built-in element.\n *\n * @fires {Event} checked - Fired when the item is checked or unchecked.\n * @cssstate enabled - True when the item is enabled.\n * @cssstate disabled - True when the item is disabled.\n * @cssstate checked - True when the item is checked.\n */\nexport class AriaMenuitemElement extends baseClass {\n static override styles: CSSResultOrNative[] = [\n css`\n :host {\n display: inline-flex;\n }\n\n [part='checkmark'] {\n &::before {\n content: '\\\\2713' / '';\n }\n\n :host(:not(:state(_checkable))) & {\n display: none;\n }\n\n :host(:not(:state(checked))) & {\n visibility: hidden;\n }\n }\n `,\n ];\n\n private internalDisabled = false;\n private checkedness = false;\n private dirtyCheckedness = false;\n private internalDefaultChecked = false;\n private cachedAncestorMenulist: AriaMenulistElement | null = null;\n private cachedAncestorFieldset: AriaFieldsetElement | null = null;\n\n private get usedCheckable(): CheckableState {\n if (\n this.cachedAncestorMenulist === null ||\n this.cachedAncestorFieldset === null\n ) {\n return null;\n }\n\n return this.cachedAncestorFieldset.checkable;\n }\n\n private get usedDisabled(): boolean {\n return this.cachedAncestorFieldset?.disabled || this.internalDisabled;\n }\n\n /**\n * Recomputes this element's used `disabled` and `checkable` values and\n * projects them onto its ARIA attributes and custom states.\n *\n * `<md-aria-fieldset>` calls this on its items when a value they inherit from\n * it changes.\n */\n [updateUsedValues]() {\n const usedDisabled = this.usedDisabled;\n this[internals].ariaDisabled = String(usedDisabled);\n this[toggleState]('disabled', usedDisabled);\n this[toggleState]('enabled', !usedDisabled);\n\n const usedCheckable = this.usedCheckable;\n switch (usedCheckable) {\n case null:\n this[internals].role = 'menuitem';\n this[toggleState]('_checkable', false);\n break;\n case 'single':\n this[internals].role = 'menuitemradio';\n this[toggleState]('_checkable', true);\n break;\n case 'multiple':\n default:\n this[internals].role = 'menuitemcheckbox';\n this[toggleState]('_checkable', true);\n break;\n }\n\n const usedChecked: boolean | null =\n usedCheckable !== null ? this.checkedness : null;\n if (usedChecked === null) {\n this[internals].ariaChecked = null;\n this[toggleState]('checked', false);\n } else {\n this[internals].ariaChecked = String(usedChecked);\n this[toggleState]('checked', usedChecked);\n }\n }\n\n private resetAncestorElementCache() {\n this.cachedAncestorMenulist = null;\n this.cachedAncestorFieldset = null;\n\n for (\n let node = this.parentNode;\n node instanceof HTMLElement;\n node = node.parentNode\n ) {\n if (node.localName === 'md-aria-menulist') {\n this.cachedAncestorMenulist = node as AriaMenulistElement;\n break;\n }\n\n if (node.localName === 'md-aria-fieldset') {\n this.cachedAncestorFieldset = node as AriaFieldsetElement;\n }\n }\n\n this[updateUsedValues]();\n }\n\n /**\n * Sets this element's checkedness directly, without running the rest of the\n * 'check a menuitem element' steps.\n *\n * `<md-aria-fieldset>` calls this to reset the items excluded by a newly\n * checked item.\n *\n * @param value The new checkedness.\n */\n [setCheckedness](value: boolean) {\n this.checkedness = value;\n this[updateUsedValues]();\n }\n\n private checkAMenuitemElement(\n isChecked: boolean,\n fireEvents: boolean,\n ): 'close-menulist' | 'stay-open' {\n if (this.usedCheckable === null) {\n // TODO: Handle the invoked submenu.\n return 'close-menulist';\n }\n\n this[setCheckedness](isChecked);\n this.dirtyCheckedness = true;\n\n if (fireEvents) {\n this.dispatchEvent(new Event('checked'));\n }\n\n if (this.checkedness && this.usedCheckable === 'single') {\n this.cachedAncestorFieldset?.[resetMenuitemCheckedness](this);\n }\n\n return this.usedCheckable === 'single' ? 'close-menulist' : 'stay-open';\n }\n\n @property({type: Boolean, reflect: true})\n get disabled() {\n return this.internalDisabled;\n }\n set disabled(value: boolean) {\n value = Boolean(value);\n const oldValue = this.internalDisabled;\n\n this.internalDisabled = value;\n this[updateUsedValues]();\n\n this.requestUpdate('disabled', oldValue);\n }\n\n @property({type: Boolean, attribute: false})\n get checked(): boolean {\n return this.checkedness;\n }\n set checked(value: boolean) {\n this.checkAMenuitemElement(value, false);\n }\n\n @property({type: Boolean, reflect: true})\n get defaultChecked(): boolean {\n return this.internalDefaultChecked;\n }\n set defaultChecked(value: boolean) {\n value = Boolean(value);\n const oldValue = this.internalDefaultChecked;\n\n this.internalDefaultChecked = value;\n\n if (!this.dirtyCheckedness) {\n // The proposed spec DOES NOT call into the full 'check a menuitem\n // element' steps - it only sets checkedness - but this seems like the\n // only reasonable behavior when the element is part of a single-checkable\n // fieldset. Otherwise, multiple elements with `defaultchecked` could\n // become checked.\n this.checkAMenuitemElement(value, false);\n this.dirtyCheckedness = false;\n }\n\n this.requestUpdate('defaultChecked', oldValue);\n }\n\n constructor() {\n super();\n this[updateUsedValues]();\n\n setupDispatchHooks(this, 'keydown', 'click');\n this.addEventListener('keydown', (event: KeyboardEvent) => {\n afterDispatch(event, () => {\n if (event.defaultPrevented) {\n return;\n }\n\n if (event.key === 'Enter' || event.key === ' ') {\n this.click();\n }\n });\n });\n this.addEventListener('click', (event: Event) => {\n afterDispatch(event, () => {\n if (event.defaultPrevented || this.usedDisabled) {\n return;\n }\n\n const newChecked = !this.checkedness;\n\n const closeBehavior = this.checkAMenuitemElement(newChecked, true);\n\n // TODO: Handle the invoked submenu.\n\n if (closeBehavior === 'close-menulist') {\n // TODO: This should be the 'outermost containing menulist', not just\n // the cached ancestor menulist.\n this.cachedAncestorMenulist?.hidePopover();\n }\n\n sharedCommandInvokerActivationSteps(this, event);\n });\n });\n }\n\n override render() {\n return html`<span part=\"checkmark\"></span><slot></slot>`;\n }\n\n override connectedCallback() {\n super.connectedCallback();\n this.resetAncestorElementCache();\n\n if (this.internalDefaultChecked && !this.dirtyCheckedness) {\n this.checkAMenuitemElement(true, false);\n this.dirtyCheckedness = false;\n }\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n this.resetAncestorElementCache();\n }\n\n override click() {\n if (!this.usedDisabled) {\n super.click();\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { CSSResultOrNative, LitElement } from 'lit';
|
|
7
|
+
declare const baseClass: import("../../behaviors/mixin.js").MixinReturn<typeof LitElement, import("../../behaviors/element-internals.js").WithElementInternals>;
|
|
8
|
+
/**
|
|
9
|
+
* An element implementing the proposed `<menulist>` built-in element.
|
|
10
|
+
*/
|
|
11
|
+
export declare class AriaMenulistElement extends baseClass {
|
|
12
|
+
static styles: CSSResultOrNative[];
|
|
13
|
+
popover: string;
|
|
14
|
+
focusGroup: string;
|
|
15
|
+
constructor();
|
|
16
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
17
|
+
private opener;
|
|
18
|
+
private handleToggle;
|
|
19
|
+
private handleFocusout;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { __decorate } from "tslib";
|
|
7
|
+
/// <reference types="../../../types/popover.d.ts" />
|
|
8
|
+
import { LitElement, css, html } from 'lit';
|
|
9
|
+
import { property } from 'lit/decorators.js';
|
|
10
|
+
import { internals, mixinElementInternals, } from '../../behaviors/element-internals.js';
|
|
11
|
+
import { sharedSlottedContentStyles } from './shared-slotted-content.js';
|
|
12
|
+
const baseClass = mixinElementInternals(LitElement);
|
|
13
|
+
/**
|
|
14
|
+
* An element implementing the proposed `<menulist>` built-in element.
|
|
15
|
+
*/
|
|
16
|
+
export class AriaMenulistElement extends baseClass {
|
|
17
|
+
constructor() {
|
|
18
|
+
super();
|
|
19
|
+
this.popover = 'auto';
|
|
20
|
+
this.focusGroup = 'menu';
|
|
21
|
+
this.opener = null;
|
|
22
|
+
this[internals].role = 'menu';
|
|
23
|
+
this[internals].ariaOrientation = 'vertical';
|
|
24
|
+
this.addEventListener('toggle', this.handleToggle.bind(this));
|
|
25
|
+
this.addEventListener('focusout', this.handleFocusout.bind(this));
|
|
26
|
+
}
|
|
27
|
+
render() {
|
|
28
|
+
return html `<slot></slot>`;
|
|
29
|
+
}
|
|
30
|
+
handleToggle(event) {
|
|
31
|
+
if (event.newState === 'open') {
|
|
32
|
+
this.opener = event.source;
|
|
33
|
+
}
|
|
34
|
+
else if (event.newState === 'closed' && this.matches(':focus-within')) {
|
|
35
|
+
// When closing, restore focus if focus remained in the menulist (e.g.
|
|
36
|
+
// during _keyboard_ light dismiss).
|
|
37
|
+
this.opener?.focus?.();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
handleFocusout() {
|
|
41
|
+
if (!this.matches(':focus-within')) {
|
|
42
|
+
this.hidePopover();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
AriaMenulistElement.styles = [
|
|
47
|
+
sharedSlottedContentStyles,
|
|
48
|
+
css `
|
|
49
|
+
/* Unset UA |[popover]| styles. */
|
|
50
|
+
@layer {
|
|
51
|
+
:host([popover]) {
|
|
52
|
+
position: unset;
|
|
53
|
+
width: unset;
|
|
54
|
+
height: unset;
|
|
55
|
+
color: unset;
|
|
56
|
+
background-color: unset;
|
|
57
|
+
inset: unset;
|
|
58
|
+
margin: unset;
|
|
59
|
+
border: unset;
|
|
60
|
+
border-image: unset;
|
|
61
|
+
padding: unset;
|
|
62
|
+
overflow: unset;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
:host([popover]:popover-open) {
|
|
66
|
+
display: unset;
|
|
67
|
+
overlay: unset;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
:host {
|
|
72
|
+
display: block;
|
|
73
|
+
position: fixed;
|
|
74
|
+
width: max-content;
|
|
75
|
+
max-block-size: stretch;
|
|
76
|
+
color: canvastext;
|
|
77
|
+
background-color: canvas;
|
|
78
|
+
margin: 0px;
|
|
79
|
+
inset: auto;
|
|
80
|
+
overflow: auto;
|
|
81
|
+
border: 1px solid currentColor;
|
|
82
|
+
border-image: none;
|
|
83
|
+
padding: 0.25em;
|
|
84
|
+
position-area: block-end span-inline-end;
|
|
85
|
+
position-try-fallbacks:
|
|
86
|
+
flip-block,
|
|
87
|
+
flip-inline,
|
|
88
|
+
flip-block flip-inline;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
:host(:not(:popover-open)) {
|
|
92
|
+
display: none;
|
|
93
|
+
}
|
|
94
|
+
`,
|
|
95
|
+
];
|
|
96
|
+
__decorate([
|
|
97
|
+
property({ reflect: true })
|
|
98
|
+
], AriaMenulistElement.prototype, "popover", void 0);
|
|
99
|
+
__decorate([
|
|
100
|
+
property({ reflect: true })
|
|
101
|
+
], AriaMenulistElement.prototype, "focusGroup", void 0);
|
|
102
|
+
//# sourceMappingURL=menulist.js.map
|
|
@@ -0,0 +1 @@
|
|
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AC;YACxE,sEAAsE;YACtE,oCAAoC;YACpC,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QACzB,CAAC;IACH,CAAC;IAEO,cAAc;QACpB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC;YACnC,IAAI,CAAC,WAAW,EAAE,CAAC;QACrB,CAAC;IACH,CAAC;;AArFe,0BAAM,GAAwB;IAC5C,0BAA0B;IAC1B,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA8CF;CACF,AAjDqB,CAiDpB;AAGO;IADR,QAAQ,CAAC,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC;oDACA;AAG1B;IADC,QAAQ,CAAC,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC;uDACN","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/// <reference types=\"../../../types/popover.d.ts\" />\n\nimport {CSSResultOrNative, LitElement, css, html} from 'lit';\nimport {property} from 'lit/decorators.js';\nimport {\n internals,\n mixinElementInternals,\n} from '../../behaviors/element-internals.js';\nimport {sharedSlottedContentStyles} from './shared-slotted-content.js';\n\n// `focus` is defined on `HTMLElement` and `SVGElement` directly, not `Element`.\ninterface MaybeFocusableElement extends Element {\n focus?: HTMLElement['focus'];\n}\n\nconst baseClass = mixinElementInternals(LitElement);\n\n/**\n * An element implementing the proposed `<menulist>` built-in element.\n */\nexport class AriaMenulistElement extends baseClass {\n static override styles: CSSResultOrNative[] = [\n sharedSlottedContentStyles,\n css`\n /* Unset UA |[popover]| styles. */\n @layer {\n :host([popover]) {\n position: unset;\n width: unset;\n height: unset;\n color: unset;\n background-color: unset;\n inset: unset;\n margin: unset;\n border: unset;\n border-image: unset;\n padding: unset;\n overflow: unset;\n }\n\n :host([popover]:popover-open) {\n display: unset;\n overlay: unset;\n }\n }\n\n :host {\n display: block;\n position: fixed;\n width: max-content;\n max-block-size: stretch;\n color: canvastext;\n background-color: canvas;\n margin: 0px;\n inset: auto;\n overflow: auto;\n border: 1px solid currentColor;\n border-image: none;\n padding: 0.25em;\n position-area: block-end span-inline-end;\n position-try-fallbacks:\n flip-block,\n flip-inline,\n flip-block flip-inline;\n }\n\n :host(:not(:popover-open)) {\n display: none;\n }\n `,\n ];\n\n @property({reflect: true})\n override popover = 'auto';\n\n @property({reflect: true})\n focusGroup = 'menu';\n\n constructor() {\n super();\n this[internals].role = 'menu';\n this[internals].ariaOrientation = 'vertical';\n this.addEventListener('toggle', this.handleToggle.bind(this));\n this.addEventListener('focusout', this.handleFocusout.bind(this));\n }\n\n override render() {\n return html`<slot></slot>`;\n }\n\n private opener: MaybeFocusableElement | null = null;\n\n private handleToggle(event: ToggleEvent) {\n if (event.newState === 'open') {\n this.opener = event.source as MaybeFocusableElement | null;\n } else if (event.newState === 'closed' && this.matches(':focus-within')) {\n // When closing, restore focus if focus remained in the menulist (e.g.\n // during _keyboard_ light dismiss).\n this.opener?.focus?.();\n }\n }\n\n private handleFocusout() {\n if (!this.matches(':focus-within')) {\n this.hidePopover();\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Shared styles used by `<md-aria-menulist>` and `<md-aria-fieldset>`, to
|
|
8
|
+
* simulate the descendant combinator in UA styles for `<menuitem>`.
|
|
9
|
+
*/
|
|
10
|
+
export declare const sharedSlottedContentStyles: import("lit").CSSResult;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { css } from 'lit';
|
|
7
|
+
/**
|
|
8
|
+
* Shared styles used by `<md-aria-menulist>` and `<md-aria-fieldset>`, to
|
|
9
|
+
* simulate the descendant combinator in UA styles for `<menuitem>`.
|
|
10
|
+
*/
|
|
11
|
+
export const sharedSlottedContentStyles = css `
|
|
12
|
+
::slotted(md-aria-menuitem) {
|
|
13
|
+
display: flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
user-select: none;
|
|
16
|
+
min-inline-size: 24px;
|
|
17
|
+
min-block-size: max(24px, 1lh);
|
|
18
|
+
font-weight: inherit;
|
|
19
|
+
gap: 0.5em;
|
|
20
|
+
padding-inline: 0.5em;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
::slotted(md-aria-menuitem:state(enabled):hover) {
|
|
24
|
+
background-color: color-mix(in lab, currentColor 10%, transparent);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
::slotted(md-aria-menuitem:state(disabled)) {
|
|
28
|
+
color: color-mix(in lab, currentColor 50%, transparent);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
::slotted(md-aria-fieldset) {
|
|
32
|
+
margin-inline: 0;
|
|
33
|
+
border: none;
|
|
34
|
+
padding-block: 0;
|
|
35
|
+
padding-inline: 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
::slotted(hr) {
|
|
39
|
+
color: inherit;
|
|
40
|
+
margin-inline: 0;
|
|
41
|
+
border: none;
|
|
42
|
+
border-block-start: 1px solid currentColor;
|
|
43
|
+
border-image: none;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
::slotted(a:any-link),
|
|
47
|
+
::slotted(img[usemap]) {
|
|
48
|
+
display: none;
|
|
49
|
+
}
|
|
50
|
+
`;
|
|
51
|
+
//# sourceMappingURL=shared-slotted-content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared-slotted-content.js","sourceRoot":"","sources":["shared-slotted-content.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,GAAG,EAAC,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuC5C,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {css} from 'lit';\n\n/**\n * Shared styles used by `<md-aria-menulist>` and `<md-aria-fieldset>`, to\n * simulate the descendant combinator in UA styles for `<menuitem>`.\n */\nexport const sharedSlottedContentStyles = css`\n ::slotted(md-aria-menuitem) {\n display: flex;\n align-items: center;\n user-select: none;\n min-inline-size: 24px;\n min-block-size: max(24px, 1lh);\n font-weight: inherit;\n gap: 0.5em;\n padding-inline: 0.5em;\n }\n\n ::slotted(md-aria-menuitem:state(enabled):hover) {\n background-color: color-mix(in lab, currentColor 10%, transparent);\n }\n\n ::slotted(md-aria-menuitem:state(disabled)) {\n color: color-mix(in lab, currentColor 50%, transparent);\n }\n\n ::slotted(md-aria-fieldset) {\n margin-inline: 0;\n border: none;\n padding-block: 0;\n padding-inline: 0;\n }\n\n ::slotted(hr) {\n color: inherit;\n margin-inline: 0;\n border: none;\n border-block-start: 1px solid currentColor;\n border-image: none;\n }\n\n ::slotted(a:any-link),\n ::slotted(img[usemap]) {\n display: none;\n }\n`;\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Returns whether the element is disabled.
|
|
8
|
+
*
|
|
9
|
+
* Checks if the element matches any of the following:
|
|
10
|
+
* - `.disabled` class
|
|
11
|
+
* - `:disabled` pseudo-class
|
|
12
|
+
* - `:state(disabled)` pseudo-class
|
|
13
|
+
* - `[disabled]` attribute
|
|
14
|
+
* - `[aria-disabled=true]` attribute
|
|
15
|
+
*
|
|
16
|
+
* @param element The element to check.
|
|
17
|
+
* @return true if the element is disabled.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isDisabled(element: Element): boolean;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Returns whether the element is disabled.
|
|
8
|
+
*
|
|
9
|
+
* Checks if the element matches any of the following:
|
|
10
|
+
* - `.disabled` class
|
|
11
|
+
* - `:disabled` pseudo-class
|
|
12
|
+
* - `:state(disabled)` pseudo-class
|
|
13
|
+
* - `[disabled]` attribute
|
|
14
|
+
* - `[aria-disabled=true]` attribute
|
|
15
|
+
*
|
|
16
|
+
* @param element The element to check.
|
|
17
|
+
* @return true if the element is disabled.
|
|
18
|
+
*/
|
|
19
|
+
export function isDisabled(element) {
|
|
20
|
+
return element.matches('.disabled,:disabled,:state(disabled),[disabled],[aria-disabled=true]');
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=pseudo-classes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pseudo-classes.js","sourceRoot":"","sources":["pseudo-classes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,UAAU,CAAC,OAAgB;IACzC,OAAO,OAAO,CAAC,OAAO,CACpB,sEAAsE,CACvE,CAAC;AACJ,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/**\n * Returns whether the element is disabled.\n *\n * Checks if the element matches any of the following:\n * - `.disabled` class\n * - `:disabled` pseudo-class\n * - `:state(disabled)` pseudo-class\n * - `[disabled]` attribute\n * - `[aria-disabled=true]` attribute\n *\n * @param element The element to check.\n * @return true if the element is disabled.\n */\nexport function isDisabled(element: Element): boolean {\n return element.matches(\n '.disabled,:disabled,:state(disabled),[disabled],[aria-disabled=true]',\n );\n}\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Queries for an associated element with the given ID that is in the same root
|
|
8
|
+
* as the given element.
|
|
9
|
+
*
|
|
10
|
+
* @param element The element to query from.
|
|
11
|
+
* @param id The ID of the associated element to query for.
|
|
12
|
+
* @return The associated element with the given ID, or null if not found.
|
|
13
|
+
*/
|
|
14
|
+
export declare function queryAssociatedById(element: Element, id: string): Element | null;
|
|
15
|
+
/**
|
|
16
|
+
* Queries for one or more associated elements that match the given
|
|
17
|
+
* space-separated ID string that are in the same root as the given element.
|
|
18
|
+
*
|
|
19
|
+
* @param element The element to query from.
|
|
20
|
+
* @param ids The space-separated IDs of the associated elements to query for.
|
|
21
|
+
* @return An array of associated elements with the given IDs.
|
|
22
|
+
*/
|
|
23
|
+
export declare function queryAssociatedByIds(element: Element, ids: string): Element[];
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Queries for an associated element with the given ID that is in the same root
|
|
8
|
+
* as the given element.
|
|
9
|
+
*
|
|
10
|
+
* @param element The element to query from.
|
|
11
|
+
* @param id The ID of the associated element to query for.
|
|
12
|
+
* @return The associated element with the given ID, or null if not found.
|
|
13
|
+
*/
|
|
14
|
+
export function queryAssociatedById(element, id) {
|
|
15
|
+
if (!id)
|
|
16
|
+
return null;
|
|
17
|
+
return element.getRootNode().querySelector(`#${id}`);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Queries for one or more associated elements that match the given
|
|
21
|
+
* space-separated ID string that are in the same root as the given element.
|
|
22
|
+
*
|
|
23
|
+
* @param element The element to query from.
|
|
24
|
+
* @param ids The space-separated IDs of the associated elements to query for.
|
|
25
|
+
* @return An array of associated elements with the given IDs.
|
|
26
|
+
*/
|
|
27
|
+
export function queryAssociatedByIds(element, ids) {
|
|
28
|
+
const selectors = ids
|
|
29
|
+
.split(/\s+/)
|
|
30
|
+
.filter((id) => !!id)
|
|
31
|
+
.map((id) => `#${id}`);
|
|
32
|
+
if (!selectors.length)
|
|
33
|
+
return [];
|
|
34
|
+
return Array.from(element.getRootNode().querySelectorAll(selectors.join(',')));
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=query-associated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-associated.js","sourceRoot":"","sources":["query-associated.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CACjC,OAAgB,EAChB,EAAU;IAEV,IAAI,CAAC,EAAE;QAAE,OAAO,IAAI,CAAC;IACrB,OACE,OAAO,CAAC,WAAW,EACpB,CAAC,aAAa,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AAC5B,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAgB,EAAE,GAAW;IAChE,MAAM,SAAS,GAAG,GAAG;SAClB,KAAK,CAAC,KAAK,CAAC;SACZ,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACpB,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACzB,IAAI,CAAC,SAAS,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IACjC,OAAO,KAAK,CAAC,IAAI,CACd,OAAO,CAAC,WAAW,EAAsC,CAAC,gBAAgB,CACzE,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CACpB,CACF,CAAC;AACJ,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/**\n * Queries for an associated element with the given ID that is in the same root\n * as the given element.\n *\n * @param element The element to query from.\n * @param id The ID of the associated element to query for.\n * @return The associated element with the given ID, or null if not found.\n */\nexport function queryAssociatedById(\n element: Element,\n id: string,\n): Element | null {\n if (!id) return null;\n return (\n element.getRootNode() as Document | ShadowRoot | Element\n ).querySelector(`#${id}`);\n}\n\n/**\n * Queries for one or more associated elements that match the given\n * space-separated ID string that are in the same root as the given element.\n *\n * @param element The element to query from.\n * @param ids The space-separated IDs of the associated elements to query for.\n * @return An array of associated elements with the given IDs.\n */\nexport function queryAssociatedByIds(element: Element, ids: string): Element[] {\n const selectors = ids\n .split(/\\s+/)\n .filter((id) => !!id)\n .map((id) => `#${id}`);\n if (!selectors.length) return [];\n return Array.from(\n (element.getRootNode() as Document | ShadowRoot | Element).querySelectorAll(\n selectors.join(','),\n ),\n );\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"md-aria-tab.js","sourceRoot":"","sources":["md-aria-tab.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,cAAc,EAAC,MAAM,UAAU,CAAC;AAQxC,cAAc,CAAC,MAAM,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {AriaTabElement} from './tab.js';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'md-aria-tab': AriaTabElement;\n }\n}\n\ncustomElements.define('md-aria-tab', AriaTabElement);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"md-aria-tablist.js","sourceRoot":"","sources":["md-aria-tablist.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,kBAAkB,EAAC,MAAM,cAAc,CAAC;AAQhD,cAAc,CAAC,MAAM,CAAC,iBAAiB,EAAE,kBAAkB,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {AriaTablistElement} from './tablist.js';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'md-aria-tablist': AriaTablistElement;\n }\n}\n\ncustomElements.define('md-aria-tablist', AriaTablistElement);\n"]}
|