@material/web 2.5.1-nightly.cbd34a8.0 → 2.5.1-nightly.de5470f.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/custom-elements.json +8248 -1222
- 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/menu/md-aria-menubar.d.ts +11 -0
- package/labs/aria/menu/md-aria-menubar.js +8 -0
- package/labs/aria/menu/md-aria-menubar.js.map +1 -0
- package/labs/aria/menu/menubar.d.ts +15 -0
- package/labs/aria/menu/menubar.js +45 -0
- package/labs/aria/menu/menubar.js.map +1 -0
- package/labs/aria/menu/menulist.d.ts +2 -2
- package/labs/aria/menu/menulist.js +6 -4
- package/labs/aria/menu/menulist.js.map +1 -1
- 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/gb/components/all.d.ts +72 -0
- package/labs/gb/components/all.js +81 -0
- package/labs/gb/components/all.js.map +1 -0
- package/labs/gb/components/button/button-element.d.ts +1 -9
- package/labs/gb/components/button/button-element.js +6 -65
- 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.scss +10 -3
- package/labs/gb/components/buttongroup/_button-group-tokens.scss +123 -0
- package/labs/gb/components/buttongroup/button-group-element.d.ts +65 -0
- package/labs/gb/components/buttongroup/button-group-element.js +277 -0
- package/labs/gb/components/buttongroup/button-group-element.js.map +1 -0
- package/labs/gb/components/buttongroup/button-group.css +5 -0
- package/labs/gb/components/buttongroup/button-group.css.map +1 -0
- package/labs/gb/components/buttongroup/button-group.cssresult.d.ts +3 -0
- package/labs/gb/components/buttongroup/button-group.cssresult.js +15 -0
- package/labs/gb/components/buttongroup/button-group.cssresult.js.map +1 -0
- package/labs/gb/components/buttongroup/button-group.d.ts +96 -0
- package/labs/gb/components/buttongroup/button-group.js +105 -0
- package/labs/gb/components/buttongroup/button-group.js.map +1 -0
- package/labs/gb/components/buttongroup/button-group.scss +282 -0
- package/labs/gb/components/buttongroup/md-gb-button-group.d.ts +12 -0
- package/labs/gb/components/buttongroup/md-gb-button-group.js +8 -0
- package/labs/gb/components/buttongroup/md-gb-button-group.js.map +1 -0
- package/labs/gb/components/card/card-element.d.ts +1 -9
- package/labs/gb/components/card/card-element.js +4 -59
- package/labs/gb/components/card/card-element.js.map +1 -1
- package/labs/gb/components/card/card.css +1 -1
- package/labs/gb/components/card/card.css.map +1 -1
- package/labs/gb/components/card/card.cssresult.js +1 -1
- package/labs/gb/components/card/card.cssresult.js.map +1 -1
- package/labs/gb/components/card/card.scss +18 -5
- package/labs/gb/components/checkbox/checkbox.css +1 -1
- package/labs/gb/components/checkbox/checkbox.css.map +1 -1
- package/labs/gb/components/checkbox/checkbox.cssresult.js +1 -1
- package/labs/gb/components/checkbox/checkbox.cssresult.js.map +1 -1
- package/labs/gb/components/checkbox/checkbox.scss +1 -0
- package/labs/gb/components/chip/chip.css +1 -1
- package/labs/gb/components/chip/chip.css.map +1 -1
- package/labs/gb/components/chip/chip.cssresult.js +1 -1
- package/labs/gb/components/chip/chip.cssresult.js.map +1 -1
- package/labs/gb/components/chip/chip.scss +1 -0
- package/labs/gb/components/iconbutton/icon-button-element.js +1 -1
- 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.scss +6 -3
- 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 +1 -0
- 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 +1 -0
- package/labs/gb/components/navbar/_nav-bar-tokens.scss +53 -0
- package/labs/gb/components/navbar/md-gb-nav-bar-item.d.ts +12 -0
- package/labs/gb/components/navbar/md-gb-nav-bar-item.js +10 -0
- package/labs/gb/components/navbar/md-gb-nav-bar-item.js.map +1 -0
- package/labs/gb/components/navbar/md-gb-nav-bar.d.ts +12 -0
- package/labs/gb/components/navbar/md-gb-nav-bar.js +10 -0
- package/labs/gb/components/navbar/md-gb-nav-bar.js.map +1 -0
- package/labs/gb/components/navbar/nav-bar-element.d.ts +58 -0
- package/labs/gb/components/navbar/nav-bar-element.js +116 -0
- package/labs/gb/components/navbar/nav-bar-element.js.map +1 -0
- package/labs/gb/components/navbar/nav-bar-item-element.d.ts +41 -0
- package/labs/gb/components/navbar/nav-bar-item-element.js +146 -0
- package/labs/gb/components/navbar/nav-bar-item-element.js.map +1 -0
- package/labs/gb/components/navbar/nav-bar.css +4 -0
- package/labs/gb/components/navbar/nav-bar.css.map +1 -0
- package/labs/gb/components/navbar/nav-bar.cssresult.d.ts +3 -0
- package/labs/gb/components/navbar/nav-bar.cssresult.js +14 -0
- package/labs/gb/components/navbar/nav-bar.cssresult.js.map +1 -0
- package/labs/gb/components/navbar/nav-bar.d.ts +86 -0
- package/labs/gb/components/navbar/nav-bar.js +92 -0
- package/labs/gb/components/navbar/nav-bar.js.map +1 -0
- package/labs/gb/components/navbar/nav-bar.scss +296 -0
- package/labs/gb/components/navrail/_nav-rail-tokens.scss +123 -0
- package/labs/gb/components/navrail/md-gb-nav-rail-item.d.ts +12 -0
- package/labs/gb/components/navrail/md-gb-nav-rail-item.js +10 -0
- package/labs/gb/components/navrail/md-gb-nav-rail-item.js.map +1 -0
- package/labs/gb/components/navrail/md-gb-nav-rail.d.ts +12 -0
- package/labs/gb/components/navrail/md-gb-nav-rail.js +10 -0
- package/labs/gb/components/navrail/md-gb-nav-rail.js.map +1 -0
- package/labs/gb/components/navrail/nav-rail-element.d.ts +120 -0
- package/labs/gb/components/navrail/nav-rail-element.js +366 -0
- package/labs/gb/components/navrail/nav-rail-element.js.map +1 -0
- package/labs/gb/components/navrail/nav-rail-item-element.d.ts +44 -0
- package/labs/gb/components/navrail/nav-rail-item-element.js +178 -0
- package/labs/gb/components/navrail/nav-rail-item-element.js.map +1 -0
- package/labs/gb/components/navrail/nav-rail.css +4 -0
- package/labs/gb/components/navrail/nav-rail.css.map +1 -0
- package/labs/gb/components/navrail/nav-rail.cssresult.d.ts +3 -0
- package/labs/gb/components/navrail/nav-rail.cssresult.js +14 -0
- package/labs/gb/components/navrail/nav-rail.cssresult.js.map +1 -0
- package/labs/gb/components/navrail/nav-rail.d.ts +108 -0
- package/labs/gb/components/navrail/nav-rail.js +115 -0
- package/labs/gb/components/navrail/nav-rail.js.map +1 -0
- package/labs/gb/components/navrail/nav-rail.scss +419 -0
- package/labs/gb/components/radio/radio.css +1 -1
- package/labs/gb/components/radio/radio.css.map +1 -1
- package/labs/gb/components/radio/radio.cssresult.js +1 -1
- package/labs/gb/components/radio/radio.cssresult.js.map +1 -1
- package/labs/gb/components/radio/radio.scss +1 -0
- package/labs/gb/components/shared/fx.d.ts +63 -0
- package/labs/gb/components/shared/fx.js +102 -0
- package/labs/gb/components/shared/fx.js.map +1 -0
- 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/slider/_slider-tokens.scss +86 -0
- package/labs/gb/components/slider/md-gb-slider.d.ts +12 -0
- package/labs/gb/components/slider/md-gb-slider.js +8 -0
- package/labs/gb/components/slider/md-gb-slider.js.map +1 -0
- package/labs/gb/components/slider/slider-element.d.ts +147 -0
- package/labs/gb/components/slider/slider-element.js +978 -0
- package/labs/gb/components/slider/slider-element.js.map +1 -0
- package/labs/gb/components/slider/slider.css +1 -0
- package/labs/gb/components/slider/slider.css.map +1 -0
- package/labs/gb/components/slider/slider.cssresult.d.ts +3 -0
- package/labs/gb/components/slider/slider.cssresult.js +11 -0
- package/labs/gb/components/slider/slider.cssresult.js.map +1 -0
- package/labs/gb/components/slider/slider.d.ts +173 -0
- package/labs/gb/components/slider/slider.js +502 -0
- package/labs/gb/components/slider/slider.js.map +1 -0
- package/labs/gb/components/slider/slider.scss +689 -0
- package/labs/gb/components/snackbar/_snackbar-tokens.scss +86 -0
- package/labs/gb/components/snackbar/harness.d.ts +32 -0
- package/labs/gb/components/snackbar/harness.js +64 -0
- package/labs/gb/components/snackbar/harness.js.map +1 -0
- package/labs/gb/components/snackbar/md-gb-snackbar.d.ts +12 -0
- package/labs/gb/components/snackbar/md-gb-snackbar.js +8 -0
- package/labs/gb/components/snackbar/md-gb-snackbar.js.map +1 -0
- package/labs/gb/components/snackbar/snackbar-element.d.ts +123 -0
- package/labs/gb/components/snackbar/snackbar-element.js +448 -0
- package/labs/gb/components/snackbar/snackbar-element.js.map +1 -0
- package/labs/gb/components/snackbar/snackbar.css +5 -0
- package/labs/gb/components/snackbar/snackbar.css.map +1 -0
- package/labs/gb/components/snackbar/snackbar.cssresult.d.ts +3 -0
- package/labs/gb/components/snackbar/snackbar.cssresult.js +15 -0
- package/labs/gb/components/snackbar/snackbar.cssresult.js.map +1 -0
- package/labs/gb/components/snackbar/snackbar.d.ts +54 -0
- package/labs/gb/components/snackbar/snackbar.js +72 -0
- package/labs/gb/components/snackbar/snackbar.js.map +1 -0
- package/labs/gb/components/snackbar/snackbar.scss +384 -0
- package/labs/gb/components/switch/switch.css +1 -1
- package/labs/gb/components/switch/switch.css.map +1 -1
- package/labs/gb/components/switch/switch.cssresult.js +1 -1
- package/labs/gb/components/switch/switch.cssresult.js.map +1 -1
- package/labs/gb/components/switch/switch.scss +4 -2
- package/package.json +1 -1
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { type ClassInfo } from 'lit/directives/class-map.js';
|
|
7
|
+
/** Button group variant layout types. */
|
|
8
|
+
export type ButtonGroupVariant = 'standard' | 'connected';
|
|
9
|
+
/** Button group selection types. */
|
|
10
|
+
export type ButtonGroupSelection = 'none' | 'single' | 'multiple';
|
|
11
|
+
/** Button group variant layout configurations. */
|
|
12
|
+
export declare const BUTTON_GROUP_VARIANTS: {
|
|
13
|
+
readonly standard: "standard";
|
|
14
|
+
readonly connected: "connected";
|
|
15
|
+
};
|
|
16
|
+
/** Button group selection configurations. */
|
|
17
|
+
export declare const BUTTON_GROUP_SELECTIONS: {
|
|
18
|
+
readonly none: "none";
|
|
19
|
+
readonly single: "single";
|
|
20
|
+
readonly multiple: "multiple";
|
|
21
|
+
};
|
|
22
|
+
/** Button group classes. */
|
|
23
|
+
export declare const BUTTON_GROUP_CLASSES: {
|
|
24
|
+
btnGroup: string;
|
|
25
|
+
btnGroupStandard: string;
|
|
26
|
+
btnGroupConnected: string;
|
|
27
|
+
disabled: string;
|
|
28
|
+
};
|
|
29
|
+
/** The state provided to the `buttonGroupClasses()` function. */
|
|
30
|
+
export interface ButtonGroupClassesState {
|
|
31
|
+
/** The visual variant of the button group. Defaults to `'standard'`. */
|
|
32
|
+
variant?: ButtonGroupVariant;
|
|
33
|
+
/** Whether the button group is disabled. */
|
|
34
|
+
disabled?: boolean;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Returns the button group classes to apply to an element based on the given state.
|
|
38
|
+
*
|
|
39
|
+
* @param state The state of the button group.
|
|
40
|
+
* @return An object of class names and truthy values if they apply.
|
|
41
|
+
*/
|
|
42
|
+
export declare function buttonGroupClasses({ variant, disabled, }?: ButtonGroupClassesState): ClassInfo;
|
|
43
|
+
/**
|
|
44
|
+
* A Lit directive that applies button group classes.
|
|
45
|
+
*/
|
|
46
|
+
export declare const buttonGroup: (state?: ButtonGroupClassesState & import("../shared/directives.js").AdditionalClasses) => import("lit-html/directive.js").DirectiveResult;
|
|
47
|
+
/**
|
|
48
|
+
* An item managed by a ButtonGroup.
|
|
49
|
+
*/
|
|
50
|
+
export interface ButtonGroupItem {
|
|
51
|
+
selected?: boolean;
|
|
52
|
+
disabled?: boolean;
|
|
53
|
+
softDisabled?: boolean;
|
|
54
|
+
href?: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Checks if a ButtonGroupItem is selectable.
|
|
58
|
+
* Disabled, soft-disabled, or link items are not selectable.
|
|
59
|
+
*/
|
|
60
|
+
export declare function isItemSelectable(item: ButtonGroupItem): boolean;
|
|
61
|
+
/** Options provided to the `normalizeSelection()` function. */
|
|
62
|
+
export interface NormalizeSelectionOptions<T extends ButtonGroupItem = ButtonGroupItem> {
|
|
63
|
+
/** The selection mode. */
|
|
64
|
+
selection?: ButtonGroupSelection;
|
|
65
|
+
/** Whether selection is required in single-select mode. */
|
|
66
|
+
required?: boolean;
|
|
67
|
+
/** The item preferred to keep selected during normalization. */
|
|
68
|
+
preferred?: T;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Pure selection normalization logic for button groups.
|
|
72
|
+
*
|
|
73
|
+
* - In 'none' mode: clears all selected items.
|
|
74
|
+
* - In 'single' mode: enforces at most 1 item selected.
|
|
75
|
+
* - If preferred is given and selected, keeps preferred and clears others.
|
|
76
|
+
* - Otherwise keeps the last selected item and clears earlier ones.
|
|
77
|
+
* - If required is true and 0 items are selected, auto-selects the first selectable item.
|
|
78
|
+
* - In 'multiple' mode: items keep their selected states as is.
|
|
79
|
+
*
|
|
80
|
+
* Mutates `item.selected` in place.
|
|
81
|
+
*/
|
|
82
|
+
export declare function normalizeSelection<T extends ButtonGroupItem>(items: T[], options: NormalizeSelectionOptions<T>): void;
|
|
83
|
+
/** Options provided to the `shouldBlockToggle()` function. */
|
|
84
|
+
export interface ShouldBlockToggleOptions {
|
|
85
|
+
/** The selection mode. */
|
|
86
|
+
selection?: ButtonGroupSelection;
|
|
87
|
+
/** Whether selection is required in single-select mode. */
|
|
88
|
+
required?: boolean;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Pure helper to determine if a toggle interaction on item `i` should be blocked.
|
|
92
|
+
*
|
|
93
|
+
* In required single-select mode, clicking an already selected button must not deselect it,
|
|
94
|
+
* ensuring exactly 1 item remains selected at all times.
|
|
95
|
+
*/
|
|
96
|
+
export declare function shouldBlockToggle(items: ButtonGroupItem[], i: number, options: ShouldBlockToggleOptions): boolean;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { createClassMapDirective } from '../shared/directives.js';
|
|
7
|
+
import { PSEUDO_CLASSES } from '../shared/pseudo-classes.js';
|
|
8
|
+
/** Button group variant layout configurations. */
|
|
9
|
+
export const BUTTON_GROUP_VARIANTS = {
|
|
10
|
+
standard: 'standard',
|
|
11
|
+
connected: 'connected',
|
|
12
|
+
};
|
|
13
|
+
/** Button group selection configurations. */
|
|
14
|
+
export const BUTTON_GROUP_SELECTIONS = {
|
|
15
|
+
none: 'none',
|
|
16
|
+
single: 'single',
|
|
17
|
+
multiple: 'multiple',
|
|
18
|
+
};
|
|
19
|
+
/** Button group classes. */
|
|
20
|
+
export const BUTTON_GROUP_CLASSES = {
|
|
21
|
+
btnGroup: 'btn-group',
|
|
22
|
+
btnGroupStandard: 'btn-group-standard',
|
|
23
|
+
btnGroupConnected: 'btn-group-connected',
|
|
24
|
+
disabled: PSEUDO_CLASSES.disabled,
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Returns the button group classes to apply to an element based on the given state.
|
|
28
|
+
*
|
|
29
|
+
* @param state The state of the button group.
|
|
30
|
+
* @return An object of class names and truthy values if they apply.
|
|
31
|
+
*/
|
|
32
|
+
export function buttonGroupClasses({ variant = 'standard', disabled = false, } = {}) {
|
|
33
|
+
return {
|
|
34
|
+
[BUTTON_GROUP_CLASSES.btnGroup]: true,
|
|
35
|
+
[BUTTON_GROUP_CLASSES.btnGroupStandard]: variant === 'standard' || !variant,
|
|
36
|
+
[BUTTON_GROUP_CLASSES.btnGroupConnected]: variant === 'connected',
|
|
37
|
+
[BUTTON_GROUP_CLASSES.disabled]: disabled,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A Lit directive that applies button group classes.
|
|
42
|
+
*/
|
|
43
|
+
export const buttonGroup = createClassMapDirective({
|
|
44
|
+
getClasses: buttonGroupClasses,
|
|
45
|
+
});
|
|
46
|
+
/**
|
|
47
|
+
* Checks if a ButtonGroupItem is selectable.
|
|
48
|
+
* Disabled, soft-disabled, or link items are not selectable.
|
|
49
|
+
*/
|
|
50
|
+
export function isItemSelectable(item) {
|
|
51
|
+
return !item.disabled && !item.softDisabled && !item.href;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Pure selection normalization logic for button groups.
|
|
55
|
+
*
|
|
56
|
+
* - In 'none' mode: clears all selected items.
|
|
57
|
+
* - In 'single' mode: enforces at most 1 item selected.
|
|
58
|
+
* - If preferred is given and selected, keeps preferred and clears others.
|
|
59
|
+
* - Otherwise keeps the last selected item and clears earlier ones.
|
|
60
|
+
* - If required is true and 0 items are selected, auto-selects the first selectable item.
|
|
61
|
+
* - In 'multiple' mode: items keep their selected states as is.
|
|
62
|
+
*
|
|
63
|
+
* Mutates `item.selected` in place.
|
|
64
|
+
*/
|
|
65
|
+
export function normalizeSelection(items, options) {
|
|
66
|
+
const { selection = 'none', required = false, preferred } = options;
|
|
67
|
+
if (selection === 'none') {
|
|
68
|
+
for (const item of items) {
|
|
69
|
+
item.selected = false;
|
|
70
|
+
}
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (selection === 'single') {
|
|
74
|
+
const selectedItems = items.filter((item) => item.selected);
|
|
75
|
+
if (selectedItems.length > 1) {
|
|
76
|
+
const itemToKeep = preferred && preferred.selected
|
|
77
|
+
? preferred
|
|
78
|
+
: selectedItems[selectedItems.length - 1];
|
|
79
|
+
for (const item of items) {
|
|
80
|
+
item.selected = item === itemToKeep;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
else if (selectedItems.length === 0 && required) {
|
|
84
|
+
const firstSelectable = items.find(isItemSelectable);
|
|
85
|
+
if (firstSelectable) {
|
|
86
|
+
firstSelectable.selected = true;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Pure helper to determine if a toggle interaction on item `i` should be blocked.
|
|
94
|
+
*
|
|
95
|
+
* In required single-select mode, clicking an already selected button must not deselect it,
|
|
96
|
+
* ensuring exactly 1 item remains selected at all times.
|
|
97
|
+
*/
|
|
98
|
+
export function shouldBlockToggle(items, i, options) {
|
|
99
|
+
const { selection = 'none', required = false } = options;
|
|
100
|
+
if (selection === 'single' && required) {
|
|
101
|
+
return Boolean(items[i]?.selected);
|
|
102
|
+
}
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=button-group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button-group.js","sourceRoot":"","sources":["button-group.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAC,uBAAuB,EAAC,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAC,cAAc,EAAC,MAAM,6BAA6B,CAAC;AAQ3D,kDAAkD;AAClD,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,QAAQ,EAAE,UAAU;IACpB,SAAS,EAAE,WAAW;CACd,CAAC;AAEX,6CAA6C;AAC7C,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;CACZ,CAAC;AAEX,4BAA4B;AAC5B,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,QAAQ,EAAE,WAAW;IACrB,gBAAgB,EAAE,oBAAoB;IACtC,iBAAiB,EAAE,qBAAqB;IACxC,QAAQ,EAAE,cAAc,CAAC,QAAQ;CAClC,CAAC;AAUF;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,EACjC,OAAO,GAAG,UAAU,EACpB,QAAQ,GAAG,KAAK,MACW,EAAE;IAC7B,OAAO;QACL,CAAC,oBAAoB,CAAC,QAAQ,CAAC,EAAE,IAAI;QACrC,CAAC,oBAAoB,CAAC,gBAAgB,CAAC,EAAE,OAAO,KAAK,UAAU,IAAI,CAAC,OAAO;QAC3E,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,OAAO,KAAK,WAAW;QACjE,CAAC,oBAAoB,CAAC,QAAQ,CAAC,EAAE,QAAQ;KAC1C,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,uBAAuB,CAA0B;IAC1E,UAAU,EAAE,kBAAkB;CAC/B,CAAC,CAAC;AAYH;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAqB;IACpD,OAAO,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,YAAY,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AAC5D,CAAC;AAcD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,kBAAkB,CAChC,KAAU,EACV,OAAqC;IAErC,MAAM,EAAC,SAAS,GAAG,MAAM,EAAE,QAAQ,GAAG,KAAK,EAAE,SAAS,EAAC,GAAG,OAAO,CAAC;IAElE,IAAI,SAAS,KAAK,MAAM,EAAE,CAAC;QACzB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACxB,CAAC;QACD,OAAO;IACT,CAAC;IAED,IAAI,SAAS,KAAK,QAAQ,EAAE,CAAC;QAC3B,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAE5D,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7B,MAAM,UAAU,GACd,SAAS,IAAI,SAAS,CAAC,QAAQ;gBAC7B,CAAC,CAAC,SAAS;gBACX,CAAC,CAAC,aAAa,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YAC9C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,IAAI,CAAC,QAAQ,GAAG,IAAI,KAAK,UAAU,CAAC;YACtC,CAAC;QACH,CAAC;aAAM,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,IAAI,QAAQ,EAAE,CAAC;YAClD,MAAM,eAAe,GAAG,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;YACrD,IAAI,eAAe,EAAE,CAAC;gBACpB,eAAe,CAAC,QAAQ,GAAG,IAAI,CAAC;YAClC,CAAC;QACH,CAAC;QACD,OAAO;IACT,CAAC;AACH,CAAC;AAUD;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAC/B,KAAwB,EACxB,CAAS,EACT,OAAiC;IAEjC,MAAM,EAAC,SAAS,GAAG,MAAM,EAAE,QAAQ,GAAG,KAAK,EAAC,GAAG,OAAO,CAAC;IACvD,IAAI,SAAS,KAAK,QAAQ,IAAI,QAAQ,EAAE,CAAC;QACvC,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {type ClassInfo} from 'lit/directives/class-map.js';\nimport {createClassMapDirective} from '../shared/directives.js';\nimport {PSEUDO_CLASSES} from '../shared/pseudo-classes.js';\n\n/** Button group variant layout types. */\nexport type ButtonGroupVariant = 'standard' | 'connected';\n\n/** Button group selection types. */\nexport type ButtonGroupSelection = 'none' | 'single' | 'multiple';\n\n/** Button group variant layout configurations. */\nexport const BUTTON_GROUP_VARIANTS = {\n standard: 'standard',\n connected: 'connected',\n} as const;\n\n/** Button group selection configurations. */\nexport const BUTTON_GROUP_SELECTIONS = {\n none: 'none',\n single: 'single',\n multiple: 'multiple',\n} as const;\n\n/** Button group classes. */\nexport const BUTTON_GROUP_CLASSES = {\n btnGroup: 'btn-group',\n btnGroupStandard: 'btn-group-standard',\n btnGroupConnected: 'btn-group-connected',\n disabled: PSEUDO_CLASSES.disabled,\n};\n\n/** The state provided to the `buttonGroupClasses()` function. */\nexport interface ButtonGroupClassesState {\n /** The visual variant of the button group. Defaults to `'standard'`. */\n variant?: ButtonGroupVariant;\n /** Whether the button group is disabled. */\n disabled?: boolean;\n}\n\n/**\n * Returns the button group classes to apply to an element based on the given state.\n *\n * @param state The state of the button group.\n * @return An object of class names and truthy values if they apply.\n */\nexport function buttonGroupClasses({\n variant = 'standard',\n disabled = false,\n}: ButtonGroupClassesState = {}): ClassInfo {\n return {\n [BUTTON_GROUP_CLASSES.btnGroup]: true,\n [BUTTON_GROUP_CLASSES.btnGroupStandard]: variant === 'standard' || !variant,\n [BUTTON_GROUP_CLASSES.btnGroupConnected]: variant === 'connected',\n [BUTTON_GROUP_CLASSES.disabled]: disabled,\n };\n}\n\n/**\n * A Lit directive that applies button group classes.\n */\nexport const buttonGroup = createClassMapDirective<ButtonGroupClassesState>({\n getClasses: buttonGroupClasses,\n});\n\n/**\n * An item managed by a ButtonGroup.\n */\nexport interface ButtonGroupItem {\n selected?: boolean;\n disabled?: boolean;\n softDisabled?: boolean;\n href?: string;\n}\n\n/**\n * Checks if a ButtonGroupItem is selectable.\n * Disabled, soft-disabled, or link items are not selectable.\n */\nexport function isItemSelectable(item: ButtonGroupItem): boolean {\n return !item.disabled && !item.softDisabled && !item.href;\n}\n\n/** Options provided to the `normalizeSelection()` function. */\nexport interface NormalizeSelectionOptions<\n T extends ButtonGroupItem = ButtonGroupItem,\n> {\n /** The selection mode. */\n selection?: ButtonGroupSelection;\n /** Whether selection is required in single-select mode. */\n required?: boolean;\n /** The item preferred to keep selected during normalization. */\n preferred?: T;\n}\n\n/**\n * Pure selection normalization logic for button groups.\n *\n * - In 'none' mode: clears all selected items.\n * - In 'single' mode: enforces at most 1 item selected.\n * - If preferred is given and selected, keeps preferred and clears others.\n * - Otherwise keeps the last selected item and clears earlier ones.\n * - If required is true and 0 items are selected, auto-selects the first selectable item.\n * - In 'multiple' mode: items keep their selected states as is.\n *\n * Mutates `item.selected` in place.\n */\nexport function normalizeSelection<T extends ButtonGroupItem>(\n items: T[],\n options: NormalizeSelectionOptions<T>,\n): void {\n const {selection = 'none', required = false, preferred} = options;\n\n if (selection === 'none') {\n for (const item of items) {\n item.selected = false;\n }\n return;\n }\n\n if (selection === 'single') {\n const selectedItems = items.filter((item) => item.selected);\n\n if (selectedItems.length > 1) {\n const itemToKeep =\n preferred && preferred.selected\n ? preferred\n : selectedItems[selectedItems.length - 1];\n for (const item of items) {\n item.selected = item === itemToKeep;\n }\n } else if (selectedItems.length === 0 && required) {\n const firstSelectable = items.find(isItemSelectable);\n if (firstSelectable) {\n firstSelectable.selected = true;\n }\n }\n return;\n }\n}\n\n/** Options provided to the `shouldBlockToggle()` function. */\nexport interface ShouldBlockToggleOptions {\n /** The selection mode. */\n selection?: ButtonGroupSelection;\n /** Whether selection is required in single-select mode. */\n required?: boolean;\n}\n\n/**\n * Pure helper to determine if a toggle interaction on item `i` should be blocked.\n *\n * In required single-select mode, clicking an already selected button must not deselect it,\n * ensuring exactly 1 item remains selected at all times.\n */\nexport function shouldBlockToggle(\n items: ButtonGroupItem[],\n i: number,\n options: ShouldBlockToggleOptions,\n): boolean {\n const {selection = 'none', required = false} = options;\n if (selection === 'single' && required) {\n return Boolean(items[i]?.selected);\n }\n return false;\n}\n"]}
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright 2026 Google LLC
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
@use 'button-group-tokens';
|
|
7
|
+
|
|
8
|
+
@layer md.sys, md.comp.ripple, md.comp.focus-ring, md.comp.button;
|
|
9
|
+
|
|
10
|
+
@layer md.comp.button-group {
|
|
11
|
+
.btn-group {
|
|
12
|
+
@include button-group-tokens.root;
|
|
13
|
+
display: inline-flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
gap: var(--between-space);
|
|
16
|
+
overflow: visible;
|
|
17
|
+
interpolate-size: allow-keywords;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Prevent button labels from wrapping when transitions undershoot
|
|
21
|
+
.btn-group > .btn,
|
|
22
|
+
.btn-group > * {
|
|
23
|
+
white-space: nowrap;
|
|
24
|
+
flex-shrink: 0;
|
|
25
|
+
min-inline-size: max-content;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Variant layout: standard (default)
|
|
29
|
+
.btn-group-standard,
|
|
30
|
+
.btn-group:not(.btn-group-connected) {
|
|
31
|
+
flex-wrap: wrap;
|
|
32
|
+
@include button-group-tokens.standard-sm;
|
|
33
|
+
|
|
34
|
+
&:has(> :is([size='xs'], .btn-xs)) {
|
|
35
|
+
@include button-group-tokens.standard-xs;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&:has(> :is([size='sm'], .btn-sm)) {
|
|
39
|
+
@include button-group-tokens.standard-sm;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
&:has(> :is([size='md'], .btn-md)) {
|
|
43
|
+
@include button-group-tokens.standard-md;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
&:has(> :is([size='lg'], .btn-lg)) {
|
|
47
|
+
@include button-group-tokens.standard-lg;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&:has(> :is([size='xl'], .btn-xl)) {
|
|
51
|
+
@include button-group-tokens.standard-xl;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Connected variant layout and gaps
|
|
56
|
+
.btn-group-connected {
|
|
57
|
+
flex-wrap: nowrap;
|
|
58
|
+
@include button-group-tokens.connected;
|
|
59
|
+
@include button-group-tokens.inner-corner-sm;
|
|
60
|
+
@include button-group-tokens.outer-corner-round;
|
|
61
|
+
|
|
62
|
+
&:has(> :is([size='xs'], .btn-xs)) {
|
|
63
|
+
@include button-group-tokens.inner-corner-xs;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
&:has(> :is([size='sm'], .btn-sm)) {
|
|
67
|
+
@include button-group-tokens.inner-corner-sm;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
&:has(> :is([size='md'], .btn-md)) {
|
|
71
|
+
@include button-group-tokens.inner-corner-md;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
&:has(> :is([size='lg'], .btn-lg)) {
|
|
75
|
+
@include button-group-tokens.inner-corner-lg;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
&:has(> :is([size='xl'], .btn-xl)) {
|
|
79
|
+
@include button-group-tokens.inner-corner-xl;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Default corners for all buttons in connected group:
|
|
84
|
+
.btn-group-connected > .btn,
|
|
85
|
+
.btn-group-connected > *::part(btn) {
|
|
86
|
+
--outer-corner-size: calc(var(--container-height) / 2);
|
|
87
|
+
border-radius: var(--inner-corner-size);
|
|
88
|
+
transition:
|
|
89
|
+
border-radius var(--motion-spring-fast-spatial-duration)
|
|
90
|
+
var(--motion-spring-fast-spatial),
|
|
91
|
+
var(--ripple-transition);
|
|
92
|
+
|
|
93
|
+
&.btn-xs,
|
|
94
|
+
&:is([size='xs'], .btn-xs)::part(btn) {
|
|
95
|
+
@include button-group-tokens.inner-corner-xs;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
&.btn-sm,
|
|
99
|
+
&:is([size='sm'], .btn-sm)::part(btn) {
|
|
100
|
+
@include button-group-tokens.inner-corner-sm;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
&.btn-md,
|
|
104
|
+
&:is([size='md'], .btn-md)::part(btn) {
|
|
105
|
+
@include button-group-tokens.inner-corner-md;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
&.btn-lg,
|
|
109
|
+
&:is([size='lg'], .btn-lg)::part(btn) {
|
|
110
|
+
@include button-group-tokens.inner-corner-lg;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
&.btn-xl,
|
|
114
|
+
&:is([size='xl'], .btn-xl)::part(btn) {
|
|
115
|
+
@include button-group-tokens.inner-corner-xl;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Square outer corner override for unselected buttons in connected group
|
|
120
|
+
.btn-group-connected
|
|
121
|
+
> [square]:not([selected]):not([aria-pressed='true'])::part(btn),
|
|
122
|
+
.btn-group-connected
|
|
123
|
+
> .btn.btn-square:not(.btn-selected):not([aria-pressed='true']) {
|
|
124
|
+
--outer-corner-size: var(--outer-corner-square-size);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Child button square size overrides
|
|
128
|
+
.btn-group-connected
|
|
129
|
+
> [size='xs'][square]:not([selected]):not([aria-pressed='true'])::part(btn),
|
|
130
|
+
.btn-group-connected
|
|
131
|
+
> .btn-xs.btn-square:not(.btn-selected):not([aria-pressed='true']) {
|
|
132
|
+
--outer-corner-size: var(--md-sys-shape-corner-xs);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.btn-group-connected
|
|
136
|
+
> [size='sm'][square]:not([selected]):not([aria-pressed='true'])::part(btn),
|
|
137
|
+
.btn-group-connected
|
|
138
|
+
> .btn-sm.btn-square:not(.btn-selected):not([aria-pressed='true']) {
|
|
139
|
+
--outer-corner-size: var(--md-sys-shape-corner-sm);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.btn-group-connected
|
|
143
|
+
> [size='md'][square]:not([selected]):not([aria-pressed='true'])::part(btn),
|
|
144
|
+
.btn-group-connected
|
|
145
|
+
> .btn-md.btn-square:not(.btn-selected):not([aria-pressed='true']) {
|
|
146
|
+
--outer-corner-size: var(--md-sys-shape-corner-sm);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.btn-group-connected
|
|
150
|
+
> [size='lg'][square]:not([selected]):not([aria-pressed='true'])::part(btn),
|
|
151
|
+
.btn-group-connected
|
|
152
|
+
> .btn-lg.btn-square:not(.btn-selected):not([aria-pressed='true']) {
|
|
153
|
+
--outer-corner-size: var(--md-sys-shape-corner-lg);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.btn-group-connected
|
|
157
|
+
> [size='xl'][square]:not([selected]):not([aria-pressed='true'])::part(btn),
|
|
158
|
+
.btn-group-connected
|
|
159
|
+
> .btn-xl.btn-square:not(.btn-selected):not([aria-pressed='true']) {
|
|
160
|
+
--outer-corner-size: var(--md-sys-shape-corner-lg-increased);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Selected button in connected group blooms all corners to full pill in any position
|
|
164
|
+
.btn-group-connected > .btn:is(.btn-selected, [aria-pressed='true']),
|
|
165
|
+
.btn-group-connected > :is([selected], [aria-pressed='true'])::part(btn) {
|
|
166
|
+
--inner-corner-size: calc(var(--container-height) / 2);
|
|
167
|
+
--outer-corner-size: calc(var(--container-height) / 2);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Pressed button in connected group tightens inner corners to pressed token (declared last so it wins over selected)
|
|
171
|
+
.btn-group-connected > .btn:active:not(:disabled, .disabled),
|
|
172
|
+
.btn-group-connected > :active:not([disabled], [soft-disabled])::part(btn) {
|
|
173
|
+
--inner-corner-size: var(--pressed-inner-corner-size);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// First child outer start corners (logical properties ensure correct LTR and RTL rendering)
|
|
177
|
+
.btn-group-connected
|
|
178
|
+
> .btn:is(:first-child, :nth-child(1 of .btn:not([hidden]))):not(
|
|
179
|
+
:only-child
|
|
180
|
+
),
|
|
181
|
+
.btn-group-connected
|
|
182
|
+
> :is(:first-child, :nth-child(1 of :not([hidden]))):not(:only-child)::part(
|
|
183
|
+
btn
|
|
184
|
+
) {
|
|
185
|
+
border-start-start-radius: var(--outer-corner-size);
|
|
186
|
+
border-end-start-radius: var(--outer-corner-size);
|
|
187
|
+
border-start-end-radius: var(--inner-corner-size);
|
|
188
|
+
border-end-end-radius: var(--inner-corner-size);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// Last child outer end corners (logical properties ensure correct LTR and RTL rendering)
|
|
192
|
+
.btn-group-connected
|
|
193
|
+
> .btn:is(:last-child, :nth-last-child(1 of .btn:not([hidden]))):not(
|
|
194
|
+
:only-child
|
|
195
|
+
),
|
|
196
|
+
.btn-group-connected
|
|
197
|
+
> :is(:last-child, :nth-last-child(1 of :not([hidden]))):not(
|
|
198
|
+
:only-child
|
|
199
|
+
)::part(btn) {
|
|
200
|
+
border-start-start-radius: var(--inner-corner-size);
|
|
201
|
+
border-end-start-radius: var(--inner-corner-size);
|
|
202
|
+
border-start-end-radius: var(--outer-corner-size);
|
|
203
|
+
border-end-end-radius: var(--outer-corner-size);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// Single-child group (both first and last)
|
|
207
|
+
.btn-group-connected > .btn:only-child,
|
|
208
|
+
.btn-group-connected > :only-child::part(btn) {
|
|
209
|
+
border-radius: var(--outer-corner-size);
|
|
210
|
+
border-start-start-radius: var(--outer-corner-size);
|
|
211
|
+
border-end-start-radius: var(--outer-corner-size);
|
|
212
|
+
border-start-end-radius: var(--outer-corner-size);
|
|
213
|
+
border-end-end-radius: var(--outer-corner-size);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// Outlined selected button has no outline in both standard and connected variants
|
|
217
|
+
.btn-group > .btn.btn-outlined:is(.btn-selected, [aria-pressed='true']),
|
|
218
|
+
.btn-group
|
|
219
|
+
> [color='outlined']:is([selected], [aria-pressed='true'])::part(btn) {
|
|
220
|
+
--outline-color: transparent;
|
|
221
|
+
border-color: transparent;
|
|
222
|
+
background-color: var(--md-sys-color-inverse-surface);
|
|
223
|
+
color: var(--md-sys-color-inverse-on-surface);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Connected XS and SM 48px min-inline-size
|
|
227
|
+
.btn-group-connected > .btn:is(.btn-xs, .btn-sm),
|
|
228
|
+
.btn-group-connected > :is([size='xs'], [size='sm']) {
|
|
229
|
+
min-inline-size: 48px;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// Focus ring stacking
|
|
233
|
+
.btn-group > .btn:focus-within,
|
|
234
|
+
.btn-group > :focus-within {
|
|
235
|
+
z-index: 1;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// Standard press width expansion
|
|
239
|
+
@supports (width: calc-size(auto, size)) {
|
|
240
|
+
.btn-group:not(.btn-group-connected) > .btn,
|
|
241
|
+
.btn-group:not(.btn-group-connected) > * {
|
|
242
|
+
transition: width var(--motion-spring-fast-spatial-duration)
|
|
243
|
+
var(--motion-spring-fast-spatial);
|
|
244
|
+
|
|
245
|
+
&:active:not(:disabled, .disabled),
|
|
246
|
+
&:active:not([disabled], [soft-disabled]) {
|
|
247
|
+
width: calc-size(
|
|
248
|
+
auto,
|
|
249
|
+
max(size, size * var(--pressed-item-width-multiplier))
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// Button positioning for touch target anchoring
|
|
256
|
+
.btn-group > .btn:is(.btn-xs, .btn-sm),
|
|
257
|
+
.btn-group > :is([size='xs'], [size='sm']) {
|
|
258
|
+
position: relative;
|
|
259
|
+
|
|
260
|
+
&::before,
|
|
261
|
+
&::part(btn)::before {
|
|
262
|
+
content: '';
|
|
263
|
+
position: absolute;
|
|
264
|
+
top: 50%;
|
|
265
|
+
left: 50%;
|
|
266
|
+
transform: translate(-50%, -50%);
|
|
267
|
+
width: 100%;
|
|
268
|
+
height: 48px;
|
|
269
|
+
min-height: 48px;
|
|
270
|
+
z-index: 0;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// Reduced motion
|
|
275
|
+
@media (prefers-reduced-motion: reduce) {
|
|
276
|
+
.btn-group > .btn,
|
|
277
|
+
.btn-group > *::part(btn),
|
|
278
|
+
.btn-group > * {
|
|
279
|
+
transition-duration: 0s;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { ButtonGroupElement } from './button-group-element.js';
|
|
7
|
+
declare global {
|
|
8
|
+
interface HTMLElementTagNameMap {
|
|
9
|
+
/** A Material Design button group. */
|
|
10
|
+
'md-gb-button-group': ButtonGroupElement;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { ButtonGroupElement } from './button-group-element.js';
|
|
7
|
+
customElements.define('md-gb-button-group', ButtonGroupElement);
|
|
8
|
+
//# sourceMappingURL=md-gb-button-group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"md-gb-button-group.js","sourceRoot":"","sources":["md-gb-button-group.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,kBAAkB,EAAC,MAAM,2BAA2B,CAAC;AAS7D,cAAc,CAAC,MAAM,CAAC,oBAAoB,EAAE,kBAAkB,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {ButtonGroupElement} from './button-group-element.js';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n /** A Material Design button group. */\n 'md-gb-button-group': ButtonGroupElement;\n }\n}\n\ncustomElements.define('md-gb-button-group', ButtonGroupElement);\n"]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Copyright 2026 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import { CSSResultOrNative, LitElement
|
|
6
|
+
import { CSSResultOrNative, LitElement } from 'lit';
|
|
7
7
|
import { type CardColor } from './card.js';
|
|
8
8
|
declare const baseClass: import("@material/web/labs/behaviors/mixin.js").MixinReturn<typeof LitElement>;
|
|
9
9
|
/**
|
|
@@ -25,20 +25,12 @@ export declare class CardElement extends baseClass {
|
|
|
25
25
|
static shadowRootOptions: ShadowRootInit;
|
|
26
26
|
/** @nocollapse */
|
|
27
27
|
static styles: CSSResultOrNative[];
|
|
28
|
-
private hideOutline;
|
|
29
|
-
private lastFiredEnabledState?;
|
|
30
28
|
/** The color of the card. */
|
|
31
29
|
color: CardColor;
|
|
32
30
|
/** Whether the card is disabled. */
|
|
33
31
|
disabled: boolean;
|
|
34
32
|
/** Whether the card is interactive. */
|
|
35
33
|
interactive: boolean;
|
|
36
|
-
connectedCallback(): void;
|
|
37
|
-
disconnectedCallback(): void;
|
|
38
|
-
private readonly handleSetShowOutline;
|
|
39
|
-
protected updated(changedProperties: PropertyValues): void;
|
|
40
|
-
private dispatchSetEnabledEvent;
|
|
41
34
|
protected render(): import("lit-html").TemplateResult<1>;
|
|
42
|
-
private handleContainerSlotChange;
|
|
43
35
|
}
|
|
44
36
|
export {};
|
|
@@ -4,10 +4,11 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import { __decorate } from "tslib";
|
|
7
|
-
import { css, html, LitElement, nothing
|
|
8
|
-
import { property
|
|
7
|
+
import { css, html, LitElement, nothing } from 'lit';
|
|
8
|
+
import { property } from 'lit/decorators.js';
|
|
9
9
|
import { mixinDelegatesAria } from '../../../../internal/aria/delegate.js';
|
|
10
10
|
import { ripple } from '../ripple/ripple.js';
|
|
11
|
+
import { fxSlot } from '../shared/fx.js';
|
|
11
12
|
import { hasSlotted } from '../shared/has-slotted.js';
|
|
12
13
|
import focusRingStyles from '../focus/focus-ring.css' with { type: 'css' }; // github-only
|
|
13
14
|
// import focusRingStyles from '../focus/focus-ring.cssresult.js'; // google3-only
|
|
@@ -35,45 +36,12 @@ const baseClass = mixinDelegatesAria(LitElement);
|
|
|
35
36
|
export class CardElement extends baseClass {
|
|
36
37
|
constructor() {
|
|
37
38
|
super(...arguments);
|
|
38
|
-
this.hideOutline = false;
|
|
39
39
|
/** The color of the card. */
|
|
40
40
|
this.color = 'outlined';
|
|
41
41
|
/** Whether the card is disabled. */
|
|
42
42
|
this.disabled = false;
|
|
43
43
|
/** Whether the card is interactive. */
|
|
44
44
|
this.interactive = false;
|
|
45
|
-
this.handleSetShowOutline = (event) => {
|
|
46
|
-
const customEvent = event;
|
|
47
|
-
this.hideOutline = !customEvent.detail.shown;
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
connectedCallback() {
|
|
51
|
-
super.connectedCallback();
|
|
52
|
-
this.addEventListener('md-gb:set-show-outline', this.handleSetShowOutline);
|
|
53
|
-
}
|
|
54
|
-
disconnectedCallback() {
|
|
55
|
-
super.disconnectedCallback();
|
|
56
|
-
this.removeEventListener('md-gb:set-show-outline', this.handleSetShowOutline);
|
|
57
|
-
}
|
|
58
|
-
updated(changedProperties) {
|
|
59
|
-
super.updated(changedProperties);
|
|
60
|
-
if (changedProperties.has('disabled')) {
|
|
61
|
-
this.dispatchSetEnabledEvent();
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
dispatchSetEnabledEvent() {
|
|
65
|
-
const enabled = !this.disabled;
|
|
66
|
-
if (this.lastFiredEnabledState === enabled)
|
|
67
|
-
return;
|
|
68
|
-
const slot = this.shadowRoot?.querySelector('slot[name="container"]');
|
|
69
|
-
if (slot) {
|
|
70
|
-
for (const element of slot.assignedElements({ flatten: true })) {
|
|
71
|
-
element.dispatchEvent(new CustomEvent('md-gb:set-enabled', {
|
|
72
|
-
detail: { enabled },
|
|
73
|
-
}));
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
this.lastFiredEnabledState = enabled;
|
|
77
45
|
}
|
|
78
46
|
render() {
|
|
79
47
|
const { ariaLabel } = this;
|
|
@@ -83,9 +51,6 @@ export class CardElement extends baseClass {
|
|
|
83
51
|
color: this.color,
|
|
84
52
|
disabled: this.disabled,
|
|
85
53
|
interactive: this.interactive,
|
|
86
|
-
classes: {
|
|
87
|
-
'card-hide-outline': this.hideOutline,
|
|
88
|
-
},
|
|
89
54
|
})}">
|
|
90
55
|
${this.interactive
|
|
91
56
|
? html `<button
|
|
@@ -96,22 +61,9 @@ export class CardElement extends baseClass {
|
|
|
96
61
|
aria-label="${ariaLabel || nothing}"></button>`
|
|
97
62
|
: nothing}
|
|
98
63
|
<slot></slot>
|
|
99
|
-
<slot
|
|
100
|
-
name="container"
|
|
101
|
-
${hasSlotted()}
|
|
102
|
-
@slotchange=${this.handleContainerSlotChange}></slot>
|
|
64
|
+
<slot name="container" ${hasSlotted()} ${fxSlot()}></slot>
|
|
103
65
|
</div>`;
|
|
104
66
|
}
|
|
105
|
-
handleContainerSlotChange(event) {
|
|
106
|
-
const slot = event.target;
|
|
107
|
-
const enabled = !this.disabled;
|
|
108
|
-
for (const element of slot.assignedElements({ flatten: true })) {
|
|
109
|
-
element.dispatchEvent(new CustomEvent('md-gb:change-container-slot'));
|
|
110
|
-
element.dispatchEvent(new CustomEvent('md-gb:set-enabled', {
|
|
111
|
-
detail: { enabled },
|
|
112
|
-
}));
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
67
|
}
|
|
116
68
|
/** @nocollapse */
|
|
117
69
|
CardElement.shadowRootOptions = {
|
|
@@ -135,10 +87,6 @@ CardElement.styles = [
|
|
|
135
87
|
.card:has([name='container'].has-slotted) {
|
|
136
88
|
background-color: transparent;
|
|
137
89
|
}
|
|
138
|
-
.card.card-hide-outline {
|
|
139
|
-
--outline-color: transparent;
|
|
140
|
-
--container-elevation: var(--md-sys-elevation-shadow-0);
|
|
141
|
-
}
|
|
142
90
|
slot[name='container'] {
|
|
143
91
|
display: block;
|
|
144
92
|
position: absolute;
|
|
@@ -155,9 +103,6 @@ CardElement.styles = [
|
|
|
155
103
|
}
|
|
156
104
|
`,
|
|
157
105
|
];
|
|
158
|
-
__decorate([
|
|
159
|
-
state()
|
|
160
|
-
], CardElement.prototype, "hideOutline", void 0);
|
|
161
106
|
__decorate([
|
|
162
107
|
property()
|
|
163
108
|
], CardElement.prototype, "color", void 0);
|