@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.
@@ -80,7 +80,7 @@ const ToastNotificationList = _ref => {
80
80
  setFilters(new Set());
81
81
  return;
82
82
  }
83
- onDismiss();
83
+ onDismiss(notifications);
84
84
  };
85
85
  const getSeverityFilters = () => {
86
86
  const filterButtons = severityOrder.map(severity => {
@@ -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);
@@ -73,7 +73,7 @@ var ToastNotificationList = _ref => {
73
73
  setFilters(new Set());
74
74
  return;
75
75
  }
76
- onDismiss();
76
+ onDismiss(notifications);
77
77
  };
78
78
  var getSeverityFilters = () => {
79
79
  var filterButtons = severityOrder.map(severity => {
@@ -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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canonical/react-components",
3
- "version": "2.12.0",
3
+ "version": "2.13.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "author": {