@material/web 2.4.2-nightly.2fe7e22.0 → 2.4.2-nightly.5088d91.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/_touch-target.scss +1 -1
- package/button/internal/button.d.ts +0 -4
- package/button/internal/button.js.map +1 -1
- package/button/internal/shared-styles.css +1 -1
- package/button/internal/shared-styles.css.map +1 -1
- package/button/internal/shared-styles.cssresult.js +1 -1
- package/button/internal/shared-styles.cssresult.js.map +1 -1
- package/checkbox/internal/checkbox.d.ts +2 -2
- package/checkbox/internal/checkbox.js.map +1 -1
- package/chips/internal/chip.d.ts +2 -0
- package/custom-elements.json +41872 -0
- package/icon/internal/icon.d.ts +1 -1
- package/icon/internal/icon.js +1 -1
- package/icon/internal/icon.js.map +1 -1
- package/iconbutton/internal/icon-button.d.ts +0 -4
- package/iconbutton/internal/icon-button.js.map +1 -1
- package/internal/aria/aria.d.ts +1 -1
- package/internal/events/dispatch-hooks.js +31 -35
- package/internal/events/dispatch-hooks.js.map +1 -1
- package/labs/behaviors/form-associated.d.ts +0 -22
- package/labs/behaviors/form-associated.js +0 -11
- package/labs/behaviors/form-associated.js.map +1 -1
- package/labs/gb/components/button/_button-tokens.scss +30 -30
- 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.d.ts +1 -16
- package/labs/gb/components/button/button.js +10 -33
- package/labs/gb/components/button/button.js.map +1 -1
- package/labs/gb/components/button/button.scss +25 -25
- package/labs/gb/components/button/md-button.d.ts +10 -2
- package/labs/gb/components/button/md-button.js +92 -11
- package/labs/gb/components/button/md-button.js.map +1 -1
- package/labs/gb/components/card/card.d.ts +1 -11
- package/labs/gb/components/card/card.js +6 -13
- package/labs/gb/components/card/card.js.map +1 -1
- package/labs/gb/components/card/md-card.d.ts +9 -1
- package/labs/gb/components/card/md-card.js +85 -8
- package/labs/gb/components/card/md-card.js.map +1 -1
- 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.d.ts +1 -16
- package/labs/gb/components/checkbox/checkbox.js +8 -31
- package/labs/gb/components/checkbox/checkbox.js.map +1 -1
- package/labs/gb/components/checkbox/checkbox.scss +13 -13
- package/labs/gb/components/checkbox/md-checkbox.d.ts +4 -4
- package/labs/gb/components/checkbox/md-checkbox.js +10 -10
- package/labs/gb/components/checkbox/md-checkbox.js.map +1 -1
- package/labs/gb/components/divider/divider.d.ts +1 -11
- package/labs/gb/components/divider/divider.js +4 -11
- package/labs/gb/components/divider/divider.js.map +1 -1
- package/labs/gb/components/fab/fab.d.ts +1 -16
- package/labs/gb/components/fab/fab.js +8 -31
- package/labs/gb/components/fab/fab.js.map +1 -1
- package/labs/gb/components/fab/md-fab.js +4 -4
- package/labs/gb/components/fab/md-fab.js.map +1 -1
- package/labs/gb/components/focus/focus-ring.js +1 -1
- package/labs/gb/components/focus/focus-ring.js.map +1 -1
- package/labs/gb/components/iconbutton/_icon-button-tokens.scss +202 -0
- package/labs/gb/components/iconbutton/icon-button.css +4 -0
- package/labs/gb/components/iconbutton/icon-button.css.map +1 -0
- package/labs/gb/components/iconbutton/icon-button.cssresult.d.ts +3 -0
- package/labs/gb/components/iconbutton/icon-button.cssresult.js +14 -0
- package/labs/gb/components/iconbutton/icon-button.cssresult.js.map +1 -0
- package/labs/gb/components/iconbutton/icon-button.d.ts +97 -0
- package/labs/gb/components/iconbutton/icon-button.js +122 -0
- package/labs/gb/components/iconbutton/icon-button.js.map +1 -0
- package/labs/gb/components/iconbutton/icon-button.scss +153 -0
- package/labs/gb/components/iconbutton/md-icon-button.d.ts +73 -0
- package/labs/gb/components/iconbutton/md-icon-button.js +176 -0
- package/labs/gb/components/iconbutton/md-icon-button.js.map +1 -0
- package/labs/gb/components/list/_list-tokens.scss +102 -0
- package/labs/gb/components/list/list.css +4 -0
- package/labs/gb/components/list/list.css.map +1 -0
- package/labs/gb/components/list/list.cssresult.d.ts +3 -0
- package/labs/gb/components/list/list.cssresult.js +14 -0
- package/labs/gb/components/list/list.cssresult.js.map +1 -0
- package/labs/gb/components/list/list.d.ts +103 -0
- package/labs/gb/components/list/list.js +109 -0
- package/labs/gb/components/list/list.js.map +1 -0
- package/labs/gb/components/list/list.scss +212 -0
- package/labs/gb/components/list/md-list-item.d.ts +44 -0
- package/labs/gb/components/list/md-list-item.js +122 -0
- package/labs/gb/components/list/md-list-item.js.map +1 -0
- package/labs/gb/components/list/md-list.d.ts +26 -0
- package/labs/gb/components/list/md-list.js +51 -0
- package/labs/gb/components/list/md-list.js.map +1 -0
- package/labs/gb/components/menu/_menu-tokens.scss +128 -0
- package/labs/gb/components/menu/md-menu-group.d.ts +26 -0
- package/labs/gb/components/menu/md-menu-group.js +65 -0
- package/labs/gb/components/menu/md-menu-group.js.map +1 -0
- package/labs/gb/components/menu/md-menu-item.d.ts +30 -0
- package/labs/gb/components/menu/md-menu-item.js +165 -0
- package/labs/gb/components/menu/md-menu-item.js.map +1 -0
- package/labs/gb/components/menu/md-menu.d.ts +28 -0
- package/labs/gb/components/menu/md-menu.js +141 -0
- package/labs/gb/components/menu/md-menu.js.map +1 -0
- package/labs/gb/components/menu/menu.css +4 -0
- package/labs/gb/components/menu/menu.css.map +1 -0
- package/labs/gb/components/menu/menu.cssresult.d.ts +3 -0
- package/labs/gb/components/menu/menu.cssresult.js +14 -0
- package/labs/gb/components/menu/menu.cssresult.js.map +1 -0
- package/labs/gb/components/menu/menu.d.ts +117 -0
- package/labs/gb/components/menu/menu.js +107 -0
- package/labs/gb/components/menu/menu.js.map +1 -0
- package/labs/gb/components/menu/menu.scss +171 -0
- package/labs/gb/components/radio/md-radio.d.ts +4 -4
- package/labs/gb/components/radio/md-radio.js +11 -11
- package/labs/gb/components/radio/md-radio.js.map +1 -1
- 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.d.ts +1 -14
- package/labs/gb/components/radio/radio.js +8 -23
- package/labs/gb/components/radio/radio.js.map +1 -1
- package/labs/gb/components/radio/radio.scss +4 -5
- package/labs/gb/components/ripple/ripple.d.ts +1 -10
- package/labs/gb/components/ripple/ripple.js +28 -32
- package/labs/gb/components/ripple/ripple.js.map +1 -1
- package/labs/gb/components/shared/directives.d.ts +93 -0
- package/labs/gb/components/shared/directives.js +111 -0
- package/labs/gb/components/shared/directives.js.map +1 -0
- package/labs/gb/components/shared/has-slotted.d.ts +10 -0
- package/labs/gb/components/shared/has-slotted.js +19 -0
- package/labs/gb/components/shared/has-slotted.js.map +1 -0
- package/labs/gb/components/shared/pseudo-classes.d.ts +7 -0
- package/labs/gb/components/shared/pseudo-classes.js +9 -0
- package/labs/gb/components/shared/pseudo-classes.js.map +1 -1
- package/labs/gb/components/splitbutton/_split-button-tokens.scss +135 -0
- package/labs/gb/components/splitbutton/md-split-button.d.ts +26 -0
- package/labs/gb/components/splitbutton/md-split-button.js +119 -0
- package/labs/gb/components/splitbutton/md-split-button.js.map +1 -0
- package/labs/gb/components/splitbutton/split-button.css +4 -0
- package/labs/gb/components/splitbutton/split-button.css.map +1 -0
- package/labs/gb/components/splitbutton/split-button.cssresult.d.ts +3 -0
- package/labs/gb/components/splitbutton/split-button.cssresult.js +14 -0
- package/labs/gb/components/splitbutton/split-button.cssresult.js.map +1 -0
- package/labs/gb/components/splitbutton/split-button.d.ts +47 -0
- package/labs/gb/components/splitbutton/split-button.js +46 -0
- package/labs/gb/components/splitbutton/split-button.js.map +1 -0
- package/labs/gb/components/splitbutton/split-button.scss +164 -0
- package/labs/gb/components/switch/_switch-tokens.scss +56 -0
- package/labs/gb/components/switch/md-switch.d.ts +66 -0
- package/labs/gb/components/switch/md-switch.js +162 -0
- package/labs/gb/components/switch/md-switch.js.map +1 -0
- package/labs/gb/components/switch/switch.css +4 -0
- package/labs/gb/components/switch/switch.css.map +1 -0
- package/labs/gb/components/switch/switch.cssresult.d.ts +3 -0
- package/labs/gb/components/switch/switch.cssresult.js +14 -0
- package/labs/gb/components/switch/switch.cssresult.js.map +1 -0
- package/labs/gb/components/switch/switch.d.ts +54 -0
- package/labs/gb/components/switch/switch.js +85 -0
- package/labs/gb/components/switch/switch.js.map +1 -0
- package/labs/gb/components/switch/switch.scss +109 -0
- package/labs/gb/styles/icon/md-icon.css +1 -1
- package/labs/gb/styles/icon/md-icon.css.map +1 -1
- package/labs/gb/styles/icon/md-icon.cssresult.js +1 -1
- package/labs/gb/styles/icon/md-icon.cssresult.js.map +1 -1
- package/labs/gb/styles/icon/md-icon.d.ts +20 -0
- package/labs/gb/styles/icon/md-icon.js +24 -0
- package/labs/gb/styles/icon/md-icon.js.map +1 -0
- package/labs/gb/styles/icon/md-icon.scss +2 -1
- package/labs/gb/styles/m3.css +5 -2
- package/labs/gb/styles/m3.css.map +1 -1
- package/labs/gb/styles/m3.cssresult.js +5 -2
- package/labs/gb/styles/m3.cssresult.js.map +1 -1
- package/labs/gb/styles/m3.scss +1 -0
- package/labs/gb/styles/space/md-space-tokens.css +4 -0
- package/labs/gb/styles/space/md-space-tokens.css.map +1 -0
- package/labs/gb/styles/space/md-space-tokens.cssresult.d.ts +3 -0
- package/labs/gb/styles/space/md-space-tokens.cssresult.js +14 -0
- package/labs/gb/styles/space/md-space-tokens.cssresult.js.map +1 -0
- package/labs/gb/styles/space/md-space-tokens.scss +28 -0
- package/labs/gb/styles/tailwind.css +4 -0
- package/labs/gb/styles/tailwind.css.map +1 -0
- package/labs/gb/styles/tailwind.cssresult.d.ts +3 -0
- package/labs/gb/styles/tailwind.cssresult.js +14 -0
- package/labs/gb/styles/tailwind.cssresult.js.map +1 -0
- package/labs/gb/styles/tailwind.scss +349 -0
- package/labs/gb/styles/typography/internal/_typography-tokens.scss +85 -16
- package/labs/gb/styles/typography/md-typography-tokens.css +1 -1
- package/labs/gb/styles/typography/md-typography-tokens.css.map +1 -1
- package/labs/gb/styles/typography/md-typography-tokens.cssresult.js +1 -1
- package/labs/gb/styles/typography/md-typography-tokens.cssresult.js.map +1 -1
- package/list/internal/listitem/list-item.d.ts +6 -1
- package/list/internal/listitem/list-item.js +4 -1
- package/list/internal/listitem/list-item.js.map +1 -1
- package/menu/internal/menuitem/menu-item.d.ts +2 -0
- package/menu/internal/submenu/sub-menu.d.ts +5 -1
- package/menu/internal/submenu/sub-menu.js +5 -1
- package/menu/internal/submenu/sub-menu.js.map +1 -1
- package/package.json +26 -4
- package/radio/internal/radio.d.ts +0 -2
- package/radio/internal/radio.js.map +1 -1
- package/select/internal/select.d.ts +2 -2
- package/select/internal/select.js.map +1 -1
- package/select/internal/selectoption/select-option.d.ts +2 -0
- package/slider/internal/slider.d.ts +0 -2
- package/slider/internal/slider.js.map +1 -1
- package/switch/internal/_switch.scss +1 -0
- package/switch/internal/switch-styles.css +1 -1
- package/switch/internal/switch-styles.css.map +1 -1
- package/switch/internal/switch-styles.cssresult.js +1 -1
- package/switch/internal/switch-styles.cssresult.js.map +1 -1
- package/switch/internal/switch.d.ts +0 -2
- package/switch/internal/switch.js.map +1 -1
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* Copyright 2026 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import { AsyncDirective, AttributePart, DirectiveParameters } from 'lit/async-directive.js';
|
|
7
6
|
import { type ClassInfo } from 'lit/directives/class-map.js';
|
|
8
7
|
/** Button color configuration types. */
|
|
9
8
|
export type ButtonColor = 'filled' | 'elevated' | 'tonal' | 'outlined' | 'text';
|
|
@@ -75,19 +74,6 @@ export declare function buttonClasses({ color, size, square, selected, active, d
|
|
|
75
74
|
export declare function setupButton(button: HTMLElement, opts?: {
|
|
76
75
|
signal?: AbortSignal;
|
|
77
76
|
}): void;
|
|
78
|
-
/** The state provided to the `button()` directive. */
|
|
79
|
-
export interface ButtonDirectiveState extends ButtonClassesState {
|
|
80
|
-
/** Additional classes to apply to the element. */
|
|
81
|
-
classes?: ClassInfo;
|
|
82
|
-
}
|
|
83
|
-
declare class ButtonDirective extends AsyncDirective {
|
|
84
|
-
private element?;
|
|
85
|
-
private cleanup?;
|
|
86
|
-
render(state?: ButtonDirectiveState): import("lit-html/directive.js").DirectiveResult<typeof import("lit-html/directives/class-map.js").ClassMapDirective>;
|
|
87
|
-
update({ element }: AttributePart, [state]: DirectiveParameters<this>): import("lit-html/directive.js").DirectiveResult<typeof import("lit-html/directives/class-map.js").ClassMapDirective>;
|
|
88
|
-
protected disconnected(): void;
|
|
89
|
-
protected reconnected(): void;
|
|
90
|
-
}
|
|
91
77
|
/**
|
|
92
78
|
* A Lit directive that adds button styling and functionality to its element.
|
|
93
79
|
*
|
|
@@ -96,5 +82,4 @@ declare class ButtonDirective extends AsyncDirective {
|
|
|
96
82
|
* html`<button class="${button({color: 'filled'})}">Filled</button>`;
|
|
97
83
|
* ```
|
|
98
84
|
*/
|
|
99
|
-
export declare const button: (state?:
|
|
100
|
-
export {};
|
|
85
|
+
export declare const button: (state?: ButtonClassesState & import("../shared/directives.js").AdditionalClasses) => import("lit-html/directive.js").DirectiveResult;
|
|
@@ -3,12 +3,11 @@
|
|
|
3
3
|
* Copyright 2026 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import { afterDispatch, setupDispatchHooks, } from '
|
|
7
|
-
import { focusRingClasses } from '
|
|
8
|
-
import { rippleClasses, setupRipple
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { classMap } from 'lit/directives/class-map.js';
|
|
6
|
+
import { afterDispatch, setupDispatchHooks, } from '../../../../internal/events/dispatch-hooks.js';
|
|
7
|
+
import { focusRingClasses } from '../focus/focus-ring.js';
|
|
8
|
+
import { rippleClasses, setupRipple } from '../ripple/ripple.js';
|
|
9
|
+
import { createClassMapDirective } from '../shared/directives.js';
|
|
10
|
+
import { isDisabled, PSEUDO_CLASSES } from '../shared/pseudo-classes.js';
|
|
12
11
|
/** Button color configurations. */
|
|
13
12
|
export const BUTTON_COLORS = {
|
|
14
13
|
filled: 'filled',
|
|
@@ -86,7 +85,7 @@ export function setupButton(button, opts) {
|
|
|
86
85
|
// event listeners as well as prevent the default action. This is because
|
|
87
86
|
// the underlying element may not actually be `:disabled`, such as an
|
|
88
87
|
// anchor tag or a soft-disabled button.
|
|
89
|
-
if (button
|
|
88
|
+
if (isDisabled(button)) {
|
|
90
89
|
event.stopImmediatePropagation();
|
|
91
90
|
event.preventDefault();
|
|
92
91
|
return;
|
|
@@ -105,31 +104,6 @@ export function setupButton(button, opts) {
|
|
|
105
104
|
});
|
|
106
105
|
}, opts);
|
|
107
106
|
}
|
|
108
|
-
class ButtonDirective extends AsyncDirective {
|
|
109
|
-
render(state = {}) {
|
|
110
|
-
return classMap({
|
|
111
|
-
...(state.classes || {}),
|
|
112
|
-
...buttonClasses(state),
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
update({ element }, [state]) {
|
|
116
|
-
if (this.isConnected && element !== this.element) {
|
|
117
|
-
this.element = element;
|
|
118
|
-
this.disconnected();
|
|
119
|
-
this.reconnected();
|
|
120
|
-
}
|
|
121
|
-
return this.render(state);
|
|
122
|
-
}
|
|
123
|
-
disconnected() {
|
|
124
|
-
this.cleanup?.abort();
|
|
125
|
-
}
|
|
126
|
-
reconnected() {
|
|
127
|
-
if (this.element) {
|
|
128
|
-
this.cleanup = new AbortController();
|
|
129
|
-
setupButton(this.element, { signal: this.cleanup.signal });
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
107
|
/**
|
|
134
108
|
* A Lit directive that adds button styling and functionality to its element.
|
|
135
109
|
*
|
|
@@ -138,5 +112,8 @@ class ButtonDirective extends AsyncDirective {
|
|
|
138
112
|
* html`<button class="${button({color: 'filled'})}">Filled</button>`;
|
|
139
113
|
* ```
|
|
140
114
|
*/
|
|
141
|
-
export const button =
|
|
115
|
+
export const button = createClassMapDirective({
|
|
116
|
+
getClasses: buttonClasses,
|
|
117
|
+
setupElement: setupButton,
|
|
118
|
+
});
|
|
142
119
|
//# sourceMappingURL=button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.js","sourceRoot":"","sources":["button.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,aAAa,EACb,kBAAkB,GACnB,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAC,gBAAgB,EAAC,MAAM,sDAAsD,CAAC;AACtF,OAAO,EACL,aAAa,EACb,WAAW,GACZ,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EAAC,cAAc,EAAC,MAAM,2DAA2D,CAAC;AACzF,OAAO,EACL,cAAc,EAEd,SAAS,GAEV,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAC,QAAQ,EAAiB,MAAM,6BAA6B,CAAC;AAKrE,mCAAmC;AACnC,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;IACpB,KAAK,EAAE,OAAO;IACd,QAAQ,EAAE,UAAU;IACpB,IAAI,EAAE,MAAM;CACJ,CAAC;AAKX,kCAAkC;AAClC,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,IAAI;CACA,CAAC;AAEX,sBAAsB;AACtB,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,GAAG,EAAE,KAAK;IACV,SAAS,EAAE,YAAY;IACvB,WAAW,EAAE,cAAc;IAC3B,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CAAC,OAAO,CAAC,MAAM,EAAC,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC;CACF;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,SAAS,CAAC,eAAe,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n afterDispatch,\n setupDispatchHooks,\n} from '@material/web/internal/events/dispatch-hooks.js';\nimport {focusRingClasses} from '@material/web/labs/gb/components/focus/focus-ring.js';\nimport {\n rippleClasses,\n setupRipple,\n} from '@material/web/labs/gb/components/ripple/ripple.js';\nimport {PSEUDO_CLASSES} from '@material/web/labs/gb/components/shared/pseudo-classes.js';\nimport {\n AsyncDirective,\n AttributePart,\n directive,\n DirectiveParameters,\n} from 'lit/async-directive.js';\nimport {classMap, type ClassInfo} from 'lit/directives/class-map.js';\n\n/** Button color configuration types. */\nexport type ButtonColor = 'filled' | 'elevated' | 'tonal' | 'outlined' | 'text';\n\n/** Button color configurations. */\nexport const BUTTON_COLORS = {\n filled: 'filled',\n elevated: 'elevated',\n tonal: 'tonal',\n outlined: 'outlined',\n text: 'text',\n} as const;\n\n/** Button size configuration types. */\nexport type ButtonSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';\n\n/** Button size configurations. */\nexport const BUTTON_SIZES = {\n xs: 'xs',\n sm: 'sm',\n md: 'md',\n lg: 'lg',\n xl: 'xl',\n} as const;\n\n/** Button classes. */\nexport const BUTTON_CLASSES = {\n btn: 'btn',\n btnFilled: 'btn-filled',\n btnElevated: 'btn-elevated',\n btnTonal: 'btn-tonal',\n btnOutlined: 'btn-outlined',\n btnText: 'btn-text',\n btnXs: 'btn-xs',\n btnSm: 'btn-sm',\n btnMd: 'btn-md',\n btnLg: 'btn-lg',\n btnXl: 'btn-xl',\n btnSquare: 'btn-square',\n btnUnselected: 'btn-unselected',\n btnSelected: 'btn-selected',\n active: PSEUDO_CLASSES.active,\n disabled: PSEUDO_CLASSES.disabled,\n};\n\n/** The state provided to the `buttonClasses()` function. */\nexport interface ButtonClassesState {\n /** The color of the button. */\n color?: ButtonColor;\n /** The size of the button. */\n size?: ButtonSize;\n /** Whether the button is a square shape. */\n square?: boolean;\n /** Whether the toggle button is selected, if not undefined. */\n selected?: boolean;\n /** Emulates `:active`. */\n active?: boolean;\n /** Emulates `:disabled`. */\n disabled?: boolean;\n}\n\n/**\n * Returns the button classes to apply to an element based on the given state.\n *\n * @param state The state of the button.\n * @return An object of class names and truthy values if they apply.\n */\nexport function buttonClasses({\n color,\n size,\n square = false,\n selected,\n active = false,\n disabled = false,\n}: ButtonClassesState = {}): ClassInfo {\n return {\n ...rippleClasses(),\n ...focusRingClasses(),\n [BUTTON_CLASSES.btn]: true,\n [BUTTON_CLASSES.btnFilled]: color === BUTTON_COLORS.filled,\n [BUTTON_CLASSES.btnElevated]: color === BUTTON_COLORS.elevated,\n [BUTTON_CLASSES.btnTonal]: color === BUTTON_COLORS.tonal,\n [BUTTON_CLASSES.btnOutlined]: color === BUTTON_COLORS.outlined,\n [BUTTON_CLASSES.btnText]: color === BUTTON_COLORS.text || !color,\n [BUTTON_CLASSES.btnXs]: size === BUTTON_SIZES.xs,\n [BUTTON_CLASSES.btnSm]: size === BUTTON_SIZES.sm || !size,\n [BUTTON_CLASSES.btnMd]: size === BUTTON_SIZES.md,\n [BUTTON_CLASSES.btnLg]: size === BUTTON_SIZES.lg,\n [BUTTON_CLASSES.btnXl]: size === BUTTON_SIZES.xl,\n [BUTTON_CLASSES.btnSquare]: square,\n [BUTTON_CLASSES.btnUnselected]: selected === false,\n [BUTTON_CLASSES.btnSelected]: selected === true,\n [BUTTON_CLASSES.active]: active,\n [BUTTON_CLASSES.disabled]: disabled,\n };\n}\n\n/**\n * Sets up button functionality for the given element.\n *\n * @param button The element on which to set up button functionality.\n * @param opts Setup options, supports a cleanup `signal`.\n */\nexport function setupButton(\n button: HTMLElement,\n opts?: {signal?: AbortSignal},\n): void {\n setupDispatchHooks(button, 'click');\n setupRipple(button, opts);\n button.addEventListener(\n 'click',\n (event) => {\n // When disabled, explicitly prevent the click from propagating to other\n // event listeners as well as prevent the default action. This is because\n // the underlying element may not actually be `:disabled`, such as an\n // anchor tag or a soft-disabled button.\n if (\n button.matches(`.${BUTTON_CLASSES.disabled},[aria-disabled=\"true\"]`)\n ) {\n event.stopImmediatePropagation();\n event.preventDefault();\n return;\n }\n\n afterDispatch(event, () => {\n const isToggle =\n button.hasAttribute('aria-pressed') ||\n button.matches(\n `.${BUTTON_CLASSES.btnSelected},.${BUTTON_CLASSES.btnUnselected}`,\n );\n if (event.defaultPrevented || !isToggle) {\n return;\n }\n\n const isPressed = button.ariaPressed === 'true';\n button.ariaPressed = String(!isPressed);\n // Mimic native browser input and change event behavior.\n button.dispatchEvent(\n new InputEvent('input', {bubbles: true, composed: true}),\n );\n button.dispatchEvent(new Event('change', {bubbles: true}));\n });\n },\n opts,\n );\n}\n\n/** The state provided to the `button()` directive. */\nexport interface ButtonDirectiveState extends ButtonClassesState {\n /** Additional classes to apply to the element. */\n classes?: ClassInfo;\n}\n\nclass ButtonDirective extends AsyncDirective {\n private element?: HTMLElement;\n private cleanup?: AbortController;\n\n render(state: ButtonDirectiveState = {}) {\n return classMap({\n ...(state.classes || {}),\n ...buttonClasses(state),\n });\n }\n\n override update(\n {element}: AttributePart,\n [state]: DirectiveParameters<this>,\n ) {\n if (this.isConnected && element !== this.element) {\n this.element = element as HTMLElement;\n this.disconnected();\n this.reconnected();\n }\n\n return this.render(state);\n }\n\n protected override disconnected() {\n this.cleanup?.abort();\n }\n\n protected override reconnected() {\n if (this.element) {\n this.cleanup = new AbortController();\n setupButton(this.element, {signal: this.cleanup.signal});\n }\n }\n}\n\n/**\n * A Lit directive that adds button styling and functionality to its element.\n *\n * @example\n * ```ts\n * html`<button class=\"${button({color: 'filled'})}\">Filled</button>`;\n * ```\n */\nexport const button = directive(ButtonDirective);\n"]}
|
|
1
|
+
{"version":3,"file":"button.js","s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J,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,uBAAuB,CAAC;IAC5C,UAAU,EAAE,aAAa;IACzB,YAAY,EAAE,WAAW;CAC1B,CAAC,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 {\n afterDispatch,\n setupDispatchHooks,\n} from '../../../../internal/events/dispatch-hooks.js';\nimport {focusRingClasses} from '../focus/focus-ring.js';\nimport {rippleClasses, setupRipple} from '../ripple/ripple.js';\nimport {createClassMapDirective} from '../shared/directives.js';\nimport {isDisabled, PSEUDO_CLASSES} from '../shared/pseudo-classes.js';\n\n/** Button color configuration types. */\nexport type ButtonColor = 'filled' | 'elevated' | 'tonal' | 'outlined' | 'text';\n\n/** Button color configurations. */\nexport const BUTTON_COLORS = {\n filled: 'filled',\n elevated: 'elevated',\n tonal: 'tonal',\n outlined: 'outlined',\n text: 'text',\n} as const;\n\n/** Button size configuration types. */\nexport type ButtonSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';\n\n/** Button size configurations. */\nexport const BUTTON_SIZES = {\n xs: 'xs',\n sm: 'sm',\n md: 'md',\n lg: 'lg',\n xl: 'xl',\n} as const;\n\n/** Button classes. */\nexport const BUTTON_CLASSES = {\n btn: 'btn',\n btnFilled: 'btn-filled',\n btnElevated: 'btn-elevated',\n btnTonal: 'btn-tonal',\n btnOutlined: 'btn-outlined',\n btnText: 'btn-text',\n btnXs: 'btn-xs',\n btnSm: 'btn-sm',\n btnMd: 'btn-md',\n btnLg: 'btn-lg',\n btnXl: 'btn-xl',\n btnSquare: 'btn-square',\n btnUnselected: 'btn-unselected',\n btnSelected: 'btn-selected',\n active: PSEUDO_CLASSES.active,\n disabled: PSEUDO_CLASSES.disabled,\n};\n\n/** The state provided to the `buttonClasses()` function. */\nexport interface ButtonClassesState {\n /** The color of the button. */\n color?: ButtonColor;\n /** The size of the button. */\n size?: ButtonSize;\n /** Whether the button is a square shape. */\n square?: boolean;\n /** Whether the toggle button is selected, if not undefined. */\n selected?: boolean;\n /** Emulates `:active`. */\n active?: boolean;\n /** Emulates `:disabled`. */\n disabled?: boolean;\n}\n\n/**\n * Returns the button classes to apply to an element based on the given state.\n *\n * @param state The state of the button.\n * @return An object of class names and truthy values if they apply.\n */\nexport function buttonClasses({\n color,\n size,\n square = false,\n selected,\n active = false,\n disabled = false,\n}: ButtonClassesState = {}): ClassInfo {\n return {\n ...rippleClasses(),\n ...focusRingClasses(),\n [BUTTON_CLASSES.btn]: true,\n [BUTTON_CLASSES.btnFilled]: color === BUTTON_COLORS.filled,\n [BUTTON_CLASSES.btnElevated]: color === BUTTON_COLORS.elevated,\n [BUTTON_CLASSES.btnTonal]: color === BUTTON_COLORS.tonal,\n [BUTTON_CLASSES.btnOutlined]: color === BUTTON_COLORS.outlined,\n [BUTTON_CLASSES.btnText]: color === BUTTON_COLORS.text || !color,\n [BUTTON_CLASSES.btnXs]: size === BUTTON_SIZES.xs,\n [BUTTON_CLASSES.btnSm]: size === BUTTON_SIZES.sm || !size,\n [BUTTON_CLASSES.btnMd]: size === BUTTON_SIZES.md,\n [BUTTON_CLASSES.btnLg]: size === BUTTON_SIZES.lg,\n [BUTTON_CLASSES.btnXl]: size === BUTTON_SIZES.xl,\n [BUTTON_CLASSES.btnSquare]: square,\n [BUTTON_CLASSES.btnUnselected]: selected === false,\n [BUTTON_CLASSES.btnSelected]: selected === true,\n [BUTTON_CLASSES.active]: active,\n [BUTTON_CLASSES.disabled]: disabled,\n };\n}\n\n/**\n * Sets up button functionality for the given element.\n *\n * @param button The element on which to set up button functionality.\n * @param opts Setup options, supports a cleanup `signal`.\n */\nexport function setupButton(\n button: HTMLElement,\n opts?: {signal?: AbortSignal},\n): void {\n setupDispatchHooks(button, 'click');\n setupRipple(button, opts);\n button.addEventListener(\n 'click',\n (event) => {\n // When disabled, explicitly prevent the click from propagating to other\n // event listeners as well as prevent the default action. This is because\n // the underlying element may not actually be `:disabled`, such as an\n // anchor tag or a soft-disabled button.\n if (isDisabled(button)) {\n event.stopImmediatePropagation();\n event.preventDefault();\n return;\n }\n\n afterDispatch(event, () => {\n const isToggle =\n button.hasAttribute('aria-pressed') ||\n button.matches(\n `.${BUTTON_CLASSES.btnSelected},.${BUTTON_CLASSES.btnUnselected}`,\n );\n if (event.defaultPrevented || !isToggle) {\n return;\n }\n\n const isPressed = button.ariaPressed === 'true';\n button.ariaPressed = String(!isPressed);\n // Mimic native browser input and change event behavior.\n button.dispatchEvent(\n new InputEvent('input', {bubbles: true, composed: true}),\n );\n button.dispatchEvent(new Event('change', {bubbles: true}));\n });\n },\n opts,\n );\n}\n\n/**\n * A Lit directive that adds button styling and functionality to its element.\n *\n * @example\n * ```ts\n * html`<button class=\"${button({color: 'filled'})}\">Filled</button>`;\n * ```\n */\nexport const button = createClassMapDirective({\n getClasses: buttonClasses,\n setupElement: setupButton,\n});\n"]}
|
|
@@ -14,15 +14,6 @@
|
|
|
14
14
|
&:is(.btn-selected, [aria-pressed='true']) {
|
|
15
15
|
@include button-tokens.selected;
|
|
16
16
|
}
|
|
17
|
-
&.btn-square {
|
|
18
|
-
@include button-tokens.square;
|
|
19
|
-
}
|
|
20
|
-
&:is(.btn-selected, [aria-pressed='true']):where(.btn-square) {
|
|
21
|
-
@include button-tokens.selected-square;
|
|
22
|
-
}
|
|
23
|
-
&:is(:active, .active):where(:not(:disabled, .disabled)) {
|
|
24
|
-
@include button-tokens.pressed;
|
|
25
|
-
}
|
|
26
17
|
&.btn-filled {
|
|
27
18
|
@include button-tokens.filled;
|
|
28
19
|
&:where(.btn-unselected, [aria-pressed='false']) {
|
|
@@ -70,35 +61,44 @@
|
|
|
70
61
|
&:where(.btn-selected, [aria-pressed='true']) {
|
|
71
62
|
@include button-tokens.md-selected;
|
|
72
63
|
}
|
|
73
|
-
&:where(.btn-square) {
|
|
74
|
-
@include button-tokens.md-square;
|
|
75
|
-
}
|
|
76
|
-
&:where(:is(:active, .active):not(:disabled, .disabled)) {
|
|
77
|
-
@include button-tokens.md-pressed;
|
|
78
|
-
}
|
|
79
64
|
}
|
|
80
65
|
&.btn-lg {
|
|
81
66
|
@include button-tokens.lg;
|
|
82
67
|
&:where(.btn-selected, [aria-pressed='true']) {
|
|
83
68
|
@include button-tokens.lg-selected;
|
|
84
69
|
}
|
|
85
|
-
&:where(.btn-square) {
|
|
86
|
-
@include button-tokens.lg-square;
|
|
87
|
-
}
|
|
88
|
-
&:where(:is(:active, .active):not(:disabled, .disabled)) {
|
|
89
|
-
@include button-tokens.lg-pressed;
|
|
90
|
-
}
|
|
91
70
|
}
|
|
92
71
|
&.btn-xl {
|
|
93
72
|
@include button-tokens.xl;
|
|
94
73
|
&:where(.btn-selected, [aria-pressed='true']) {
|
|
95
74
|
@include button-tokens.xl-selected;
|
|
96
75
|
}
|
|
97
|
-
|
|
98
|
-
|
|
76
|
+
}
|
|
77
|
+
&.btn-square {
|
|
78
|
+
@include button-tokens.square;
|
|
79
|
+
&:where(.btn-md) {
|
|
80
|
+
@include button-tokens.square-md;
|
|
99
81
|
}
|
|
100
|
-
&:where(
|
|
101
|
-
@include button-tokens.
|
|
82
|
+
&:where(.btn-lg) {
|
|
83
|
+
@include button-tokens.square-lg;
|
|
84
|
+
}
|
|
85
|
+
&:where(.btn-xl) {
|
|
86
|
+
@include button-tokens.square-xl;
|
|
87
|
+
}
|
|
88
|
+
&:where(.btn-selected, [aria-pressed='true']) {
|
|
89
|
+
@include button-tokens.square-selected;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
&:is(:active, .active):where(:not(:disabled, .disabled)) {
|
|
93
|
+
@include button-tokens.pressed;
|
|
94
|
+
&:where(.btn-md) {
|
|
95
|
+
@include button-tokens.pressed-md;
|
|
96
|
+
}
|
|
97
|
+
&:where(.btn-lg) {
|
|
98
|
+
@include button-tokens.pressed-lg;
|
|
99
|
+
}
|
|
100
|
+
&:where(.btn-xl) {
|
|
101
|
+
@include button-tokens.pressed-xl;
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
&:is(:disabled, .disabled) {
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
* Copyright 2026 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import { CSSResultOrNative, LitElement } from 'lit';
|
|
6
|
+
import { CSSResultOrNative, LitElement, PropertyValues } from 'lit';
|
|
7
7
|
declare global {
|
|
8
8
|
interface HTMLElementTagNameMap {
|
|
9
9
|
/** A Material Design button. */
|
|
10
10
|
'md-button': Button;
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
-
declare const baseClass: import("@material/web/labs/behaviors/mixin.js").MixinReturn<import("@material/web/labs/behaviors/mixin.js").MixinReturn<import("@material/web/labs/behaviors/mixin.js").MixinReturn<(abstract new (...args: any[]) => import("
|
|
13
|
+
declare const baseClass: import("@material/web/labs/behaviors/mixin.js").MixinReturn<import("@material/web/labs/behaviors/mixin.js").MixinReturn<import("@material/web/labs/behaviors/mixin.js").MixinReturn<(abstract new (...args: any[]) => import("../../../behaviors/element-internals.js").WithElementInternals) & typeof LitElement & import("../../../behaviors/form-associated.js").FormAssociatedConstructor, import("../../../behaviors/form-associated.js").FormAssociated>, import("../../../behaviors/form-submitter.js").FormSubmitter>>;
|
|
14
14
|
/**
|
|
15
15
|
* A Material Design button.
|
|
16
16
|
*/
|
|
@@ -18,6 +18,7 @@ export declare class Button extends baseClass {
|
|
|
18
18
|
/** @nocollapse */
|
|
19
19
|
static shadowRootOptions: ShadowRootInit;
|
|
20
20
|
static styles: CSSResultOrNative[];
|
|
21
|
+
private hideOutline;
|
|
21
22
|
/**
|
|
22
23
|
* The color of the button.
|
|
23
24
|
*/
|
|
@@ -69,7 +70,14 @@ export declare class Button extends baseClass {
|
|
|
69
70
|
* include `_blank` to open in a new tab.
|
|
70
71
|
*/
|
|
71
72
|
target: '_blank' | '_parent' | '_self' | '_top' | '';
|
|
73
|
+
private lastFiredEnabledState?;
|
|
74
|
+
connectedCallback(): void;
|
|
75
|
+
disconnectedCallback(): void;
|
|
76
|
+
private readonly handleSetShowOutline;
|
|
77
|
+
protected updated(changedProperties: PropertyValues): void;
|
|
78
|
+
private dispatchSetEnabledEvent;
|
|
72
79
|
protected render(): import("lit-html").TemplateResult<1>;
|
|
80
|
+
private handleContainerSlotChange;
|
|
73
81
|
private handleChange;
|
|
74
82
|
}
|
|
75
83
|
export {};
|
|
@@ -4,17 +4,18 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import { __decorate } from "tslib";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import focusRingStyles from '
|
|
15
|
-
// import focusRingStyles from '
|
|
16
|
-
import rippleStyles from '
|
|
17
|
-
// import rippleStyles from '
|
|
7
|
+
import { css, html, LitElement, nothing, } from 'lit';
|
|
8
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
|
9
|
+
import { mixinDelegatesAria } from '../../../../internal/aria/delegate.js';
|
|
10
|
+
import { redispatchEvent } from '../../../../internal/events/redispatch-event.js';
|
|
11
|
+
import { mixinElementInternals } from '../../../behaviors/element-internals.js';
|
|
12
|
+
import { mixinFormAssociated } from '../../../behaviors/form-associated.js';
|
|
13
|
+
import { mixinFormSubmitter } from '../../../behaviors/form-submitter.js';
|
|
14
|
+
import focusRingStyles from '../focus/focus-ring.css' with { type: 'css' }; // github-only
|
|
15
|
+
// import focusRingStyles from '../focus/focus-ring.cssresult.js'; // google3-only
|
|
16
|
+
import rippleStyles from '../ripple/ripple.css' with { type: 'css' }; // github-only
|
|
17
|
+
// import rippleStyles from '../ripple/ripple.cssresult.js'; // google3-only
|
|
18
|
+
import { hasSlotted } from '../shared/has-slotted.js';
|
|
18
19
|
import buttonStyles from './button.css' with { type: 'css' }; // github-only
|
|
19
20
|
// import buttonStyles from './button.cssresult.js'; // google3-only
|
|
20
21
|
import { button } from './button.js';
|
|
@@ -26,6 +27,7 @@ const baseClass = mixinDelegatesAria(mixinFormSubmitter(mixinFormAssociated(mixi
|
|
|
26
27
|
let Button = class Button extends baseClass {
|
|
27
28
|
constructor() {
|
|
28
29
|
super(...arguments);
|
|
30
|
+
this.hideOutline = false;
|
|
29
31
|
/**
|
|
30
32
|
* The color of the button.
|
|
31
33
|
*/
|
|
@@ -66,6 +68,10 @@ let Button = class Button extends baseClass {
|
|
|
66
68
|
* include `_blank` to open in a new tab.
|
|
67
69
|
*/
|
|
68
70
|
this.target = '';
|
|
71
|
+
this.handleSetShowOutline = (event) => {
|
|
72
|
+
const customEvent = event;
|
|
73
|
+
this.hideOutline = !customEvent.detail.shown;
|
|
74
|
+
};
|
|
69
75
|
}
|
|
70
76
|
/**
|
|
71
77
|
* A string indicating the behavior of the button.
|
|
@@ -85,6 +91,35 @@ let Button = class Button extends baseClass {
|
|
|
85
91
|
}
|
|
86
92
|
super.type = type;
|
|
87
93
|
}
|
|
94
|
+
connectedCallback() {
|
|
95
|
+
super.connectedCallback();
|
|
96
|
+
this.addEventListener('md-gb:set-show-outline', this.handleSetShowOutline);
|
|
97
|
+
}
|
|
98
|
+
disconnectedCallback() {
|
|
99
|
+
super.disconnectedCallback();
|
|
100
|
+
this.removeEventListener('md-gb:set-show-outline', this.handleSetShowOutline);
|
|
101
|
+
}
|
|
102
|
+
updated(changedProperties) {
|
|
103
|
+
super.updated(changedProperties);
|
|
104
|
+
if (changedProperties.has('disabled') ||
|
|
105
|
+
changedProperties.has('softDisabled')) {
|
|
106
|
+
this.dispatchSetEnabledEvent();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
dispatchSetEnabledEvent() {
|
|
110
|
+
const enabled = !(this.disabled || this.softDisabled);
|
|
111
|
+
if (this.lastFiredEnabledState === enabled)
|
|
112
|
+
return;
|
|
113
|
+
const slot = this.shadowRoot?.querySelector('slot[name="container"]');
|
|
114
|
+
if (slot) {
|
|
115
|
+
for (const element of slot.assignedElements({ flatten: true })) {
|
|
116
|
+
element.dispatchEvent(new CustomEvent('md-gb:set-enabled', {
|
|
117
|
+
detail: { enabled },
|
|
118
|
+
}));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
this.lastFiredEnabledState = enabled;
|
|
122
|
+
}
|
|
88
123
|
render() {
|
|
89
124
|
const classes = button({
|
|
90
125
|
color: this.color,
|
|
@@ -92,6 +127,9 @@ let Button = class Button extends baseClass {
|
|
|
92
127
|
square: this.square,
|
|
93
128
|
// Emulate `:disabled` when soft-disabled
|
|
94
129
|
disabled: this.softDisabled,
|
|
130
|
+
classes: {
|
|
131
|
+
'btn-hide-outline': this.hideOutline,
|
|
132
|
+
},
|
|
95
133
|
});
|
|
96
134
|
// Needed for closure conformance
|
|
97
135
|
const { ariaLabel, ariaHasPopup, ariaExpanded } = this;
|
|
@@ -108,6 +146,10 @@ let Button = class Button extends baseClass {
|
|
|
108
146
|
aria-disabled=${this.disabled || this.softDisabled || nothing}
|
|
109
147
|
tabindex=${this.disabled && !this.softDisabled ? -1 : nothing}>
|
|
110
148
|
<slot></slot>
|
|
149
|
+
<slot
|
|
150
|
+
name="container"
|
|
151
|
+
${hasSlotted()}
|
|
152
|
+
@slotchange=${this.handleContainerSlotChange}></slot>
|
|
111
153
|
</a>`;
|
|
112
154
|
}
|
|
113
155
|
return html `<button
|
|
@@ -121,8 +163,22 @@ let Button = class Button extends baseClass {
|
|
|
121
163
|
aria-expanded=${ariaExpanded || nothing}
|
|
122
164
|
@change=${this.handleChange}>
|
|
123
165
|
<slot></slot>
|
|
166
|
+
<slot
|
|
167
|
+
name="container"
|
|
168
|
+
${hasSlotted()}
|
|
169
|
+
@slotchange=${this.handleContainerSlotChange}></slot>
|
|
124
170
|
</button>`;
|
|
125
171
|
}
|
|
172
|
+
handleContainerSlotChange(event) {
|
|
173
|
+
const slot = event.target;
|
|
174
|
+
const enabled = !(this.disabled || this.softDisabled);
|
|
175
|
+
for (const element of slot.assignedElements({ flatten: true })) {
|
|
176
|
+
element.dispatchEvent(new CustomEvent('md-gb:change-container-slot'));
|
|
177
|
+
element.dispatchEvent(new CustomEvent('md-gb:set-enabled', {
|
|
178
|
+
detail: { enabled },
|
|
179
|
+
}));
|
|
180
|
+
}
|
|
181
|
+
}
|
|
126
182
|
handleChange(event) {
|
|
127
183
|
this.selected = event.target.ariaPressed === 'true';
|
|
128
184
|
redispatchEvent(this, event);
|
|
@@ -140,12 +196,37 @@ Button.styles = [
|
|
|
140
196
|
css `
|
|
141
197
|
:host {
|
|
142
198
|
display: inline-flex;
|
|
199
|
+
isolation: isolate;
|
|
143
200
|
}
|
|
144
201
|
.btn {
|
|
145
202
|
flex: 1;
|
|
203
|
+
position: relative;
|
|
204
|
+
}
|
|
205
|
+
.btn:has([name='container'].has-slotted) {
|
|
206
|
+
background-color: transparent;
|
|
207
|
+
}
|
|
208
|
+
.btn.btn-hide-outline {
|
|
209
|
+
--outline-color: transparent;
|
|
210
|
+
}
|
|
211
|
+
slot[name='container'] {
|
|
212
|
+
display: block;
|
|
213
|
+
position: absolute;
|
|
214
|
+
inset: 0;
|
|
215
|
+
border-radius: inherit;
|
|
216
|
+
pointer-events: none;
|
|
217
|
+
--color: var(--container-color);
|
|
218
|
+
z-index: -1;
|
|
219
|
+
transition: inherit;
|
|
220
|
+
}
|
|
221
|
+
slot[name='container']::slotted(*) {
|
|
222
|
+
width: 100%;
|
|
223
|
+
height: 100%;
|
|
146
224
|
}
|
|
147
225
|
`,
|
|
148
226
|
];
|
|
227
|
+
__decorate([
|
|
228
|
+
state()
|
|
229
|
+
], Button.prototype, "hideOutline", void 0);
|
|
149
230
|
__decorate([
|
|
150
231
|
property()
|
|
151
232
|
], Button.prototype, "color", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"md-button.js","sourceRoot":"","sources":["md-button.ts"],"names":[],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lB,aAAa,CAAC,WAAW,CAAC;GACd,MAAM,CAwIlB","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {ARIAMixinStrict} from '@material/web/internal/aria/aria.js';\nimport {mixinDelegatesAria} from '@material/web/internal/aria/delegate.js';\nimport {redispatchEvent} from '@material/web/internal/events/redispatch-event.js';\nimport {mixinElementInternals} from '@material/web/labs/behaviors/element-internals.js';\nimport {mixinFormAssociated} from '@material/web/labs/behaviors/form-associated.js';\nimport {mixinFormSubmitter} from '@material/web/labs/behaviors/form-submitter.js';\nimport {css, CSSResultOrNative, html, LitElement, nothing} from 'lit';\nimport {customElement, property} from 'lit/decorators.js';\n\nimport focusRingStyles from '@material/web/labs/gb/components/focus/focus-ring.css' with {type: 'css'}; // github-only\n// import focusRingStyles from '@material/web/labs/gb/components/focus/focus-ring.cssresult.js'; // google3-only\nimport rippleStyles from '@material/web/labs/gb/components/ripple/ripple.css' with {type: 'css'}; // github-only\n// import rippleStyles from '@material/web/labs/gb/components/ripple/ripple.cssresult.js'; // google3-only\nimport buttonStyles from './button.css' with {type: 'css'}; // github-only\n// import buttonStyles from './button.cssresult.js'; // google3-only\n\nimport {button} from './button.js';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n /** A Material Design button. */\n 'md-button': Button;\n }\n}\n\n// Separate variable needed for closure.\nconst baseClass = mixinDelegatesAria(\n mixinFormSubmitter(mixinFormAssociated(mixinElementInternals(LitElement))),\n);\n\n/**\n * A Material Design button.\n */\n@customElement('md-button')\nexport class Button extends baseClass {\n /** @nocollapse */\n static override shadowRootOptions: ShadowRootInit = {\n mode: 'open',\n delegatesFocus: true,\n };\n\n static override styles: CSSResultOrNative[] = [\n focusRingStyles,\n rippleStyles,\n buttonStyles,\n css`\n :host {\n display: inline-flex;\n }\n .btn {\n flex: 1;\n }\n `,\n ];\n\n /**\n * The color of the button.\n */\n @property()\n color: 'filled' | 'elevated' | 'tonal' | 'outlined' | 'text' = 'text';\n\n /**\n * The size of the button.\n */\n @property() size: 'xs' | 'sm' | 'md' | 'lg' | 'xl' = 'sm';\n\n /**\n * Changes the shape of the button to be square.\n */\n @property({type: Boolean}) square = false;\n\n /**\n * A string indicating the behavior of the button.\n *\n * - \"submit\" (default): A button that submits its associated form.\n * - \"reset\": A button that resets its associated form.\n * - \"button\": A normal button.\n * - \"toggle\": A toggle button using the `selected` property.\n * - \"link\": An anchor link (`<a>`). Type is always \"link\" when `href` is set.\n */\n @property({noAccessor: true})\n override get type(): string {\n return this.href ? 'link' : super.type;\n }\n override set type(type: string) {\n if (this.href && type !== 'link') {\n return;\n }\n super.type = type;\n }\n\n /**\n * Whether or not the button is \"soft-disabled\" (disabled but still\n * focusable).\n *\n * Use this when a button needs increased visibility when disabled. See\n * https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_disabled_controls\n * for more guidance on when this is needed.\n */\n @property({type: Boolean, attribute: 'soft-disabled', reflect: true})\n softDisabled = false;\n\n /**\n * Whether or not the button is selected, when `type=\"toggle\"`.\n */\n @property({type: Boolean}) selected = false;\n\n /**\n * The URL that the link button points to.\n */\n @property() href = '';\n\n /**\n * The filename to use when downloading the linked resource.\n * If not specified, the browser will determine a filename.\n * This is only applicable when the button is used as a link (`href` is set).\n */\n @property() download = '';\n\n /**\n * Where to display the linked `href` URL for a link button. Common options\n * include `_blank` to open in a new tab.\n */\n @property() target: '_blank' | '_parent' | '_self' | '_top' | '' = '';\n\n protected override render() {\n const classes = button({\n color: this.color,\n size: this.size,\n square: this.square,\n // Emulate `:disabled` when soft-disabled\n disabled: this.softDisabled,\n });\n\n // Needed for closure conformance\n const {ariaLabel, ariaHasPopup, ariaExpanded} = this as ARIAMixinStrict;\n if (this.type === 'link') {\n return html`<a\n part=\"btn\"\n class=${classes}\n href=${this.href}\n download=${this.download || nothing}\n target=${this.target || nothing}\n aria-label=${ariaLabel || nothing}\n aria-haspopup=${ariaHasPopup || nothing}\n aria-expanded=${ariaExpanded || nothing}\n aria-disabled=${this.disabled || this.softDisabled || nothing}\n tabindex=${this.disabled && !this.softDisabled ? -1 : nothing}>\n <slot></slot>\n </a>`;\n }\n\n return html`<button\n part=\"btn\"\n class=${classes}\n ?disabled=${this.disabled}\n aria-disabled=${this.softDisabled || nothing}\n aria-label=${ariaLabel || nothing}\n aria-pressed=${this.type === 'toggle' ? this.selected : nothing}\n aria-haspopup=${ariaHasPopup || nothing}\n aria-expanded=${ariaExpanded || nothing}\n @change=${this.handleChange}>\n <slot></slot>\n </button>`;\n }\n\n private handleChange(event: Event) {\n this.selected = (event.target as HTMLElement).ariaPressed === 'true';\n redispatchEvent(this, event);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"md-button.js","sourceRoot":"","sources":["md-button.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EACL,GAAG,EAEH,IAAI,EACJ,UAAU,EACV,OAAO,GAER,MAAM,KAAK,CAAC;AACb,OAAO,EAAC,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAC,MAAM,mBAAmB,CAAC;AAEjE,OAAO,EAAC,kBAAkB,EAAC,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAC,eAAe,EAAC,MAAM,iDAAiD,CAAC;AAChF,OAAO,EAAC,qBAAqB,EAAC,MAAM,yCAAyC,CAAC;AAC9E,OAAO,EAAC,mBAAmB,EAAC,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAC,kBAAkB,EAAC,MAAM,sCAAsC,CAAC;AAExE,OAAO,eAAe,MAAM,yBAAyB,CAAC,OAAM,IAAI,EAAE,KAAK,EAAC,CAAC,CAAC,cAAc;AACxF,kFAAkF;AAClF,OAAO,YAAY,MAAM,sBAAsB,CAAC,OAAM,IAAI,EAAE,KAAK,EAAC,CAAC,CAAC,cAAc;AAClF,4EAA4E;AAE5E,OAAO,EAAC,UAAU,EAAC,MAAM,0BAA0B,CAAC;AAEpD,OAAO,YAAY,MAAM,cAAc,CAAC,OAAM,IAA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AC,CAAC;wCAAkB;AAKhC;IAAX,QAAQ,EAAE;oCAAW;AAOV;IAAX,QAAQ,EAAE;wCAAe;AAMd;IAAX,QAAQ,EAAE;sCAA2D;AAjH3D,MAAM;IADlB,aAAa,CAAC,WAAW,CAAC;GACd,MAAM,CA4OlB","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n css,\n CSSResultOrNative,\n html,\n LitElement,\n nothing,\n PropertyValues,\n} from 'lit';\nimport {customElement, property, state} from 'lit/decorators.js';\nimport {ARIAMixinStrict} from '../../../../internal/aria/aria.js';\nimport {mixinDelegatesAria} from '../../../../internal/aria/delegate.js';\nimport {redispatchEvent} from '../../../../internal/events/redispatch-event.js';\nimport {mixinElementInternals} from '../../../behaviors/element-internals.js';\nimport {mixinFormAssociated} from '../../../behaviors/form-associated.js';\nimport {mixinFormSubmitter} from '../../../behaviors/form-submitter.js';\n\nimport focusRingStyles from '../focus/focus-ring.css' with {type: 'css'}; // github-only\n// import focusRingStyles from '../focus/focus-ring.cssresult.js'; // google3-only\nimport rippleStyles from '../ripple/ripple.css' with {type: 'css'}; // github-only\n// import rippleStyles from '../ripple/ripple.cssresult.js'; // google3-only\n\nimport {hasSlotted} from '../shared/has-slotted.js';\n\nimport buttonStyles from './button.css' with {type: 'css'}; // github-only\n// import buttonStyles from './button.cssresult.js'; // google3-only\n\nimport {button} from './button.js';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n /** A Material Design button. */\n 'md-button': Button;\n }\n}\n\n// Separate variable needed for closure.\nconst baseClass = mixinDelegatesAria(\n mixinFormSubmitter(mixinFormAssociated(mixinElementInternals(LitElement))),\n);\n\n/**\n * A Material Design button.\n */\n@customElement('md-button')\nexport class Button extends baseClass {\n /** @nocollapse */\n static override shadowRootOptions: ShadowRootInit = {\n mode: 'open',\n delegatesFocus: true,\n };\n\n static override styles: CSSResultOrNative[] = [\n focusRingStyles,\n rippleStyles,\n buttonStyles,\n css`\n :host {\n display: inline-flex;\n isolation: isolate;\n }\n .btn {\n flex: 1;\n position: relative;\n }\n .btn:has([name='container'].has-slotted) {\n background-color: transparent;\n }\n .btn.btn-hide-outline {\n --outline-color: transparent;\n }\n slot[name='container'] {\n display: block;\n position: absolute;\n inset: 0;\n border-radius: inherit;\n pointer-events: none;\n --color: var(--container-color);\n z-index: -1;\n transition: inherit;\n }\n slot[name='container']::slotted(*) {\n width: 100%;\n height: 100%;\n }\n `,\n ];\n\n @state() private hideOutline = false;\n\n /**\n * The color of the button.\n */\n @property()\n color: 'filled' | 'elevated' | 'tonal' | 'outlined' | 'text' = 'text';\n\n /**\n * The size of the button.\n */\n @property() size: 'xs' | 'sm' | 'md' | 'lg' | 'xl' = 'sm';\n\n /**\n * Changes the shape of the button to be square.\n */\n @property({type: Boolean}) square = false;\n\n /**\n * A string indicating the behavior of the button.\n *\n * - \"submit\" (default): A button that submits its associated form.\n * - \"reset\": A button that resets its associated form.\n * - \"button\": A normal button.\n * - \"toggle\": A toggle button using the `selected` property.\n * - \"link\": An anchor link (`<a>`). Type is always \"link\" when `href` is set.\n */\n @property({noAccessor: true})\n override get type(): string {\n return this.href ? 'link' : super.type;\n }\n override set type(type: string) {\n if (this.href && type !== 'link') {\n return;\n }\n super.type = type;\n }\n\n /**\n * Whether or not the button is \"soft-disabled\" (disabled but still\n * focusable).\n *\n * Use this when a button needs increased visibility when disabled. See\n * https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_disabled_controls\n * for more guidance on when this is needed.\n */\n @property({type: Boolean, attribute: 'soft-disabled', reflect: true})\n softDisabled = false;\n\n /**\n * Whether or not the button is selected, when `type=\"toggle\"`.\n */\n @property({type: Boolean}) selected = false;\n\n /**\n * The URL that the link button points to.\n */\n @property() href = '';\n\n /**\n * The filename to use when downloading the linked resource.\n * If not specified, the browser will determine a filename.\n * This is only applicable when the button is used as a link (`href` is set).\n */\n @property() download = '';\n\n /**\n * Where to display the linked `href` URL for a link button. Common options\n * include `_blank` to open in a new tab.\n */\n @property() target: '_blank' | '_parent' | '_self' | '_top' | '' = '';\n\n private lastFiredEnabledState?: boolean;\n\n override connectedCallback() {\n super.connectedCallback();\n this.addEventListener('md-gb:set-show-outline', this.handleSetShowOutline);\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n this.removeEventListener(\n 'md-gb:set-show-outline',\n this.handleSetShowOutline,\n );\n }\n\n private readonly handleSetShowOutline = (event: Event) => {\n const customEvent = event as CustomEvent<{shown: boolean}>;\n this.hideOutline = !customEvent.detail.shown;\n };\n\n protected override updated(changedProperties: PropertyValues) {\n super.updated(changedProperties);\n if (\n changedProperties.has('disabled') ||\n changedProperties.has('softDisabled')\n ) {\n this.dispatchSetEnabledEvent();\n }\n }\n\n private dispatchSetEnabledEvent() {\n const enabled = !(this.disabled || this.softDisabled);\n\n if (this.lastFiredEnabledState === enabled) return;\n\n const slot = this.shadowRoot?.querySelector(\n 'slot[name=\"container\"]',\n ) as HTMLSlotElement;\n if (slot) {\n for (const element of slot.assignedElements({flatten: true})) {\n element.dispatchEvent(\n new CustomEvent('md-gb:set-enabled', {\n detail: {enabled},\n }),\n );\n }\n }\n this.lastFiredEnabledState = enabled;\n }\n\n protected override render() {\n const classes = button({\n color: this.color,\n size: this.size,\n square: this.square,\n // Emulate `:disabled` when soft-disabled\n disabled: this.softDisabled,\n classes: {\n 'btn-hide-outline': this.hideOutline,\n },\n });\n\n // Needed for closure conformance\n const {ariaLabel, ariaHasPopup, ariaExpanded} = this as ARIAMixinStrict;\n if (this.type === 'link') {\n return html`<a\n part=\"btn\"\n class=${classes}\n href=${this.href}\n download=${this.download || nothing}\n target=${this.target || nothing}\n aria-label=${ariaLabel || nothing}\n aria-haspopup=${ariaHasPopup || nothing}\n aria-expanded=${ariaExpanded || nothing}\n aria-disabled=${this.disabled || this.softDisabled || nothing}\n tabindex=${this.disabled && !this.softDisabled ? -1 : nothing}>\n <slot></slot>\n <slot\n name=\"container\"\n ${hasSlotted()}\n @slotchange=${this.handleContainerSlotChange}></slot>\n </a>`;\n }\n\n return html`<button\n part=\"btn\"\n class=${classes}\n ?disabled=${this.disabled}\n aria-disabled=${this.softDisabled || nothing}\n aria-label=${ariaLabel || nothing}\n aria-pressed=${this.type === 'toggle' ? this.selected : nothing}\n aria-haspopup=${ariaHasPopup || nothing}\n aria-expanded=${ariaExpanded || nothing}\n @change=${this.handleChange}>\n <slot></slot>\n <slot\n name=\"container\"\n ${hasSlotted()}\n @slotchange=${this.handleContainerSlotChange}></slot>\n </button>`;\n }\n\n private handleContainerSlotChange(event: Event) {\n const slot = event.target as HTMLSlotElement;\n\n const enabled = !(this.disabled || this.softDisabled);\n\n for (const element of slot.assignedElements({flatten: true})) {\n element.dispatchEvent(new CustomEvent('md-gb:change-container-slot'));\n element.dispatchEvent(\n new CustomEvent('md-gb:set-enabled', {\n detail: {enabled},\n }),\n );\n }\n }\n\n private handleChange(event: Event) {\n this.selected = (event.target as HTMLElement).ariaPressed === 'true';\n redispatchEvent(this, event);\n }\n}\n"]}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* Copyright 2026 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import { Directive } from 'lit/directive.js';
|
|
7
6
|
import { type ClassInfo } from 'lit/directives/class-map.js';
|
|
8
7
|
/** Card color configuration types. */
|
|
9
8
|
export type CardColor = 'elevated' | 'filled' | 'outlined';
|
|
@@ -43,14 +42,6 @@ export interface CardClassesState {
|
|
|
43
42
|
* @return An object of class names and truthy values if they apply.
|
|
44
43
|
*/
|
|
45
44
|
export declare function cardClasses({ color, interactive, hover, focus, disabled, }?: CardClassesState): ClassInfo;
|
|
46
|
-
/** The state provided to the `card()` directive. */
|
|
47
|
-
export interface CardDirectiveState extends CardClassesState {
|
|
48
|
-
/** Additional classes to apply to the element. */
|
|
49
|
-
classes?: ClassInfo;
|
|
50
|
-
}
|
|
51
|
-
declare class CardDirective extends Directive {
|
|
52
|
-
render(state?: CardDirectiveState): import("lit-html/directive.js").DirectiveResult<typeof import("lit-html/directives/class-map.js").ClassMapDirective>;
|
|
53
|
-
}
|
|
54
45
|
/**
|
|
55
46
|
* A Lit directive that adds card styling and functionality to its element.
|
|
56
47
|
*
|
|
@@ -63,5 +54,4 @@ declare class CardDirective extends Directive {
|
|
|
63
54
|
* `
|
|
64
55
|
* ```
|
|
65
56
|
*/
|
|
66
|
-
export declare const card: (state?:
|
|
67
|
-
export {};
|
|
57
|
+
export declare const card: (state?: CardClassesState & import("../shared/directives.js").AdditionalClasses) => import("lit-html/directive.js").DirectiveResult;
|
|
@@ -3,10 +3,9 @@
|
|
|
3
3
|
* Copyright 2026 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import { FOCUS_RING_CLASSES } from '
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { classMap } from 'lit/directives/class-map.js';
|
|
6
|
+
import { FOCUS_RING_CLASSES } from '../focus/focus-ring.js';
|
|
7
|
+
import { createClassMapDirective } from '../shared/directives.js';
|
|
8
|
+
import { PSEUDO_CLASSES } from '../shared/pseudo-classes.js';
|
|
10
9
|
/** Card color configurations. */
|
|
11
10
|
export const CARD_COLORS = {
|
|
12
11
|
elevated: 'elevated',
|
|
@@ -41,14 +40,6 @@ export function cardClasses({ color, interactive = false, hover = false, focus =
|
|
|
41
40
|
[CARD_CLASSES.disabled]: disabled,
|
|
42
41
|
};
|
|
43
42
|
}
|
|
44
|
-
class CardDirective extends Directive {
|
|
45
|
-
render(state = {}) {
|
|
46
|
-
return classMap({
|
|
47
|
-
...(state.classes || {}),
|
|
48
|
-
...cardClasses(state),
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
43
|
/**
|
|
53
44
|
* A Lit directive that adds card styling and functionality to its element.
|
|
54
45
|
*
|
|
@@ -61,5 +52,7 @@ class CardDirective extends Directive {
|
|
|
61
52
|
* `
|
|
62
53
|
* ```
|
|
63
54
|
*/
|
|
64
|
-
export const card =
|
|
55
|
+
export const card = createClassMapDirective({
|
|
56
|
+
getClasses: cardClasses,
|
|
57
|
+
});
|
|
65
58
|
//# sourceMappingURL=card.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card.js","sourceRoot":"","sources":["card.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"card.js","sourceRoot":"","sources":["card.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAC,kBAAkB,EAAC,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAC,uBAAuB,EAAC,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAC,cAAc,EAAC,MAAM,6BAA6B,CAAC;AAK3D,iCAAiC;AACjC,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;CACZ,CAAC;AAEX,oBAAoB;AACpB,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,MAAM;IACZ,YAAY,EAAE,eAAe;IAC7B,UAAU,EAAE,aAAa;IACzB,YAAY,EAAE,eAAe;IAC7B,KAAK,EAAE,cAAc,CAAC,KAAK;IAC3B,KAAK,EAAE,cAAc,CAAC,KAAK;IAC3B,QAAQ,EAAE,cAAc,CAAC,QAAQ;CACzB,CAAC;AAgBX;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,EAC1B,KAAK,EACL,WAAW,GAAG,KAAK,EACnB,KAAK,GAAG,KAAK,EACb,KAAK,GAAG,KAAK,EACb,QAAQ,GAAG,KAAK,MACI,EAAE;IACtB,OAAO;QACL,CAAC,kBAAkB,CAAC,cAAc,CAAC,EAAE,WAAW;QAChD,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,IAAI;QACzB,CAAC,YAAY,CAAC,YAAY,CAAC,EAAE,KAAK,KAAK,WAAW,CAAC,QAAQ;QAC3D,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,KAAK,KAAK,WAAW,CAAC,MAAM;QACvD,CAAC,YAAY,CAAC,YAAY,CAAC,EAAE,KAAK,KAAK,WAAW,CAAC,QAAQ,IAAI,CAAC,KAAK;QACrE,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,KAAK;QAC3B,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,KAAK;QAC3B,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,QAAQ;KAClC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,uBAAuB,CAAC;IAC1C,UAAU,EAAE,WAAW;CACxB,CAAC,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 {FOCUS_RING_CLASSES} from '../focus/focus-ring.js';\nimport {createClassMapDirective} from '../shared/directives.js';\nimport {PSEUDO_CLASSES} from '../shared/pseudo-classes.js';\n\n/** Card color configuration types. */\nexport type CardColor = 'elevated' | 'filled' | 'outlined';\n\n/** Card color configurations. */\nexport const CARD_COLORS = {\n elevated: 'elevated',\n filled: 'filled',\n outlined: 'outlined',\n} as const;\n\n/** Card classes. */\nexport const CARD_CLASSES = {\n card: 'card',\n cardElevated: 'card-elevated',\n cardFilled: 'card-filled',\n cardOutlined: 'card-outlined',\n hover: PSEUDO_CLASSES.hover,\n focus: PSEUDO_CLASSES.focus,\n disabled: PSEUDO_CLASSES.disabled,\n} as const;\n\n/** The state provided to the `cardClasses()` function. */\nexport interface CardClassesState {\n /** The color of the card. */\n color?: CardColor;\n /** Whether the card is interactive. */\n interactive?: boolean;\n /** Emulates `:hover`. */\n hover?: boolean;\n /** Emulates `:focus`. */\n focus?: boolean;\n /** Emulates `:disabled`. */\n disabled?: boolean;\n}\n\n/**\n * Returns the card classes to apply to an element based on the given state.\n *\n * @param state The state of the card.\n * @return An object of class names and truthy values if they apply.\n */\nexport function cardClasses({\n color,\n interactive = false,\n hover = false,\n focus = false,\n disabled = false,\n}: CardClassesState = {}): ClassInfo {\n return {\n [FOCUS_RING_CLASSES.focusRingOuter]: interactive,\n [CARD_CLASSES.card]: true,\n [CARD_CLASSES.cardElevated]: color === CARD_COLORS.elevated,\n [CARD_CLASSES.cardFilled]: color === CARD_COLORS.filled,\n [CARD_CLASSES.cardOutlined]: color === CARD_COLORS.outlined || !color,\n [CARD_CLASSES.hover]: hover,\n [CARD_CLASSES.focus]: focus,\n [CARD_CLASSES.disabled]: disabled,\n };\n}\n\n/**\n * A Lit directive that adds card styling and functionality to its element.\n *\n * @example\n * ```ts\n * html`\n * <div class=\"${card({color: 'filled'})} flex flex-row p-4\">\n * Card content\n * </div>\n * `\n * ```\n */\nexport const card = createClassMapDirective({\n getClasses: cardClasses,\n});\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 } from 'lit';
|
|
6
|
+
import { CSSResultOrNative, LitElement, PropertyValues } from 'lit';
|
|
7
7
|
import { type CardColor } from './card.js';
|
|
8
8
|
declare global {
|
|
9
9
|
interface HTMLElementTagNameMap {
|
|
@@ -19,12 +19,20 @@ export declare class Card extends baseClass {
|
|
|
19
19
|
/** @nocollapse */
|
|
20
20
|
static shadowRootOptions: ShadowRootInit;
|
|
21
21
|
static styles: CSSResultOrNative[];
|
|
22
|
+
private hideOutline;
|
|
23
|
+
private lastFiredEnabledState?;
|
|
22
24
|
/** The color of the card. */
|
|
23
25
|
color: CardColor;
|
|
24
26
|
/** Whether the card is disabled. */
|
|
25
27
|
disabled: boolean;
|
|
26
28
|
/** Whether the card is interactive. */
|
|
27
29
|
interactive: boolean;
|
|
30
|
+
connectedCallback(): void;
|
|
31
|
+
disconnectedCallback(): void;
|
|
32
|
+
private readonly handleSetShowOutline;
|
|
33
|
+
protected updated(changedProperties: PropertyValues): void;
|
|
34
|
+
private dispatchSetEnabledEvent;
|
|
28
35
|
protected render(): import("lit-html").TemplateResult<1>;
|
|
36
|
+
private handleContainerSlotChange;
|
|
29
37
|
}
|
|
30
38
|
export {};
|