@unitedstatespowersquadrons/components 1.4.0-1 → 1.4.0-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/Toasts/GlobalToasts.tsx
CHANGED
|
@@ -14,7 +14,7 @@ interface BroadcastPayload {
|
|
|
14
14
|
dismissToast?: number;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
const sortBroadcastsFirst = (toasts:
|
|
17
|
+
const sortBroadcastsFirst = (toasts: readonly ToastProps[]): ToastProps[] => (
|
|
18
18
|
[...toasts].sort((a, b) => (
|
|
19
19
|
Number(b.kind === "broadcast") - Number(a.kind === "broadcast")
|
|
20
20
|
))
|
|
@@ -48,13 +48,11 @@ const GlobalToasts = ({ allowedDomains }: Props) => {
|
|
|
48
48
|
};
|
|
49
49
|
}, []);
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
/>
|
|
57
|
-
);
|
|
51
|
+
const sorted = sortBroadcastsFirst(toasts);
|
|
52
|
+
|
|
53
|
+
return allowedDomains
|
|
54
|
+
? <Toasts allowedDomains={allowedDomains} dismiss={dismissToastGlobal} toasts={sorted} />
|
|
55
|
+
: <Toasts dismiss={dismissToastGlobal} toasts={sorted} />;
|
|
58
56
|
};
|
|
59
57
|
|
|
60
58
|
export default GlobalToasts;
|
package/Toasts/Toast.tsx
CHANGED
|
@@ -155,7 +155,10 @@ const Toast = (props: Props) => {
|
|
|
155
155
|
const opacityClass = dismissed ? classes.dismissed : classes.visible;
|
|
156
156
|
|
|
157
157
|
return (
|
|
158
|
-
<div
|
|
158
|
+
<div
|
|
159
|
+
className={classNames(classes.toast, statusClassName, opacityClass, isBroadcast && classes.broadcast)}
|
|
160
|
+
key={`toast-${id}`}
|
|
161
|
+
>
|
|
159
162
|
<div className={classes.toastTitle}>
|
|
160
163
|
<FontAwesomeIcon fa="fw" icon={icon} mode="duotone" />
|
|
161
164
|
{isBroadcast && <span className={classes.broadcastTag}>Broadcast</span>}
|
package/Toasts/globalStore.ts
CHANGED
|
@@ -81,6 +81,6 @@ const subscribe = (listener: Listener): (() => void) => {
|
|
|
81
81
|
return () => { listeners.delete(listener); };
|
|
82
82
|
};
|
|
83
83
|
|
|
84
|
-
const getSnapshot = ():
|
|
84
|
+
const getSnapshot = (): readonly ToastProps[] => toasts;
|
|
85
85
|
|
|
86
86
|
export const toastStore = { add, clear, dismiss, getSnapshot, remove, subscribe };
|
|
@@ -8,6 +8,7 @@ export const useBroadcastChannel = (): BroadcastChannelHandle => ({
|
|
|
8
8
|
send: (data: object) => {
|
|
9
9
|
const sub = broadcastSubscriptionRef.current;
|
|
10
10
|
if (!sub) {
|
|
11
|
+
// eslint-disable-next-line no-console
|
|
11
12
|
console.warn("useBroadcastChannel: <GlobalToasts /> is not mounted; broadcast send ignored");
|
|
12
13
|
return;
|
|
13
14
|
}
|