@snack-uikit/toaster 0.6.13-preview-c70fa919.0 → 0.6.13
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/CHANGELOG.md +12 -0
- package/dist/components/ToastSystemEvent/ToastSystemEvent.d.ts +0 -2
- package/dist/components/ToastUserAction/ToastUserAction.d.ts +0 -2
- package/dist/helpers.js +10 -1
- package/dist/types.d.ts +2 -2
- package/package.json +2 -2
- package/src/components/ToastSystemEvent/ToastSystemEvent.tsx +0 -2
- package/src/components/ToastUserAction/ToastUserAction.tsx +0 -2
- package/src/helpers.tsx +10 -1
- package/src/types.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 0.6.13 (2024-04-27)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **FF-4851:** add missing toastOptions ([e1b6b2b](https://github.com/cloud-ru-tech/snack-uikit/commit/e1b6b2bd8c49da4fc36c80f4b65a65dd0c4258de))
|
|
12
|
+
* **FF-4851:** add missing toastOptions, fix typings ([cd70ebb](https://github.com/cloud-ru-tech/snack-uikit/commit/cd70ebb4d3fd2d8ec46fa3917ee079e7a5190273))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
6
18
|
## 0.6.12 (2024-04-25)
|
|
7
19
|
|
|
8
20
|
|
|
@@ -2,7 +2,6 @@ import { MouseEvent } from 'react';
|
|
|
2
2
|
import { ToastContentProps as RtToastContentProps } from 'react-toastify';
|
|
3
3
|
import { WithSupportProps } from '@snack-uikit/utils';
|
|
4
4
|
import { ButtonActionProps } from '../../helperComponents/ButtonAction';
|
|
5
|
-
import { ToasterId } from '../../types';
|
|
6
5
|
import { ToastSystemEventAppearance } from './types';
|
|
7
6
|
export type ToastSystemEventLink = {
|
|
8
7
|
text: string;
|
|
@@ -18,7 +17,6 @@ export type ToastSystemEventProps = Partial<RtToastContentProps> & WithSupportPr
|
|
|
18
17
|
closable?: boolean;
|
|
19
18
|
className?: string;
|
|
20
19
|
onCloseClick?(e: MouseEvent<HTMLButtonElement>, close?: () => void): void;
|
|
21
|
-
onClose?(id?: ToasterId): void;
|
|
22
20
|
action?: ButtonActionProps[];
|
|
23
21
|
loading?: never;
|
|
24
22
|
}>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { MouseEvent } from 'react';
|
|
2
2
|
import { ToastContentProps as RtToastContentProps } from 'react-toastify';
|
|
3
3
|
import { WithSupportProps } from '@snack-uikit/utils';
|
|
4
|
-
import { ToasterId } from '../../types';
|
|
5
4
|
import { ToastUserActionAppearance } from './types';
|
|
6
5
|
export type ToastUserActionLink = {
|
|
7
6
|
text: string;
|
|
@@ -14,6 +13,5 @@ export type ToastUserActionProps = Partial<RtToastContentProps> & WithSupportPro
|
|
|
14
13
|
link?: ToastUserActionLink;
|
|
15
14
|
className?: string;
|
|
16
15
|
loading?: boolean;
|
|
17
|
-
onClose?(id?: ToasterId): void;
|
|
18
16
|
}>;
|
|
19
17
|
export declare function ToastUserAction({ appearance, label, link, className, loading, ...rest }: ToastUserActionProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/helpers.js
CHANGED
|
@@ -24,7 +24,7 @@ function getToastOptions({ type, toastOptions, containerId, toasterProps, }) {
|
|
|
24
24
|
toastId: toastOptions === null || toastOptions === void 0 ? void 0 : toastOptions.id,
|
|
25
25
|
onClose: ((data) => {
|
|
26
26
|
var _a;
|
|
27
|
-
(_a =
|
|
27
|
+
(_a = toastOptions === null || toastOptions === void 0 ? void 0 : toastOptions.onClose) === null || _a === void 0 ? void 0 : _a.call(toastOptions, data === null || data === void 0 ? void 0 : data.id);
|
|
28
28
|
}),
|
|
29
29
|
autoClose: (toasterProps === null || toasterProps === void 0 ? void 0 : toasterProps.loading) ? false : AUTO_CLOSE_TIME[type],
|
|
30
30
|
containerId: containerId || `${TOASTER_CONTAINER_PREFIX}${type}`,
|
|
@@ -81,6 +81,7 @@ const userAction = {
|
|
|
81
81
|
toasterProps: Object.assign(Object.assign({}, options), { appearance: 'success' }),
|
|
82
82
|
toastOptions: {
|
|
83
83
|
id: options.id,
|
|
84
|
+
onClose: options.onClose,
|
|
84
85
|
},
|
|
85
86
|
});
|
|
86
87
|
},
|
|
@@ -90,6 +91,7 @@ const userAction = {
|
|
|
90
91
|
toasterProps: Object.assign(Object.assign({}, options), { appearance: 'neutral' }),
|
|
91
92
|
toastOptions: {
|
|
92
93
|
id: options.id,
|
|
94
|
+
onClose: options.onClose,
|
|
93
95
|
},
|
|
94
96
|
});
|
|
95
97
|
},
|
|
@@ -99,6 +101,7 @@ const userAction = {
|
|
|
99
101
|
toasterProps: Object.assign(Object.assign({}, options), { appearance: 'error' }),
|
|
100
102
|
toastOptions: {
|
|
101
103
|
id: options.id,
|
|
104
|
+
onClose: options.onClose,
|
|
102
105
|
},
|
|
103
106
|
});
|
|
104
107
|
},
|
|
@@ -108,6 +111,7 @@ const userAction = {
|
|
|
108
111
|
toasterProps: Object.assign(Object.assign({}, options), { appearance: 'warning' }),
|
|
109
112
|
toastOptions: {
|
|
110
113
|
id: options.id,
|
|
114
|
+
onClose: options.onClose,
|
|
111
115
|
},
|
|
112
116
|
});
|
|
113
117
|
},
|
|
@@ -148,6 +152,7 @@ const systemEvent = {
|
|
|
148
152
|
toasterProps: Object.assign(Object.assign({}, options), { appearance: 'success' }),
|
|
149
153
|
toastOptions: {
|
|
150
154
|
id: options.id,
|
|
155
|
+
onClose: options.onClose,
|
|
151
156
|
},
|
|
152
157
|
});
|
|
153
158
|
},
|
|
@@ -157,6 +162,7 @@ const systemEvent = {
|
|
|
157
162
|
toasterProps: Object.assign(Object.assign({}, options), { appearance: 'neutral' }),
|
|
158
163
|
toastOptions: {
|
|
159
164
|
id: options.id,
|
|
165
|
+
onClose: options.onClose,
|
|
160
166
|
},
|
|
161
167
|
});
|
|
162
168
|
},
|
|
@@ -166,6 +172,7 @@ const systemEvent = {
|
|
|
166
172
|
toasterProps: Object.assign(Object.assign({}, options), { appearance: 'warning' }),
|
|
167
173
|
toastOptions: {
|
|
168
174
|
id: options.id,
|
|
175
|
+
onClose: options.onClose,
|
|
169
176
|
},
|
|
170
177
|
});
|
|
171
178
|
},
|
|
@@ -175,6 +182,7 @@ const systemEvent = {
|
|
|
175
182
|
toasterProps: Object.assign(Object.assign({}, options), { appearance: 'error' }),
|
|
176
183
|
toastOptions: {
|
|
177
184
|
id: options.id,
|
|
185
|
+
onClose: options.onClose,
|
|
178
186
|
},
|
|
179
187
|
});
|
|
180
188
|
},
|
|
@@ -184,6 +192,7 @@ const systemEvent = {
|
|
|
184
192
|
toasterProps: Object.assign(Object.assign({}, options), { appearance: 'errorCritical' }),
|
|
185
193
|
toastOptions: {
|
|
186
194
|
id: options.id,
|
|
195
|
+
onClose: options.onClose,
|
|
187
196
|
},
|
|
188
197
|
});
|
|
189
198
|
},
|
package/dist/types.d.ts
CHANGED
|
@@ -31,8 +31,8 @@ export type UpdateToast = <T extends keyof ToasterPropsMap>(id: string | number,
|
|
|
31
31
|
toastOptions?: ToastOptions;
|
|
32
32
|
containerId?: ToasterContainerProps['containerId'];
|
|
33
33
|
}) => void;
|
|
34
|
-
export type UserActionOptions = Omit<ToastUserActionProps, 'appearance'> & Pick<ToastOptions, 'id'>;
|
|
35
|
-
export type SystemEventOptions = Omit<ToastSystemEventProps, 'appearance'> & Pick<ToastOptions, 'id'>;
|
|
34
|
+
export type UserActionOptions = Omit<ToastUserActionProps, 'appearance'> & Pick<ToastOptions, 'id' | 'onClose'>;
|
|
35
|
+
export type SystemEventOptions = Omit<ToastSystemEventProps, 'appearance'> & Pick<ToastOptions, 'id' | 'onClose'>;
|
|
36
36
|
export type Toaster = {
|
|
37
37
|
userAction: {
|
|
38
38
|
success(options: UserActionOptions): PromisedId;
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Toaster",
|
|
7
|
-
"version": "0.6.13
|
|
7
|
+
"version": "0.6.13",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"classnames": "2.3.2",
|
|
41
41
|
"react-toastify": "10.0.5"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "8db420a0c19e722c15478c3db5b74847a24bf6f7"
|
|
44
44
|
}
|
|
@@ -10,7 +10,6 @@ import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
|
|
|
10
10
|
import { AUTO_CLOSE_TIME, TOASTER_TYPE } from '../../constants';
|
|
11
11
|
import { ButtonAction, ButtonActionProps } from '../../helperComponents/ButtonAction';
|
|
12
12
|
import { TOAST_SYSTEM_EVENT_TEST_IDS } from '../../testIds';
|
|
13
|
-
import { ToasterId } from '../../types';
|
|
14
13
|
import { APPEARANCE_TO_ON_COLOR_MAP } from './constants';
|
|
15
14
|
import styles from './styles.module.scss';
|
|
16
15
|
import { ToastSystemEventAppearance } from './types';
|
|
@@ -32,7 +31,6 @@ export type ToastSystemEventProps = Partial<RtToastContentProps> &
|
|
|
32
31
|
closable?: boolean;
|
|
33
32
|
className?: string;
|
|
34
33
|
onCloseClick?(e: MouseEvent<HTMLButtonElement>, close?: () => void): void;
|
|
35
|
-
onClose?(id?: ToasterId): void;
|
|
36
34
|
action?: ButtonActionProps[];
|
|
37
35
|
loading?: never;
|
|
38
36
|
}>;
|
|
@@ -7,7 +7,6 @@ import { Sun } from '@snack-uikit/loaders';
|
|
|
7
7
|
import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
|
|
8
8
|
|
|
9
9
|
import { TOAST_USER_ACTION_TEST_IDS } from '../../testIds';
|
|
10
|
-
import { ToasterId } from '../../types';
|
|
11
10
|
import styles from './styles.module.scss';
|
|
12
11
|
import { ToastUserActionAppearance } from './types';
|
|
13
12
|
import { getIcon } from './utils';
|
|
@@ -25,7 +24,6 @@ export type ToastUserActionProps = Partial<RtToastContentProps> &
|
|
|
25
24
|
link?: ToastUserActionLink;
|
|
26
25
|
className?: string;
|
|
27
26
|
loading?: boolean;
|
|
28
|
-
onClose?(id?: ToasterId): void;
|
|
29
27
|
}>;
|
|
30
28
|
|
|
31
29
|
export function ToastUserAction({
|
package/src/helpers.tsx
CHANGED
|
@@ -76,7 +76,7 @@ function getToastOptions<T extends keyof ToasterPropsMap>({
|
|
|
76
76
|
return {
|
|
77
77
|
toastId: toastOptions?.id,
|
|
78
78
|
onClose: ((data: { id: ToasterId }) => {
|
|
79
|
-
|
|
79
|
+
toastOptions?.onClose?.(data?.id);
|
|
80
80
|
}) as RtToastOptions['onClose'],
|
|
81
81
|
autoClose: toasterProps?.loading ? false : AUTO_CLOSE_TIME[type],
|
|
82
82
|
containerId: containerId || `${TOASTER_CONTAINER_PREFIX}${type}`,
|
|
@@ -158,6 +158,7 @@ const userAction = {
|
|
|
158
158
|
toasterProps: { ...options, appearance: 'success' },
|
|
159
159
|
toastOptions: {
|
|
160
160
|
id: options.id,
|
|
161
|
+
onClose: options.onClose,
|
|
161
162
|
},
|
|
162
163
|
});
|
|
163
164
|
},
|
|
@@ -168,6 +169,7 @@ const userAction = {
|
|
|
168
169
|
toasterProps: { ...options, appearance: 'neutral' },
|
|
169
170
|
toastOptions: {
|
|
170
171
|
id: options.id,
|
|
172
|
+
onClose: options.onClose,
|
|
171
173
|
},
|
|
172
174
|
});
|
|
173
175
|
},
|
|
@@ -178,6 +180,7 @@ const userAction = {
|
|
|
178
180
|
toasterProps: { ...options, appearance: 'error' },
|
|
179
181
|
toastOptions: {
|
|
180
182
|
id: options.id,
|
|
183
|
+
onClose: options.onClose,
|
|
181
184
|
},
|
|
182
185
|
});
|
|
183
186
|
},
|
|
@@ -188,6 +191,7 @@ const userAction = {
|
|
|
188
191
|
toasterProps: { ...options, appearance: 'warning' },
|
|
189
192
|
toastOptions: {
|
|
190
193
|
id: options.id,
|
|
194
|
+
onClose: options.onClose,
|
|
191
195
|
},
|
|
192
196
|
});
|
|
193
197
|
},
|
|
@@ -234,6 +238,7 @@ const systemEvent = {
|
|
|
234
238
|
toasterProps: { ...options, appearance: 'success' },
|
|
235
239
|
toastOptions: {
|
|
236
240
|
id: options.id,
|
|
241
|
+
onClose: options.onClose,
|
|
237
242
|
},
|
|
238
243
|
});
|
|
239
244
|
},
|
|
@@ -244,6 +249,7 @@ const systemEvent = {
|
|
|
244
249
|
toasterProps: { ...options, appearance: 'neutral' },
|
|
245
250
|
toastOptions: {
|
|
246
251
|
id: options.id,
|
|
252
|
+
onClose: options.onClose,
|
|
247
253
|
},
|
|
248
254
|
});
|
|
249
255
|
},
|
|
@@ -254,6 +260,7 @@ const systemEvent = {
|
|
|
254
260
|
toasterProps: { ...options, appearance: 'warning' },
|
|
255
261
|
toastOptions: {
|
|
256
262
|
id: options.id,
|
|
263
|
+
onClose: options.onClose,
|
|
257
264
|
},
|
|
258
265
|
});
|
|
259
266
|
},
|
|
@@ -264,6 +271,7 @@ const systemEvent = {
|
|
|
264
271
|
toasterProps: { ...options, appearance: 'error' },
|
|
265
272
|
toastOptions: {
|
|
266
273
|
id: options.id,
|
|
274
|
+
onClose: options.onClose,
|
|
267
275
|
},
|
|
268
276
|
});
|
|
269
277
|
},
|
|
@@ -274,6 +282,7 @@ const systemEvent = {
|
|
|
274
282
|
toasterProps: { ...options, appearance: 'errorCritical' },
|
|
275
283
|
toastOptions: {
|
|
276
284
|
id: options.id,
|
|
285
|
+
onClose: options.onClose,
|
|
277
286
|
},
|
|
278
287
|
});
|
|
279
288
|
},
|
package/src/types.ts
CHANGED
|
@@ -47,8 +47,8 @@ export type UpdateToast = <T extends keyof ToasterPropsMap>(
|
|
|
47
47
|
},
|
|
48
48
|
) => void;
|
|
49
49
|
|
|
50
|
-
export type UserActionOptions = Omit<ToastUserActionProps, 'appearance'> & Pick<ToastOptions, 'id'>;
|
|
51
|
-
export type SystemEventOptions = Omit<ToastSystemEventProps, 'appearance'> & Pick<ToastOptions, 'id'>;
|
|
50
|
+
export type UserActionOptions = Omit<ToastUserActionProps, 'appearance'> & Pick<ToastOptions, 'id' | 'onClose'>;
|
|
51
|
+
export type SystemEventOptions = Omit<ToastSystemEventProps, 'appearance'> & Pick<ToastOptions, 'id' | 'onClose'>;
|
|
52
52
|
|
|
53
53
|
export type Toaster = {
|
|
54
54
|
userAction: {
|