@aurodesignsystem-dev/auro-toast 0.0.0-pr121.19 → 0.0.0-pr121.20

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 CHANGED
@@ -93,7 +93,7 @@ In cases where the project is not able to process JS assets, there are pre-proce
93
93
  NOTE: The manually added style is NOT necessary for use,
94
94
  Demo purposes ONLY!
95
95
  -->
96
- <auro-toast style="display: block; margin: 0.5rem 0;" id="basicToast">
96
+ <auro-toast style="display: block; margin: 0.5rem 0;" id="basicToast">
97
97
  Default notification with no error type.
98
98
  </auro-toast>
99
99
  ```
package/demo/api.md CHANGED
@@ -49,7 +49,7 @@ The `auro-toast` element provides users a way to display short, temporary messag
49
49
  NOTE: The manually added style is NOT necessary for use,
50
50
  Demo purposes ONLY!
51
51
  -->
52
- <auro-toast style="display: block; margin: 0.5rem 0;" id="basicToast">
52
+ <auro-toast style="display: block; margin: 0.5rem 0;" id="basicToast">
53
53
  Default notification with no error type.
54
54
  </auro-toast>
55
55
  <!-- AURO-GENERATED-CONTENT:END -->
@@ -67,7 +67,7 @@ The `auro-toast` element provides users a way to display short, temporary messag
67
67
  NOTE: The manually added style is NOT necessary for use,
68
68
  Demo purposes ONLY!
69
69
  -->
70
- <auro-toast style="display: block; margin: 0.5rem 0;" id="basicToast">
70
+ <auro-toast style="display: block; margin: 0.5rem 0;" id="basicToast">
71
71
  Default notification with no error type.
72
72
  </auro-toast>
73
73
  ```
@@ -530,7 +530,7 @@ When dynamically injecting `auro-toast` elements at runtime, the consumer is res
530
530
 
531
531
  The required pattern is a persistent container — a `div` or equivalent — with `aria-live="polite"` or `aria-live="assertive"`* that remains in the DOM at all times. Your application logic then injects `auro-toast` elements into this container at runtime as notifications occur.
532
532
 
533
- **Warning:** Never apply `display: none` to the live region container. Doing so removes it from the accessibility tree entirely, which prevents screen readers from registering the live region. Any toast announcements will be silently lost, resulting in a critical accessibility violation.
533
+ **Warning:** Avoid applying `display: none` to a live region while it is in use. This removes it from the accessibility tree, preventing screen readers from detecting updates. Any announcements triggered during that time will be lost.
534
534
 
535
535
  `auro-toast` automatically detects any ancestor live region at connection time. When one is found, it defers to that region and does not add its own role, preventing nested live regions.
536
536
 
package/demo/basic.min.js CHANGED
@@ -768,24 +768,53 @@ class AuroToaster extends i$2 {
768
768
 
769
769
  /**
770
770
  * @private
771
+ *
772
+ * Observes toast attribute changes to determine when we should temporarily
773
+ * switch the live region from "polite" → "assertive".
774
+ *
775
+ * Supported trigger paths:
776
+ * 1. Normal path:
777
+ * - A toast becomes visible
778
+ * - AND it is already an error toast
779
+ * 2. Defensive fallback (unsupported but possible misuse):
780
+ * - A visible toast has its variant changed to "error"
781
+ *
782
+ * Note:
783
+ * Toasts are not intended to mutate while visible. This fallback exists
784
+ * only to preserve accessibility behavior if that contract is violated.
771
785
  */
772
- // Only react to visible attribute changes on error toasts.
773
- // Other mutations (polite toasts appearing, etc.) should not
774
- // override a timed assertive reset already in progress.
775
786
  this._observer = new MutationObserver((mutations) => {
776
787
  for (const mutation of mutations) {
777
788
  const target = mutation.target;
778
789
 
779
- // Only react to auro-toast elements, not other children that may also
780
- // use a "visible" attribute. The regex matches auro-toast and versioned
781
- // tag names (e.g. auro-toast_9_2_1) but intentionally excludes
782
- // auro-toaster, which shares the same prefix.
790
+ // Only react to auro-toast elements (including versioned tags like
791
+ // auro-toast_1_2_3). Explicitly ignore auro-toaster itself.
783
792
  if (!/^auro-toast(_|$)/u.test(target.localName ?? '')) continue;
784
793
 
785
- const isErrorToast = target.getAttribute?.('variant') === 'error';
786
- const becameVisible = target.hasAttribute?.('visible');
787
-
788
- if (isErrorToast && becameVisible) {
794
+ const isVisible = target.hasAttribute?.('visible');
795
+ const isError = target.getAttribute?.('variant') === 'error';
796
+
797
+ // ---------------------------------------------------------------------
798
+ // Case 1: supported behavior
799
+ // A toast becomes visible AND is already an error toast
800
+ // ---------------------------------------------------------------------
801
+ const becameVisible =
802
+ mutation.attributeName === 'visible' &&
803
+ isVisible &&
804
+ isError;
805
+
806
+ // ---------------------------------------------------------------------
807
+ // Case 2: defensive fallback
808
+ // A toast is already visible and its variant is changed to "error"
809
+ // (unsupported usage pattern, but we handle it safely for a11y)
810
+ // ---------------------------------------------------------------------
811
+ const becameErrorWhileVisible =
812
+ mutation.attributeName === 'variant' &&
813
+ mutation.oldValue !== 'error' &&
814
+ isVisible &&
815
+ isError;
816
+
817
+ if (becameVisible || becameErrorWhileVisible) {
789
818
  this._setAssertiveTemporarily();
790
819
  }
791
820
  }
@@ -793,7 +822,15 @@ class AuroToaster extends i$2 {
793
822
 
794
823
  this._observer.observe(this, {
795
824
  subtree: true,
796
- attributeFilter: ['visible'],
825
+
826
+ // REQUIRED: without this, attribute changes will not trigger the observer
827
+ attributes: true,
828
+
829
+ // We only care about these two attributes for performance and clarity
830
+ attributeFilter: ['visible', 'variant'],
831
+
832
+ // REQUIRED for detecting transitions (e.g. non-error → error)
833
+ attributeOldValue: true,
797
834
  });
798
835
  }
799
836
 
package/demo/index.md CHANGED
@@ -51,7 +51,7 @@ showToast = (toastID) => {
51
51
  NOTE: The manually added style is NOT necessary for use,
52
52
  Demo purposes ONLY!
53
53
  -->
54
- <auro-toast style="display: block; margin: 0.5rem 0;" id="basicToast">
54
+ <auro-toast style="display: block; margin: 0.5rem 0;" id="basicToast">
55
55
  Default notification with no error type.
56
56
  </auro-toast>
57
57
  <!-- AURO-GENERATED-CONTENT:END -->
@@ -69,7 +69,7 @@ showToast = (toastID) => {
69
69
  NOTE: The manually added style is NOT necessary for use,
70
70
  Demo purposes ONLY!
71
71
  -->
72
- <auro-toast style="display: block; margin: 0.5rem 0;" id="basicToast">
72
+ <auro-toast style="display: block; margin: 0.5rem 0;" id="basicToast">
73
73
  Default notification with no error type.
74
74
  </auro-toast>
75
75
  ```
@@ -103,7 +103,7 @@ import{css as e,LitElement as t,html as s}from"lit";import{unsafeStatic as a,lit
103
103
  </div>
104
104
  `:void 0}
105
105
  `}}var Z=e`.toaster-wrapper{position:fixed;z-index:var(--ds-depth-modal, 300);right:2%;bottom:2%;left:2%;display:flex;flex-direction:column-reverse;align-items:flex-end;gap:var(--ds-size-200, 1rem);pointer-events:none}@media (width >= 1024px){.toaster-wrapper{right:1%;left:unset;width:100%}}
106
- `;class ee extends t{static get styles(){return[Z]}constructor(){super(),this._assertiveResetTimer=void 0,this._announcedErrorToasts=new WeakSet,this._onToastRequestAnnounce=e=>e.preventDefault()}static register(e="auro-toaster"){c.prototype.registerComponent(e,ee)}connectedCallback(){super.connectedCallback(),this.addEventListener("toast-request-announce",this._onToastRequestAnnounce),this._observer=new MutationObserver(e=>{for(const t of e){const e=t.target;if(!/^auro-toast(_|$)/u.test(e.localName??""))continue;const s="error"===e.getAttribute?.("variant"),a=e.hasAttribute?.("visible");s&&a&&this._setAssertiveTemporarily()}}),this._observer.observe(this,{subtree:!0,attributeFilter:["visible"]})}disconnectedCallback(){super.disconnectedCallback(),this._observer?.disconnect(),clearTimeout(this._assertiveResetTimer),this.removeEventListener("toast-request-announce",this._onToastRequestAnnounce);const e=this.shadowRoot?.querySelector("[aria-live]");e&&e.setAttribute("aria-live","polite")}_setAssertiveTemporarily(){const e=this.shadowRoot?.querySelector("[aria-live]");e&&(clearTimeout(this._assertiveResetTimer),e.setAttribute("aria-live","assertive"),this._assertiveResetTimer=setTimeout(()=>{e.setAttribute("aria-live","polite")},3e3))}render(){return s`
106
+ `;class ee extends t{static get styles(){return[Z]}constructor(){super(),this._assertiveResetTimer=void 0,this._announcedErrorToasts=new WeakSet,this._onToastRequestAnnounce=e=>e.preventDefault()}static register(e="auro-toaster"){c.prototype.registerComponent(e,ee)}connectedCallback(){super.connectedCallback(),this.addEventListener("toast-request-announce",this._onToastRequestAnnounce),this._observer=new MutationObserver(e=>{for(const t of e){const e=t.target;if(!/^auro-toast(_|$)/u.test(e.localName??""))continue;const s=e.hasAttribute?.("visible"),a="error"===e.getAttribute?.("variant"),o="visible"===t.attributeName&&s&&a,r="variant"===t.attributeName&&"error"!==t.oldValue&&s&&a;(o||r)&&this._setAssertiveTemporarily()}}),this._observer.observe(this,{subtree:!0,attributes:!0,attributeFilter:["visible","variant"],attributeOldValue:!0})}disconnectedCallback(){super.disconnectedCallback(),this._observer?.disconnect(),clearTimeout(this._assertiveResetTimer),this.removeEventListener("toast-request-announce",this._onToastRequestAnnounce);const e=this.shadowRoot?.querySelector("[aria-live]");e&&e.setAttribute("aria-live","polite")}_setAssertiveTemporarily(){const e=this.shadowRoot?.querySelector("[aria-live]");e&&(clearTimeout(this._assertiveResetTimer),e.setAttribute("aria-live","assertive"),this._assertiveResetTimer=setTimeout(()=>{e.setAttribute("aria-live","polite")},3e3))}render(){return s`
107
107
  <div class="toaster-wrapper" aria-live="polite" aria-atomic="false">
108
108
  <slot @slotchange="${this._onSlotChange}"></slot>
109
109
  </div>
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export{A as AuroToast,a as AuroToaster}from"./auro-toaster-jZvkUugt.js";import"lit";import"lit/static-html.js";import"lit/directives/class-map.js";import"lit/directives/if-defined.js";
1
+ export{A as AuroToast,a as AuroToaster}from"./auro-toaster-C16e0fNp.js";import"lit";import"lit/static-html.js";import"lit/directives/class-map.js";import"lit/directives/if-defined.js";
@@ -1 +1 @@
1
- import{A as i,a as t}from"./auro-toaster-jZvkUugt.js";import"lit";import"lit/static-html.js";import"lit/directives/class-map.js";import"lit/directives/if-defined.js";i.register(),t.register();
1
+ import{A as i,a as t}from"./auro-toaster-C16e0fNp.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-pr121.19",
10
+ "version": "0.0.0-pr121.20",
11
11
  "description": "auro-toast HTML custom element",
12
12
  "repository": {
13
13
  "type": "git",