@supersoniks/concorde 3.1.98 → 3.1.99

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supersoniks/concorde",
3
- "version": "3.1.98",
3
+ "version": "3.1.99",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "",
@@ -8,7 +8,10 @@ import { ifDefined } from "lit/directives/if-defined.js";
8
8
  import { unsafeHTML } from "lit/directives/unsafe-html.js";
9
9
  import { styleMap, StyleInfo } from "lit/directives/style-map.js";
10
10
  import "@supersoniks/concorde/core/components/ui/toast/toast-item";
11
- import { Toast } from "@supersoniks/concorde/core/components/ui/toast/types";
11
+ import {
12
+ Toast,
13
+ ToastStatus,
14
+ } from "@supersoniks/concorde/core/components/ui/toast/types";
12
15
  import { ConcordeWindow } from "@supersoniks/concorde/core/_types/types";
13
16
  import { Theme } from "@supersoniks/concorde/core/components/ui/theme/theme";
14
17
  import { sonicClassPrefix } from "@supersoniks/concorde/core/utils/Utils";
@@ -110,6 +113,36 @@ export class SonicToast extends LitElement {
110
113
  toastComponent.toasts = toastComponent.toasts.filter((item) => item.ghost);
111
114
  }
112
115
 
116
+ static removeItemsByStatus(status: ToastStatus) {
117
+ if (SonicToast.delegateToasts) {
118
+ SonicToast.handleExistingToastDelegation();
119
+ window.parent.postMessage({ type: "removeItemsByStatus", status }, "*");
120
+ return;
121
+ }
122
+ const toastComponent: SonicToast = SonicToast.getInstance();
123
+ if (!toastComponent) return;
124
+
125
+ // Filtrer pour garder seulement les toasts qui ne correspondent pas au statut donné
126
+ toastComponent.toasts = toastComponent.toasts.filter(
127
+ (toast) => toast.status !== status
128
+ );
129
+ }
130
+
131
+ // retire les items qui ne sont pas en preserve
132
+ static removeTemporaryItems() {
133
+ if (SonicToast.delegateToasts) {
134
+ SonicToast.handleExistingToastDelegation();
135
+ window.parent.postMessage({ type: "removeTemporaryItems" }, "*");
136
+ return;
137
+ }
138
+ const toastComponent: SonicToast = SonicToast.getInstance();
139
+ if (!toastComponent) return;
140
+
141
+ toastComponent.toasts = toastComponent.toasts.filter(
142
+ (item) => item.preserve
143
+ );
144
+ }
145
+
113
146
  // ADD TOAST
114
147
  static instance?: SonicToast;
115
148
  static getInstance() {
@@ -219,6 +252,15 @@ function handleIframeContexts() {
219
252
  if (e.data.type == "querySonicToastAvailability") {
220
253
  (e.source as Window).postMessage({ type: "sonicToastAvailable" }, "*");
221
254
  }
255
+
256
+ if (e.data.type == "removeItemsByStatus") {
257
+ SonicToast.removeItemsByStatus(e.data.status);
258
+ }
259
+
260
+ if (e.data.type == "removeTemporaryItems") {
261
+ SonicToast.removeTemporaryItems();
262
+ }
263
+
222
264
  if (e.data.type == "sonicToastAvailable") {
223
265
  SonicToast.delegateToasts = true;
224
266
  SonicToast.handleExistingToastDelegation();