@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,448 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { __decorate } from "tslib";
|
|
7
|
+
import { css, html, LitElement, nothing } from 'lit';
|
|
8
|
+
import { property, state } from 'lit/decorators.js';
|
|
9
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
10
|
+
import { button } from '../button/button.js';
|
|
11
|
+
import { iconButton } from '../iconbutton/icon-button.js';
|
|
12
|
+
import { hasSlotted } from '../shared/has-slotted.js';
|
|
13
|
+
import { CLOSE_REASONS, snackbarClasses } from './snackbar.js';
|
|
14
|
+
import buttonStyles from '../button/button.css' with { type: 'css' }; // github-only
|
|
15
|
+
// import buttonStyles from '../button/button.cssresult.js'; // google3-only
|
|
16
|
+
import focusRingStyles from '../focus/focus-ring.css' with { type: 'css' }; // github-only
|
|
17
|
+
// import focusRingStyles from '../focus/focus-ring.cssresult.js'; // google3-only
|
|
18
|
+
import iconButtonStyles from '../iconbutton/icon-button.css' with { type: 'css' }; // github-only
|
|
19
|
+
// import iconButtonStyles from '../iconbutton/icon-button.cssresult.js'; // google3-only
|
|
20
|
+
import rippleStyles from '../ripple/ripple.css' with { type: 'css' }; // github-only
|
|
21
|
+
// import rippleStyles from '../ripple/ripple.cssresult.js'; // google3-only
|
|
22
|
+
import snackbarStyles from './snackbar.css' with { type: 'css' }; // github-only
|
|
23
|
+
// import snackbarStyles from './snackbar.cssresult.js'; // google3-only
|
|
24
|
+
/**
|
|
25
|
+
* Animation duration for snackbar appearance in milliseconds.
|
|
26
|
+
*/
|
|
27
|
+
export const OPEN_DURATION_MS = 150;
|
|
28
|
+
/**
|
|
29
|
+
* Animation duration for snackbar disappearance in milliseconds.
|
|
30
|
+
*/
|
|
31
|
+
export const CLOSE_DURATION_MS = 75;
|
|
32
|
+
/**
|
|
33
|
+
* A Material Design snackbar component.
|
|
34
|
+
*
|
|
35
|
+
* @fires {Event} open - Fired when the snackbar begins opening.
|
|
36
|
+
* @fires {Event} opened - Fired when the snackbar has opened and animations finished.
|
|
37
|
+
* @fires {CustomEvent<{reason: string}>} close - Fired when the snackbar begins closing.
|
|
38
|
+
* @fires {CustomEvent<{reason: string}>} closed - Fired when the snackbar has closed.
|
|
39
|
+
* @slot - Default slot for rich content (rendered after `label-text`). If both `label-text` and slotted content are provided, both render.
|
|
40
|
+
* @slot action - Slot for a custom action button; replaces the built-in action rendered from `action-label`. Prefer the `action-label` attribute, which renders a text button matching the spec. A slotted plain `<button>` is styled by the snackbar, with hover, focus and pressed states. A slotted text `<md-gb-button>` gets the `--action-label-text*` colors and typography, but keeps its own 16px padding and pressed shape, because its component tokens can't be set from outside its shadow root.
|
|
41
|
+
* @slot dismiss - Slot for dismiss button (falls back to close icon button when `has-close-button` is set).
|
|
42
|
+
* @csspart surface - The surface container of the snackbar.
|
|
43
|
+
* @csspart label - The container wrapping the label content.
|
|
44
|
+
* @csspart actions - The container wrapping action and dismiss slots.
|
|
45
|
+
* @cssprop --action-label-text-color - Action button label text color.
|
|
46
|
+
* @cssprop --action-label-text - Action button label typography.
|
|
47
|
+
* @cssprop --action-label-text-axes - Action button label typography font variation settings.
|
|
48
|
+
* @cssprop --action-label-text-tracking - Action button label letter spacing.
|
|
49
|
+
* @cssprop --container-color - Container background color.
|
|
50
|
+
* @cssprop --container-elevation - Container box shadow elevation.
|
|
51
|
+
* @cssprop --container-shape - Container border radius.
|
|
52
|
+
* @cssprop --icon-color - Close icon color.
|
|
53
|
+
* @cssprop --icon-size - Close icon size.
|
|
54
|
+
* @cssprop --supporting-text - Supporting label typography.
|
|
55
|
+
* @cssprop --supporting-text-axes - Supporting label typography font variation settings.
|
|
56
|
+
* @cssprop --supporting-text-color - Supporting label text color.
|
|
57
|
+
* @cssprop --supporting-text-tracking - Supporting label letter spacing.
|
|
58
|
+
* @cssprop --min-width - Minimum surface width in wide layout.
|
|
59
|
+
* @cssprop --max-width - Maximum surface width in wide layout.
|
|
60
|
+
* @cssprop --min-height - Minimum surface height.
|
|
61
|
+
* @cssprop --bottom-offset - Inset block end distance from container bottom.
|
|
62
|
+
* @cssprop --position - CSS position property (`absolute` by default).
|
|
63
|
+
* @cssprop --z-index - Z-index of the snackbar.
|
|
64
|
+
*/
|
|
65
|
+
export class SnackbarElement extends LitElement {
|
|
66
|
+
constructor() {
|
|
67
|
+
super(...arguments);
|
|
68
|
+
this.isOpenInternal = false;
|
|
69
|
+
/**
|
|
70
|
+
* Time in milliseconds before the snackbar automatically dismisses.
|
|
71
|
+
* Set to 0 or a negative value (e.g. -1) to disable auto-dismiss. Read when
|
|
72
|
+
* the snackbar opens; changing it while open takes effect on the next open.
|
|
73
|
+
*/
|
|
74
|
+
this.timeoutMs = 5000;
|
|
75
|
+
/**
|
|
76
|
+
* Whether the snackbar should be positioned relative to the viewport (fixed).
|
|
77
|
+
*/
|
|
78
|
+
this.fixed = false;
|
|
79
|
+
/**
|
|
80
|
+
* Accessible label for the built-in dismiss button.
|
|
81
|
+
*/
|
|
82
|
+
this.closeLabel = 'Close';
|
|
83
|
+
/**
|
|
84
|
+
* Supporting message text to display. Rendered before default slot content.
|
|
85
|
+
*/
|
|
86
|
+
this.labelText = '';
|
|
87
|
+
/**
|
|
88
|
+
* Visible text of the built-in action button. Rendered only when non-empty
|
|
89
|
+
* and nothing is slotted into `action`.
|
|
90
|
+
*/
|
|
91
|
+
this.actionLabel = '';
|
|
92
|
+
/**
|
|
93
|
+
* Whether to display a close icon button.
|
|
94
|
+
*/
|
|
95
|
+
this.hasCloseButton = false;
|
|
96
|
+
/**
|
|
97
|
+
* Whether to skip opening and closing transition delays.
|
|
98
|
+
*/
|
|
99
|
+
this.quick = false;
|
|
100
|
+
this.isOpening = false;
|
|
101
|
+
this.isClosing = false;
|
|
102
|
+
this.isHovered = false;
|
|
103
|
+
this.isFocused = false;
|
|
104
|
+
this.isPaused = false;
|
|
105
|
+
this.autoDismissTimerId = null;
|
|
106
|
+
this.remainingTimeMs = 0;
|
|
107
|
+
this.timerStartTime = 0;
|
|
108
|
+
this.transitionCounter = 0;
|
|
109
|
+
this.handleMouseEnter = () => {
|
|
110
|
+
this.isHovered = true;
|
|
111
|
+
this.pauseAutoDismissTimer();
|
|
112
|
+
};
|
|
113
|
+
this.handleMouseLeave = () => {
|
|
114
|
+
this.isHovered = false;
|
|
115
|
+
if (!this.isFocused) {
|
|
116
|
+
this.resumeAutoDismissTimer();
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
this.handleFocusIn = () => {
|
|
120
|
+
this.isFocused = true;
|
|
121
|
+
this.pauseAutoDismissTimer();
|
|
122
|
+
};
|
|
123
|
+
this.handleFocusOut = () => {
|
|
124
|
+
this.isFocused = false;
|
|
125
|
+
if (!this.isHovered) {
|
|
126
|
+
this.resumeAutoDismissTimer();
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
this.handleKeyDown = (event) => {
|
|
130
|
+
if (event.key === 'Escape' && this.isOpenInternal) {
|
|
131
|
+
event.preventDefault();
|
|
132
|
+
this.close(CLOSE_REASONS.DISMISS);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
this.handleClick = (event) => {
|
|
136
|
+
const path = event.composedPath();
|
|
137
|
+
for (const target of path) {
|
|
138
|
+
if (!(target instanceof HTMLElement))
|
|
139
|
+
continue;
|
|
140
|
+
if (target.getAttribute('slot') === 'action' ||
|
|
141
|
+
target.classList.contains('snackbar-action')) {
|
|
142
|
+
this.close(CLOSE_REASONS.ACTION);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
if (target.getAttribute('slot') === 'dismiss' ||
|
|
146
|
+
target.classList.contains('snackbar-dismiss')) {
|
|
147
|
+
this.close(CLOSE_REASONS.DISMISS);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
this.handleDismissClick = (event) => {
|
|
153
|
+
event.stopPropagation();
|
|
154
|
+
this.close(CLOSE_REASONS.DISMISS);
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Whether the snackbar is currently open.
|
|
159
|
+
*/
|
|
160
|
+
get open() {
|
|
161
|
+
return this.isOpenInternal;
|
|
162
|
+
}
|
|
163
|
+
set open(value) {
|
|
164
|
+
if (value === this.isOpenInternal) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
if (value) {
|
|
168
|
+
this.show();
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
this.close(CLOSE_REASONS.DISMISS);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
connectedCallback() {
|
|
175
|
+
super.connectedCallback();
|
|
176
|
+
this.addEventListener('mouseenter', this.handleMouseEnter);
|
|
177
|
+
this.addEventListener('mouseleave', this.handleMouseLeave);
|
|
178
|
+
this.addEventListener('focusin', this.handleFocusIn);
|
|
179
|
+
this.addEventListener('focusout', this.handleFocusOut);
|
|
180
|
+
this.addEventListener('keydown', this.handleKeyDown);
|
|
181
|
+
this.addEventListener('click', this.handleClick);
|
|
182
|
+
if (this.open && !this.isOpening && !this.isClosing) {
|
|
183
|
+
this.startAutoDismissTimer();
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
disconnectedCallback() {
|
|
187
|
+
super.disconnectedCallback();
|
|
188
|
+
this.removeEventListener('mouseenter', this.handleMouseEnter);
|
|
189
|
+
this.removeEventListener('mouseleave', this.handleMouseLeave);
|
|
190
|
+
this.removeEventListener('focusin', this.handleFocusIn);
|
|
191
|
+
this.removeEventListener('focusout', this.handleFocusOut);
|
|
192
|
+
this.removeEventListener('keydown', this.handleKeyDown);
|
|
193
|
+
this.removeEventListener('click', this.handleClick);
|
|
194
|
+
this.clearAutoDismissTimer();
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Opens the snackbar.
|
|
198
|
+
*/
|
|
199
|
+
async show() {
|
|
200
|
+
if (this.isOpenInternal && !this.isClosing) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
const preventOpen = !this.dispatchEvent(new Event('open', { bubbles: true, cancelable: true }));
|
|
204
|
+
if (preventOpen) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
const token = ++this.transitionCounter;
|
|
208
|
+
this.clearAutoDismissTimer();
|
|
209
|
+
this.isHovered = false;
|
|
210
|
+
this.isFocused = false;
|
|
211
|
+
this.isPaused = false;
|
|
212
|
+
const prev = this.isOpenInternal;
|
|
213
|
+
this.isOpenInternal = true;
|
|
214
|
+
this.requestUpdate('open', prev);
|
|
215
|
+
this.isClosing = false;
|
|
216
|
+
this.isOpening = true;
|
|
217
|
+
this.requestUpdate();
|
|
218
|
+
await this.updateComplete;
|
|
219
|
+
if (token !== this.transitionCounter) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
await this.waitForAnimation(OPEN_DURATION_MS);
|
|
223
|
+
if (token !== this.transitionCounter) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
this.isOpening = false;
|
|
227
|
+
this.requestUpdate();
|
|
228
|
+
this.dispatchEvent(new Event('opened', { bubbles: true }));
|
|
229
|
+
if (!this.isConnected) {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
this.startAutoDismissTimer();
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Closes the snackbar.
|
|
236
|
+
*
|
|
237
|
+
* @param reason The reason for closing (e.g. 'action', 'dismiss', 'timeout').
|
|
238
|
+
*/
|
|
239
|
+
async close(reason = CLOSE_REASONS.DISMISS) {
|
|
240
|
+
if (!this.isOpenInternal && !this.isOpening) {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
const preventClose = !this.dispatchEvent(new CustomEvent('close', {
|
|
244
|
+
bubbles: true,
|
|
245
|
+
cancelable: true,
|
|
246
|
+
detail: { reason },
|
|
247
|
+
}));
|
|
248
|
+
if (preventClose) {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
const token = ++this.transitionCounter;
|
|
252
|
+
this.clearAutoDismissTimer();
|
|
253
|
+
this.isHovered = false;
|
|
254
|
+
this.isFocused = false;
|
|
255
|
+
this.isPaused = false;
|
|
256
|
+
const prev = this.isOpenInternal;
|
|
257
|
+
this.isOpenInternal = false;
|
|
258
|
+
this.requestUpdate('open', prev);
|
|
259
|
+
this.isOpening = false;
|
|
260
|
+
this.isClosing = true;
|
|
261
|
+
this.requestUpdate();
|
|
262
|
+
await this.updateComplete;
|
|
263
|
+
if (token !== this.transitionCounter) {
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
await this.waitForAnimation(CLOSE_DURATION_MS);
|
|
267
|
+
if (token !== this.transitionCounter) {
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
this.isClosing = false;
|
|
271
|
+
this.requestUpdate();
|
|
272
|
+
this.dispatchEvent(new CustomEvent('closed', {
|
|
273
|
+
bubbles: true,
|
|
274
|
+
detail: { reason },
|
|
275
|
+
}));
|
|
276
|
+
}
|
|
277
|
+
async waitForAnimation(durationMs) {
|
|
278
|
+
const prefersReducedMotion = typeof window !== 'undefined' &&
|
|
279
|
+
window.matchMedia?.('(prefers-reduced-motion: reduce)')?.matches;
|
|
280
|
+
if (this.quick || durationMs <= 0 || prefersReducedMotion) {
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
await new Promise((resolve) => {
|
|
284
|
+
globalThis.setTimeout(resolve, durationMs);
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
startAutoDismissTimer() {
|
|
288
|
+
this.clearAutoDismissTimer();
|
|
289
|
+
if (this.timeoutMs <= 0) {
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
this.remainingTimeMs = this.timeoutMs;
|
|
293
|
+
if (this.isHovered || this.isFocused) {
|
|
294
|
+
this.isPaused = true;
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
this.isPaused = false;
|
|
298
|
+
this.timerStartTime = Date.now();
|
|
299
|
+
this.scheduleAutoDismiss(this.remainingTimeMs);
|
|
300
|
+
}
|
|
301
|
+
scheduleAutoDismiss(ms) {
|
|
302
|
+
this.autoDismissTimerId = globalThis.setTimeout(() => {
|
|
303
|
+
this.close(CLOSE_REASONS.TIMEOUT);
|
|
304
|
+
}, ms);
|
|
305
|
+
}
|
|
306
|
+
clearAutoDismissTimer() {
|
|
307
|
+
if (this.autoDismissTimerId !== null) {
|
|
308
|
+
globalThis.clearTimeout(this.autoDismissTimerId);
|
|
309
|
+
this.autoDismissTimerId = null;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
pauseAutoDismissTimer() {
|
|
313
|
+
if (this.autoDismissTimerId !== null) {
|
|
314
|
+
this.clearAutoDismissTimer();
|
|
315
|
+
const elapsed = Date.now() - this.timerStartTime;
|
|
316
|
+
this.remainingTimeMs = Math.max(0, this.remainingTimeMs - elapsed);
|
|
317
|
+
this.isPaused = true;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
resumeAutoDismissTimer() {
|
|
321
|
+
if (!this.isHovered &&
|
|
322
|
+
!this.isFocused &&
|
|
323
|
+
this.isPaused &&
|
|
324
|
+
this.isOpenInternal) {
|
|
325
|
+
this.isPaused = false;
|
|
326
|
+
if (this.remainingTimeMs <= 0) {
|
|
327
|
+
this.close(CLOSE_REASONS.TIMEOUT);
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
this.timerStartTime = Date.now();
|
|
331
|
+
this.scheduleAutoDismiss(this.remainingTimeMs);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
render() {
|
|
335
|
+
const classes = snackbarClasses({
|
|
336
|
+
open: this.isOpenInternal,
|
|
337
|
+
opening: this.isOpening,
|
|
338
|
+
closing: this.isClosing,
|
|
339
|
+
fixed: this.fixed,
|
|
340
|
+
});
|
|
341
|
+
return html `
|
|
342
|
+
<div
|
|
343
|
+
class="${classMap(classes)}"
|
|
344
|
+
role="status"
|
|
345
|
+
aria-live="polite"
|
|
346
|
+
aria-atomic="true">
|
|
347
|
+
<div class="snackbar-surface" part="surface">
|
|
348
|
+
<div class="snackbar-content">
|
|
349
|
+
<div class="snackbar-label" part="label">
|
|
350
|
+
${this.labelText}<slot></slot>
|
|
351
|
+
</div>
|
|
352
|
+
<div class="snackbar-actions" part="actions">
|
|
353
|
+
<slot name="action" ${hasSlotted()}>
|
|
354
|
+
${this.actionLabel?.trim()
|
|
355
|
+
? html `
|
|
356
|
+
<button
|
|
357
|
+
type="button"
|
|
358
|
+
class="${button({
|
|
359
|
+
color: 'text',
|
|
360
|
+
size: 'sm',
|
|
361
|
+
classes: { 'snackbar-action': true },
|
|
362
|
+
})}">
|
|
363
|
+
${this.actionLabel}
|
|
364
|
+
</button>
|
|
365
|
+
`
|
|
366
|
+
: nothing}
|
|
367
|
+
</slot>
|
|
368
|
+
<slot name="dismiss" ${hasSlotted()}>
|
|
369
|
+
${this.hasCloseButton
|
|
370
|
+
? html `
|
|
371
|
+
<button
|
|
372
|
+
type="button"
|
|
373
|
+
class="${iconButton({
|
|
374
|
+
color: 'standard',
|
|
375
|
+
size: 'sm',
|
|
376
|
+
classes: { 'snackbar-dismiss': true },
|
|
377
|
+
})}"
|
|
378
|
+
aria-label="${this.closeLabel}"
|
|
379
|
+
@click="${this.handleDismissClick}">
|
|
380
|
+
<svg viewBox="0 0 24 24" aria-hidden="true">
|
|
381
|
+
<path
|
|
382
|
+
d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" />
|
|
383
|
+
</svg>
|
|
384
|
+
</button>
|
|
385
|
+
`
|
|
386
|
+
: nothing}
|
|
387
|
+
</slot>
|
|
388
|
+
</div>
|
|
389
|
+
</div>
|
|
390
|
+
</div>
|
|
391
|
+
</div>
|
|
392
|
+
`;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
// Layer order is pinned by the `@layer` statement at the top of
|
|
396
|
+
// snackbar.scss, so `md.comp.snackbar` outranks the shared layers.
|
|
397
|
+
/** @nocollapse */
|
|
398
|
+
SnackbarElement.styles = [
|
|
399
|
+
focusRingStyles,
|
|
400
|
+
rippleStyles,
|
|
401
|
+
iconButtonStyles,
|
|
402
|
+
buttonStyles,
|
|
403
|
+
snackbarStyles,
|
|
404
|
+
css `
|
|
405
|
+
:host {
|
|
406
|
+
display: block;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
:host([hidden]) {
|
|
410
|
+
display: none;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
:host([quick]) .snackbar-surface {
|
|
414
|
+
transition: none;
|
|
415
|
+
}
|
|
416
|
+
`,
|
|
417
|
+
];
|
|
418
|
+
__decorate([
|
|
419
|
+
property({ type: Boolean, reflect: true })
|
|
420
|
+
], SnackbarElement.prototype, "open", null);
|
|
421
|
+
__decorate([
|
|
422
|
+
property({ type: Number, attribute: 'timeout-ms' })
|
|
423
|
+
], SnackbarElement.prototype, "timeoutMs", void 0);
|
|
424
|
+
__decorate([
|
|
425
|
+
property({ type: Boolean, reflect: true })
|
|
426
|
+
], SnackbarElement.prototype, "fixed", void 0);
|
|
427
|
+
__decorate([
|
|
428
|
+
property({ attribute: 'close-label' })
|
|
429
|
+
], SnackbarElement.prototype, "closeLabel", void 0);
|
|
430
|
+
__decorate([
|
|
431
|
+
property({ attribute: 'label-text' })
|
|
432
|
+
], SnackbarElement.prototype, "labelText", void 0);
|
|
433
|
+
__decorate([
|
|
434
|
+
property({ attribute: 'action-label' })
|
|
435
|
+
], SnackbarElement.prototype, "actionLabel", void 0);
|
|
436
|
+
__decorate([
|
|
437
|
+
property({ type: Boolean, attribute: 'has-close-button' })
|
|
438
|
+
], SnackbarElement.prototype, "hasCloseButton", void 0);
|
|
439
|
+
__decorate([
|
|
440
|
+
property({ type: Boolean, reflect: true })
|
|
441
|
+
], SnackbarElement.prototype, "quick", void 0);
|
|
442
|
+
__decorate([
|
|
443
|
+
state()
|
|
444
|
+
], SnackbarElement.prototype, "isOpening", void 0);
|
|
445
|
+
__decorate([
|
|
446
|
+
state()
|
|
447
|
+
], SnackbarElement.prototype, "isClosing", void 0);
|
|
448
|
+
//# sourceMappingURL=snackbar-element.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snackbar-element.js","sourceRoot":"","sources":["snackbar-element.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAC,GAAG,EAA0B,IAAI,EAAE,UAAU,EAAE,OAAO,EAAC,MAAM,KAAK,CAAC;AAC3E,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAC,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAC,QAAQ,EAAC,MAAM,6BAA6B,CAAC;AACrD,OAAO,EAAC,MAAM,EAAC,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAC,UAAU,EAAC,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAC,UAAU,EAAC,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAC,aAAa,EAAE,eAAe,EAAC,MAAM,eAAe,CAAC;AAE7D,OAAO,YAAY,MAAM,sBAAsB,CAAC,OAAM,IAAI,EAAE,KAAK,EAAC,CAAC,CAAC,cAAc;AAClF,4EAA4E;AAC5E,OAAO,eAAe,MAAM,yBAAyB,CAAC,OAAM,IAAI,EAAE,KAAK,EAAC,CAAC,CAA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CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAC,CAAC;uDAClC;AAKmB;IAAzC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;8CAAe;AAEvC;IAAhB,KAAK,EAAE;kDAA2B;AAClB;IAAhB,KAAK,EAAE;kDAA2B","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {css, type CSSResultOrNative, html, LitElement, nothing} from 'lit';\nimport {property, state} from 'lit/decorators.js';\nimport {classMap} from 'lit/directives/class-map.js';\nimport {button} from '../button/button.js';\nimport {iconButton} from '../iconbutton/icon-button.js';\nimport {hasSlotted} from '../shared/has-slotted.js';\nimport {CLOSE_REASONS, snackbarClasses} from './snackbar.js';\n\nimport buttonStyles from '../button/button.css' with {type: 'css'}; // github-only\n// import buttonStyles from '../button/button.cssresult.js'; // google3-only\nimport focusRingStyles from '../focus/focus-ring.css' with {type: 'css'}; // github-only\n// import focusRingStyles from '../focus/focus-ring.cssresult.js'; // google3-only\nimport iconButtonStyles from '../iconbutton/icon-button.css' with {type: 'css'}; // github-only\n// import iconButtonStyles from '../iconbutton/icon-button.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\nimport snackbarStyles from './snackbar.css' with {type: 'css'}; // github-only\n// import snackbarStyles from './snackbar.cssresult.js'; // google3-only\n\n/**\n * Animation duration for snackbar appearance in milliseconds.\n */\nexport const OPEN_DURATION_MS = 150;\n\n/**\n * Animation duration for snackbar disappearance in milliseconds.\n */\nexport const CLOSE_DURATION_MS = 75;\n\n/**\n * A Material Design snackbar component.\n *\n * @fires {Event} open - Fired when the snackbar begins opening.\n * @fires {Event} opened - Fired when the snackbar has opened and animations finished.\n * @fires {CustomEvent<{reason: string}>} close - Fired when the snackbar begins closing.\n * @fires {CustomEvent<{reason: string}>} closed - Fired when the snackbar has closed.\n * @slot - Default slot for rich content (rendered after `label-text`). If both `label-text` and slotted content are provided, both render.\n * @slot action - Slot for a custom action button; replaces the built-in action rendered from `action-label`. Prefer the `action-label` attribute, which renders a text button matching the spec. A slotted plain `<button>` is styled by the snackbar, with hover, focus and pressed states. A slotted text `<md-gb-button>` gets the `--action-label-text*` colors and typography, but keeps its own 16px padding and pressed shape, because its component tokens can't be set from outside its shadow root.\n * @slot dismiss - Slot for dismiss button (falls back to close icon button when `has-close-button` is set).\n * @csspart surface - The surface container of the snackbar.\n * @csspart label - The container wrapping the label content.\n * @csspart actions - The container wrapping action and dismiss slots.\n * @cssprop --action-label-text-color - Action button label text color.\n * @cssprop --action-label-text - Action button label typography.\n * @cssprop --action-label-text-axes - Action button label typography font variation settings.\n * @cssprop --action-label-text-tracking - Action button label letter spacing.\n * @cssprop --container-color - Container background color.\n * @cssprop --container-elevation - Container box shadow elevation.\n * @cssprop --container-shape - Container border radius.\n * @cssprop --icon-color - Close icon color.\n * @cssprop --icon-size - Close icon size.\n * @cssprop --supporting-text - Supporting label typography.\n * @cssprop --supporting-text-axes - Supporting label typography font variation settings.\n * @cssprop --supporting-text-color - Supporting label text color.\n * @cssprop --supporting-text-tracking - Supporting label letter spacing.\n * @cssprop --min-width - Minimum surface width in wide layout.\n * @cssprop --max-width - Maximum surface width in wide layout.\n * @cssprop --min-height - Minimum surface height.\n * @cssprop --bottom-offset - Inset block end distance from container bottom.\n * @cssprop --position - CSS position property (`absolute` by default).\n * @cssprop --z-index - Z-index of the snackbar.\n */\nexport class SnackbarElement extends LitElement {\n // Layer order is pinned by the `@layer` statement at the top of\n // snackbar.scss, so `md.comp.snackbar` outranks the shared layers.\n /** @nocollapse */\n static override styles: CSSResultOrNative[] = [\n focusRingStyles,\n rippleStyles,\n iconButtonStyles,\n buttonStyles,\n snackbarStyles,\n css`\n :host {\n display: block;\n }\n\n :host([hidden]) {\n display: none;\n }\n\n :host([quick]) .snackbar-surface {\n transition: none;\n }\n `,\n ];\n\n private isOpenInternal = false;\n\n /**\n * Whether the snackbar is currently open.\n */\n @property({type: Boolean, reflect: true})\n get open(): boolean {\n return this.isOpenInternal;\n }\n set open(value: boolean) {\n if (value === this.isOpenInternal) {\n return;\n }\n if (value) {\n this.show();\n } else {\n this.close(CLOSE_REASONS.DISMISS);\n }\n }\n\n /**\n * Time in milliseconds before the snackbar automatically dismisses.\n * Set to 0 or a negative value (e.g. -1) to disable auto-dismiss. Read when\n * the snackbar opens; changing it while open takes effect on the next open.\n */\n @property({type: Number, attribute: 'timeout-ms'}) timeoutMs = 5000;\n\n /**\n * Whether the snackbar should be positioned relative to the viewport (fixed).\n */\n @property({type: Boolean, reflect: true}) fixed = false;\n\n /**\n * Accessible label for the built-in dismiss button.\n */\n @property({attribute: 'close-label'}) closeLabel = 'Close';\n\n /**\n * Supporting message text to display. Rendered before default slot content.\n */\n @property({attribute: 'label-text'}) labelText = '';\n\n /**\n * Visible text of the built-in action button. Rendered only when non-empty\n * and nothing is slotted into `action`.\n */\n @property({attribute: 'action-label'}) actionLabel = '';\n\n /**\n * Whether to display a close icon button.\n */\n @property({type: Boolean, attribute: 'has-close-button'})\n hasCloseButton = false;\n\n /**\n * Whether to skip opening and closing transition delays.\n */\n @property({type: Boolean, reflect: true}) quick = false;\n\n @state() private isOpening = false;\n @state() private isClosing = false;\n\n private isHovered = false;\n private isFocused = false;\n private isPaused = false;\n private autoDismissTimerId: number | null = null;\n private remainingTimeMs = 0;\n private timerStartTime = 0;\n private transitionCounter = 0;\n\n override connectedCallback() {\n super.connectedCallback();\n this.addEventListener('mouseenter', this.handleMouseEnter);\n this.addEventListener('mouseleave', this.handleMouseLeave);\n this.addEventListener('focusin', this.handleFocusIn);\n this.addEventListener('focusout', this.handleFocusOut);\n this.addEventListener('keydown', this.handleKeyDown);\n this.addEventListener('click', this.handleClick);\n if (this.open && !this.isOpening && !this.isClosing) {\n this.startAutoDismissTimer();\n }\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n this.removeEventListener('mouseenter', this.handleMouseEnter);\n this.removeEventListener('mouseleave', this.handleMouseLeave);\n this.removeEventListener('focusin', this.handleFocusIn);\n this.removeEventListener('focusout', this.handleFocusOut);\n this.removeEventListener('keydown', this.handleKeyDown);\n this.removeEventListener('click', this.handleClick);\n this.clearAutoDismissTimer();\n }\n\n /**\n * Opens the snackbar.\n */\n async show(): Promise<void> {\n if (this.isOpenInternal && !this.isClosing) {\n return;\n }\n\n const preventOpen = !this.dispatchEvent(\n new Event('open', {bubbles: true, cancelable: true}),\n );\n if (preventOpen) {\n return;\n }\n\n const token = ++this.transitionCounter;\n this.clearAutoDismissTimer();\n this.isHovered = false;\n this.isFocused = false;\n this.isPaused = false;\n const prev = this.isOpenInternal;\n this.isOpenInternal = true;\n this.requestUpdate('open', prev);\n this.isClosing = false;\n this.isOpening = true;\n this.requestUpdate();\n await this.updateComplete;\n if (token !== this.transitionCounter) {\n return;\n }\n\n await this.waitForAnimation(OPEN_DURATION_MS);\n if (token !== this.transitionCounter) {\n return;\n }\n\n this.isOpening = false;\n this.requestUpdate();\n this.dispatchEvent(new Event('opened', {bubbles: true}));\n\n if (!this.isConnected) {\n return;\n }\n this.startAutoDismissTimer();\n }\n\n /**\n * Closes the snackbar.\n *\n * @param reason The reason for closing (e.g. 'action', 'dismiss', 'timeout').\n */\n async close(reason: string = CLOSE_REASONS.DISMISS): Promise<void> {\n if (!this.isOpenInternal && !this.isOpening) {\n return;\n }\n\n const preventClose = !this.dispatchEvent(\n new CustomEvent('close', {\n bubbles: true,\n cancelable: true,\n detail: {reason},\n }),\n );\n if (preventClose) {\n return;\n }\n\n const token = ++this.transitionCounter;\n this.clearAutoDismissTimer();\n this.isHovered = false;\n this.isFocused = false;\n this.isPaused = false;\n const prev = this.isOpenInternal;\n this.isOpenInternal = false;\n this.requestUpdate('open', prev);\n this.isOpening = false;\n this.isClosing = true;\n this.requestUpdate();\n await this.updateComplete;\n if (token !== this.transitionCounter) {\n return;\n }\n\n await this.waitForAnimation(CLOSE_DURATION_MS);\n if (token !== this.transitionCounter) {\n return;\n }\n\n this.isClosing = false;\n this.requestUpdate();\n this.dispatchEvent(\n new CustomEvent('closed', {\n bubbles: true,\n detail: {reason},\n }),\n );\n }\n\n private async waitForAnimation(durationMs: number): Promise<void> {\n const prefersReducedMotion =\n typeof window !== 'undefined' &&\n window.matchMedia?.('(prefers-reduced-motion: reduce)')?.matches;\n if (this.quick || durationMs <= 0 || prefersReducedMotion) {\n return;\n }\n await new Promise<void>((resolve) => {\n globalThis.setTimeout(resolve, durationMs);\n });\n }\n\n private startAutoDismissTimer() {\n this.clearAutoDismissTimer();\n if (this.timeoutMs <= 0) {\n return;\n }\n this.remainingTimeMs = this.timeoutMs;\n if (this.isHovered || this.isFocused) {\n this.isPaused = true;\n return;\n }\n this.isPaused = false;\n this.timerStartTime = Date.now();\n this.scheduleAutoDismiss(this.remainingTimeMs);\n }\n\n private scheduleAutoDismiss(ms: number) {\n this.autoDismissTimerId = globalThis.setTimeout(() => {\n this.close(CLOSE_REASONS.TIMEOUT);\n }, ms);\n }\n\n private clearAutoDismissTimer() {\n if (this.autoDismissTimerId !== null) {\n globalThis.clearTimeout(this.autoDismissTimerId);\n this.autoDismissTimerId = null;\n }\n }\n\n private pauseAutoDismissTimer() {\n if (this.autoDismissTimerId !== null) {\n this.clearAutoDismissTimer();\n const elapsed = Date.now() - this.timerStartTime;\n this.remainingTimeMs = Math.max(0, this.remainingTimeMs - elapsed);\n this.isPaused = true;\n }\n }\n\n private resumeAutoDismissTimer() {\n if (\n !this.isHovered &&\n !this.isFocused &&\n this.isPaused &&\n this.isOpenInternal\n ) {\n this.isPaused = false;\n if (this.remainingTimeMs <= 0) {\n this.close(CLOSE_REASONS.TIMEOUT);\n return;\n }\n this.timerStartTime = Date.now();\n this.scheduleAutoDismiss(this.remainingTimeMs);\n }\n }\n\n private readonly handleMouseEnter = () => {\n this.isHovered = true;\n this.pauseAutoDismissTimer();\n };\n\n private readonly handleMouseLeave = () => {\n this.isHovered = false;\n if (!this.isFocused) {\n this.resumeAutoDismissTimer();\n }\n };\n\n private readonly handleFocusIn = () => {\n this.isFocused = true;\n this.pauseAutoDismissTimer();\n };\n\n private readonly handleFocusOut = () => {\n this.isFocused = false;\n if (!this.isHovered) {\n this.resumeAutoDismissTimer();\n }\n };\n\n private readonly handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape' && this.isOpenInternal) {\n event.preventDefault();\n this.close(CLOSE_REASONS.DISMISS);\n }\n };\n\n private readonly handleClick = (event: MouseEvent) => {\n const path = event.composedPath();\n for (const target of path) {\n if (!(target instanceof HTMLElement)) continue;\n if (\n target.getAttribute('slot') === 'action' ||\n target.classList.contains('snackbar-action')\n ) {\n this.close(CLOSE_REASONS.ACTION);\n return;\n }\n if (\n target.getAttribute('slot') === 'dismiss' ||\n target.classList.contains('snackbar-dismiss')\n ) {\n this.close(CLOSE_REASONS.DISMISS);\n return;\n }\n }\n };\n\n private readonly handleDismissClick = (event: MouseEvent) => {\n event.stopPropagation();\n this.close(CLOSE_REASONS.DISMISS);\n };\n\n override render() {\n const classes = snackbarClasses({\n open: this.isOpenInternal,\n opening: this.isOpening,\n closing: this.isClosing,\n fixed: this.fixed,\n });\n\n return html`\n <div\n class=\"${classMap(classes)}\"\n role=\"status\"\n aria-live=\"polite\"\n aria-atomic=\"true\">\n <div class=\"snackbar-surface\" part=\"surface\">\n <div class=\"snackbar-content\">\n <div class=\"snackbar-label\" part=\"label\">\n ${this.labelText}<slot></slot>\n </div>\n <div class=\"snackbar-actions\" part=\"actions\">\n <slot name=\"action\" ${hasSlotted()}>\n ${this.actionLabel?.trim()\n ? html`\n <button\n type=\"button\"\n class=\"${button({\n color: 'text',\n size: 'sm',\n classes: {'snackbar-action': true},\n })}\">\n ${this.actionLabel}\n </button>\n `\n : nothing}\n </slot>\n <slot name=\"dismiss\" ${hasSlotted()}>\n ${this.hasCloseButton\n ? html`\n <button\n type=\"button\"\n class=\"${iconButton({\n color: 'standard',\n size: 'sm',\n classes: {'snackbar-dismiss': true},\n })}\"\n aria-label=\"${this.closeLabel}\"\n @click=\"${this.handleDismissClick}\">\n <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n <path\n d=\"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z\" />\n </svg>\n </button>\n `\n : nothing}\n </slot>\n </div>\n </div>\n </div>\n </div>\n `;\n }\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright 2026 Google LLC
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/@layer md.sys, md.comp.ripple, md.comp.focus-ring, md.comp.icon-btn,
|
|
5
|
+
md.comp.button;@layer md.comp.snackbar{:host,.snackbar{--action-label-text-color: var(--md-sys-color-inverse-primary);--action-label-text: var(--md-sys-typescale-label-lg);--action-label-text-axes: var(--md-sys-typescale-label-lg-axes);--action-label-text-tracking: var(--md-sys-typescale-label-lg-tracking);--container-color: var(--md-sys-color-inverse-surface);--container-elevation: var(--md-sys-elevation-shadow-3);--container-shape: var(--md-sys-shape-corner-xs);--icon-color: var(--md-sys-color-inverse-on-surface);--icon-size: 24px;--supporting-text: var(--md-sys-typescale-body-md);--supporting-text-axes: var(--md-sys-typescale-body-md-axes);--supporting-text-color: var(--md-sys-color-inverse-on-surface);--supporting-text-tracking: var(--md-sys-typescale-body-md-tracking);--min-width: 344px;--max-width: 672px;--min-height: 48px;--bottom-offset: 16px;--position: absolute;--z-index: 1000;--_close-icon-color: var(--icon-color);--_close-icon-size: var(--icon-size);position:var(--position);inset-block-end:var(--bottom-offset);inset-inline:0;inline-size:100%;box-sizing:border-box;pointer-events:none;z-index:var(--z-index)}:host([fixed]),.snackbar.snackbar-fixed{position:fixed}.snackbar{container:snackbar/inline-size;display:none;align-items:center;justify-content:center}:host>.snackbar{--action-label-text-color: inherit;--action-label-text: inherit;--action-label-text-axes: inherit;--action-label-text-tracking: inherit;--container-color: inherit;--container-elevation: inherit;--container-shape: inherit;--icon-color: inherit;--icon-size: inherit;--supporting-text: inherit;--supporting-text-axes: inherit;--supporting-text-color: inherit;--supporting-text-tracking: inherit;--min-width: inherit;--max-width: inherit;--min-height: inherit;--bottom-offset: inherit;--position: inherit;--z-index: inherit;position:static;z-index:auto}.snackbar.snackbar-opening,.snackbar.snackbar-open,.snackbar.snackbar-closing{display:flex}.snackbar-surface{position:relative;background-color:var(--container-color);box-shadow:var(--container-elevation);border-radius:var(--container-shape);min-block-size:var(--min-height);box-sizing:border-box;display:flex;align-items:center;justify-content:space-between;opacity:0;transform:scaleY(0);transform-origin:center bottom;pointer-events:none;transition:opacity 75ms cubic-bezier(0.4, 0, 1, 1),transform 75ms cubic-bezier(0.4, 0, 1, 1)}.snackbar.snackbar-open .snackbar-surface{opacity:1;transform:none;pointer-events:auto;transition:opacity 150ms cubic-bezier(0, 0, 0.2, 1),transform 150ms cubic-bezier(0, 0, 0.2, 1)}@starting-style{.snackbar.snackbar-open .snackbar-surface{opacity:0;transform:scaleY(0)}}.snackbar.snackbar-closing .snackbar-surface{opacity:0;transform:none;pointer-events:none;transition:opacity 75ms cubic-bezier(0.4, 0, 1, 1)}@media(prefers-reduced-motion: reduce){.snackbar-surface{transition-duration:.001ms}}.snackbar-content{--_actions-chrome: 0px;flex:1 1 auto;display:flex;flex-wrap:wrap;align-items:center;row-gap:0;padding-inline:16px;padding-block:0 4px;inline-size:100%;box-sizing:border-box}.snackbar-content:is(:has(slot[name=action].has-slotted),:has(.snackbar-action)):not(:has(slot[name=dismiss].has-slotted),:has(.snackbar-dismiss)){--_actions-chrome: 4px;padding-inline-end:8px}.snackbar-content:is(:has(slot[name=dismiss].has-slotted),:has(.snackbar-dismiss)){padding-inline-end:0}.snackbar-content:is(:has(slot[name=action].has-slotted),:has(.snackbar-action)):is(:has(slot[name=dismiss].has-slotted),:has(.snackbar-dismiss)){--_actions-chrome: 48px}.snackbar-label{color:var(--supporting-text-color);font:var(--supporting-text);letter-spacing:var(--supporting-text-tracking);font-variation-settings:var(--supporting-text-axes);box-sizing:border-box;padding-block:14px;margin:0;margin-block-end:-4px;overflow-wrap:anywhere}.snackbar-actions{flex:none;display:flex;align-items:center;gap:0;margin-inline-start:auto;box-sizing:border-box}.snackbar-actions:is(:has(slot[name=action].has-slotted),:has(.snackbar-action)):not(:has(slot[name=dismiss].has-slotted),:has(.snackbar-dismiss)){margin-block-start:4px}.snackbar-actions:is(:has(slot[name=dismiss].has-slotted),:has(.snackbar-dismiss)){margin-block-end:-4px;margin-inline-end:-4px}.snackbar-actions:not(:has(slot[name=action].has-slotted),:has(.snackbar-action),:has(slot[name=dismiss].has-slotted),:has(.snackbar-dismiss)){display:none}@container snackbar (inline-size < 600px){.snackbar-surface{inline-size:calc(100% - 32px);margin-inline:16px}.snackbar-label{flex:1 1 0;min-inline-size:calc(70% - var(--_actions-chrome))}}@container snackbar (inline-size >= 600px){.snackbar-surface{inline-size:fit-content;min-inline-size:var(--min-width);max-inline-size:min(var(--max-width),100% - 32px);margin-inline:auto}.snackbar-label{flex:1 1 calc(.7*(min(var(--max-width),100cqi - 32px) - 32px) - var(--_actions-chrome));max-inline-size:max-content;min-inline-size:0}}.snackbar-actions ::slotted([slot=action]){margin-inline-start:4px}.snackbar-action{--leading-space: 12px;--trailing-space: 12px;--outline-width: 0;--label-text-color: var(--action-label-text-color);--icon-color: var(--action-label-text-color);--label-text: var(--action-label-text);--label-text-axes: var(--action-label-text-axes);--label-text-tracking: var(--action-label-text-tracking);margin-inline-start:4px;white-space:nowrap;-webkit-tap-highlight-color:rgba(0,0,0,0)}.snackbar-action:is(:active,.active),.snackbar-dismiss:is(:active,.active){--container-shape: calc(var(--container-height) / 2)}.snackbar-actions ::slotted(md-gb-button[slot=action]){--md-sys-color-primary: var(--action-label-text-color);--md-sys-typescale-label-lg: var(--action-label-text);--md-sys-typescale-label-lg-axes: var(--action-label-text-axes);--md-sys-typescale-label-lg-tracking: var(--action-label-text-tracking)}.snackbar-actions ::slotted([slot=action]:not(md-gb-button)){color:var(--action-label-text-color);background:rgba(0,0,0,0);border:none;font:var(--action-label-text);letter-spacing:var(--action-label-text-tracking);font-variation-settings:var(--action-label-text-axes);cursor:pointer;padding-inline:12px;block-size:40px;border-radius:100px;display:inline-flex;align-items:center;justify-content:center;box-sizing:border-box;text-transform:none;outline:none;white-space:nowrap}.snackbar-actions ::slotted([slot=action]:not(md-gb-button):disabled){cursor:default}.snackbar-actions ::slotted([slot=action]:not(md-gb-button):not(:disabled):hover){background-color:hsl(from var(--action-label-text-color) h s l/8%)}.snackbar-actions ::slotted([slot=action]:not(md-gb-button):focus-visible){outline:3px solid var(--md-sys-color-secondary);outline-offset:2px}.snackbar-actions ::slotted([slot=action]:not(md-gb-button):not(:disabled):active){background-color:hsl(from var(--action-label-text-color) h s l/10%)}.snackbar-dismiss{--icon-color: var(--_close-icon-color);--icon-size: var(--_close-icon-size);--outline-width: 0;position:relative;flex-shrink:0;box-sizing:border-box;margin:4px;padding:0;-webkit-tap-highlight-color:rgba(0,0,0,0)}.snackbar-dismiss::after{content:"";position:absolute;inset:-4px}.snackbar-dismiss svg{inline-size:var(--icon-size);block-size:var(--icon-size);fill:currentColor}}/*# sourceMappingURL=snackbar.css.map */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sourceRoot":"","sources":["snackbar.scss","_snackbar-tokens.scss","../../../../tokens/versions/latest/sass/_md-sys-state-focus-indicator.scss"],"names":[],"mappings":"AAAA;AAAA;AAAA;AAAA,GAuCA;AAAA,iBAEA,wBAGE,gBC5BA,+DAKA,sDAEA,gEAEA,wEAEA,uDAEA,wDAEA,iDAEA,qDAEA,kBAKA,mDAEA,6DAEA,gEAEA,qEAEA,mBAEA,mBAEA,mBAEA,sBAEA,qBAEA,gBDRE,uCACA,qCACA,yBACA,qCACA,eACA,iBACA,sBACA,oBACA,uBAGF,wCAEE,eAKF,UACE,+BACA,aACA,mBACA,uBAOF,gBCbA,mCACA,6BACA,kCACA,sCACA,2BACA,+BACA,2BACA,sBACA,qBACA,2BACA,gCACA,iCACA,oCACA,qBACA,qBACA,sBACA,yBACA,oBACA,mBDHE,gBACA,aAGF,8EAGE,aAGF,kBACE,kBACA,wCACA,sCACA,qCACA,iCACA,sBACA,aACA,mBACA,8BACA,UAEA,oBACA,+BACA,oBACA,WACE,kFAIJ,0CACE,UACA,eACA,oBACA,WACE,oFAOJ,gBACE,0CACE,UACA,qBAKJ,6CACE,UACA,eACA,oBACA,mDAGF,uCACE,kBACE,4BAMJ,kBACE,uBACA,cACA,aACA,eACA,mBACA,UACA,eAzIqB,KA0IrB,oBACA,iBACA,sBAOF,mJACE,uBACA,mBApJ6B,IAyJ/B,mFACE,qBAKF,kJACE,wBAKF,gBACE,mCACA,4BACA,+CACA,oDACA,sBACA,mBACA,SACA,sBACA,uBAGF,kBACE,UACA,aACA,mBACA,MACA,yBACA,sBAIF,mJACE,uBAKF,mFACE,sBACA,uBAIF,+IACE,aAGF,0CACE,kBACE,8BACA,mBAGF,gBACE,WACA,oDAIJ,2CACE,kBACE,wBACA,iCACA,kDACA,mBAUF,gBACE,wFAQA,4BACA,mBAIJ,2CACE,oBApPS,IA0PX,iBACE,sBACA,uBAGA,mBACA,mDACA,6CACA,uCACA,iDACA,yDACA,oBArQS,IAsQT,mBACA,0CAKF,2EAEE,qDAUF,uDACE,uDACA,sDACA,gEACA,wEAKF,6DACE,qCACA,yBACA,YACA,8BACA,iDACA,sDACA,eACA,eA/RoB,KAgSpB,gBACA,oBACA,oBACA,mBACA,uBACA,sBACA,oBACA,aACA,mBAGF,sEACE,eAGF,kFAEE,mEAOF,2EACE,gDAEA,eEnUW,IFsUb,mFAEE,oEAQF,kBACE,uCACA,qCAGA,mBACA,kBACA,cACA,sBACA,OAhWiB,IAiWjB,UACA,0CAKF,yBACE,WACA,kBACA,WAGF,sBACE,6BACA,4BACA","file":"snackbar.css"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
// Generated stylesheet for ./labs/gb/components/snackbar/snackbar.css.
|
|
7
|
+
import { css } from 'lit';
|
|
8
|
+
export const styles = css `/*!
|
|
9
|
+
* Copyright 2026 Google LLC
|
|
10
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
11
|
+
*/@layer md.sys, md.comp.ripple, md.comp.focus-ring, md.comp.icon-btn,
|
|
12
|
+
md.comp.button;@layer md.comp.snackbar{:host,.snackbar{--action-label-text-color: var(--md-sys-color-inverse-primary);--action-label-text: var(--md-sys-typescale-label-lg);--action-label-text-axes: var(--md-sys-typescale-label-lg-axes);--action-label-text-tracking: var(--md-sys-typescale-label-lg-tracking);--container-color: var(--md-sys-color-inverse-surface);--container-elevation: var(--md-sys-elevation-shadow-3);--container-shape: var(--md-sys-shape-corner-xs);--icon-color: var(--md-sys-color-inverse-on-surface);--icon-size: 24px;--supporting-text: var(--md-sys-typescale-body-md);--supporting-text-axes: var(--md-sys-typescale-body-md-axes);--supporting-text-color: var(--md-sys-color-inverse-on-surface);--supporting-text-tracking: var(--md-sys-typescale-body-md-tracking);--min-width: 344px;--max-width: 672px;--min-height: 48px;--bottom-offset: 16px;--position: absolute;--z-index: 1000;--_close-icon-color: var(--icon-color);--_close-icon-size: var(--icon-size);position:var(--position);inset-block-end:var(--bottom-offset);inset-inline:0;inline-size:100%;box-sizing:border-box;pointer-events:none;z-index:var(--z-index)}:host([fixed]),.snackbar.snackbar-fixed{position:fixed}.snackbar{container:snackbar/inline-size;display:none;align-items:center;justify-content:center}:host>.snackbar{--action-label-text-color: inherit;--action-label-text: inherit;--action-label-text-axes: inherit;--action-label-text-tracking: inherit;--container-color: inherit;--container-elevation: inherit;--container-shape: inherit;--icon-color: inherit;--icon-size: inherit;--supporting-text: inherit;--supporting-text-axes: inherit;--supporting-text-color: inherit;--supporting-text-tracking: inherit;--min-width: inherit;--max-width: inherit;--min-height: inherit;--bottom-offset: inherit;--position: inherit;--z-index: inherit;position:static;z-index:auto}.snackbar.snackbar-opening,.snackbar.snackbar-open,.snackbar.snackbar-closing{display:flex}.snackbar-surface{position:relative;background-color:var(--container-color);box-shadow:var(--container-elevation);border-radius:var(--container-shape);min-block-size:var(--min-height);box-sizing:border-box;display:flex;align-items:center;justify-content:space-between;opacity:0;transform:scaleY(0);transform-origin:center bottom;pointer-events:none;transition:opacity 75ms cubic-bezier(0.4, 0, 1, 1),transform 75ms cubic-bezier(0.4, 0, 1, 1)}.snackbar.snackbar-open .snackbar-surface{opacity:1;transform:none;pointer-events:auto;transition:opacity 150ms cubic-bezier(0, 0, 0.2, 1),transform 150ms cubic-bezier(0, 0, 0.2, 1)}@starting-style{.snackbar.snackbar-open .snackbar-surface{opacity:0;transform:scaleY(0)}}.snackbar.snackbar-closing .snackbar-surface{opacity:0;transform:none;pointer-events:none;transition:opacity 75ms cubic-bezier(0.4, 0, 1, 1)}@media(prefers-reduced-motion: reduce){.snackbar-surface{transition-duration:.001ms}}.snackbar-content{--_actions-chrome: 0px;flex:1 1 auto;display:flex;flex-wrap:wrap;align-items:center;row-gap:0;padding-inline:16px;padding-block:0 4px;inline-size:100%;box-sizing:border-box}.snackbar-content:is(:has(slot[name=action].has-slotted),:has(.snackbar-action)):not(:has(slot[name=dismiss].has-slotted),:has(.snackbar-dismiss)){--_actions-chrome: 4px;padding-inline-end:8px}.snackbar-content:is(:has(slot[name=dismiss].has-slotted),:has(.snackbar-dismiss)){padding-inline-end:0}.snackbar-content:is(:has(slot[name=action].has-slotted),:has(.snackbar-action)):is(:has(slot[name=dismiss].has-slotted),:has(.snackbar-dismiss)){--_actions-chrome: 48px}.snackbar-label{color:var(--supporting-text-color);font:var(--supporting-text);letter-spacing:var(--supporting-text-tracking);font-variation-settings:var(--supporting-text-axes);box-sizing:border-box;padding-block:14px;margin:0;margin-block-end:-4px;overflow-wrap:anywhere}.snackbar-actions{flex:none;display:flex;align-items:center;gap:0;margin-inline-start:auto;box-sizing:border-box}.snackbar-actions:is(:has(slot[name=action].has-slotted),:has(.snackbar-action)):not(:has(slot[name=dismiss].has-slotted),:has(.snackbar-dismiss)){margin-block-start:4px}.snackbar-actions:is(:has(slot[name=dismiss].has-slotted),:has(.snackbar-dismiss)){margin-block-end:-4px;margin-inline-end:-4px}.snackbar-actions:not(:has(slot[name=action].has-slotted),:has(.snackbar-action),:has(slot[name=dismiss].has-slotted),:has(.snackbar-dismiss)){display:none}@container snackbar (inline-size < 600px){.snackbar-surface{inline-size:calc(100% - 32px);margin-inline:16px}.snackbar-label{flex:1 1 0;min-inline-size:calc(70% - var(--_actions-chrome))}}@container snackbar (inline-size >= 600px){.snackbar-surface{inline-size:fit-content;min-inline-size:var(--min-width);max-inline-size:min(var(--max-width),100% - 32px);margin-inline:auto}.snackbar-label{flex:1 1 calc(.7*(min(var(--max-width),100cqi - 32px) - 32px) - var(--_actions-chrome));max-inline-size:max-content;min-inline-size:0}}.snackbar-actions ::slotted([slot=action]){margin-inline-start:4px}.snackbar-action{--leading-space: 12px;--trailing-space: 12px;--outline-width: 0;--label-text-color: var(--action-label-text-color);--icon-color: var(--action-label-text-color);--label-text: var(--action-label-text);--label-text-axes: var(--action-label-text-axes);--label-text-tracking: var(--action-label-text-tracking);margin-inline-start:4px;white-space:nowrap;-webkit-tap-highlight-color:rgba(0,0,0,0)}.snackbar-action:is(:active,.active),.snackbar-dismiss:is(:active,.active){--container-shape: calc(var(--container-height) / 2)}.snackbar-actions ::slotted(md-gb-button[slot=action]){--md-sys-color-primary: var(--action-label-text-color);--md-sys-typescale-label-lg: var(--action-label-text);--md-sys-typescale-label-lg-axes: var(--action-label-text-axes);--md-sys-typescale-label-lg-tracking: var(--action-label-text-tracking)}.snackbar-actions ::slotted([slot=action]:not(md-gb-button)){color:var(--action-label-text-color);background:rgba(0,0,0,0);border:none;font:var(--action-label-text);letter-spacing:var(--action-label-text-tracking);font-variation-settings:var(--action-label-text-axes);cursor:pointer;padding-inline:12px;block-size:40px;border-radius:100px;display:inline-flex;align-items:center;justify-content:center;box-sizing:border-box;text-transform:none;outline:none;white-space:nowrap}.snackbar-actions ::slotted([slot=action]:not(md-gb-button):disabled){cursor:default}.snackbar-actions ::slotted([slot=action]:not(md-gb-button):not(:disabled):hover){background-color:hsl(from var(--action-label-text-color) h s l/8%)}.snackbar-actions ::slotted([slot=action]:not(md-gb-button):focus-visible){outline:3px solid var(--md-sys-color-secondary);outline-offset:2px}.snackbar-actions ::slotted([slot=action]:not(md-gb-button):not(:disabled):active){background-color:hsl(from var(--action-label-text-color) h s l/10%)}.snackbar-dismiss{--icon-color: var(--_close-icon-color);--icon-size: var(--_close-icon-size);--outline-width: 0;position:relative;flex-shrink:0;box-sizing:border-box;margin:4px;padding:0;-webkit-tap-highlight-color:rgba(0,0,0,0)}.snackbar-dismiss::after{content:"";position:absolute;inset:-4px}.snackbar-dismiss svg{inline-size:var(--icon-size);block-size:var(--icon-size);fill:currentColor}}
|
|
13
|
+
`;
|
|
14
|
+
export default styles.styleSheet;
|
|
15
|
+
//# sourceMappingURL=snackbar.cssresult.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snackbar.cssresult.js","sourceRoot":"","sources":["snackbar.cssresult.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,uEAAuE;AACvE,OAAO,EAAC,GAAG,EAAC,MAAM,KAAK,CAAC;AACxB,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;CAKxB,CAAC;AACF,eAAe,MAAM,CAAC,UAAW,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n// Generated stylesheet for ./labs/gb/components/snackbar/snackbar.css.\nimport {css} from 'lit';\nexport const styles = css`/*!\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */@layer md.sys, md.comp.ripple, md.comp.focus-ring, md.comp.icon-btn,\n md.comp.button;@layer md.comp.snackbar{:host,.snackbar{--action-label-text-color: var(--md-sys-color-inverse-primary);--action-label-text: var(--md-sys-typescale-label-lg);--action-label-text-axes: var(--md-sys-typescale-label-lg-axes);--action-label-text-tracking: var(--md-sys-typescale-label-lg-tracking);--container-color: var(--md-sys-color-inverse-surface);--container-elevation: var(--md-sys-elevation-shadow-3);--container-shape: var(--md-sys-shape-corner-xs);--icon-color: var(--md-sys-color-inverse-on-surface);--icon-size: 24px;--supporting-text: var(--md-sys-typescale-body-md);--supporting-text-axes: var(--md-sys-typescale-body-md-axes);--supporting-text-color: var(--md-sys-color-inverse-on-surface);--supporting-text-tracking: var(--md-sys-typescale-body-md-tracking);--min-width: 344px;--max-width: 672px;--min-height: 48px;--bottom-offset: 16px;--position: absolute;--z-index: 1000;--_close-icon-color: var(--icon-color);--_close-icon-size: var(--icon-size);position:var(--position);inset-block-end:var(--bottom-offset);inset-inline:0;inline-size:100%;box-sizing:border-box;pointer-events:none;z-index:var(--z-index)}:host([fixed]),.snackbar.snackbar-fixed{position:fixed}.snackbar{container:snackbar/inline-size;display:none;align-items:center;justify-content:center}:host>.snackbar{--action-label-text-color: inherit;--action-label-text: inherit;--action-label-text-axes: inherit;--action-label-text-tracking: inherit;--container-color: inherit;--container-elevation: inherit;--container-shape: inherit;--icon-color: inherit;--icon-size: inherit;--supporting-text: inherit;--supporting-text-axes: inherit;--supporting-text-color: inherit;--supporting-text-tracking: inherit;--min-width: inherit;--max-width: inherit;--min-height: inherit;--bottom-offset: inherit;--position: inherit;--z-index: inherit;position:static;z-index:auto}.snackbar.snackbar-opening,.snackbar.snackbar-open,.snackbar.snackbar-closing{display:flex}.snackbar-surface{position:relative;background-color:var(--container-color);box-shadow:var(--container-elevation);border-radius:var(--container-shape);min-block-size:var(--min-height);box-sizing:border-box;display:flex;align-items:center;justify-content:space-between;opacity:0;transform:scaleY(0);transform-origin:center bottom;pointer-events:none;transition:opacity 75ms cubic-bezier(0.4, 0, 1, 1),transform 75ms cubic-bezier(0.4, 0, 1, 1)}.snackbar.snackbar-open .snackbar-surface{opacity:1;transform:none;pointer-events:auto;transition:opacity 150ms cubic-bezier(0, 0, 0.2, 1),transform 150ms cubic-bezier(0, 0, 0.2, 1)}@starting-style{.snackbar.snackbar-open .snackbar-surface{opacity:0;transform:scaleY(0)}}.snackbar.snackbar-closing .snackbar-surface{opacity:0;transform:none;pointer-events:none;transition:opacity 75ms cubic-bezier(0.4, 0, 1, 1)}@media(prefers-reduced-motion: reduce){.snackbar-surface{transition-duration:.001ms}}.snackbar-content{--_actions-chrome: 0px;flex:1 1 auto;display:flex;flex-wrap:wrap;align-items:center;row-gap:0;padding-inline:16px;padding-block:0 4px;inline-size:100%;box-sizing:border-box}.snackbar-content:is(:has(slot[name=action].has-slotted),:has(.snackbar-action)):not(:has(slot[name=dismiss].has-slotted),:has(.snackbar-dismiss)){--_actions-chrome: 4px;padding-inline-end:8px}.snackbar-content:is(:has(slot[name=dismiss].has-slotted),:has(.snackbar-dismiss)){padding-inline-end:0}.snackbar-content:is(:has(slot[name=action].has-slotted),:has(.snackbar-action)):is(:has(slot[name=dismiss].has-slotted),:has(.snackbar-dismiss)){--_actions-chrome: 48px}.snackbar-label{color:var(--supporting-text-color);font:var(--supporting-text);letter-spacing:var(--supporting-text-tracking);font-variation-settings:var(--supporting-text-axes);box-sizing:border-box;padding-block:14px;margin:0;margin-block-end:-4px;overflow-wrap:anywhere}.snackbar-actions{flex:none;display:flex;align-items:center;gap:0;margin-inline-start:auto;box-sizing:border-box}.snackbar-actions:is(:has(slot[name=action].has-slotted),:has(.snackbar-action)):not(:has(slot[name=dismiss].has-slotted),:has(.snackbar-dismiss)){margin-block-start:4px}.snackbar-actions:is(:has(slot[name=dismiss].has-slotted),:has(.snackbar-dismiss)){margin-block-end:-4px;margin-inline-end:-4px}.snackbar-actions:not(:has(slot[name=action].has-slotted),:has(.snackbar-action),:has(slot[name=dismiss].has-slotted),:has(.snackbar-dismiss)){display:none}@container snackbar (inline-size < 600px){.snackbar-surface{inline-size:calc(100% - 32px);margin-inline:16px}.snackbar-label{flex:1 1 0;min-inline-size:calc(70% - var(--_actions-chrome))}}@container snackbar (inline-size >= 600px){.snackbar-surface{inline-size:fit-content;min-inline-size:var(--min-width);max-inline-size:min(var(--max-width),100% - 32px);margin-inline:auto}.snackbar-label{flex:1 1 calc(.7*(min(var(--max-width),100cqi - 32px) - 32px) - var(--_actions-chrome));max-inline-size:max-content;min-inline-size:0}}.snackbar-actions ::slotted([slot=action]){margin-inline-start:4px}.snackbar-action{--leading-space: 12px;--trailing-space: 12px;--outline-width: 0;--label-text-color: var(--action-label-text-color);--icon-color: var(--action-label-text-color);--label-text: var(--action-label-text);--label-text-axes: var(--action-label-text-axes);--label-text-tracking: var(--action-label-text-tracking);margin-inline-start:4px;white-space:nowrap;-webkit-tap-highlight-color:rgba(0,0,0,0)}.snackbar-action:is(:active,.active),.snackbar-dismiss:is(:active,.active){--container-shape: calc(var(--container-height) / 2)}.snackbar-actions ::slotted(md-gb-button[slot=action]){--md-sys-color-primary: var(--action-label-text-color);--md-sys-typescale-label-lg: var(--action-label-text);--md-sys-typescale-label-lg-axes: var(--action-label-text-axes);--md-sys-typescale-label-lg-tracking: var(--action-label-text-tracking)}.snackbar-actions ::slotted([slot=action]:not(md-gb-button)){color:var(--action-label-text-color);background:rgba(0,0,0,0);border:none;font:var(--action-label-text);letter-spacing:var(--action-label-text-tracking);font-variation-settings:var(--action-label-text-axes);cursor:pointer;padding-inline:12px;block-size:40px;border-radius:100px;display:inline-flex;align-items:center;justify-content:center;box-sizing:border-box;text-transform:none;outline:none;white-space:nowrap}.snackbar-actions ::slotted([slot=action]:not(md-gb-button):disabled){cursor:default}.snackbar-actions ::slotted([slot=action]:not(md-gb-button):not(:disabled):hover){background-color:hsl(from var(--action-label-text-color) h s l/8%)}.snackbar-actions ::slotted([slot=action]:not(md-gb-button):focus-visible){outline:3px solid var(--md-sys-color-secondary);outline-offset:2px}.snackbar-actions ::slotted([slot=action]:not(md-gb-button):not(:disabled):active){background-color:hsl(from var(--action-label-text-color) h s l/10%)}.snackbar-dismiss{--icon-color: var(--_close-icon-color);--icon-size: var(--_close-icon-size);--outline-width: 0;position:relative;flex-shrink:0;box-sizing:border-box;margin:4px;padding:0;-webkit-tap-highlight-color:rgba(0,0,0,0)}.snackbar-dismiss::after{content:\"\";position:absolute;inset:-4px}.snackbar-dismiss svg{inline-size:var(--icon-size);block-size:var(--icon-size);fill:currentColor}}\n`;\nexport default styles.styleSheet!;\n"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
/**
|
|
8
|
+
* Standard reasons for closing a snackbar.
|
|
9
|
+
*/
|
|
10
|
+
export declare const CLOSE_REASONS: {
|
|
11
|
+
readonly ACTION: "action";
|
|
12
|
+
readonly DISMISS: "dismiss";
|
|
13
|
+
readonly TIMEOUT: "timeout";
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Close reason type.
|
|
17
|
+
*/
|
|
18
|
+
export type CloseReason = (typeof CLOSE_REASONS)[keyof typeof CLOSE_REASONS] | string;
|
|
19
|
+
/**
|
|
20
|
+
* Snackbar CSS classes.
|
|
21
|
+
*/
|
|
22
|
+
export declare const SNACKBAR_CLASSES: {
|
|
23
|
+
readonly snackbar: "snackbar";
|
|
24
|
+
readonly open: "snackbar-open";
|
|
25
|
+
readonly opening: "snackbar-opening";
|
|
26
|
+
readonly closing: "snackbar-closing";
|
|
27
|
+
readonly fixed: "snackbar-fixed";
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* State provided to `snackbarClasses()`.
|
|
31
|
+
*/
|
|
32
|
+
export interface SnackbarClassesState {
|
|
33
|
+
open?: boolean;
|
|
34
|
+
opening?: boolean;
|
|
35
|
+
closing?: boolean;
|
|
36
|
+
fixed?: boolean;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Returns the class map object for the snackbar based on given state.
|
|
40
|
+
*/
|
|
41
|
+
export declare function snackbarClasses({ open, opening, closing, fixed, }?: SnackbarClassesState): ClassInfo;
|
|
42
|
+
/**
|
|
43
|
+
* Sets up snackbar accessibility and keydown behavior on an element.
|
|
44
|
+
*
|
|
45
|
+
* @param snackbar The snackbar root element.
|
|
46
|
+
* @param opts Options, supports AbortSignal for cleanup.
|
|
47
|
+
*/
|
|
48
|
+
export declare function setupSnackbar(snackbar: HTMLElement, opts?: {
|
|
49
|
+
signal?: AbortSignal;
|
|
50
|
+
}): void;
|
|
51
|
+
/**
|
|
52
|
+
* A Lit directive that adds snackbar classes and setup logic to an element.
|
|
53
|
+
*/
|
|
54
|
+
export declare const snackbar: (state?: SnackbarClassesState & import("../shared/directives.js").AdditionalClasses) => import("lit-html/directive.js").DirectiveResult;
|