@spectrum-web-components/toast 0.10.13 → 0.10.14-devmode.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/package.json +23 -10
- package/sp-toast.dev.js +3 -0
- package/sp-toast.dev.js.map +7 -0
- package/sp-toast.js +3 -14
- package/sp-toast.js.map +7 -1
- package/src/Toast.dev.js +191 -0
- package/src/Toast.dev.js.map +7 -0
- package/src/Toast.js +151 -180
- package/src/Toast.js.map +7 -1
- package/src/index.dev.js +2 -0
- package/src/index.dev.js.map +7 -0
- package/src/index.js +2 -13
- package/src/index.js.map +7 -1
- package/src/spectrum-toast.css.dev.js +90 -0
- package/src/spectrum-toast.css.dev.js.map +7 -0
- package/src/spectrum-toast.css.js +3 -14
- package/src/spectrum-toast.css.js.map +7 -1
- package/src/toast.css.dev.js +90 -0
- package/src/toast.css.dev.js.map +7 -0
- package/src/toast.css.js +3 -14
- package/src/toast.css.js.map +7 -1
- package/stories/toast.stories.js +52 -51
- package/stories/toast.stories.js.map +7 -1
- package/test/benchmark/test-basic.js +5 -16
- package/test/benchmark/test-basic.js.map +7 -1
- package/test/toast.test-vrt.js +4 -15
- package/test/toast.test-vrt.js.map +7 -1
- package/test/toast.test.js +157 -161
- package/test/toast.test.js.map +7 -1
package/src/Toast.js
CHANGED
|
@@ -1,173 +1,146 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
+
if (decorator = decorators[i])
|
|
7
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
+
if (kind && result)
|
|
9
|
+
__defProp(target, key, result);
|
|
10
|
+
return result;
|
|
11
|
+
};
|
|
12
|
+
import {
|
|
13
|
+
html,
|
|
14
|
+
SpectrumElement
|
|
15
|
+
} from "@spectrum-web-components/base";
|
|
16
|
+
import { property } from "@spectrum-web-components/base/src/decorators.js";
|
|
17
|
+
import "@spectrum-web-components/button/sp-close-button.js";
|
|
18
|
+
import "@spectrum-web-components/icons-workflow/icons/sp-icon-alert.js";
|
|
19
|
+
import "@spectrum-web-components/icons-workflow/icons/sp-icon-info.js";
|
|
20
|
+
import "@spectrum-web-components/icons-workflow/icons/sp-icon-checkmark-circle.js";
|
|
21
|
+
import toastStyles from "./toast.css.js";
|
|
20
22
|
export const toastVariants = [
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
"negative",
|
|
24
|
+
"positive",
|
|
25
|
+
"info",
|
|
26
|
+
"error",
|
|
27
|
+
"warning"
|
|
26
28
|
];
|
|
27
|
-
/**
|
|
28
|
-
* @element sp-toast
|
|
29
|
-
*
|
|
30
|
-
* @slot - The toast content
|
|
31
|
-
* @slot action - button element surfacing an action in the Toast
|
|
32
|
-
*
|
|
33
|
-
* @fires close - Announces that the Toast has been closed by the user or by its timeout.
|
|
34
|
-
*/
|
|
35
29
|
export class Toast extends SpectrumElement {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
30
|
+
constructor() {
|
|
31
|
+
super(...arguments);
|
|
32
|
+
this.open = false;
|
|
33
|
+
this._timeout = null;
|
|
34
|
+
this._variant = "";
|
|
35
|
+
this.countdownStart = 0;
|
|
36
|
+
this.nextCount = -1;
|
|
37
|
+
this.doCountdown = (time) => {
|
|
38
|
+
if (!this.countdownStart) {
|
|
39
|
+
this.countdownStart = performance.now();
|
|
40
|
+
}
|
|
41
|
+
if (time - this.countdownStart > this._timeout) {
|
|
42
|
+
this.shouldClose();
|
|
41
43
|
this.countdownStart = 0;
|
|
42
|
-
|
|
43
|
-
this.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
static get styles() {
|
|
69
|
-
return [toastStyles];
|
|
44
|
+
} else {
|
|
45
|
+
this.countdown();
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
this.countdown = () => {
|
|
49
|
+
cancelAnimationFrame(this.nextCount);
|
|
50
|
+
this.nextCount = requestAnimationFrame(this.doCountdown);
|
|
51
|
+
};
|
|
52
|
+
this.holdCountdown = () => {
|
|
53
|
+
this.stopCountdown();
|
|
54
|
+
this.addEventListener("focusout", this.resumeCountdown);
|
|
55
|
+
};
|
|
56
|
+
this.resumeCountdown = () => {
|
|
57
|
+
this.removeEventListener("focusout", this.holdCountdown);
|
|
58
|
+
this.countdown();
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
static get styles() {
|
|
62
|
+
return [toastStyles];
|
|
63
|
+
}
|
|
64
|
+
set timeout(timeout) {
|
|
65
|
+
const hasTimeout = typeof timeout !== null && timeout > 0;
|
|
66
|
+
const newTimeout = hasTimeout ? Math.max(6e3, timeout) : null;
|
|
67
|
+
const oldValue = this.timeout;
|
|
68
|
+
if (newTimeout && this.countdownStart) {
|
|
69
|
+
this.countdownStart = performance.now();
|
|
70
70
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
* @param {Number} timeout
|
|
81
|
-
*/
|
|
82
|
-
set timeout(timeout) {
|
|
83
|
-
const hasTimeout = typeof timeout !== null && timeout > 0;
|
|
84
|
-
const newTimeout = hasTimeout
|
|
85
|
-
? Math.max(6000, timeout)
|
|
86
|
-
: null;
|
|
87
|
-
const oldValue = this.timeout;
|
|
88
|
-
if (newTimeout && this.countdownStart) {
|
|
89
|
-
this.countdownStart = performance.now();
|
|
90
|
-
}
|
|
91
|
-
this._timeout = newTimeout;
|
|
92
|
-
this.requestUpdate('timeout', oldValue);
|
|
71
|
+
this._timeout = newTimeout;
|
|
72
|
+
this.requestUpdate("timeout", oldValue);
|
|
73
|
+
}
|
|
74
|
+
get timeout() {
|
|
75
|
+
return this._timeout;
|
|
76
|
+
}
|
|
77
|
+
set variant(variant) {
|
|
78
|
+
if (variant === this.variant) {
|
|
79
|
+
return;
|
|
93
80
|
}
|
|
94
|
-
|
|
95
|
-
|
|
81
|
+
const oldValue = this.variant;
|
|
82
|
+
if (toastVariants.includes(variant)) {
|
|
83
|
+
this.setAttribute("variant", variant);
|
|
84
|
+
this._variant = variant;
|
|
85
|
+
} else {
|
|
86
|
+
this.removeAttribute("variant");
|
|
87
|
+
this._variant = "";
|
|
96
88
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
const oldValue = this.variant;
|
|
108
|
-
if (toastVariants.includes(variant)) {
|
|
109
|
-
this.setAttribute('variant', variant);
|
|
110
|
-
this._variant = variant;
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
this.removeAttribute('variant');
|
|
114
|
-
this._variant = '';
|
|
115
|
-
}
|
|
116
|
-
this.requestUpdate('variant', oldValue);
|
|
117
|
-
}
|
|
118
|
-
get variant() {
|
|
119
|
-
return this._variant;
|
|
120
|
-
}
|
|
121
|
-
renderIcon(variant) {
|
|
122
|
-
switch (variant) {
|
|
123
|
-
case 'info':
|
|
124
|
-
return html `
|
|
89
|
+
this.requestUpdate("variant", oldValue);
|
|
90
|
+
}
|
|
91
|
+
get variant() {
|
|
92
|
+
return this._variant;
|
|
93
|
+
}
|
|
94
|
+
renderIcon(variant) {
|
|
95
|
+
switch (variant) {
|
|
96
|
+
case "info":
|
|
97
|
+
return html`
|
|
125
98
|
<sp-icon-info
|
|
126
99
|
label="Information"
|
|
127
100
|
class="type"
|
|
128
101
|
></sp-icon-info>
|
|
129
102
|
`;
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
103
|
+
case "negative":
|
|
104
|
+
case "error":
|
|
105
|
+
case "warning":
|
|
106
|
+
return html`
|
|
134
107
|
<sp-icon-alert label="Error" class="type"></sp-icon-alert>
|
|
135
108
|
`;
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
109
|
+
case "positive":
|
|
110
|
+
case "success":
|
|
111
|
+
return html`
|
|
139
112
|
<sp-icon-checkmark-circle
|
|
140
113
|
label="Success"
|
|
141
114
|
class="type"
|
|
142
115
|
></sp-icon-checkmark-circle>
|
|
143
116
|
`;
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
117
|
+
default:
|
|
118
|
+
return html``;
|
|
147
119
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
close() {
|
|
167
|
-
this.open = false;
|
|
120
|
+
}
|
|
121
|
+
startCountdown() {
|
|
122
|
+
this.countdown();
|
|
123
|
+
this.addEventListener("focusin", this.holdCountdown);
|
|
124
|
+
}
|
|
125
|
+
stopCountdown() {
|
|
126
|
+
cancelAnimationFrame(this.nextCount);
|
|
127
|
+
this.countdownStart = 0;
|
|
128
|
+
}
|
|
129
|
+
shouldClose() {
|
|
130
|
+
const applyDefault = this.dispatchEvent(new CustomEvent("close", {
|
|
131
|
+
composed: true,
|
|
132
|
+
bubbles: true,
|
|
133
|
+
cancelable: true
|
|
134
|
+
}));
|
|
135
|
+
if (applyDefault) {
|
|
136
|
+
this.close();
|
|
168
137
|
}
|
|
169
|
-
|
|
170
|
-
|
|
138
|
+
}
|
|
139
|
+
close() {
|
|
140
|
+
this.open = false;
|
|
141
|
+
}
|
|
142
|
+
render() {
|
|
143
|
+
return html`
|
|
171
144
|
${this.renderIcon(this.variant)}
|
|
172
145
|
<div class="body" role="alert">
|
|
173
146
|
<div class="content">
|
|
@@ -183,38 +156,36 @@ export class Toast extends SpectrumElement {
|
|
|
183
156
|
></sp-close-button>
|
|
184
157
|
</div>
|
|
185
158
|
`;
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
else {
|
|
196
|
-
if (this.timeout) {
|
|
197
|
-
this.stopCountdown();
|
|
198
|
-
}
|
|
199
|
-
}
|
|
159
|
+
}
|
|
160
|
+
updated(changes) {
|
|
161
|
+
super.updated(changes);
|
|
162
|
+
if (changes.has("open")) {
|
|
163
|
+
if (this.open) {
|
|
164
|
+
if (this.timeout) {
|
|
165
|
+
this.startCountdown();
|
|
200
166
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
}
|
|
205
|
-
else {
|
|
206
|
-
this.stopCountdown();
|
|
207
|
-
}
|
|
167
|
+
} else {
|
|
168
|
+
if (this.timeout) {
|
|
169
|
+
this.stopCountdown();
|
|
208
170
|
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (changes.has("timeout")) {
|
|
174
|
+
if (this.timeout !== null && this.open) {
|
|
175
|
+
this.startCountdown();
|
|
176
|
+
} else {
|
|
177
|
+
this.stopCountdown();
|
|
178
|
+
}
|
|
209
179
|
}
|
|
180
|
+
}
|
|
210
181
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
], Toast.prototype, "open",
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
], Toast.prototype, "timeout",
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
], Toast.prototype, "variant",
|
|
220
|
-
//# sourceMappingURL=Toast.js.map
|
|
182
|
+
__decorateClass([
|
|
183
|
+
property({ type: Boolean, reflect: true })
|
|
184
|
+
], Toast.prototype, "open", 2);
|
|
185
|
+
__decorateClass([
|
|
186
|
+
property({ type: Number })
|
|
187
|
+
], Toast.prototype, "timeout", 1);
|
|
188
|
+
__decorateClass([
|
|
189
|
+
property({ type: String })
|
|
190
|
+
], Toast.prototype, "variant", 1);
|
|
191
|
+
//# sourceMappingURL=Toast.js.map
|
package/src/Toast.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{"version":3,"file":"Toast.js","sourceRoot":"","sources":["Toast.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;;AAEF,OAAO,EAEH,IAAI,EAEJ,eAAe,GAElB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,iDAAiD,CAAC;AAC3E,OAAO,oDAAoD,CAAC;AAC5D,OAAO,gEAAgE,CAAC;AACxE,OAAO,+DAA+D,CAAC;AACvE,OAAO,2EAA2E,CAAC;AAEnF,OAAO,WAAW,MAAM,gBAAgB,CAAC;AAEzC,MAAM,CAAC,MAAM,aAAa,GAAoB;IAC1C,UAAU;IACV,UAAU;IACV,MAAM;IACN,OAAO;IACP,SAAS;CACZ,CAAC;AAUF;;;;;;;GAOG;AAEH,MAAM,OAAO,KAAM,SAAQ,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;aACJ;iBAAM;gBACH,IAAI,IAAI,CAAC,OAAO,EAAE;oBACd,IAAI,CAAC,aAAa,EAAE,CAAC;iBACxB;aACJ;SACJ;QACD,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;YACxB,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE;gBACpC,IAAI,CAAC,cAAc,EAAE,CAAC;aACzB;iBAAM;gBACH,IAAI,CAAC,aAAa,EAAE,CAAC;aACxB;SACJ;IACL,CAAC;CACJ;AA1LG;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;mCACvB;AAcpB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oCAY1B;AAeD;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oCAc1B","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n html,\n PropertyValues,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\nimport '@spectrum-web-components/button/sp-close-button.js';\nimport '@spectrum-web-components/icons-workflow/icons/sp-icon-alert.js';\nimport '@spectrum-web-components/icons-workflow/icons/sp-icon-info.js';\nimport '@spectrum-web-components/icons-workflow/icons/sp-icon-checkmark-circle.js';\n\nimport toastStyles from './toast.css.js';\n\nexport const toastVariants: ToastVariants[] = [\n 'negative',\n 'positive',\n 'info',\n 'error',\n 'warning',\n];\n\nexport type ToastVariants =\n | 'negative'\n | 'positive'\n | 'info'\n | 'error'\n | 'warning'\n | '';\n\n/**\n * @element sp-toast\n *\n * @slot - The toast content\n * @slot action - button element surfacing an action in the Toast\n *\n * @fires close - Announces that the Toast has been closed by the user or by its timeout.\n */\n\nexport class Toast extends SpectrumElement {\n public static override get styles(): CSSResultArray {\n return [toastStyles];\n }\n\n @property({ type: Boolean, reflect: true })\n public open = false;\n\n /**\n * When a timeout is provided it represents the number of milliseconds from when\n * the Toast was placed on the page before it will automatically dismiss itself.\n * Accessibility concerns require that a Toast is available for at least 6000ms\n * before being dismissed, so any timeout of less than 6000ms will be raised to\n * that baseline. It is suggested that messages longer than 120 words should\n * receive another 1000ms in their timeout for each additional 120 words in the\n * message. E.G. 240 words = 7000ms, 360 words = 8000ms, etc.\n *\n * @param {Number} timeout\n */\n @property({ type: Number })\n public set timeout(timeout: number | null) {\n const hasTimeout = typeof timeout !== null && (timeout as number) > 0;\n const newTimeout = hasTimeout\n ? Math.max(6000, timeout as number)\n : null;\n const oldValue = this.timeout;\n if (newTimeout && this.countdownStart) {\n this.countdownStart = performance.now();\n }\n this._timeout = newTimeout;\n this.requestUpdate('timeout', oldValue);\n }\n\n public get timeout(): number | null {\n return this._timeout;\n }\n\n public _timeout: number | null = null;\n\n /**\n * The variant applies specific styling when set to `negative`, `positive`, `info`, `error`, or `warning`.\n * `variant` attribute is removed when not matching one of the above.\n *\n * @param {String} variant\n */\n @property({ type: String })\n public set variant(variant: ToastVariants) {\n if (variant === this.variant) {\n return;\n }\n const oldValue = this.variant;\n if (toastVariants.includes(variant)) {\n this.setAttribute('variant', variant);\n this._variant = variant;\n } else {\n this.removeAttribute('variant');\n this._variant = '';\n }\n this.requestUpdate('variant', oldValue);\n }\n\n public get variant(): ToastVariants {\n return this._variant;\n }\n\n private _variant: ToastVariants = '';\n\n private renderIcon(variant: string): TemplateResult {\n switch (variant) {\n case 'info':\n return html`\n <sp-icon-info\n label=\"Information\"\n class=\"type\"\n ></sp-icon-info>\n `;\n case 'negative':\n case 'error': // deprecated\n case 'warning': // deprecated\n return html`\n <sp-icon-alert label=\"Error\" class=\"type\"></sp-icon-alert>\n `;\n case 'positive':\n case 'success': // deprecated\n return html`\n <sp-icon-checkmark-circle\n label=\"Success\"\n class=\"type\"\n ></sp-icon-checkmark-circle>\n `;\n default:\n return html``;\n }\n }\n\n private countdownStart = 0;\n private nextCount = -1;\n\n private doCountdown = (time: number): void => {\n if (!this.countdownStart) {\n this.countdownStart = performance.now();\n }\n if (time - this.countdownStart > (this._timeout as number)) {\n this.shouldClose();\n this.countdownStart = 0;\n } else {\n this.countdown();\n }\n };\n\n private countdown = (): void => {\n cancelAnimationFrame(this.nextCount);\n this.nextCount = requestAnimationFrame(this.doCountdown);\n };\n\n private holdCountdown = (): void => {\n this.stopCountdown();\n this.addEventListener('focusout', this.resumeCountdown);\n };\n\n private resumeCountdown = (): void => {\n this.removeEventListener('focusout', this.holdCountdown);\n this.countdown();\n };\n\n private startCountdown(): void {\n this.countdown();\n this.addEventListener('focusin', this.holdCountdown);\n }\n\n private stopCountdown(): void {\n cancelAnimationFrame(this.nextCount);\n this.countdownStart = 0;\n }\n\n private shouldClose(): void {\n const applyDefault = this.dispatchEvent(\n new CustomEvent('close', {\n composed: true,\n bubbles: true,\n cancelable: true,\n })\n );\n if (applyDefault) {\n this.close();\n }\n }\n\n public close(): void {\n this.open = false;\n }\n\n protected override render(): TemplateResult {\n return html`\n ${this.renderIcon(this.variant)}\n <div class=\"body\" role=\"alert\">\n <div class=\"content\">\n <slot></slot>\n </div>\n <slot name=\"action\"></slot>\n </div>\n <div class=\"buttons\">\n <sp-close-button\n @click=${this.shouldClose}\n label=\"Close\"\n variant=\"white\"\n ></sp-close-button>\n </div>\n `;\n }\n\n protected override updated(changes: PropertyValues): void {\n super.updated(changes);\n if (changes.has('open')) {\n if (this.open) {\n if (this.timeout) {\n this.startCountdown();\n }\n } else {\n if (this.timeout) {\n this.stopCountdown();\n }\n }\n }\n if (changes.has('timeout')) {\n if (this.timeout !== null && this.open) {\n this.startCountdown();\n } else {\n this.stopCountdown();\n }\n }\n }\n}\n"]}
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["Toast.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n html,\n PropertyValues,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\nimport '@spectrum-web-components/button/sp-close-button.js';\nimport '@spectrum-web-components/icons-workflow/icons/sp-icon-alert.js';\nimport '@spectrum-web-components/icons-workflow/icons/sp-icon-info.js';\nimport '@spectrum-web-components/icons-workflow/icons/sp-icon-checkmark-circle.js';\n\nimport toastStyles from './toast.css.js';\n\nexport const toastVariants: ToastVariants[] = [\n 'negative',\n 'positive',\n 'info',\n 'error',\n 'warning',\n];\n\nexport type ToastVariants =\n | 'negative'\n | 'positive'\n | 'info'\n | 'error'\n | 'warning'\n | '';\n\n/**\n * @element sp-toast\n *\n * @slot - The toast content\n * @slot action - button element surfacing an action in the Toast\n *\n * @fires close - Announces that the Toast has been closed by the user or by its timeout.\n */\n\nexport class Toast extends SpectrumElement {\n public static override get styles(): CSSResultArray {\n return [toastStyles];\n }\n\n @property({ type: Boolean, reflect: true })\n public open = false;\n\n /**\n * When a timeout is provided it represents the number of milliseconds from when\n * the Toast was placed on the page before it will automatically dismiss itself.\n * Accessibility concerns require that a Toast is available for at least 6000ms\n * before being dismissed, so any timeout of less than 6000ms will be raised to\n * that baseline. It is suggested that messages longer than 120 words should\n * receive another 1000ms in their timeout for each additional 120 words in the\n * message. E.G. 240 words = 7000ms, 360 words = 8000ms, etc.\n *\n * @param {Number} timeout\n */\n @property({ type: Number })\n public set timeout(timeout: number | null) {\n const hasTimeout = typeof timeout !== null && (timeout as number) > 0;\n const newTimeout = hasTimeout\n ? Math.max(6000, timeout as number)\n : null;\n const oldValue = this.timeout;\n if (newTimeout && this.countdownStart) {\n this.countdownStart = performance.now();\n }\n this._timeout = newTimeout;\n this.requestUpdate('timeout', oldValue);\n }\n\n public get timeout(): number | null {\n return this._timeout;\n }\n\n public _timeout: number | null = null;\n\n /**\n * The variant applies specific styling when set to `negative`, `positive`, `info`, `error`, or `warning`.\n * `variant` attribute is removed when not matching one of the above.\n *\n * @param {String} variant\n */\n @property({ type: String })\n public set variant(variant: ToastVariants) {\n if (variant === this.variant) {\n return;\n }\n const oldValue = this.variant;\n if (toastVariants.includes(variant)) {\n this.setAttribute('variant', variant);\n this._variant = variant;\n } else {\n this.removeAttribute('variant');\n this._variant = '';\n }\n this.requestUpdate('variant', oldValue);\n }\n\n public get variant(): ToastVariants {\n return this._variant;\n }\n\n private _variant: ToastVariants = '';\n\n private renderIcon(variant: string): TemplateResult {\n switch (variant) {\n case 'info':\n return html`\n <sp-icon-info\n label=\"Information\"\n class=\"type\"\n ></sp-icon-info>\n `;\n case 'negative':\n case 'error': // deprecated\n case 'warning': // deprecated\n return html`\n <sp-icon-alert label=\"Error\" class=\"type\"></sp-icon-alert>\n `;\n case 'positive':\n case 'success': // deprecated\n return html`\n <sp-icon-checkmark-circle\n label=\"Success\"\n class=\"type\"\n ></sp-icon-checkmark-circle>\n `;\n default:\n return html``;\n }\n }\n\n private countdownStart = 0;\n private nextCount = -1;\n\n private doCountdown = (time: number): void => {\n if (!this.countdownStart) {\n this.countdownStart = performance.now();\n }\n if (time - this.countdownStart > (this._timeout as number)) {\n this.shouldClose();\n this.countdownStart = 0;\n } else {\n this.countdown();\n }\n };\n\n private countdown = (): void => {\n cancelAnimationFrame(this.nextCount);\n this.nextCount = requestAnimationFrame(this.doCountdown);\n };\n\n private holdCountdown = (): void => {\n this.stopCountdown();\n this.addEventListener('focusout', this.resumeCountdown);\n };\n\n private resumeCountdown = (): void => {\n this.removeEventListener('focusout', this.holdCountdown);\n this.countdown();\n };\n\n private startCountdown(): void {\n this.countdown();\n this.addEventListener('focusin', this.holdCountdown);\n }\n\n private stopCountdown(): void {\n cancelAnimationFrame(this.nextCount);\n this.countdownStart = 0;\n }\n\n private shouldClose(): void {\n const applyDefault = this.dispatchEvent(\n new CustomEvent('close', {\n composed: true,\n bubbles: true,\n cancelable: true,\n })\n );\n if (applyDefault) {\n this.close();\n }\n }\n\n public close(): void {\n this.open = false;\n }\n\n protected override render(): TemplateResult {\n return html`\n ${this.renderIcon(this.variant)}\n <div class=\"body\" role=\"alert\">\n <div class=\"content\">\n <slot></slot>\n </div>\n <slot name=\"action\"></slot>\n </div>\n <div class=\"buttons\">\n <sp-close-button\n @click=${this.shouldClose}\n label=\"Close\"\n variant=\"white\"\n ></sp-close-button>\n </div>\n `;\n }\n\n protected override updated(changes: PropertyValues): void {\n super.updated(changes);\n if (changes.has('open')) {\n if (this.open) {\n if (this.timeout) {\n this.startCountdown();\n }\n } else {\n if (this.timeout) {\n this.stopCountdown();\n }\n }\n }\n if (changes.has('timeout')) {\n if (this.timeout !== null && this.open) {\n this.startCountdown();\n } else {\n this.stopCountdown();\n }\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;AAYA;AAAA;AAAA;AAAA;AAOA;AACA;AACA;AACA;AACA;AAEA;AAEO,aAAM,gBAAiC;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ;AAmBO,aAAM,cAAc,gBAAgB;AAAA,EAApC;AAAA;AAMI,gBAAO;AA+BP,oBAA0B;AA4BzB,oBAA0B;AA8B1B,0BAAiB;AACjB,qBAAY;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MAAM;AACpC,aAAK,eAAe;AAAA,MACxB,OAAO;AACH,aAAK,cAAc;AAAA,MACvB;AAAA,IACJ;AAAA,EACJ;AACJ;AA1LW;AAAA,EADP,AAAC,SAAS,EAAE,MAAM,SAAS,SAAS,KAAK,CAAC;AAAA,GACnC,AANJ,MAMI;AAcI;AAAA,EADX,AAAC,SAAS,EAAE,MAAM,OAAO,CAAC;AAAA,GACf,AApBR,MAoBQ;AA0BA;AAAA,EADX,AAAC,SAAS,EAAE,MAAM,OAAO,CAAC;AAAA,GACf,AA9CR,MA8CQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/src/index.dev.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["index.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nexport * from './Toast.dev.js'\n"],
|
|
5
|
+
"mappings": "AAWA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/src/index.js
CHANGED
|
@@ -1,13 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
|
|
7
|
-
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
export * from './Toast.js';
|
|
13
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export * from "./Toast.js";
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["index.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nexport * from './Toast.js';\n"],
|
|
5
|
+
"mappings": "AAWA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { css } from "@spectrum-web-components/base";
|
|
2
|
+
const styles = css`
|
|
3
|
+
:host{--spectrum-toast-icon-padding-y:var(
|
|
4
|
+
--spectrum-global-dimension-size-85
|
|
5
|
+
);--spectrum-toast-neutral-content-padding-top:var(
|
|
6
|
+
--spectrum-global-dimension-size-65
|
|
7
|
+
);--spectrum-toast-content-padding-bottom:var(
|
|
8
|
+
--spectrum-global-dimension-size-65
|
|
9
|
+
);--spectrum-toast-button-margin-right:var(
|
|
10
|
+
--spectrum-global-dimension-size-130
|
|
11
|
+
)}:host([dir=ltr]){padding-right:var(
|
|
12
|
+
--spectrum-toast-neutral-padding-right,var(--spectrum-global-dimension-size-100)
|
|
13
|
+
)}:host([dir=rtl]){padding-left:var(
|
|
14
|
+
--spectrum-toast-neutral-padding-right,var(--spectrum-global-dimension-size-100)
|
|
15
|
+
)}:host([dir=ltr]){padding-left:var(
|
|
16
|
+
--spectrum-toast-neutral-padding-left,var(--spectrum-global-dimension-size-200)
|
|
17
|
+
)}:host([dir=rtl]){padding-right:var(
|
|
18
|
+
--spectrum-toast-neutral-padding-left,var(--spectrum-global-dimension-size-200)
|
|
19
|
+
)}:host{-webkit-font-smoothing:antialiased;align-items:stretch;border-radius:var(
|
|
20
|
+
--spectrum-toast-neutral-border-radius,var(--spectrum-alias-border-radius-regular)
|
|
21
|
+
);box-sizing:border-box;display:inline-flex;flex-direction:row;font-size:var(
|
|
22
|
+
--spectrum-toast-neutral-text-size,var(--spectrum-global-dimension-font-size-100)
|
|
23
|
+
);font-weight:var(
|
|
24
|
+
--spectrum-toast-neutral-text-font-weight,var(--spectrum-alias-body-text-font-weight)
|
|
25
|
+
);padding-bottom:var(
|
|
26
|
+
--spectrum-toast-neutral-padding-y,var(--spectrum-global-dimension-size-100)
|
|
27
|
+
);padding-top:var(
|
|
28
|
+
--spectrum-toast-neutral-padding-y,var(--spectrum-global-dimension-size-100)
|
|
29
|
+
)}:host([dir=ltr]) .type{margin-right:var(
|
|
30
|
+
--spectrum-toast-neutral-icon-padding-right,var(--spectrum-global-dimension-size-150)
|
|
31
|
+
)}:host([dir=rtl]) .type{margin-left:var(
|
|
32
|
+
--spectrum-toast-neutral-icon-padding-right,var(--spectrum-global-dimension-size-150)
|
|
33
|
+
)}:host([dir=ltr]) .type{margin-left:0}:host([dir=rtl]) .type{margin-right:0}.type{flex-grow:0;flex-shrink:0;margin-bottom:var(--spectrum-toast-icon-padding-y);margin-top:var(--spectrum-toast-icon-padding-y)}:host([dir=ltr]) .content{padding-right:var(
|
|
34
|
+
--spectrum-toast-neutral-content-padding-right,var(--spectrum-global-dimension-size-200)
|
|
35
|
+
)}:host([dir=rtl]) .content{padding-left:var(
|
|
36
|
+
--spectrum-toast-neutral-content-padding-right,var(--spectrum-global-dimension-size-200)
|
|
37
|
+
)}:host([dir=ltr]) .content{padding-left:0}:host([dir=rtl]) .content{padding-right:0}:host([dir=ltr]) .content{text-align:left}:host([dir=rtl]) .content{text-align:right}.content{box-sizing:border-box;display:inline-block;flex:1 1 auto;font-size:var(
|
|
38
|
+
--spectrum-toast-info-text-size,var(--spectrum-global-dimension-font-size-100)
|
|
39
|
+
);font-weight:var(
|
|
40
|
+
--spectrum-toast-info-text-font-weight,var(--spectrum-alias-body-text-font-weight)
|
|
41
|
+
);line-height:var(
|
|
42
|
+
--spectrum-toast-info-text-line-height,var(--spectrum-alias-component-text-line-height)
|
|
43
|
+
);padding-bottom:var(--spectrum-toast-content-padding-bottom);padding-top:var(
|
|
44
|
+
--spectrum-toast-neutral-content-padding-top,var(--spectrum-global-dimension-size-65)
|
|
45
|
+
)}.buttons{align-items:flex-start;display:flex;flex:0 0 auto}:host([dir=ltr]) .buttons .spectrum-ClearButton+.spectrum-ClearButton,:host([dir=ltr]) .buttons .spectrum-ClearButton+::slotted([slot=action]),:host([dir=ltr]) .buttons slot[name=action]+.spectrum-ClearButton,:host([dir=ltr]) .buttons slot[name=action]+::slotted([slot=action]){margin-left:var(
|
|
46
|
+
--spectrum-toast-neutral-button-gap-x,var(--spectrum-global-dimension-size-100)
|
|
47
|
+
)}:host([dir=rtl]) .buttons .spectrum-ClearButton+.spectrum-ClearButton,:host([dir=rtl]) .buttons .spectrum-ClearButton+::slotted([slot=action]),:host([dir=rtl]) .buttons slot[name=action]+.spectrum-ClearButton,:host([dir=rtl]) .buttons slot[name=action]+::slotted([slot=action]){margin-right:var(
|
|
48
|
+
--spectrum-toast-neutral-button-gap-x,var(--spectrum-global-dimension-size-100)
|
|
49
|
+
)}.body{align-self:center;flex:1 1 auto}:host([dir=ltr]) .body ::slotted([slot=action]){float:right}:host([dir=rtl]) .body ::slotted([slot=action]){float:left}:host([dir=ltr]) .body ::slotted([slot=action]){margin-right:var(
|
|
50
|
+
--spectrum-toast-button-margin-right
|
|
51
|
+
)}:host([dir=rtl]) .body ::slotted([slot=action]){margin-left:var(
|
|
52
|
+
--spectrum-toast-button-margin-right
|
|
53
|
+
)}:host([dir=ltr]) .body+.buttons{padding-left:var(
|
|
54
|
+
--spectrum-toast-neutral-padding-right,var(--spectrum-global-dimension-size-100)
|
|
55
|
+
)}:host([dir=rtl]) .body+.buttons{padding-right:var(
|
|
56
|
+
--spectrum-toast-neutral-padding-right,var(--spectrum-global-dimension-size-100)
|
|
57
|
+
)}:host([dir=ltr]) .body+.buttons{border-left-width:1px}:host([dir=rtl]) .body+.buttons{border-right-width:1px}:host([dir=ltr]) .body+.buttons{border-left-style:solid}:host([dir=rtl]) .body+.buttons{border-right-style:solid}:host{background-color:var(
|
|
58
|
+
--spectrum-toast-neutral-background-color,var(--spectrum-semantic-neutral-background-color-default)
|
|
59
|
+
);color:var(
|
|
60
|
+
--spectrum-toast-neutral-background-color,var(--spectrum-semantic-neutral-background-color-default)
|
|
61
|
+
)}.content{color:var(
|
|
62
|
+
--spectrum-toast-neutral-text-color,var(--spectrum-global-color-static-white)
|
|
63
|
+
)}.type{color:#fff}:host([dir=ltr]) .buttons{border-left-color:hsla(0,0%,100%,.2)}:host([dir=rtl]) .buttons{border-right-color:hsla(0,0%,100%,.2)}:host([variant=error]),:host([variant=negative]){background-color:var(
|
|
64
|
+
--spectrum-toast-negative-background-color,var(--spectrum-semantic-negative-background-color)
|
|
65
|
+
);color:var(
|
|
66
|
+
--spectrum-toast-negative-background-color,var(--spectrum-semantic-negative-background-color)
|
|
67
|
+
)}:host([variant=error]) .closeButton.focus-visible:not(:active),:host([variant=negative]) .closeButton.focus-visible:not(:active){color:var(
|
|
68
|
+
--spectrum-toast-negative-background-color,var(--spectrum-semantic-negative-background-color)
|
|
69
|
+
)}:host([variant=error]) .closeButton:focus-visible:not(:active),:host([variant=negative]) .closeButton:focus-visible:not(:active){color:var(
|
|
70
|
+
--spectrum-toast-negative-background-color,var(--spectrum-semantic-negative-background-color)
|
|
71
|
+
)}:host([variant=info]){background-color:var(
|
|
72
|
+
--spectrum-toast-info-background-color,var(--spectrum-semantic-informative-background-color)
|
|
73
|
+
);color:var(
|
|
74
|
+
--spectrum-toast-info-background-color,var(--spectrum-semantic-informative-background-color)
|
|
75
|
+
)}:host([variant=info]) .closeButton.focus-visible:not(:active){color:var(
|
|
76
|
+
--spectrum-toast-info-background-color,var(--spectrum-semantic-informative-background-color)
|
|
77
|
+
)}:host([variant=info]) .closeButton:focus-visible:not(:active){color:var(
|
|
78
|
+
--spectrum-toast-info-background-color,var(--spectrum-semantic-informative-background-color)
|
|
79
|
+
)}:host([variant=positive]),:host([variant=success]){background-color:var(
|
|
80
|
+
--spectrum-toast-positive-background-color,var(--spectrum-semantic-positive-background-color)
|
|
81
|
+
);color:var(
|
|
82
|
+
--spectrum-toast-positive-background-color,var(--spectrum-semantic-positive-background-color)
|
|
83
|
+
)}:host([variant=positive]) .closeButton.focus-visible:not(:active),:host([variant=success]) .closeButton.focus-visible:not(:active){color:var(
|
|
84
|
+
--spectrum-toast-positive-background-color,var(--spectrum-semantic-positive-background-color)
|
|
85
|
+
)}:host([variant=positive]) .closeButton:focus-visible:not(:active),:host([variant=success]) .closeButton:focus-visible:not(:active){color:var(
|
|
86
|
+
--spectrum-toast-positive-background-color,var(--spectrum-semantic-positive-background-color)
|
|
87
|
+
)}@media (forced-colors:active){:host{border:1px solid transparent}}
|
|
88
|
+
`;
|
|
89
|
+
export default styles;
|
|
90
|
+
//# sourceMappingURL=spectrum-toast.css.dev.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["spectrum-toast.css.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { css } from '@spectrum-web-components/base';\nconst styles = css`\n:host{--spectrum-toast-icon-padding-y:var(\n--spectrum-global-dimension-size-85\n);--spectrum-toast-neutral-content-padding-top:var(\n--spectrum-global-dimension-size-65\n);--spectrum-toast-content-padding-bottom:var(\n--spectrum-global-dimension-size-65\n);--spectrum-toast-button-margin-right:var(\n--spectrum-global-dimension-size-130\n)}:host([dir=ltr]){padding-right:var(\n--spectrum-toast-neutral-padding-right,var(--spectrum-global-dimension-size-100)\n)}:host([dir=rtl]){padding-left:var(\n--spectrum-toast-neutral-padding-right,var(--spectrum-global-dimension-size-100)\n)}:host([dir=ltr]){padding-left:var(\n--spectrum-toast-neutral-padding-left,var(--spectrum-global-dimension-size-200)\n)}:host([dir=rtl]){padding-right:var(\n--spectrum-toast-neutral-padding-left,var(--spectrum-global-dimension-size-200)\n)}:host{-webkit-font-smoothing:antialiased;align-items:stretch;border-radius:var(\n--spectrum-toast-neutral-border-radius,var(--spectrum-alias-border-radius-regular)\n);box-sizing:border-box;display:inline-flex;flex-direction:row;font-size:var(\n--spectrum-toast-neutral-text-size,var(--spectrum-global-dimension-font-size-100)\n);font-weight:var(\n--spectrum-toast-neutral-text-font-weight,var(--spectrum-alias-body-text-font-weight)\n);padding-bottom:var(\n--spectrum-toast-neutral-padding-y,var(--spectrum-global-dimension-size-100)\n);padding-top:var(\n--spectrum-toast-neutral-padding-y,var(--spectrum-global-dimension-size-100)\n)}:host([dir=ltr]) .type{margin-right:var(\n--spectrum-toast-neutral-icon-padding-right,var(--spectrum-global-dimension-size-150)\n)}:host([dir=rtl]) .type{margin-left:var(\n--spectrum-toast-neutral-icon-padding-right,var(--spectrum-global-dimension-size-150)\n)}:host([dir=ltr]) .type{margin-left:0}:host([dir=rtl]) .type{margin-right:0}.type{flex-grow:0;flex-shrink:0;margin-bottom:var(--spectrum-toast-icon-padding-y);margin-top:var(--spectrum-toast-icon-padding-y)}:host([dir=ltr]) .content{padding-right:var(\n--spectrum-toast-neutral-content-padding-right,var(--spectrum-global-dimension-size-200)\n)}:host([dir=rtl]) .content{padding-left:var(\n--spectrum-toast-neutral-content-padding-right,var(--spectrum-global-dimension-size-200)\n)}:host([dir=ltr]) .content{padding-left:0}:host([dir=rtl]) .content{padding-right:0}:host([dir=ltr]) .content{text-align:left}:host([dir=rtl]) .content{text-align:right}.content{box-sizing:border-box;display:inline-block;flex:1 1 auto;font-size:var(\n--spectrum-toast-info-text-size,var(--spectrum-global-dimension-font-size-100)\n);font-weight:var(\n--spectrum-toast-info-text-font-weight,var(--spectrum-alias-body-text-font-weight)\n);line-height:var(\n--spectrum-toast-info-text-line-height,var(--spectrum-alias-component-text-line-height)\n);padding-bottom:var(--spectrum-toast-content-padding-bottom);padding-top:var(\n--spectrum-toast-neutral-content-padding-top,var(--spectrum-global-dimension-size-65)\n)}.buttons{align-items:flex-start;display:flex;flex:0 0 auto}:host([dir=ltr]) .buttons .spectrum-ClearButton+.spectrum-ClearButton,:host([dir=ltr]) .buttons .spectrum-ClearButton+::slotted([slot=action]),:host([dir=ltr]) .buttons slot[name=action]+.spectrum-ClearButton,:host([dir=ltr]) .buttons slot[name=action]+::slotted([slot=action]){margin-left:var(\n--spectrum-toast-neutral-button-gap-x,var(--spectrum-global-dimension-size-100)\n)}:host([dir=rtl]) .buttons .spectrum-ClearButton+.spectrum-ClearButton,:host([dir=rtl]) .buttons .spectrum-ClearButton+::slotted([slot=action]),:host([dir=rtl]) .buttons slot[name=action]+.spectrum-ClearButton,:host([dir=rtl]) .buttons slot[name=action]+::slotted([slot=action]){margin-right:var(\n--spectrum-toast-neutral-button-gap-x,var(--spectrum-global-dimension-size-100)\n)}.body{align-self:center;flex:1 1 auto}:host([dir=ltr]) .body ::slotted([slot=action]){float:right}:host([dir=rtl]) .body ::slotted([slot=action]){float:left}:host([dir=ltr]) .body ::slotted([slot=action]){margin-right:var(\n--spectrum-toast-button-margin-right\n)}:host([dir=rtl]) .body ::slotted([slot=action]){margin-left:var(\n--spectrum-toast-button-margin-right\n)}:host([dir=ltr]) .body+.buttons{padding-left:var(\n--spectrum-toast-neutral-padding-right,var(--spectrum-global-dimension-size-100)\n)}:host([dir=rtl]) .body+.buttons{padding-right:var(\n--spectrum-toast-neutral-padding-right,var(--spectrum-global-dimension-size-100)\n)}:host([dir=ltr]) .body+.buttons{border-left-width:1px}:host([dir=rtl]) .body+.buttons{border-right-width:1px}:host([dir=ltr]) .body+.buttons{border-left-style:solid}:host([dir=rtl]) .body+.buttons{border-right-style:solid}:host{background-color:var(\n--spectrum-toast-neutral-background-color,var(--spectrum-semantic-neutral-background-color-default)\n);color:var(\n--spectrum-toast-neutral-background-color,var(--spectrum-semantic-neutral-background-color-default)\n)}.content{color:var(\n--spectrum-toast-neutral-text-color,var(--spectrum-global-color-static-white)\n)}.type{color:#fff}:host([dir=ltr]) .buttons{border-left-color:hsla(0,0%,100%,.2)}:host([dir=rtl]) .buttons{border-right-color:hsla(0,0%,100%,.2)}:host([variant=error]),:host([variant=negative]){background-color:var(\n--spectrum-toast-negative-background-color,var(--spectrum-semantic-negative-background-color)\n);color:var(\n--spectrum-toast-negative-background-color,var(--spectrum-semantic-negative-background-color)\n)}:host([variant=error]) .closeButton.focus-visible:not(:active),:host([variant=negative]) .closeButton.focus-visible:not(:active){color:var(\n--spectrum-toast-negative-background-color,var(--spectrum-semantic-negative-background-color)\n)}:host([variant=error]) .closeButton:focus-visible:not(:active),:host([variant=negative]) .closeButton:focus-visible:not(:active){color:var(\n--spectrum-toast-negative-background-color,var(--spectrum-semantic-negative-background-color)\n)}:host([variant=info]){background-color:var(\n--spectrum-toast-info-background-color,var(--spectrum-semantic-informative-background-color)\n);color:var(\n--spectrum-toast-info-background-color,var(--spectrum-semantic-informative-background-color)\n)}:host([variant=info]) .closeButton.focus-visible:not(:active){color:var(\n--spectrum-toast-info-background-color,var(--spectrum-semantic-informative-background-color)\n)}:host([variant=info]) .closeButton:focus-visible:not(:active){color:var(\n--spectrum-toast-info-background-color,var(--spectrum-semantic-informative-background-color)\n)}:host([variant=positive]),:host([variant=success]){background-color:var(\n--spectrum-toast-positive-background-color,var(--spectrum-semantic-positive-background-color)\n);color:var(\n--spectrum-toast-positive-background-color,var(--spectrum-semantic-positive-background-color)\n)}:host([variant=positive]) .closeButton.focus-visible:not(:active),:host([variant=success]) .closeButton.focus-visible:not(:active){color:var(\n--spectrum-toast-positive-background-color,var(--spectrum-semantic-positive-background-color)\n)}:host([variant=positive]) .closeButton:focus-visible:not(:active),:host([variant=success]) .closeButton:focus-visible:not(:active){color:var(\n--spectrum-toast-positive-background-color,var(--spectrum-semantic-positive-background-color)\n)}@media (forced-colors:active){:host{border:1px solid transparent}}\n`;\nexport default styles;"],
|
|
5
|
+
"mappings": "AAWA;AACA,MAAM,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuFf,eAAe;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
|
|
7
|
-
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
import { css } from '@spectrum-web-components/base';
|
|
13
|
-
const styles = css `
|
|
1
|
+
import { css } from "@spectrum-web-components/base";
|
|
2
|
+
const styles = css`
|
|
14
3
|
:host{--spectrum-toast-icon-padding-y:var(
|
|
15
4
|
--spectrum-global-dimension-size-85
|
|
16
5
|
);--spectrum-toast-neutral-content-padding-top:var(
|
|
@@ -98,4 +87,4 @@ const styles = css `
|
|
|
98
87
|
)}@media (forced-colors:active){:host{border:1px solid transparent}}
|
|
99
88
|
`;
|
|
100
89
|
export default styles;
|
|
101
|
-
//# sourceMappingURL=spectrum-toast.css.js.map
|
|
90
|
+
//# sourceMappingURL=spectrum-toast.css.js.map
|