@snack-uikit/toaster 0.6.12 → 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 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 = toasterProps === null || toasterProps === void 0 ? void 0 : toasterProps.onClose) === null || _a === void 0 ? void 0 : _a.call(toasterProps, data === null || data === void 0 ? void 0 : data.id);
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}`,
@@ -79,24 +79,40 @@ const userAction = {
79
79
  return openToast({
80
80
  type: TOASTER_TYPE.UserAction,
81
81
  toasterProps: Object.assign(Object.assign({}, options), { appearance: 'success' }),
82
+ toastOptions: {
83
+ id: options.id,
84
+ onClose: options.onClose,
85
+ },
82
86
  });
83
87
  },
84
88
  neutral(options) {
85
89
  return openToast({
86
90
  type: TOASTER_TYPE.UserAction,
87
91
  toasterProps: Object.assign(Object.assign({}, options), { appearance: 'neutral' }),
92
+ toastOptions: {
93
+ id: options.id,
94
+ onClose: options.onClose,
95
+ },
88
96
  });
89
97
  },
90
98
  error(options) {
91
99
  return openToast({
92
100
  type: TOASTER_TYPE.UserAction,
93
101
  toasterProps: Object.assign(Object.assign({}, options), { appearance: 'error' }),
102
+ toastOptions: {
103
+ id: options.id,
104
+ onClose: options.onClose,
105
+ },
94
106
  });
95
107
  },
96
108
  warning(options) {
97
109
  return openToast({
98
110
  type: TOASTER_TYPE.UserAction,
99
111
  toasterProps: Object.assign(Object.assign({}, options), { appearance: 'warning' }),
112
+ toastOptions: {
113
+ id: options.id,
114
+ onClose: options.onClose,
115
+ },
100
116
  });
101
117
  },
102
118
  update: {
@@ -134,30 +150,50 @@ const systemEvent = {
134
150
  return openToast({
135
151
  type: TOASTER_TYPE.SystemEvent,
136
152
  toasterProps: Object.assign(Object.assign({}, options), { appearance: 'success' }),
153
+ toastOptions: {
154
+ id: options.id,
155
+ onClose: options.onClose,
156
+ },
137
157
  });
138
158
  },
139
159
  neutral(options) {
140
160
  return openToast({
141
161
  type: TOASTER_TYPE.SystemEvent,
142
162
  toasterProps: Object.assign(Object.assign({}, options), { appearance: 'neutral' }),
163
+ toastOptions: {
164
+ id: options.id,
165
+ onClose: options.onClose,
166
+ },
143
167
  });
144
168
  },
145
169
  warning(options) {
146
170
  return openToast({
147
171
  type: TOASTER_TYPE.SystemEvent,
148
172
  toasterProps: Object.assign(Object.assign({}, options), { appearance: 'warning' }),
173
+ toastOptions: {
174
+ id: options.id,
175
+ onClose: options.onClose,
176
+ },
149
177
  });
150
178
  },
151
179
  error(options) {
152
180
  return openToast({
153
181
  type: TOASTER_TYPE.SystemEvent,
154
182
  toasterProps: Object.assign(Object.assign({}, options), { appearance: 'error' }),
183
+ toastOptions: {
184
+ id: options.id,
185
+ onClose: options.onClose,
186
+ },
155
187
  });
156
188
  },
157
189
  errorCritical(options) {
158
190
  return openToast({
159
191
  type: TOASTER_TYPE.SystemEvent,
160
192
  toasterProps: Object.assign(Object.assign({}, options), { appearance: 'errorCritical' }),
193
+ toastOptions: {
194
+ id: options.id,
195
+ onClose: options.onClose,
196
+ },
161
197
  });
162
198
  },
163
199
  update: {
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.12",
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": "17bfcf1150776cd35c77d9cca8f45dde97472bf1"
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
- toasterProps?.onClose?.(data?.id);
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}`,
@@ -156,6 +156,10 @@ const userAction = {
156
156
  return openToast({
157
157
  type: TOASTER_TYPE.UserAction,
158
158
  toasterProps: { ...options, appearance: 'success' },
159
+ toastOptions: {
160
+ id: options.id,
161
+ onClose: options.onClose,
162
+ },
159
163
  });
160
164
  },
161
165
 
@@ -163,6 +167,10 @@ const userAction = {
163
167
  return openToast({
164
168
  type: TOASTER_TYPE.UserAction,
165
169
  toasterProps: { ...options, appearance: 'neutral' },
170
+ toastOptions: {
171
+ id: options.id,
172
+ onClose: options.onClose,
173
+ },
166
174
  });
167
175
  },
168
176
 
@@ -170,6 +178,10 @@ const userAction = {
170
178
  return openToast({
171
179
  type: TOASTER_TYPE.UserAction,
172
180
  toasterProps: { ...options, appearance: 'error' },
181
+ toastOptions: {
182
+ id: options.id,
183
+ onClose: options.onClose,
184
+ },
173
185
  });
174
186
  },
175
187
 
@@ -177,6 +189,10 @@ const userAction = {
177
189
  return openToast({
178
190
  type: TOASTER_TYPE.UserAction,
179
191
  toasterProps: { ...options, appearance: 'warning' },
192
+ toastOptions: {
193
+ id: options.id,
194
+ onClose: options.onClose,
195
+ },
180
196
  });
181
197
  },
182
198
 
@@ -220,6 +236,10 @@ const systemEvent = {
220
236
  return openToast({
221
237
  type: TOASTER_TYPE.SystemEvent,
222
238
  toasterProps: { ...options, appearance: 'success' },
239
+ toastOptions: {
240
+ id: options.id,
241
+ onClose: options.onClose,
242
+ },
223
243
  });
224
244
  },
225
245
 
@@ -227,6 +247,10 @@ const systemEvent = {
227
247
  return openToast({
228
248
  type: TOASTER_TYPE.SystemEvent,
229
249
  toasterProps: { ...options, appearance: 'neutral' },
250
+ toastOptions: {
251
+ id: options.id,
252
+ onClose: options.onClose,
253
+ },
230
254
  });
231
255
  },
232
256
 
@@ -234,6 +258,10 @@ const systemEvent = {
234
258
  return openToast({
235
259
  type: TOASTER_TYPE.SystemEvent,
236
260
  toasterProps: { ...options, appearance: 'warning' },
261
+ toastOptions: {
262
+ id: options.id,
263
+ onClose: options.onClose,
264
+ },
237
265
  });
238
266
  },
239
267
 
@@ -241,6 +269,10 @@ const systemEvent = {
241
269
  return openToast({
242
270
  type: TOASTER_TYPE.SystemEvent,
243
271
  toasterProps: { ...options, appearance: 'error' },
272
+ toastOptions: {
273
+ id: options.id,
274
+ onClose: options.onClose,
275
+ },
244
276
  });
245
277
  },
246
278
 
@@ -248,6 +280,10 @@ const systemEvent = {
248
280
  return openToast({
249
281
  type: TOASTER_TYPE.SystemEvent,
250
282
  toasterProps: { ...options, appearance: 'errorCritical' },
283
+ toastOptions: {
284
+ id: options.id,
285
+ onClose: options.onClose,
286
+ },
251
287
  });
252
288
  },
253
289
 
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: {