@spectrum-web-components/toast 1.1.0 → 1.1.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.
Files changed (41) hide show
  1. package/package.json +7 -7
  2. package/sp-toast.d.ts +6 -0
  3. package/sp-toast.dev.js +5 -0
  4. package/sp-toast.dev.js.map +7 -0
  5. package/sp-toast.js +2 -0
  6. package/sp-toast.js.map +7 -0
  7. package/src/Toast.d.ts +79 -0
  8. package/src/Toast.dev.js +206 -0
  9. package/src/Toast.dev.js.map +7 -0
  10. package/src/Toast.js +37 -0
  11. package/src/Toast.js.map +7 -0
  12. package/src/index.d.ts +1 -0
  13. package/src/index.dev.js +3 -0
  14. package/src/index.dev.js.map +7 -0
  15. package/src/index.js +2 -0
  16. package/src/index.js.map +7 -0
  17. package/src/spectrum-toast.css.d.ts +2 -0
  18. package/src/spectrum-toast.css.dev.js +7 -0
  19. package/src/spectrum-toast.css.dev.js.map +7 -0
  20. package/src/spectrum-toast.css.js +4 -0
  21. package/src/spectrum-toast.css.js.map +7 -0
  22. package/src/toast-overrides.css.d.ts +2 -0
  23. package/src/toast-overrides.css.dev.js +7 -0
  24. package/src/toast-overrides.css.dev.js.map +7 -0
  25. package/src/toast-overrides.css.js +4 -0
  26. package/src/toast-overrides.css.js.map +7 -0
  27. package/src/toast.css.d.ts +2 -0
  28. package/src/toast.css.dev.js +7 -0
  29. package/src/toast.css.dev.js.map +7 -0
  30. package/src/toast.css.js +4 -0
  31. package/src/toast.css.js.map +7 -0
  32. package/stories/toast.stories.js +192 -0
  33. package/stories/toast.stories.js.map +7 -0
  34. package/test/benchmark/test-basic.js +8 -0
  35. package/test/benchmark/test-basic.js.map +7 -0
  36. package/test/toast-memory.test.js +8 -0
  37. package/test/toast-memory.test.js.map +7 -0
  38. package/test/toast.test-vrt.js +5 -0
  39. package/test/toast.test-vrt.js.map +7 -0
  40. package/test/toast.test.js +227 -0
  41. package/test/toast.test.js.map +7 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["toast-overrides.css.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2025 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-background-color-default:var(--system-toast-background-color-default);--spectrum-toast-font-weight:var(--system-toast-font-weight);--spectrum-toast-font-size:var(--system-toast-font-size);--spectrum-toast-corner-radius:var(--system-toast-corner-radius);--spectrum-toast-block-size:var(--system-toast-block-size);--spectrum-toast-max-inline-size:var(--system-toast-max-inline-size);--spectrum-toast-border-width:var(--system-toast-border-width);--spectrum-toast-line-height:var(--system-toast-line-height);--spectrum-toast-line-height-cjk:var(--system-toast-line-height-cjk);--spectrum-toast-spacing-icon-to-text:var(--system-toast-spacing-icon-to-text);--spectrum-toast-spacing-start-edge-to-text-and-icon:var(--system-toast-spacing-start-edge-to-text-and-icon);--spectrum-toast-spacing-text-and-action-button-to-divider:var(--system-toast-spacing-text-and-action-button-to-divider);--spectrum-toast-spacing-top-edge-to-divider:var(--system-toast-spacing-top-edge-to-divider);--spectrum-toast-spacing-bottom-edge-to-divider:var(--system-toast-spacing-bottom-edge-to-divider);--spectrum-toast-spacing-top-edge-to-icon:var(--system-toast-spacing-top-edge-to-icon);--spectrum-toast-spacing-text-to-action-button-horizontal:var(--system-toast-spacing-text-to-action-button-horizontal);--spectrum-toast-spacing-close-button:var(--system-toast-spacing-close-button);--spectrum-toast-spacing-block-start:var(--system-toast-spacing-block-start);--spectrum-toast-spacing-block-end:var(--system-toast-spacing-block-end);--spectrum-toast-spacing-top-edge-to-text:var(--system-toast-spacing-top-edge-to-text);--spectrum-toast-spacing-bottom-edge-to-text:var(--system-toast-spacing-bottom-edge-to-text);--spectrum-toast-negative-background-color-default:var(--system-toast-negative-background-color-default);--spectrum-toast-positive-background-color-default:var(--system-toast-positive-background-color-default);--spectrum-toast-informative-background-color-default:var(--system-toast-informative-background-color-default);--spectrum-toast-text-and-icon-color:var(--system-toast-text-and-icon-color);--spectrum-toast-divider-color:var(--system-toast-divider-color)}\n`;\nexport default styles;"],
5
+ "mappings": "aAWA,OAAS,OAAAA,MAAW,gCACpB,MAAMC,EAASD;AAAA;AAAA,EAGf,eAAeC",
6
+ "names": ["css", "styles"]
7
+ }
@@ -0,0 +1,2 @@
1
+ declare const styles: import("@spectrum-web-components/base").CSSResult;
2
+ export default styles;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ import { css } from "@spectrum-web-components/base";
3
+ const styles = css`
4
+ @media (forced-colors:active){:host{--highcontrast-toast-border-color:ButtonText;border:var(--mod-toast-border-width,var(--spectrum-toast-border-width))solid var(--highcontrast-toast-border-color,transparent)}}:host{box-sizing:border-box;min-block-size:var(--mod-toast-block-size,var(--spectrum-toast-block-size));max-inline-size:var(--mod-toast-max-inline-size,var(--spectrum-toast-max-inline-size));border-radius:var(--mod-toast-corner-radius,var(--spectrum-toast-corner-radius));font-size:var(--mod-toast-font-size,var(--spectrum-toast-font-size));font-weight:var(--mod-toast-font-weight,var(--spectrum-toast-font-weight));-webkit-font-smoothing:antialiased;background-color:var(--highcontrast-toast-background-color-default,var(--mod-toast-background-color-default,var(--spectrum-toast-background-color-default)));color:var(--highcontrast-toast-background-color-default,var(--mod-toast-background-color-default,var(--spectrum-toast-background-color-default)));overflow-wrap:anywhere;flex-direction:row;align-items:stretch;padding-inline-start:var(--mod-toast-spacing-start-edge-to-text-and-icon,var(--spectrum-toast-spacing-start-edge-to-text-and-icon));display:inline-flex}:host([variant=negative]){background-color:var(--highcontrast-toast-negative-background-color-default,var(--mod-toast-negative-background-color-default,var(--spectrum-toast-negative-background-color-default)))}:host([variant=negative]),:host([variant=negative]) .closeButton:focus-visible:not(:active){color:var(--highcontrast-toast-negative-background-color-default,var(--mod-toast-negative-background-color-default,var(--spectrum-toast-negative-background-color-default)))}:host([variant=info]){background-color:var(--highcontrast-toast-informative-background-color-default,var(--mod-toast-informative-background-color-default,var(--spectrum-toast-informative-background-color-default)))}:host([variant=info]),:host([variant=info]) .closeButton:focus-visible:not(:active){color:var(--highcontrast-toast-informative-background-color-default,var(--mod-toast-informative-background-color-default,var(--spectrum-toast-informative-background-color-default)))}:host([variant=positive]){background-color:var(--highcontrast-toast-positive-background-color-default,var(--mod-toast-positive-background-color-default,var(--spectrum-toast-positive-background-color-default)))}:host([variant=positive]),:host([variant=positive]) .closeButton:focus-visible:not(:active){color:var(--highcontrast-toast-positive-background-color-default,var(--mod-toast-positive-background-color-default,var(--spectrum-toast-positive-background-color-default)))}.type{flex-grow:0;flex-shrink:0;margin-block-start:var(--mod-toast-spacing-top-edge-to-icon,var(--spectrum-toast-spacing-top-edge-to-icon));margin-inline-start:0;margin-inline-end:var(--mod-toast-spacing-icon-to-text,var(--spectrum-toast-spacing-icon-to-text))}.content,.type{color:var(--highcontrast-toast-text-and-icon-color,var(--mod-toast-text-and-icon-color,var(--spectrum-toast-text-and-icon-color)))}.content{box-sizing:border-box;line-height:var(--mod-toast-line-height,var(--spectrum-toast-line-height));text-align:start;flex:auto;padding-block-start:calc(var(--mod-toast-spacing-top-edge-to-text,var(--spectrum-toast-spacing-top-edge-to-text)) - var(--mod-toast-spacing-block-start,var(--spectrum-toast-spacing-block-start)));padding-block-end:calc(var(--mod-toast-spacing-bottom-edge-to-text,var(--spectrum-toast-spacing-bottom-edge-to-text)) - var(--mod-toast-spacing-block-end,var(--spectrum-toast-spacing-block-end)));padding-inline-start:0;padding-inline-end:var(--mod-toast-spacing-text-to-action-button-horizontal,var(--spectrum-toast-spacing-text-to-action-button-horizontal));display:inline-block}.content:lang(ja),.content:lang(ko),.content:lang(zh){line-height:var(--mod-toast-line-height-cjk,var(--spectrum-toast-line-height-cjk))}.buttons{border-inline-start-color:var(--mod-toast-divider-color,var(--spectrum-toast-divider-color));flex:none;align-items:flex-start;margin-block-start:var(--mod-toast-spacing-top-edge-to-divider,var(--spectrum-toast-spacing-top-edge-to-divider));margin-block-end:var(--mod-toast-spacing-bottom-edge-to-divider,var(--spectrum-toast-spacing-bottom-edge-to-divider));padding-inline-end:var(--mod-toast-spacing-close-button,var(--spectrum-toast-spacing-close-button));display:flex}.buttons .spectrum-CloseButton{align-self:flex-start}.body{flex-wrap:wrap;flex:auto;align-self:center;align-items:center;padding-block-start:var(--mod-toast-spacing-block-start,var(--spectrum-toast-spacing-block-start));padding-block-end:var(--mod-toast-spacing-block-end,var(--spectrum-toast-spacing-block-end));display:flex}.body ::slotted([slot=action]){margin-inline-start:auto;margin-inline-end:var(--mod-toast-spacing-text-and-action-button-to-divider,var(--spectrum-toast-spacing-text-and-action-button-to-divider))}.body ::slotted([slot=action]:dir(rtl)),:host([dir=rtl]) .body ::slotted([slot=action]){margin-inline-end:var(--mod-toast-spacing-text-and-action-button-to-divider,var(--spectrum-toast-spacing-text-and-action-button-to-divider))}.body+.buttons{border-inline-start-style:solid;border-inline-start-width:1px;padding-inline-start:var(--mod-toast-spacing-close-button,var(--spectrum-toast-spacing-close-button))}:host{--spectrum-toast-background-color-default:var(--system-toast-background-color-default);--spectrum-toast-font-weight:var(--system-toast-font-weight);--spectrum-toast-font-size:var(--system-toast-font-size);--spectrum-toast-corner-radius:var(--system-toast-corner-radius);--spectrum-toast-block-size:var(--system-toast-block-size);--spectrum-toast-max-inline-size:var(--system-toast-max-inline-size);--spectrum-toast-border-width:var(--system-toast-border-width);--spectrum-toast-line-height:var(--system-toast-line-height);--spectrum-toast-line-height-cjk:var(--system-toast-line-height-cjk);--spectrum-toast-spacing-icon-to-text:var(--system-toast-spacing-icon-to-text);--spectrum-toast-spacing-start-edge-to-text-and-icon:var(--system-toast-spacing-start-edge-to-text-and-icon);--spectrum-toast-spacing-text-and-action-button-to-divider:var(--system-toast-spacing-text-and-action-button-to-divider);--spectrum-toast-spacing-top-edge-to-divider:var(--system-toast-spacing-top-edge-to-divider);--spectrum-toast-spacing-bottom-edge-to-divider:var(--system-toast-spacing-bottom-edge-to-divider);--spectrum-toast-spacing-top-edge-to-icon:var(--system-toast-spacing-top-edge-to-icon);--spectrum-toast-spacing-text-to-action-button-horizontal:var(--system-toast-spacing-text-to-action-button-horizontal);--spectrum-toast-spacing-close-button:var(--system-toast-spacing-close-button);--spectrum-toast-spacing-block-start:var(--system-toast-spacing-block-start);--spectrum-toast-spacing-block-end:var(--system-toast-spacing-block-end);--spectrum-toast-spacing-top-edge-to-text:var(--system-toast-spacing-top-edge-to-text);--spectrum-toast-spacing-bottom-edge-to-text:var(--system-toast-spacing-bottom-edge-to-text);--spectrum-toast-negative-background-color-default:var(--system-toast-negative-background-color-default);--spectrum-toast-positive-background-color-default:var(--system-toast-positive-background-color-default);--spectrum-toast-informative-background-color-default:var(--system-toast-informative-background-color-default);--spectrum-toast-text-and-icon-color:var(--system-toast-text-and-icon-color);--spectrum-toast-divider-color:var(--system-toast-divider-color)}:host{--spectrum-overlay-animation-distance:var(--spectrum-spacing-100);--spectrum-overlay-animation-duration:var(--spectrum-animation-duration-100);opacity:0;pointer-events:none;transition:transform var(--spectrum-overlay-animation-duration)ease-in-out,opacity var(--spectrum-overlay-animation-duration)ease-in-out,visibility 0s linear var(--spectrum-overlay-animation-duration);visibility:hidden}:host([open]){opacity:1;pointer-events:auto;visibility:visible;transition-delay:0s}:host([variant=error]),:host([variant=warning]){background-color:var(--highcontrast-toast-negative-background-color-default,var(--mod-toast-negative-background-color-default,var(--spectrum-toast-negative-background-color-default)))}:host([variant=negative]),:host([variant=negative]) .closeButton:focus-visible:not(:active),:host([variant=warning]),:host([variant=warning]) .closeButton:focus-visible:not(:active){color:var(--highcontrast-toast-negative-background-color-default,var(--mod-toast-negative-background-color-default,var(--spectrum-toast-negative-background-color-default)))}
5
+ `;
6
+ export default styles;
7
+ //# sourceMappingURL=toast.css.dev.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["toast.css.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2025 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 @media (forced-colors:active){:host{--highcontrast-toast-border-color:ButtonText;border:var(--mod-toast-border-width,var(--spectrum-toast-border-width))solid var(--highcontrast-toast-border-color,transparent)}}:host{box-sizing:border-box;min-block-size:var(--mod-toast-block-size,var(--spectrum-toast-block-size));max-inline-size:var(--mod-toast-max-inline-size,var(--spectrum-toast-max-inline-size));border-radius:var(--mod-toast-corner-radius,var(--spectrum-toast-corner-radius));font-size:var(--mod-toast-font-size,var(--spectrum-toast-font-size));font-weight:var(--mod-toast-font-weight,var(--spectrum-toast-font-weight));-webkit-font-smoothing:antialiased;background-color:var(--highcontrast-toast-background-color-default,var(--mod-toast-background-color-default,var(--spectrum-toast-background-color-default)));color:var(--highcontrast-toast-background-color-default,var(--mod-toast-background-color-default,var(--spectrum-toast-background-color-default)));overflow-wrap:anywhere;flex-direction:row;align-items:stretch;padding-inline-start:var(--mod-toast-spacing-start-edge-to-text-and-icon,var(--spectrum-toast-spacing-start-edge-to-text-and-icon));display:inline-flex}:host([variant=negative]){background-color:var(--highcontrast-toast-negative-background-color-default,var(--mod-toast-negative-background-color-default,var(--spectrum-toast-negative-background-color-default)))}:host([variant=negative]),:host([variant=negative]) .closeButton:focus-visible:not(:active){color:var(--highcontrast-toast-negative-background-color-default,var(--mod-toast-negative-background-color-default,var(--spectrum-toast-negative-background-color-default)))}:host([variant=info]){background-color:var(--highcontrast-toast-informative-background-color-default,var(--mod-toast-informative-background-color-default,var(--spectrum-toast-informative-background-color-default)))}:host([variant=info]),:host([variant=info]) .closeButton:focus-visible:not(:active){color:var(--highcontrast-toast-informative-background-color-default,var(--mod-toast-informative-background-color-default,var(--spectrum-toast-informative-background-color-default)))}:host([variant=positive]){background-color:var(--highcontrast-toast-positive-background-color-default,var(--mod-toast-positive-background-color-default,var(--spectrum-toast-positive-background-color-default)))}:host([variant=positive]),:host([variant=positive]) .closeButton:focus-visible:not(:active){color:var(--highcontrast-toast-positive-background-color-default,var(--mod-toast-positive-background-color-default,var(--spectrum-toast-positive-background-color-default)))}.type{flex-grow:0;flex-shrink:0;margin-block-start:var(--mod-toast-spacing-top-edge-to-icon,var(--spectrum-toast-spacing-top-edge-to-icon));margin-inline-start:0;margin-inline-end:var(--mod-toast-spacing-icon-to-text,var(--spectrum-toast-spacing-icon-to-text))}.content,.type{color:var(--highcontrast-toast-text-and-icon-color,var(--mod-toast-text-and-icon-color,var(--spectrum-toast-text-and-icon-color)))}.content{box-sizing:border-box;line-height:var(--mod-toast-line-height,var(--spectrum-toast-line-height));text-align:start;flex:auto;padding-block-start:calc(var(--mod-toast-spacing-top-edge-to-text,var(--spectrum-toast-spacing-top-edge-to-text)) - var(--mod-toast-spacing-block-start,var(--spectrum-toast-spacing-block-start)));padding-block-end:calc(var(--mod-toast-spacing-bottom-edge-to-text,var(--spectrum-toast-spacing-bottom-edge-to-text)) - var(--mod-toast-spacing-block-end,var(--spectrum-toast-spacing-block-end)));padding-inline-start:0;padding-inline-end:var(--mod-toast-spacing-text-to-action-button-horizontal,var(--spectrum-toast-spacing-text-to-action-button-horizontal));display:inline-block}.content:lang(ja),.content:lang(ko),.content:lang(zh){line-height:var(--mod-toast-line-height-cjk,var(--spectrum-toast-line-height-cjk))}.buttons{border-inline-start-color:var(--mod-toast-divider-color,var(--spectrum-toast-divider-color));flex:none;align-items:flex-start;margin-block-start:var(--mod-toast-spacing-top-edge-to-divider,var(--spectrum-toast-spacing-top-edge-to-divider));margin-block-end:var(--mod-toast-spacing-bottom-edge-to-divider,var(--spectrum-toast-spacing-bottom-edge-to-divider));padding-inline-end:var(--mod-toast-spacing-close-button,var(--spectrum-toast-spacing-close-button));display:flex}.buttons .spectrum-CloseButton{align-self:flex-start}.body{flex-wrap:wrap;flex:auto;align-self:center;align-items:center;padding-block-start:var(--mod-toast-spacing-block-start,var(--spectrum-toast-spacing-block-start));padding-block-end:var(--mod-toast-spacing-block-end,var(--spectrum-toast-spacing-block-end));display:flex}.body ::slotted([slot=action]){margin-inline-start:auto;margin-inline-end:var(--mod-toast-spacing-text-and-action-button-to-divider,var(--spectrum-toast-spacing-text-and-action-button-to-divider))}.body ::slotted([slot=action]:dir(rtl)),:host([dir=rtl]) .body ::slotted([slot=action]){margin-inline-end:var(--mod-toast-spacing-text-and-action-button-to-divider,var(--spectrum-toast-spacing-text-and-action-button-to-divider))}.body+.buttons{border-inline-start-style:solid;border-inline-start-width:1px;padding-inline-start:var(--mod-toast-spacing-close-button,var(--spectrum-toast-spacing-close-button))}:host{--spectrum-toast-background-color-default:var(--system-toast-background-color-default);--spectrum-toast-font-weight:var(--system-toast-font-weight);--spectrum-toast-font-size:var(--system-toast-font-size);--spectrum-toast-corner-radius:var(--system-toast-corner-radius);--spectrum-toast-block-size:var(--system-toast-block-size);--spectrum-toast-max-inline-size:var(--system-toast-max-inline-size);--spectrum-toast-border-width:var(--system-toast-border-width);--spectrum-toast-line-height:var(--system-toast-line-height);--spectrum-toast-line-height-cjk:var(--system-toast-line-height-cjk);--spectrum-toast-spacing-icon-to-text:var(--system-toast-spacing-icon-to-text);--spectrum-toast-spacing-start-edge-to-text-and-icon:var(--system-toast-spacing-start-edge-to-text-and-icon);--spectrum-toast-spacing-text-and-action-button-to-divider:var(--system-toast-spacing-text-and-action-button-to-divider);--spectrum-toast-spacing-top-edge-to-divider:var(--system-toast-spacing-top-edge-to-divider);--spectrum-toast-spacing-bottom-edge-to-divider:var(--system-toast-spacing-bottom-edge-to-divider);--spectrum-toast-spacing-top-edge-to-icon:var(--system-toast-spacing-top-edge-to-icon);--spectrum-toast-spacing-text-to-action-button-horizontal:var(--system-toast-spacing-text-to-action-button-horizontal);--spectrum-toast-spacing-close-button:var(--system-toast-spacing-close-button);--spectrum-toast-spacing-block-start:var(--system-toast-spacing-block-start);--spectrum-toast-spacing-block-end:var(--system-toast-spacing-block-end);--spectrum-toast-spacing-top-edge-to-text:var(--system-toast-spacing-top-edge-to-text);--spectrum-toast-spacing-bottom-edge-to-text:var(--system-toast-spacing-bottom-edge-to-text);--spectrum-toast-negative-background-color-default:var(--system-toast-negative-background-color-default);--spectrum-toast-positive-background-color-default:var(--system-toast-positive-background-color-default);--spectrum-toast-informative-background-color-default:var(--system-toast-informative-background-color-default);--spectrum-toast-text-and-icon-color:var(--system-toast-text-and-icon-color);--spectrum-toast-divider-color:var(--system-toast-divider-color)}:host{--spectrum-overlay-animation-distance:var(--spectrum-spacing-100);--spectrum-overlay-animation-duration:var(--spectrum-animation-duration-100);opacity:0;pointer-events:none;transition:transform var(--spectrum-overlay-animation-duration)ease-in-out,opacity var(--spectrum-overlay-animation-duration)ease-in-out,visibility 0s linear var(--spectrum-overlay-animation-duration);visibility:hidden}:host([open]){opacity:1;pointer-events:auto;visibility:visible;transition-delay:0s}:host([variant=error]),:host([variant=warning]){background-color:var(--highcontrast-toast-negative-background-color-default,var(--mod-toast-negative-background-color-default,var(--spectrum-toast-negative-background-color-default)))}:host([variant=negative]),:host([variant=negative]) .closeButton:focus-visible:not(:active),:host([variant=warning]),:host([variant=warning]) .closeButton:focus-visible:not(:active){color:var(--highcontrast-toast-negative-background-color-default,var(--mod-toast-negative-background-color-default,var(--spectrum-toast-negative-background-color-default)))}\n`;\nexport default styles;"],
5
+ "mappings": ";AAWA,SAAS,WAAW;AACpB,MAAM,SAAS;AAAA;AAAA;AAGf,eAAe;",
6
+ "names": []
7
+ }
@@ -0,0 +1,4 @@
1
+ "use strict";import{css as t}from"@spectrum-web-components/base";const o=t`
2
+ @media (forced-colors:active){:host{--highcontrast-toast-border-color:ButtonText;border:var(--mod-toast-border-width,var(--spectrum-toast-border-width))solid var(--highcontrast-toast-border-color,transparent)}}:host{box-sizing:border-box;min-block-size:var(--mod-toast-block-size,var(--spectrum-toast-block-size));max-inline-size:var(--mod-toast-max-inline-size,var(--spectrum-toast-max-inline-size));border-radius:var(--mod-toast-corner-radius,var(--spectrum-toast-corner-radius));font-size:var(--mod-toast-font-size,var(--spectrum-toast-font-size));font-weight:var(--mod-toast-font-weight,var(--spectrum-toast-font-weight));-webkit-font-smoothing:antialiased;background-color:var(--highcontrast-toast-background-color-default,var(--mod-toast-background-color-default,var(--spectrum-toast-background-color-default)));color:var(--highcontrast-toast-background-color-default,var(--mod-toast-background-color-default,var(--spectrum-toast-background-color-default)));overflow-wrap:anywhere;flex-direction:row;align-items:stretch;padding-inline-start:var(--mod-toast-spacing-start-edge-to-text-and-icon,var(--spectrum-toast-spacing-start-edge-to-text-and-icon));display:inline-flex}:host([variant=negative]){background-color:var(--highcontrast-toast-negative-background-color-default,var(--mod-toast-negative-background-color-default,var(--spectrum-toast-negative-background-color-default)))}:host([variant=negative]),:host([variant=negative]) .closeButton:focus-visible:not(:active){color:var(--highcontrast-toast-negative-background-color-default,var(--mod-toast-negative-background-color-default,var(--spectrum-toast-negative-background-color-default)))}:host([variant=info]){background-color:var(--highcontrast-toast-informative-background-color-default,var(--mod-toast-informative-background-color-default,var(--spectrum-toast-informative-background-color-default)))}:host([variant=info]),:host([variant=info]) .closeButton:focus-visible:not(:active){color:var(--highcontrast-toast-informative-background-color-default,var(--mod-toast-informative-background-color-default,var(--spectrum-toast-informative-background-color-default)))}:host([variant=positive]){background-color:var(--highcontrast-toast-positive-background-color-default,var(--mod-toast-positive-background-color-default,var(--spectrum-toast-positive-background-color-default)))}:host([variant=positive]),:host([variant=positive]) .closeButton:focus-visible:not(:active){color:var(--highcontrast-toast-positive-background-color-default,var(--mod-toast-positive-background-color-default,var(--spectrum-toast-positive-background-color-default)))}.type{flex-grow:0;flex-shrink:0;margin-block-start:var(--mod-toast-spacing-top-edge-to-icon,var(--spectrum-toast-spacing-top-edge-to-icon));margin-inline-start:0;margin-inline-end:var(--mod-toast-spacing-icon-to-text,var(--spectrum-toast-spacing-icon-to-text))}.content,.type{color:var(--highcontrast-toast-text-and-icon-color,var(--mod-toast-text-and-icon-color,var(--spectrum-toast-text-and-icon-color)))}.content{box-sizing:border-box;line-height:var(--mod-toast-line-height,var(--spectrum-toast-line-height));text-align:start;flex:auto;padding-block-start:calc(var(--mod-toast-spacing-top-edge-to-text,var(--spectrum-toast-spacing-top-edge-to-text)) - var(--mod-toast-spacing-block-start,var(--spectrum-toast-spacing-block-start)));padding-block-end:calc(var(--mod-toast-spacing-bottom-edge-to-text,var(--spectrum-toast-spacing-bottom-edge-to-text)) - var(--mod-toast-spacing-block-end,var(--spectrum-toast-spacing-block-end)));padding-inline-start:0;padding-inline-end:var(--mod-toast-spacing-text-to-action-button-horizontal,var(--spectrum-toast-spacing-text-to-action-button-horizontal));display:inline-block}.content:lang(ja),.content:lang(ko),.content:lang(zh){line-height:var(--mod-toast-line-height-cjk,var(--spectrum-toast-line-height-cjk))}.buttons{border-inline-start-color:var(--mod-toast-divider-color,var(--spectrum-toast-divider-color));flex:none;align-items:flex-start;margin-block-start:var(--mod-toast-spacing-top-edge-to-divider,var(--spectrum-toast-spacing-top-edge-to-divider));margin-block-end:var(--mod-toast-spacing-bottom-edge-to-divider,var(--spectrum-toast-spacing-bottom-edge-to-divider));padding-inline-end:var(--mod-toast-spacing-close-button,var(--spectrum-toast-spacing-close-button));display:flex}.buttons .spectrum-CloseButton{align-self:flex-start}.body{flex-wrap:wrap;flex:auto;align-self:center;align-items:center;padding-block-start:var(--mod-toast-spacing-block-start,var(--spectrum-toast-spacing-block-start));padding-block-end:var(--mod-toast-spacing-block-end,var(--spectrum-toast-spacing-block-end));display:flex}.body ::slotted([slot=action]){margin-inline-start:auto;margin-inline-end:var(--mod-toast-spacing-text-and-action-button-to-divider,var(--spectrum-toast-spacing-text-and-action-button-to-divider))}.body ::slotted([slot=action]:dir(rtl)),:host([dir=rtl]) .body ::slotted([slot=action]){margin-inline-end:var(--mod-toast-spacing-text-and-action-button-to-divider,var(--spectrum-toast-spacing-text-and-action-button-to-divider))}.body+.buttons{border-inline-start-style:solid;border-inline-start-width:1px;padding-inline-start:var(--mod-toast-spacing-close-button,var(--spectrum-toast-spacing-close-button))}:host{--spectrum-toast-background-color-default:var(--system-toast-background-color-default);--spectrum-toast-font-weight:var(--system-toast-font-weight);--spectrum-toast-font-size:var(--system-toast-font-size);--spectrum-toast-corner-radius:var(--system-toast-corner-radius);--spectrum-toast-block-size:var(--system-toast-block-size);--spectrum-toast-max-inline-size:var(--system-toast-max-inline-size);--spectrum-toast-border-width:var(--system-toast-border-width);--spectrum-toast-line-height:var(--system-toast-line-height);--spectrum-toast-line-height-cjk:var(--system-toast-line-height-cjk);--spectrum-toast-spacing-icon-to-text:var(--system-toast-spacing-icon-to-text);--spectrum-toast-spacing-start-edge-to-text-and-icon:var(--system-toast-spacing-start-edge-to-text-and-icon);--spectrum-toast-spacing-text-and-action-button-to-divider:var(--system-toast-spacing-text-and-action-button-to-divider);--spectrum-toast-spacing-top-edge-to-divider:var(--system-toast-spacing-top-edge-to-divider);--spectrum-toast-spacing-bottom-edge-to-divider:var(--system-toast-spacing-bottom-edge-to-divider);--spectrum-toast-spacing-top-edge-to-icon:var(--system-toast-spacing-top-edge-to-icon);--spectrum-toast-spacing-text-to-action-button-horizontal:var(--system-toast-spacing-text-to-action-button-horizontal);--spectrum-toast-spacing-close-button:var(--system-toast-spacing-close-button);--spectrum-toast-spacing-block-start:var(--system-toast-spacing-block-start);--spectrum-toast-spacing-block-end:var(--system-toast-spacing-block-end);--spectrum-toast-spacing-top-edge-to-text:var(--system-toast-spacing-top-edge-to-text);--spectrum-toast-spacing-bottom-edge-to-text:var(--system-toast-spacing-bottom-edge-to-text);--spectrum-toast-negative-background-color-default:var(--system-toast-negative-background-color-default);--spectrum-toast-positive-background-color-default:var(--system-toast-positive-background-color-default);--spectrum-toast-informative-background-color-default:var(--system-toast-informative-background-color-default);--spectrum-toast-text-and-icon-color:var(--system-toast-text-and-icon-color);--spectrum-toast-divider-color:var(--system-toast-divider-color)}:host{--spectrum-overlay-animation-distance:var(--spectrum-spacing-100);--spectrum-overlay-animation-duration:var(--spectrum-animation-duration-100);opacity:0;pointer-events:none;transition:transform var(--spectrum-overlay-animation-duration)ease-in-out,opacity var(--spectrum-overlay-animation-duration)ease-in-out,visibility 0s linear var(--spectrum-overlay-animation-duration);visibility:hidden}:host([open]){opacity:1;pointer-events:auto;visibility:visible;transition-delay:0s}:host([variant=error]),:host([variant=warning]){background-color:var(--highcontrast-toast-negative-background-color-default,var(--mod-toast-negative-background-color-default,var(--spectrum-toast-negative-background-color-default)))}:host([variant=negative]),:host([variant=negative]) .closeButton:focus-visible:not(:active),:host([variant=warning]),:host([variant=warning]) .closeButton:focus-visible:not(:active){color:var(--highcontrast-toast-negative-background-color-default,var(--mod-toast-negative-background-color-default,var(--spectrum-toast-negative-background-color-default)))}
3
+ `;export default o;
4
+ //# sourceMappingURL=toast.css.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["toast.css.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2025 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 @media (forced-colors:active){:host{--highcontrast-toast-border-color:ButtonText;border:var(--mod-toast-border-width,var(--spectrum-toast-border-width))solid var(--highcontrast-toast-border-color,transparent)}}:host{box-sizing:border-box;min-block-size:var(--mod-toast-block-size,var(--spectrum-toast-block-size));max-inline-size:var(--mod-toast-max-inline-size,var(--spectrum-toast-max-inline-size));border-radius:var(--mod-toast-corner-radius,var(--spectrum-toast-corner-radius));font-size:var(--mod-toast-font-size,var(--spectrum-toast-font-size));font-weight:var(--mod-toast-font-weight,var(--spectrum-toast-font-weight));-webkit-font-smoothing:antialiased;background-color:var(--highcontrast-toast-background-color-default,var(--mod-toast-background-color-default,var(--spectrum-toast-background-color-default)));color:var(--highcontrast-toast-background-color-default,var(--mod-toast-background-color-default,var(--spectrum-toast-background-color-default)));overflow-wrap:anywhere;flex-direction:row;align-items:stretch;padding-inline-start:var(--mod-toast-spacing-start-edge-to-text-and-icon,var(--spectrum-toast-spacing-start-edge-to-text-and-icon));display:inline-flex}:host([variant=negative]){background-color:var(--highcontrast-toast-negative-background-color-default,var(--mod-toast-negative-background-color-default,var(--spectrum-toast-negative-background-color-default)))}:host([variant=negative]),:host([variant=negative]) .closeButton:focus-visible:not(:active){color:var(--highcontrast-toast-negative-background-color-default,var(--mod-toast-negative-background-color-default,var(--spectrum-toast-negative-background-color-default)))}:host([variant=info]){background-color:var(--highcontrast-toast-informative-background-color-default,var(--mod-toast-informative-background-color-default,var(--spectrum-toast-informative-background-color-default)))}:host([variant=info]),:host([variant=info]) .closeButton:focus-visible:not(:active){color:var(--highcontrast-toast-informative-background-color-default,var(--mod-toast-informative-background-color-default,var(--spectrum-toast-informative-background-color-default)))}:host([variant=positive]){background-color:var(--highcontrast-toast-positive-background-color-default,var(--mod-toast-positive-background-color-default,var(--spectrum-toast-positive-background-color-default)))}:host([variant=positive]),:host([variant=positive]) .closeButton:focus-visible:not(:active){color:var(--highcontrast-toast-positive-background-color-default,var(--mod-toast-positive-background-color-default,var(--spectrum-toast-positive-background-color-default)))}.type{flex-grow:0;flex-shrink:0;margin-block-start:var(--mod-toast-spacing-top-edge-to-icon,var(--spectrum-toast-spacing-top-edge-to-icon));margin-inline-start:0;margin-inline-end:var(--mod-toast-spacing-icon-to-text,var(--spectrum-toast-spacing-icon-to-text))}.content,.type{color:var(--highcontrast-toast-text-and-icon-color,var(--mod-toast-text-and-icon-color,var(--spectrum-toast-text-and-icon-color)))}.content{box-sizing:border-box;line-height:var(--mod-toast-line-height,var(--spectrum-toast-line-height));text-align:start;flex:auto;padding-block-start:calc(var(--mod-toast-spacing-top-edge-to-text,var(--spectrum-toast-spacing-top-edge-to-text)) - var(--mod-toast-spacing-block-start,var(--spectrum-toast-spacing-block-start)));padding-block-end:calc(var(--mod-toast-spacing-bottom-edge-to-text,var(--spectrum-toast-spacing-bottom-edge-to-text)) - var(--mod-toast-spacing-block-end,var(--spectrum-toast-spacing-block-end)));padding-inline-start:0;padding-inline-end:var(--mod-toast-spacing-text-to-action-button-horizontal,var(--spectrum-toast-spacing-text-to-action-button-horizontal));display:inline-block}.content:lang(ja),.content:lang(ko),.content:lang(zh){line-height:var(--mod-toast-line-height-cjk,var(--spectrum-toast-line-height-cjk))}.buttons{border-inline-start-color:var(--mod-toast-divider-color,var(--spectrum-toast-divider-color));flex:none;align-items:flex-start;margin-block-start:var(--mod-toast-spacing-top-edge-to-divider,var(--spectrum-toast-spacing-top-edge-to-divider));margin-block-end:var(--mod-toast-spacing-bottom-edge-to-divider,var(--spectrum-toast-spacing-bottom-edge-to-divider));padding-inline-end:var(--mod-toast-spacing-close-button,var(--spectrum-toast-spacing-close-button));display:flex}.buttons .spectrum-CloseButton{align-self:flex-start}.body{flex-wrap:wrap;flex:auto;align-self:center;align-items:center;padding-block-start:var(--mod-toast-spacing-block-start,var(--spectrum-toast-spacing-block-start));padding-block-end:var(--mod-toast-spacing-block-end,var(--spectrum-toast-spacing-block-end));display:flex}.body ::slotted([slot=action]){margin-inline-start:auto;margin-inline-end:var(--mod-toast-spacing-text-and-action-button-to-divider,var(--spectrum-toast-spacing-text-and-action-button-to-divider))}.body ::slotted([slot=action]:dir(rtl)),:host([dir=rtl]) .body ::slotted([slot=action]){margin-inline-end:var(--mod-toast-spacing-text-and-action-button-to-divider,var(--spectrum-toast-spacing-text-and-action-button-to-divider))}.body+.buttons{border-inline-start-style:solid;border-inline-start-width:1px;padding-inline-start:var(--mod-toast-spacing-close-button,var(--spectrum-toast-spacing-close-button))}:host{--spectrum-toast-background-color-default:var(--system-toast-background-color-default);--spectrum-toast-font-weight:var(--system-toast-font-weight);--spectrum-toast-font-size:var(--system-toast-font-size);--spectrum-toast-corner-radius:var(--system-toast-corner-radius);--spectrum-toast-block-size:var(--system-toast-block-size);--spectrum-toast-max-inline-size:var(--system-toast-max-inline-size);--spectrum-toast-border-width:var(--system-toast-border-width);--spectrum-toast-line-height:var(--system-toast-line-height);--spectrum-toast-line-height-cjk:var(--system-toast-line-height-cjk);--spectrum-toast-spacing-icon-to-text:var(--system-toast-spacing-icon-to-text);--spectrum-toast-spacing-start-edge-to-text-and-icon:var(--system-toast-spacing-start-edge-to-text-and-icon);--spectrum-toast-spacing-text-and-action-button-to-divider:var(--system-toast-spacing-text-and-action-button-to-divider);--spectrum-toast-spacing-top-edge-to-divider:var(--system-toast-spacing-top-edge-to-divider);--spectrum-toast-spacing-bottom-edge-to-divider:var(--system-toast-spacing-bottom-edge-to-divider);--spectrum-toast-spacing-top-edge-to-icon:var(--system-toast-spacing-top-edge-to-icon);--spectrum-toast-spacing-text-to-action-button-horizontal:var(--system-toast-spacing-text-to-action-button-horizontal);--spectrum-toast-spacing-close-button:var(--system-toast-spacing-close-button);--spectrum-toast-spacing-block-start:var(--system-toast-spacing-block-start);--spectrum-toast-spacing-block-end:var(--system-toast-spacing-block-end);--spectrum-toast-spacing-top-edge-to-text:var(--system-toast-spacing-top-edge-to-text);--spectrum-toast-spacing-bottom-edge-to-text:var(--system-toast-spacing-bottom-edge-to-text);--spectrum-toast-negative-background-color-default:var(--system-toast-negative-background-color-default);--spectrum-toast-positive-background-color-default:var(--system-toast-positive-background-color-default);--spectrum-toast-informative-background-color-default:var(--system-toast-informative-background-color-default);--spectrum-toast-text-and-icon-color:var(--system-toast-text-and-icon-color);--spectrum-toast-divider-color:var(--system-toast-divider-color)}:host{--spectrum-overlay-animation-distance:var(--spectrum-spacing-100);--spectrum-overlay-animation-duration:var(--spectrum-animation-duration-100);opacity:0;pointer-events:none;transition:transform var(--spectrum-overlay-animation-duration)ease-in-out,opacity var(--spectrum-overlay-animation-duration)ease-in-out,visibility 0s linear var(--spectrum-overlay-animation-duration);visibility:hidden}:host([open]){opacity:1;pointer-events:auto;visibility:visible;transition-delay:0s}:host([variant=error]),:host([variant=warning]){background-color:var(--highcontrast-toast-negative-background-color-default,var(--mod-toast-negative-background-color-default,var(--spectrum-toast-negative-background-color-default)))}:host([variant=negative]),:host([variant=negative]) .closeButton:focus-visible:not(:active),:host([variant=warning]),:host([variant=warning]) .closeButton:focus-visible:not(:active){color:var(--highcontrast-toast-negative-background-color-default,var(--mod-toast-negative-background-color-default,var(--spectrum-toast-negative-background-color-default)))}\n`;\nexport default styles;"],
5
+ "mappings": "aAWA,OAAS,OAAAA,MAAW,gCACpB,MAAMC,EAASD;AAAA;AAAA,EAGf,eAAeC",
6
+ "names": ["css", "styles"]
7
+ }
@@ -0,0 +1,192 @@
1
+ "use strict";
2
+ import { html } from "@spectrum-web-components/base";
3
+ import "@spectrum-web-components/toast/sp-toast.js";
4
+ import "@spectrum-web-components/button/sp-button.js";
5
+ import "@spectrum-web-components/overlay/sp-overlay.js";
6
+ import "@spectrum-web-components/overlay/overlay-trigger.js";
7
+ import { ifDefined } from "@spectrum-web-components/base/src/directives.js";
8
+ const toast = ({
9
+ variant = "",
10
+ open = true,
11
+ content = "",
12
+ timeout = 0,
13
+ iconLabel = ""
14
+ }) => html`
15
+ <sp-toast
16
+ variant=${variant}
17
+ ?open=${open}
18
+ timeout=${ifDefined(timeout)}
19
+ .iconLabel=${iconLabel}
20
+ >
21
+ ${content}
22
+ <sp-button
23
+ slot="action"
24
+ static-color="white"
25
+ variant="secondary"
26
+ treatment="outline"
27
+ >
28
+ Undo
29
+ </sp-button>
30
+ </sp-toast>
31
+ `;
32
+ export default {
33
+ component: "sp-toast",
34
+ title: "Toast",
35
+ args: {
36
+ content: "This is a toast message.",
37
+ open: true
38
+ },
39
+ argTypes: {
40
+ content: {
41
+ name: "content",
42
+ type: { name: "string", required: false },
43
+ table: {
44
+ type: { summary: "string" },
45
+ defaultValue: { summary: "" }
46
+ }
47
+ },
48
+ open: {
49
+ name: "open",
50
+ type: { name: "boolean", required: false },
51
+ table: {
52
+ type: { summary: "boolean" },
53
+ defaultValue: { summary: false }
54
+ }
55
+ },
56
+ variant: {
57
+ name: "variant",
58
+ options: ["", "negative", "positive", "info", "error", "warning"],
59
+ table: {
60
+ type: { summary: "string" },
61
+ defaultValue: { summary: "" }
62
+ },
63
+ control: {
64
+ type: "select"
65
+ }
66
+ },
67
+ timeout: {
68
+ name: "timeout",
69
+ type: { name: "number", required: false },
70
+ table: {
71
+ type: { summary: "number" },
72
+ defaultValue: { summary: null }
73
+ }
74
+ },
75
+ iconLabel: {
76
+ name: "iconLabel",
77
+ type: { name: "string", required: false },
78
+ table: {
79
+ type: { summary: "string" },
80
+ defaultValue: { summary: "" }
81
+ }
82
+ }
83
+ }
84
+ };
85
+ export const Default = ({
86
+ variant,
87
+ open,
88
+ content,
89
+ timeout,
90
+ iconLabel
91
+ }) => {
92
+ return toast({ variant, open, content, timeout, iconLabel });
93
+ };
94
+ const variantDemo = ({
95
+ variant,
96
+ open,
97
+ content,
98
+ timeout,
99
+ iconLabel
100
+ }) => {
101
+ return toast({ variant, open, content, timeout, iconLabel });
102
+ };
103
+ export const Positive = (args) => variantDemo({ ...args, variant: "positive" });
104
+ export const Negative = (args) => variantDemo({ ...args, variant: "negative" });
105
+ export const Info = (args) => variantDemo({ ...args, variant: "info" });
106
+ export const Wrapping = (args) => variantDemo({
107
+ ...args,
108
+ variant: "info",
109
+ content: "A new version of Lightroom Classic is now available. Use the Update button below to start using the new version."
110
+ });
111
+ const overlayStyles = html`
112
+ <style>
113
+ html,
114
+ body,
115
+ #root,
116
+ #root-inner,
117
+ sp-story-decorator {
118
+ height: 100%;
119
+ margin: 0;
120
+ }
121
+
122
+ sp-story-decorator > div {
123
+ display: contents;
124
+ }
125
+
126
+ sp-story-decorator::part(container) {
127
+ display: flex;
128
+ flex-direction: column;
129
+ width: 100%;
130
+ height: 100%;
131
+ align-items: center;
132
+ justify-content: center;
133
+ }
134
+
135
+ overlay-trigger {
136
+ flex: none;
137
+ margin: 24px 0;
138
+ }
139
+
140
+ .self-managed:nth-child(3) {
141
+ margin-left: 50px;
142
+ }
143
+ </style>
144
+ `;
145
+ const overlaid = (openPlacement) => {
146
+ return html`
147
+ ${overlayStyles}
148
+ ${[
149
+ ["bottom", ""],
150
+ ["left", "negative"],
151
+ ["right", "positive"],
152
+ ["top", "info"]
153
+ ].map(([placement, variant]) => {
154
+ return html`
155
+ <overlay-trigger
156
+ placement=${placement}
157
+ open=${ifDefined(
158
+ openPlacement === placement ? "click" : void 0
159
+ )}
160
+ >
161
+ <sp-button label="${placement} test" slot="trigger">
162
+ Click for ${variant ? variant : "toast"} on the
163
+ ${placement}
164
+ </sp-button>
165
+ <sp-toast slot="click-content" variant=${variant}>
166
+ ${placement}
167
+ </sp-toast>
168
+ </overlay-trigger>
169
+ `;
170
+ })}
171
+ `;
172
+ };
173
+ export const overlaidTop = () => overlaid("top");
174
+ export const overlaidRight = () => overlaid("right");
175
+ export const overlaidBottom = () => overlaid("bottom");
176
+ export const overlaidLeft = () => overlaid("left");
177
+ export const overlay = (args) => {
178
+ return html`
179
+ <style>
180
+ sp-toast {
181
+ position: fixed;
182
+ bottom: 1em;
183
+ left: 1em;
184
+ }
185
+ </style>
186
+ <sp-button id="overlay">Toggle Toast overlay</sp-button>
187
+ <sp-overlay trigger="overlay@click" type="auto" open>
188
+ ${variantDemo({ ...args, variant: "positive" })}
189
+ </sp-overlay>
190
+ `;
191
+ };
192
+ //# sourceMappingURL=toast.stories.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 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 timeout = 0,\n iconLabel = '',\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 timeout=${ifDefined(timeout)}\n .iconLabel=${iconLabel}\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 },\n open: {\n name: 'open',\n type: { name: 'boolean', required: false },\n table: {\n type: { summary: 'boolean' },\n defaultValue: { summary: false },\n },\n },\n variant: {\n name: 'variant',\n options: ['', 'negative', 'positive', 'info', 'error', 'warning'],\n table: {\n type: { summary: 'string' },\n defaultValue: { summary: '' },\n },\n control: {\n type: 'select',\n },\n },\n timeout: {\n name: 'timeout',\n type: { name: 'number', required: false },\n table: {\n type: { summary: 'number' },\n defaultValue: { summary: null },\n },\n },\n iconLabel: {\n name: 'iconLabel',\n type: { name: 'string', required: false },\n table: {\n type: { summary: 'string' },\n defaultValue: { summary: '' },\n },\n },\n },\n};\n\ninterface Properties {\n variant: '' | 'negative' | 'positive' | 'info' | 'error' | 'warning';\n open: boolean;\n content: string;\n timeout: number;\n iconLabel: string;\n onClose: (event: Event) => void;\n}\n\nexport const Default = ({\n variant,\n open,\n content,\n timeout,\n iconLabel,\n}: Properties): TemplateResult => {\n return toast({ variant, open, content, timeout, iconLabel });\n};\n\nconst variantDemo = ({\n variant,\n open,\n content,\n timeout,\n iconLabel,\n}: Properties): TemplateResult => {\n return toast({ variant, open, content, timeout, iconLabel });\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
+ "mappings": "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",
6
+ "names": []
7
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ import "@spectrum-web-components/toast/sp-toast.js";
3
+ import { html } from "lit";
4
+ import { measureFixtureCreation } from "../../../../test/benchmark/helpers.js";
5
+ measureFixtureCreation(html`
6
+ <sp-toast>Tip me!</sp-toast>
7
+ `);
8
+ //# sourceMappingURL=test-basic.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["test-basic.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 { html } from 'lit';\nimport { measureFixtureCreation } from '../../../../test/benchmark/helpers.js';\n\nmeasureFixtureCreation(html`\n <sp-toast>Tip me!</sp-toast>\n`);\n"],
5
+ "mappings": ";AAYA,OAAO;AACP,SAAS,YAAY;AACrB,SAAS,8BAA8B;AAEvC,uBAAuB;AAAA;AAAA,CAEtB;",
6
+ "names": []
7
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ import { html } from "@open-wc/testing";
3
+ import "@spectrum-web-components/toast/sp-toast.js";
4
+ import { testForMemoryLeaks } from "../../../test/testing-helpers.js";
5
+ testForMemoryLeaks(html`
6
+ <sp-toast></sp-toast>
7
+ `);
8
+ //# sourceMappingURL=toast-memory.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["toast-memory.test.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2023 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\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 { html } from '@open-wc/testing';\nimport '@spectrum-web-components/toast/sp-toast.js';\nimport { testForMemoryLeaks } from '../../../test/testing-helpers.js';\n\ntestForMemoryLeaks(html`\n <sp-toast></sp-toast>\n`);\n"],
5
+ "mappings": ";AAWA,SAAS,YAAY;AACrB,OAAO;AACP,SAAS,0BAA0B;AAEnC,mBAAmB;AAAA;AAAA,CAElB;",
6
+ "names": []
7
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ import * as stories from "../stories/toast.stories.js";
3
+ import { regressVisuals } from "../../../test/visual/test.js";
4
+ regressVisuals("ToastStories", stories);
5
+ //# sourceMappingURL=toast.test-vrt.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["toast.test-vrt.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 * as stories from '../stories/toast.stories.js';\nimport { regressVisuals } from '../../../test/visual/test.js';\nimport type { TestsType } from '../../../test/visual/test.js';\n\nregressVisuals('ToastStories', stories as unknown as TestsType);\n"],
5
+ "mappings": ";AAYA,YAAY,aAAa;AACzB,SAAS,sBAAsB;AAG/B,eAAe,gBAAgB,OAA+B;",
6
+ "names": []
7
+ }
@@ -0,0 +1,227 @@
1
+ "use strict";
2
+ import "@spectrum-web-components/toast/sp-toast.js";
3
+ import { toastVariants } from "@spectrum-web-components/toast";
4
+ import {
5
+ elementUpdated,
6
+ expect,
7
+ fixture,
8
+ html,
9
+ nextFrame,
10
+ waitUntil
11
+ } from "@open-wc/testing";
12
+ import {
13
+ testForLitDevWarnings,
14
+ waitForPredicate
15
+ } from "../../../test/testing-helpers.js";
16
+ import { spy } from "sinon";
17
+ describe("Toast", () => {
18
+ testForLitDevWarnings(
19
+ async () => await fixture(html`
20
+ <sp-toast open>Help text.</sp-toast>
21
+ `)
22
+ );
23
+ it("loads", async () => {
24
+ const el = await fixture(html`
25
+ <sp-toast open>Help text.</sp-toast>
26
+ `);
27
+ await elementUpdated(el);
28
+ await expect(el).to.be.accessible();
29
+ });
30
+ toastVariants.map((variant) => {
31
+ it(`loads - [variant="${variant}"]`, async () => {
32
+ const el = await fixture(html`
33
+ <sp-toast variant=${variant} open>
34
+ This toast is of the \`${variant}\` variant.
35
+ </sp-toast>
36
+ `);
37
+ await elementUpdated(el);
38
+ await expect(el).to.be.accessible();
39
+ });
40
+ });
41
+ it("loads - timeout", async () => {
42
+ const el = await fixture(html`
43
+ <sp-toast timeout="100">Help text.</sp-toast>
44
+ `);
45
+ await elementUpdated(el);
46
+ expect(el.open).to.be.false;
47
+ el._timeout = 100;
48
+ el.open = true;
49
+ await elementUpdated(el);
50
+ await waitForPredicate(() => el.open === false);
51
+ expect(el.open).to.be.false;
52
+ });
53
+ it("`timeout` updates `countdownStart`", async () => {
54
+ const el = await fixture(html`
55
+ <sp-toast timeout="100">Help text.</sp-toast>
56
+ `);
57
+ await elementUpdated(el);
58
+ expect(el.open).to.be.false;
59
+ const testableEl = el;
60
+ testableEl._timeout = 100;
61
+ el.open = true;
62
+ await elementUpdated(el);
63
+ const firstStart = testableEl.countdownStart;
64
+ await nextFrame();
65
+ await nextFrame();
66
+ await nextFrame();
67
+ el.timeout = 400;
68
+ await elementUpdated(el);
69
+ const secondStart = testableEl.countdownStart;
70
+ expect(secondStart).to.not.equal(firstStart);
71
+ await nextFrame();
72
+ await nextFrame();
73
+ el.timeout = 0;
74
+ await elementUpdated(el);
75
+ const thirdStart = testableEl.countdownStart;
76
+ expect(thirdStart).to.equal(0);
77
+ });
78
+ it("stops timeout on `focusin`", async () => {
79
+ const el = await fixture(html`
80
+ <sp-toast timeout="100">Help text.</sp-toast>
81
+ `);
82
+ await elementUpdated(el);
83
+ const testableEl = el;
84
+ expect(el.open, "not open to start").to.be.false;
85
+ el.open = true;
86
+ await elementUpdated(el);
87
+ await nextFrame();
88
+ expect(testableEl.countdownStart, "initially not 0").to.not.equal(0);
89
+ testableEl._timeout = 100;
90
+ el.dispatchEvent(new FocusEvent("focusin"));
91
+ await elementUpdated(el);
92
+ expect(testableEl.countdownStart, "0 after focusin").to.equal(0);
93
+ el.dispatchEvent(new FocusEvent("focusout"));
94
+ await elementUpdated(el);
95
+ await nextFrame();
96
+ expect(testableEl.countdownStart, "not 0 after focusout").to.not.equal(
97
+ 0
98
+ );
99
+ await waitUntil(() => el.open === false, "closes");
100
+ expect(el.open, "not open to end").to.be.false;
101
+ });
102
+ it("closes", async () => {
103
+ const el = await fixture(html`
104
+ <sp-toast open>Help text.</sp-toast>
105
+ `);
106
+ await elementUpdated(el);
107
+ expect(el.open).to.be.true;
108
+ const renderRoot = el.shadowRoot ? el.shadowRoot : el;
109
+ const closeButton = renderRoot.querySelector(
110
+ "sp-close-button"
111
+ );
112
+ closeButton.click();
113
+ await elementUpdated(el);
114
+ expect(el.open).to.be.false;
115
+ });
116
+ it("`close` can be prevented", async () => {
117
+ const handleClose = (event) => event.preventDefault();
118
+ const el = await fixture(html`
119
+ <sp-toast open timeout="100" @close=${handleClose}>
120
+ Help text.
121
+ </sp-toast>
122
+ `);
123
+ await elementUpdated(el);
124
+ expect(el.open).to.be.true;
125
+ const renderRoot = el.shadowRoot ? el.shadowRoot : el;
126
+ const closeButton = renderRoot.querySelector(
127
+ "sp-close-button"
128
+ );
129
+ closeButton.click();
130
+ await elementUpdated(el);
131
+ expect(el.open).to.be.true;
132
+ });
133
+ it("can be a controlled element", async () => {
134
+ const closeSpy = spy();
135
+ const handleClose = (event) => {
136
+ event.preventDefault();
137
+ closeSpy();
138
+ };
139
+ const el = await fixture(html`
140
+ <sp-toast open timeout="100" @close=${handleClose}>
141
+ Help text.
142
+ </sp-toast>
143
+ `);
144
+ await elementUpdated(el);
145
+ expect(el.open).to.be.true;
146
+ expect(closeSpy.callCount).to.equal(0);
147
+ const renderRoot = el.shadowRoot ? el.shadowRoot : el;
148
+ const closeButton = renderRoot.querySelector(
149
+ "sp-close-button"
150
+ );
151
+ closeButton.click();
152
+ await elementUpdated(el);
153
+ expect(el.open).to.be.true;
154
+ expect(closeSpy.callCount).to.equal(1);
155
+ el.open = false;
156
+ await elementUpdated(el);
157
+ expect(el.open).to.be.false;
158
+ expect(closeSpy.callCount).to.equal(1);
159
+ });
160
+ it("validates variants", async () => {
161
+ const el = await fixture(html`
162
+ <sp-toast variant="invalid" open>
163
+ This toast validates variants.
164
+ </sp-toast>
165
+ `);
166
+ await elementUpdated(el);
167
+ expect(el.variant).to.equal("");
168
+ el.variant = toastVariants[0];
169
+ await elementUpdated(el);
170
+ expect(el.variant).to.equal(toastVariants[0]);
171
+ el.variant = toastVariants[0];
172
+ await elementUpdated(el);
173
+ expect(el.variant).to.equal(toastVariants[0]);
174
+ });
175
+ it("maintains [variant] when disconnected/connected", async () => {
176
+ const el = await fixture(html`
177
+ <sp-toast variant="positive" open>
178
+ This toast maintains variants.
179
+ </sp-toast>
180
+ `);
181
+ await elementUpdated(el);
182
+ expect(el.variant).to.equal("positive");
183
+ const parent = el.parentElement;
184
+ el.remove();
185
+ expect(el.variant).to.equal("positive");
186
+ parent.append(el);
187
+ expect(el.variant).to.equal("positive");
188
+ });
189
+ it("reopens", async () => {
190
+ const closeSpy = spy();
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
+ `);
202
+ await elementUpdated(el);
203
+ expect(el.open).to.be.true;
204
+ const closeButton = el.shadowRoot.querySelector(
205
+ "sp-close-button"
206
+ );
207
+ closeButton.click();
208
+ await elementUpdated(el);
209
+ expect(el.open).to.be.false;
210
+ el.open = true;
211
+ await elementUpdated(el);
212
+ expect(el.open).to.be.true;
213
+ expect(closeSpy.callCount).to.equal(1);
214
+ });
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
+ `);
219
+ const renderRoot = el.shadowRoot ? el.shadowRoot : el;
220
+ const closeButton = renderRoot.querySelector(
221
+ "sp-close-button"
222
+ );
223
+ expect(closeButton).to.exist;
224
+ expect(closeButton.getAttribute("static-color")).to.equal("white");
225
+ });
226
+ });
227
+ //# sourceMappingURL=toast.test.js.map