@snack-uikit/notification 0.13.17 → 0.13.19
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 +16 -0
- package/README.md +2 -2
- package/dist/cjs/components/NotificationCard/NotificationCard.js +5 -13
- package/dist/cjs/components/NotificationCard/styles.module.css +15 -6
- package/dist/cjs/components/NotificationPanel/NotificationPanel.d.ts +6 -5
- package/dist/cjs/components/NotificationPanel/NotificationPanel.js +26 -22
- package/dist/cjs/components/NotificationPanel/components/NotificationPanelDivider/styles.module.css +1 -0
- package/dist/cjs/components/NotificationPanel/constants.d.ts +1 -1
- package/dist/cjs/components/NotificationPanel/constants.js +1 -1
- package/dist/cjs/components/NotificationPanel/helperComponents/WithTooltip/WithTooltip.d.ts +7 -0
- package/dist/cjs/components/NotificationPanel/helperComponents/WithTooltip/WithTooltip.js +20 -0
- package/dist/cjs/components/NotificationPanel/helperComponents/WithTooltip/index.d.ts +1 -0
- package/dist/cjs/components/NotificationPanel/helperComponents/WithTooltip/index.js +25 -0
- package/dist/cjs/components/NotificationPanel/helperComponents/index.d.ts +1 -0
- package/dist/cjs/components/NotificationPanel/helperComponents/index.js +25 -0
- package/dist/cjs/components/NotificationPanel/styles.module.css +11 -21
- package/dist/esm/components/NotificationCard/NotificationCard.js +2 -6
- package/dist/esm/components/NotificationCard/styles.module.css +15 -6
- package/dist/esm/components/NotificationPanel/NotificationPanel.d.ts +6 -5
- package/dist/esm/components/NotificationPanel/NotificationPanel.js +4 -4
- package/dist/esm/components/NotificationPanel/components/NotificationPanelDivider/styles.module.css +1 -0
- package/dist/esm/components/NotificationPanel/constants.d.ts +1 -1
- package/dist/esm/components/NotificationPanel/constants.js +1 -1
- package/dist/esm/components/NotificationPanel/helperComponents/WithTooltip/WithTooltip.d.ts +7 -0
- package/dist/esm/components/NotificationPanel/helperComponents/WithTooltip/WithTooltip.js +8 -0
- package/dist/esm/components/NotificationPanel/helperComponents/WithTooltip/index.d.ts +1 -0
- package/dist/esm/components/NotificationPanel/helperComponents/WithTooltip/index.js +1 -0
- package/dist/esm/components/NotificationPanel/helperComponents/index.d.ts +1 -0
- package/dist/esm/components/NotificationPanel/helperComponents/index.js +1 -0
- package/dist/esm/components/NotificationPanel/styles.module.css +11 -21
- package/package.json +4 -3
- package/src/components/NotificationCard/NotificationCard.tsx +6 -27
- package/src/components/NotificationCard/styles.module.scss +19 -9
- package/src/components/NotificationPanel/NotificationPanel.tsx +31 -24
- package/src/components/NotificationPanel/components/NotificationPanelDivider/styles.module.scss +1 -0
- package/src/components/NotificationPanel/constants.ts +1 -1
- package/src/components/NotificationPanel/helperComponents/WithTooltip/WithTooltip.tsx +15 -0
- package/src/components/NotificationPanel/helperComponents/WithTooltip/index.ts +1 -0
- package/src/components/NotificationPanel/helperComponents/index.ts +1 -0
- package/src/components/NotificationPanel/styles.module.scss +11 -26
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
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
|
+
## <small>0.13.19 (2025-10-29)</small>
|
|
7
|
+
|
|
8
|
+
* fix(PDS-2914): removed extra div ([636b983](https://github.com/cloud-ru-tech/snack-uikit/commit/636b983))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## <small>0.13.18 (2025-10-29)</small>
|
|
15
|
+
|
|
16
|
+
* feat(PDS-2914): chips changed to segments ([833f610](https://github.com/cloud-ru-tech/snack-uikit/commit/833f610))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
## <small>0.13.17 (2025-10-28)</small>
|
|
7
23
|
|
|
8
24
|
### Only dependencies have been changed
|
package/README.md
CHANGED
|
@@ -102,8 +102,8 @@ const cards = [
|
|
|
102
102
|
|------|------|---------------|-------------|
|
|
103
103
|
| title* | `string` | - | Заголовок панели |
|
|
104
104
|
| settings | `NotificationPanelSettingsProps` | - | Кнопка настроек и выпадающий список |
|
|
105
|
-
|
|
|
106
|
-
| readAllButton | `Omit<ButtonFunctionProps,
|
|
105
|
+
| segments | `Omit<SegmentedControlProps, "size" \| "data-test-id">` | - | Сегменты для фильтрации |
|
|
106
|
+
| readAllButton | `Omit<ButtonFunctionProps, 'data-test-id'> & { tooltip?: TooltipProps; }` | - | Кнопка в "шапке" панели |
|
|
107
107
|
| footerButton | `{ label: string; onClick: MouseEventHandler<HTMLButtonElement>; }` | - | Кнопка внизу панели |
|
|
108
108
|
| className | `string` | - | CSS-класс |
|
|
109
109
|
| loading | `boolean` | - | Состояние загрузки |
|
|
@@ -48,15 +48,7 @@ function NotificationCard(_a) {
|
|
|
48
48
|
className
|
|
49
49
|
} = _a,
|
|
50
50
|
rest = __rest(_a, ["id", "appearance", "label", "unread", "title", "content", "link", "date", "onClick", "primaryButton", "secondaryButton", "actions", "onVisible", "className"]);
|
|
51
|
-
const
|
|
52
|
-
icon,
|
|
53
|
-
linkOnColor,
|
|
54
|
-
buttonAppearance
|
|
55
|
-
} = (0, react_1.useMemo)(() => ({
|
|
56
|
-
icon: (0, helpers_1.getIcon)(appearance),
|
|
57
|
-
linkOnColor: appearance === constants_1.APPEARANCE.ErrorCritical ? 'red' : undefined,
|
|
58
|
-
buttonAppearance: appearance === constants_1.APPEARANCE.ErrorCritical ? 'destructive' : 'primary'
|
|
59
|
-
}), [appearance]);
|
|
51
|
+
const icon = (0, react_1.useMemo)(() => (0, helpers_1.getIcon)(appearance), [appearance]);
|
|
60
52
|
const [isDroplistOpen, setDroplistOpen] = (0, react_1.useState)(false);
|
|
61
53
|
const cardRef = (0, react_1.useRef)(null);
|
|
62
54
|
(0, react_1.useEffect)(() => {
|
|
@@ -130,11 +122,11 @@ function NotificationCard(_a) {
|
|
|
130
122
|
}), (primaryButton || secondaryButton) && (0, jsx_runtime_1.jsxs)("div", {
|
|
131
123
|
className: styles_module_scss_1.default.notificationCardButtons,
|
|
132
124
|
children: [secondaryButton && (0, jsx_runtime_1.jsx)(button_1.ButtonSimple, Object.assign({}, secondaryButton, {
|
|
133
|
-
appearance:
|
|
125
|
+
appearance: 'neutral',
|
|
134
126
|
size: 's',
|
|
135
127
|
"data-test-id": constants_1.TEST_IDS.primaryButton
|
|
136
128
|
})), primaryButton && (0, jsx_runtime_1.jsx)(button_1.ButtonTonal, Object.assign({}, primaryButton, {
|
|
137
|
-
appearance:
|
|
129
|
+
appearance: 'neutral',
|
|
138
130
|
size: 's',
|
|
139
131
|
"data-test-id": constants_1.TEST_IDS.secondaryButton
|
|
140
132
|
}))]
|
|
@@ -142,8 +134,8 @@ function NotificationCard(_a) {
|
|
|
142
134
|
className: styles_module_scss_1.default.notificationCardFooter,
|
|
143
135
|
children: [link && (0, jsx_runtime_1.jsx)(link_1.Link, Object.assign({}, link, {
|
|
144
136
|
onClick: handleLinkClick,
|
|
145
|
-
appearance:
|
|
146
|
-
textMode: '
|
|
137
|
+
appearance: 'primary',
|
|
138
|
+
textMode: 'accent',
|
|
147
139
|
size: 's',
|
|
148
140
|
"data-test-id": constants_1.TEST_IDS.link
|
|
149
141
|
})), date && (0, jsx_runtime_1.jsx)(typography_1.Typography.LightLabelS, {
|
|
@@ -47,7 +47,8 @@
|
|
|
47
47
|
box-sizing:border-box;
|
|
48
48
|
width:100%;
|
|
49
49
|
height:calc(100% + var(--border-width-notification-panel-card, 1px));
|
|
50
|
-
opacity:
|
|
50
|
+
opacity:0;
|
|
51
|
+
background-color:var(--sys-neutral-accent-default, #787b8a);
|
|
51
52
|
}
|
|
52
53
|
.notificationCard:focus-visible{
|
|
53
54
|
outline-width:var(--border-state-focus-s-border-width, 2px);
|
|
@@ -57,7 +58,7 @@
|
|
|
57
58
|
outline-color:var(--sys-available-complementary, #1c1c24);
|
|
58
59
|
}
|
|
59
60
|
.notificationCard[data-droplist-open]::before, .notificationCard:hover::before, .notificationCard:focus-visible::before, .notificationCard:focus-within:not(:focus)::before{
|
|
60
|
-
|
|
61
|
+
opacity:var(--opacity-a004, 0.04);
|
|
61
62
|
}
|
|
62
63
|
.notificationCard[data-droplist-open] .notificationCardFunction, .notificationCard:hover .notificationCardFunction, .notificationCard:focus-visible .notificationCardFunction, .notificationCard:focus-within:not(:focus) .notificationCardFunction{
|
|
63
64
|
pointer-events:auto;
|
|
@@ -68,26 +69,34 @@
|
|
|
68
69
|
}
|
|
69
70
|
.notificationCard[data-unread]::before{
|
|
70
71
|
opacity:var(--opacity-a008, 0.08);
|
|
71
|
-
background-color:var(--sys-neutral-accent-default, #787b8a);
|
|
72
72
|
}
|
|
73
73
|
.notificationCard[data-unread][data-droplist-open]::before, .notificationCard[data-unread]:hover::before, .notificationCard[data-unread]:focus-visible::before, .notificationCard[data-unread]:focus-within:not(:focus)::before{
|
|
74
74
|
opacity:var(--opacity-a004, 0.04);
|
|
75
75
|
}
|
|
76
|
+
.notificationCard[data-appearance=neutral]::before{
|
|
77
|
+
background-color:var(--sys-neutral-accent-default, #787b8a);
|
|
78
|
+
}
|
|
76
79
|
.notificationCard[data-appearance=neutral] .notificationCardTitleIcon{
|
|
77
80
|
color:var(--sys-neutral-accent-default, #787b8a);
|
|
78
81
|
}
|
|
82
|
+
.notificationCard[data-appearance=error]::before, .notificationCard[data-appearance=errorCritical]::before{
|
|
83
|
+
background-color:var(--sys-red-accent-default, #cb3f3e);
|
|
84
|
+
}
|
|
79
85
|
.notificationCard[data-appearance=error] .notificationCardTitleIcon, .notificationCard[data-appearance=errorCritical] .notificationCardTitleIcon{
|
|
80
86
|
color:var(--sys-red-accent-default, #cb3f3e);
|
|
81
87
|
}
|
|
82
|
-
.notificationCard[data-appearance=errorCritical][data-unread]::before, .notificationCard[data-appearance=errorCritical][data-droplist-open]::before, .notificationCard[data-appearance=errorCritical]:hover::before, .notificationCard[data-appearance=errorCritical]:focus-visible::before, .notificationCard[data-appearance=errorCritical]:focus-within:not(:focus)::before{
|
|
83
|
-
background-color:var(--sys-red-accent-default, #cb3f3e);
|
|
84
|
-
}
|
|
85
88
|
.notificationCard[data-appearance=errorCritical] .notificationCardTitleText{
|
|
86
89
|
color:var(--sys-red-accent-default, #cb3f3e);
|
|
87
90
|
}
|
|
91
|
+
.notificationCard[data-appearance=warning]::before{
|
|
92
|
+
background-color:var(--sys-yellow-accent-default, #e2b134);
|
|
93
|
+
}
|
|
88
94
|
.notificationCard[data-appearance=warning] .notificationCardTitleIcon{
|
|
89
95
|
color:var(--sys-yellow-accent-default, #e2b134);
|
|
90
96
|
}
|
|
97
|
+
.notificationCard[data-appearance=success]::before{
|
|
98
|
+
background-color:var(--sys-green-accent-default, #57b762);
|
|
99
|
+
}
|
|
91
100
|
.notificationCard[data-appearance=success] .notificationCardTitleIcon{
|
|
92
101
|
color:var(--sys-green-accent-default, #57b762);
|
|
93
102
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { MouseEventHandler, ReactNode, RefObject } from 'react';
|
|
2
2
|
import { ButtonFunctionProps } from '@snack-uikit/button';
|
|
3
|
-
import {
|
|
3
|
+
import { SegmentedControlProps } from '@snack-uikit/segmented-control';
|
|
4
|
+
import { TooltipProps } from '@snack-uikit/tooltip';
|
|
4
5
|
import { WithSupportProps } from '@snack-uikit/utils';
|
|
5
6
|
import { NotificationPanelBlank, NotificationPanelBlankProps, NotificationPanelSettingsProps } from './components';
|
|
6
7
|
import { NotificationPanelDivider, NotificationPanelDividerProps } from './components/NotificationPanelDivider';
|
|
@@ -10,11 +11,11 @@ export type NotificationPanelProps = WithSupportProps<{
|
|
|
10
11
|
title: string;
|
|
11
12
|
/** Кнопка настроек и выпадающий список */
|
|
12
13
|
settings?: NotificationPanelSettingsProps;
|
|
13
|
-
/**
|
|
14
|
-
|
|
14
|
+
/** Сегменты для фильтрации */
|
|
15
|
+
segments?: Omit<SegmentedControlProps, 'size' | 'data-test-id'>;
|
|
15
16
|
/** Кнопка в "шапке" панели */
|
|
16
17
|
readAllButton?: Omit<ButtonFunctionProps, 'data-test-id'> & {
|
|
17
|
-
|
|
18
|
+
tooltip?: TooltipProps;
|
|
18
19
|
};
|
|
19
20
|
/** Кнопка внизу панели */
|
|
20
21
|
footerButton?: {
|
|
@@ -34,7 +35,7 @@ export type NotificationPanelProps = WithSupportProps<{
|
|
|
34
35
|
scrollContainerRef?: RefObject<HTMLElement>;
|
|
35
36
|
}>;
|
|
36
37
|
/** Компонент панели для уведомлений */
|
|
37
|
-
export declare function NotificationPanel({ title, settings,
|
|
38
|
+
export declare function NotificationPanel({ title, settings, segments, readAllButton, footerButton, content, loading, skeletonsAmount, scrollEndRef, scrollContainerRef, className, ...rest }: NotificationPanelProps): import("react/jsx-runtime").JSX.Element;
|
|
38
39
|
export declare namespace NotificationPanel {
|
|
39
40
|
const Blank: typeof NotificationPanelBlank;
|
|
40
41
|
type BlankProps = NotificationPanelBlankProps;
|
|
@@ -17,13 +17,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
17
17
|
value: true
|
|
18
18
|
});
|
|
19
19
|
exports.NotificationPanel = NotificationPanel;
|
|
20
|
-
const react_1 = require("react");
|
|
21
20
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
22
21
|
const classnames_1 = __importDefault(require("classnames"));
|
|
23
|
-
const
|
|
22
|
+
const react_1 = require("react");
|
|
24
23
|
const button_1 = require("@snack-uikit/button");
|
|
25
|
-
const chips_1 = require("@snack-uikit/chips");
|
|
26
24
|
const scroll_1 = require("@snack-uikit/scroll");
|
|
25
|
+
const segmented_control_1 = require("@snack-uikit/segmented-control");
|
|
27
26
|
const skeleton_1 = require("@snack-uikit/skeleton");
|
|
28
27
|
const truncate_string_1 = require("@snack-uikit/truncate-string");
|
|
29
28
|
const typography_1 = require("@snack-uikit/typography");
|
|
@@ -32,13 +31,14 @@ const components_1 = require("../NotificationCard/components");
|
|
|
32
31
|
const components_2 = require("./components");
|
|
33
32
|
const NotificationPanelDivider_1 = require("./components/NotificationPanelDivider");
|
|
34
33
|
const constants_1 = require("./constants");
|
|
34
|
+
const helperComponents_1 = require("./helperComponents");
|
|
35
35
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
36
36
|
/** Компонент панели для уведомлений */
|
|
37
37
|
function NotificationPanel(_a) {
|
|
38
38
|
var {
|
|
39
39
|
title,
|
|
40
40
|
settings,
|
|
41
|
-
|
|
41
|
+
segments,
|
|
42
42
|
readAllButton,
|
|
43
43
|
footerButton,
|
|
44
44
|
content,
|
|
@@ -48,8 +48,8 @@ function NotificationPanel(_a) {
|
|
|
48
48
|
scrollContainerRef,
|
|
49
49
|
className
|
|
50
50
|
} = _a,
|
|
51
|
-
rest = __rest(_a, ["title", "settings", "
|
|
52
|
-
const skeletons = (0,
|
|
51
|
+
rest = __rest(_a, ["title", "settings", "segments", "readAllButton", "footerButton", "content", "loading", "skeletonsAmount", "scrollEndRef", "scrollContainerRef", "className"]);
|
|
52
|
+
const skeletons = (0, react_1.useMemo)(() => Array.from({
|
|
53
53
|
length: skeletonsAmount
|
|
54
54
|
}, (_, i) => i), [skeletonsAmount]);
|
|
55
55
|
return (0, jsx_runtime_1.jsxs)("div", Object.assign({
|
|
@@ -65,22 +65,26 @@ function NotificationPanel(_a) {
|
|
|
65
65
|
text: title,
|
|
66
66
|
"data-test-id": constants_1.TEST_IDS.title
|
|
67
67
|
})
|
|
68
|
-
}),
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
})))
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
68
|
+
}), (0, jsx_runtime_1.jsxs)("div", {
|
|
69
|
+
className: styles_module_scss_1.default.notificationPanelHeaderActions,
|
|
70
|
+
children: [readAllButton && (0, jsx_runtime_1.jsx)(helperComponents_1.WithTooltip, {
|
|
71
|
+
tooltip: readAllButton.tooltip,
|
|
72
|
+
children: (0, jsx_runtime_1.jsx)(button_1.ButtonFunction, Object.assign({}, readAllButton, {
|
|
73
|
+
onClick: readAllButton.onClick,
|
|
74
|
+
size: 'xs',
|
|
75
|
+
disabled: readAllButton.disabled || loading,
|
|
76
|
+
"data-test-id": constants_1.TEST_IDS.readAll
|
|
77
|
+
}))
|
|
78
|
+
}), settings && (0, jsx_runtime_1.jsx)(components_2.NotificationPanelSettings, Object.assign({}, settings))]
|
|
79
|
+
})]
|
|
80
|
+
}), (0, jsx_runtime_1.jsx)("div", {
|
|
81
|
+
children: segments && (0, jsx_runtime_1.jsx)(segmented_control_1.SegmentedControl, Object.assign({}, segments, {
|
|
82
|
+
size: 's',
|
|
83
|
+
items: segments.items.map(item => Object.assign(Object.assign({}, item), {
|
|
84
|
+
disabled: item.disabled || loading
|
|
85
|
+
})),
|
|
86
|
+
"data-test-id": constants_1.TEST_IDS.segments
|
|
87
|
+
}))
|
|
84
88
|
})]
|
|
85
89
|
}), (0, jsx_runtime_1.jsxs)(scroll_1.Scroll, {
|
|
86
90
|
size: 'm',
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.TEST_IDS = void 0;
|
|
7
7
|
exports.TEST_IDS = {
|
|
8
8
|
title: 'notification-panel__title',
|
|
9
|
-
|
|
9
|
+
segments: 'notification-panel__segments',
|
|
10
10
|
settings: {
|
|
11
11
|
droplist: 'notification-panel__settings__droplist',
|
|
12
12
|
droplistTrigger: 'notification-panel__settings__droplist-trigger',
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { TooltipProps } from '@snack-uikit/tooltip';
|
|
3
|
+
type WithTooltipProps = PropsWithChildren<{
|
|
4
|
+
tooltip?: TooltipProps;
|
|
5
|
+
}>;
|
|
6
|
+
export declare function WithTooltip({ tooltip, children }: WithTooltipProps): string | number | boolean | Iterable<import("react").ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.WithTooltip = WithTooltip;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const tooltip_1 = require("@snack-uikit/tooltip");
|
|
9
|
+
function WithTooltip(_ref) {
|
|
10
|
+
let {
|
|
11
|
+
tooltip,
|
|
12
|
+
children
|
|
13
|
+
} = _ref;
|
|
14
|
+
if (!tooltip) {
|
|
15
|
+
return children;
|
|
16
|
+
}
|
|
17
|
+
return (0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, Object.assign({}, tooltip, {
|
|
18
|
+
children: children
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './WithTooltip';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return m[k];
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
} : function (o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
});
|
|
19
|
+
var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", {
|
|
23
|
+
value: true
|
|
24
|
+
});
|
|
25
|
+
__exportStar(require("./WithTooltip"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './WithTooltip';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return m[k];
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
} : function (o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
});
|
|
19
|
+
var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", {
|
|
23
|
+
value: true
|
|
24
|
+
});
|
|
25
|
+
__exportStar(require("./WithTooltip"), exports);
|
|
@@ -8,35 +8,17 @@
|
|
|
8
8
|
position:relative;
|
|
9
9
|
display:flex;
|
|
10
10
|
flex-direction:column;
|
|
11
|
+
background-color:var(--sys-neutral-background2-level, #ffffff);
|
|
11
12
|
border-bottom-color:var(--sys-neutral-decor-default, #dde0ea);
|
|
12
13
|
border-bottom-style:solid;
|
|
13
14
|
}
|
|
14
|
-
.notificationPanelHeader::before{
|
|
15
|
-
pointer-events:none;
|
|
16
|
-
content:"";
|
|
17
|
-
position:absolute;
|
|
18
|
-
top:0;
|
|
19
|
-
left:0;
|
|
20
|
-
box-sizing:border-box;
|
|
21
|
-
width:100%;
|
|
22
|
-
height:calc(100% + var(--border-width-notification-panel-container, 1px));
|
|
23
|
-
opacity:var(--opacity-a004, 0.04);
|
|
24
|
-
background-color:var(--sys-neutral-accent-default, #787b8a);
|
|
25
|
-
border-radius:inherit;
|
|
26
|
-
}
|
|
27
15
|
|
|
28
|
-
.
|
|
16
|
+
.notificationPanelSegments{
|
|
29
17
|
gap:var(--space-notification-panel-header-chips-gap, 8px);
|
|
30
18
|
display:flex;
|
|
31
19
|
align-items:center;
|
|
32
20
|
}
|
|
33
21
|
|
|
34
|
-
.notificationPanelHeaderFunctions{
|
|
35
|
-
display:flex;
|
|
36
|
-
align-items:center;
|
|
37
|
-
justify-content:space-between;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
22
|
.notificationPanelHeadline{
|
|
41
23
|
gap:var(--space-notification-panel-header-headline-gap, 16px);
|
|
42
24
|
display:flex;
|
|
@@ -70,7 +52,7 @@
|
|
|
70
52
|
margin:0;
|
|
71
53
|
padding:0;
|
|
72
54
|
color:var(--sys-neutral-text-light, #8b8e9b);
|
|
73
|
-
background:
|
|
55
|
+
background-color:var(--sys-neutral-background2-level, #ffffff);
|
|
74
56
|
border-color:var(--sys-neutral-decor-default, #dde0ea);
|
|
75
57
|
border-top-style:solid;
|
|
76
58
|
border-right:none;
|
|
@@ -102,10 +84,18 @@
|
|
|
102
84
|
box-sizing:border-box;
|
|
103
85
|
width:100%;
|
|
104
86
|
height:100%;
|
|
87
|
+
background-color:var(--sys-neutral-background2-level, #ffffff);
|
|
105
88
|
}
|
|
106
89
|
|
|
107
90
|
.scrollStub{
|
|
108
91
|
height:calc(var(--dimension-025m, 2px) / 2);
|
|
109
92
|
margin-top:calc(var(--dimension-025m, 2px) / -2);
|
|
110
93
|
background:transparent;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.notificationPanelHeaderActions{
|
|
97
|
+
display:flex;
|
|
98
|
+
-moz-column-gap:var(--dimension-1m, 8px);
|
|
99
|
+
column-gap:var(--dimension-1m, 8px);
|
|
100
|
+
align-items:center;
|
|
111
101
|
}
|
|
@@ -24,11 +24,7 @@ import styles from './styles.module.css';
|
|
|
24
24
|
/** Компонент карточки уведомления */
|
|
25
25
|
export function NotificationCard(_a) {
|
|
26
26
|
var { id, appearance = APPEARANCE.Neutral, label, unread, title, content, link, date, onClick, primaryButton, secondaryButton, actions, onVisible, className } = _a, rest = __rest(_a, ["id", "appearance", "label", "unread", "title", "content", "link", "date", "onClick", "primaryButton", "secondaryButton", "actions", "onVisible", "className"]);
|
|
27
|
-
const
|
|
28
|
-
icon: getIcon(appearance),
|
|
29
|
-
linkOnColor: appearance === APPEARANCE.ErrorCritical ? 'red' : undefined,
|
|
30
|
-
buttonAppearance: appearance === APPEARANCE.ErrorCritical ? 'destructive' : 'primary',
|
|
31
|
-
}), [appearance]);
|
|
27
|
+
const icon = useMemo(() => getIcon(appearance), [appearance]);
|
|
32
28
|
const [isDroplistOpen, setDroplistOpen] = useState(false);
|
|
33
29
|
const cardRef = useRef(null);
|
|
34
30
|
useEffect(() => {
|
|
@@ -57,5 +53,5 @@ export function NotificationCard(_a) {
|
|
|
57
53
|
e.stopPropagation();
|
|
58
54
|
(_a = link === null || link === void 0 ? void 0 : link.onClick) === null || _a === void 0 ? void 0 : _a.call(link, e);
|
|
59
55
|
};
|
|
60
|
-
return (_jsxs("div", Object.assign({ ref: cardRef, role: 'button', onClick: onClick, tabIndex: 0 }, extractSupportProps(rest), { "data-appearance": appearance, "data-unread": unread || undefined, "data-clickable": Boolean(onClick) || undefined, "data-droplist-open": isDroplistOpen || undefined, className: cn(styles.notificationCard, className), children: [(actions === null || actions === void 0 ? void 0 : actions.length) && (_jsx(NotificationCardFunction, { actions: actions, open: isDroplistOpen, setDroplistOpen: setDroplistOpen })), label && (_jsx(Typography.LightLabelS, { tag: 'div', className: styles.notificationCardLabel, children: _jsx(TruncateString, { maxLines: 1, text: label, "data-test-id": TEST_IDS.label }) })), _jsxs("div", { className: styles.notificationCardTitle, children: [_jsx("div", { className: styles.notificationCardTitleIcon, children: icon }), _jsx(Typography.SansTitleS, { tag: 'div', className: styles.notificationCardTitleText, children: _jsx(TruncateString, { maxLines: 2, text: title, "data-test-id": TEST_IDS.title }) })] }), content && (_jsx(Typography.SansBodyS, { tag: 'div', className: styles.notificationCardContent, "data-test-id": TEST_IDS.content, children: content })), (primaryButton || secondaryButton) && (_jsxs("div", { className: styles.notificationCardButtons, children: [secondaryButton && (_jsx(ButtonSimple, Object.assign({}, secondaryButton, { appearance:
|
|
56
|
+
return (_jsxs("div", Object.assign({ ref: cardRef, role: 'button', onClick: onClick, tabIndex: 0 }, extractSupportProps(rest), { "data-appearance": appearance, "data-unread": unread || undefined, "data-clickable": Boolean(onClick) || undefined, "data-droplist-open": isDroplistOpen || undefined, className: cn(styles.notificationCard, className), children: [(actions === null || actions === void 0 ? void 0 : actions.length) && (_jsx(NotificationCardFunction, { actions: actions, open: isDroplistOpen, setDroplistOpen: setDroplistOpen })), label && (_jsx(Typography.LightLabelS, { tag: 'div', className: styles.notificationCardLabel, children: _jsx(TruncateString, { maxLines: 1, text: label, "data-test-id": TEST_IDS.label }) })), _jsxs("div", { className: styles.notificationCardTitle, children: [_jsx("div", { className: styles.notificationCardTitleIcon, children: icon }), _jsx(Typography.SansTitleS, { tag: 'div', className: styles.notificationCardTitleText, children: _jsx(TruncateString, { maxLines: 2, text: title, "data-test-id": TEST_IDS.title }) })] }), content && (_jsx(Typography.SansBodyS, { tag: 'div', className: styles.notificationCardContent, "data-test-id": TEST_IDS.content, children: content })), (primaryButton || secondaryButton) && (_jsxs("div", { className: styles.notificationCardButtons, children: [secondaryButton && (_jsx(ButtonSimple, Object.assign({}, secondaryButton, { appearance: 'neutral', size: 's', "data-test-id": TEST_IDS.primaryButton }))), primaryButton && (_jsx(ButtonTonal, Object.assign({}, primaryButton, { appearance: 'neutral', size: 's', "data-test-id": TEST_IDS.secondaryButton })))] })), showFooter && (_jsxs("div", { className: styles.notificationCardFooter, children: [link && (_jsx(Link, Object.assign({}, link, { onClick: handleLinkClick, appearance: 'primary', textMode: 'accent', size: 's', "data-test-id": TEST_IDS.link }))), date && (_jsx(Typography.LightLabelS, { className: styles.notificationCardDate, "data-test-id": TEST_IDS.date, children: date }))] }))] })));
|
|
61
57
|
}
|
|
@@ -47,7 +47,8 @@
|
|
|
47
47
|
box-sizing:border-box;
|
|
48
48
|
width:100%;
|
|
49
49
|
height:calc(100% + var(--border-width-notification-panel-card, 1px));
|
|
50
|
-
opacity:
|
|
50
|
+
opacity:0;
|
|
51
|
+
background-color:var(--sys-neutral-accent-default, #787b8a);
|
|
51
52
|
}
|
|
52
53
|
.notificationCard:focus-visible{
|
|
53
54
|
outline-width:var(--border-state-focus-s-border-width, 2px);
|
|
@@ -57,7 +58,7 @@
|
|
|
57
58
|
outline-color:var(--sys-available-complementary, #1c1c24);
|
|
58
59
|
}
|
|
59
60
|
.notificationCard[data-droplist-open]::before, .notificationCard:hover::before, .notificationCard:focus-visible::before, .notificationCard:focus-within:not(:focus)::before{
|
|
60
|
-
|
|
61
|
+
opacity:var(--opacity-a004, 0.04);
|
|
61
62
|
}
|
|
62
63
|
.notificationCard[data-droplist-open] .notificationCardFunction, .notificationCard:hover .notificationCardFunction, .notificationCard:focus-visible .notificationCardFunction, .notificationCard:focus-within:not(:focus) .notificationCardFunction{
|
|
63
64
|
pointer-events:auto;
|
|
@@ -68,26 +69,34 @@
|
|
|
68
69
|
}
|
|
69
70
|
.notificationCard[data-unread]::before{
|
|
70
71
|
opacity:var(--opacity-a008, 0.08);
|
|
71
|
-
background-color:var(--sys-neutral-accent-default, #787b8a);
|
|
72
72
|
}
|
|
73
73
|
.notificationCard[data-unread][data-droplist-open]::before, .notificationCard[data-unread]:hover::before, .notificationCard[data-unread]:focus-visible::before, .notificationCard[data-unread]:focus-within:not(:focus)::before{
|
|
74
74
|
opacity:var(--opacity-a004, 0.04);
|
|
75
75
|
}
|
|
76
|
+
.notificationCard[data-appearance=neutral]::before{
|
|
77
|
+
background-color:var(--sys-neutral-accent-default, #787b8a);
|
|
78
|
+
}
|
|
76
79
|
.notificationCard[data-appearance=neutral] .notificationCardTitleIcon{
|
|
77
80
|
color:var(--sys-neutral-accent-default, #787b8a);
|
|
78
81
|
}
|
|
82
|
+
.notificationCard[data-appearance=error]::before, .notificationCard[data-appearance=errorCritical]::before{
|
|
83
|
+
background-color:var(--sys-red-accent-default, #cb3f3e);
|
|
84
|
+
}
|
|
79
85
|
.notificationCard[data-appearance=error] .notificationCardTitleIcon, .notificationCard[data-appearance=errorCritical] .notificationCardTitleIcon{
|
|
80
86
|
color:var(--sys-red-accent-default, #cb3f3e);
|
|
81
87
|
}
|
|
82
|
-
.notificationCard[data-appearance=errorCritical][data-unread]::before, .notificationCard[data-appearance=errorCritical][data-droplist-open]::before, .notificationCard[data-appearance=errorCritical]:hover::before, .notificationCard[data-appearance=errorCritical]:focus-visible::before, .notificationCard[data-appearance=errorCritical]:focus-within:not(:focus)::before{
|
|
83
|
-
background-color:var(--sys-red-accent-default, #cb3f3e);
|
|
84
|
-
}
|
|
85
88
|
.notificationCard[data-appearance=errorCritical] .notificationCardTitleText{
|
|
86
89
|
color:var(--sys-red-accent-default, #cb3f3e);
|
|
87
90
|
}
|
|
91
|
+
.notificationCard[data-appearance=warning]::before{
|
|
92
|
+
background-color:var(--sys-yellow-accent-default, #e2b134);
|
|
93
|
+
}
|
|
88
94
|
.notificationCard[data-appearance=warning] .notificationCardTitleIcon{
|
|
89
95
|
color:var(--sys-yellow-accent-default, #e2b134);
|
|
90
96
|
}
|
|
97
|
+
.notificationCard[data-appearance=success]::before{
|
|
98
|
+
background-color:var(--sys-green-accent-default, #57b762);
|
|
99
|
+
}
|
|
91
100
|
.notificationCard[data-appearance=success] .notificationCardTitleIcon{
|
|
92
101
|
color:var(--sys-green-accent-default, #57b762);
|
|
93
102
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { MouseEventHandler, ReactNode, RefObject } from 'react';
|
|
2
2
|
import { ButtonFunctionProps } from '@snack-uikit/button';
|
|
3
|
-
import {
|
|
3
|
+
import { SegmentedControlProps } from '@snack-uikit/segmented-control';
|
|
4
|
+
import { TooltipProps } from '@snack-uikit/tooltip';
|
|
4
5
|
import { WithSupportProps } from '@snack-uikit/utils';
|
|
5
6
|
import { NotificationPanelBlank, NotificationPanelBlankProps, NotificationPanelSettingsProps } from './components';
|
|
6
7
|
import { NotificationPanelDivider, NotificationPanelDividerProps } from './components/NotificationPanelDivider';
|
|
@@ -10,11 +11,11 @@ export type NotificationPanelProps = WithSupportProps<{
|
|
|
10
11
|
title: string;
|
|
11
12
|
/** Кнопка настроек и выпадающий список */
|
|
12
13
|
settings?: NotificationPanelSettingsProps;
|
|
13
|
-
/**
|
|
14
|
-
|
|
14
|
+
/** Сегменты для фильтрации */
|
|
15
|
+
segments?: Omit<SegmentedControlProps, 'size' | 'data-test-id'>;
|
|
15
16
|
/** Кнопка в "шапке" панели */
|
|
16
17
|
readAllButton?: Omit<ButtonFunctionProps, 'data-test-id'> & {
|
|
17
|
-
|
|
18
|
+
tooltip?: TooltipProps;
|
|
18
19
|
};
|
|
19
20
|
/** Кнопка внизу панели */
|
|
20
21
|
footerButton?: {
|
|
@@ -34,7 +35,7 @@ export type NotificationPanelProps = WithSupportProps<{
|
|
|
34
35
|
scrollContainerRef?: RefObject<HTMLElement>;
|
|
35
36
|
}>;
|
|
36
37
|
/** Компонент панели для уведомлений */
|
|
37
|
-
export declare function NotificationPanel({ title, settings,
|
|
38
|
+
export declare function NotificationPanel({ title, settings, segments, readAllButton, footerButton, content, loading, skeletonsAmount, scrollEndRef, scrollContainerRef, className, ...rest }: NotificationPanelProps): import("react/jsx-runtime").JSX.Element;
|
|
38
39
|
export declare namespace NotificationPanel {
|
|
39
40
|
const Blank: typeof NotificationPanelBlank;
|
|
40
41
|
type BlankProps = NotificationPanelBlankProps;
|
|
@@ -9,13 +9,12 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import { createElement as _createElement } from "react";
|
|
13
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
13
|
import cn from 'classnames';
|
|
15
14
|
import { useMemo } from 'react';
|
|
16
15
|
import { ButtonFunction } from '@snack-uikit/button';
|
|
17
|
-
import { ChipToggle } from '@snack-uikit/chips';
|
|
18
16
|
import { Scroll } from '@snack-uikit/scroll';
|
|
17
|
+
import { SegmentedControl } from '@snack-uikit/segmented-control';
|
|
19
18
|
import { SkeletonContextProvider, WithSkeleton } from '@snack-uikit/skeleton';
|
|
20
19
|
import { TruncateString } from '@snack-uikit/truncate-string';
|
|
21
20
|
import { Typography } from '@snack-uikit/typography';
|
|
@@ -24,12 +23,13 @@ import { NotificationCardSkeleton } from '../NotificationCard/components';
|
|
|
24
23
|
import { NotificationPanelBlank, NotificationPanelSettings, } from './components';
|
|
25
24
|
import { NotificationPanelDivider } from './components/NotificationPanelDivider';
|
|
26
25
|
import { TEST_IDS } from './constants';
|
|
26
|
+
import { WithTooltip } from './helperComponents';
|
|
27
27
|
import styles from './styles.module.css';
|
|
28
28
|
/** Компонент панели для уведомлений */
|
|
29
29
|
export function NotificationPanel(_a) {
|
|
30
|
-
var { title, settings,
|
|
30
|
+
var { title, settings, segments, readAllButton, footerButton, content, loading, skeletonsAmount = 2, scrollEndRef, scrollContainerRef, className } = _a, rest = __rest(_a, ["title", "settings", "segments", "readAllButton", "footerButton", "content", "loading", "skeletonsAmount", "scrollEndRef", "scrollContainerRef", "className"]);
|
|
31
31
|
const skeletons = useMemo(() => Array.from({ length: skeletonsAmount }, (_, i) => i), [skeletonsAmount]);
|
|
32
|
-
return (_jsxs("div", Object.assign({ className: cn(styles.wrapper, className) }, extractSupportProps(rest), { children: [_jsxs("div", { className: styles.notificationPanelHeader, children: [_jsxs("div", { className: styles.notificationPanelHeadline, children: [_jsx(Typography.SansHeadlineS, { className: styles.notificationPanelTitle, children: _jsx(TruncateString, { text: title, "data-test-id": TEST_IDS.title }) }),
|
|
32
|
+
return (_jsxs("div", Object.assign({ className: cn(styles.wrapper, className) }, extractSupportProps(rest), { children: [_jsxs("div", { className: styles.notificationPanelHeader, children: [_jsxs("div", { className: styles.notificationPanelHeadline, children: [_jsx(Typography.SansHeadlineS, { className: styles.notificationPanelTitle, children: _jsx(TruncateString, { text: title, "data-test-id": TEST_IDS.title }) }), _jsxs("div", { className: styles.notificationPanelHeaderActions, children: [readAllButton && (_jsx(WithTooltip, { tooltip: readAllButton.tooltip, children: _jsx(ButtonFunction, Object.assign({}, readAllButton, { onClick: readAllButton.onClick, size: 'xs', disabled: readAllButton.disabled || loading, "data-test-id": TEST_IDS.readAll })) })), settings && _jsx(NotificationPanelSettings, Object.assign({}, settings))] })] }), _jsx("div", { children: segments && (_jsx(SegmentedControl, Object.assign({}, segments, { size: 's', items: segments.items.map(item => (Object.assign(Object.assign({}, item), { disabled: item.disabled || loading }))), "data-test-id": TEST_IDS.segments }))) })] }), _jsxs(Scroll, { size: 'm', className: styles.notificationPanelBody, ref: scrollContainerRef, children: [content, loading && (_jsx(SkeletonContextProvider, { loading: loading || false, children: skeletons.map(skeleton => (_jsx(WithSkeleton, { skeleton: _jsx(NotificationCardSkeleton, {}) }, skeleton))) })), _jsx("div", { className: styles.scrollStub, ref: scrollEndRef })] }), footerButton && (_jsx("button", { type: 'button', onClick: footerButton.onClick, className: styles.notificationPanelFooterButton, "data-test-id": TEST_IDS.footerButton, children: _jsx(Typography.SansLabelS, { children: footerButton.label }) }))] })));
|
|
33
33
|
}
|
|
34
34
|
(function (NotificationPanel) {
|
|
35
35
|
NotificationPanel.Blank = NotificationPanelBlank;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const TEST_IDS = {
|
|
2
2
|
title: 'notification-panel__title',
|
|
3
|
-
|
|
3
|
+
segments: 'notification-panel__segments',
|
|
4
4
|
settings: {
|
|
5
5
|
droplist: 'notification-panel__settings__droplist',
|
|
6
6
|
droplistTrigger: 'notification-panel__settings__droplist-trigger',
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { TooltipProps } from '@snack-uikit/tooltip';
|
|
3
|
+
type WithTooltipProps = PropsWithChildren<{
|
|
4
|
+
tooltip?: TooltipProps;
|
|
5
|
+
}>;
|
|
6
|
+
export declare function WithTooltip({ tooltip, children }: WithTooltipProps): string | number | boolean | Iterable<import("react").ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Tooltip } from '@snack-uikit/tooltip';
|
|
3
|
+
export function WithTooltip({ tooltip, children }) {
|
|
4
|
+
if (!tooltip) {
|
|
5
|
+
return children;
|
|
6
|
+
}
|
|
7
|
+
return _jsx(Tooltip, Object.assign({}, tooltip, { children: children }));
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './WithTooltip';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './WithTooltip';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './WithTooltip';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './WithTooltip';
|
|
@@ -8,35 +8,17 @@
|
|
|
8
8
|
position:relative;
|
|
9
9
|
display:flex;
|
|
10
10
|
flex-direction:column;
|
|
11
|
+
background-color:var(--sys-neutral-background2-level, #ffffff);
|
|
11
12
|
border-bottom-color:var(--sys-neutral-decor-default, #dde0ea);
|
|
12
13
|
border-bottom-style:solid;
|
|
13
14
|
}
|
|
14
|
-
.notificationPanelHeader::before{
|
|
15
|
-
pointer-events:none;
|
|
16
|
-
content:"";
|
|
17
|
-
position:absolute;
|
|
18
|
-
top:0;
|
|
19
|
-
left:0;
|
|
20
|
-
box-sizing:border-box;
|
|
21
|
-
width:100%;
|
|
22
|
-
height:calc(100% + var(--border-width-notification-panel-container, 1px));
|
|
23
|
-
opacity:var(--opacity-a004, 0.04);
|
|
24
|
-
background-color:var(--sys-neutral-accent-default, #787b8a);
|
|
25
|
-
border-radius:inherit;
|
|
26
|
-
}
|
|
27
15
|
|
|
28
|
-
.
|
|
16
|
+
.notificationPanelSegments{
|
|
29
17
|
gap:var(--space-notification-panel-header-chips-gap, 8px);
|
|
30
18
|
display:flex;
|
|
31
19
|
align-items:center;
|
|
32
20
|
}
|
|
33
21
|
|
|
34
|
-
.notificationPanelHeaderFunctions{
|
|
35
|
-
display:flex;
|
|
36
|
-
align-items:center;
|
|
37
|
-
justify-content:space-between;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
22
|
.notificationPanelHeadline{
|
|
41
23
|
gap:var(--space-notification-panel-header-headline-gap, 16px);
|
|
42
24
|
display:flex;
|
|
@@ -70,7 +52,7 @@
|
|
|
70
52
|
margin:0;
|
|
71
53
|
padding:0;
|
|
72
54
|
color:var(--sys-neutral-text-light, #8b8e9b);
|
|
73
|
-
background:
|
|
55
|
+
background-color:var(--sys-neutral-background2-level, #ffffff);
|
|
74
56
|
border-color:var(--sys-neutral-decor-default, #dde0ea);
|
|
75
57
|
border-top-style:solid;
|
|
76
58
|
border-right:none;
|
|
@@ -102,10 +84,18 @@
|
|
|
102
84
|
box-sizing:border-box;
|
|
103
85
|
width:100%;
|
|
104
86
|
height:100%;
|
|
87
|
+
background-color:var(--sys-neutral-background2-level, #ffffff);
|
|
105
88
|
}
|
|
106
89
|
|
|
107
90
|
.scrollStub{
|
|
108
91
|
height:calc(var(--dimension-025m, 2px) / 2);
|
|
109
92
|
margin-top:calc(var(--dimension-025m, 2px) / -2);
|
|
110
93
|
background:transparent;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.notificationPanelHeaderActions{
|
|
97
|
+
display:flex;
|
|
98
|
+
-moz-column-gap:var(--dimension-1m, 8px);
|
|
99
|
+
column-gap:var(--dimension-1m, 8px);
|
|
100
|
+
align-items:center;
|
|
111
101
|
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Notification",
|
|
7
|
-
"version": "0.13.
|
|
7
|
+
"version": "0.13.19",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -37,19 +37,20 @@
|
|
|
37
37
|
"scripts": {},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@snack-uikit/button": "0.19.16",
|
|
40
|
-
"@snack-uikit/chips": "0.28.6",
|
|
41
40
|
"@snack-uikit/icons": "0.27.3",
|
|
42
41
|
"@snack-uikit/info-block": "0.6.33",
|
|
43
42
|
"@snack-uikit/link": "0.17.12",
|
|
44
43
|
"@snack-uikit/list": "0.32.6",
|
|
45
44
|
"@snack-uikit/popover-private": "0.15.3",
|
|
46
45
|
"@snack-uikit/scroll": "0.10.5",
|
|
46
|
+
"@snack-uikit/segmented-control": "0.6.12",
|
|
47
47
|
"@snack-uikit/skeleton": "0.6.9",
|
|
48
48
|
"@snack-uikit/tag": "0.15.10",
|
|
49
|
+
"@snack-uikit/tooltip": "0.18.5",
|
|
49
50
|
"@snack-uikit/truncate-string": "0.7.3",
|
|
50
51
|
"@snack-uikit/typography": "0.8.11",
|
|
51
52
|
"@snack-uikit/utils": "4.0.0",
|
|
52
53
|
"classnames": "2.5.1"
|
|
53
54
|
},
|
|
54
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "aa80f463fc1e5e9412d766dbfe5d09b1350b9e71"
|
|
55
56
|
}
|
|
@@ -2,7 +2,7 @@ import cn from 'classnames';
|
|
|
2
2
|
import { ElementType, MouseEventHandler, ReactElement, ReactNode, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
3
|
|
|
4
4
|
import { ButtonSimple, ButtonSimpleProps, ButtonTonal, ButtonTonalProps } from '@snack-uikit/button';
|
|
5
|
-
import { Link,
|
|
5
|
+
import { Link, PickLinkProps } from '@snack-uikit/link';
|
|
6
6
|
import { BaseItemProps } from '@snack-uikit/list';
|
|
7
7
|
import { TruncateString } from '@snack-uikit/truncate-string';
|
|
8
8
|
import { Typography } from '@snack-uikit/typography';
|
|
@@ -68,18 +68,7 @@ export function NotificationCard<LinkElement extends ElementType = 'a'>({
|
|
|
68
68
|
className,
|
|
69
69
|
...rest
|
|
70
70
|
}: NotificationCardProps<LinkElement>) {
|
|
71
|
-
const
|
|
72
|
-
icon: ReturnType<typeof getIcon>;
|
|
73
|
-
linkOnColor: LinkProps['appearance'];
|
|
74
|
-
buttonAppearance: ButtonTonalProps['appearance'];
|
|
75
|
-
}>(
|
|
76
|
-
() => ({
|
|
77
|
-
icon: getIcon(appearance),
|
|
78
|
-
linkOnColor: appearance === APPEARANCE.ErrorCritical ? 'red' : undefined,
|
|
79
|
-
buttonAppearance: appearance === APPEARANCE.ErrorCritical ? 'destructive' : 'primary',
|
|
80
|
-
}),
|
|
81
|
-
[appearance],
|
|
82
|
-
);
|
|
71
|
+
const icon = useMemo(() => getIcon(appearance), [appearance]);
|
|
83
72
|
|
|
84
73
|
const [isDroplistOpen, setDroplistOpen] = useState(false);
|
|
85
74
|
|
|
@@ -159,21 +148,11 @@ export function NotificationCard<LinkElement extends ElementType = 'a'>({
|
|
|
159
148
|
{(primaryButton || secondaryButton) && (
|
|
160
149
|
<div className={styles.notificationCardButtons}>
|
|
161
150
|
{secondaryButton && (
|
|
162
|
-
<ButtonSimple
|
|
163
|
-
{...secondaryButton}
|
|
164
|
-
appearance={buttonAppearance}
|
|
165
|
-
size='s'
|
|
166
|
-
data-test-id={TEST_IDS.primaryButton}
|
|
167
|
-
/>
|
|
151
|
+
<ButtonSimple {...secondaryButton} appearance='neutral' size='s' data-test-id={TEST_IDS.primaryButton} />
|
|
168
152
|
)}
|
|
169
153
|
|
|
170
154
|
{primaryButton && (
|
|
171
|
-
<ButtonTonal
|
|
172
|
-
{...primaryButton}
|
|
173
|
-
appearance={buttonAppearance}
|
|
174
|
-
size='s'
|
|
175
|
-
data-test-id={TEST_IDS.secondaryButton}
|
|
176
|
-
/>
|
|
155
|
+
<ButtonTonal {...primaryButton} appearance='neutral' size='s' data-test-id={TEST_IDS.secondaryButton} />
|
|
177
156
|
)}
|
|
178
157
|
</div>
|
|
179
158
|
)}
|
|
@@ -184,8 +163,8 @@ export function NotificationCard<LinkElement extends ElementType = 'a'>({
|
|
|
184
163
|
<Link
|
|
185
164
|
{...link}
|
|
186
165
|
onClick={handleLinkClick}
|
|
187
|
-
appearance=
|
|
188
|
-
textMode='
|
|
166
|
+
appearance='primary'
|
|
167
|
+
textMode='accent'
|
|
189
168
|
size='s'
|
|
190
169
|
data-test-id={TEST_IDS.link}
|
|
191
170
|
/>
|
|
@@ -55,7 +55,8 @@
|
|
|
55
55
|
width: 100%;
|
|
56
56
|
height: calc(100% + styles-tokens-notification-notificationCard.$border-width-notification-panel-card);
|
|
57
57
|
|
|
58
|
-
opacity:
|
|
58
|
+
opacity: 0;
|
|
59
|
+
background-color: styles-tokens-notification-notificationCard.$sys-neutral-accent-default;
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
&:focus-visible {
|
|
@@ -67,7 +68,7 @@
|
|
|
67
68
|
|
|
68
69
|
&[data-droplist-open], &:hover, &:focus-visible, &:focus-within:not(:focus) {
|
|
69
70
|
&::before {
|
|
70
|
-
|
|
71
|
+
opacity: styles-tokens-notification-notificationCard.$opacity-a004;
|
|
71
72
|
}
|
|
72
73
|
|
|
73
74
|
.notificationCardFunction {
|
|
@@ -83,7 +84,6 @@
|
|
|
83
84
|
&[data-unread] {
|
|
84
85
|
&::before {
|
|
85
86
|
opacity: styles-tokens-notification-notificationCard.$opacity-a008;
|
|
86
|
-
background-color: styles-tokens-notification-notificationCard.$sys-neutral-accent-default;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
&[data-droplist-open], &:hover, &:focus-visible, &:focus-within:not(:focus) {
|
|
@@ -94,6 +94,10 @@
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
&[data-appearance='neutral'] {
|
|
97
|
+
&::before {
|
|
98
|
+
background-color: styles-tokens-notification-notificationCard.$sys-neutral-accent-default;
|
|
99
|
+
}
|
|
100
|
+
|
|
97
101
|
.notificationCardTitleIcon {
|
|
98
102
|
color: styles-tokens-notification-notificationCard.$sys-neutral-accent-default;
|
|
99
103
|
}
|
|
@@ -101,30 +105,36 @@
|
|
|
101
105
|
|
|
102
106
|
&[data-appearance='error'],
|
|
103
107
|
&[data-appearance='errorCritical'] {
|
|
108
|
+
&::before {
|
|
109
|
+
background-color: styles-tokens-notification-notificationCard.$sys-red-accent-default;
|
|
110
|
+
}
|
|
111
|
+
|
|
104
112
|
.notificationCardTitleIcon {
|
|
105
113
|
color: styles-tokens-notification-notificationCard.$sys-red-accent-default;
|
|
106
114
|
}
|
|
107
115
|
}
|
|
108
116
|
|
|
109
117
|
&[data-appearance='errorCritical'] {
|
|
110
|
-
&[data-unread], &[data-droplist-open], &:hover, &:focus-visible, &:focus-within:not(:focus) {
|
|
111
|
-
&::before {
|
|
112
|
-
background-color: styles-tokens-notification-notificationCard.$sys-red-accent-default;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
118
|
.notificationCardTitleText {
|
|
117
119
|
color: styles-tokens-notification-notificationCard.$sys-red-accent-default;
|
|
118
120
|
}
|
|
119
121
|
}
|
|
120
122
|
|
|
121
123
|
&[data-appearance='warning'] {
|
|
124
|
+
&::before {
|
|
125
|
+
background-color: styles-tokens-notification-notificationCard.$sys-yellow-accent-default;
|
|
126
|
+
}
|
|
127
|
+
|
|
122
128
|
.notificationCardTitleIcon {
|
|
123
129
|
color: styles-tokens-notification-notificationCard.$sys-yellow-accent-default;
|
|
124
130
|
}
|
|
125
131
|
}
|
|
126
132
|
|
|
127
133
|
&[data-appearance='success'] {
|
|
134
|
+
&::before {
|
|
135
|
+
background-color: styles-tokens-notification-notificationCard.$sys-green-accent-default;
|
|
136
|
+
}
|
|
137
|
+
|
|
128
138
|
.notificationCardTitleIcon {
|
|
129
139
|
color: styles-tokens-notification-notificationCard.$sys-green-accent-default;
|
|
130
140
|
}
|
|
@@ -2,9 +2,10 @@ import cn from 'classnames';
|
|
|
2
2
|
import { MouseEventHandler, ReactNode, RefObject, useMemo } from 'react';
|
|
3
3
|
|
|
4
4
|
import { ButtonFunction, ButtonFunctionProps } from '@snack-uikit/button';
|
|
5
|
-
import { ChipToggle, ChipToggleProps } from '@snack-uikit/chips';
|
|
6
5
|
import { Scroll } from '@snack-uikit/scroll';
|
|
6
|
+
import { SegmentedControl, SegmentedControlProps } from '@snack-uikit/segmented-control';
|
|
7
7
|
import { SkeletonContextProvider, WithSkeleton } from '@snack-uikit/skeleton';
|
|
8
|
+
import { TooltipProps } from '@snack-uikit/tooltip';
|
|
8
9
|
import { TruncateString } from '@snack-uikit/truncate-string';
|
|
9
10
|
import { Typography } from '@snack-uikit/typography';
|
|
10
11
|
import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
|
|
@@ -18,6 +19,7 @@ import {
|
|
|
18
19
|
} from './components';
|
|
19
20
|
import { NotificationPanelDivider, NotificationPanelDividerProps } from './components/NotificationPanelDivider';
|
|
20
21
|
import { TEST_IDS } from './constants';
|
|
22
|
+
import { WithTooltip } from './helperComponents';
|
|
21
23
|
import styles from './styles.module.scss';
|
|
22
24
|
|
|
23
25
|
export type { NotificationPanelBlankProps };
|
|
@@ -27,11 +29,11 @@ export type NotificationPanelProps = WithSupportProps<{
|
|
|
27
29
|
title: string;
|
|
28
30
|
/** Кнопка настроек и выпадающий список */
|
|
29
31
|
settings?: NotificationPanelSettingsProps;
|
|
30
|
-
/**
|
|
31
|
-
|
|
32
|
+
/** Сегменты для фильтрации */
|
|
33
|
+
segments?: Omit<SegmentedControlProps, 'size' | 'data-test-id'>;
|
|
32
34
|
/** Кнопка в "шапке" панели */
|
|
33
35
|
readAllButton?: Omit<ButtonFunctionProps, 'data-test-id'> & {
|
|
34
|
-
|
|
36
|
+
tooltip?: TooltipProps;
|
|
35
37
|
};
|
|
36
38
|
/** Кнопка внизу панели */
|
|
37
39
|
footerButton?: {
|
|
@@ -55,7 +57,7 @@ export type NotificationPanelProps = WithSupportProps<{
|
|
|
55
57
|
export function NotificationPanel({
|
|
56
58
|
title,
|
|
57
59
|
settings,
|
|
58
|
-
|
|
60
|
+
segments,
|
|
59
61
|
readAllButton,
|
|
60
62
|
footerButton,
|
|
61
63
|
content,
|
|
@@ -76,28 +78,33 @@ export function NotificationPanel({
|
|
|
76
78
|
<TruncateString text={title} data-test-id={TEST_IDS.title} />
|
|
77
79
|
</Typography.SansHeadlineS>
|
|
78
80
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
<div className={styles.notificationPanelHeaderActions}>
|
|
82
|
+
{readAllButton && (
|
|
83
|
+
<WithTooltip tooltip={readAllButton.tooltip}>
|
|
84
|
+
<ButtonFunction
|
|
85
|
+
{...readAllButton}
|
|
86
|
+
onClick={readAllButton.onClick}
|
|
87
|
+
size='xs'
|
|
88
|
+
disabled={readAllButton.disabled || loading}
|
|
89
|
+
data-test-id={TEST_IDS.readAll}
|
|
90
|
+
/>
|
|
91
|
+
</WithTooltip>
|
|
92
|
+
)}
|
|
81
93
|
|
|
82
|
-
|
|
83
|
-
<div className={styles.notificationPanelChips}>
|
|
84
|
-
{chips?.map(chip => (
|
|
85
|
-
<ChipToggle
|
|
86
|
-
{...chip}
|
|
87
|
-
key={chip.label}
|
|
88
|
-
data-test-id={`${TEST_IDS.chip}-${chip.label}`}
|
|
89
|
-
size='xs'
|
|
90
|
-
disabled={chip.disabled || loading}
|
|
91
|
-
/>
|
|
92
|
-
))}
|
|
94
|
+
{settings && <NotificationPanelSettings {...settings} />}
|
|
93
95
|
</div>
|
|
96
|
+
</div>
|
|
94
97
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
<div>
|
|
99
|
+
{segments && (
|
|
100
|
+
<SegmentedControl
|
|
101
|
+
{...segments}
|
|
102
|
+
size='s'
|
|
103
|
+
items={segments.items.map(item => ({
|
|
104
|
+
...item,
|
|
105
|
+
disabled: item.disabled || loading,
|
|
106
|
+
}))}
|
|
107
|
+
data-test-id={TEST_IDS.segments}
|
|
101
108
|
/>
|
|
102
109
|
)}
|
|
103
110
|
</div>
|
package/src/components/NotificationPanel/components/NotificationPanelDivider/styles.module.scss
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
color: styles-tokens-notification-notificationPanel.$sys-neutral-text-light;
|
|
11
11
|
|
|
12
|
+
background-color: styles-tokens-notification-notificationPanel.$sys-neutral-background2-level;
|
|
12
13
|
border-bottom-color: styles-tokens-notification-notificationPanel.$sys-neutral-decor-default;
|
|
13
14
|
border-bottom-style: solid;
|
|
14
15
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const TEST_IDS = {
|
|
2
2
|
title: 'notification-panel__title',
|
|
3
|
-
|
|
3
|
+
segments: 'notification-panel__segments',
|
|
4
4
|
settings: {
|
|
5
5
|
droplist: 'notification-panel__settings__droplist',
|
|
6
6
|
droplistTrigger: 'notification-panel__settings__droplist-trigger',
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
|
|
3
|
+
import { Tooltip, TooltipProps } from '@snack-uikit/tooltip';
|
|
4
|
+
|
|
5
|
+
type WithTooltipProps = PropsWithChildren<{
|
|
6
|
+
tooltip?: TooltipProps;
|
|
7
|
+
}>;
|
|
8
|
+
|
|
9
|
+
export function WithTooltip({ tooltip, children }: WithTooltipProps) {
|
|
10
|
+
if (!tooltip) {
|
|
11
|
+
return children;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return <Tooltip {...tooltip}>{children}</Tooltip>;
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './WithTooltip';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './WithTooltip';
|
|
@@ -9,40 +9,17 @@
|
|
|
9
9
|
display: flex;
|
|
10
10
|
flex-direction: column;
|
|
11
11
|
|
|
12
|
+
background-color: styles-tokens-notification-notificationPanel.$sys-neutral-background2-level;
|
|
12
13
|
border-bottom-color: styles-tokens-notification-notificationPanel.$sys-neutral-decor-default;
|
|
13
14
|
border-bottom-style: solid;
|
|
14
|
-
|
|
15
|
-
&::before {
|
|
16
|
-
pointer-events: none;
|
|
17
|
-
content: '';
|
|
18
|
-
|
|
19
|
-
position: absolute;
|
|
20
|
-
top: 0;
|
|
21
|
-
left: 0;
|
|
22
|
-
|
|
23
|
-
box-sizing: border-box;
|
|
24
|
-
width: 100%;
|
|
25
|
-
height: calc(100% + styles-tokens-notification-notificationPanel.$border-width-notification-panel-container);
|
|
26
|
-
|
|
27
|
-
opacity: styles-tokens-notification-notificationPanel.$opacity-a004;
|
|
28
|
-
background-color: styles-tokens-notification-notificationPanel.$sys-neutral-accent-default;
|
|
29
|
-
border-radius: inherit;
|
|
30
|
-
}
|
|
31
15
|
}
|
|
32
|
-
.
|
|
16
|
+
.notificationPanelSegments {
|
|
33
17
|
@include styles-tokens-notification-notificationPanel.composite-var(styles-tokens-notification-notificationPanel.$notification-panel-header-chips);
|
|
34
18
|
|
|
35
19
|
display: flex;
|
|
36
20
|
align-items: center;
|
|
37
21
|
}
|
|
38
22
|
|
|
39
|
-
.notificationPanelHeaderFunctions {
|
|
40
|
-
display: flex;
|
|
41
|
-
align-items: center;
|
|
42
|
-
justify-content: space-between;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
23
|
.notificationPanelHeadline {
|
|
47
24
|
@include styles-tokens-notification-notificationPanel.composite-var(styles-tokens-notification-notificationPanel.$notification-panel-header-headline);
|
|
48
25
|
|
|
@@ -81,7 +58,7 @@
|
|
|
81
58
|
|
|
82
59
|
color: styles-tokens-notification-notificationPanel.$sys-neutral-text-light;
|
|
83
60
|
|
|
84
|
-
background:
|
|
61
|
+
background-color: styles-tokens-notification-notificationPanel.$sys-neutral-background2-level;
|
|
85
62
|
border-color: styles-tokens-notification-notificationPanel.$sys-neutral-decor-default;
|
|
86
63
|
border-top-style: solid;
|
|
87
64
|
border-right: none;
|
|
@@ -115,6 +92,8 @@
|
|
|
115
92
|
box-sizing: border-box;
|
|
116
93
|
width: 100%;
|
|
117
94
|
height: 100%;
|
|
95
|
+
|
|
96
|
+
background-color: styles-tokens-notification-notificationPanel.$sys-neutral-background2-level;
|
|
118
97
|
}
|
|
119
98
|
|
|
120
99
|
.scrollStub {
|
|
@@ -122,3 +101,9 @@
|
|
|
122
101
|
margin-top: calc(styles-tokens-notification-notificationPanel.$dimension-025m / -2);
|
|
123
102
|
background: transparent;
|
|
124
103
|
}
|
|
104
|
+
|
|
105
|
+
.notificationPanelHeaderActions {
|
|
106
|
+
display: flex;
|
|
107
|
+
column-gap: styles-tokens-notification-notificationPanel.$dimension-1m;
|
|
108
|
+
align-items: center;
|
|
109
|
+
}
|