@snack-uikit/alert 0.12.0 → 0.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.
- package/CHANGELOG.md +27 -0
- package/README.md +2 -2
- package/dist/components/Alert/Alert.d.ts +1 -1
- package/dist/components/Alert/Alert.js +1 -1
- package/dist/components/AlertTop/AlertTop.d.ts +1 -1
- package/dist/components/AlertTop/AlertTop.js +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +5 -5
- package/package.json +3 -3
- package/src/components/Alert/Alert.tsx +2 -3
- package/src/components/AlertTop/AlertTop.tsx +2 -3
- package/src/utils.tsx +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,33 @@
|
|
|
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.13.0 (2024-08-02)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **FF-3788:** updated typescript to v5 ([89e3338](https://github.com/cloud-ru-tech/snack-uikit/commit/89e3338a3ef4df24e4c20d9a9c8cd16e7934ba63))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### BREAKING CHANGES
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
* **PDS-349:** link property external deleted ([fe15016](https://github.com/cloud-ru-tech/snack-uikit/commit/fe150162c9a6bdec5d43dabe1e1a8296ddbe0cd4))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## 0.12.1 (2024-07-29)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* **FF-00:** change icon size for size='s' ([17923a9](https://github.com/cloud-ru-tech/snack-uikit/commit/17923a99dbadb946c3ba0e67c2415fc82a4fb3d0))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
6
33
|
# 0.12.0 (2024-07-24)
|
|
7
34
|
|
|
8
35
|
|
package/README.md
CHANGED
|
@@ -58,7 +58,7 @@ import { InfoFilledSVG } from '@snack-uikit/icons';
|
|
|
58
58
|
| icon | `boolean` | true | Отображать иконку |
|
|
59
59
|
| title | `string` | - | Заголовок |
|
|
60
60
|
| truncate | `{ title?: number; }` | '{ <br>title: 1 }' | Максимальное кол-во строк <br> - `title` - в заголовке |
|
|
61
|
-
| link | `Pick<LinkProps, "text" \| "target" \| "onClick" \| "href" \| "appearance"
|
|
61
|
+
| link | `Pick<LinkProps, "text" \| "target" \| "onClick" \| "href" \| "appearance">` | - | Cсылка |
|
|
62
62
|
| onClose | `() => void` | - | Колбек закрытия |
|
|
63
63
|
| appearance | enum Appearance: `"neutral"`, `"primary"`, `"error"`, `"warning"`, `"success"`, `"info"` | neutral | Внешний вид |
|
|
64
64
|
| outline | `boolean` | - | Внешний бордер |
|
|
@@ -74,7 +74,7 @@ import { InfoFilledSVG } from '@snack-uikit/icons';
|
|
|
74
74
|
| icon | `boolean` | true | Отображать иконку |
|
|
75
75
|
| title | `string` | - | Заголовок |
|
|
76
76
|
| truncate | `{ title?: number; }` | '{ <br>title: 1 }' | Максимальное кол-во строк <br> - `title` - в заголовке |
|
|
77
|
-
| link | `Pick<LinkProps, "text" \| "target" \| "onClick" \| "href" \| "appearance"
|
|
77
|
+
| link | `Pick<LinkProps, "text" \| "target" \| "onClick" \| "href" \| "appearance">` | - | Cсылка |
|
|
78
78
|
| action | `AlertButtonProps` | - | Кнопка дополнительного действия |
|
|
79
79
|
| onClose | `() => void` | - | Колбек закрытия |
|
|
80
80
|
| appearance | enum Appearance: `"neutral"`, `"primary"`, `"error"`, `"warning"`, `"success"`, `"info"` | neutral | Внешний вид |
|
|
@@ -19,7 +19,7 @@ export type AlertProps = WithSupportProps<{
|
|
|
19
19
|
/** Описание */
|
|
20
20
|
description: ReactNode;
|
|
21
21
|
/** Cсылка */
|
|
22
|
-
link?: Pick<LinkProps, 'text' | 'target' | 'onClick' | 'href' | 'appearance'
|
|
22
|
+
link?: Pick<LinkProps, 'text' | 'target' | 'onClick' | 'href' | 'appearance'>;
|
|
23
23
|
/** Колбек закрытия */
|
|
24
24
|
onClose?: () => void;
|
|
25
25
|
/** Внешний вид */
|
|
@@ -27,5 +27,5 @@ export function Alert(_a) {
|
|
|
27
27
|
var { icon = true, title, truncate, link, description, onClose, appearance = APPEARANCE.Neutral, className, actions, outline, size = 'm' } = _a, rest = __rest(_a, ["icon", "title", "truncate", "link", "description", "onClose", "appearance", "className", "actions", "outline", "size"]);
|
|
28
28
|
return (_jsxs("div", Object.assign({ className: cn(styles.alert, {
|
|
29
29
|
[styles.alertOutline]: outline,
|
|
30
|
-
}, className) }, extractSupportProps(rest), { "data-color": APPEARANCE_TO_COLOR_MAP[appearance], "data-size": size, children: [_jsxs("div", { className: styles.body, "data-size": size, children: [icon && (_jsx("div", { className: styles.icon, "data-color": APPEARANCE_TO_COLOR_MAP[appearance], "data-test-id": 'alert__icon', "data-size": size, children: getIcon(appearance) })), _jsxs("div", { className: styles.contentLayout, children: [title && (_jsx(TruncateString, { text: title, maxLines: (_b = truncate === null || truncate === void 0 ? void 0 : truncate.title) !== null && _b !== void 0 ? _b : 1, className: styles.title, "data-test-id": 'alert__title', "data-size": size })), _jsx("span", { "data-test-id": 'alert__description', className: styles.description, "data-size": size, children: description }), link && (_jsx("span", { children: _jsx(Link, Object.assign({
|
|
30
|
+
}, className) }, extractSupportProps(rest), { "data-color": APPEARANCE_TO_COLOR_MAP[appearance], "data-size": size, children: [_jsxs("div", { className: styles.body, "data-size": size, children: [icon && (_jsx("div", { className: styles.icon, "data-color": APPEARANCE_TO_COLOR_MAP[appearance], "data-test-id": 'alert__icon', "data-size": size, children: getIcon(appearance, size === 's' ? 16 : 24) })), _jsxs("div", { className: styles.contentLayout, children: [title && (_jsx(TruncateString, { text: title, maxLines: (_b = truncate === null || truncate === void 0 ? void 0 : truncate.title) !== null && _b !== void 0 ? _b : 1, className: styles.title, "data-test-id": 'alert__title', "data-size": size })), _jsx("span", { "data-test-id": 'alert__description', className: styles.description, "data-size": size, children: description }), link && (_jsx("span", { children: _jsx(Link, Object.assign({}, link, { appearance: APPEARANCE_TO_COLOR_MAP[appearance], textMode: 'default', size: size, "data-test-id": 'alert__link' })) }))] }), onClose && (_jsx(AlertButton, { onClick: onClose, appearance: APPEARANCE_TO_COLOR_MAP[appearance], icon: _jsx(CrossSVG, {}), variant: 'simple', dataTestId: 'alert__close-button' }))] }), actions && (_jsxs("div", { className: styles.footer, "data-size": size, children: [actions.primary && (_jsx(AlertButton, Object.assign({}, actions.primary, { appearance: APPEARANCE_TO_COLOR_MAP[appearance], variant: 'simple', size: size }))), (actions === null || actions === void 0 ? void 0 : actions.secondary) && (_jsx(AlertButton, Object.assign({}, actions.secondary, { appearance: APPEARANCE_TO_COLOR_MAP[appearance], variant: 'simple', size: size })))] }))] })));
|
|
31
31
|
}
|
|
@@ -19,7 +19,7 @@ export type AlertTopProps = WithSupportProps<{
|
|
|
19
19
|
/** Описание */
|
|
20
20
|
description: ReactNode;
|
|
21
21
|
/** Cсылка */
|
|
22
|
-
link?: Pick<LinkProps, 'text' | 'target' | 'onClick' | 'href' | 'appearance'
|
|
22
|
+
link?: Pick<LinkProps, 'text' | 'target' | 'onClick' | 'href' | 'appearance'>;
|
|
23
23
|
/** Кнопка дополнительного действия */
|
|
24
24
|
action?: AlertButtonProps;
|
|
25
25
|
/** Колбек закрытия */
|
|
@@ -26,5 +26,5 @@ import styles from './styles.module.css';
|
|
|
26
26
|
export function AlertTop(_a) {
|
|
27
27
|
var _b;
|
|
28
28
|
var { icon = true, title, description, link, onClose, truncate, appearance = APPEARANCE.Neutral, action, className } = _a, rest = __rest(_a, ["icon", "title", "description", "link", "onClose", "truncate", "appearance", "action", "className"]);
|
|
29
|
-
return (_jsxs("div", Object.assign({ className: cn(styles.alertTop, className) }, extractSupportProps(rest), { "data-color": APPEARANCE_TO_COLOR_MAP_INVERT[appearance], children: [_jsxs("div", { className: styles.contentWrapper, children: [icon && (_jsx("div", { className: styles.icon, "data-color": APPEARANCE_TO_COLOR_MAP_INVERT[appearance], "data-test-id": 'alert-top__icon', children: getIcon(appearance) })), _jsxs("div", { className: styles.contentLayout, children: [_jsxs("div", { className: styles.textLayout, children: [title && (_jsx("div", { className: styles.title, "data-color": APPEARANCE_TO_COLOR_MAP_INVERT[appearance], "data-test-id": 'alert-top__title', children: _jsx(TruncateString, { text: title, maxLines: (_b = truncate === null || truncate === void 0 ? void 0 : truncate.title) !== null && _b !== void 0 ? _b : 1 }) })), _jsx("span", { className: styles.description, "data-color": APPEARANCE_TO_COLOR_MAP_INVERT[appearance], "data-test-id": 'alert-top__description', children: description })] }), link && (_jsx("span", { children: _jsx(Link, Object.assign({
|
|
29
|
+
return (_jsxs("div", Object.assign({ className: cn(styles.alertTop, className) }, extractSupportProps(rest), { "data-color": APPEARANCE_TO_COLOR_MAP_INVERT[appearance], children: [_jsxs("div", { className: styles.contentWrapper, children: [icon && (_jsx("div", { className: styles.icon, "data-color": APPEARANCE_TO_COLOR_MAP_INVERT[appearance], "data-test-id": 'alert-top__icon', children: getIcon(appearance, 24) })), _jsxs("div", { className: styles.contentLayout, children: [_jsxs("div", { className: styles.textLayout, children: [title && (_jsx("div", { className: styles.title, "data-color": APPEARANCE_TO_COLOR_MAP_INVERT[appearance], "data-test-id": 'alert-top__title', children: _jsx(TruncateString, { text: title, maxLines: (_b = truncate === null || truncate === void 0 ? void 0 : truncate.title) !== null && _b !== void 0 ? _b : 1 }) })), _jsx("span", { className: styles.description, "data-color": APPEARANCE_TO_COLOR_MAP_INVERT[appearance], "data-test-id": 'alert-top__description', children: description })] }), link && (_jsx("span", { children: _jsx(Link, Object.assign({}, link, { appearance: APPEARANCE_TO_COLOR_MAP[appearance], textMode: 'on-accent', size: 'm', "data-test-id": 'alert-top__link' })) }))] })] }), _jsxs("div", { className: styles.actions, children: [action && _jsx(AlertButton, Object.assign({}, action, { appearance: APPEARANCE_TO_COLOR_MAP_INVERT[appearance], variant: 'tonal' })), onClose && (_jsx(AlertButton, { onClick: onClose, appearance: APPEARANCE_TO_COLOR_MAP_INVERT[appearance], icon: _jsx(CrossSVG, {}), variant: 'tonal', dataTestId: 'alert-top__close-button' }))] })] })));
|
|
30
30
|
}
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Appearance } from './types';
|
|
2
|
-
export declare function getIcon(appearance: Appearance): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare function getIcon(appearance: Appearance, size: number): import("react/jsx-runtime").JSX.Element;
|
package/dist/utils.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { AlarmFilledSVG, CheckFilledSVG, CrossFilledSVG, InfoFilledSVG } from '@snack-uikit/icons';
|
|
3
3
|
import { APPEARANCE } from './constants';
|
|
4
|
-
export function getIcon(appearance) {
|
|
4
|
+
export function getIcon(appearance, size) {
|
|
5
5
|
switch (appearance) {
|
|
6
6
|
case APPEARANCE.Success:
|
|
7
|
-
return _jsx(CheckFilledSVG, {});
|
|
7
|
+
return _jsx(CheckFilledSVG, { size: size });
|
|
8
8
|
case APPEARANCE.Error:
|
|
9
|
-
return _jsx(CrossFilledSVG, {});
|
|
9
|
+
return _jsx(CrossFilledSVG, { size: size });
|
|
10
10
|
case APPEARANCE.Warning:
|
|
11
|
-
return _jsx(AlarmFilledSVG, {});
|
|
11
|
+
return _jsx(AlarmFilledSVG, { size: size });
|
|
12
12
|
case APPEARANCE.Primary:
|
|
13
13
|
case APPEARANCE.Neutral:
|
|
14
14
|
default:
|
|
15
|
-
return _jsx(InfoFilledSVG, {});
|
|
15
|
+
return _jsx(InfoFilledSVG, { size: size });
|
|
16
16
|
}
|
|
17
17
|
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Alert",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.13.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.22.0",
|
|
36
|
-
"@snack-uikit/link": "0.
|
|
36
|
+
"@snack-uikit/link": "0.13.0",
|
|
37
37
|
"@snack-uikit/loaders": "0.5.2",
|
|
38
38
|
"@snack-uikit/truncate-string": "0.4.20",
|
|
39
39
|
"@snack-uikit/utils": "3.3.0",
|
|
40
40
|
"classnames": "2.3.2"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "86e5b8fc3a6235eddccf75485b6e989b6baf9a86"
|
|
43
43
|
}
|
|
@@ -28,7 +28,7 @@ export type AlertProps = WithSupportProps<{
|
|
|
28
28
|
/** Описание */
|
|
29
29
|
description: ReactNode;
|
|
30
30
|
/** Cсылка */
|
|
31
|
-
link?: Pick<LinkProps, 'text' | 'target' | 'onClick' | 'href' | 'appearance'
|
|
31
|
+
link?: Pick<LinkProps, 'text' | 'target' | 'onClick' | 'href' | 'appearance'>;
|
|
32
32
|
/** Колбек закрытия */
|
|
33
33
|
onClose?: () => void;
|
|
34
34
|
/** Внешний вид */
|
|
@@ -84,7 +84,7 @@ export function Alert({
|
|
|
84
84
|
data-test-id='alert__icon'
|
|
85
85
|
data-size={size}
|
|
86
86
|
>
|
|
87
|
-
{getIcon(appearance)}
|
|
87
|
+
{getIcon(appearance, size === 's' ? 16 : 24)}
|
|
88
88
|
</div>
|
|
89
89
|
)}
|
|
90
90
|
|
|
@@ -106,7 +106,6 @@ export function Alert({
|
|
|
106
106
|
{link && (
|
|
107
107
|
<span>
|
|
108
108
|
<Link
|
|
109
|
-
external
|
|
110
109
|
{...link}
|
|
111
110
|
appearance={APPEARANCE_TO_COLOR_MAP[appearance]}
|
|
112
111
|
textMode='default'
|
|
@@ -29,7 +29,7 @@ export type AlertTopProps = WithSupportProps<{
|
|
|
29
29
|
/** Описание */
|
|
30
30
|
description: ReactNode;
|
|
31
31
|
/** Cсылка */
|
|
32
|
-
link?: Pick<LinkProps, 'text' | 'target' | 'onClick' | 'href' | 'appearance'
|
|
32
|
+
link?: Pick<LinkProps, 'text' | 'target' | 'onClick' | 'href' | 'appearance'>;
|
|
33
33
|
/** Кнопка дополнительного действия */
|
|
34
34
|
action?: AlertButtonProps;
|
|
35
35
|
/** Колбек закрытия */
|
|
@@ -68,7 +68,7 @@ export function AlertTop({
|
|
|
68
68
|
data-color={APPEARANCE_TO_COLOR_MAP_INVERT[appearance]}
|
|
69
69
|
data-test-id='alert-top__icon'
|
|
70
70
|
>
|
|
71
|
-
{getIcon(appearance)}
|
|
71
|
+
{getIcon(appearance, 24)}
|
|
72
72
|
</div>
|
|
73
73
|
)}
|
|
74
74
|
|
|
@@ -96,7 +96,6 @@ export function AlertTop({
|
|
|
96
96
|
{link && (
|
|
97
97
|
<span>
|
|
98
98
|
<Link
|
|
99
|
-
external
|
|
100
99
|
{...link}
|
|
101
100
|
appearance={APPEARANCE_TO_COLOR_MAP[appearance]}
|
|
102
101
|
textMode='on-accent'
|
package/src/utils.tsx
CHANGED
|
@@ -3,17 +3,17 @@ import { AlarmFilledSVG, CheckFilledSVG, CrossFilledSVG, InfoFilledSVG } from '@
|
|
|
3
3
|
import { APPEARANCE } from './constants';
|
|
4
4
|
import { Appearance } from './types';
|
|
5
5
|
|
|
6
|
-
export function getIcon(appearance: Appearance) {
|
|
6
|
+
export function getIcon(appearance: Appearance, size: number) {
|
|
7
7
|
switch (appearance) {
|
|
8
8
|
case APPEARANCE.Success:
|
|
9
|
-
return <CheckFilledSVG />;
|
|
9
|
+
return <CheckFilledSVG size={size} />;
|
|
10
10
|
case APPEARANCE.Error:
|
|
11
|
-
return <CrossFilledSVG />;
|
|
11
|
+
return <CrossFilledSVG size={size} />;
|
|
12
12
|
case APPEARANCE.Warning:
|
|
13
|
-
return <AlarmFilledSVG />;
|
|
13
|
+
return <AlarmFilledSVG size={size} />;
|
|
14
14
|
case APPEARANCE.Primary:
|
|
15
15
|
case APPEARANCE.Neutral:
|
|
16
16
|
default:
|
|
17
|
-
return <InfoFilledSVG />;
|
|
17
|
+
return <InfoFilledSVG size={size} />;
|
|
18
18
|
}
|
|
19
19
|
}
|