@snack-uikit/toaster 0.6.8-preview-8c773b48.0 → 0.6.8

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,16 @@
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.8 (2024-03-26)
7
+
8
+ ### Only dependencies have been changed
9
+ * [@snack-uikit/link@0.11.6](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/link/CHANGELOG.md)
10
+ * [@snack-uikit/truncate-string@0.4.12](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/truncate-string/CHANGELOG.md)
11
+
12
+
13
+
14
+
15
+
6
16
  ## 0.6.7 (2024-03-22)
7
17
 
8
18
  ### Only dependencies have been changed
@@ -16,9 +16,10 @@ import { CrossSVG } from '@snack-uikit/icons';
16
16
  import { Link } from '@snack-uikit/link';
17
17
  import { TruncateString } from '@snack-uikit/truncate-string';
18
18
  import { extractSupportProps } from '@snack-uikit/utils';
19
- import { AUTO_CLOSE_TIME, TOASTER_TYPE } from '../../constants';
19
+ import { AUTO_CLOSE_TIME } from '../../constants';
20
20
  import { ButtonAction } from '../../helperComponents/ButtonAction';
21
21
  import { TOAST_SYSTEM_EVENT_TEST_IDS } from '../../testIds';
22
+ import { ToasterType } from '../../types';
22
23
  import { APPEARANCE_TO_ON_COLOR_MAP } from './constants';
23
24
  import styles from './styles.module.css';
24
25
  import { getIcon } from './utils';
@@ -29,5 +30,5 @@ export function ToastSystemEvent(_a) {
29
30
  onCloseClick ? onCloseClick(e, closeToast) : closeToast === null || closeToast === void 0 ? void 0 : closeToast();
30
31
  };
31
32
  const icon = useMemo(() => getIcon(appearance), [appearance]);
32
- return (_jsxs("div", Object.assign({ className: cn(styles.container, className) }, extractSupportProps(rest), { "data-appearance": appearance, children: [_jsxs("div", { className: styles.body, children: [_jsx("div", { className: styles.icon, children: icon }), _jsxs("div", { className: styles.contentLayout, children: [_jsxs("div", { children: [_jsx("span", { className: styles.title, children: _jsx(TruncateString, { text: title, maxLines: 2, hideTooltip: true, "data-test-id": TOAST_SYSTEM_EVENT_TEST_IDS.title }) }), description && (_jsx("span", { className: styles.description, children: _jsx(TruncateString, { maxLines: 4, text: description, hideTooltip: true, "data-test-id": TOAST_SYSTEM_EVENT_TEST_IDS.description }) }))] }), link && (_jsx(Link, { text: link.text, href: link.href, size: 'm', onClick: link.onClick, appearance: APPEARANCE_TO_ON_COLOR_MAP[appearance], "data-test-id": TOAST_SYSTEM_EVENT_TEST_IDS.link, textMode: appearance === 'errorCritical' ? 'on-accent' : 'accent' }))] }), closable && (_jsx("button", { className: styles.buttonClose, onClick: handleCloseClick, "data-test-id": TOAST_SYSTEM_EVENT_TEST_IDS.buttonClose, "aria-label": 'close notification', children: _jsx(CrossSVG, {}) }))] }), progressBar && (_jsx("div", { role: 'progressbar', "aria-label": 'progressbar', "data-test-id": TOAST_SYSTEM_EVENT_TEST_IDS.progressbar, className: styles.progress, style: { animationDuration: `${AUTO_CLOSE_TIME[TOASTER_TYPE.SystemEvent]}ms` } })), Array.isArray(action) && action.length > 0 && (_jsx("div", { className: styles.footer, children: action.map(buttonProps => (_jsx(ButtonAction, Object.assign({}, buttonProps, { critical: appearance === 'errorCritical' }), buttonProps.label))) }))] })));
33
+ return (_jsxs("div", Object.assign({ className: cn(styles.container, className) }, extractSupportProps(rest), { "data-appearance": appearance, children: [_jsxs("div", { className: styles.body, children: [_jsx("div", { className: styles.icon, children: icon }), _jsxs("div", { className: styles.contentLayout, children: [_jsxs("div", { children: [_jsx("span", { className: styles.title, children: _jsx(TruncateString, { text: title, maxLines: 2, hideTooltip: true, "data-test-id": TOAST_SYSTEM_EVENT_TEST_IDS.title }) }), description && (_jsx("span", { className: styles.description, children: _jsx(TruncateString, { maxLines: 4, text: description, hideTooltip: true, "data-test-id": TOAST_SYSTEM_EVENT_TEST_IDS.description }) }))] }), link && (_jsx(Link, { text: link.text, href: link.href, size: 'm', onClick: link.onClick, appearance: APPEARANCE_TO_ON_COLOR_MAP[appearance], "data-test-id": TOAST_SYSTEM_EVENT_TEST_IDS.link, textMode: appearance === 'errorCritical' ? 'on-accent' : 'accent' }))] }), closable && (_jsx("button", { className: styles.buttonClose, onClick: handleCloseClick, "data-test-id": TOAST_SYSTEM_EVENT_TEST_IDS.buttonClose, "aria-label": 'close notification', children: _jsx(CrossSVG, {}) }))] }), progressBar && (_jsx("div", { role: 'progressbar', "aria-label": 'progressbar', "data-test-id": TOAST_SYSTEM_EVENT_TEST_IDS.progressbar, className: styles.progress, style: { animationDuration: `${AUTO_CLOSE_TIME[ToasterType.SystemEvent]}ms` } })), Array.isArray(action) && action.length > 0 && (_jsx("div", { className: styles.footer, children: action.map(buttonProps => (_jsx(ButtonAction, Object.assign({}, buttonProps, { critical: appearance === 'errorCritical' }), buttonProps.label))) }))] })));
33
34
  }
@@ -3,10 +3,11 @@ import 'react-toastify/dist/ReactToastify.css';
3
3
  import cn from 'classnames';
4
4
  import { useEffect, useState } from 'react';
5
5
  import { toast, ToastContainer as RtToastContainer, } from 'react-toastify';
6
- import { TOASTER_CONTAINER_PREFIX, TOASTER_TYPE } from '../../constants';
6
+ import { TOASTER_CONTAINER_PREFIX } from '../../constants';
7
7
  import { TOAST_SYSTEM_EVENT_TEST_IDS } from '../../testIds';
8
+ import { ToasterType } from '../../types';
8
9
  import styles from './styles.module.css';
9
- export function ToasterContainer({ position = toast.POSITION.BOTTOM_RIGHT, limit = 5, containerId, displayCloseAllButton, type = TOASTER_TYPE.SystemEvent, }) {
10
+ export function ToasterContainer({ position = toast.POSITION.BOTTOM_RIGHT, limit = 5, containerId, displayCloseAllButton, type = ToasterType.SystemEvent, }) {
10
11
  const [notificationCounter, setNotificationCounter] = useState(0);
11
12
  const [isCloseAllButtonHidden, setIsCloseAllButtonHidden] = useState(false);
12
13
  const closeAll = () => {
@@ -15,7 +16,7 @@ export function ToasterContainer({ position = toast.POSITION.BOTTOM_RIGHT, limit
15
16
  };
16
17
  useEffect(() => {
17
18
  const unsubscribe = toast.onChange(({ status, containerId }) => {
18
- if (containerId === `${TOASTER_CONTAINER_PREFIX}${TOASTER_TYPE.SystemEvent}`) {
19
+ if (containerId === `${TOASTER_CONTAINER_PREFIX}${ToasterType.SystemEvent}`) {
19
20
  if (status === 'added') {
20
21
  setIsCloseAllButtonHidden(false);
21
22
  setNotificationCounter(prev => prev + 1);
@@ -1,9 +1,5 @@
1
1
  import { ToasterContainerProps } from './components';
2
2
  import { ToasterType } from './types';
3
- export declare const TOASTER_TYPE: {
4
- readonly SystemEvent: "system-event";
5
- readonly UserAction: "user-action";
6
- };
7
3
  export declare const TOASTER_CONTAINER_DEFAULT_PROPS: Record<ToasterType, ToasterContainerProps>;
8
4
  export declare const AUTO_CLOSE_TIME: {
9
5
  "system-event": number;
package/dist/constants.js CHANGED
@@ -1,25 +1,22 @@
1
1
  import { ToasterContainer } from './components';
2
- export const TOASTER_TYPE = {
3
- SystemEvent: 'system-event',
4
- UserAction: 'user-action',
5
- };
2
+ import { ToasterType } from './types';
6
3
  export const TOASTER_CONTAINER_DEFAULT_PROPS = {
7
- [TOASTER_TYPE.SystemEvent]: {
4
+ [ToasterType.SystemEvent]: {
8
5
  limit: 5,
9
6
  position: ToasterContainer.position.BOTTOM_RIGHT,
10
7
  displayCloseAllButton: true,
11
- type: TOASTER_TYPE.SystemEvent,
8
+ type: ToasterType.SystemEvent,
12
9
  },
13
- [TOASTER_TYPE.UserAction]: {
10
+ [ToasterType.UserAction]: {
14
11
  limit: 2,
15
12
  position: ToasterContainer.position.BOTTOM_CENTER,
16
13
  displayCloseAllButton: false,
17
- type: TOASTER_TYPE.UserAction,
14
+ type: ToasterType.UserAction,
18
15
  },
19
16
  };
20
17
  export const AUTO_CLOSE_TIME = {
21
- [TOASTER_TYPE.SystemEvent]: 5000,
22
- [TOASTER_TYPE.UserAction]: 2000,
18
+ [ToasterType.SystemEvent]: 5000,
19
+ [ToasterType.UserAction]: 2000,
23
20
  };
24
21
  export const TOASTER_ROOT_ID = 'toaster-root';
25
22
  export const TOASTER_CONTAINER_PREFIX = 'toaster-container__';
package/dist/helpers.js CHANGED
@@ -3,7 +3,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { render } from 'react-dom';
4
4
  import { toast } from 'react-toastify';
5
5
  import { ToasterContainer, ToastSystemEvent, ToastUserAction, } from './components';
6
- import { AUTO_CLOSE_TIME, TOASTER_CONTAINER_DEFAULT_PROPS, TOASTER_CONTAINER_PREFIX, TOASTER_ROOT_ID, TOASTER_TYPE, } from './constants';
6
+ import { AUTO_CLOSE_TIME, TOASTER_CONTAINER_DEFAULT_PROPS, TOASTER_CONTAINER_PREFIX, TOASTER_ROOT_ID, } from './constants';
7
+ import { ToasterType, } from './types';
7
8
  function getToasterContainer({ type, toasterParent, containerProps, }) {
8
9
  const containerId = (containerProps === null || containerProps === void 0 ? void 0 : containerProps.containerId) || `${TOASTER_CONTAINER_PREFIX}${type}`;
9
10
  const toasterContainerProps = Object.assign(Object.assign(Object.assign({}, TOASTER_CONTAINER_DEFAULT_PROPS[type]), (containerProps || {})), { containerId });
@@ -32,9 +33,9 @@ function getToastOptions({ type, toastOptions, containerId, toasterProps, }) {
32
33
  }
33
34
  function getToastComponent({ type, toasterProps, }) {
34
35
  switch (type) {
35
- case TOASTER_TYPE.UserAction:
36
+ case ToasterType.UserAction:
36
37
  return _jsx(ToastUserAction, Object.assign({}, toasterProps));
37
- case TOASTER_TYPE.SystemEvent:
38
+ case ToasterType.SystemEvent:
38
39
  return _jsx(ToastSystemEvent, Object.assign({}, toasterProps));
39
40
  default:
40
41
  return undefined;
@@ -77,50 +78,50 @@ export const isToastActive = toast.isActive;
77
78
  const userAction = {
78
79
  success(options) {
79
80
  return openToast({
80
- type: TOASTER_TYPE.UserAction,
81
+ type: ToasterType.UserAction,
81
82
  toasterProps: Object.assign(Object.assign({}, options), { appearance: 'success' }),
82
83
  });
83
84
  },
84
85
  neutral(options) {
85
86
  return openToast({
86
- type: TOASTER_TYPE.UserAction,
87
+ type: ToasterType.UserAction,
87
88
  toasterProps: Object.assign(Object.assign({}, options), { appearance: 'neutral' }),
88
89
  });
89
90
  },
90
91
  error(options) {
91
92
  return openToast({
92
- type: TOASTER_TYPE.UserAction,
93
+ type: ToasterType.UserAction,
93
94
  toasterProps: Object.assign(Object.assign({}, options), { appearance: 'error' }),
94
95
  });
95
96
  },
96
97
  warning(options) {
97
98
  return openToast({
98
- type: TOASTER_TYPE.UserAction,
99
+ type: ToasterType.UserAction,
99
100
  toasterProps: Object.assign(Object.assign({}, options), { appearance: 'warning' }),
100
101
  });
101
102
  },
102
103
  update: {
103
104
  success(id, options) {
104
105
  updateToast(id, {
105
- type: TOASTER_TYPE.UserAction,
106
+ type: ToasterType.UserAction,
106
107
  toasterProps: Object.assign(Object.assign({}, options), { appearance: 'success' }),
107
108
  });
108
109
  },
109
110
  neutral(id, options) {
110
111
  updateToast(id, {
111
- type: TOASTER_TYPE.UserAction,
112
+ type: ToasterType.UserAction,
112
113
  toasterProps: Object.assign(Object.assign({}, options), { appearance: 'neutral' }),
113
114
  });
114
115
  },
115
116
  warning(id, options) {
116
117
  updateToast(id, {
117
- type: TOASTER_TYPE.UserAction,
118
+ type: ToasterType.UserAction,
118
119
  toasterProps: Object.assign(Object.assign({}, options), { appearance: 'warning' }),
119
120
  });
120
121
  },
121
122
  error(id, options) {
122
123
  updateToast(id, {
123
- type: TOASTER_TYPE.UserAction,
124
+ type: ToasterType.UserAction,
124
125
  toasterProps: Object.assign(Object.assign({}, options), { appearance: 'error' }),
125
126
  });
126
127
  },
@@ -132,62 +133,62 @@ const userAction = {
132
133
  const systemEvent = {
133
134
  success(options) {
134
135
  return openToast({
135
- type: TOASTER_TYPE.SystemEvent,
136
+ type: ToasterType.SystemEvent,
136
137
  toasterProps: Object.assign(Object.assign({}, options), { appearance: 'success' }),
137
138
  });
138
139
  },
139
140
  neutral(options) {
140
141
  return openToast({
141
- type: TOASTER_TYPE.SystemEvent,
142
+ type: ToasterType.SystemEvent,
142
143
  toasterProps: Object.assign(Object.assign({}, options), { appearance: 'neutral' }),
143
144
  });
144
145
  },
145
146
  warning(options) {
146
147
  return openToast({
147
- type: TOASTER_TYPE.SystemEvent,
148
+ type: ToasterType.SystemEvent,
148
149
  toasterProps: Object.assign(Object.assign({}, options), { appearance: 'warning' }),
149
150
  });
150
151
  },
151
152
  error(options) {
152
153
  return openToast({
153
- type: TOASTER_TYPE.SystemEvent,
154
+ type: ToasterType.SystemEvent,
154
155
  toasterProps: Object.assign(Object.assign({}, options), { appearance: 'error' }),
155
156
  });
156
157
  },
157
158
  errorCritical(options) {
158
159
  return openToast({
159
- type: TOASTER_TYPE.SystemEvent,
160
+ type: ToasterType.SystemEvent,
160
161
  toasterProps: Object.assign(Object.assign({}, options), { appearance: 'errorCritical' }),
161
162
  });
162
163
  },
163
164
  update: {
164
165
  success(id, options) {
165
166
  return updateToast(id, {
166
- type: TOASTER_TYPE.SystemEvent,
167
+ type: ToasterType.SystemEvent,
167
168
  toasterProps: Object.assign(Object.assign({}, options), { appearance: 'success' }),
168
169
  });
169
170
  },
170
171
  neutral(id, options) {
171
172
  return updateToast(id, {
172
- type: TOASTER_TYPE.SystemEvent,
173
+ type: ToasterType.SystemEvent,
173
174
  toasterProps: Object.assign(Object.assign({}, options), { appearance: 'neutral' }),
174
175
  });
175
176
  },
176
177
  warning(id, options) {
177
178
  return updateToast(id, {
178
- type: TOASTER_TYPE.SystemEvent,
179
+ type: ToasterType.SystemEvent,
179
180
  toasterProps: Object.assign(Object.assign({}, options), { appearance: 'warning' }),
180
181
  });
181
182
  },
182
183
  error(id, options) {
183
184
  return updateToast(id, {
184
- type: TOASTER_TYPE.SystemEvent,
185
+ type: ToasterType.SystemEvent,
185
186
  toasterProps: Object.assign(Object.assign({}, options), { appearance: 'error' }),
186
187
  });
187
188
  },
188
189
  errorCritical(id, options) {
189
190
  return updateToast(id, {
190
- type: TOASTER_TYPE.SystemEvent,
191
+ type: ToasterType.SystemEvent,
191
192
  toasterProps: Object.assign(Object.assign({}, options), { appearance: 'errorCritical' }),
192
193
  });
193
194
  },
package/dist/index.d.ts CHANGED
@@ -1,4 +1,2 @@
1
1
  export { toaster } from './helpers';
2
2
  export type { ToastSystemEventProps, ToastUserActionProps } from './components';
3
- export { openToast, updateToast, dismissToast } from './helpers';
4
- export type { Toaster, UpdateToast, OpenToast } from './types';
package/dist/index.js CHANGED
@@ -1,2 +1 @@
1
1
  export { toaster } from './helpers';
2
- export { openToast, updateToast, dismissToast } from './helpers';
package/dist/types.d.ts CHANGED
@@ -1,7 +1,5 @@
1
1
  import { Id, ToastOptions as RtToastOptions } from 'react-toastify';
2
- import { ValueOf } from '@snack-uikit/utils';
3
2
  import { ToasterContainerProps, ToastSystemEventProps, ToastUserActionProps } from './components';
4
- import { TOASTER_TYPE } from './constants';
5
3
  export type ToasterId = Id;
6
4
  export type PromisedId = Promise<ToasterId>;
7
5
  export type ToastOptions = {
@@ -9,10 +7,13 @@ export type ToastOptions = {
9
7
  autoClose?: RtToastOptions['autoClose'];
10
8
  onClose?(id?: ToasterId): void;
11
9
  };
12
- export type ToasterType = ValueOf<typeof TOASTER_TYPE>;
10
+ export declare enum ToasterType {
11
+ SystemEvent = "system-event",
12
+ UserAction = "user-action"
13
+ }
13
14
  export type ToasterPropsMap = {
14
- [TOASTER_TYPE.UserAction]: ToastUserActionProps;
15
- [TOASTER_TYPE.SystemEvent]: ToastSystemEventProps;
15
+ [ToasterType.UserAction]: ToastUserActionProps;
16
+ [ToasterType.SystemEvent]: ToastSystemEventProps;
16
17
  };
17
18
  type OpenNotificationProps<T extends keyof ToasterPropsMap> = {
18
19
  type: T;
package/dist/types.js CHANGED
@@ -1 +1,5 @@
1
- import { TOASTER_TYPE } from './constants';
1
+ export var ToasterType;
2
+ (function (ToasterType) {
3
+ ToasterType["SystemEvent"] = "system-event";
4
+ ToasterType["UserAction"] = "user-action";
5
+ })(ToasterType || (ToasterType = {}));
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Toaster",
7
- "version": "0.6.8-preview-8c773b48.0",
7
+ "version": "0.6.8",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -33,12 +33,12 @@
33
33
  "scripts": {},
34
34
  "dependencies": {
35
35
  "@snack-uikit/icons": "0.20.1",
36
- "@snack-uikit/link": "0.11.5",
36
+ "@snack-uikit/link": "0.11.6",
37
37
  "@snack-uikit/loaders": "0.5.1",
38
- "@snack-uikit/truncate-string": "0.4.11",
38
+ "@snack-uikit/truncate-string": "0.4.12",
39
39
  "@snack-uikit/utils": "3.2.0",
40
40
  "classnames": "2.3.2",
41
41
  "react-toastify": "9.1.3"
42
42
  },
43
- "gitHead": "96a2e4b7298bb6e7be522f5e7b22f90bc1861cf3"
43
+ "gitHead": "234be77560f8bd1b3a4b567e2ec88f3a89c3631f"
44
44
  }
@@ -7,10 +7,10 @@ import { Link } from '@snack-uikit/link';
7
7
  import { TruncateString } from '@snack-uikit/truncate-string';
8
8
  import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
9
9
 
10
- import { AUTO_CLOSE_TIME, TOASTER_TYPE } from '../../constants';
10
+ import { AUTO_CLOSE_TIME } 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';
13
+ import { ToasterId, ToasterType } from '../../types';
14
14
  import { APPEARANCE_TO_ON_COLOR_MAP } from './constants';
15
15
  import styles from './styles.module.scss';
16
16
  import { ToastSystemEventAppearance } from './types';
@@ -113,7 +113,7 @@ export function ToastSystemEvent({
113
113
  aria-label='progressbar'
114
114
  data-test-id={TOAST_SYSTEM_EVENT_TEST_IDS.progressbar}
115
115
  className={styles.progress}
116
- style={{ animationDuration: `${AUTO_CLOSE_TIME[TOASTER_TYPE.SystemEvent]}ms` }}
116
+ style={{ animationDuration: `${AUTO_CLOSE_TIME[ToasterType.SystemEvent]}ms` }}
117
117
  />
118
118
  )}
119
119
 
@@ -10,7 +10,7 @@ import {
10
10
  ToastPosition,
11
11
  } from 'react-toastify';
12
12
 
13
- import { TOASTER_CONTAINER_PREFIX, TOASTER_TYPE } from '../../constants';
13
+ import { TOASTER_CONTAINER_PREFIX } from '../../constants';
14
14
  import { TOAST_SYSTEM_EVENT_TEST_IDS } from '../../testIds';
15
15
  import { ToasterType } from '../../types';
16
16
  import styles from './styles.module.scss';
@@ -28,7 +28,7 @@ export function ToasterContainer({
28
28
  limit = 5,
29
29
  containerId,
30
30
  displayCloseAllButton,
31
- type = TOASTER_TYPE.SystemEvent,
31
+ type = ToasterType.SystemEvent,
32
32
  }: ToasterContainerProps) {
33
33
  const [notificationCounter, setNotificationCounter] = useState(0);
34
34
  const [isCloseAllButtonHidden, setIsCloseAllButtonHidden] = useState(false);
@@ -39,7 +39,7 @@ export function ToasterContainer({
39
39
 
40
40
  useEffect(() => {
41
41
  const unsubscribe = toast.onChange(({ status, containerId }: ToastItem) => {
42
- if (containerId === `${TOASTER_CONTAINER_PREFIX}${TOASTER_TYPE.SystemEvent}`) {
42
+ if (containerId === `${TOASTER_CONTAINER_PREFIX}${ToasterType.SystemEvent}`) {
43
43
  if (status === 'added') {
44
44
  setIsCloseAllButtonHidden(false);
45
45
  setNotificationCounter(prev => prev + 1);
package/src/constants.ts CHANGED
@@ -1,29 +1,24 @@
1
1
  import { ToasterContainer, ToasterContainerProps } from './components';
2
2
  import { ToasterType } from './types';
3
3
 
4
- export const TOASTER_TYPE = {
5
- SystemEvent: 'system-event',
6
- UserAction: 'user-action',
7
- } as const;
8
-
9
4
  export const TOASTER_CONTAINER_DEFAULT_PROPS: Record<ToasterType, ToasterContainerProps> = {
10
- [TOASTER_TYPE.SystemEvent]: {
5
+ [ToasterType.SystemEvent]: {
11
6
  limit: 5,
12
7
  position: ToasterContainer.position.BOTTOM_RIGHT,
13
8
  displayCloseAllButton: true,
14
- type: TOASTER_TYPE.SystemEvent,
9
+ type: ToasterType.SystemEvent,
15
10
  },
16
- [TOASTER_TYPE.UserAction]: {
11
+ [ToasterType.UserAction]: {
17
12
  limit: 2,
18
13
  position: ToasterContainer.position.BOTTOM_CENTER,
19
14
  displayCloseAllButton: false,
20
- type: TOASTER_TYPE.UserAction,
15
+ type: ToasterType.UserAction,
21
16
  },
22
17
  };
23
18
 
24
19
  export const AUTO_CLOSE_TIME = {
25
- [TOASTER_TYPE.SystemEvent]: 5000,
26
- [TOASTER_TYPE.UserAction]: 2000,
20
+ [ToasterType.SystemEvent]: 5000,
21
+ [ToasterType.UserAction]: 2000,
27
22
  };
28
23
 
29
24
  export const TOASTER_ROOT_ID = 'toaster-root';
package/src/helpers.tsx CHANGED
@@ -15,7 +15,6 @@ import {
15
15
  TOASTER_CONTAINER_DEFAULT_PROPS,
16
16
  TOASTER_CONTAINER_PREFIX,
17
17
  TOASTER_ROOT_ID,
18
- TOASTER_TYPE,
19
18
  } from './constants';
20
19
  import {
21
20
  OpenToast,
@@ -91,9 +90,9 @@ function getToastComponent<T extends keyof ToasterPropsMap>({
91
90
  toasterProps: ToasterPropsMap[T];
92
91
  }) {
93
92
  switch (type) {
94
- case TOASTER_TYPE.UserAction:
93
+ case ToasterType.UserAction:
95
94
  return <ToastUserAction {...(toasterProps as ToastUserActionProps)} />;
96
- case TOASTER_TYPE.SystemEvent:
95
+ case ToasterType.SystemEvent:
97
96
  return <ToastSystemEvent {...(toasterProps as ToastSystemEventProps)} />;
98
97
  default:
99
98
  return undefined;
@@ -154,28 +153,28 @@ export const isToastActive = toast.isActive;
154
153
  const userAction = {
155
154
  success(options: UserActionOptions) {
156
155
  return openToast({
157
- type: TOASTER_TYPE.UserAction,
156
+ type: ToasterType.UserAction,
158
157
  toasterProps: { ...options, appearance: 'success' },
159
158
  });
160
159
  },
161
160
 
162
161
  neutral(options: UserActionOptions) {
163
162
  return openToast({
164
- type: TOASTER_TYPE.UserAction,
163
+ type: ToasterType.UserAction,
165
164
  toasterProps: { ...options, appearance: 'neutral' },
166
165
  });
167
166
  },
168
167
 
169
168
  error(options: UserActionOptions) {
170
169
  return openToast({
171
- type: TOASTER_TYPE.UserAction,
170
+ type: ToasterType.UserAction,
172
171
  toasterProps: { ...options, appearance: 'error' },
173
172
  });
174
173
  },
175
174
 
176
175
  warning(options: UserActionOptions) {
177
176
  return openToast({
178
- type: TOASTER_TYPE.UserAction,
177
+ type: ToasterType.UserAction,
179
178
  toasterProps: { ...options, appearance: 'warning' },
180
179
  });
181
180
  },
@@ -183,28 +182,28 @@ const userAction = {
183
182
  update: {
184
183
  success(id: ToasterId, options: UserActionOptions) {
185
184
  updateToast(id, {
186
- type: TOASTER_TYPE.UserAction,
185
+ type: ToasterType.UserAction,
187
186
  toasterProps: { ...options, appearance: 'success' },
188
187
  });
189
188
  },
190
189
 
191
190
  neutral(id: ToasterId, options: UserActionOptions) {
192
191
  updateToast(id, {
193
- type: TOASTER_TYPE.UserAction,
192
+ type: ToasterType.UserAction,
194
193
  toasterProps: { ...options, appearance: 'neutral' },
195
194
  });
196
195
  },
197
196
 
198
197
  warning(id: ToasterId, options: UserActionOptions) {
199
198
  updateToast(id, {
200
- type: TOASTER_TYPE.UserAction,
199
+ type: ToasterType.UserAction,
201
200
  toasterProps: { ...options, appearance: 'warning' },
202
201
  });
203
202
  },
204
203
 
205
204
  error(id: ToasterId, options: UserActionOptions) {
206
205
  updateToast(id, {
207
- type: TOASTER_TYPE.UserAction,
206
+ type: ToasterType.UserAction,
208
207
  toasterProps: { ...options, appearance: 'error' },
209
208
  });
210
209
  },
@@ -218,35 +217,35 @@ const userAction = {
218
217
  const systemEvent = {
219
218
  success(options: SystemEventOptions) {
220
219
  return openToast({
221
- type: TOASTER_TYPE.SystemEvent,
220
+ type: ToasterType.SystemEvent,
222
221
  toasterProps: { ...options, appearance: 'success' },
223
222
  });
224
223
  },
225
224
 
226
225
  neutral(options: SystemEventOptions) {
227
226
  return openToast({
228
- type: TOASTER_TYPE.SystemEvent,
227
+ type: ToasterType.SystemEvent,
229
228
  toasterProps: { ...options, appearance: 'neutral' },
230
229
  });
231
230
  },
232
231
 
233
232
  warning(options: SystemEventOptions) {
234
233
  return openToast({
235
- type: TOASTER_TYPE.SystemEvent,
234
+ type: ToasterType.SystemEvent,
236
235
  toasterProps: { ...options, appearance: 'warning' },
237
236
  });
238
237
  },
239
238
 
240
239
  error(options: SystemEventOptions) {
241
240
  return openToast({
242
- type: TOASTER_TYPE.SystemEvent,
241
+ type: ToasterType.SystemEvent,
243
242
  toasterProps: { ...options, appearance: 'error' },
244
243
  });
245
244
  },
246
245
 
247
246
  errorCritical(options: SystemEventOptions) {
248
247
  return openToast({
249
- type: TOASTER_TYPE.SystemEvent,
248
+ type: ToasterType.SystemEvent,
250
249
  toasterProps: { ...options, appearance: 'errorCritical' },
251
250
  });
252
251
  },
@@ -254,35 +253,35 @@ const systemEvent = {
254
253
  update: {
255
254
  success(id: ToasterId, options: SystemEventOptions) {
256
255
  return updateToast(id, {
257
- type: TOASTER_TYPE.SystemEvent,
256
+ type: ToasterType.SystemEvent,
258
257
  toasterProps: { ...options, appearance: 'success' },
259
258
  });
260
259
  },
261
260
 
262
261
  neutral(id: ToasterId, options: SystemEventOptions) {
263
262
  return updateToast(id, {
264
- type: TOASTER_TYPE.SystemEvent,
263
+ type: ToasterType.SystemEvent,
265
264
  toasterProps: { ...options, appearance: 'neutral' },
266
265
  });
267
266
  },
268
267
 
269
268
  warning(id: ToasterId, options: SystemEventOptions) {
270
269
  return updateToast(id, {
271
- type: TOASTER_TYPE.SystemEvent,
270
+ type: ToasterType.SystemEvent,
272
271
  toasterProps: { ...options, appearance: 'warning' },
273
272
  });
274
273
  },
275
274
 
276
275
  error(id: ToasterId, options: SystemEventOptions) {
277
276
  return updateToast(id, {
278
- type: TOASTER_TYPE.SystemEvent,
277
+ type: ToasterType.SystemEvent,
279
278
  toasterProps: { ...options, appearance: 'error' },
280
279
  });
281
280
  },
282
281
 
283
282
  errorCritical(id: ToasterId, options: SystemEventOptions) {
284
283
  return updateToast(id, {
285
- type: TOASTER_TYPE.SystemEvent,
284
+ type: ToasterType.SystemEvent,
286
285
  toasterProps: { ...options, appearance: 'errorCritical' },
287
286
  });
288
287
  },
package/src/index.ts CHANGED
@@ -1,7 +1,3 @@
1
1
  export { toaster } from './helpers';
2
2
 
3
3
  export type { ToastSystemEventProps, ToastUserActionProps } from './components';
4
-
5
- export { openToast, updateToast, dismissToast } from './helpers';
6
-
7
- export type { Toaster, UpdateToast, OpenToast } from './types';
package/src/types.ts CHANGED
@@ -1,9 +1,6 @@
1
1
  import { Id, ToastOptions as RtToastOptions } from 'react-toastify';
2
2
 
3
- import { ValueOf } from '@snack-uikit/utils';
4
-
5
3
  import { ToasterContainerProps, ToastSystemEventProps, ToastUserActionProps } from './components';
6
- import { TOASTER_TYPE } from './constants';
7
4
 
8
5
  export type ToasterId = Id;
9
6
  export type PromisedId = Promise<ToasterId>;
@@ -14,11 +11,14 @@ export type ToastOptions = {
14
11
  onClose?(id?: ToasterId): void;
15
12
  };
16
13
 
17
- export type ToasterType = ValueOf<typeof TOASTER_TYPE>;
14
+ export enum ToasterType {
15
+ SystemEvent = 'system-event',
16
+ UserAction = 'user-action',
17
+ }
18
18
 
19
19
  export type ToasterPropsMap = {
20
- [TOASTER_TYPE.UserAction]: ToastUserActionProps;
21
- [TOASTER_TYPE.SystemEvent]: ToastSystemEventProps;
20
+ [ToasterType.UserAction]: ToastUserActionProps;
21
+ [ToasterType.SystemEvent]: ToastSystemEventProps;
22
22
  };
23
23
 
24
24
  type OpenNotificationProps<T extends keyof ToasterPropsMap> = {