@aurodesignsystem-dev/auro-toast 0.0.0-pr156.0 → 0.0.0-pr156.2
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 +0 -1
- package/custom-elements.json +1 -1
- package/demo/api.min.js +2 -2
- package/demo/index.min.js +2 -2
- package/demo/readme.md +0 -1
- package/dist/{auro-toaster-BghWbuzd.js → auro-toaster-Cl6LVy6n.js} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/registered.js +1 -1
- package/package.json +1 -3
- package/src/auro-toast.js +0 -538
- package/src/auro-toaster.js +0 -175
- package/src/buttonVersion.js +0 -1
- package/src/iconVersion.js +0 -1
- package/src/index.js +0 -4
- package/src/registered.js +0 -5
- package/src/styles/color.scss +0 -34
- package/src/styles/style-toaster.scss +0 -27
- package/src/styles/style.scss +0 -61
- package/src/styles/tokens.scss +0 -8
package/README.md
CHANGED
|
@@ -107,7 +107,6 @@ You can do this by importing only the component class and using the `register(na
|
|
|
107
107
|
|
|
108
108
|
<pre class="language-js"><code class="language-js">// Import the class only
|
|
109
109
|
import { AuroToast } from '@aurodesignsystem/auro-toast/class';
|
|
110
|
-
|
|
111
110
|
// Register with a custom name if desired
|
|
112
111
|
AuroToast.register('custom-toast');</code></pre>
|
|
113
112
|
|
package/custom-elements.json
CHANGED
package/demo/api.min.js
CHANGED
|
@@ -821,13 +821,13 @@ class AuroToast extends i$2 {
|
|
|
821
821
|
* Emits closed toast event.
|
|
822
822
|
*
|
|
823
823
|
* @event toast-close
|
|
824
|
-
* @type {{ visible: boolean }}
|
|
824
|
+
* @type {{ visible: boolean, id: string }}
|
|
825
825
|
*/
|
|
826
826
|
this.dispatchEvent(
|
|
827
827
|
new CustomEvent("toast-close", {
|
|
828
828
|
bubbles: true,
|
|
829
829
|
composed: true,
|
|
830
|
-
detail: { visible: false },
|
|
830
|
+
detail: { visible: false, id: this.id },
|
|
831
831
|
}),
|
|
832
832
|
);
|
|
833
833
|
}
|
package/demo/index.min.js
CHANGED
|
@@ -572,13 +572,13 @@ class AuroToast extends i$2 {
|
|
|
572
572
|
* Emits closed toast event.
|
|
573
573
|
*
|
|
574
574
|
* @event toast-close
|
|
575
|
-
* @type {{ visible: boolean }}
|
|
575
|
+
* @type {{ visible: boolean, id: string }}
|
|
576
576
|
*/
|
|
577
577
|
this.dispatchEvent(
|
|
578
578
|
new CustomEvent("toast-close", {
|
|
579
579
|
bubbles: true,
|
|
580
580
|
composed: true,
|
|
581
|
-
detail: { visible: false },
|
|
581
|
+
detail: { visible: false, id: this.id },
|
|
582
582
|
}),
|
|
583
583
|
);
|
|
584
584
|
}
|
package/demo/readme.md
CHANGED
|
@@ -107,7 +107,6 @@ You can do this by importing only the component class and using the `register(na
|
|
|
107
107
|
|
|
108
108
|
<pre class="language-js"><code class="language-js">// Import the class only
|
|
109
109
|
import { AuroToast } from '@aurodesignsystem/auro-toast/class';
|
|
110
|
-
|
|
111
110
|
// Register with a custom name if desired
|
|
112
111
|
AuroToast.register('custom-toast');</code></pre>
|
|
113
112
|
|
|
@@ -78,7 +78,7 @@ import{css as e,LitElement as t,html as s}from"lit";import{unsafeStatic as a,lit
|
|
|
78
78
|
`}}var X='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-labelledby="error-stroke__desc" class="ico_squareLarge" role="img" style="min-width:var(--auro-size-lg, var(--ds-size-300, 1.5rem));height:var(--auro-size-lg, var(--ds-size-300, 1.5rem));fill:currentColor" viewBox="0 0 24 24" part="svg"><title/><desc id="error-stroke__desc">triangle with exclamation mark.</desc><path d="M12 15.34c-.41 0-.75-.34-.75-.75V9.33c0-.41.34-.75.75-.75s.75.34.75.75v5.26c0 .41-.34.75-.75.75m.87 1.62c0-.48-.39-.88-.88-.88s-.88.39-.88.88.39.88.88.88.88-.39.88-.88M11.98 4.5 3.5 18.97h16.99zm0-1.5c.5 0 1 .25 1.29.74l8.51 14.47c.59 1-.13 2.26-1.29 2.26H3.5c-1.16 0-1.88-1.26-1.29-2.26l8.48-14.47c.29-.49.79-.74 1.29-.74"/></svg>',j='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-labelledby="information-stroke__desc" class="ico_squareLarge" role="img" style="min-width:var(--auro-size-lg, var(--ds-size-300, 1.5rem));height:var(--auro-size-lg, var(--ds-size-300, 1.5rem));fill:currentColor" viewBox="0 0 24 24" part="svg"><title/><desc id="information-stroke__desc">Important information indicator.</desc><path d="M12 2c5.523 0 10 4.477 10 10s-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2m0 1.5a8.5 8.5 0 1 0 0 17 8.5 8.5 0 0 0 0-17m0 5.75a.75.75 0 0 1 .743.648l.007.102v6.25a.75.75 0 0 1-1.493.102l-.007-.102V10a.75.75 0 0 1 .75-.75M12 7a.75.75 0 1 1 0 1.5.75.75 0 0 1 0-1.5"/></svg>',P='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" class="ico_squareLarge" role="img" style="min-width:var(--auro-size-lg, var(--ds-size-300, 1.5rem));height:var(--auro-size-lg, var(--ds-size-300, 1.5rem));fill:currentColor" viewBox="0 0 24 24" part="svg"><title/><path d="M12 2c5.523 0 10 4.477 10 10s-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2m0 1.5a8.5 8.5 0 1 0 0 17 8.5 8.5 0 0 0 0-17m-1.524 10.416 4.971-5.423a.75.75 0 0 1 1.175.927l-.07.087-5.5 6a.75.75 0 0 1-.996.098l-.086-.075-2.5-2.5a.75.75 0 0 1 .976-1.133l.084.073zl4.971-5.423z"/></svg>',V='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-labelledby="x-lg__desc" class="ico_squareLarge" role="img" style="min-width:var(--auro-size-lg, var(--ds-size-300, 1.5rem));height:var(--auro-size-lg, var(--ds-size-300, 1.5rem));fill:currentColor" viewBox="0 0 24 24" part="svg"><title/><desc id="x-lg__desc">a large x</desc><path fill-rule="evenodd" d="M16.51 17.26q-.255 0-.45-.15l-.09-.08-3.96-3.96-3.98 3.98-.1.08a.76.76 0 0 1-.43.14.75.75 0 0 1-.6-1.2l.08-.09 3.96-3.96-3.98-3.98-.08-.1a.746.746 0 0 1 .61-1.18q.255 0 .45.15l.1.08L12 10.95l3.98-3.98.1-.08a.76.76 0 0 1 .43-.14.75.75 0 0 1 .6 1.2l-.08.1-3.96 3.96 3.98 3.98.08.1a.746.746 0 0 1-.61 1.18z" clip-rule="evenodd"/></svg>',J=e`:host([visible]){background-color:var(--ds-auro-toast-container-color);color:var(--ds-auro-toast-text-color)}:host([visible]) .typeIcon{color:var(--ds-auro-toast-icon-color)}:host([visible]) .closeButton:hover{background-color:var(--ds-auro-toast-close-button-hover-container-color)}:host([variant=error]){--ds-auro-toast-container-color: var(--ds-basic-color-status-error-subtle, #fbc6c6);--ds-auro-toast-icon-color: var(--ds-basic-color-status-error, #e31f26);--ds-auro-toast-text-color: var(--ds-basic-color-texticon-default, #2a2a2a)}:host([variant=success]){--ds-auro-toast-container-color: var(--ds-basic-color-status-success-subtle, #d6eac7);--ds-auro-toast-icon-color: var(--ds-basic-color-status-success, #447a1f);--ds-auro-toast-text-color: var(--ds-basic-color-texticon-default, #2a2a2a)}
|
|
79
79
|
`,K=e`.body-default{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-size:var(--wcss-body-default-font-size, 1rem);font-variant-ligatures:none;font-weight:var(--wcss-body-default-weight, );line-height:var(--wcss-body-default-line-height, 1.5rem)}.body-default,.body-default-emphasized{letter-spacing:var(--wcss-body-letter-spacing, 0)}.body-default-emphasized{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-size:var(--wcss-body-default-emphasized-font-size, 1rem);font-variant-ligatures:none;font-weight:var(--wcss-body-default-emphasized-weight, );line-height:var(--wcss-body-default-emphasized-line-height, 1.5rem)}.body-lg{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-size:var(--wcss-body-lg-font-size, 1.125rem);font-variant-ligatures:none;font-weight:var(--wcss-body-lg-weight, );line-height:var(--wcss-body-lg-line-height, 1.625rem)}.body-lg,.body-lg-emphasized{letter-spacing:var(--wcss-body-letter-spacing, 0)}.body-lg-emphasized{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-size:var(--wcss-body-lg-emphasized-font-size, 1.125rem);font-variant-ligatures:none;font-weight:var(--wcss-body-lg-emphasized-weight, );line-height:var(--wcss-body-lg-emphasized-line-height, 1.625rem)}.body-sm{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-size:var(--wcss-body-sm-font-size, .875rem);font-variant-ligatures:none;font-weight:var(--wcss-body-sm-weight, );line-height:var(--wcss-body-sm-line-height, 1.25rem)}.body-sm,.body-sm-emphasized{letter-spacing:var(--wcss-body-letter-spacing, 0)}.body-sm-emphasized{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-size:var(--wcss-body-sm-emphasized-font-size, .875rem);font-variant-ligatures:none;font-weight:var(--wcss-body-sm-emphasized-weight, );line-height:var(--wcss-body-sm-emphasized-line-height, 1.25rem)}.body-xs{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-size:var(--wcss-body-xs-font-size, .75rem);font-variant-ligatures:none;font-weight:var(--wcss-body-xs-weight, );line-height:var(--wcss-body-xs-line-height, 1rem)}.body-xs,.body-xs-emphasized{letter-spacing:var(--wcss-body-letter-spacing, 0)}.body-xs-emphasized{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-size:var(--wcss-body-xs-emphasized-font-size, .75rem);font-variant-ligatures:none;font-weight:var(--wcss-body-xs-emphasized-weight, );line-height:var(--wcss-body-xs-emphasized-line-height, 1rem)}.body-2xs{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-size:var(--wcss-body-2xs-font-size, .625rem);font-variant-ligatures:none;font-weight:var(--wcss-body-2xs-weight, );line-height:var(--wcss-body-2xs-line-height, .875rem)}.body-2xs,.body-2xs-emphasized{letter-spacing:var(--wcss-body-letter-spacing, 0)}.body-2xs-emphasized{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-size:var(--wcss-body-2xs-emphasized-font-size, .625rem);font-variant-ligatures:none;font-weight:var(--wcss-body-2xs-emphasized-weight, );line-height:var(--wcss-body-2xs-emphasized-line-height, .875rem)}.display-2xl{font-family:var(--wcss-display-2xl-family, "AS Circular"),var(--wcss-display-2xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-display-2xl-font-size, clamp(3.5rem, 6vw, 5.375rem));font-variant-ligatures:none;font-weight:var(--wcss-display-2xl-weight, 300);letter-spacing:var(--wcss-display-2xl-letter-spacing, 0);line-height:var(--wcss-display-2xl-line-height, 1.3)}.display-xl{font-family:var(--wcss-display-xl-family, "AS Circular"),var(--wcss-display-xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-display-xl-font-size, clamp(3rem, 5.3333333333vw, 4.5rem));font-variant-ligatures:none;font-weight:var(--wcss-display-xl-weight, 300);letter-spacing:var(--wcss-display-xl-letter-spacing, 0);line-height:var(--wcss-display-xl-line-height, 1.3)}.display-lg{font-family:var(--wcss-display-lg-family, "AS Circular"),var(--wcss-display-lg-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-display-lg-font-size, clamp(2.75rem, 4.6666666667vw, 4rem));font-variant-ligatures:none;font-weight:var(--wcss-display-lg-weight, 300);letter-spacing:var(--wcss-display-lg-letter-spacing, 0);line-height:var(--wcss-display-lg-line-height, 1.3)}.display-md{font-family:var(--wcss-display-md-family, "AS Circular"),var(--wcss-display-md-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-display-md-font-size, clamp(2.5rem, 4vw, 3.5rem));font-variant-ligatures:none;font-weight:var(--wcss-display-md-weight, 300);letter-spacing:var(--wcss-display-md-letter-spacing, 0);line-height:var(--wcss-display-md-line-height, 1.3)}.display-sm{font-family:var(--wcss-display-sm-family, "AS Circular"),var(--wcss-display-sm-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-display-sm-font-size, clamp(2rem, 3.6666666667vw, 3rem));font-variant-ligatures:none;font-weight:var(--wcss-display-sm-weight, 300);letter-spacing:var(--wcss-display-sm-letter-spacing, 0);line-height:var(--wcss-display-sm-line-height, 1.3)}.display-xs{font-family:var(--wcss-display-xs-family, "AS Circular"),var(--wcss-display-xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-display-xs-font-size, clamp(1.75rem, 3vw, 2.375rem));font-variant-ligatures:none;font-weight:var(--wcss-display-xs-weight, 300);letter-spacing:var(--wcss-display-xs-letter-spacing, 0);line-height:var(--wcss-display-xs-line-height, 1.3)}.heading-xl{font-family:var(--wcss-heading-xl-family, "AS Circular"),var(--wcss-heading-xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-heading-xl-font-size, clamp(2rem, 3vw, 2.5rem));font-variant-ligatures:none;font-weight:var(--wcss-heading-xl-weight, 300);letter-spacing:var(--wcss-heading-xl-letter-spacing, 0);line-height:var(--wcss-heading-xl-line-height, 1.3)}.heading-lg{font-family:var(--wcss-heading-lg-family, "AS Circular"),var(--wcss-heading-lg-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-heading-lg-font-size, clamp(1.75rem, 2.6666666667vw, 2.25rem));font-variant-ligatures:none;font-weight:var(--wcss-heading-lg-weight, 300);letter-spacing:var(--wcss-heading-lg-letter-spacing, 0);line-height:var(--wcss-heading-lg-line-height, 1.3)}.heading-md{font-family:var(--wcss-heading-md-family, "AS Circular"),var(--wcss-heading-md-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-heading-md-font-size, clamp(1.625rem, 2.3333333333vw, 1.75rem));font-variant-ligatures:none;font-weight:var(--wcss-heading-md-weight, 300);letter-spacing:var(--wcss-heading-md-letter-spacing, 0);line-height:var(--wcss-heading-md-line-height, 1.3)}.heading-sm{font-family:var(--wcss-heading-sm-family, "AS Circular"),var(--wcss-heading-sm-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-heading-sm-font-size, clamp(1.375rem, 2vw, 1.5rem));font-variant-ligatures:none;font-weight:var(--wcss-heading-sm-weight, 300);letter-spacing:var(--wcss-heading-sm-letter-spacing, 0);line-height:var(--wcss-heading-sm-line-height, 1.3)}.heading-xs{font-family:var(--wcss-heading-xs-family, "AS Circular"),var(--wcss-heading-xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-heading-xs-font-size, clamp(1.25rem, 1.6666666667vw, 1.25rem));font-variant-ligatures:none;font-weight:var(--wcss-heading-xs-weight, 300);letter-spacing:var(--wcss-heading-xs-letter-spacing, 0);line-height:var(--wcss-heading-xs-line-height, 1.3)}.heading-2xs{font-family:var(--wcss-heading-2xs-family, "AS Circular"),var(--wcss-heading-2xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-heading-2xs-font-size, clamp(1.125rem, 1.5vw, 1.125rem));font-variant-ligatures:none;font-weight:var(--wcss-heading-2xs-weight, 300);letter-spacing:var(--wcss-heading-2xs-letter-spacing, 0);line-height:var(--wcss-heading-2xs-line-height, 1.3)}.accent-2xl{font-family:var(--wcss-accent-2xl-family, "Good OT"),var(--wcss-accent-2xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-accent-2xl-font-size, clamp(2rem, 3.1666666667vw, 2.375rem));font-variant-ligatures:none;font-weight:var(--wcss-accent-2xl-weight, 450);letter-spacing:var(--wcss-accent-2xl-letter-spacing, .05em);line-height:var(--wcss-accent-2xl-line-height, 1)}.accent-2xl,.accent-xl{text-transform:uppercase}.accent-xl{font-family:var(--wcss-accent-xl-family, "Good OT"),var(--wcss-accent-xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-accent-xl-font-size, clamp(1.625rem, 2.3333333333vw, 2rem));font-variant-ligatures:none;font-weight:var(--wcss-accent-xl-weight, 450);letter-spacing:var(--wcss-accent-xl-letter-spacing, .05em);line-height:var(--wcss-accent-xl-line-height, 1.3)}.accent-lg{font-family:var(--wcss-accent-lg-family, "Good OT"),var(--wcss-accent-lg-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-accent-lg-font-size, clamp(1.5rem, 2.1666666667vw, 1.75rem));font-variant-ligatures:none;font-weight:var(--wcss-accent-lg-weight, 450);letter-spacing:var(--wcss-accent-lg-letter-spacing, .05em);line-height:var(--wcss-accent-lg-line-height, 1.3)}.accent-lg,.accent-md{text-transform:uppercase}.accent-md{font-family:var(--wcss-accent-md-family, "Good OT"),var(--wcss-accent-md-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-accent-md-font-size, clamp(1.375rem, 1.8333333333vw, 1.5rem));font-variant-ligatures:none;font-weight:var(--wcss-accent-md-weight, 500);letter-spacing:var(--wcss-accent-md-letter-spacing, .05em);line-height:var(--wcss-accent-md-line-height, 1.3)}.accent-sm{font-family:var(--wcss-accent-sm-family, "Good OT"),var(--wcss-accent-sm-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-accent-sm-font-size, clamp(1.125rem, 1.5vw, 1.25rem));font-variant-ligatures:none;font-weight:var(--wcss-accent-sm-weight, 500);letter-spacing:var(--wcss-accent-sm-letter-spacing, .05em);line-height:var(--wcss-accent-sm-line-height, 1.3)}.accent-sm,.accent-xs{text-transform:uppercase}.accent-xs{font-family:var(--wcss-accent-xs-family, "Good OT"),var(--wcss-accent-xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-accent-xs-font-size, clamp(1rem, 1.3333333333vw, 1rem));font-variant-ligatures:none;font-weight:var(--wcss-accent-xs-weight, 500);letter-spacing:var(--wcss-accent-xs-letter-spacing, .1em);line-height:var(--wcss-accent-xs-line-height, 1.3)}.accent-2xs{font-family:var(--wcss-accent-2xs-family, "Good OT"),var(--wcss-accent-2xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-accent-2xs-font-size, clamp(.875rem, 1.1666666667vw, .875rem));font-variant-ligatures:none;font-weight:var(--wcss-accent-2xs-weight, 450);letter-spacing:var(--wcss-accent-2xs-letter-spacing, .1em);line-height:var(--wcss-accent-2xs-line-height, 1.3);text-transform:uppercase}:host{display:inherit}:host([visible]){display:inline-block;min-width:100%;border-radius:var(--ds-size-100, .5rem);box-shadow:var(--ds-elevation-200, 0px 0px 10px rgba(0, 0, 0, .15));pointer-events:auto}@media (width >= 576px){:host([visible]){min-width:200px;max-width:500px}}:host([visible]) .toastContainer{display:flex;flex-direction:row;align-items:flex-start;padding:var(--ds-size-200, 1rem) var(--ds-size-150, .75rem);gap:var(--ds-size-200, 1rem)}:host([visible]) .hidden{opacity:0;transition:visibility 0s .3s,opacity .3s ease-out;visibility:hidden}:host([visible]) [auro-icon]{--ds-auro-icon-size: var(--ds-size-300, 1.5rem)}:host([visible]) .message{flex:1}:host([visible]) .closeButton{border-radius:50%}
|
|
80
80
|
`,Q=e`:host{--ds-auro-toast-close-button-hover-container-color: var(--ds-advanced-color-button-tertiary-background-hover, rgba(0, 0, 0, .1));--ds-auro-toast-container-color: var(--ds-advanced-color-shared-background-strong, #676767);--ds-auro-toast-icon-color: var(--ds-basic-color-texticon-inverse, #ffffff);--ds-auro-toast-text-color: var(--ds-basic-color-texticon-inverse, #ffffff)}
|
|
81
|
-
`;class Y extends t{constructor(){super(),this._initializeDefaults()}_initializeDefaults(){this.closeDom=(new DOMParser).parseFromString(V,"text/html"),this.closeSvg=this.closeDom.body.firstChild,this.closeSvg.setAttribute("slot","svg"),this.successDom=(new DOMParser).parseFromString(P,"text/html"),this.successSvg=this.successDom.body.firstChild,this.successSvg.setAttribute("slot","svg"),this.errorDom=(new DOMParser).parseFromString(X,"text/html"),this.errorSvg=this.errorDom.body.firstChild,this.errorSvg.setAttribute("slot","svg"),this.infoDom=(new DOMParser).parseFromString(j,"text/html"),this.infoSvg=this.infoDom.body.firstChild,this.infoSvg.setAttribute("slot","svg");const e=new l;this.buttonTag=e.generateTag("auro-button","12.3.2",U),this.iconTag=e.generateTag("auro-icon","9.2.0",G),this.runtimeUtils=new c,this.fadeOutTimer=void 0,this.closeTimer=void 0,this._isStandalone=!1}static get properties(){return{...t.properties,disableAutoHide:{type:Boolean,reflect:!0,attribute:"disableautohide"},noIcon:{type:Boolean,reflect:!0,attribute:"noicon"},timeTilHide:{type:Number,reflect:!0,attribute:"timetilhide"},trigger:{type:String,reflect:!0},triggerElement:{type:Object,attribute:!1},variant:{type:String,reflect:!0},visible:{type:Boolean,reflect:!0}}}static get styles(){return[K,J,Q]}static register(e="auro-toast"){c.prototype.registerComponent(e,Y)}firstUpdated(){this.runtimeUtils.handleComponentTagRename(this,"auro-toast")}disconnectedCallback(){super.disconnectedCallback(),clearTimeout(this.fadeOutTimer),clearTimeout(this.closeTimer)}_returnFocus(){const e=(this.trigger?document.getElementById(this.trigger):null)??this.triggerElement;e&&e.focus()}clickToClose(){this._returnFocus(),clearTimeout(this.fadeOutTimer),clearTimeout(this.closeTimer),this.closeToast()}fadeOutToast(){if(!this.disableAutoHide&&this.visible){const e=this.shadowRoot.querySelector(".toastContainer");e&&e.classList.add("hidden"),clearTimeout(this.closeTimer),this.closeTimer=setTimeout(()=>{this.closeToast()},300)}}closeToast(){this.visible&&(clearTimeout(this.fadeOutTimer),clearTimeout(this.closeTimer),this.visible=!1,this.dispatchEvent(new CustomEvent("onToastClose",{bubbles:!0,composed:!0,detail:this})),this.dispatchEvent(new CustomEvent("toast-close",{bubbles:!0,composed:!0,detail:{visible:!1}})))}setOnClick(){window.innerWidth<767&&(this.onclick=e=>{const t=this.shadowRoot?.querySelector('[part="close-button"]');t&&e.composedPath().includes(t)||this.fadeOutToast()})}getVariantIcon(){const e={success:this.successSvg,error:this.errorSvg,default:this.infoSvg};return e[this.variant]||e.default}connectedCallback(){super.connectedCallback(),this.setOnClick(),this._scheduleAutoHide();const e=new CustomEvent("toast-request-announce",{bubbles:!0,cancelable:!0,composed:!0}),t=this.dispatchEvent(e);this._isStandalone=t&&!this._hasAncestorLiveRegion(),this._syncStandaloneRole()}_syncStandaloneRole(){this._isStandalone?this.setAttribute("role","error"===this.variant?"alert":"status"):this.removeAttribute("role")}_hasAncestorLiveRegion(){let e=this.parentElement;for(;e;){if(["polite","assertive"].includes(e.getAttribute?.("aria-live"))||["alert","status","log"].includes(e.getAttribute?.("role")))return!0;e=e.parentElement??e.getRootNode()?.host??null}return!1}updated(e){e.has("visible")&&this.handleSlotContent(),e.has("variant")&&(clearTimeout(this.fadeOutTimer),clearTimeout(this.closeTimer),this.shadowRoot?.querySelector(".toastContainer")?.classList.remove("hidden"),this._syncStandaloneRole()),this._scheduleAutoHide()}_scheduleAutoHide(){this.visible&&!this.disableAutoHide&&"error"!==this.variant&&(clearTimeout(this.fadeOutTimer),this.fadeOutTimer=setTimeout(()=>{this.fadeOutToast()},this.timeTilHide||5e3))}handleSlotContent(){try{const e=this.querySelector('[slot="customSvg"]');if(e){const t=e.cloneNode(!0),s=this.shadowRoot.querySelector(".typeIcon");s&&(t.setAttribute("slot","svg"),s.appendChild(t))}}catch(e){console.error("handleSlotContent",e)}}render(){return r`
|
|
81
|
+
`;class Y extends t{constructor(){super(),this._initializeDefaults()}_initializeDefaults(){this.closeDom=(new DOMParser).parseFromString(V,"text/html"),this.closeSvg=this.closeDom.body.firstChild,this.closeSvg.setAttribute("slot","svg"),this.successDom=(new DOMParser).parseFromString(P,"text/html"),this.successSvg=this.successDom.body.firstChild,this.successSvg.setAttribute("slot","svg"),this.errorDom=(new DOMParser).parseFromString(X,"text/html"),this.errorSvg=this.errorDom.body.firstChild,this.errorSvg.setAttribute("slot","svg"),this.infoDom=(new DOMParser).parseFromString(j,"text/html"),this.infoSvg=this.infoDom.body.firstChild,this.infoSvg.setAttribute("slot","svg");const e=new l;this.buttonTag=e.generateTag("auro-button","12.3.2",U),this.iconTag=e.generateTag("auro-icon","9.2.0",G),this.runtimeUtils=new c,this.fadeOutTimer=void 0,this.closeTimer=void 0,this._isStandalone=!1}static get properties(){return{...t.properties,disableAutoHide:{type:Boolean,reflect:!0,attribute:"disableautohide"},noIcon:{type:Boolean,reflect:!0,attribute:"noicon"},timeTilHide:{type:Number,reflect:!0,attribute:"timetilhide"},trigger:{type:String,reflect:!0},triggerElement:{type:Object,attribute:!1},variant:{type:String,reflect:!0},visible:{type:Boolean,reflect:!0}}}static get styles(){return[K,J,Q]}static register(e="auro-toast"){c.prototype.registerComponent(e,Y)}firstUpdated(){this.runtimeUtils.handleComponentTagRename(this,"auro-toast")}disconnectedCallback(){super.disconnectedCallback(),clearTimeout(this.fadeOutTimer),clearTimeout(this.closeTimer)}_returnFocus(){const e=(this.trigger?document.getElementById(this.trigger):null)??this.triggerElement;e&&e.focus()}clickToClose(){this._returnFocus(),clearTimeout(this.fadeOutTimer),clearTimeout(this.closeTimer),this.closeToast()}fadeOutToast(){if(!this.disableAutoHide&&this.visible){const e=this.shadowRoot.querySelector(".toastContainer");e&&e.classList.add("hidden"),clearTimeout(this.closeTimer),this.closeTimer=setTimeout(()=>{this.closeToast()},300)}}closeToast(){this.visible&&(clearTimeout(this.fadeOutTimer),clearTimeout(this.closeTimer),this.visible=!1,this.dispatchEvent(new CustomEvent("onToastClose",{bubbles:!0,composed:!0,detail:this})),this.dispatchEvent(new CustomEvent("toast-close",{bubbles:!0,composed:!0,detail:{visible:!1,id:this.id}})))}setOnClick(){window.innerWidth<767&&(this.onclick=e=>{const t=this.shadowRoot?.querySelector('[part="close-button"]');t&&e.composedPath().includes(t)||this.fadeOutToast()})}getVariantIcon(){const e={success:this.successSvg,error:this.errorSvg,default:this.infoSvg};return e[this.variant]||e.default}connectedCallback(){super.connectedCallback(),this.setOnClick(),this._scheduleAutoHide();const e=new CustomEvent("toast-request-announce",{bubbles:!0,cancelable:!0,composed:!0}),t=this.dispatchEvent(e);this._isStandalone=t&&!this._hasAncestorLiveRegion(),this._syncStandaloneRole()}_syncStandaloneRole(){this._isStandalone?this.setAttribute("role","error"===this.variant?"alert":"status"):this.removeAttribute("role")}_hasAncestorLiveRegion(){let e=this.parentElement;for(;e;){if(["polite","assertive"].includes(e.getAttribute?.("aria-live"))||["alert","status","log"].includes(e.getAttribute?.("role")))return!0;e=e.parentElement??e.getRootNode()?.host??null}return!1}updated(e){e.has("visible")&&this.handleSlotContent(),e.has("variant")&&(clearTimeout(this.fadeOutTimer),clearTimeout(this.closeTimer),this.shadowRoot?.querySelector(".toastContainer")?.classList.remove("hidden"),this._syncStandaloneRole()),this._scheduleAutoHide()}_scheduleAutoHide(){this.visible&&!this.disableAutoHide&&"error"!==this.variant&&(clearTimeout(this.fadeOutTimer),this.fadeOutTimer=setTimeout(()=>{this.fadeOutToast()},this.timeTilHide||5e3))}handleSlotContent(){try{const e=this.querySelector('[slot="customSvg"]');if(e){const t=e.cloneNode(!0),s=this.shadowRoot.querySelector(".typeIcon");s&&(t.setAttribute("slot","svg"),s.appendChild(t))}}catch(e){console.error("handleSlotContent",e)}}render(){return r`
|
|
82
82
|
${this.visible?r`
|
|
83
83
|
<div class="toastContainer">
|
|
84
84
|
${this.noIcon?void 0:r`
|
package/dist/index.d.ts
CHANGED
|
@@ -108,7 +108,7 @@ Use the trigger attribute instead if you prefer a declarative approach. */
|
|
|
108
108
|
"triggerElement"?: AuroToast['triggerElement'];
|
|
109
109
|
|
|
110
110
|
/** Notifies that the toast has been closed */
|
|
111
|
-
"ontoast-close"?: (e: CustomEvent<{ visible: boolean }>) => void;
|
|
111
|
+
"ontoast-close"?: (e: CustomEvent<{ visible: boolean, id: string }>) => void;
|
|
112
112
|
/** @deprecated Use `toast-close` event instead. - **Deprecated**, use `toast-close` event instead. */
|
|
113
113
|
"ononToastClose"?: (e: CustomEvent<Object>) => void;
|
|
114
114
|
}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{A as AuroToast,a as AuroToaster}from"./auro-toaster-
|
|
1
|
+
export{A as AuroToast,a as AuroToaster}from"./auro-toaster-Cl6LVy6n.js";import"lit";import"lit/static-html.js";import"lit/directives/class-map.js";import"lit/directives/if-defined.js";
|
package/dist/registered.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as i,a as t}from"./auro-toaster-
|
|
1
|
+
import{A as i,a as t}from"./auro-toaster-Cl6LVy6n.js";import"lit";import"lit/static-html.js";import"lit/directives/class-map.js";import"lit/directives/if-defined.js";i.register(),t.register();
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"================================================================================"
|
|
8
8
|
],
|
|
9
9
|
"name": "@aurodesignsystem-dev/auro-toast",
|
|
10
|
-
"version": "0.0.0-pr156.
|
|
10
|
+
"version": "0.0.0-pr156.2",
|
|
11
11
|
"description": "auro-toast HTML custom element",
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
@@ -84,13 +84,11 @@
|
|
|
84
84
|
"files": [
|
|
85
85
|
"dist/**/*",
|
|
86
86
|
"demo/**/*",
|
|
87
|
-
"src/**/*",
|
|
88
87
|
"custom-elements.json",
|
|
89
88
|
"CHANGELOG.md",
|
|
90
89
|
"README.md",
|
|
91
90
|
"LICENSE",
|
|
92
91
|
"NOTICE"
|
|
93
92
|
],
|
|
94
|
-
"custom-elements": "custom-elements.json",
|
|
95
93
|
"customElements": "custom-elements.json"
|
|
96
94
|
}
|
package/src/auro-toast.js
DELETED
|
@@ -1,538 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2023 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
2
|
-
// See LICENSE in the project root for license information.
|
|
3
|
-
|
|
4
|
-
// ---------------------------------------------------------------------
|
|
5
|
-
|
|
6
|
-
/* eslint-disable lit/binding-positions, lit/no-invalid-html, max-lines */
|
|
7
|
-
import { LitElement } from "lit";
|
|
8
|
-
import { html } from "lit/static-html.js";
|
|
9
|
-
|
|
10
|
-
import { AuroDependencyVersioning } from "@aurodesignsystem/auro-library/scripts/runtime/dependencyTagVersioning.mjs";
|
|
11
|
-
import AuroLibraryRuntimeUtils from "@aurodesignsystem/auro-library/scripts/utils/runtimeUtils.mjs";
|
|
12
|
-
import { AuroButton } from "@aurodesignsystem/auro-button/class";
|
|
13
|
-
import { AuroIcon } from "@aurodesignsystem/auro-icon/class";
|
|
14
|
-
|
|
15
|
-
// Icons
|
|
16
|
-
import errorIcon from "@alaskaairux/icons/dist/icons/alert/error-stroke.mjs";
|
|
17
|
-
import infoIcon from "@alaskaairux/icons/dist/icons/alert/information-stroke.mjs";
|
|
18
|
-
import successIcon from "@alaskaairux/icons/dist/icons/interface/check-stroke.mjs";
|
|
19
|
-
import closeIcon from "@alaskaairux/icons/dist/icons/interface/x-lg.mjs";
|
|
20
|
-
|
|
21
|
-
import buttonVersion from "./buttonVersion.js";
|
|
22
|
-
import iconVersion from "./iconVersion.js";
|
|
23
|
-
|
|
24
|
-
import colorCss from "./styles/color.scss";
|
|
25
|
-
import styleCss from "./styles/style.scss";
|
|
26
|
-
import tokensCss from "./styles/tokens.scss";
|
|
27
|
-
|
|
28
|
-
const DEFAULT_TIME_TIL_FADE_OUT = 5000;
|
|
29
|
-
const FADE_OUT_DURATION = 300;
|
|
30
|
-
|
|
31
|
-
// See https://git.io/JJ6SJ for "How to document your components using JSDoc"
|
|
32
|
-
/**
|
|
33
|
-
* The `auro-toast` element provides users a way to display short, temporary messages.
|
|
34
|
-
* @customElement auro-toast
|
|
35
|
-
*
|
|
36
|
-
* @csspart type-icon - Apply css to the toast type icon
|
|
37
|
-
* @csspart close-button - Apply css to the toast close button
|
|
38
|
-
* @fires onToastClose - **Deprecated**, use `toast-close` event instead.
|
|
39
|
-
* @event toast-close - Notifies that the toast has been closed
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
|
-
// build the component class
|
|
43
|
-
export class AuroToast extends LitElement {
|
|
44
|
-
constructor() {
|
|
45
|
-
super();
|
|
46
|
-
|
|
47
|
-
this._initializeDefaults();
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
_initializeDefaults() {
|
|
51
|
-
/**
|
|
52
|
-
* @private
|
|
53
|
-
*/
|
|
54
|
-
this.closeDom = new DOMParser().parseFromString(closeIcon.svg, "text/html");
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* @private
|
|
58
|
-
*/
|
|
59
|
-
this.closeSvg = this.closeDom.body.firstChild;
|
|
60
|
-
this.closeSvg.setAttribute("slot", "svg");
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* @private
|
|
64
|
-
*/
|
|
65
|
-
this.successDom = new DOMParser().parseFromString(
|
|
66
|
-
successIcon.svg,
|
|
67
|
-
"text/html",
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* @private
|
|
72
|
-
*/
|
|
73
|
-
this.successSvg = this.successDom.body.firstChild;
|
|
74
|
-
|
|
75
|
-
this.successSvg.setAttribute("slot", "svg");
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* @private
|
|
79
|
-
*/
|
|
80
|
-
this.errorDom = new DOMParser().parseFromString(errorIcon.svg, "text/html");
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* @private
|
|
84
|
-
*/
|
|
85
|
-
this.errorSvg = this.errorDom.body.firstChild;
|
|
86
|
-
this.errorSvg.setAttribute("slot", "svg");
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* @private
|
|
90
|
-
*/
|
|
91
|
-
this.infoDom = new DOMParser().parseFromString(infoIcon.svg, "text/html");
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* @private
|
|
95
|
-
*/
|
|
96
|
-
this.infoSvg = this.infoDom.body.firstChild;
|
|
97
|
-
this.infoSvg.setAttribute("slot", "svg");
|
|
98
|
-
|
|
99
|
-
const versioning = new AuroDependencyVersioning();
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* @private
|
|
103
|
-
*/
|
|
104
|
-
this.buttonTag = versioning.generateTag(
|
|
105
|
-
"auro-button",
|
|
106
|
-
buttonVersion,
|
|
107
|
-
AuroButton,
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* @private
|
|
112
|
-
*/
|
|
113
|
-
this.iconTag = versioning.generateTag("auro-icon", iconVersion, AuroIcon);
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* @private
|
|
117
|
-
*/
|
|
118
|
-
this.runtimeUtils = new AuroLibraryRuntimeUtils();
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* @private
|
|
122
|
-
*/
|
|
123
|
-
this.fadeOutTimer = undefined;
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* @private
|
|
127
|
-
*/
|
|
128
|
-
this.closeTimer = undefined;
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* True when the toast is not inside an auro-toaster and must manage its
|
|
132
|
-
* own live region announcement. Set once in connectedCallback.
|
|
133
|
-
* Default -- assumes toast is inside toaster.
|
|
134
|
-
* @private
|
|
135
|
-
*/
|
|
136
|
-
this._isStandalone = false;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// This function is to define props used within the scope of this component
|
|
140
|
-
// Be sure to review https://lit.dev/docs/components/properties/
|
|
141
|
-
// to understand how to use reflected attributes with your property settings.
|
|
142
|
-
static get properties() {
|
|
143
|
-
return {
|
|
144
|
-
...LitElement.properties,
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Prevents the toast from auto-hiding on the default time.
|
|
148
|
-
*/
|
|
149
|
-
disableAutoHide: {
|
|
150
|
-
type: Boolean,
|
|
151
|
-
reflect: true,
|
|
152
|
-
attribute: "disableautohide",
|
|
153
|
-
},
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Removes icon from the toast UI.
|
|
157
|
-
*/
|
|
158
|
-
noIcon: {
|
|
159
|
-
type: Boolean,
|
|
160
|
-
reflect: true,
|
|
161
|
-
attribute: "noicon",
|
|
162
|
-
},
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Sets the time in milliseconds until the toast hides.
|
|
166
|
-
*/
|
|
167
|
-
timeTilHide: {
|
|
168
|
-
type: Number,
|
|
169
|
-
reflect: true,
|
|
170
|
-
attribute: "timetilhide",
|
|
171
|
-
},
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* The id of the element that triggered the toast.
|
|
175
|
-
* When the toast is manually closed, focus will return to this element.
|
|
176
|
-
* Takes precedence over the triggerElement property if both are set.
|
|
177
|
-
*/
|
|
178
|
-
trigger: {
|
|
179
|
-
type: String,
|
|
180
|
-
reflect: true,
|
|
181
|
-
},
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* A direct reference to the element that triggered the toast.
|
|
185
|
-
* When the toast is manually closed, focus will return to this element.
|
|
186
|
-
* Use the trigger attribute instead if you prefer a declarative approach.
|
|
187
|
-
* @type {HTMLElement}
|
|
188
|
-
*/
|
|
189
|
-
triggerElement: {
|
|
190
|
-
type: Object,
|
|
191
|
-
attribute: false,
|
|
192
|
-
},
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Component will render visually based on which variant value is set.
|
|
196
|
-
* @type {'error' | 'success' | 'custom'}
|
|
197
|
-
*/
|
|
198
|
-
variant: {
|
|
199
|
-
type: String,
|
|
200
|
-
reflect: true,
|
|
201
|
-
},
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Sets state of toast to visible
|
|
205
|
-
*/
|
|
206
|
-
visible: {
|
|
207
|
-
type: Boolean,
|
|
208
|
-
reflect: true,
|
|
209
|
-
}
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
static get styles() {
|
|
214
|
-
return [styleCss, colorCss, tokensCss];
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* This will register this element with the browser.
|
|
219
|
-
* @param {string} [name="auro-toast"] - The name of the element that you want to register.
|
|
220
|
-
*
|
|
221
|
-
* @example
|
|
222
|
-
* AuroToast.register("custom-toast") // this will register this element to <custom-toast/>
|
|
223
|
-
*
|
|
224
|
-
*/
|
|
225
|
-
static register(name = "auro-toast") {
|
|
226
|
-
AuroLibraryRuntimeUtils.prototype.registerComponent(name, AuroToast);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
firstUpdated() {
|
|
230
|
-
// Add the tag name as an attribute if it is different than the component name
|
|
231
|
-
this.runtimeUtils.handleComponentTagRename(this, "auro-toast");
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
disconnectedCallback() {
|
|
235
|
-
super.disconnectedCallback();
|
|
236
|
-
clearTimeout(this.fadeOutTimer);
|
|
237
|
-
clearTimeout(this.closeTimer);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* Returns focus to the trigger element when the toast is manually closed.
|
|
242
|
-
* Not called on auto-dismiss — moving focus during auto-dismiss would
|
|
243
|
-
* interrupt the AT user's current position in the page.
|
|
244
|
-
* @private
|
|
245
|
-
* @returns {void}
|
|
246
|
-
*/
|
|
247
|
-
_returnFocus() {
|
|
248
|
-
const target = (this.trigger ? document.getElementById(this.trigger) : null) ??
|
|
249
|
-
this.triggerElement;
|
|
250
|
-
|
|
251
|
-
if (target) {
|
|
252
|
-
target.focus();
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
/**
|
|
257
|
-
* @private
|
|
258
|
-
* @returns {void}
|
|
259
|
-
*/
|
|
260
|
-
clickToClose() {
|
|
261
|
-
this._returnFocus();
|
|
262
|
-
clearTimeout(this.fadeOutTimer);
|
|
263
|
-
clearTimeout(this.closeTimer);
|
|
264
|
-
this.closeToast();
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
/**
|
|
268
|
-
* @private
|
|
269
|
-
* @returns {void}
|
|
270
|
-
*/
|
|
271
|
-
fadeOutToast() {
|
|
272
|
-
if (!this.disableAutoHide && this.visible) {
|
|
273
|
-
const toastContainer = this.shadowRoot.querySelector(".toastContainer");
|
|
274
|
-
if (toastContainer) {
|
|
275
|
-
toastContainer.classList.add("hidden");
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
clearTimeout(this.closeTimer);
|
|
279
|
-
this.closeTimer = setTimeout(() => {
|
|
280
|
-
this.closeToast();
|
|
281
|
-
}, FADE_OUT_DURATION);
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* @private
|
|
287
|
-
* @returns {void}
|
|
288
|
-
*/
|
|
289
|
-
closeToast() {
|
|
290
|
-
// Guards against re-entry -- e.g. a close-button click on mobile widths
|
|
291
|
-
// both closes the toast directly and bubbles to the host's own onclick
|
|
292
|
-
// handler (see setOnClick()), which would otherwise schedule a second,
|
|
293
|
-
// untracked close via fadeOutToast().
|
|
294
|
-
if (!this.visible) {
|
|
295
|
-
return;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
clearTimeout(this.fadeOutTimer);
|
|
299
|
-
clearTimeout(this.closeTimer);
|
|
300
|
-
this.visible = false;
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
* Emits closed toast event.
|
|
304
|
-
*
|
|
305
|
-
* @deprecated Use `toast-close` event instead.
|
|
306
|
-
* @event onToastClose
|
|
307
|
-
* @type {Object}
|
|
308
|
-
*/
|
|
309
|
-
this.dispatchEvent(
|
|
310
|
-
new CustomEvent("onToastClose", {
|
|
311
|
-
bubbles: true,
|
|
312
|
-
composed: true,
|
|
313
|
-
detail: this, // unchanged for backwards compatibility; use `toast-close` for the new `{ visible }` shape
|
|
314
|
-
}),
|
|
315
|
-
);
|
|
316
|
-
|
|
317
|
-
/**
|
|
318
|
-
* Emits closed toast event.
|
|
319
|
-
*
|
|
320
|
-
* @event toast-close
|
|
321
|
-
* @type {{ visible: boolean }}
|
|
322
|
-
*/
|
|
323
|
-
this.dispatchEvent(
|
|
324
|
-
new CustomEvent("toast-close", {
|
|
325
|
-
bubbles: true,
|
|
326
|
-
composed: true,
|
|
327
|
-
detail: { visible: false },
|
|
328
|
-
}),
|
|
329
|
-
);
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
/**
|
|
333
|
-
* For mobile, set the onclick function so the toast can be dismissed if it is tapped on anywhere inside the toast.
|
|
334
|
-
* Ignores clicks on the close button -- clickToClose() already handles those, and re-running
|
|
335
|
-
* fadeOutToast() for the same click is what caused a double close (see AB#1643472).
|
|
336
|
-
* @private
|
|
337
|
-
* @returns {void}
|
|
338
|
-
*/
|
|
339
|
-
setOnClick() {
|
|
340
|
-
const mobileBreakPoint = 767;
|
|
341
|
-
if (window.innerWidth < mobileBreakPoint) {
|
|
342
|
-
this.onclick = (event) => {
|
|
343
|
-
const closeButton = this.shadowRoot?.querySelector('[part="close-button"]');
|
|
344
|
-
if (closeButton && event.composedPath().includes(closeButton)) {
|
|
345
|
-
return;
|
|
346
|
-
}
|
|
347
|
-
this.fadeOutToast();
|
|
348
|
-
};
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
/**
|
|
353
|
-
* Determines which type icon to render based on the variant prop.
|
|
354
|
-
* @private
|
|
355
|
-
* @returns {HTMLElement} - The icon element to render.
|
|
356
|
-
*/
|
|
357
|
-
getVariantIcon() {
|
|
358
|
-
const VARIANT_ICONS = {
|
|
359
|
-
success: this.successSvg,
|
|
360
|
-
error: this.errorSvg,
|
|
361
|
-
default: this.infoSvg,
|
|
362
|
-
};
|
|
363
|
-
|
|
364
|
-
return VARIANT_ICONS[this.variant] || VARIANT_ICONS.default;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
connectedCallback() {
|
|
368
|
-
super.connectedCallback();
|
|
369
|
-
this.setOnClick();
|
|
370
|
-
|
|
371
|
-
// Re-arm auto-hide on reconnect (e.g. re-parenting the node elsewhere in
|
|
372
|
-
// the DOM) -- updated() does not re-run just because connectedCallback()
|
|
373
|
-
// fired again, since no reactive property changed as a result.
|
|
374
|
-
this._scheduleAutoHide();
|
|
375
|
-
|
|
376
|
-
// Dispatch a cancelable event so auro-toaster can signal it will handle
|
|
377
|
-
// announcements. If nothing cancels the event the toast is standalone and
|
|
378
|
-
// must register its own live region on the host element — before
|
|
379
|
-
// any visibility change — so the AT has already observed it as a live
|
|
380
|
-
// region by the time content is rendered into the shadow DOM.
|
|
381
|
-
const event = new CustomEvent('toast-request-announce', {
|
|
382
|
-
bubbles: true,
|
|
383
|
-
cancelable: true,
|
|
384
|
-
composed: true,
|
|
385
|
-
});
|
|
386
|
-
|
|
387
|
-
// NOTE — reverse logic:
|
|
388
|
-
// dispatchEvent() returns TRUE when nobody called preventDefault(), which
|
|
389
|
-
// means no auro-toaster was listening — the toast is standalone and must
|
|
390
|
-
// own its live region. It returns FALSE when a toaster cancelled the event,
|
|
391
|
-
// signalling that the toaster's aria-live region will handle announcements.
|
|
392
|
-
const eventNotPrevented = this.dispatchEvent(event);
|
|
393
|
-
|
|
394
|
-
// Secondary check: even if no toaster answered the event, the toast may
|
|
395
|
-
// be inside another element that already owns a live region (e.g. a plain
|
|
396
|
-
// div[aria-live="polite"]). Setting a role on the host in that case would
|
|
397
|
-
// create a nested live region. aria-live="off" is intentionally excluded
|
|
398
|
-
// — it disables live region behavior and is not an active announcer.
|
|
399
|
-
this._isStandalone = eventNotPrevented && !this._hasAncestorLiveRegion();
|
|
400
|
-
|
|
401
|
-
this._syncStandaloneRole();
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
/**
|
|
405
|
-
* Sets or removes the live-region role on the host depending on whether
|
|
406
|
-
* the toast is standalone. Extracted so connectedCallback and updated()
|
|
407
|
-
* stay in sync without duplicating the logic.
|
|
408
|
-
* @private
|
|
409
|
-
* @returns {void}
|
|
410
|
-
*/
|
|
411
|
-
_syncStandaloneRole() {
|
|
412
|
-
if (this._isStandalone) {
|
|
413
|
-
this.setAttribute('role', this.variant === 'error' ? 'alert' : 'status');
|
|
414
|
-
} else {
|
|
415
|
-
this.removeAttribute('role');
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
/**
|
|
420
|
-
* Walks the DOM ancestors (crossing shadow boundaries) looking for any
|
|
421
|
-
* active live region — either an aria-live="polite/assertive" attribute or
|
|
422
|
-
* an implicit live region role (alert, status, log).
|
|
423
|
-
* aria-live="off" is not considered active and is intentionally ignored.
|
|
424
|
-
* @private
|
|
425
|
-
* @returns {boolean}
|
|
426
|
-
*/
|
|
427
|
-
_hasAncestorLiveRegion() {
|
|
428
|
-
let node = this.parentElement;
|
|
429
|
-
while (node) {
|
|
430
|
-
if (
|
|
431
|
-
['polite', 'assertive'].includes(node.getAttribute?.('aria-live')) ||
|
|
432
|
-
['alert', 'status', 'log'].includes(node.getAttribute?.('role'))
|
|
433
|
-
) {
|
|
434
|
-
return true;
|
|
435
|
-
}
|
|
436
|
-
// Traverse up, crossing shadow DOM boundaries if needed
|
|
437
|
-
node = node.parentElement ?? node.getRootNode()?.host ?? null;
|
|
438
|
-
}
|
|
439
|
-
return false;
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
updated(changedProperties) {
|
|
443
|
-
if (changedProperties.has("visible")) {
|
|
444
|
-
this.handleSlotContent();
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
// Keep the standalone role in sync if variant changes after connection.
|
|
448
|
-
if (changedProperties.has("variant")) {
|
|
449
|
-
clearTimeout(this.fadeOutTimer);
|
|
450
|
-
clearTimeout(this.closeTimer);
|
|
451
|
-
|
|
452
|
-
// Cancelling a pending close mid-fade must also undo fadeOutToast()'s
|
|
453
|
-
// visual state, otherwise the toast is left invisible (via the
|
|
454
|
-
// "hidden" class) but still marked visible, with no close ever fired.
|
|
455
|
-
this.shadowRoot?.querySelector(".toastContainer")?.classList.remove("hidden");
|
|
456
|
-
|
|
457
|
-
this._syncStandaloneRole();
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
this._scheduleAutoHide();
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
/**
|
|
464
|
-
* (Re-)schedules the auto-hide timer based on current visible/disableAutoHide/
|
|
465
|
-
* variant/timeTilHide values. Called from updated() on property changes and
|
|
466
|
-
* from connectedCallback() to re-arm auto-hide after a reconnect (e.g. the
|
|
467
|
-
* node is re-parented elsewhere in the DOM), since updated() does not run
|
|
468
|
-
* again on reconnect alone.
|
|
469
|
-
* @private
|
|
470
|
-
* @returns {void}
|
|
471
|
-
*/
|
|
472
|
-
_scheduleAutoHide() {
|
|
473
|
-
// do not auto dismiss for error toasts or if disableAutoHide is set
|
|
474
|
-
if (this.visible && !this.disableAutoHide && this.variant !== "error") {
|
|
475
|
-
clearTimeout(this.fadeOutTimer);
|
|
476
|
-
this.fadeOutTimer = setTimeout(() => {
|
|
477
|
-
this.fadeOutToast();
|
|
478
|
-
}, this.timeTilHide || DEFAULT_TIME_TIL_FADE_OUT);
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
/**
|
|
483
|
-
* Mirrors any defined custom type svg into the correct place in the template.
|
|
484
|
-
* @private
|
|
485
|
-
* @returns {void}
|
|
486
|
-
*/
|
|
487
|
-
handleSlotContent() {
|
|
488
|
-
try {
|
|
489
|
-
const customSvg = this.querySelector(`[slot="customSvg"]`);
|
|
490
|
-
|
|
491
|
-
if (customSvg) {
|
|
492
|
-
const iconSvg = customSvg.cloneNode(true);
|
|
493
|
-
const typeIcon = this.shadowRoot.querySelector(".typeIcon");
|
|
494
|
-
|
|
495
|
-
if (typeIcon) {
|
|
496
|
-
iconSvg.setAttribute("slot", "svg");
|
|
497
|
-
typeIcon.appendChild(iconSvg);
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
} catch (error) {
|
|
501
|
-
console.error("handleSlotContent", error); // eslint-disable-line no-console
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
render() {
|
|
506
|
-
return html`
|
|
507
|
-
${this.visible
|
|
508
|
-
? html`
|
|
509
|
-
<div class="toastContainer">
|
|
510
|
-
${this.noIcon
|
|
511
|
-
? undefined
|
|
512
|
-
: html`
|
|
513
|
-
<${this.iconTag} customColor customSvg class="typeIcon body-default" part="type-icon">
|
|
514
|
-
${this.variant === "custom" ? undefined : html`${this.getVariantIcon()}`}
|
|
515
|
-
</${this.iconTag}>
|
|
516
|
-
`
|
|
517
|
-
}
|
|
518
|
-
<div class="message body-default"><slot></slot></div>
|
|
519
|
-
<${this.buttonTag}
|
|
520
|
-
variant="flat"
|
|
521
|
-
shape="circle"
|
|
522
|
-
size="xs"
|
|
523
|
-
appearance=${this.variant !== "error" && this.variant !== "success" ? "inverse" : this.appearance}
|
|
524
|
-
@click="${this.clickToClose}"
|
|
525
|
-
part="close-button"
|
|
526
|
-
class="closeButton">
|
|
527
|
-
<${this.iconTag} customColor customSvg>
|
|
528
|
-
${this.closeSvg}
|
|
529
|
-
</${this.iconTag}>
|
|
530
|
-
<span slot="ariaLabel">Close this notification.</span>
|
|
531
|
-
</${this.buttonTag}>
|
|
532
|
-
</div>
|
|
533
|
-
`
|
|
534
|
-
: undefined
|
|
535
|
-
}
|
|
536
|
-
`;
|
|
537
|
-
}
|
|
538
|
-
}
|
package/src/auro-toaster.js
DELETED
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2023 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
2
|
-
// See LICENSE in the project root for license information.
|
|
3
|
-
|
|
4
|
-
// ---------------------------------------------------------------------
|
|
5
|
-
|
|
6
|
-
import { html, LitElement } from "lit";
|
|
7
|
-
import AuroLibraryRuntimeUtils from "@aurodesignsystem/auro-library/scripts/utils/runtimeUtils.mjs";
|
|
8
|
-
import styleCss from "./styles/style-toaster.scss";
|
|
9
|
-
|
|
10
|
-
export class AuroToaster extends LitElement {
|
|
11
|
-
static get styles() {
|
|
12
|
-
return [styleCss];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
constructor() {
|
|
16
|
-
super();
|
|
17
|
-
// Initialised in the constructor so they survive disconnect/reconnect.
|
|
18
|
-
// If these were in connectedCallback, a reconnected toaster would forget
|
|
19
|
-
// which error toasts it had already announced and could re-announce them.
|
|
20
|
-
this._assertiveResetTimer = undefined;
|
|
21
|
-
this._announcedErrorToasts = new WeakSet();
|
|
22
|
-
|
|
23
|
-
// Cancel the standalone live region request from any child toast — the
|
|
24
|
-
// toaster's own aria-live region handles all announcements.
|
|
25
|
-
// Calling preventDefault() causes dispatchEvent() on the toast to return
|
|
26
|
-
// false, which the toast reads as "a toaster is present — do not set a
|
|
27
|
-
// standalone live region role on the host element."
|
|
28
|
-
this._onToastRequestAnnounce = (e) => e.preventDefault();
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* This will register this element with the browser.
|
|
33
|
-
* @param {string} [name="auro-toaster"] - The name of the element that you want to register to.
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* AuroToaster.register("custom-toaster") // this will register this element to <custom-toaster/>
|
|
37
|
-
*
|
|
38
|
-
*/
|
|
39
|
-
static register(name = "auro-toaster") {
|
|
40
|
-
AuroLibraryRuntimeUtils.prototype.registerComponent(name, AuroToaster);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
connectedCallback() {
|
|
44
|
-
super.connectedCallback();
|
|
45
|
-
this.addEventListener('toast-request-announce', this._onToastRequestAnnounce);
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* @private
|
|
49
|
-
*
|
|
50
|
-
* Observes toast attribute changes to determine when we should temporarily
|
|
51
|
-
* switch the live region from "polite" → "assertive".
|
|
52
|
-
*
|
|
53
|
-
* Supported trigger paths:
|
|
54
|
-
* 1. Normal path:
|
|
55
|
-
* - A toast becomes visible
|
|
56
|
-
* - AND it is already an error toast
|
|
57
|
-
* 2. Defensive fallback (unsupported but possible misuse):
|
|
58
|
-
* - A visible toast has its variant changed to "error"
|
|
59
|
-
*
|
|
60
|
-
* Note:
|
|
61
|
-
* Toasts are not intended to mutate while visible. This fallback exists
|
|
62
|
-
* only to preserve accessibility behavior if that contract is violated.
|
|
63
|
-
*/
|
|
64
|
-
this._observer = new MutationObserver((mutations) => {
|
|
65
|
-
for (const mutation of mutations) {
|
|
66
|
-
const target = mutation.target;
|
|
67
|
-
|
|
68
|
-
// Only react to auro-toast elements (including versioned tags like
|
|
69
|
-
// auro-toast_1_2_3). Explicitly ignore auro-toaster itself.
|
|
70
|
-
if (!/^auro-toast(_|$)/u.test(target.localName ?? '')) continue;
|
|
71
|
-
|
|
72
|
-
const isVisible = target.hasAttribute?.('visible');
|
|
73
|
-
const isError = target.getAttribute?.('variant') === 'error';
|
|
74
|
-
|
|
75
|
-
// ---------------------------------------------------------------------
|
|
76
|
-
// Case 1: supported behavior
|
|
77
|
-
// A toast becomes visible AND is already an error toast
|
|
78
|
-
// ---------------------------------------------------------------------
|
|
79
|
-
const becameVisible =
|
|
80
|
-
mutation.attributeName === 'visible' &&
|
|
81
|
-
isVisible &&
|
|
82
|
-
isError;
|
|
83
|
-
|
|
84
|
-
// ---------------------------------------------------------------------
|
|
85
|
-
// Case 2: defensive fallback
|
|
86
|
-
// A toast is already visible and its variant is changed to "error"
|
|
87
|
-
// (unsupported usage pattern, but we handle it safely for a11y)
|
|
88
|
-
// ---------------------------------------------------------------------
|
|
89
|
-
const becameErrorWhileVisible =
|
|
90
|
-
mutation.attributeName === 'variant' &&
|
|
91
|
-
mutation.oldValue !== 'error' &&
|
|
92
|
-
isVisible &&
|
|
93
|
-
isError;
|
|
94
|
-
|
|
95
|
-
if (becameVisible || becameErrorWhileVisible) {
|
|
96
|
-
this._setAssertiveTemporarily();
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
this._observer.observe(this, {
|
|
102
|
-
subtree: true,
|
|
103
|
-
|
|
104
|
-
// REQUIRED: without this, attribute changes will not trigger the observer
|
|
105
|
-
attributes: true,
|
|
106
|
-
|
|
107
|
-
// We only care about these two attributes for performance and clarity
|
|
108
|
-
attributeFilter: ['visible', 'variant'],
|
|
109
|
-
|
|
110
|
-
// REQUIRED for detecting transitions (e.g. non-error → error)
|
|
111
|
-
attributeOldValue: true,
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
disconnectedCallback() {
|
|
116
|
-
super.disconnectedCallback();
|
|
117
|
-
this._observer?.disconnect();
|
|
118
|
-
clearTimeout(this._assertiveResetTimer);
|
|
119
|
-
this.removeEventListener('toast-request-announce', this._onToastRequestAnnounce);
|
|
120
|
-
|
|
121
|
-
// Reset the live region to polite so a reconnected toaster does not
|
|
122
|
-
// inherit a stale assertive state left behind by a cleared timer.
|
|
123
|
-
const liveRegion = this.shadowRoot?.querySelector('[aria-live]');
|
|
124
|
-
if (liveRegion) {
|
|
125
|
-
liveRegion.setAttribute('aria-live', 'polite');
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Temporarily sets the live region to assertive so the error toast
|
|
131
|
-
* interrupts the screen reader, then resets to polite after 3 seconds.
|
|
132
|
-
* This ensures subsequent polite toasts don't keep interrupting the user,
|
|
133
|
-
* even if the error toast remains visible (errors are never auto-dismissed).
|
|
134
|
-
* @private
|
|
135
|
-
*/
|
|
136
|
-
_setAssertiveTemporarily() {
|
|
137
|
-
const liveRegion = this.shadowRoot?.querySelector('[aria-live]');
|
|
138
|
-
if (!liveRegion) return;
|
|
139
|
-
|
|
140
|
-
clearTimeout(this._assertiveResetTimer);
|
|
141
|
-
liveRegion.setAttribute('aria-live', 'assertive');
|
|
142
|
-
|
|
143
|
-
this._assertiveResetTimer = setTimeout(() => {
|
|
144
|
-
liveRegion.setAttribute('aria-live', 'polite');
|
|
145
|
-
}, 3000);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
render() {
|
|
149
|
-
return html`
|
|
150
|
-
<div class="toaster-wrapper" aria-live="polite" aria-atomic="false">
|
|
151
|
-
<slot @slotchange="${this._onSlotChange}"></slot>
|
|
152
|
-
</div>
|
|
153
|
-
`;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Handles slot changes — checks if a newly slotted error toast
|
|
158
|
-
* is already visible at the time it is added to the toaster.
|
|
159
|
-
* @private
|
|
160
|
-
*/
|
|
161
|
-
_onSlotChange(e) {
|
|
162
|
-
const newErrorToast = e.target.assignedElements({ flatten: true })
|
|
163
|
-
.find(el =>
|
|
164
|
-
/^auro-toast(_|$)/u.test(el.localName ?? '') &&
|
|
165
|
-
el.getAttribute('variant') === 'error' &&
|
|
166
|
-
el.hasAttribute('visible') &&
|
|
167
|
-
!this._announcedErrorToasts.has(el)
|
|
168
|
-
);
|
|
169
|
-
|
|
170
|
-
if (newErrorToast) {
|
|
171
|
-
this._announcedErrorToasts.add(newErrorToast);
|
|
172
|
-
this._setAssertiveTemporarily();
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
package/src/buttonVersion.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default "12.3.2";
|
package/src/iconVersion.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default "9.2.0";
|
package/src/index.js
DELETED
package/src/registered.js
DELETED
package/src/styles/color.scss
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2023 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
2
|
-
// See LICENSE in the project root for license information.
|
|
3
|
-
|
|
4
|
-
// ---------------------------------------------------------------------
|
|
5
|
-
|
|
6
|
-
// Import Auro tokens
|
|
7
|
-
@use "@aurodesignsystem/design-tokens/dist/themes/alaska/SCSSVariables--alaska" as v;
|
|
8
|
-
|
|
9
|
-
:host([visible]) {
|
|
10
|
-
background-color: var(--ds-auro-toast-container-color);
|
|
11
|
-
color: var(--ds-auro-toast-text-color);
|
|
12
|
-
|
|
13
|
-
.typeIcon {
|
|
14
|
-
color: var(--ds-auro-toast-icon-color);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.closeButton {
|
|
18
|
-
&:hover {
|
|
19
|
-
background-color: var(--ds-auro-toast-close-button-hover-container-color);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
:host([variant='error']) {
|
|
25
|
-
--ds-auro-toast-container-color: var(--ds-basic-color-status-error-subtle, #{v.$ds-basic-color-status-error-subtle});
|
|
26
|
-
--ds-auro-toast-icon-color: var(--ds-basic-color-status-error, #{v.$ds-basic-color-status-error});
|
|
27
|
-
--ds-auro-toast-text-color: var(--ds-basic-color-texticon-default, #{v.$ds-basic-color-texticon-default});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
:host([variant='success']) {
|
|
31
|
-
--ds-auro-toast-container-color: var(--ds-basic-color-status-success-subtle, #{v.$ds-basic-color-status-success-subtle});
|
|
32
|
-
--ds-auro-toast-icon-color: var(--ds-basic-color-status-success, #{v.$ds-basic-color-status-success});
|
|
33
|
-
--ds-auro-toast-text-color: var(--ds-basic-color-texticon-default, #{v.$ds-basic-color-texticon-default});
|
|
34
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2023 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
2
|
-
// See LICENSE in the project root for license information.
|
|
3
|
-
|
|
4
|
-
// ---------------------------------------------------------------------
|
|
5
|
-
|
|
6
|
-
// Import Auro tokens
|
|
7
|
-
@use "@aurodesignsystem/design-tokens/dist/legacy/auro-classic/SCSSVariables" as vac;
|
|
8
|
-
|
|
9
|
-
// container styles - defines the look of the outer custom component
|
|
10
|
-
.toaster-wrapper {
|
|
11
|
-
position: fixed;
|
|
12
|
-
z-index: var(--ds-depth-modal, vac.$ds-depth-modal);
|
|
13
|
-
right: 2%;
|
|
14
|
-
bottom: 2%;
|
|
15
|
-
left: 2%;
|
|
16
|
-
display: flex;
|
|
17
|
-
flex-direction: column-reverse;
|
|
18
|
-
align-items: flex-end;
|
|
19
|
-
gap: var(--ds-size-200, vac.$ds-size-200);
|
|
20
|
-
pointer-events: none;
|
|
21
|
-
|
|
22
|
-
@media (width >= #{vac.$ds-grid-breakpoint-lg}) {
|
|
23
|
-
right: 1%;
|
|
24
|
-
left: unset;
|
|
25
|
-
width: 100%;
|
|
26
|
-
}
|
|
27
|
-
}
|
package/src/styles/style.scss
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2023 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
2
|
-
// See LICENSE in the project root for license information.
|
|
3
|
-
|
|
4
|
-
// ---------------------------------------------------------------------
|
|
5
|
-
|
|
6
|
-
// Import Auro tokens
|
|
7
|
-
@use "@aurodesignsystem/design-tokens/dist/legacy/auro-classic/SCSSVariables" as vac;
|
|
8
|
-
|
|
9
|
-
@use '@aurodesignsystem/webcorestylesheets/dist/bundled/type/classes.alaska.min.css';
|
|
10
|
-
|
|
11
|
-
// display: inherit keeps the host in the accessibility tree when not visible.
|
|
12
|
-
// display: none removes it entirely from the accessibility tree —
|
|
13
|
-
//
|
|
14
|
-
// This is used to prevent visual artifacts from toasts that remain in the DOM
|
|
15
|
-
// after hiding.
|
|
16
|
-
:host {
|
|
17
|
-
display: inherit;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
:host([visible]) {
|
|
21
|
-
display: inline-block;
|
|
22
|
-
min-width: 100%;
|
|
23
|
-
border-radius: var(--ds-size-100, vac.$ds-size-100);
|
|
24
|
-
box-shadow: var(--ds-elevation-200, vac.$ds-elevation-200);
|
|
25
|
-
pointer-events: auto;
|
|
26
|
-
|
|
27
|
-
// Phones (< sm) keep the full-width sizing from the base rule above.
|
|
28
|
-
// From the sm breakpoint up, use fixed pixel bounds so the toast is sized
|
|
29
|
-
// consistently across tablet and desktop widths instead of shrinking to a
|
|
30
|
-
// small fraction of the available space.
|
|
31
|
-
@media (width >= #{vac.$ds-grid-breakpoint-sm}) {
|
|
32
|
-
min-width: 200px;
|
|
33
|
-
max-width: 500px;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.toastContainer {
|
|
37
|
-
display: flex;
|
|
38
|
-
flex-direction: row;
|
|
39
|
-
align-items: flex-start;
|
|
40
|
-
padding: var(--ds-size-200, vac.$ds-size-200) var(--ds-size-150, vac.$ds-size-150);
|
|
41
|
-
gap: var(--ds-size-200, vac.$ds-size-200);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.hidden {
|
|
45
|
-
opacity: 0;
|
|
46
|
-
transition: visibility 0s 300ms, opacity 300ms ease-out;
|
|
47
|
-
visibility: hidden;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
[auro-icon] {
|
|
51
|
-
--ds-auro-icon-size: var(--ds-size-300, #{vac.$ds-size-300});
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.message {
|
|
55
|
-
flex: 1;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.closeButton {
|
|
59
|
-
border-radius: 50%;
|
|
60
|
-
}
|
|
61
|
-
}
|
package/src/styles/tokens.scss
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
@use "@aurodesignsystem/design-tokens/dist/themes/alaska/SCSSVariables--alaska" as v;
|
|
2
|
-
|
|
3
|
-
:host {
|
|
4
|
-
--ds-auro-toast-close-button-hover-container-color: var(--ds-advanced-color-button-tertiary-background-hover, #{v.$ds-advanced-color-button-tertiary-background-hover});
|
|
5
|
-
--ds-auro-toast-container-color: var(--ds-advanced-color-shared-background-strong, #{v.$ds-advanced-color-shared-background-strong});
|
|
6
|
-
--ds-auro-toast-icon-color: var(--ds-basic-color-texticon-inverse, #{v.$ds-basic-color-texticon-inverse});
|
|
7
|
-
--ds-auro-toast-text-color: var(--ds-basic-color-texticon-inverse, #{v.$ds-basic-color-texticon-inverse});
|
|
8
|
-
}
|