@spectrum-web-components/toast 0.48.1 → 0.49.0-beta.1
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/README.md +2 -2
- package/package.json +7 -7
- package/src/Toast.dev.js +1 -1
- package/src/Toast.dev.js.map +1 -1
- package/src/Toast.js +1 -1
- package/src/Toast.js.map +1 -1
- package/stories/toast.stories.js +1 -1
- package/stories/toast.stories.js.map +1 -1
- package/test/toast.test.js +59 -85
- package/test/toast.test.js.map +2 -2
- package/custom-elements.json +0 -294
package/README.md
CHANGED
|
@@ -39,7 +39,7 @@ import { Toast } from '@spectrum-web-components/toast';
|
|
|
39
39
|
This is important information that you should read, soon.
|
|
40
40
|
<sp-button
|
|
41
41
|
slot="action"
|
|
42
|
-
static="white"
|
|
42
|
+
static-color="white"
|
|
43
43
|
variant="secondary"
|
|
44
44
|
treatment="outline"
|
|
45
45
|
>
|
|
@@ -55,7 +55,7 @@ import { Toast } from '@spectrum-web-components/toast';
|
|
|
55
55
|
This is important information that you should read, soon.
|
|
56
56
|
<sp-button
|
|
57
57
|
slot="action"
|
|
58
|
-
static="white"
|
|
58
|
+
static-color="white"
|
|
59
59
|
variant="secondary"
|
|
60
60
|
treatment="outline"
|
|
61
61
|
>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/toast",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.49.0-beta.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -57,11 +57,11 @@
|
|
|
57
57
|
"lit-html"
|
|
58
58
|
],
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@spectrum-web-components/base": "^0.
|
|
61
|
-
"@spectrum-web-components/button": "^0.
|
|
62
|
-
"@spectrum-web-components/icon": "^0.
|
|
63
|
-
"@spectrum-web-components/icons-workflow": "^0.
|
|
64
|
-
"@spectrum-web-components/shared": "^0.
|
|
60
|
+
"@spectrum-web-components/base": "^0.49.0-beta.1",
|
|
61
|
+
"@spectrum-web-components/button": "^0.49.0-beta.1",
|
|
62
|
+
"@spectrum-web-components/icon": "^0.49.0-beta.1",
|
|
63
|
+
"@spectrum-web-components/icons-workflow": "^0.49.0-beta.1",
|
|
64
|
+
"@spectrum-web-components/shared": "^0.49.0-beta.1"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@spectrum-css/toast": "^10.2.0"
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"./sp-*.js",
|
|
73
73
|
"./**/*.dev.js"
|
|
74
74
|
],
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "74ee2c5b1276e8e4f768566a1c3c4e263a7eb8b3"
|
|
76
76
|
}
|
package/src/Toast.dev.js
CHANGED
package/src/Toast.dev.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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';\nimport { FocusVisiblePolyfillMixin } from '@spectrum-web-components/shared/src/focus-visible.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 FocusVisiblePolyfillMixin(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 static=\"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"],
|
|
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';\nimport { FocusVisiblePolyfillMixin } from '@spectrum-web-components/shared/src/focus-visible.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 FocusVisiblePolyfillMixin(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 static-color=\"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
5
|
"mappings": ";;;;;;;;;;;AAYA;AAAA,EAEI;AAAA,EAEA;AAAA,OAEG;AACP,SAAS,gBAAgB;AACzB,OAAO;AACP,OAAO;A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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BASd,KAAK,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMzC;AAAA,EAEmB,QAAQ,SAA+B;AACtD,UAAM,QAAQ,OAAO;AACrB,QAAI,QAAQ,IAAI,MAAM,GAAG;AACrB,UAAI,KAAK,MAAM;AACX,YAAI,KAAK,SAAS;AACd,eAAK,eAAe;AAAA,QACxB;AAAA,MACJ,OAAO;AACH,YAAI,KAAK,SAAS;AACd,eAAK,cAAc;AAAA,QACvB;AAAA,MACJ;AAAA,IACJ;AACA,QAAI,QAAQ,IAAI,SAAS,GAAG;AACxB,UAAI,KAAK,YAAY,QAAQ,KAAK,MAAM;AACpC,aAAK,eAAe;AAAA,MACxB,OAAO;AACH,aAAK,cAAc;AAAA,MACvB;AAAA,IACJ;AAAA,EACJ;AACJ;AA1LW;AAAA,EADN,SAAS,EAAE,MAAM,SAAS,SAAS,KAAK,CAAC;AAAA,GALjC,MAMF;AAcI;AAAA,EADV,SAAS,EAAE,MAAM,OAAO,CAAC;AAAA,GAnBjB,MAoBE;AA0BA;AAAA,EADV,SAAS,EAAE,MAAM,OAAO,CAAC;AAAA,GA7CjB,MA8CE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/Toast.js
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
<sp-close-button
|
|
23
23
|
@click=${this.shouldClose}
|
|
24
24
|
label="Close"
|
|
25
|
-
static="white"
|
|
25
|
+
static-color="white"
|
|
26
26
|
></sp-close-button>
|
|
27
27
|
</div>
|
|
28
28
|
`}updated(t){super.updated(t),t.has("open")&&(this.open?this.timeout&&this.startCountdown():this.timeout&&this.stopCountdown()),t.has("timeout")&&(this.timeout!==null&&this.open?this.startCountdown():this.stopCountdown())}}r([l({type:Boolean,reflect:!0})],Toast.prototype,"open",2),r([l({type:Number})],Toast.prototype,"timeout",1),r([l({type:String})],Toast.prototype,"variant",1);
|
package/src/Toast.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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';\nimport { FocusVisiblePolyfillMixin } from '@spectrum-web-components/shared/src/focus-visible.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 FocusVisiblePolyfillMixin(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 static=\"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"],
|
|
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';\nimport { FocusVisiblePolyfillMixin } from '@spectrum-web-components/shared/src/focus-visible.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 FocusVisiblePolyfillMixin(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 static-color=\"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
5
|
"mappings": "qNAYA,OAEI,QAAAA,EAEA,mBAAAC,MAEG,gCACP,OAAS,YAAAC,MAAgB,kDACzB,MAAO,qDACP,MAAO,iEACP,MAAO,gEACP,MAAO,4EACP,OAAS,6BAAAC,MAAiC,uDAE1C,OAAOC,MAAiB,iBAEjB,aAAM,cAAiC,CAC1C,WACA,WACA,OACA,QACA,SACJ,EAmBO,aAAM,cAAcD,EAA0BF,CAAe,CAAE,CAA/D,kCAMH,KAAO,KAAO,GA+Bd,KAAO,SAA0B,KA4BjC,KAAQ,SAA0B,GA8BlC,KAAQ,eAAiB,EACzB,KAAQ,UAAY,GAEpB,KAAQ,YAAeI,GAAuB,CACrC,KAAK,iBACN,KAAK,eAAiB,YAAY,IAAI,GAEtCA,EAAO,KAAK,eAAkB,KAAK,UACnC,KAAK,YAAY,EACjB,KAAK,eAAiB,GAEtB,KAAK,UAAU,CAEvB,EAEA,KAAQ,UAAY,IAAY,CAC5B,qBAAqB,KAAK,SAAS,EACnC,KAAK,UAAY,sBAAsB,KAAK,WAAW,CAC3D,EAEA,KAA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I,YAAY,QAAS,CACrB,SAAU,GACV,QAAS,GACT,WAAY,EAChB,CAAC,CACL,GAEI,KAAK,MAAM,CAEnB,CAEO,OAAc,CACjB,KAAK,KAAO,EAChB,CAEmB,QAAyB,CACxC,OAAOA;AAAA,cACD,KAAK,WAAW,KAAK,OAAO,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BASd,KAAK,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA,SAMzC,CAEmB,QAAQU,EAA+B,CACtD,MAAM,QAAQA,CAAO,EACjBA,EAAQ,IAAI,MAAM,IACd,KAAK,KACD,KAAK,SACL,KAAK,eAAe,EAGpB,KAAK,SACL,KAAK,cAAc,GAI3BA,EAAQ,IAAI,SAAS,IACjB,KAAK,UAAY,MAAQ,KAAK,KAC9B,KAAK,eAAe,EAEpB,KAAK,cAAc,EAG/B,CACJ,CA1LWC,EAAA,CADNT,EAAS,CAAE,KAAM,QAAS,QAAS,EAAK,CAAC,GALjC,MAMF,oBAcIS,EAAA,CADVT,EAAS,CAAE,KAAM,MAAO,CAAC,GAnBjB,MAoBE,uBA0BAS,EAAA,CADVT,EAAS,CAAE,KAAM,MAAO,CAAC,GA7CjB,MA8CE",
|
|
6
6
|
"names": ["html", "SpectrumElement", "property", "FocusVisiblePolyfillMixin", "toastStyles", "time", "timeout", "newTimeout", "oldValue", "variant", "changes", "__decorateClass"]
|
|
7
7
|
}
|
package/stories/toast.stories.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["toast.stories.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*/\nimport { html, TemplateResult } from '@spectrum-web-components/base';\n\nimport '@spectrum-web-components/toast/sp-toast.js';\nimport '@spectrum-web-components/button/sp-button.js';\nimport '@spectrum-web-components/overlay/sp-overlay.js';\n\nimport { Placement } from '@spectrum-web-components/overlay';\nimport '@spectrum-web-components/overlay/overlay-trigger.js';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\n\nconst toast = ({\n variant = '',\n open = true,\n content = '',\n}): TemplateResult => html`\n <sp-toast\n variant=${variant as\n | ''\n | 'negative'\n | 'positive'\n | 'info'\n | 'error'\n | 'warning'}\n ?open=${open}\n >\n ${content}\n <sp-button\n slot=\"action\"\n static=\"white\"\n variant=\"secondary\"\n treatment=\"outline\"\n >\n Undo\n </sp-button>\n </sp-toast>\n`;\n\nexport default {\n component: 'sp-toast',\n title: 'Toast',\n args: {\n content: 'This is a toast message.',\n open: true,\n },\n argTypes: {\n content: {\n name: 'content',\n type: { name: 'string', required: false },\n table: {\n type: { summary: 'string' },\n defaultValue: { summary: '' },\n },\n control: 'text',\n },\n open: {\n name: 'open',\n type: { name: 'boolean', required: false },\n description: 'Whether the toast is open.',\n table: {\n type: { summary: 'boolean' },\n defaultValue: { summary: false },\n },\n control: {\n type: 'boolean',\n },\n },\n },\n};\n\ninterface Properties {\n variant: '' | 'negative' | 'positive' | 'info' | 'error' | 'warning';\n open: boolean;\n content: string;\n onClose: (event: Event) => void;\n}\n\nexport const Default = ({\n variant,\n open,\n content,\n}: Properties): TemplateResult => {\n return toast({ variant, open, content });\n};\n\nconst variantDemo = ({\n variant,\n open,\n content,\n}: Properties): TemplateResult => {\n return toast({ variant, open, content });\n};\n\nexport const Positive = (args: Properties): TemplateResult =>\n variantDemo({ ...args, variant: 'positive' });\n\nexport const Negative = (args: Properties): TemplateResult =>\n variantDemo({ ...args, variant: 'negative' });\n\nexport const Info = (args: Properties): TemplateResult =>\n variantDemo({ ...args, variant: 'info' });\n\nexport const Wrapping = (args: Properties): TemplateResult =>\n variantDemo({\n ...args,\n variant: 'info',\n content:\n 'A new version of Lightroom Classic is now available. Use the Update button below to start using the new version.',\n });\n\nconst overlayStyles = html`\n <style>\n html,\n body,\n #root,\n #root-inner,\n sp-story-decorator {\n height: 100%;\n margin: 0;\n }\n\n sp-story-decorator > div {\n display: contents;\n }\n\n sp-story-decorator::part(container) {\n display: flex;\n flex-direction: column;\n width: 100%;\n height: 100%;\n align-items: center;\n justify-content: center;\n }\n\n overlay-trigger {\n flex: none;\n margin: 24px 0;\n }\n\n .self-managed:nth-child(3) {\n margin-left: 50px;\n }\n </style>\n`;\n\nconst overlaid = (openPlacement: Placement): TemplateResult => {\n return html`\n ${overlayStyles}\n ${(\n [\n ['bottom', ''],\n ['left', 'negative'],\n ['right', 'positive'],\n ['top', 'info'],\n ] as [Placement, string][]\n ).map(([placement, variant]) => {\n return html`\n <overlay-trigger\n placement=${placement}\n open=${ifDefined(\n openPlacement === placement ? 'click' : undefined\n )}\n >\n <sp-button label=\"${placement} test\" slot=\"trigger\">\n Click for ${variant ? variant : 'toast'} on the\n ${placement}\n </sp-button>\n <sp-toast slot=\"click-content\" variant=${variant}>\n ${placement}\n </sp-toast>\n </overlay-trigger>\n `;\n })}\n `;\n};\n\nexport const overlaidTop = (): TemplateResult => overlaid('top');\nexport const overlaidRight = (): TemplateResult => overlaid('right');\nexport const overlaidBottom = (): TemplateResult => overlaid('bottom');\nexport const overlaidLeft = (): TemplateResult => overlaid('left');\n\nexport const overlay = (args: Properties): TemplateResult => {\n return html`\n <style>\n sp-toast {\n position: fixed;\n bottom: 1em;\n left: 1em;\n }\n </style>\n <sp-button id=\"overlay\">Toggle Toast overlay</sp-button>\n <sp-overlay trigger=\"overlay@click\" type=\"auto\" open>\n ${variantDemo({ ...args, variant: 'positive' })}\n </sp-overlay>\n `;\n};\n"],
|
|
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*/\nimport { html, TemplateResult } from '@spectrum-web-components/base';\n\nimport '@spectrum-web-components/toast/sp-toast.js';\nimport '@spectrum-web-components/button/sp-button.js';\nimport '@spectrum-web-components/overlay/sp-overlay.js';\n\nimport { Placement } from '@spectrum-web-components/overlay';\nimport '@spectrum-web-components/overlay/overlay-trigger.js';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\n\nconst toast = ({\n variant = '',\n open = true,\n content = '',\n}): TemplateResult => html`\n <sp-toast\n variant=${variant as\n | ''\n | 'negative'\n | 'positive'\n | 'info'\n | 'error'\n | 'warning'}\n ?open=${open}\n >\n ${content}\n <sp-button\n slot=\"action\"\n static-color=\"white\"\n variant=\"secondary\"\n treatment=\"outline\"\n >\n Undo\n </sp-button>\n </sp-toast>\n`;\n\nexport default {\n component: 'sp-toast',\n title: 'Toast',\n args: {\n content: 'This is a toast message.',\n open: true,\n },\n argTypes: {\n content: {\n name: 'content',\n type: { name: 'string', required: false },\n table: {\n type: { summary: 'string' },\n defaultValue: { summary: '' },\n },\n control: 'text',\n },\n open: {\n name: 'open',\n type: { name: 'boolean', required: false },\n description: 'Whether the toast is open.',\n table: {\n type: { summary: 'boolean' },\n defaultValue: { summary: false },\n },\n control: {\n type: 'boolean',\n },\n },\n },\n};\n\ninterface Properties {\n variant: '' | 'negative' | 'positive' | 'info' | 'error' | 'warning';\n open: boolean;\n content: string;\n onClose: (event: Event) => void;\n}\n\nexport const Default = ({\n variant,\n open,\n content,\n}: Properties): TemplateResult => {\n return toast({ variant, open, content });\n};\n\nconst variantDemo = ({\n variant,\n open,\n content,\n}: Properties): TemplateResult => {\n return toast({ variant, open, content });\n};\n\nexport const Positive = (args: Properties): TemplateResult =>\n variantDemo({ ...args, variant: 'positive' });\n\nexport const Negative = (args: Properties): TemplateResult =>\n variantDemo({ ...args, variant: 'negative' });\n\nexport const Info = (args: Properties): TemplateResult =>\n variantDemo({ ...args, variant: 'info' });\n\nexport const Wrapping = (args: Properties): TemplateResult =>\n variantDemo({\n ...args,\n variant: 'info',\n content:\n 'A new version of Lightroom Classic is now available. Use the Update button below to start using the new version.',\n });\n\nconst overlayStyles = html`\n <style>\n html,\n body,\n #root,\n #root-inner,\n sp-story-decorator {\n height: 100%;\n margin: 0;\n }\n\n sp-story-decorator > div {\n display: contents;\n }\n\n sp-story-decorator::part(container) {\n display: flex;\n flex-direction: column;\n width: 100%;\n height: 100%;\n align-items: center;\n justify-content: center;\n }\n\n overlay-trigger {\n flex: none;\n margin: 24px 0;\n }\n\n .self-managed:nth-child(3) {\n margin-left: 50px;\n }\n </style>\n`;\n\nconst overlaid = (openPlacement: Placement): TemplateResult => {\n return html`\n ${overlayStyles}\n ${(\n [\n ['bottom', ''],\n ['left', 'negative'],\n ['right', 'positive'],\n ['top', 'info'],\n ] as [Placement, string][]\n ).map(([placement, variant]) => {\n return html`\n <overlay-trigger\n placement=${placement}\n open=${ifDefined(\n openPlacement === placement ? 'click' : undefined\n )}\n >\n <sp-button label=\"${placement} test\" slot=\"trigger\">\n Click for ${variant ? variant : 'toast'} on the\n ${placement}\n </sp-button>\n <sp-toast slot=\"click-content\" variant=${variant}>\n ${placement}\n </sp-toast>\n </overlay-trigger>\n `;\n })}\n `;\n};\n\nexport const overlaidTop = (): TemplateResult => overlaid('top');\nexport const overlaidRight = (): TemplateResult => overlaid('right');\nexport const overlaidBottom = (): TemplateResult => overlaid('bottom');\nexport const overlaidLeft = (): TemplateResult => overlaid('left');\n\nexport const overlay = (args: Properties): TemplateResult => {\n return html`\n <style>\n sp-toast {\n position: fixed;\n bottom: 1em;\n left: 1em;\n }\n </style>\n <sp-button id=\"overlay\">Toggle Toast overlay</sp-button>\n <sp-overlay trigger=\"overlay@click\" type=\"auto\" open>\n ${variantDemo({ ...args, variant: 'positive' })}\n </sp-overlay>\n `;\n};\n"],
|
|
5
5
|
"mappings": ";AAWA,SAAS,YAA4B;AAErC,OAAO;AACP,OAAO;AACP,OAAO;AAGP,OAAO;AACP,SAAS,iBAAiB;AAE1B,MAAM,QAAQ,CAAC;AAAA,EACX,UAAU;AAAA,EACV,OAAO;AAAA,EACP,UAAU;AACd,MAAsB;AAAA;AAAA,kBAEJ,OAMK;AAAA,gBACP,IAAI;AAAA;AAAA,UAEV,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYjB,eAAe;AAAA,EACX,WAAW;AAAA,EACX,OAAO;AAAA,EACP,MAAM;AAAA,IACF,SAAS;AAAA,IACT,MAAM;AAAA,EACV;AAAA,EACA,UAAU;AAAA,IACN,SAAS;AAAA,MACL,MAAM;AAAA,MACN,MAAM,EAAE,MAAM,UAAU,UAAU,MAAM;AAAA,MACxC,OAAO;AAAA,QACH,MAAM,EAAE,SAAS,SAAS;AAAA,QAC1B,cAAc,EAAE,SAAS,GAAG;AAAA,MAChC;AAAA,MACA,SAAS;AAAA,IACb;AAAA,IACA,MAAM;AAAA,MACF,MAAM;AAAA,MACN,MAAM,EAAE,MAAM,WAAW,UAAU,MAAM;AAAA,MACzC,aAAa;AAAA,MACb,OAAO;AAAA,QACH,MAAM,EAAE,SAAS,UAAU;AAAA,QAC3B,cAAc,EAAE,SAAS,MAAM;AAAA,MACnC;AAAA,MACA,SAAS;AAAA,QACL,MAAM;AAAA,MACV;AAAA,IACJ;AAAA,EACJ;AACJ;AASO,aAAM,UAAU,CAAC;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AACJ,MAAkC;AAC9B,SAAO,MAAM,EAAE,SAAS,MAAM,QAAQ,CAAC;AAC3C;AAEA,MAAM,cAAc,CA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sB,SAAS,OAAO;AAC5D,aAAM,iBAAiB,MAAsB,SAAS,QAAQ;AAC9D,aAAM,eAAe,MAAsB,SAAS,MAAM;AAE1D,aAAM,UAAU,CAAC,SAAqC;AACzD,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,cAUG,YAAY,EAAE,GAAG,MAAM,SAAS,WAAW,CAAC,CAAC;AAAA;AAAA;AAG3D;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/test/toast.test.js
CHANGED
|
@@ -16,40 +16,32 @@ import {
|
|
|
16
16
|
import { spy } from "sinon";
|
|
17
17
|
describe("Toast", () => {
|
|
18
18
|
testForLitDevWarnings(
|
|
19
|
-
async () => await fixture(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
`
|
|
23
|
-
)
|
|
19
|
+
async () => await fixture(html`
|
|
20
|
+
<sp-toast open>Help text.</sp-toast>
|
|
21
|
+
`)
|
|
24
22
|
);
|
|
25
23
|
it("loads", async () => {
|
|
26
|
-
const el = await fixture(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
`
|
|
30
|
-
);
|
|
24
|
+
const el = await fixture(html`
|
|
25
|
+
<sp-toast open>Help text.</sp-toast>
|
|
26
|
+
`);
|
|
31
27
|
await elementUpdated(el);
|
|
32
28
|
await expect(el).to.be.accessible();
|
|
33
29
|
});
|
|
34
30
|
toastVariants.map((variant) => {
|
|
35
31
|
it(`loads - [variant="${variant}"]`, async () => {
|
|
36
|
-
const el = await fixture(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
`
|
|
42
|
-
);
|
|
32
|
+
const el = await fixture(html`
|
|
33
|
+
<sp-toast variant=${variant} open>
|
|
34
|
+
This toast is of the \`${variant}\` variant.
|
|
35
|
+
</sp-toast>
|
|
36
|
+
`);
|
|
43
37
|
await elementUpdated(el);
|
|
44
38
|
await expect(el).to.be.accessible();
|
|
45
39
|
});
|
|
46
40
|
});
|
|
47
41
|
it("loads - timeout", async () => {
|
|
48
|
-
const el = await fixture(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
`
|
|
52
|
-
);
|
|
42
|
+
const el = await fixture(html`
|
|
43
|
+
<sp-toast timeout="100">Help text.</sp-toast>
|
|
44
|
+
`);
|
|
53
45
|
await elementUpdated(el);
|
|
54
46
|
expect(el.open).to.be.false;
|
|
55
47
|
el._timeout = 100;
|
|
@@ -59,11 +51,9 @@ describe("Toast", () => {
|
|
|
59
51
|
expect(el.open).to.be.false;
|
|
60
52
|
});
|
|
61
53
|
it("`timeout` updates `countdownStart`", async () => {
|
|
62
|
-
const el = await fixture(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
`
|
|
66
|
-
);
|
|
54
|
+
const el = await fixture(html`
|
|
55
|
+
<sp-toast timeout="100">Help text.</sp-toast>
|
|
56
|
+
`);
|
|
67
57
|
await elementUpdated(el);
|
|
68
58
|
expect(el.open).to.be.false;
|
|
69
59
|
const testableEl = el;
|
|
@@ -86,11 +76,9 @@ describe("Toast", () => {
|
|
|
86
76
|
expect(thirdStart).to.equal(0);
|
|
87
77
|
});
|
|
88
78
|
it("stops timeout on `focusin`", async () => {
|
|
89
|
-
const el = await fixture(
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
`
|
|
93
|
-
);
|
|
79
|
+
const el = await fixture(html`
|
|
80
|
+
<sp-toast timeout="100">Help text.</sp-toast>
|
|
81
|
+
`);
|
|
94
82
|
await elementUpdated(el);
|
|
95
83
|
const testableEl = el;
|
|
96
84
|
expect(el.open, "not open to start").to.be.false;
|
|
@@ -112,11 +100,9 @@ describe("Toast", () => {
|
|
|
112
100
|
expect(el.open, "not open to end").to.be.false;
|
|
113
101
|
});
|
|
114
102
|
it("closes", async () => {
|
|
115
|
-
const el = await fixture(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
`
|
|
119
|
-
);
|
|
103
|
+
const el = await fixture(html`
|
|
104
|
+
<sp-toast open>Help text.</sp-toast>
|
|
105
|
+
`);
|
|
120
106
|
await elementUpdated(el);
|
|
121
107
|
expect(el.open).to.be.true;
|
|
122
108
|
const renderRoot = el.shadowRoot ? el.shadowRoot : el;
|
|
@@ -129,13 +115,11 @@ describe("Toast", () => {
|
|
|
129
115
|
});
|
|
130
116
|
it("`close` can be prevented", async () => {
|
|
131
117
|
const handleClose = (event) => event.preventDefault();
|
|
132
|
-
const el = await fixture(
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
`
|
|
138
|
-
);
|
|
118
|
+
const el = await fixture(html`
|
|
119
|
+
<sp-toast open timeout="100" @close=${handleClose}>
|
|
120
|
+
Help text.
|
|
121
|
+
</sp-toast>
|
|
122
|
+
`);
|
|
139
123
|
await elementUpdated(el);
|
|
140
124
|
expect(el.open).to.be.true;
|
|
141
125
|
const renderRoot = el.shadowRoot ? el.shadowRoot : el;
|
|
@@ -152,13 +136,11 @@ describe("Toast", () => {
|
|
|
152
136
|
event.preventDefault();
|
|
153
137
|
closeSpy();
|
|
154
138
|
};
|
|
155
|
-
const el = await fixture(
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
`
|
|
161
|
-
);
|
|
139
|
+
const el = await fixture(html`
|
|
140
|
+
<sp-toast open timeout="100" @close=${handleClose}>
|
|
141
|
+
Help text.
|
|
142
|
+
</sp-toast>
|
|
143
|
+
`);
|
|
162
144
|
await elementUpdated(el);
|
|
163
145
|
expect(el.open).to.be.true;
|
|
164
146
|
expect(closeSpy.callCount).to.equal(0);
|
|
@@ -176,13 +158,11 @@ describe("Toast", () => {
|
|
|
176
158
|
expect(closeSpy.callCount).to.equal(1);
|
|
177
159
|
});
|
|
178
160
|
it("validates variants", async () => {
|
|
179
|
-
const el = await fixture(
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
`
|
|
185
|
-
);
|
|
161
|
+
const el = await fixture(html`
|
|
162
|
+
<sp-toast variant="invalid" open>
|
|
163
|
+
This toast validates variants.
|
|
164
|
+
</sp-toast>
|
|
165
|
+
`);
|
|
186
166
|
await elementUpdated(el);
|
|
187
167
|
expect(el.variant).to.equal("");
|
|
188
168
|
el.variant = toastVariants[0];
|
|
@@ -193,13 +173,11 @@ describe("Toast", () => {
|
|
|
193
173
|
expect(el.variant).to.equal(toastVariants[0]);
|
|
194
174
|
});
|
|
195
175
|
it("maintains [variant] when disconnected/connected", async () => {
|
|
196
|
-
const el = await fixture(
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
`
|
|
202
|
-
);
|
|
176
|
+
const el = await fixture(html`
|
|
177
|
+
<sp-toast variant="positive" open>
|
|
178
|
+
This toast maintains variants.
|
|
179
|
+
</sp-toast>
|
|
180
|
+
`);
|
|
203
181
|
await elementUpdated(el);
|
|
204
182
|
expect(el.variant).to.equal("positive");
|
|
205
183
|
const parent = el.parentElement;
|
|
@@ -210,19 +188,17 @@ describe("Toast", () => {
|
|
|
210
188
|
});
|
|
211
189
|
it("reopens", async () => {
|
|
212
190
|
const closeSpy = spy();
|
|
213
|
-
const el = await fixture(
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
`
|
|
225
|
-
);
|
|
191
|
+
const el = await fixture(html`
|
|
192
|
+
<sp-toast
|
|
193
|
+
variant="positive"
|
|
194
|
+
open
|
|
195
|
+
@close=${() => {
|
|
196
|
+
closeSpy();
|
|
197
|
+
}}
|
|
198
|
+
>
|
|
199
|
+
This toast maintains variants.
|
|
200
|
+
</sp-toast>
|
|
201
|
+
`);
|
|
226
202
|
await elementUpdated(el);
|
|
227
203
|
expect(el.open).to.be.true;
|
|
228
204
|
const closeButton = el.shadowRoot.querySelector(
|
|
@@ -236,18 +212,16 @@ describe("Toast", () => {
|
|
|
236
212
|
expect(el.open).to.be.true;
|
|
237
213
|
expect(closeSpy.callCount).to.equal(1);
|
|
238
214
|
});
|
|
239
|
-
it('sp close button renders with static="white"', async () => {
|
|
240
|
-
const el = await fixture(
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
`
|
|
244
|
-
);
|
|
215
|
+
it('sp close button renders with static-color="white"', async () => {
|
|
216
|
+
const el = await fixture(html`
|
|
217
|
+
<sp-toast open>Help text.</sp-toast>
|
|
218
|
+
`);
|
|
245
219
|
const renderRoot = el.shadowRoot ? el.shadowRoot : el;
|
|
246
220
|
const closeButton = renderRoot.querySelector(
|
|
247
221
|
"sp-close-button"
|
|
248
222
|
);
|
|
249
223
|
expect(closeButton).to.exist;
|
|
250
|
-
expect(closeButton.getAttribute("static")).to.equal("white");
|
|
224
|
+
expect(closeButton.getAttribute("static-color")).to.equal("white");
|
|
251
225
|
});
|
|
252
226
|
});
|
|
253
227
|
//# sourceMappingURL=toast.test.js.map
|
package/test/toast.test.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["toast.test.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 '@spectrum-web-components/toast/sp-toast.js';\nimport { Toast, toastVariants } from '@spectrum-web-components/toast';\nimport {\n elementUpdated,\n expect,\n fixture,\n html,\n nextFrame,\n waitUntil,\n} from '@open-wc/testing';\nimport { CloseButton } from '@spectrum-web-components/button';\nimport {\n testForLitDevWarnings,\n waitForPredicate,\n} from '../../../test/testing-helpers.js';\nimport { spy } from 'sinon';\n\ninterface TestableToast {\n _timeout: number;\n countdownStart: number;\n}\n\ndescribe('Toast', () => {\n testForLitDevWarnings(\n async () =>\n await fixture<Toast>(
|
|
5
|
-
"mappings": ";AAYA,OAAO;AACP,SAAgB,qBAAqB;AACrC;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAEP;AAAA,EACI;AAAA,EACA;AAAA,OACG;AACP,SAAS,WAAW;AAOpB,SAAS,SAAS,MAAM;AACpB;AAAA,IACI,YACI,MAAM
|
|
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 '@spectrum-web-components/toast/sp-toast.js';\nimport { Toast, toastVariants } from '@spectrum-web-components/toast';\nimport {\n elementUpdated,\n expect,\n fixture,\n html,\n nextFrame,\n waitUntil,\n} from '@open-wc/testing';\nimport { CloseButton } from '@spectrum-web-components/button';\nimport {\n testForLitDevWarnings,\n waitForPredicate,\n} from '../../../test/testing-helpers.js';\nimport { spy } from 'sinon';\n\ninterface TestableToast {\n _timeout: number;\n countdownStart: number;\n}\n\ndescribe('Toast', () => {\n testForLitDevWarnings(\n async () =>\n await fixture<Toast>(html`\n <sp-toast open>Help text.</sp-toast>\n `)\n );\n it('loads', async () => {\n const el = await fixture<Toast>(html`\n <sp-toast open>Help text.</sp-toast>\n `);\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n toastVariants.map((variant) => {\n it(`loads - [variant=\"${variant}\"]`, async () => {\n const el = await fixture<Toast>(html`\n <sp-toast variant=${variant} open>\n This toast is of the \\`${variant}\\` variant.\n </sp-toast>\n `);\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n });\n it('loads - timeout', async () => {\n const el = await fixture<Toast>(html`\n <sp-toast timeout=\"100\">Help text.</sp-toast>\n `);\n\n await elementUpdated(el);\n expect(el.open).to.be.false;\n\n (el as unknown as TestableToast)._timeout = 100;\n el.open = true;\n await elementUpdated(el);\n\n await waitForPredicate(() => el.open === false);\n expect(el.open).to.be.false;\n });\n it('`timeout` updates `countdownStart`', async () => {\n const el = await fixture<Toast>(html`\n <sp-toast timeout=\"100\">Help text.</sp-toast>\n `);\n\n await elementUpdated(el);\n expect(el.open).to.be.false;\n\n const testableEl = el as unknown as TestableToast;\n testableEl._timeout = 100;\n el.open = true;\n await elementUpdated(el);\n\n const firstStart = testableEl.countdownStart;\n\n await nextFrame();\n await nextFrame();\n await nextFrame();\n\n el.timeout = 400;\n\n await elementUpdated(el);\n const secondStart = testableEl.countdownStart;\n\n expect(secondStart).to.not.equal(firstStart);\n\n await nextFrame();\n await nextFrame();\n\n el.timeout = 0;\n\n await elementUpdated(el);\n const thirdStart = testableEl.countdownStart;\n\n expect(thirdStart).to.equal(0);\n });\n it('stops timeout on `focusin`', async () => {\n const el = await fixture<Toast>(html`\n <sp-toast timeout=\"100\">Help text.</sp-toast>\n `);\n\n await elementUpdated(el);\n\n const testableEl = el as unknown as TestableToast;\n expect(el.open, 'not open to start').to.be.false;\n\n el.open = true;\n await elementUpdated(el);\n await nextFrame();\n\n expect(testableEl.countdownStart, 'initially not 0').to.not.equal(0);\n\n testableEl._timeout = 100;\n\n el.dispatchEvent(new FocusEvent('focusin'));\n\n await elementUpdated(el);\n expect(testableEl.countdownStart, '0 after focusin').to.equal(0);\n el.dispatchEvent(new FocusEvent('focusout'));\n\n await elementUpdated(el);\n await nextFrame();\n expect(testableEl.countdownStart, 'not 0 after focusout').to.not.equal(\n 0\n );\n\n await waitUntil(() => el.open === false, 'closes');\n expect(el.open, 'not open to end').to.be.false;\n });\n it('closes', async () => {\n const el = await fixture<Toast>(html`\n <sp-toast open>Help text.</sp-toast>\n `);\n\n await elementUpdated(el);\n expect(el.open).to.be.true;\n\n const renderRoot = el.shadowRoot ? el.shadowRoot : el;\n const closeButton = renderRoot.querySelector(\n 'sp-close-button'\n ) as CloseButton;\n closeButton.click();\n\n await elementUpdated(el);\n expect(el.open).to.be.false;\n });\n it('`close` can be prevented', async () => {\n const handleClose = (event: CustomEvent): void =>\n event.preventDefault();\n const el = await fixture<Toast>(html`\n <sp-toast open timeout=\"100\" @close=${handleClose}>\n Help text.\n </sp-toast>\n `);\n\n await elementUpdated(el);\n expect(el.open).to.be.true;\n\n const renderRoot = el.shadowRoot ? el.shadowRoot : el;\n const closeButton = renderRoot.querySelector(\n 'sp-close-button'\n ) as CloseButton;\n closeButton.click();\n\n await elementUpdated(el);\n expect(el.open).to.be.true;\n });\n it('can be a controlled element', async () => {\n const closeSpy = spy();\n const handleClose = (event: CustomEvent): void => {\n event.preventDefault();\n closeSpy();\n };\n const el = await fixture<Toast>(html`\n <sp-toast open timeout=\"100\" @close=${handleClose}>\n Help text.\n </sp-toast>\n `);\n\n await elementUpdated(el);\n expect(el.open).to.be.true;\n expect(closeSpy.callCount).to.equal(0);\n\n const renderRoot = el.shadowRoot ? el.shadowRoot : el;\n const closeButton = renderRoot.querySelector(\n 'sp-close-button'\n ) as CloseButton;\n closeButton.click();\n\n await elementUpdated(el);\n expect(el.open).to.be.true;\n expect(closeSpy.callCount).to.equal(1);\n\n el.open = false;\n await elementUpdated(el);\n expect(el.open).to.be.false;\n expect(closeSpy.callCount).to.equal(1);\n });\n it('validates variants', async () => {\n const el = await fixture<Toast>(html`\n <sp-toast variant=\"invalid\" open>\n This toast validates variants.\n </sp-toast>\n `);\n\n await elementUpdated(el);\n expect(el.variant).to.equal('');\n\n el.variant = toastVariants[0];\n\n await elementUpdated(el);\n expect(el.variant).to.equal(toastVariants[0]);\n\n el.variant = toastVariants[0];\n\n await elementUpdated(el);\n expect(el.variant).to.equal(toastVariants[0]);\n });\n it('maintains [variant] when disconnected/connected', async () => {\n const el = await fixture<Toast>(html`\n <sp-toast variant=\"positive\" open>\n This toast maintains variants.\n </sp-toast>\n `);\n\n await elementUpdated(el);\n expect(el.variant).to.equal('positive');\n const parent = el.parentElement as HTMLElement;\n\n el.remove();\n\n expect(el.variant).to.equal('positive');\n\n parent.append(el);\n\n expect(el.variant).to.equal('positive');\n });\n it('reopens', async () => {\n const closeSpy = spy();\n const el = await fixture<Toast>(html`\n <sp-toast\n variant=\"positive\"\n open\n @close=${() => {\n closeSpy();\n }}\n >\n This toast maintains variants.\n </sp-toast>\n `);\n\n await elementUpdated(el);\n expect(el.open).to.be.true;\n\n const closeButton = el.shadowRoot.querySelector(\n 'sp-close-button'\n ) as HTMLElement;\n closeButton.click();\n\n await elementUpdated(el);\n expect(el.open).to.be.false;\n\n el.open = true;\n\n await elementUpdated(el);\n expect(el.open).to.be.true;\n expect(closeSpy.callCount).to.equal(1);\n });\n it('sp close button renders with static-color=\"white\"', async () => {\n const el = await fixture<Toast>(html`\n <sp-toast open>Help text.</sp-toast>\n `);\n const renderRoot = el.shadowRoot ? el.shadowRoot : el;\n const closeButton = renderRoot.querySelector(\n 'sp-close-button'\n ) as CloseButton;\n\n expect(closeButton).to.exist;\n\n expect(closeButton.getAttribute('static-color')).to.equal('white');\n });\n});\n"],
|
|
5
|
+
"mappings": ";AAYA,OAAO;AACP,SAAgB,qBAAqB;AACrC;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAEP;AAAA,EACI;AAAA,EACA;AAAA,OACG;AACP,SAAS,WAAW;AAOpB,SAAS,SAAS,MAAM;AACpB;AAAA,IACI,YACI,MAAM,QAAe;AAAA;AAAA,aAEpB;AAAA,EACT;AACA,KAAG,SAAS,YAAY;AACpB,UAAM,KAAK,MAAM,QAAe;AAAA;AAAA,SAE/B;AAED,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AAA,EACrE,CAAC;AACL,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/custom-elements.json
DELETED
|
@@ -1,294 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"schemaVersion": "1.0.0",
|
|
3
|
-
"readme": "",
|
|
4
|
-
"modules": [
|
|
5
|
-
{
|
|
6
|
-
"kind": "javascript-module",
|
|
7
|
-
"path": "sp-toast.js",
|
|
8
|
-
"declarations": [],
|
|
9
|
-
"exports": [
|
|
10
|
-
{
|
|
11
|
-
"kind": "custom-element-definition",
|
|
12
|
-
"name": "sp-toast",
|
|
13
|
-
"declaration": {
|
|
14
|
-
"name": "Toast",
|
|
15
|
-
"module": "/src/Toast.js"
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
]
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"kind": "javascript-module",
|
|
22
|
-
"path": "src/Toast.js",
|
|
23
|
-
"declarations": [
|
|
24
|
-
{
|
|
25
|
-
"kind": "variable",
|
|
26
|
-
"name": "toastVariants",
|
|
27
|
-
"type": {
|
|
28
|
-
"text": "ToastVariants[]"
|
|
29
|
-
},
|
|
30
|
-
"default": "[\n 'negative',\n 'positive',\n 'info',\n 'error',\n 'warning',\n]"
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
"kind": "class",
|
|
34
|
-
"description": "",
|
|
35
|
-
"name": "Toast",
|
|
36
|
-
"slots": [
|
|
37
|
-
{
|
|
38
|
-
"description": "The toast content",
|
|
39
|
-
"name": ""
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
"description": "button element surfacing an action in the Toast",
|
|
43
|
-
"name": "action"
|
|
44
|
-
}
|
|
45
|
-
],
|
|
46
|
-
"members": [
|
|
47
|
-
{
|
|
48
|
-
"kind": "field",
|
|
49
|
-
"name": "open",
|
|
50
|
-
"type": {
|
|
51
|
-
"text": "boolean"
|
|
52
|
-
},
|
|
53
|
-
"privacy": "public",
|
|
54
|
-
"default": "false",
|
|
55
|
-
"attribute": "open",
|
|
56
|
-
"reflects": true
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
"kind": "field",
|
|
60
|
-
"name": "timeout",
|
|
61
|
-
"privacy": "public",
|
|
62
|
-
"description": "When a timeout is provided it represents the number of milliseconds from when\nthe Toast was placed on the page before it will automatically dismiss itself.\nAccessibility concerns require that a Toast is available for at least 6000ms\nbefore being dismissed, so any timeout of less than 6000ms will be raised to\nthat baseline. It is suggested that messages longer than 120 words should\nreceive another 1000ms in their timeout for each additional 120 words in the\nmessage. E.G. 240 words = 7000ms, 360 words = 8000ms, etc.",
|
|
63
|
-
"parameters": [
|
|
64
|
-
{
|
|
65
|
-
"name": "timeout",
|
|
66
|
-
"type": {
|
|
67
|
-
"text": "Number"
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
],
|
|
71
|
-
"type": {
|
|
72
|
-
"text": "number | null"
|
|
73
|
-
},
|
|
74
|
-
"attribute": "timeout"
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
"kind": "field",
|
|
78
|
-
"name": "_timeout",
|
|
79
|
-
"type": {
|
|
80
|
-
"text": "number | null"
|
|
81
|
-
},
|
|
82
|
-
"privacy": "public",
|
|
83
|
-
"default": "null"
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
"kind": "field",
|
|
87
|
-
"name": "variant",
|
|
88
|
-
"privacy": "public",
|
|
89
|
-
"description": "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.",
|
|
90
|
-
"parameters": [
|
|
91
|
-
{
|
|
92
|
-
"name": "variant",
|
|
93
|
-
"type": {
|
|
94
|
-
"text": "String"
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
],
|
|
98
|
-
"type": {
|
|
99
|
-
"text": "ToastVariants"
|
|
100
|
-
},
|
|
101
|
-
"attribute": "variant"
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
"kind": "field",
|
|
105
|
-
"name": "_variant",
|
|
106
|
-
"type": {
|
|
107
|
-
"text": "ToastVariants"
|
|
108
|
-
},
|
|
109
|
-
"privacy": "private",
|
|
110
|
-
"default": "''"
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
"kind": "method",
|
|
114
|
-
"name": "renderIcon",
|
|
115
|
-
"privacy": "private",
|
|
116
|
-
"return": {
|
|
117
|
-
"type": {
|
|
118
|
-
"text": "TemplateResult"
|
|
119
|
-
}
|
|
120
|
-
},
|
|
121
|
-
"parameters": [
|
|
122
|
-
{
|
|
123
|
-
"name": "variant",
|
|
124
|
-
"type": {
|
|
125
|
-
"text": "string"
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
]
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
"kind": "field",
|
|
132
|
-
"name": "countdownStart",
|
|
133
|
-
"type": {
|
|
134
|
-
"text": "number"
|
|
135
|
-
},
|
|
136
|
-
"privacy": "private",
|
|
137
|
-
"default": "0"
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
"kind": "field",
|
|
141
|
-
"name": "nextCount",
|
|
142
|
-
"type": {
|
|
143
|
-
"text": "number"
|
|
144
|
-
},
|
|
145
|
-
"privacy": "private",
|
|
146
|
-
"default": "-1"
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
"kind": "field",
|
|
150
|
-
"name": "doCountdown",
|
|
151
|
-
"privacy": "private"
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
"kind": "field",
|
|
155
|
-
"name": "countdown",
|
|
156
|
-
"privacy": "private"
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
"kind": "field",
|
|
160
|
-
"name": "holdCountdown",
|
|
161
|
-
"privacy": "private"
|
|
162
|
-
},
|
|
163
|
-
{
|
|
164
|
-
"kind": "field",
|
|
165
|
-
"name": "resumeCountdown",
|
|
166
|
-
"privacy": "private"
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
"kind": "method",
|
|
170
|
-
"name": "startCountdown",
|
|
171
|
-
"privacy": "private",
|
|
172
|
-
"return": {
|
|
173
|
-
"type": {
|
|
174
|
-
"text": "void"
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
},
|
|
178
|
-
{
|
|
179
|
-
"kind": "method",
|
|
180
|
-
"name": "stopCountdown",
|
|
181
|
-
"privacy": "private",
|
|
182
|
-
"return": {
|
|
183
|
-
"type": {
|
|
184
|
-
"text": "void"
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
"kind": "method",
|
|
190
|
-
"name": "shouldClose",
|
|
191
|
-
"privacy": "private",
|
|
192
|
-
"return": {
|
|
193
|
-
"type": {
|
|
194
|
-
"text": "void"
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
},
|
|
198
|
-
{
|
|
199
|
-
"kind": "method",
|
|
200
|
-
"name": "close",
|
|
201
|
-
"privacy": "public",
|
|
202
|
-
"return": {
|
|
203
|
-
"type": {
|
|
204
|
-
"text": "void"
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
],
|
|
209
|
-
"events": [
|
|
210
|
-
{
|
|
211
|
-
"name": "close",
|
|
212
|
-
"type": {
|
|
213
|
-
"text": "CustomEvent"
|
|
214
|
-
},
|
|
215
|
-
"description": "Announces that the Toast has been closed by the user or by its timeout."
|
|
216
|
-
}
|
|
217
|
-
],
|
|
218
|
-
"attributes": [
|
|
219
|
-
{
|
|
220
|
-
"name": "open",
|
|
221
|
-
"type": {
|
|
222
|
-
"text": "boolean"
|
|
223
|
-
},
|
|
224
|
-
"default": "false",
|
|
225
|
-
"fieldName": "open"
|
|
226
|
-
},
|
|
227
|
-
{
|
|
228
|
-
"name": "timeout",
|
|
229
|
-
"description": "When a timeout is provided it represents the number of milliseconds from when\nthe Toast was placed on the page before it will automatically dismiss itself.\nAccessibility concerns require that a Toast is available for at least 6000ms\nbefore being dismissed, so any timeout of less than 6000ms will be raised to\nthat baseline. It is suggested that messages longer than 120 words should\nreceive another 1000ms in their timeout for each additional 120 words in the\nmessage. E.G. 240 words = 7000ms, 360 words = 8000ms, etc.",
|
|
230
|
-
"parameters": [
|
|
231
|
-
{
|
|
232
|
-
"name": "timeout",
|
|
233
|
-
"type": {
|
|
234
|
-
"text": "Number"
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
],
|
|
238
|
-
"type": {
|
|
239
|
-
"text": "number | null"
|
|
240
|
-
},
|
|
241
|
-
"fieldName": "timeout"
|
|
242
|
-
},
|
|
243
|
-
{
|
|
244
|
-
"name": "variant",
|
|
245
|
-
"description": "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.",
|
|
246
|
-
"parameters": [
|
|
247
|
-
{
|
|
248
|
-
"name": "variant",
|
|
249
|
-
"type": {
|
|
250
|
-
"text": "String"
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
],
|
|
254
|
-
"type": {
|
|
255
|
-
"text": "ToastVariants"
|
|
256
|
-
},
|
|
257
|
-
"fieldName": "variant"
|
|
258
|
-
}
|
|
259
|
-
],
|
|
260
|
-
"mixins": [
|
|
261
|
-
{
|
|
262
|
-
"name": "FocusVisiblePolyfillMixin",
|
|
263
|
-
"package": "@spectrum-web-components/shared/src/focus-visible.js"
|
|
264
|
-
}
|
|
265
|
-
],
|
|
266
|
-
"superclass": {
|
|
267
|
-
"name": "SpectrumElement",
|
|
268
|
-
"package": "@spectrum-web-components/base"
|
|
269
|
-
},
|
|
270
|
-
"tagName": "sp-toast",
|
|
271
|
-
"customElement": true
|
|
272
|
-
}
|
|
273
|
-
],
|
|
274
|
-
"exports": [
|
|
275
|
-
{
|
|
276
|
-
"kind": "js",
|
|
277
|
-
"name": "toastVariants",
|
|
278
|
-
"declaration": {
|
|
279
|
-
"name": "toastVariants",
|
|
280
|
-
"module": "src/Toast.js"
|
|
281
|
-
}
|
|
282
|
-
},
|
|
283
|
-
{
|
|
284
|
-
"kind": "js",
|
|
285
|
-
"name": "Toast",
|
|
286
|
-
"declaration": {
|
|
287
|
-
"name": "Toast",
|
|
288
|
-
"module": "src/Toast.js"
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
]
|
|
292
|
-
}
|
|
293
|
-
]
|
|
294
|
-
}
|