@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,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/// <reference types="../../types/command-event.d.ts" />
|
|
7
|
+
/// <reference types="../../types/popover.d.ts" />
|
|
8
|
+
import { queryAssociatedById } from './query-associated.js';
|
|
9
|
+
/**
|
|
10
|
+
* Determines an element's `command` attribute state, given the attribute value.
|
|
11
|
+
*/
|
|
12
|
+
function getCommandState(attrValue) {
|
|
13
|
+
switch (attrValue) {
|
|
14
|
+
case 'toggle-popover':
|
|
15
|
+
case 'show-popover':
|
|
16
|
+
case 'hide-popover':
|
|
17
|
+
case 'close':
|
|
18
|
+
case 'request-close':
|
|
19
|
+
case 'show-modal':
|
|
20
|
+
return attrValue;
|
|
21
|
+
default:
|
|
22
|
+
return attrValue?.startsWith('--') ? 'custom' : 'unknown';
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/** Determines the popover state of an element. */
|
|
26
|
+
function getPopoverState(element) {
|
|
27
|
+
if (element.localName === 'md-aria-menulist') {
|
|
28
|
+
return 'auto';
|
|
29
|
+
}
|
|
30
|
+
const attrValue = element.getAttribute('popover');
|
|
31
|
+
switch (attrValue) {
|
|
32
|
+
case '':
|
|
33
|
+
return 'auto';
|
|
34
|
+
case 'auto':
|
|
35
|
+
case 'manual':
|
|
36
|
+
case 'hint':
|
|
37
|
+
return attrValue;
|
|
38
|
+
case null:
|
|
39
|
+
default:
|
|
40
|
+
return 'no-popover';
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Determines the popover target action from an element's `popovertargetaction`
|
|
45
|
+
* attribute value.
|
|
46
|
+
*/
|
|
47
|
+
function getPopoverTargetActionState(attrValue) {
|
|
48
|
+
switch (attrValue) {
|
|
49
|
+
case 'toggle':
|
|
50
|
+
case 'show':
|
|
51
|
+
case 'hide':
|
|
52
|
+
return attrValue;
|
|
53
|
+
default:
|
|
54
|
+
return 'toggle';
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Performs the 'shared command invoker activation steps' for a button or
|
|
59
|
+
* menuitem, to be called when that element is activated: either runs a command
|
|
60
|
+
* (i.e. the element has `command` and `commandfor` attributes) or changes a
|
|
61
|
+
* popover's state (i.e. the element has the `popovertarget` and possibly
|
|
62
|
+
* `popovertargetaction` attributes).
|
|
63
|
+
*
|
|
64
|
+
* https://whatpr.org/html/12011/popover.html#shared-command-invoker-activation-steps
|
|
65
|
+
*
|
|
66
|
+
* @param element The button or menuitem being activated.
|
|
67
|
+
* @param event The event that activated `element`.
|
|
68
|
+
*/
|
|
69
|
+
export function sharedCommandInvokerActivationSteps(element, event) {
|
|
70
|
+
const idref = element.getAttribute('commandfor');
|
|
71
|
+
const commandTarget = queryAssociatedById(element, idref ?? '');
|
|
72
|
+
if (!commandTarget) {
|
|
73
|
+
popoverTargetAttributeActivationBehavior(element, event.target);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const command = element.getAttribute('command');
|
|
77
|
+
const commandState = getCommandState(command);
|
|
78
|
+
if (commandState === 'unknown' || command === null) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const isPopover = getPopoverState(commandTarget) !== 'no-popover';
|
|
82
|
+
if (isPopover && commandState !== 'custom') {
|
|
83
|
+
// `<dialog>` is the only element that defines 'is valid command steps'.
|
|
84
|
+
if (commandTarget.localName === 'dialog' &&
|
|
85
|
+
!['close', 'request-close', 'show-modal'].includes(commandState)) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const continueSteps = commandTarget.dispatchEvent(new CommandEvent('command', { source: element, command, cancelable: true }));
|
|
90
|
+
if (!continueSteps ||
|
|
91
|
+
!commandTarget.isConnected ||
|
|
92
|
+
commandState === 'custom') {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
switch (command) {
|
|
96
|
+
case 'hide-popover':
|
|
97
|
+
try {
|
|
98
|
+
// Use `togglePopover` because `hidePopover` doesn't support `source`.
|
|
99
|
+
commandTarget.togglePopover({ force: false, source: element });
|
|
100
|
+
}
|
|
101
|
+
catch (e) {
|
|
102
|
+
// Do nothing. No exception should be thrown by these steps if the
|
|
103
|
+
// popover isn't in the expected state.
|
|
104
|
+
}
|
|
105
|
+
break;
|
|
106
|
+
case 'toggle-popover':
|
|
107
|
+
try {
|
|
108
|
+
commandTarget.togglePopover({ source: element });
|
|
109
|
+
}
|
|
110
|
+
catch (e) {
|
|
111
|
+
// Do nothing. No exception should be thrown by these steps if the
|
|
112
|
+
// popover isn't in the expected state.
|
|
113
|
+
}
|
|
114
|
+
break;
|
|
115
|
+
case 'show-popover':
|
|
116
|
+
try {
|
|
117
|
+
commandTarget.showPopover({ source: element });
|
|
118
|
+
}
|
|
119
|
+
catch (e) {
|
|
120
|
+
// Do nothing. No exception should be thrown by these steps if the
|
|
121
|
+
// popover isn't in the expected state.
|
|
122
|
+
}
|
|
123
|
+
break;
|
|
124
|
+
default:
|
|
125
|
+
// An element can have 'command steps', which are run if the element's
|
|
126
|
+
// command is not a popover command. Currently, only `<dialog>` defines
|
|
127
|
+
// 'command steps', so they're inlined here.
|
|
128
|
+
//
|
|
129
|
+
// https://whatpr.org/html/12011/popover.html#command-steps
|
|
130
|
+
// https://whatpr.org/html/12011/interactive-elements.html#the-dialog-element:command-steps
|
|
131
|
+
if (commandTarget.localName === 'dialog') {
|
|
132
|
+
const dialog = commandTarget;
|
|
133
|
+
if (dialog.matches(':popover-open')) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
switch (commandState) {
|
|
137
|
+
case 'close':
|
|
138
|
+
if (dialog.hasAttribute('open')) {
|
|
139
|
+
dialog.close(element.getAttribute('value') ?? undefined);
|
|
140
|
+
}
|
|
141
|
+
break;
|
|
142
|
+
case 'request-close':
|
|
143
|
+
if (dialog.hasAttribute('open')) {
|
|
144
|
+
dialog.requestClose(element.getAttribute('value') ?? undefined);
|
|
145
|
+
}
|
|
146
|
+
break;
|
|
147
|
+
case 'show-modal':
|
|
148
|
+
if (!dialog.hasAttribute('open')) {
|
|
149
|
+
dialog.showModal();
|
|
150
|
+
}
|
|
151
|
+
break;
|
|
152
|
+
default:
|
|
153
|
+
// Do nothing.
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Performs the 'popover target attribute activation behavior' for a button or
|
|
161
|
+
* menuitem.
|
|
162
|
+
*
|
|
163
|
+
* These steps are taken when a button or menuitem is activated, but doesn't
|
|
164
|
+
* target an element with a `command` attribute.
|
|
165
|
+
*
|
|
166
|
+
* https://whatpr.org/html/12011/popover.html#popover-target-attribute-activation-behavior
|
|
167
|
+
*
|
|
168
|
+
* @param element The button or menuitem being activated.
|
|
169
|
+
* @param eventTarget The target of the event that activated `element`.
|
|
170
|
+
*/
|
|
171
|
+
function popoverTargetAttributeActivationBehavior(element, eventTarget) {
|
|
172
|
+
const idref = element.getAttribute('popovertarget');
|
|
173
|
+
const popover = queryAssociatedById(element, idref ?? '');
|
|
174
|
+
if (!popover) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
// TODO: The spec describes a case here that's relevant when the popover is
|
|
178
|
+
// nested inside its invoker itself, which would cause clicking anywhere in
|
|
179
|
+
// the popover to close the popover.
|
|
180
|
+
//
|
|
181
|
+
// https://github.com/whatwg/html/pull/10770
|
|
182
|
+
const open = popover.matches(':popover-open');
|
|
183
|
+
const action = getPopoverTargetActionState(element.getAttribute('popovertargetaction') ?? '');
|
|
184
|
+
if (!open && (action === 'show' || action === 'toggle')) {
|
|
185
|
+
try {
|
|
186
|
+
popover.showPopover({ source: element });
|
|
187
|
+
}
|
|
188
|
+
catch (e) {
|
|
189
|
+
// Do nothing. No exception should be thrown by these steps if the
|
|
190
|
+
// popover isn't in the expected state.
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
else if (open && (action === 'hide' || action === 'toggle')) {
|
|
194
|
+
try {
|
|
195
|
+
// Use `togglePopover` because `hidePopover` doesn't support `source`.
|
|
196
|
+
popover.togglePopover({ force: false, source: element });
|
|
197
|
+
}
|
|
198
|
+
catch (e) {
|
|
199
|
+
// Do nothing. No exception should be thrown by these steps if the
|
|
200
|
+
// popover isn't in the expected state.
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["command.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,wDAAwD;AACxD,kDAAkD;AAElD,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAC;AAkB1D;;GAEG;AACH,SAAS,eAAe,CAAC,SAAwB;IAC/C,QAAQ,SAAS,EAAE,CAAC;QAClB,KAAK,gBAAgB,CAAC;QACtB,KAAK,cAAc,CAAC;QACpB,KAAK,cAAc,CAAC;QACpB,KAAK,OAAO,CAAC;QACb,KAAK,eAAe,CAAC;QACrB,KAAK,YAAY;YACf,OAAO,SAAS,CAAC;QACnB;YACE,OAAO,SAAS,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;IAC9D,CAAC;AACH,CAAC;AASD,kDAAkD;AAClD,SAAS,eAAe,CAAC,OAAoB;IAC3C,IAAI,OAAO,CAAC,SAAS,KAAK,kBAAkB,EA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Ae,CAAC,CAAC;IAC9C,MAAM,MAAM,GAAG,2BAA2B,CACxC,OAAO,CAAC,YAAY,CAAC,qBAAqB,CAAC,IAAI,EAAE,CAClD,CAAC;IACF,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM,IAAI,MAAM,KAAK,QAAQ,CAAC,EAAE,CAAC;QACxD,IAAI,CAAC;YACH,OAAO,CAAC,WAAW,CAAC,EAAC,MAAM,EAAE,OAAO,EAAC,CAAC,CAAC;QACzC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,kEAAkE;YAClE,uCAAuC;QACzC,CAAC;IACH,CAAC;SAAM,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM,IAAI,MAAM,KAAK,QAAQ,CAAC,EAAE,CAAC;QAC9D,IAAI,CAAC;YACH,sEAAsE;YACtE,OAAO,CAAC,aAAa,CAAC,EAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAC,CAAC,CAAC;QACzD,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,kEAAkE;YAClE,uCAAuC;QACzC,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/// <reference types=\"../../types/command-event.d.ts\" />\n/// <reference types=\"../../types/popover.d.ts\" />\n\nimport {queryAssociatedById} from './query-associated.js';\n\n/**\n * An element's `command` attribute state: either one of a fixed set of commands\n * with spec-defined actions, `custom` (if it begins with `--`), or `unknown`.\n *\n * https://whatpr.org/html/12011/popover.html#attr-command\n */\ntype CommandState =\n | 'toggle-popover'\n | 'show-popover'\n | 'hide-popover'\n | 'close'\n | 'request-close'\n | 'show-modal'\n | 'custom'\n | 'unknown';\n\n/**\n * Determines an element's `command` attribute state, given the attribute value.\n */\nfunction getCommandState(attrValue: string | null): CommandState {\n switch (attrValue) {\n case 'toggle-popover':\n case 'show-popover':\n case 'hide-popover':\n case 'close':\n case 'request-close':\n case 'show-modal':\n return attrValue;\n default:\n return attrValue?.startsWith('--') ? 'custom' : 'unknown';\n }\n}\n\n/**\n * An element's popover state, as determined by its type or `popover` attribute.\n *\n * https://whatpr.org/html/12011/popover.html#popover-state\n */\ntype PopoverState = 'auto' | 'manual' | 'hint' | 'no-popover';\n\n/** Determines the popover state of an element. */\nfunction getPopoverState(element: HTMLElement): PopoverState {\n if (element.localName === 'md-aria-menulist') {\n return 'auto';\n }\n\n const attrValue = element.getAttribute('popover');\n switch (attrValue) {\n case '':\n return 'auto';\n case 'auto':\n case 'manual':\n case 'hint':\n return attrValue;\n case null:\n default:\n return 'no-popover';\n }\n}\n\n/**\n * An element's popover target action state: the action taken on the popover\n * referenced by the element's `popovertarget` attribute.\n *\n * https://whatpr.org/html/12011/popover.html#attr-popovertargetaction\n */\ntype PopoverTargetActionState = 'toggle' | 'show' | 'hide';\n\n/**\n * Determines the popover target action from an element's `popovertargetaction`\n * attribute value.\n */\nfunction getPopoverTargetActionState(\n attrValue: string,\n): PopoverTargetActionState {\n switch (attrValue) {\n case 'toggle':\n case 'show':\n case 'hide':\n return attrValue;\n default:\n return 'toggle';\n }\n}\n\n/**\n * Performs the 'shared command invoker activation steps' for a button or\n * menuitem, to be called when that element is activated: either runs a command\n * (i.e. the element has `command` and `commandfor` attributes) or changes a\n * popover's state (i.e. the element has the `popovertarget` and possibly\n * `popovertargetaction` attributes).\n *\n * https://whatpr.org/html/12011/popover.html#shared-command-invoker-activation-steps\n *\n * @param element The button or menuitem being activated.\n * @param event The event that activated `element`.\n */\nexport function sharedCommandInvokerActivationSteps(\n element: HTMLElement,\n event: Event,\n) {\n const idref = element.getAttribute('commandfor');\n const commandTarget = queryAssociatedById(\n element,\n idref ?? '',\n ) as HTMLElement | null;\n if (!commandTarget) {\n popoverTargetAttributeActivationBehavior(element, event.target as Node);\n return;\n }\n\n const command = element.getAttribute('command');\n const commandState = getCommandState(command);\n if (commandState === 'unknown' || command === null) {\n return;\n }\n\n const isPopover = getPopoverState(commandTarget) !== 'no-popover';\n if (isPopover && commandState !== 'custom') {\n // `<dialog>` is the only element that defines 'is valid command steps'.\n if (\n commandTarget.localName === 'dialog' &&\n !['close', 'request-close', 'show-modal'].includes(commandState)\n ) {\n return;\n }\n }\n\n const continueSteps = commandTarget.dispatchEvent(\n new CommandEvent('command', {source: element, command, cancelable: true}),\n );\n\n if (\n !continueSteps ||\n !commandTarget.isConnected ||\n commandState === 'custom'\n ) {\n return;\n }\n\n switch (command) {\n case 'hide-popover':\n try {\n // Use `togglePopover` because `hidePopover` doesn't support `source`.\n commandTarget.togglePopover({force: false, source: element});\n } catch (e) {\n // Do nothing. No exception should be thrown by these steps if the\n // popover isn't in the expected state.\n }\n break;\n case 'toggle-popover':\n try {\n commandTarget.togglePopover({source: element});\n } catch (e) {\n // Do nothing. No exception should be thrown by these steps if the\n // popover isn't in the expected state.\n }\n break;\n case 'show-popover':\n try {\n commandTarget.showPopover({source: element});\n } catch (e) {\n // Do nothing. No exception should be thrown by these steps if the\n // popover isn't in the expected state.\n }\n break;\n default:\n // An element can have 'command steps', which are run if the element's\n // command is not a popover command. Currently, only `<dialog>` defines\n // 'command steps', so they're inlined here.\n //\n // https://whatpr.org/html/12011/popover.html#command-steps\n // https://whatpr.org/html/12011/interactive-elements.html#the-dialog-element:command-steps\n if (commandTarget.localName === 'dialog') {\n const dialog = commandTarget as HTMLDialogElement;\n if (dialog.matches(':popover-open')) {\n return;\n }\n\n switch (commandState) {\n case 'close':\n if (dialog.hasAttribute('open')) {\n dialog.close(element.getAttribute('value') ?? undefined);\n }\n break;\n case 'request-close':\n if (dialog.hasAttribute('open')) {\n dialog.requestClose(element.getAttribute('value') ?? undefined);\n }\n break;\n case 'show-modal':\n if (!dialog.hasAttribute('open')) {\n dialog.showModal();\n }\n break;\n default:\n // Do nothing.\n break;\n }\n }\n }\n}\n\n/**\n * Performs the 'popover target attribute activation behavior' for a button or\n * menuitem.\n *\n * These steps are taken when a button or menuitem is activated, but doesn't\n * target an element with a `command` attribute.\n *\n * https://whatpr.org/html/12011/popover.html#popover-target-attribute-activation-behavior\n *\n * @param element The button or menuitem being activated.\n * @param eventTarget The target of the event that activated `element`.\n */\nfunction popoverTargetAttributeActivationBehavior(\n element: HTMLElement,\n eventTarget: Node,\n) {\n const idref = element.getAttribute('popovertarget');\n const popover = queryAssociatedById(\n element,\n idref ?? '',\n ) as HTMLElement | null;\n if (!popover) {\n return;\n }\n\n // TODO: The spec describes a case here that's relevant when the popover is\n // nested inside its invoker itself, which would cause clicking anywhere in\n // the popover to close the popover.\n //\n // https://github.com/whatwg/html/pull/10770\n\n const open = popover.matches(':popover-open');\n const action = getPopoverTargetActionState(\n element.getAttribute('popovertargetaction') ?? '',\n );\n if (!open && (action === 'show' || action === 'toggle')) {\n try {\n popover.showPopover({source: element});\n } catch (e) {\n // Do nothing. No exception should be thrown by these steps if the\n // popover isn't in the expected state.\n }\n } else if (open && (action === 'hide' || action === 'toggle')) {\n try {\n // Use `togglePopover` because `hidePopover` doesn't support `source`.\n popover.togglePopover({force: false, source: element});\n } catch (e) {\n // Do nothing. No exception should be thrown by these steps if the\n // popover isn't in the expected state.\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { CSSResultOrNative, LitElement } from 'lit';
|
|
7
|
+
import { resetMenuitemCheckedness } from './internal.js';
|
|
8
|
+
import type { AriaMenuitemElement } from './menuitem.js';
|
|
9
|
+
declare const baseClass: import("../../behaviors/mixin.js").MixinReturn<typeof LitElement, import("../../behaviors/element-internals.js").WithElementInternals>;
|
|
10
|
+
/** Possible values for `AriaFieldsetElement`'s `checkable` property. */
|
|
11
|
+
export type CheckableState = 'single' | 'multiple' | null;
|
|
12
|
+
/**
|
|
13
|
+
* An element implementing the proposed menu behavior of `<fieldset>`.
|
|
14
|
+
*/
|
|
15
|
+
export declare class AriaFieldsetElement extends baseClass {
|
|
16
|
+
static styles: CSSResultOrNative[];
|
|
17
|
+
private internalDisabled;
|
|
18
|
+
private internalCheckable;
|
|
19
|
+
private get items();
|
|
20
|
+
get disabled(): boolean;
|
|
21
|
+
set disabled(value: boolean);
|
|
22
|
+
get checkable(): CheckableState;
|
|
23
|
+
set checkable(value: CheckableState);
|
|
24
|
+
constructor();
|
|
25
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
26
|
+
/**
|
|
27
|
+
* Unchecks every menuitem in this fieldset apart from the given one.
|
|
28
|
+
*
|
|
29
|
+
* `<md-aria-menuitem>` calls this on its cached ancestor fieldset when it
|
|
30
|
+
* becomes checked in a single-checkable fieldset.
|
|
31
|
+
*
|
|
32
|
+
* @param checkedItem The item to leave as-is, or null to uncheck every item.
|
|
33
|
+
*/
|
|
34
|
+
[resetMenuitemCheckedness](checkedItem: AriaMenuitemElement | null): void;
|
|
35
|
+
}
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,103 @@
|
|
|
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 { internals, mixinElementInternals, } from '../../behaviors/element-internals.js';
|
|
10
|
+
import { resetMenuitemCheckedness, setCheckedness, updateUsedValues, } from './internal.js';
|
|
11
|
+
import { sharedSlottedContentStyles } from './shared-slotted-content.js';
|
|
12
|
+
const baseClass = mixinElementInternals(LitElement);
|
|
13
|
+
/**
|
|
14
|
+
* An element implementing the proposed menu behavior of `<fieldset>`.
|
|
15
|
+
*/
|
|
16
|
+
export class AriaFieldsetElement extends baseClass {
|
|
17
|
+
get items() {
|
|
18
|
+
// This naively queries for these elements because this element doesn't need
|
|
19
|
+
// to support nested fieldsets yet.
|
|
20
|
+
return this.querySelectorAll('md-aria-menuitem');
|
|
21
|
+
}
|
|
22
|
+
get disabled() {
|
|
23
|
+
return this.internalDisabled;
|
|
24
|
+
}
|
|
25
|
+
set disabled(value) {
|
|
26
|
+
this.internalDisabled = value;
|
|
27
|
+
for (const item of this.items) {
|
|
28
|
+
// If this component is upgraded with `disabled` set in HTML,
|
|
29
|
+
// `<md-aria-menuitem>` children will not be upgraded at this point.
|
|
30
|
+
// These children will update themselves during `connectedCallback`.
|
|
31
|
+
item[updateUsedValues]?.();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
get checkable() {
|
|
35
|
+
return this.internalCheckable;
|
|
36
|
+
}
|
|
37
|
+
set checkable(value) {
|
|
38
|
+
if (typeof value === 'string') {
|
|
39
|
+
const canonicalizedValue = value.toLowerCase();
|
|
40
|
+
if (canonicalizedValue === 'single' ||
|
|
41
|
+
canonicalizedValue === 'multiple') {
|
|
42
|
+
value = canonicalizedValue;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
value = 'multiple';
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
this.internalCheckable = value;
|
|
49
|
+
if (value === 'single') {
|
|
50
|
+
this[resetMenuitemCheckedness](null);
|
|
51
|
+
}
|
|
52
|
+
for (const item of this.items) {
|
|
53
|
+
// If this component is upgraded with `checkable` set in HTML,
|
|
54
|
+
// `<md-aria-menuitem>` children will not be upgraded at this point.
|
|
55
|
+
// These children will update themselves during `connectedCallback`.
|
|
56
|
+
item[updateUsedValues]?.();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
constructor() {
|
|
60
|
+
super();
|
|
61
|
+
this.internalDisabled = false;
|
|
62
|
+
this.internalCheckable = null;
|
|
63
|
+
this[internals].role = 'group';
|
|
64
|
+
}
|
|
65
|
+
render() {
|
|
66
|
+
return html `<slot></slot>`;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Unchecks every menuitem in this fieldset apart from the given one.
|
|
70
|
+
*
|
|
71
|
+
* `<md-aria-menuitem>` calls this on its cached ancestor fieldset when it
|
|
72
|
+
* becomes checked in a single-checkable fieldset.
|
|
73
|
+
*
|
|
74
|
+
* @param checkedItem The item to leave as-is, or null to uncheck every item.
|
|
75
|
+
*/
|
|
76
|
+
[resetMenuitemCheckedness](checkedItem) {
|
|
77
|
+
for (const item of this.items) {
|
|
78
|
+
if (item !== checkedItem) {
|
|
79
|
+
item[setCheckedness]?.(false);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
AriaFieldsetElement.styles = [
|
|
85
|
+
sharedSlottedContentStyles,
|
|
86
|
+
css `
|
|
87
|
+
:host {
|
|
88
|
+
display: block;
|
|
89
|
+
margin-inline: 2px;
|
|
90
|
+
border: groove 2px ThreeDFace;
|
|
91
|
+
padding-block: 0.35em 0.625em;
|
|
92
|
+
padding-inline: 0.75em;
|
|
93
|
+
min-inline-size: min-content;
|
|
94
|
+
}
|
|
95
|
+
`,
|
|
96
|
+
];
|
|
97
|
+
__decorate([
|
|
98
|
+
property({ type: Boolean, reflect: true })
|
|
99
|
+
], AriaFieldsetElement.prototype, "disabled", null);
|
|
100
|
+
__decorate([
|
|
101
|
+
property({ type: String, reflect: true })
|
|
102
|
+
], AriaFieldsetElement.prototype, "checkable", null);
|
|
103
|
+
//# sourceMappingURL=fieldset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fieldset.js","sourceRoot":"","sources":["fieldset.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,SAAS,EACT,qBAAqB,GACtB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,wBAAwB,EACxB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IAAI,CAAC,KAAK,EAAE,CAAC;YAC9B,8DAA8D;YAC9D,oEAAoE;YACpE,oEAAoE;YACpE,IAAI,CAAC,gBAAgB,CAAC,EAAE,EAAE,CAAC;QAC7B,CAAC;IACH,CAAC;IAED;QACE,KAAK,EAAE,CAAC;QAvDF,qBAAgB,GAAG,KAAK,CAAC;QACzB,sBAAiB,GAAmB,IAAI,CAAC;QAuD/C,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,GAAG,OAAO,CAAC;IACjC,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,eAAe,CAAC;IAC7B,CAAC;IAED;;;;;;;OAOG;IACH,CAAC,wBAAwB,CAAC,CAAC,WAAuC;QAChE,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC9B,IAAI,IAAI,KAAK,WAAW,EAAE,CAAC;gBACzB,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;YAChC,CAAC;QACH,CAAC;IACH,CAAC;;AA3Fe,0BAAM,GAAwB;IAC5C,0BAA0B;IAC1B,GAAG,CAAA;;;;;;;;;KASF;CACF,AAZqB,CAYpB;AAYF;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;mDAGxC;AAYD;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;oDAGvC","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 internals,\n mixinElementInternals,\n} from '../../behaviors/element-internals.js';\nimport {\n resetMenuitemCheckedness,\n setCheckedness,\n updateUsedValues,\n} from './internal.js';\nimport type {AriaMenuitemElement} from './menuitem.js';\nimport {sharedSlottedContentStyles} from './shared-slotted-content.js';\n\nconst baseClass = mixinElementInternals(LitElement);\n\n/** Possible values for `AriaFieldsetElement`'s `checkable` property. */\n// tslint:disable-next-line:no-undefined-type-alias Defined by proposed spec\nexport type CheckableState = 'single' | 'multiple' | null;\n\n/**\n * An element implementing the proposed menu behavior of `<fieldset>`.\n */\nexport class AriaFieldsetElement extends baseClass {\n static override styles: CSSResultOrNative[] = [\n sharedSlottedContentStyles,\n css`\n :host {\n display: block;\n margin-inline: 2px;\n border: groove 2px ThreeDFace;\n padding-block: 0.35em 0.625em;\n padding-inline: 0.75em;\n min-inline-size: min-content;\n }\n `,\n ];\n\n private internalDisabled = false;\n private internalCheckable: CheckableState = null;\n\n private get items(): Iterable<AriaMenuitemElement> {\n // This naively queries for these elements because this element doesn't need\n // to support nested fieldsets yet.\n return this.querySelectorAll('md-aria-menuitem');\n }\n\n @property({type: Boolean, reflect: true})\n get disabled(): boolean {\n return this.internalDisabled;\n }\n set disabled(value: boolean) {\n this.internalDisabled = value;\n for (const item of this.items) {\n // If this component is upgraded with `disabled` set in HTML,\n // `<md-aria-menuitem>` children will not be upgraded at this point.\n // These children will update themselves during `connectedCallback`.\n item[updateUsedValues]?.();\n }\n }\n\n @property({type: String, reflect: true})\n get checkable(): CheckableState {\n return this.internalCheckable;\n }\n set checkable(value: CheckableState) {\n if (typeof value === 'string') {\n const canonicalizedValue = value.toLowerCase();\n if (\n canonicalizedValue === 'single' ||\n canonicalizedValue === 'multiple'\n ) {\n value = canonicalizedValue;\n } else {\n value = 'multiple';\n }\n }\n\n this.internalCheckable = value;\n\n if (value === 'single') {\n this[resetMenuitemCheckedness](null);\n }\n\n for (const item of this.items) {\n // If this component is upgraded with `checkable` set in HTML,\n // `<md-aria-menuitem>` children will not be upgraded at this point.\n // These children will update themselves during `connectedCallback`.\n item[updateUsedValues]?.();\n }\n }\n\n constructor() {\n super();\n this[internals].role = 'group';\n }\n\n override render() {\n return html`<slot></slot>`;\n }\n\n /**\n * Unchecks every menuitem in this fieldset apart from the given one.\n *\n * `<md-aria-menuitem>` calls this on its cached ancestor fieldset when it\n * becomes checked in a single-checkable fieldset.\n *\n * @param checkedItem The item to leave as-is, or null to uncheck every item.\n */\n [resetMenuitemCheckedness](checkedItem: AriaMenuitemElement | null) {\n for (const item of this.items) {\n if (item !== checkedItem) {\n item[setCheckedness]?.(false);\n }\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* @fileoverview Unique symbols for members that the menu elements share with
|
|
8
|
+
* each other but that are not part of any of their public APIs.
|
|
9
|
+
*/
|
|
10
|
+
/** Defined by `AriaMenuitemElement`. */
|
|
11
|
+
export declare const updateUsedValues: unique symbol;
|
|
12
|
+
/** Defined by `AriaMenuitemElement`. */
|
|
13
|
+
export declare const setCheckedness: unique symbol;
|
|
14
|
+
/** Defined by `AriaFieldsetElement`. */
|
|
15
|
+
export declare const resetMenuitemCheckedness: unique symbol;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* @fileoverview Unique symbols for members that the menu elements share with
|
|
8
|
+
* each other but that are not part of any of their public APIs.
|
|
9
|
+
*/
|
|
10
|
+
/** Defined by `AriaMenuitemElement`. */
|
|
11
|
+
export const updateUsedValues = Symbol('updateUsedValues');
|
|
12
|
+
/** Defined by `AriaMenuitemElement`. */
|
|
13
|
+
export const setCheckedness = Symbol('setCheckedness');
|
|
14
|
+
/** Defined by `AriaFieldsetElement`. */
|
|
15
|
+
export const resetMenuitemCheckedness = Symbol('resetMenuitemCheckedness');
|
|
16
|
+
//# sourceMappingURL=internal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["internal.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;GAGG;AAEH,wCAAwC;AACxC,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC;AAE3D,wCAAwC;AACxC,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAEvD,wCAAwC;AACxC,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC,0BAA0B,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/**\n * @fileoverview Unique symbols for members that the menu elements share with\n * each other but that are not part of any of their public APIs.\n */\n\n/** Defined by `AriaMenuitemElement`. */\nexport const updateUsedValues = Symbol('updateUsedValues');\n\n/** Defined by `AriaMenuitemElement`. */\nexport const setCheckedness = Symbol('setCheckedness');\n\n/** Defined by `AriaFieldsetElement`. */\nexport const resetMenuitemCheckedness = Symbol('resetMenuitemCheckedness');\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"md-aria-fieldset.js","sourceRoot":"","sources":["md-aria-fieldset.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,mBAAmB,EAAC,MAAM,eAAe,CAAC;AAQlD,cAAc,CAAC,MAAM,CAAC,kBAAkB,EAAE,mBAAmB,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {AriaFieldsetElement} from './fieldset.js';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'md-aria-fieldset': AriaFieldsetElement;\n }\n}\n\ncustomElements.define('md-aria-fieldset', AriaFieldsetElement);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"md-aria-menuitem.js","sourceRoot":"","sources":["md-aria-menuitem.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,mBAAmB,EAAC,MAAM,eAAe,CAAC;AAQlD,cAAc,CAAC,MAAM,CAAC,kBAAkB,EAAE,mBAAmB,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {AriaMenuitemElement} from './menuitem.js';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'md-aria-menuitem': AriaMenuitemElement;\n }\n}\n\ncustomElements.define('md-aria-menuitem', AriaMenuitemElement);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"md-aria-menulist.js","sourceRoot":"","sources":["md-aria-menulist.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,mBAAmB,EAAC,MAAM,eAAe,CAAC;AAQlD,cAAc,CAAC,MAAM,CAAC,kBAAkB,EAAE,mBAAmB,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {AriaMenulistElement} from './menulist.js';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'md-aria-menulist': AriaMenulistElement;\n }\n}\n\ncustomElements.define('md-aria-menulist', AriaMenulistElement);\n"]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { CSSResultOrNative, LitElement } from 'lit';
|
|
7
|
+
import { setCheckedness, updateUsedValues } from './internal.js';
|
|
8
|
+
declare const baseClass: import("../../behaviors/mixin.js").MixinReturn<import("../../behaviors/mixin.js").MixinReturn<import("../../behaviors/mixin.js").MixinReturn<typeof LitElement, import("../../behaviors/element-internals.js").WithElementInternals>, import("../../behaviors/focusable.js").Focusable>, import("../../behaviors/custom-state-set.js").WithCustomStateSet>;
|
|
9
|
+
/**
|
|
10
|
+
* An element implementing the proposed `<menuitem>` built-in element.
|
|
11
|
+
*
|
|
12
|
+
* @fires {Event} checked - Fired when the item is checked or unchecked.
|
|
13
|
+
* @cssstate enabled - True when the item is enabled.
|
|
14
|
+
* @cssstate disabled - True when the item is disabled.
|
|
15
|
+
* @cssstate checked - True when the item is checked.
|
|
16
|
+
*/
|
|
17
|
+
export declare class AriaMenuitemElement extends baseClass {
|
|
18
|
+
static styles: CSSResultOrNative[];
|
|
19
|
+
private internalDisabled;
|
|
20
|
+
private checkedness;
|
|
21
|
+
private dirtyCheckedness;
|
|
22
|
+
private internalDefaultChecked;
|
|
23
|
+
private cachedAncestorMenulist;
|
|
24
|
+
private cachedAncestorFieldset;
|
|
25
|
+
private get usedCheckable();
|
|
26
|
+
private get usedDisabled();
|
|
27
|
+
/**
|
|
28
|
+
* Recomputes this element's used `disabled` and `checkable` values and
|
|
29
|
+
* projects them onto its ARIA attributes and custom states.
|
|
30
|
+
*
|
|
31
|
+
* `<md-aria-fieldset>` calls this on its items when a value they inherit from
|
|
32
|
+
* it changes.
|
|
33
|
+
*/
|
|
34
|
+
[updateUsedValues](): void;
|
|
35
|
+
private resetAncestorElementCache;
|
|
36
|
+
/**
|
|
37
|
+
* Sets this element's checkedness directly, without running the rest of the
|
|
38
|
+
* 'check a menuitem element' steps.
|
|
39
|
+
*
|
|
40
|
+
* `<md-aria-fieldset>` calls this to reset the items excluded by a newly
|
|
41
|
+
* checked item.
|
|
42
|
+
*
|
|
43
|
+
* @param value The new checkedness.
|
|
44
|
+
*/
|
|
45
|
+
[setCheckedness](value: boolean): void;
|
|
46
|
+
private checkAMenuitemElement;
|
|
47
|
+
get disabled(): boolean;
|
|
48
|
+
set disabled(value: boolean);
|
|
49
|
+
get checked(): boolean;
|
|
50
|
+
set checked(value: boolean);
|
|
51
|
+
get defaultChecked(): boolean;
|
|
52
|
+
set defaultChecked(value: boolean);
|
|
53
|
+
constructor();
|
|
54
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
55
|
+
connectedCallback(): void;
|
|
56
|
+
disconnectedCallback(): void;
|
|
57
|
+
click(): void;
|
|
58
|
+
}
|
|
59
|
+
export {};
|