@aurodesignsystem-dev/auro-toast 0.0.0-pr121.2 → 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
@@ -89,8 +89,12 @@ In cases where the project is not able to process JS assets, there are pre-proce
89
89
  <auro-button id="basicToastBtn">
90
90
  Show default notification
91
91
  </auro-button>
92
+ <!--
93
+ NOTE: The manually added style is NOT necessary for use,
94
+ Demo purposes ONLY!
95
+ -->
92
96
  <auro-toast style="display: block; margin: 0.5rem 0;" id="basicToast">
93
- Default notification with no error type
97
+ Default notification with no error type.
94
98
  </auro-toast>
95
99
  ```
96
100
  <!-- AURO-GENERATED-CONTENT:END -->
@@ -126,7 +130,7 @@ This will create a new custom element `<custom-toast>` that behaves exactly like
126
130
  Show default notification
127
131
  </auro-button>
128
132
  <custom-toast style="display: block; margin: 0.5rem 0;" id="customToast">
129
- Default notification with no error type
133
+ Default notification with no error type.
130
134
  </custom-toast>
131
135
  <!-- AURO-GENERATED-CONTENT:END -->
132
136
  </div>
@@ -140,7 +144,7 @@ This will create a new custom element `<custom-toast>` that behaves exactly like
140
144
  Show default notification
141
145
  </auro-button>
142
146
  <custom-toast style="display: block; margin: 0.5rem 0;" id="customToast">
143
- Default notification with no error type
147
+ Default notification with no error type.
144
148
  </custom-toast>
145
149
  ```
146
150
  <!-- AURO-GENERATED-CONTENT:END -->
package/demo/api.js CHANGED
@@ -7,6 +7,8 @@ import { initCustomToastExample } from "../apiExamples/custom-toast";
7
7
  import { initVisibleExample } from "../apiExamples/visible";
8
8
  import { initMultipleToastsExample } from "../apiExamples/multiple-toasts";
9
9
  import { initDynamicToastsExample } from "../apiExamples/dynamic-toasts";
10
+ import { initStandaloneToastExample } from "../apiExamples/standalone-toast";
11
+ import { initTriggerExample } from "../apiExamples/trigger";
10
12
 
11
13
  import "../src/registered";
12
14
  /* eslint-disable jsdoc/require-jsdoc, no-magic-numbers, no-param-reassign */
@@ -26,6 +28,8 @@ export function initExamples(initCount) {
26
28
  initVisibleExample();
27
29
  initMultipleToastsExample();
28
30
  initDynamicToastsExample();
31
+ initStandaloneToastExample();
32
+ initTriggerExample();
29
33
  } catch (_err) {
30
34
  if (initCount <= 20) {
31
35
  // setTimeout handles issue where content is sometimes loaded after the functions get called
package/demo/api.md CHANGED
@@ -7,13 +7,15 @@ The `auro-toast` element provides users a way to display short, temporary messag
7
7
 
8
8
  ### Properties & Attributes
9
9
 
10
- | Properties | Attributes | Modifiers | Type | Default | Description |
11
- | --------------- | --------------- | --------- | -------------------------------- | ------- | ------------------------------------------------------------------- |
12
- | disableAutoHide | disableAutoHide | | boolean | | Prevents the toast from auto-hiding on the default time. |
13
- | noIcon | noIcon | | boolean | | Removes icon from the toast UI. |
14
- | timeTilHide | timeTilHide | | number | | Sets the time in milliseconds until the toast hides. |
15
- | variant | variant | | `error` \| `success` \| `custom` | | Component will render visually based on which variant value is set. |
16
- | visible | visible | | boolean | | Sets state of toast to visible |
10
+ | Properties | Attributes | Modifiers | Type | Default | Description |
11
+ | --------------- | --------------- | --------- | -------------------------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
12
+ | disableAutoHide | disableAutoHide | | boolean | | Prevents the toast from auto-hiding on the default time. |
13
+ | noIcon | noIcon | | boolean | | Removes icon from the toast UI. |
14
+ | timeTilHide | timeTilHide | | number | | Sets the time in milliseconds until the toast hides. |
15
+ | trigger | trigger | | string | | The id of the element that triggered the toast.<br>When the toast is manually closed, focus will return to this element.<br>Takes precedence over the triggerElement property if both are set. |
16
+ | triggerElement | | | HTMLElement | | A direct reference to the element that triggered the toast.<br>When the toast is manually closed, focus will return to this element.<br>Use the trigger attribute instead if you prefer a declarative approach. |
17
+ | variant | variant | | `error` \| `success` \| `custom` | | Component will render visually based on which variant value is set. |
18
+ | visible | visible | | boolean | | Sets state of toast to visible |
17
19
 
18
20
  ### Methods
19
21
 
@@ -43,8 +45,12 @@ The `auro-toast` element provides users a way to display short, temporary messag
43
45
  <auro-button id="basicToastBtn">
44
46
  Show default notification
45
47
  </auro-button>
48
+ <!--
49
+ NOTE: The manually added style is NOT necessary for use,
50
+ Demo purposes ONLY!
51
+ -->
46
52
  <auro-toast style="display: block; margin: 0.5rem 0;" id="basicToast">
47
- Default notification with no error type
53
+ Default notification with no error type.
48
54
  </auro-toast>
49
55
  <!-- AURO-GENERATED-CONTENT:END -->
50
56
  </div>
@@ -57,8 +63,12 @@ The `auro-toast` element provides users a way to display short, temporary messag
57
63
  <auro-button id="basicToastBtn">
58
64
  Show default notification
59
65
  </auro-button>
66
+ <!--
67
+ NOTE: The manually added style is NOT necessary for use,
68
+ Demo purposes ONLY!
69
+ -->
60
70
  <auro-toast style="display: block; margin: 0.5rem 0;" id="basicToast">
61
- Default notification with no error type
71
+ Default notification with no error type.
62
72
  </auro-toast>
63
73
  ```
64
74
  <!-- AURO-GENERATED-CONTENT:END -->
@@ -77,7 +87,7 @@ Use the `disableAutoHide` attribute to prevent the toast from automatically dism
77
87
  Show default notification
78
88
  </auro-button>
79
89
  <auro-toast style="display: block; margin: 0.5rem 0;" id="disableHideToast">
80
- Default notification with no error type
90
+ Default notification with no error type.
81
91
  </auro-toast>
82
92
  <!-- AURO-GENERATED-CONTENT:END -->
83
93
  </div>
@@ -91,7 +101,7 @@ Use the `disableAutoHide` attribute to prevent the toast from automatically dism
91
101
  Show default notification
92
102
  </auro-button>
93
103
  <auro-toast style="display: block; margin: 0.5rem 0;" id="disableHideToast">
94
- Default notification with no error type
104
+ Default notification with no error type.
95
105
  </auro-toast>
96
106
  ```
97
107
  <!-- AURO-GENERATED-CONTENT:END -->
@@ -105,7 +115,7 @@ Using the `noIcon` attribute will set no icon to be visible in the notification.
105
115
  <!-- AURO-GENERATED-CONTENT:START (FILE:src=./../apiExamples/no-icon.html) -->
106
116
  <!-- The below content is automatically added from ./../apiExamples/no-icon.html -->
107
117
  <auro-button id="noIconBtn"> Show toast with no icon </auro-button>
108
- <auro-toast id="noIcon" noIcon style="display: block; margin: 0.5rem 0;"> Default toast </auro-toast>
118
+ <auro-toast id="noIcon" noIcon style="display: block; margin: 0.5rem 0;"> Default toast. </auro-toast>
109
119
  <!-- AURO-GENERATED-CONTENT:END -->
110
120
  </div>
111
121
  <auro-accordion alignRight>
@@ -115,7 +125,7 @@ Using the `noIcon` attribute will set no icon to be visible in the notification.
115
125
 
116
126
  ```html
117
127
  <auro-button id="noIconBtn"> Show toast with no icon </auro-button>
118
- <auro-toast id="noIcon" noIcon style="display: block; margin: 0.5rem 0;"> Default toast </auro-toast>
128
+ <auro-toast id="noIcon" noIcon style="display: block; margin: 0.5rem 0;"> Default toast. </auro-toast>
119
129
  ```
120
130
  <!-- AURO-GENERATED-CONTENT:END -->
121
131
  </auro-accordion>
@@ -131,7 +141,7 @@ Using the `timeTilHide` attribute will set a timer in milliseconds for how long
131
141
  Show default notification
132
142
  </auro-button>
133
143
  <auro-toast timeTilHide="1000" style="display: block; margin: 0.5rem 0;" id="timeTilHideToast">
134
- Default notification with no error type
144
+ Default notification with no error type.
135
145
  </auro-toast>
136
146
  <!-- AURO-GENERATED-CONTENT:END -->
137
147
  </div>
@@ -145,7 +155,7 @@ Using the `timeTilHide` attribute will set a timer in milliseconds for how long
145
155
  Show default notification
146
156
  </auro-button>
147
157
  <auro-toast timeTilHide="1000" style="display: block; margin: 0.5rem 0;" id="timeTilHideToast">
148
- Default notification with no error type
158
+ Default notification with no error type.
149
159
  </auro-toast>
150
160
  ```
151
161
  <!-- AURO-GENERATED-CONTENT:END -->
@@ -164,19 +174,19 @@ What the component will render visually based on which variant value is set; cur
164
174
  Show default toast
165
175
  </auro-button>
166
176
  <auro-toast id="defaultVariant" style="display: block; margin: 0.5rem 0;">
167
- Default toast
177
+ Default toast.
168
178
  </auro-toast>
169
179
  <auro-button id="errorVariantBtn">
170
180
  Show error toast
171
181
  </auro-button>
172
182
  <auro-toast id="errorVariant" variant="error" style="display: block; margin: 0.5rem 0;">
173
- Unable to add lap infant. Please try again
183
+ Unable to add lap infant. Please try again.
174
184
  </auro-toast>
175
185
  <auro-button id="successVariantBtn">
176
186
  Show success toast
177
187
  </auro-button>
178
188
  <auro-toast id="successVariant" variant="success" style="display: block; margin: 0.5rem 0;">
179
- Successfully added lap infant
189
+ Successfully added lap infant.
180
190
  </auro-toast>
181
191
  <!-- AURO-GENERATED-CONTENT:END -->
182
192
  </div>
@@ -190,19 +200,19 @@ What the component will render visually based on which variant value is set; cur
190
200
  Show default toast
191
201
  </auro-button>
192
202
  <auro-toast id="defaultVariant" style="display: block; margin: 0.5rem 0;">
193
- Default toast
203
+ Default toast.
194
204
  </auro-toast>
195
205
  <auro-button id="errorVariantBtn">
196
206
  Show error toast
197
207
  </auro-button>
198
208
  <auro-toast id="errorVariant" variant="error" style="display: block; margin: 0.5rem 0;">
199
- Unable to add lap infant. Please try again
209
+ Unable to add lap infant. Please try again.
200
210
  </auro-toast>
201
211
  <auro-button id="successVariantBtn">
202
212
  Show success toast
203
213
  </auro-button>
204
214
  <auro-toast id="successVariant" variant="success" style="display: block; margin: 0.5rem 0;">
205
- Successfully added lap infant
215
+ Successfully added lap infant.
206
216
  </auro-toast>
207
217
  ```
208
218
  <!-- AURO-GENERATED-CONTENT:END -->
@@ -229,7 +239,7 @@ The toast notification can be customized in several ways.
229
239
  variant="custom"
230
240
  visible
231
241
  disableAutoHide
232
- style="--ds-auro-toast-container-color: var(--ds-color-background-info-default); --ds-auro-toast-text-color: var(--ds-color-text-primary-default);">
242
+ style="--ds-auro-toast-container-color: var(--ds-color-background-info-default); --ds-auro-toast-text-color: var(--ds-color-text-primary-default); display: block; margin: 0.5rem 0;">
233
243
  Did you know you can create a price alert for this route?
234
244
  <br />
235
245
  <auro-button variant="tertiary">Create Alert</auro-button>
@@ -252,7 +262,7 @@ The toast notification can be customized in several ways.
252
262
  variant="custom"
253
263
  visible
254
264
  disableAutoHide
255
- style="--ds-auro-toast-container-color: var(--ds-color-background-info-default); --ds-auro-toast-text-color: var(--ds-color-text-primary-default);">
265
+ style="--ds-auro-toast-container-color: var(--ds-color-background-info-default); --ds-auro-toast-text-color: var(--ds-color-text-primary-default); display: block; margin: 0.5rem 0;">
256
266
  Did you know you can create a price alert for this route?
257
267
  <br />
258
268
  <auro-button variant="tertiary">Create Alert</auro-button>
@@ -273,7 +283,7 @@ State of the push notification which determines if it is `visible`.
273
283
  Set visible to true
274
284
  </auro-button>
275
285
  <auro-toast id="visibleToast" style="display: block; margin: 0.5rem 0;">
276
- Default toast
286
+ Default toast.
277
287
  </auro-toast>
278
288
  <!-- AURO-GENERATED-CONTENT:END -->
279
289
  </div>
@@ -287,12 +297,136 @@ State of the push notification which determines if it is `visible`.
287
297
  Set visible to true
288
298
  </auro-button>
289
299
  <auro-toast id="visibleToast" style="display: block; margin: 0.5rem 0;">
290
- Default toast
300
+ Default toast.
291
301
  </auro-toast>
292
302
  ```
293
303
  <!-- AURO-GENERATED-CONTENT:END -->
294
304
  </auro-accordion>
295
305
 
306
+ ### Focus Management — trigger and triggerElement
307
+
308
+ When a toast is manually dismissed via the close button, focus should return to the element that originally triggered it. Use the `trigger` attribute to specify the `id` of that element, or the `triggerElement` property to pass a direct element reference. The `trigger` attribute takes precedence when both are set.
309
+
310
+ <div class="exampleWrapper">
311
+ <!-- AURO-GENERATED-CONTENT:START (FILE:src=./../apiExamples/trigger.html) -->
312
+ <!-- The below content is automatically added from ./../apiExamples/trigger.html -->
313
+ <p>Use the <code>trigger</code> attribute to pass the <code>id</code> of the element that opened the toast. When the toast is manually closed, focus will return to that element.</p>
314
+ <auro-button id="triggerAttrBtn">
315
+ Show notification
316
+ </auro-button>
317
+ <!--
318
+ NOTE: The manually added style is NOT necessary for use,
319
+ Demo purposes ONLY!
320
+ -->
321
+ <auro-toast style="display: block; margin: 0.5rem 0;" id="triggerAttrToast" trigger="triggerAttrBtn" disableAutoHide>
322
+ Flight booked successfully
323
+ </auro-toast>
324
+ <p>Use the <code>triggerElement</code> property to pass a direct reference to the element that opened the toast. Useful when an <code>id</code> is not available or when working programmatically.</p>
325
+ <auro-button id="triggerPropBtn">
326
+ Show notification
327
+ </auro-button>
328
+ <auro-toast style="display: block; margin: 0.5rem 0;" id="triggerPropToast" disableAutoHide>
329
+ Flight booked successfully.
330
+ </auro-toast>
331
+ <p>When both <code>trigger</code> and <code>triggerElement</code> are set, <code>trigger</code> takes precedence. In this example, <code>triggerElement</code> points to the second button but <code>trigger</code> points to the first — focus returns to the first button on close.</p>
332
+ <auro-button id="triggerPrecedenceBtn1">
333
+ Button 1 (trigger attribute target)
334
+ </auro-button>
335
+ <auro-button id="triggerPrecedenceBtn2">
336
+ Button 2 (triggerElement target — ignored)
337
+ </auro-button>
338
+ <auro-toast style="display: block; margin: 0.5rem 0;" id="triggerPrecedenceToast" trigger="triggerPrecedenceBtn1" disableAutoHide>
339
+ Flight booked successfully.
340
+ </auro-toast>
341
+ <!-- AURO-GENERATED-CONTENT:END -->
342
+ </div>
343
+ <auro-accordion alignRight>
344
+ <span slot="trigger">See code</span>
345
+ <!-- AURO-GENERATED-CONTENT:START (CODE:src=./../apiExamples/trigger.html) -->
346
+ <!-- The below code snippet is automatically added from ./../apiExamples/trigger.html -->
347
+
348
+ ```html
349
+ <p>Use the <code>trigger</code> attribute to pass the <code>id</code> of the element that opened the toast. When the toast is manually closed, focus will return to that element.</p>
350
+ <auro-button id="triggerAttrBtn">
351
+ Show notification
352
+ </auro-button>
353
+ <!--
354
+ NOTE: The manually added style is NOT necessary for use,
355
+ Demo purposes ONLY!
356
+ -->
357
+ <auro-toast style="display: block; margin: 0.5rem 0;" id="triggerAttrToast" trigger="triggerAttrBtn" disableAutoHide>
358
+ Flight booked successfully
359
+ </auro-toast>
360
+ <p>Use the <code>triggerElement</code> property to pass a direct reference to the element that opened the toast. Useful when an <code>id</code> is not available or when working programmatically.</p>
361
+ <auro-button id="triggerPropBtn">
362
+ Show notification
363
+ </auro-button>
364
+ <auro-toast style="display: block; margin: 0.5rem 0;" id="triggerPropToast" disableAutoHide>
365
+ Flight booked successfully.
366
+ </auro-toast>
367
+ <p>When both <code>trigger</code> and <code>triggerElement</code> are set, <code>trigger</code> takes precedence. In this example, <code>triggerElement</code> points to the second button but <code>trigger</code> points to the first — focus returns to the first button on close.</p>
368
+ <auro-button id="triggerPrecedenceBtn1">
369
+ Button 1 (trigger attribute target)
370
+ </auro-button>
371
+ <auro-button id="triggerPrecedenceBtn2">
372
+ Button 2 (triggerElement target — ignored)
373
+ </auro-button>
374
+ <auro-toast style="display: block; margin: 0.5rem 0;" id="triggerPrecedenceToast" trigger="triggerPrecedenceBtn1" disableAutoHide>
375
+ Flight booked successfully.
376
+ </auro-toast>
377
+ ```
378
+ <!-- AURO-GENERATED-CONTENT:END -->
379
+ <!-- AURO-GENERATED-CONTENT:START (CODE:src=./../apiExamples/trigger.js) -->
380
+ <!-- The below code snippet is automatically added from ./../apiExamples/trigger.js -->
381
+
382
+ ```js
383
+ /* eslint-disable jsdoc/require-jsdoc */
384
+
385
+ export function initTriggerExample() {
386
+ // trigger attribute — pass element id as a string
387
+ const attrBtn = document.querySelector("#triggerAttrBtn");
388
+ const attrToast = document.querySelector("#triggerAttrToast");
389
+
390
+ attrBtn.addEventListener("click", () => {
391
+ if (!attrToast.hasAttribute("visible")) {
392
+ attrToast.setAttribute("visible", true);
393
+ }
394
+ });
395
+
396
+ // triggerElement property — pass a direct element reference
397
+ const propBtn = document.querySelector("#triggerPropBtn");
398
+ const propToast = document.querySelector("#triggerPropToast");
399
+
400
+ propBtn.addEventListener("click", () => {
401
+ if (!propToast.hasAttribute("visible")) {
402
+ propToast.triggerElement = propBtn;
403
+ propToast.setAttribute("visible", true);
404
+ }
405
+ });
406
+
407
+ // precedence — trigger attribute wins over triggerElement when both are set
408
+ const precedenceBtn1 = document.querySelector("#triggerPrecedenceBtn1");
409
+ const precedenceBtn2 = document.querySelector("#triggerPrecedenceBtn2");
410
+ const precedenceToast = document.querySelector("#triggerPrecedenceToast");
411
+
412
+ precedenceBtn1.addEventListener("click", () => {
413
+ if (!precedenceToast.hasAttribute("visible")) {
414
+ precedenceToast.triggerElement = precedenceBtn2;
415
+ precedenceToast.setAttribute("visible", true);
416
+ }
417
+ });
418
+
419
+ precedenceBtn2.addEventListener("click", () => {
420
+ if (!precedenceToast.hasAttribute("visible")) {
421
+ precedenceToast.triggerElement = precedenceBtn2;
422
+ precedenceToast.setAttribute("visible", true);
423
+ }
424
+ });
425
+ }
426
+ ```
427
+ <!-- AURO-GENERATED-CONTENT:END -->
428
+ </auro-accordion>
429
+
296
430
  ## Common Usage Patterns & Functional Examples
297
431
 
298
432
  ### Multiple Toasts
@@ -306,9 +440,9 @@ The multi-notification use case requires the use of the `<auro-toaster>` compone
306
440
  <auro-button id="multiToastBtn-error">Show error toast</auro-button>
307
441
  <auro-button id="multiToastBtn-success">Show success toast</auro-button>
308
442
  <auro-toaster>
309
- <auro-toast id="multiToast-default">Default toast</auro-toast>
310
- <auro-toast id="multiToast-error" variant="error">Unable to add lap infant. Please try again</auro-toast>
311
- <auro-toast id="multiToast-success" variant="success">Successfully added lap infant</auro-toast>
443
+ <auro-toast id="multiToast-default">Default toast.</auro-toast>
444
+ <auro-toast id="multiToast-error" variant="error">Unable to add lap infant. Please try again.</auro-toast>
445
+ <auro-toast id="multiToast-success" variant="success">Successfully added lap infant.</auro-toast>
312
446
  </auro-toaster>
313
447
  <!-- AURO-GENERATED-CONTENT:END -->
314
448
  </div>
@@ -322,9 +456,9 @@ The multi-notification use case requires the use of the `<auro-toaster>` compone
322
456
  <auro-button id="multiToastBtn-error">Show error toast</auro-button>
323
457
  <auro-button id="multiToastBtn-success">Show success toast</auro-button>
324
458
  <auro-toaster>
325
- <auro-toast id="multiToast-default">Default toast</auro-toast>
326
- <auro-toast id="multiToast-error" variant="error">Unable to add lap infant. Please try again</auro-toast>
327
- <auro-toast id="multiToast-success" variant="success">Successfully added lap infant</auro-toast>
459
+ <auro-toast id="multiToast-default">Default toast.</auro-toast>
460
+ <auro-toast id="multiToast-error" variant="error">Unable to add lap infant. Please try again.</auro-toast>
461
+ <auro-toast id="multiToast-success" variant="success">Successfully added lap infant.</auro-toast>
328
462
  </auro-toaster>
329
463
  ```
330
464
  <!-- AURO-GENERATED-CONTENT:END -->
@@ -364,9 +498,9 @@ The dynamic notification use case requires the use of the `<auro-toaster>` compo
364
498
  /* eslint-disable jsdoc/require-jsdoc */
365
499
 
366
500
  const toastDefs = [
367
- { id: "dynamicToast-default", variant: null, message: "Default toast", btnId: "dynamicToastBtn-default" },
368
- { id: "dynamicToast-error", variant: "error", message: "Unable to add lap infant. Please try again", btnId: "dynamicToastBtn-error" },
369
- { id: "dynamicToast-success", variant: "success", message: "Successfully added lap infant", btnId: "dynamicToastBtn-success" },
501
+ { id: "dynamicToast-default", variant: null, message: "Default toast.", btnId: "dynamicToastBtn-default" },
502
+ { id: "dynamicToast-error", variant: "error", message: "Unable to add lap infant. Please try again.", btnId: "dynamicToastBtn-error" },
503
+ { id: "dynamicToast-success", variant: "success", message: "Successfully added lap infant.", btnId: "dynamicToastBtn-success" },
370
504
  ];
371
505
 
372
506
  export function initDynamicToastsExample() {
@@ -390,6 +524,56 @@ export function initDynamicToastsExample() {
390
524
  <!-- AURO-GENERATED-CONTENT:END -->
391
525
  </auro-accordion>
392
526
 
527
+ ### Dynamic Injection of Standalone Toasts without auro-toaster
528
+
529
+ When dynamically injecting `auro-toast` elements at runtime, the consumer is responsible for a container element with `aria-live` that **must already be present in the DOM** before any toast is appended to it. Screen readers register a live region when it first encounters the element on the page — content added to it later will trigger an announcement. If a live region and toast content enter the DOM at the same time, the screen reader has no opportunity to register the region first and will **not** announce the content.
530
+
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
+
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
+
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
+
537
+ \* Only use `aria-live="assertive"` if your UI is making use of toasts that are alerting the user of important information. If you are not using `auro-toaster` you are responsible for managing the changes between `assertive` and `polite` announcement states.
538
+
539
+ <div class="exampleWrapper">
540
+ <!-- AURO-GENERATED-CONTENT:START (FILE:src=./../apiExamples/standalone-toast.html) -->
541
+ <!-- The below content is automatically added from ./../apiExamples/standalone-toast.html -->
542
+ <auro-button id="standaloneToastBtn">Show toast</auro-button>
543
+ <div id="standaloneContainer" aria-live="polite" aria-atomic="false"></div>
544
+ <!-- AURO-GENERATED-CONTENT:END -->
545
+ </div>
546
+ <auro-accordion alignRight>
547
+ <span slot="trigger">See code</span>
548
+ <!-- AURO-GENERATED-CONTENT:START (CODE:src=./../apiExamples/standalone-toast.html) -->
549
+ <!-- The below code snippet is automatically added from ./../apiExamples/standalone-toast.html -->
550
+
551
+ ```html
552
+ <auro-button id="standaloneToastBtn">Show toast</auro-button>
553
+ <div id="standaloneContainer" aria-live="polite" aria-atomic="false"></div>
554
+ ```
555
+ <!-- AURO-GENERATED-CONTENT:END -->
556
+ <!-- AURO-GENERATED-CONTENT:START (CODE:src=./../apiExamples/standalone-toast.js) -->
557
+ <!-- The below code snippet is automatically added from ./../apiExamples/standalone-toast.js -->
558
+
559
+ ```js
560
+ /* eslint-disable jsdoc/require-jsdoc */
561
+
562
+ export function initStandaloneToastExample() {
563
+ const container = document.querySelector("#standaloneContainer");
564
+
565
+ document.querySelector("#standaloneToastBtn").addEventListener("click", () => {
566
+ const toast = document.createElement("auro-toast");
567
+ toast.setAttribute("visible", "");
568
+ toast.setAttribute("variant", "success");
569
+ toast.textContent = "Successfully added lap infant";
570
+ container.appendChild(toast);
571
+ });
572
+ }
573
+ ```
574
+ <!-- AURO-GENERATED-CONTENT:END -->
575
+ </auro-accordion>
576
+
393
577
  ## Restyle Component with CSS Variables
394
578
 
395
579
  The component may be restyled by changing the values of the following token(s).
package/demo/api.min.js CHANGED
@@ -104,6 +104,7 @@ function initMultipleToastsExample() {
104
104
 
105
105
  btn.addEventListener("click", () => {
106
106
  if (!toast.hasAttribute("visible")) {
107
+ toast.triggerElement = btn;
107
108
  toast.setAttribute("visible", true);
108
109
  }
109
110
  });
@@ -113,6 +114,7 @@ function initMultipleToastsExample() {
113
114
 
114
115
  btnTwo.addEventListener("click", () => {
115
116
  if (!toastTwo.hasAttribute("visible")) {
117
+ toastTwo.triggerElement = btnTwo;
116
118
  toastTwo.setAttribute("visible", true);
117
119
  }
118
120
  });
@@ -122,6 +124,7 @@ function initMultipleToastsExample() {
122
124
 
123
125
  btnThree.addEventListener("click", () => {
124
126
  if (!toastThree.hasAttribute("visible")) {
127
+ toastThree.triggerElement = btnThree;
125
128
  toastThree.setAttribute("visible", true);
126
129
  }
127
130
  });
@@ -130,9 +133,9 @@ function initMultipleToastsExample() {
130
133
  /* eslint-disable jsdoc/require-jsdoc */
131
134
 
132
135
  const toastDefs = [
133
- { id: "dynamicToast-default", variant: null, message: "Default toast", btnId: "dynamicToastBtn-default" },
134
- { id: "dynamicToast-error", variant: "error", message: "Unable to add lap infant. Please try again", btnId: "dynamicToastBtn-error" },
135
- { id: "dynamicToast-success", variant: "success", message: "Successfully added lap infant", btnId: "dynamicToastBtn-success" },
136
+ { id: "dynamicToast-default", variant: null, message: "Default toast.", btnId: "dynamicToastBtn-default" },
137
+ { id: "dynamicToast-error", variant: "error", message: "Unable to add lap infant. Please try again.", btnId: "dynamicToastBtn-error" },
138
+ { id: "dynamicToast-success", variant: "success", message: "Successfully added lap infant.", btnId: "dynamicToastBtn-success" },
136
139
  ];
137
140
 
138
141
  function initDynamicToastsExample() {
@@ -153,6 +156,64 @@ function initDynamicToastsExample() {
153
156
  });
154
157
  }
155
158
 
159
+ /* eslint-disable jsdoc/require-jsdoc */
160
+
161
+ function initStandaloneToastExample() {
162
+ const container = document.querySelector("#standaloneContainer");
163
+
164
+ document.querySelector("#standaloneToastBtn").addEventListener("click", () => {
165
+ const toast = document.createElement("auro-toast");
166
+ toast.setAttribute("visible", "");
167
+ toast.setAttribute("variant", "success");
168
+ toast.textContent = "Successfully added lap infant";
169
+ container.appendChild(toast);
170
+ });
171
+ }
172
+
173
+ /* eslint-disable jsdoc/require-jsdoc */
174
+
175
+ function initTriggerExample() {
176
+ // trigger attribute — pass element id as a string
177
+ const attrBtn = document.querySelector("#triggerAttrBtn");
178
+ const attrToast = document.querySelector("#triggerAttrToast");
179
+
180
+ attrBtn.addEventListener("click", () => {
181
+ if (!attrToast.hasAttribute("visible")) {
182
+ attrToast.setAttribute("visible", true);
183
+ }
184
+ });
185
+
186
+ // triggerElement property — pass a direct element reference
187
+ const propBtn = document.querySelector("#triggerPropBtn");
188
+ const propToast = document.querySelector("#triggerPropToast");
189
+
190
+ propBtn.addEventListener("click", () => {
191
+ if (!propToast.hasAttribute("visible")) {
192
+ propToast.triggerElement = propBtn;
193
+ propToast.setAttribute("visible", true);
194
+ }
195
+ });
196
+
197
+ // precedence — trigger attribute wins over triggerElement when both are set
198
+ const precedenceBtn1 = document.querySelector("#triggerPrecedenceBtn1");
199
+ const precedenceBtn2 = document.querySelector("#triggerPrecedenceBtn2");
200
+ const precedenceToast = document.querySelector("#triggerPrecedenceToast");
201
+
202
+ precedenceBtn1.addEventListener("click", () => {
203
+ if (!precedenceToast.hasAttribute("visible")) {
204
+ precedenceToast.triggerElement = precedenceBtn2;
205
+ precedenceToast.setAttribute("visible", true);
206
+ }
207
+ });
208
+
209
+ precedenceBtn2.addEventListener("click", () => {
210
+ if (!precedenceToast.hasAttribute("visible")) {
211
+ precedenceToast.triggerElement = precedenceBtn2;
212
+ precedenceToast.setAttribute("visible", true);
213
+ }
214
+ });
215
+ }
216
+
156
217
  AuroToast.register();
157
218
  AuroToaster.register();
158
219
 
@@ -173,6 +234,8 @@ function initExamples(initCount) {
173
234
  initVisibleExample();
174
235
  initMultipleToastsExample();
175
236
  initDynamicToastsExample();
237
+ initStandaloneToastExample();
238
+ initTriggerExample();
176
239
  } catch (_err) {
177
240
  if (initCount <= 20) {
178
241
  // setTimeout handles issue where content is sometimes loaded after the functions get called