@snack-uikit/toaster 0.4.1 → 0.5.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/CHANGELOG.md +11 -0
- package/README.md +6 -18
- package/dist/components/ToastSystemEvent/ToastSystemEvent.js +1 -3
- package/dist/components/ToastSystemEvent/constants.d.ts +5 -6
- package/dist/components/ToastSystemEvent/constants.js +6 -6
- package/dist/components/ToastUserAction/ToastUserAction.js +1 -1
- package/package.json +5 -5
- package/src/components/ToastSystemEvent/ToastSystemEvent.tsx +2 -6
- package/src/components/ToastSystemEvent/constants.ts +6 -6
- package/src/components/ToastUserAction/ToastUserAction.tsx +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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.5.0 (2023-12-14)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### BREAKING CHANGES
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
* **FF-3729:** replace enum with unions ([910db4a](https://github.com/cloud-ru-tech/snack-uikit/commit/910db4aa8231ccbc58e538e5c5c1f461b1dec275))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## 0.4.1 (2023-12-06)
|
|
7
18
|
|
|
8
19
|
### Only dependencies have been changed
|
package/README.md
CHANGED
|
@@ -36,14 +36,6 @@ toaster.systemEvent.dismiss(systemEventId);
|
|
|
36
36
|
## Props
|
|
37
37
|
|
|
38
38
|
```typescript jsx
|
|
39
|
-
|
|
40
|
-
enum ToastUserActionAppearance {
|
|
41
|
-
Neutral = 'neutral',
|
|
42
|
-
Success = 'success',
|
|
43
|
-
Error = 'error',
|
|
44
|
-
Warning = 'warning',
|
|
45
|
-
}
|
|
46
|
-
|
|
47
39
|
type ToastUserActionLink = {
|
|
48
40
|
text: string;
|
|
49
41
|
href: string;
|
|
@@ -53,24 +45,20 @@ type ToastUserActionLink = {
|
|
|
53
45
|
type ToastUserActionProps = Partial<RtToastContentProps> &
|
|
54
46
|
WithSupportProps<{
|
|
55
47
|
label: string;
|
|
56
|
-
appearance?: ToastUserActionAppearance;
|
|
57
48
|
link?: ToastUserActionLink;
|
|
58
49
|
className?: string;
|
|
59
50
|
}>;
|
|
60
51
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
Success = 'success',
|
|
67
|
-
}
|
|
52
|
+
type ToastSystemEventLink = {
|
|
53
|
+
text: string;
|
|
54
|
+
href: string;
|
|
55
|
+
onClick?(e: MouseEvent<HTMLAnchorElement>): void;
|
|
56
|
+
};
|
|
68
57
|
|
|
69
58
|
type ToastSystemEventProps = Partial<RtToastContentProps> &
|
|
70
59
|
WithSupportProps<{
|
|
71
60
|
title: string;
|
|
72
61
|
description?: string;
|
|
73
|
-
appearance?: ToastSystemEventAppearance;
|
|
74
62
|
link?: ToastSystemEventLink;
|
|
75
63
|
progressBar?: boolean;
|
|
76
64
|
closable?: boolean;
|
|
@@ -81,4 +69,4 @@ type ToastSystemEventProps = Partial<RtToastContentProps> &
|
|
|
81
69
|
|
|
82
70
|
### TODO
|
|
83
71
|
|
|
84
|
-
- Translations
|
|
72
|
+
- Translations
|
|
@@ -29,8 +29,6 @@ export function ToastSystemEvent(_a) {
|
|
|
29
29
|
onCloseClick ? onCloseClick(e, closeToast) : closeToast === null || closeToast === void 0 ? void 0 : closeToast();
|
|
30
30
|
};
|
|
31
31
|
const icon = useMemo(() => getIcon(appearance), [appearance]);
|
|
32
|
-
return (_jsxs("div", Object.assign({ className: cn(styles.container, className) }, extractSupportProps(rest), { "data-appearance": appearance }, { children: [_jsx("div", Object.assign({ className: styles.icon }, { children: icon })), _jsxs("div", Object.assign({ className: styles.content }, { children: [_jsxs("div", { children: [_jsx("span", Object.assign({ className: styles.title }, { children: _jsx(TruncateString, { text: title, maxLines: 1, hideTooltip: true, "data-test-id": TOAST_SYSTEM_EVENT_TEST_IDS.title }) })), description && (_jsx("span", Object.assign({ 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:
|
|
33
|
-
? Link.onSurfaces.Accent
|
|
34
|
-
: Link.onSurfaces.Background }))] })), closable && (_jsx("button", Object.assign({ 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` } }))] })));
|
|
32
|
+
return (_jsxs("div", Object.assign({ className: cn(styles.container, className) }, extractSupportProps(rest), { "data-appearance": appearance }, { children: [_jsx("div", Object.assign({ className: styles.icon }, { children: icon })), _jsxs("div", Object.assign({ className: styles.content }, { children: [_jsxs("div", { children: [_jsx("span", Object.assign({ className: styles.title }, { children: _jsx(TruncateString, { text: title, maxLines: 1, hideTooltip: true, "data-test-id": TOAST_SYSTEM_EVENT_TEST_IDS.title }) })), description && (_jsx("span", Object.assign({ 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, onColor: APPEARANCE_TO_ON_COLOR_MAP[appearance], "data-test-id": TOAST_SYSTEM_EVENT_TEST_IDS.link, onSurface: appearance === ToastSystemEventAppearance.ErrorCritical ? 'accent' : 'background' }))] })), closable && (_jsx("button", Object.assign({ 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` } }))] })));
|
|
35
33
|
}
|
|
36
34
|
ToastSystemEvent.appearances = ToastSystemEventAppearance;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { OnColor } from '@snack-uikit/link';
|
|
2
1
|
export declare enum ToastSystemEventAppearance {
|
|
3
2
|
Neutral = "neutral",
|
|
4
3
|
Error = "error",
|
|
@@ -7,9 +6,9 @@ export declare enum ToastSystemEventAppearance {
|
|
|
7
6
|
Success = "success"
|
|
8
7
|
}
|
|
9
8
|
export declare const APPEARANCE_TO_ON_COLOR_MAP: {
|
|
10
|
-
readonly neutral:
|
|
11
|
-
readonly error:
|
|
12
|
-
readonly errorCritical:
|
|
13
|
-
readonly warning:
|
|
14
|
-
readonly success:
|
|
9
|
+
readonly neutral: "invert-neutral";
|
|
10
|
+
readonly error: "invert-neutral";
|
|
11
|
+
readonly errorCritical: "red";
|
|
12
|
+
readonly warning: "invert-neutral";
|
|
13
|
+
readonly success: "invert-neutral";
|
|
15
14
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ON_COLOR } from '@snack-uikit/link';
|
|
2
2
|
export var ToastSystemEventAppearance;
|
|
3
3
|
(function (ToastSystemEventAppearance) {
|
|
4
4
|
ToastSystemEventAppearance["Neutral"] = "neutral";
|
|
@@ -8,9 +8,9 @@ export var ToastSystemEventAppearance;
|
|
|
8
8
|
ToastSystemEventAppearance["Success"] = "success";
|
|
9
9
|
})(ToastSystemEventAppearance || (ToastSystemEventAppearance = {}));
|
|
10
10
|
export const APPEARANCE_TO_ON_COLOR_MAP = {
|
|
11
|
-
[ToastSystemEventAppearance.Neutral]:
|
|
12
|
-
[ToastSystemEventAppearance.Error]:
|
|
13
|
-
[ToastSystemEventAppearance.ErrorCritical]:
|
|
14
|
-
[ToastSystemEventAppearance.Warning]:
|
|
15
|
-
[ToastSystemEventAppearance.Success]:
|
|
11
|
+
[ToastSystemEventAppearance.Neutral]: ON_COLOR.InvertNeutral,
|
|
12
|
+
[ToastSystemEventAppearance.Error]: ON_COLOR.InvertNeutral,
|
|
13
|
+
[ToastSystemEventAppearance.ErrorCritical]: ON_COLOR.Red,
|
|
14
|
+
[ToastSystemEventAppearance.Warning]: ON_COLOR.InvertNeutral,
|
|
15
|
+
[ToastSystemEventAppearance.Success]: ON_COLOR.InvertNeutral,
|
|
16
16
|
};
|
|
@@ -21,6 +21,6 @@ import { getIcon } from './utils';
|
|
|
21
21
|
export function ToastUserAction(_a) {
|
|
22
22
|
var { appearance = ToastUserActionAppearance.Neutral, label, link, className } = _a, rest = __rest(_a, ["appearance", "label", "link", "className"]);
|
|
23
23
|
const icon = useMemo(() => getIcon(appearance), [appearance]);
|
|
24
|
-
return (_jsxs("div", Object.assign({ className: cn(styles.container, className) }, extractSupportProps(rest), { "data-appearance": appearance, "data-variant": icon ? Variant.WithIcon : Variant.LabelOnly }, { children: [_jsxs("div", Object.assign({ className: styles.content }, { children: [icon && (_jsx("span", Object.assign({ className: styles.icon, "data-test-id": TOAST_USER_ACTION_TEST_IDS.icon }, { children: icon }))), _jsx("span", Object.assign({ className: styles.label, "data-test-id": TOAST_USER_ACTION_TEST_IDS.label }, { children: label }))] })), link && (_jsx(Link, { size:
|
|
24
|
+
return (_jsxs("div", Object.assign({ className: cn(styles.container, className) }, extractSupportProps(rest), { "data-appearance": appearance, "data-variant": icon ? Variant.WithIcon : Variant.LabelOnly }, { children: [_jsxs("div", Object.assign({ className: styles.content }, { children: [icon && (_jsx("span", Object.assign({ className: styles.icon, "data-test-id": TOAST_USER_ACTION_TEST_IDS.icon }, { children: icon }))), _jsx("span", Object.assign({ className: styles.label, "data-test-id": TOAST_USER_ACTION_TEST_IDS.label }, { children: label }))] })), link && (_jsx(Link, { size: 'm', text: link.text, href: link.href, onClick: link.onClick, onColor: 'invert-neutral', "data-test-id": TOAST_USER_ACTION_TEST_IDS.link }))] })));
|
|
25
25
|
}
|
|
26
26
|
ToastUserAction.appearances = ToastUserActionAppearance;
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Toaster",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.5.0",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
"scripts": {},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@snack-uikit/icons": "0.19.0",
|
|
36
|
-
"@snack-uikit/link": "0.
|
|
37
|
-
"@snack-uikit/truncate-string": "0.
|
|
38
|
-
"@snack-uikit/utils": "3.
|
|
36
|
+
"@snack-uikit/link": "0.9.0",
|
|
37
|
+
"@snack-uikit/truncate-string": "0.4.0",
|
|
38
|
+
"@snack-uikit/utils": "3.2.0",
|
|
39
39
|
"classnames": "2.3.2",
|
|
40
40
|
"react-toastify": "9.1.3"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "bd39c5e674f3b91b0e2487782a04b15034cf3d8b"
|
|
43
43
|
}
|
|
@@ -77,15 +77,11 @@ export function ToastSystemEvent({
|
|
|
77
77
|
<Link
|
|
78
78
|
text={link.text}
|
|
79
79
|
href={link.href}
|
|
80
|
-
size=
|
|
80
|
+
size='m'
|
|
81
81
|
onClick={link.onClick}
|
|
82
82
|
onColor={APPEARANCE_TO_ON_COLOR_MAP[appearance]}
|
|
83
83
|
data-test-id={TOAST_SYSTEM_EVENT_TEST_IDS.link}
|
|
84
|
-
onSurface={
|
|
85
|
-
appearance === ToastSystemEventAppearance.ErrorCritical
|
|
86
|
-
? Link.onSurfaces.Accent
|
|
87
|
-
: Link.onSurfaces.Background
|
|
88
|
-
}
|
|
84
|
+
onSurface={appearance === ToastSystemEventAppearance.ErrorCritical ? 'accent' : 'background'}
|
|
89
85
|
/>
|
|
90
86
|
)}
|
|
91
87
|
</div>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ON_COLOR } from '@snack-uikit/link';
|
|
2
2
|
|
|
3
3
|
export enum ToastSystemEventAppearance {
|
|
4
4
|
Neutral = 'neutral',
|
|
@@ -9,9 +9,9 @@ export enum ToastSystemEventAppearance {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export const APPEARANCE_TO_ON_COLOR_MAP = {
|
|
12
|
-
[ToastSystemEventAppearance.Neutral]:
|
|
13
|
-
[ToastSystemEventAppearance.Error]:
|
|
14
|
-
[ToastSystemEventAppearance.ErrorCritical]:
|
|
15
|
-
[ToastSystemEventAppearance.Warning]:
|
|
16
|
-
[ToastSystemEventAppearance.Success]:
|
|
12
|
+
[ToastSystemEventAppearance.Neutral]: ON_COLOR.InvertNeutral,
|
|
13
|
+
[ToastSystemEventAppearance.Error]: ON_COLOR.InvertNeutral,
|
|
14
|
+
[ToastSystemEventAppearance.ErrorCritical]: ON_COLOR.Red,
|
|
15
|
+
[ToastSystemEventAppearance.Warning]: ON_COLOR.InvertNeutral,
|
|
16
|
+
[ToastSystemEventAppearance.Success]: ON_COLOR.InvertNeutral,
|
|
17
17
|
} as const;
|
|
@@ -53,11 +53,11 @@ export function ToastUserAction({
|
|
|
53
53
|
|
|
54
54
|
{link && (
|
|
55
55
|
<Link
|
|
56
|
-
size=
|
|
56
|
+
size='m'
|
|
57
57
|
text={link.text}
|
|
58
58
|
href={link.href}
|
|
59
59
|
onClick={link.onClick}
|
|
60
|
-
onColor=
|
|
60
|
+
onColor='invert-neutral'
|
|
61
61
|
data-test-id={TOAST_USER_ACTION_TEST_IDS.link}
|
|
62
62
|
/>
|
|
63
63
|
)}
|