@canonical/react-components 2.12.0 → 2.13.0
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/dist/components/Notifications/ToastNotification/ToastNotificationList.js +1 -1
- package/dist/components/Notifications/ToastNotification/ToastNotificationProvider.d.ts +4 -1
- package/dist/components/Notifications/ToastNotification/ToastNotificationProvider.js +5 -1
- package/dist/esm/components/Notifications/ToastNotification/ToastNotificationList.js +1 -1
- package/dist/esm/components/Notifications/ToastNotification/ToastNotificationProvider.d.ts +4 -1
- package/dist/esm/components/Notifications/ToastNotification/ToastNotificationProvider.js +5 -1
- package/package.json +1 -1
|
@@ -6,6 +6,9 @@ export type ToastNotificationType = NotificationType & {
|
|
|
6
6
|
timestamp?: ReactNode;
|
|
7
7
|
id: string;
|
|
8
8
|
};
|
|
9
|
+
interface Props {
|
|
10
|
+
onDismiss?: (notifications?: ToastNotificationType[]) => void;
|
|
11
|
+
}
|
|
9
12
|
interface ToastNotificationHelper {
|
|
10
13
|
notifications: ToastNotificationType[];
|
|
11
14
|
success: (message: ReactNode, actions?: NotificationAction[], title?: string) => ToastNotificationType;
|
|
@@ -81,6 +84,6 @@ console.log(count.positive);
|
|
|
81
84
|
|
|
82
85
|
Alternatively, you can use the `ToastNotification` and `ToastNotificationList` components directly, without using the provider.
|
|
83
86
|
*/
|
|
84
|
-
declare const ToastNotificationProvider: FC<PropsWithChildren
|
|
87
|
+
declare const ToastNotificationProvider: FC<PropsWithChildren<Props>>;
|
|
85
88
|
export default ToastNotificationProvider;
|
|
86
89
|
export declare const useToastNotification: () => ToastNotificationHelper;
|
|
@@ -103,7 +103,8 @@ Alternatively, you can use the `ToastNotification` and `ToastNotificationList` c
|
|
|
103
103
|
|
|
104
104
|
const ToastNotificationProvider = _ref => {
|
|
105
105
|
let {
|
|
106
|
-
children
|
|
106
|
+
children,
|
|
107
|
+
onDismiss
|
|
107
108
|
} = _ref;
|
|
108
109
|
const [notifications, setNotifications] = (0, _react.useState)([]);
|
|
109
110
|
const [showList, setShowList] = (0, _react.useState)(false);
|
|
@@ -152,6 +153,9 @@ const ToastNotificationProvider = _ref => {
|
|
|
152
153
|
return notificationToAdd;
|
|
153
154
|
};
|
|
154
155
|
const clear = notifications => {
|
|
156
|
+
if (onDismiss) {
|
|
157
|
+
onDismiss(notifications);
|
|
158
|
+
}
|
|
155
159
|
if (!notifications) {
|
|
156
160
|
setNotifications([]);
|
|
157
161
|
setShowList(false);
|
|
@@ -6,6 +6,9 @@ export type ToastNotificationType = NotificationType & {
|
|
|
6
6
|
timestamp?: ReactNode;
|
|
7
7
|
id: string;
|
|
8
8
|
};
|
|
9
|
+
interface Props {
|
|
10
|
+
onDismiss?: (notifications?: ToastNotificationType[]) => void;
|
|
11
|
+
}
|
|
9
12
|
interface ToastNotificationHelper {
|
|
10
13
|
notifications: ToastNotificationType[];
|
|
11
14
|
success: (message: ReactNode, actions?: NotificationAction[], title?: string) => ToastNotificationType;
|
|
@@ -81,6 +84,6 @@ console.log(count.positive);
|
|
|
81
84
|
|
|
82
85
|
Alternatively, you can use the `ToastNotification` and `ToastNotificationList` components directly, without using the provider.
|
|
83
86
|
*/
|
|
84
|
-
declare const ToastNotificationProvider: FC<PropsWithChildren
|
|
87
|
+
declare const ToastNotificationProvider: FC<PropsWithChildren<Props>>;
|
|
85
88
|
export default ToastNotificationProvider;
|
|
86
89
|
export declare const useToastNotification: () => ToastNotificationHelper;
|
|
@@ -100,7 +100,8 @@ Alternatively, you can use the `ToastNotification` and `ToastNotificationList` c
|
|
|
100
100
|
|
|
101
101
|
var ToastNotificationProvider = _ref => {
|
|
102
102
|
var {
|
|
103
|
-
children
|
|
103
|
+
children,
|
|
104
|
+
onDismiss
|
|
104
105
|
} = _ref;
|
|
105
106
|
var [notifications, setNotifications] = useState([]);
|
|
106
107
|
var [showList, setShowList] = useState(false);
|
|
@@ -148,6 +149,9 @@ var ToastNotificationProvider = _ref => {
|
|
|
148
149
|
return notificationToAdd;
|
|
149
150
|
};
|
|
150
151
|
var clear = notifications => {
|
|
152
|
+
if (onDismiss) {
|
|
153
|
+
onDismiss(notifications);
|
|
154
|
+
}
|
|
151
155
|
if (!notifications) {
|
|
152
156
|
setNotifications([]);
|
|
153
157
|
setShowList(false);
|