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

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/demo/api.md CHANGED
@@ -503,20 +503,42 @@ const toastDefs = [
503
503
  { id: "dynamicToast-success", variant: "success", message: "Successfully added lap infant.", btnId: "dynamicToastBtn-success" },
504
504
  ];
505
505
 
506
+ // simple in-memory registry of active toasts
507
+ const activeToasts = new Map();
508
+
509
+ function generateToastId(baseId) {
510
+ return `${baseId}-${crypto.randomUUID()}`;
511
+ }
512
+
506
513
  export function initDynamicToastsExample() {
507
514
  const toaster = document.querySelector("#dynamicToaster");
508
515
 
509
- toastDefs.forEach(({ id, variant, message, btnId }) => {
516
+ toastDefs.forEach(({ id: baseId, variant, message, btnId }) => {
510
517
  document.querySelector(`#${btnId}`).addEventListener("click", () => {
511
518
  const toast = document.createElement("auro-toast");
512
- toast.id = id;
519
+
520
+ const toastId = generateToastId(baseId);
521
+
522
+ toast.id = toastId;
523
+
513
524
  if (variant) {
514
525
  toast.setAttribute("variant", variant);
515
526
  }
527
+
516
528
  toast.setAttribute("visible", true);
517
529
  toast.textContent = message;
530
+
518
531
  toaster.appendChild(toast);
519
- console.log("Toast added:", toast); // eslint-disable-line no-console
532
+
533
+ // 👇 now the ID is actually used meaningfully
534
+ activeToasts.set(toastId, toast);
535
+
536
+ console.log("Toast added:", toastId);
537
+
538
+ // optional cleanup if your component doesn't auto-remove itself
539
+ toast.addEventListener("onToastClose", () => {
540
+ activeToasts.delete(toastId);
541
+ });
520
542
  });
521
543
  });
522
544
  }
package/demo/api.min.js CHANGED
@@ -138,20 +138,42 @@ const toastDefs = [
138
138
  { id: "dynamicToast-success", variant: "success", message: "Successfully added lap infant.", btnId: "dynamicToastBtn-success" },
139
139
  ];
140
140
 
141
+ // simple in-memory registry of active toasts
142
+ const activeToasts = new Map();
143
+
144
+ function generateToastId(baseId) {
145
+ return `${baseId}-${crypto.randomUUID()}`;
146
+ }
147
+
141
148
  function initDynamicToastsExample() {
142
149
  const toaster = document.querySelector("#dynamicToaster");
143
150
 
144
- toastDefs.forEach(({ id, variant, message, btnId }) => {
151
+ toastDefs.forEach(({ id: baseId, variant, message, btnId }) => {
145
152
  document.querySelector(`#${btnId}`).addEventListener("click", () => {
146
153
  const toast = document.createElement("auro-toast");
147
- toast.id = id;
154
+
155
+ const toastId = generateToastId(baseId);
156
+
157
+ toast.id = toastId;
158
+
148
159
  if (variant) {
149
160
  toast.setAttribute("variant", variant);
150
161
  }
162
+
151
163
  toast.setAttribute("visible", true);
152
164
  toast.textContent = message;
165
+
153
166
  toaster.appendChild(toast);
154
- console.log("Toast added:", toast); // eslint-disable-line no-console
167
+
168
+ // 👇 now the ID is actually used meaningfully
169
+ activeToasts.set(toastId, toast);
170
+
171
+ console.log("Toast added:", toastId);
172
+
173
+ // optional cleanup if your component doesn't auto-remove itself
174
+ toast.addEventListener("onToastClose", () => {
175
+ activeToasts.delete(toastId);
176
+ });
155
177
  });
156
178
  });
157
179
  }
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.20",
10
+ "version": "0.0.0-pr121.22",
11
11
  "description": "auro-toast HTML custom element",
12
12
  "repository": {
13
13
  "type": "git",