@snack-uikit/notification 0.4.2 → 0.5.1
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 +25 -0
- package/README.md +8 -8
- package/dist/components/NotificationCard/NotificationCard.d.ts +1 -4
- package/dist/components/NotificationCard/NotificationCard.js +4 -5
- package/dist/components/NotificationCard/components/NotificationCardFunction.js +1 -1
- package/dist/components/NotificationCard/components/NotificationCardSkeleton.js +1 -1
- package/dist/components/NotificationCard/constants.d.ts +7 -7
- package/dist/components/NotificationCard/constants.js +7 -8
- package/dist/components/NotificationCard/helpers.d.ts +1 -1
- package/dist/components/NotificationCard/helpers.js +6 -6
- package/dist/components/NotificationCard/types.d.ts +3 -0
- package/dist/components/NotificationCard/types.js +1 -0
- package/dist/components/NotificationPanel/NotificationPanel.d.ts +0 -5
- package/dist/components/NotificationPanel/NotificationPanel.js +1 -5
- package/dist/components/NotificationPanel/components/NotificationPanelBlank/NotificationPanelBlank.d.ts +0 -3
- package/dist/components/NotificationPanel/components/NotificationPanelBlank/NotificationPanelBlank.js +2 -3
- package/dist/components/NotificationPanel/components/NotificationPanelSettings/NotificationPanelSettings.js +1 -1
- package/dist/components/NotificationPanel/components/NotificationPanelSettings/NotificationPanelSettingsDroplist.js +1 -1
- package/dist/helperComponents/NotificationPanelPopover/NotificationPanelPopover.js +2 -2
- package/package.json +14 -14
- package/src/components/NotificationCard/NotificationCard.tsx +10 -15
- package/src/components/NotificationCard/components/NotificationCardFunction.tsx +2 -2
- package/src/components/NotificationCard/constants.ts +7 -7
- package/src/components/NotificationCard/helpers.tsx +7 -6
- package/src/components/NotificationCard/types.ts +5 -0
- package/src/components/NotificationPanel/NotificationPanel.tsx +2 -7
- package/src/components/NotificationPanel/components/NotificationPanelBlank/NotificationPanelBlank.tsx +4 -13
- package/src/components/NotificationPanel/components/NotificationPanelSettings/NotificationPanelSettings.tsx +1 -1
- package/src/components/NotificationPanel/components/NotificationPanelSettings/NotificationPanelSettingsDroplist.tsx +1 -1
- package/src/helperComponents/NotificationPanelPopover/NotificationPanelPopover.tsx +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,31 @@
|
|
|
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.1 (2023-12-14)
|
|
7
|
+
|
|
8
|
+
### Only dependencies have been changed
|
|
9
|
+
* [@snack-uikit/chips@0.10.1](https://git.sbercloud.tech/sbercloud-ui/tokens-design-system/snack-uikit/-/blob/master/packages/chips/CHANGELOG.md)
|
|
10
|
+
* [@snack-uikit/droplist@0.12.1](https://git.sbercloud.tech/sbercloud-ui/tokens-design-system/snack-uikit/-/blob/master/packages/droplist/CHANGELOG.md)
|
|
11
|
+
* [@snack-uikit/icons@0.19.1](https://git.sbercloud.tech/sbercloud-ui/tokens-design-system/snack-uikit/-/blob/master/packages/icons/CHANGELOG.md)
|
|
12
|
+
* [@snack-uikit/link@0.9.1](https://git.sbercloud.tech/sbercloud-ui/tokens-design-system/snack-uikit/-/blob/master/packages/link/CHANGELOG.md)
|
|
13
|
+
* [@snack-uikit/popover-private@0.12.1](https://git.sbercloud.tech/sbercloud-ui/tokens-design-system/snack-uikit/-/blob/master/packages/popover-private/CHANGELOG.md)
|
|
14
|
+
* [@snack-uikit/truncate-string@0.4.1](https://git.sbercloud.tech/sbercloud-ui/tokens-design-system/snack-uikit/-/blob/master/packages/truncate-string/CHANGELOG.md)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
# 0.5.0 (2023-12-14)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### BREAKING CHANGES
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
* **FF-3729:** replace enum with unions ([910db4a](https://github.com/cloud-ru-tech/snack-uikit/commit/910db4aa8231ccbc58e538e5c5c1f461b1dec275))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
6
31
|
## 0.4.2 (2023-12-07)
|
|
7
32
|
|
|
8
33
|
### Only dependencies have been changed
|
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ const cards = [
|
|
|
17
17
|
{
|
|
18
18
|
id: 'cardId',
|
|
19
19
|
label: ['Category', 'Subcategory'].join('・'),
|
|
20
|
-
appearance:
|
|
20
|
+
appearance: 'errorCritical',
|
|
21
21
|
title: 'Title truncate two line',
|
|
22
22
|
content: `Demo content.`,
|
|
23
23
|
link: {
|
|
@@ -49,12 +49,12 @@ const cards = [
|
|
|
49
49
|
}}
|
|
50
50
|
chips={[
|
|
51
51
|
{
|
|
52
|
-
label:
|
|
52
|
+
label: 'all',
|
|
53
53
|
checked: true,
|
|
54
54
|
onChange() { /* */ },
|
|
55
55
|
},
|
|
56
56
|
{
|
|
57
|
-
label:
|
|
57
|
+
label: 'unread',
|
|
58
58
|
checked: false,
|
|
59
59
|
onChange() { /* */ },
|
|
60
60
|
},
|
|
@@ -85,7 +85,7 @@ const cards = [
|
|
|
85
85
|
| content* | `ReactNode` | - | Контент уведомления |
|
|
86
86
|
| title* | `string` | - | Заголовок уведомления |
|
|
87
87
|
| id* | `string` | - | Идентификатор уведомления |
|
|
88
|
-
| appearance | enum Appearance: `"neutral"`, `"error"`, `"errorCritical"`, `"warning"`, `"success"` |
|
|
88
|
+
| appearance | enum Appearance: `"neutral"`, `"error"`, `"errorCritical"`, `"warning"`, `"success"` | neutral | Тип уведомления |
|
|
89
89
|
| label | `string` | - | Лейбл перед заголовком |
|
|
90
90
|
| unread | `boolean` | - | Управление состоянием прочитано/не прочитано |
|
|
91
91
|
| link | `Omit<LinkProps, "data-test-id" \| "size" \| "onColor" \| "onSurface">` | - | Ссылка |
|
|
@@ -115,10 +115,10 @@ const cards = [
|
|
|
115
115
|
| hoverDelayClose | `number` | - | Задержка закрытия по ховеру |
|
|
116
116
|
| offset | `number` | 0 | Отступ поповера от его триггер-элемента (в пикселях). |
|
|
117
117
|
| closeOnEscapeKey | `boolean` | true | Закрывать ли по нажатию на кнопку `Esc` |
|
|
118
|
-
| triggerClickByKeys | `boolean` | true | Вызывается ли попоповер по нажатию клавиш Enter/Space (при trigger = `
|
|
118
|
+
| triggerClickByKeys | `boolean` | true | Вызывается ли попоповер по нажатию клавиш Enter/Space (при trigger = `click`) |
|
|
119
119
|
| triggerRef | `ForwardedRef<HTMLElement \| ReferenceType>` | - | Ref ссылка на триггер |
|
|
120
|
-
| trigger | enum Trigger: `"click"`, `"hover"`, `"focusVisible"`, `"focus"`, `"hoverAndFocusVisible"`, `"hoverAndFocus"`, `"clickAndFocusVisible"` | - | Условие отображения поповера: <br> - `
|
|
121
|
-
| placement | enum Placement: `"left"`, `"left-start"`, `"left-end"`, `"right"`, `"right-start"`, `"right-end"`, `"top"`, `"top-start"`, `"top-end"`, `"bottom"`, `"bottom-start"`, `"bottom-end"` |
|
|
120
|
+
| trigger | enum Trigger: `"click"`, `"hover"`, `"focusVisible"`, `"focus"`, `"hoverAndFocusVisible"`, `"hoverAndFocus"`, `"clickAndFocusVisible"` | - | Условие отображения поповера: <br> - `click` - открывать по клику <br> - `hover` - открывать по ховеру <br> - `focusVisible` - открывать по focus-visible <br> - `focus` - открывать по фокусу <br> - `hoverAndFocusVisible` - открывать по ховеру и focus-visible <br> - `hoverAndFocus` - открывать по ховеру и фокусу <br> - `clickAndFocusVisible` - открывать по клику и focus-visible |
|
|
121
|
+
| placement | enum Placement: `"left"`, `"left-start"`, `"left-end"`, `"right"`, `"right-start"`, `"right-end"`, `"top"`, `"top-start"`, `"top-end"`, `"bottom"`, `"bottom-start"`, `"bottom-end"` | top | Положение поповера относительно своего триггера (children). |
|
|
122
122
|
| contentClassName | `string` | - | CSS-класс для элемента содержащего контент |
|
|
123
123
|
## NotificationPanel.Blank
|
|
124
124
|
### Props
|
|
@@ -127,7 +127,7 @@ const cards = [
|
|
|
127
127
|
| title* | `ReactNode` | - | Заголовок |
|
|
128
128
|
| description | `ReactNode` | - | Описание |
|
|
129
129
|
| icon | `JSXElementConstructor<{ size?: number; className?: string; }>` | - | Иконка |
|
|
130
|
-
| iconAppearance | enum Appearance: `"
|
|
130
|
+
| iconAppearance | enum Appearance: `"neutral"`, `"primary"`, `"red"`, `"orange"`, `"yellow"`, `"green"`, `"blue"`, `"violet"`, `"pink"` | - | Цвет обводки для иконки |
|
|
131
131
|
| className | `string` | - | CSS-класс |
|
|
132
132
|
|
|
133
133
|
|
|
@@ -2,7 +2,7 @@ import { MouseEventHandler, ReactNode } from 'react';
|
|
|
2
2
|
import { ItemSingleProps } from '@snack-uikit/droplist';
|
|
3
3
|
import { LinkProps } from '@snack-uikit/link';
|
|
4
4
|
import { WithSupportProps } from '@snack-uikit/utils';
|
|
5
|
-
import { Appearance } from './
|
|
5
|
+
import { Appearance } from './types';
|
|
6
6
|
export type NotificationCardProps = WithSupportProps<{
|
|
7
7
|
/** Идентификатор уведомления */
|
|
8
8
|
id: string;
|
|
@@ -31,6 +31,3 @@ export type NotificationCardProps = WithSupportProps<{
|
|
|
31
31
|
}>;
|
|
32
32
|
/** Компонент карточки уведомления */
|
|
33
33
|
export declare function NotificationCard({ id, appearance, label, unread, title, content, link, date, onClick, actions, onVisible, className, ...rest }: NotificationCardProps): import("react/jsx-runtime").JSX.Element;
|
|
34
|
-
export declare namespace NotificationCard {
|
|
35
|
-
var appearances: typeof Appearance;
|
|
36
|
-
}
|
|
@@ -17,15 +17,15 @@ import { TruncateString } from '@snack-uikit/truncate-string';
|
|
|
17
17
|
import { Typography } from '@snack-uikit/typography';
|
|
18
18
|
import { extractSupportProps } from '@snack-uikit/utils';
|
|
19
19
|
import { NotificationCardFunction } from './components';
|
|
20
|
-
import {
|
|
20
|
+
import { APPEARANCE, TEST_IDS } from './constants';
|
|
21
21
|
import { getIcon } from './helpers';
|
|
22
22
|
import styles from './styles.module.css';
|
|
23
23
|
/** Компонент карточки уведомления */
|
|
24
24
|
export function NotificationCard(_a) {
|
|
25
|
-
var { id, appearance =
|
|
25
|
+
var { id, appearance = APPEARANCE.Neutral, label, unread, title, content, link, date, onClick, actions, onVisible, className } = _a, rest = __rest(_a, ["id", "appearance", "label", "unread", "title", "content", "link", "date", "onClick", "actions", "onVisible", "className"]);
|
|
26
26
|
const { icon, linkOnColor } = useMemo(() => ({
|
|
27
27
|
icon: getIcon(appearance),
|
|
28
|
-
linkOnColor: appearance ===
|
|
28
|
+
linkOnColor: appearance === APPEARANCE.ErrorCritical ? 'red' : undefined,
|
|
29
29
|
}), [appearance]);
|
|
30
30
|
const [isDroplistOpen, setDroplistOpen] = useState(false);
|
|
31
31
|
const cardRef = useRef(null);
|
|
@@ -55,6 +55,5 @@ export function NotificationCard(_a) {
|
|
|
55
55
|
e.stopPropagation();
|
|
56
56
|
(_a = link === null || link === void 0 ? void 0 : link.onClick) === null || _a === void 0 ? void 0 : _a.call(link, e);
|
|
57
57
|
};
|
|
58
|
-
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)
|
|
58
|
+
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 })), showFooter && (_jsxs("div", { className: styles.notificationCardFooter, children: [link && (_jsx(Link, Object.assign({}, link, { onClick: handleLinkClick, onColor: linkOnColor, onSurface: 'decor', size: 's', "data-test-id": TEST_IDS.link }))), date && (_jsx(Typography.LightLabelS, { className: styles.notificationCardDate, "data-test-id": TEST_IDS.date, children: date }))] }))] })));
|
|
59
59
|
}
|
|
60
|
-
NotificationCard.appearances = Appearance;
|
|
@@ -9,5 +9,5 @@ export function NotificationCardFunction({ actions, open, setDroplistOpen }) {
|
|
|
9
9
|
const { firstElementRefCallback, triggerElementRef, handleDroplistFocusLeave, handleTriggerKeyDown, handleDroplistItemKeyDown, handleDroplistItemClick, } = Droplist.useKeyboardNavigation({
|
|
10
10
|
setDroplistOpen,
|
|
11
11
|
});
|
|
12
|
-
return (_jsx("div",
|
|
12
|
+
return (_jsx("div", { className: styles.notificationCardFunction, "data-test-id": TEST_IDS.actions.wrapper, children: _jsx(Droplist, { open: open, onOpenChange: setDroplistOpen, placement: 'bottom-end', firstElementRefCallback: firstElementRefCallback, onFocusLeave: handleDroplistFocusLeave, triggerRef: triggerElementRef, useScroll: true, triggerElement: _jsx(ButtonFunction, { size: 's', icon: _jsx(KebabSVG, {}), onKeyDown: handleTriggerKeyDown, "data-test-id": TEST_IDS.actions.droplistTrigger }), "data-test-id": TEST_IDS.actions.droplist, children: actions.map(action => (_createElement(Droplist.ItemSingle, Object.assign({}, action, { key: action.option, onClick: e => handleDroplistItemClick(e, action.onClick), "data-test-id": TEST_IDS.actions.droplistAction, onKeyDown: handleDroplistItemKeyDown })))) }) }));
|
|
13
13
|
}
|
|
@@ -4,5 +4,5 @@ import { TEST_IDS } from '../../NotificationPanel/constants';
|
|
|
4
4
|
import styles from '../styles.module.css';
|
|
5
5
|
const BORDER_RADIUS = 24;
|
|
6
6
|
export function NotificationCardSkeleton() {
|
|
7
|
-
return (_jsxs("div",
|
|
7
|
+
return (_jsxs("div", { className: styles.notificationCard, "data-test-id": TEST_IDS.skeleton, "data-skeleton": true, children: [_jsx(Skeleton, { width: 140, height: 11, borderRadius: BORDER_RADIUS }), _jsxs("div", { className: styles.notificationCardTitle, "data-center": true, children: [_jsx("div", { className: styles.notificationCardTitleIcon, children: _jsx(Skeleton, { width: 16, height: 16, borderRadius: BORDER_RADIUS }) }), _jsx(Skeleton, { width: 140, height: 14, borderRadius: BORDER_RADIUS })] }), _jsx("div", { className: styles.notificationCardContent, children: _jsx(SkeletonText, { lines: 3, borderRadius: BORDER_RADIUS }) }), _jsxs("div", { className: styles.notificationCardFooter, children: [_jsx(Skeleton, { width: 140, borderRadius: BORDER_RADIUS, height: 12 }), _jsx(Skeleton, { width: 140, borderRadius: BORDER_RADIUS, height: 11 })] })] }));
|
|
8
8
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export declare
|
|
2
|
-
Neutral
|
|
3
|
-
Error
|
|
4
|
-
ErrorCritical
|
|
5
|
-
Warning
|
|
6
|
-
Success
|
|
7
|
-
}
|
|
1
|
+
export declare const APPEARANCE: {
|
|
2
|
+
readonly Neutral: "neutral";
|
|
3
|
+
readonly Error: "error";
|
|
4
|
+
readonly ErrorCritical: "errorCritical";
|
|
5
|
+
readonly Warning: "warning";
|
|
6
|
+
readonly Success: "success";
|
|
7
|
+
};
|
|
8
8
|
export declare const TEST_IDS: {
|
|
9
9
|
label: string;
|
|
10
10
|
title: string;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
})(Appearance || (Appearance = {}));
|
|
1
|
+
export const APPEARANCE = {
|
|
2
|
+
Neutral: 'neutral',
|
|
3
|
+
Error: 'error',
|
|
4
|
+
ErrorCritical: 'errorCritical',
|
|
5
|
+
Warning: 'warning',
|
|
6
|
+
Success: 'success',
|
|
7
|
+
};
|
|
9
8
|
export const TEST_IDS = {
|
|
10
9
|
label: 'notification-card__label',
|
|
11
10
|
title: 'notification-card__title',
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Appearance } from './
|
|
1
|
+
import { Appearance } from './types';
|
|
2
2
|
export declare function getIcon(appearance: Appearance): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { AlarmFilledSVG, CheckFilledSVG, CrossFilledSVG, InfoFilledSVG } from '@snack-uikit/icons';
|
|
3
|
-
import {
|
|
3
|
+
import { APPEARANCE } from './constants';
|
|
4
4
|
export function getIcon(appearance) {
|
|
5
5
|
switch (appearance) {
|
|
6
|
-
case
|
|
6
|
+
case APPEARANCE.Success:
|
|
7
7
|
return _jsx(CheckFilledSVG, { size: 16 });
|
|
8
|
-
case
|
|
9
|
-
case
|
|
8
|
+
case APPEARANCE.Error:
|
|
9
|
+
case APPEARANCE.ErrorCritical:
|
|
10
10
|
return _jsx(CrossFilledSVG, { size: 16 });
|
|
11
|
-
case
|
|
11
|
+
case APPEARANCE.Warning:
|
|
12
12
|
return _jsx(AlarmFilledSVG, { size: 16 });
|
|
13
|
-
case
|
|
13
|
+
case APPEARANCE.Neutral:
|
|
14
14
|
return _jsx(InfoFilledSVG, { size: 16 });
|
|
15
15
|
default:
|
|
16
16
|
return null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -31,11 +31,6 @@ export type NotificationPanelProps = {
|
|
|
31
31
|
} & Omit<NotificationPanelPopoverProps, 'children' | 'content'>;
|
|
32
32
|
/** Компонент панели для уведомлений */
|
|
33
33
|
export declare function NotificationPanel({ title, triggerElement, settings, chips, readAllButton, footerButton, content, loading, skeletonsAmount, ...rest }: NotificationPanelProps): import("react/jsx-runtime").JSX.Element;
|
|
34
|
-
export declare namespace NotificationPanel {
|
|
35
|
-
var placements: typeof import("@snack-uikit/popover-private/dist/constants").Placement;
|
|
36
|
-
var triggers: typeof import("@snack-uikit/popover-private/dist/constants").Trigger;
|
|
37
|
-
var widthStrategies: typeof import("@snack-uikit/popover-private/dist/constants").PopoverWidthStrategy;
|
|
38
|
-
}
|
|
39
34
|
export declare namespace NotificationPanel {
|
|
40
35
|
const Blank: typeof NotificationPanelBlank;
|
|
41
36
|
type BlankProps = NotificationPanelBlankProps;
|
|
@@ -14,7 +14,6 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
14
14
|
import { useMemo } from 'react';
|
|
15
15
|
import { ButtonFunction } from '@snack-uikit/button';
|
|
16
16
|
import { ChipToggle } from '@snack-uikit/chips';
|
|
17
|
-
import { PopoverPrivate } from '@snack-uikit/popover-private';
|
|
18
17
|
import { Scroll } from '@snack-uikit/scroll';
|
|
19
18
|
import { SkeletonContextProvider, WithSkeleton } from '@snack-uikit/skeleton';
|
|
20
19
|
import { TruncateString } from '@snack-uikit/truncate-string';
|
|
@@ -28,11 +27,8 @@ import styles from './styles.module.css';
|
|
|
28
27
|
export function NotificationPanel(_a) {
|
|
29
28
|
var { title, triggerElement, settings, chips, readAllButton, footerButton, content, loading, skeletonsAmount = 2 } = _a, rest = __rest(_a, ["title", "triggerElement", "settings", "chips", "readAllButton", "footerButton", "content", "loading", "skeletonsAmount"]);
|
|
30
29
|
const skeletons = useMemo(() => Array.from({ length: skeletonsAmount }, (_, i) => i), [skeletonsAmount]);
|
|
31
|
-
return (_jsx(NotificationPanelPopover, Object.assign({}, rest, { content: _jsxs(_Fragment, { children: [_jsxs("div",
|
|
30
|
+
return (_jsx(NotificationPanelPopover, Object.assign({}, rest, { content: _jsxs(_Fragment, { 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 }) }), settings && _jsx(NotificationPanelSettings, Object.assign({}, settings))] }), _jsxs("div", { className: styles.notificationPanelHeaderFunctions, children: [_jsx("div", { className: styles.notificationPanelChips, children: chips === null || chips === void 0 ? void 0 : chips.map(chip => (_createElement(ChipToggle, Object.assign({}, chip, { key: chip.label, "data-test-id": `${TEST_IDS.chip}-${chip.label}`, size: 'xs', disabled: chip.disabled || loading })))) }), readAllButton && (_jsx(ButtonFunction, Object.assign({}, readAllButton, { disabled: readAllButton.disabled || loading, "data-test-id": TEST_IDS.readAll })))] })] }), _jsx(Scroll, { size: 'm', className: styles.notificationPanelBody, children: loading ? (_jsx(SkeletonContextProvider, { loading: loading || false, children: skeletons.map(skeleton => (_jsx(WithSkeleton, { skeleton: _jsx(NotificationCardSkeleton, {}) }, skeleton))) })) : (content) }), !loading && footerButton && (_jsx("button", { className: styles.notificationPanelFooterButton, "data-test-id": TEST_IDS.footerButton, children: _jsx(Typography.SansLabelS, { children: footerButton.label }) }))] }), children: triggerElement })));
|
|
32
31
|
}
|
|
33
|
-
NotificationPanel.placements = PopoverPrivate.placements;
|
|
34
|
-
NotificationPanel.triggers = PopoverPrivate.triggers;
|
|
35
|
-
NotificationPanel.widthStrategies = PopoverPrivate.widthStrategies;
|
|
36
32
|
(function (NotificationPanel) {
|
|
37
33
|
NotificationPanel.Blank = NotificationPanelBlank;
|
|
38
34
|
})(NotificationPanel || (NotificationPanel = {}));
|
|
@@ -15,6 +15,3 @@ export type NotificationPanelBlankProps = WithSupportProps<{
|
|
|
15
15
|
}>;
|
|
16
16
|
/** Компонента для "заглушки" вместо карточек в панели */
|
|
17
17
|
export declare function NotificationPanelBlank({ icon, iconAppearance, title, description, className, ...rest }: NotificationPanelBlankProps): import("react/jsx-runtime").JSX.Element;
|
|
18
|
-
export declare namespace NotificationPanelBlank {
|
|
19
|
-
var iconAppearances: typeof import("@snack-uikit/icon-predefined/dist/constants").Appearance;
|
|
20
|
-
}
|
|
@@ -18,7 +18,6 @@ import { TEST_IDS } from '../../constants';
|
|
|
18
18
|
import styles from './styles.module.css';
|
|
19
19
|
/** Компонента для "заглушки" вместо карточек в панели */
|
|
20
20
|
export function NotificationPanelBlank(_a) {
|
|
21
|
-
var { icon, iconAppearance =
|
|
22
|
-
return (_jsxs("div", Object.assign({ className: cn(styles.notificationPanelBlank, className) }, extractSupportProps(rest), { children: [icon &&
|
|
21
|
+
var { icon, iconAppearance = 'neutral', title, description, className } = _a, rest = __rest(_a, ["icon", "iconAppearance", "title", "description", "className"]);
|
|
22
|
+
return (_jsxs("div", Object.assign({ className: cn(styles.notificationPanelBlank, className) }, extractSupportProps(rest), { children: [icon && _jsx(IconPredefined, { icon: icon, appearance: iconAppearance, size: 'l', "data-test-id": TEST_IDS.blank.icon }), _jsxs("div", { className: styles.notificationPanelBlankContent, children: [_jsx(Typography.SansTitleS, { tag: 'div', className: styles.notificationPanelBlankTitle, "data-test-id": TEST_IDS.blank.title, children: title }), _jsx(Typography.SansBodyM, { tag: 'div', className: styles.notificationPanelBlankDescription, "data-test-id": TEST_IDS.blank.description, children: description })] })] })));
|
|
23
23
|
}
|
|
24
|
-
NotificationPanelBlank.iconAppearances = IconPredefined.appearances;
|
|
@@ -4,7 +4,7 @@ import { KebabSVG } from '@snack-uikit/icons';
|
|
|
4
4
|
import { TEST_IDS } from '../../constants';
|
|
5
5
|
import { NotificationPanelSettingsDroplist } from './NotificationPanelSettingsDroplist';
|
|
6
6
|
export function NotificationPanelSettings({ actions, button }) {
|
|
7
|
-
const buttonProps = Object.assign(Object.assign({}, button), { size:
|
|
7
|
+
const buttonProps = Object.assign(Object.assign({}, button), { size: 's', icon: button.icon || _jsx(KebabSVG, {}), 'data-test-id': TEST_IDS.settings.droplistTrigger });
|
|
8
8
|
if (!(actions === null || actions === void 0 ? void 0 : actions.length)) {
|
|
9
9
|
return _jsx(ButtonSimple, Object.assign({}, buttonProps));
|
|
10
10
|
}
|
|
@@ -9,5 +9,5 @@ export function NotificationPanelSettingsDroplist({ actions, button }) {
|
|
|
9
9
|
const { firstElementRefCallback, triggerElementRef, handleDroplistFocusLeave, handleTriggerKeyDown, handleDroplistItemKeyDown, handleDroplistItemClick, } = Droplist.useKeyboardNavigation({
|
|
10
10
|
setDroplistOpen,
|
|
11
11
|
});
|
|
12
|
-
return (_jsx(Droplist,
|
|
12
|
+
return (_jsx(Droplist, { open: isDroplistOpen, onOpenChange: setDroplistOpen, firstElementRefCallback: firstElementRefCallback, onFocusLeave: handleDroplistFocusLeave, useScroll: true, triggerRef: triggerElementRef, triggerElement: _jsx(ButtonSimple, Object.assign({}, button, { onKeyDown: handleTriggerKeyDown })), placement: 'bottom-end', "data-test-id": TEST_IDS.settings.droplist, children: actions.map(action => (_createElement(Droplist.ItemSingle, Object.assign({}, action, { key: action.option, onClick: e => handleDroplistItemClick(e, action.onClick), onKeyDown: handleDroplistItemKeyDown, "data-test-id": TEST_IDS.settings.droplistAction })))) }));
|
|
13
13
|
}
|
|
@@ -14,9 +14,9 @@ import cn from 'classnames';
|
|
|
14
14
|
import { PopoverPrivate } from '@snack-uikit/popover-private';
|
|
15
15
|
import styles from './styles.module.css';
|
|
16
16
|
export function NotificationPanelPopover(_a) {
|
|
17
|
-
var { content, trigger =
|
|
17
|
+
var { content, trigger = 'click', placement = 'bottom-end', children, contentClassName } = _a, otherProps = __rest(_a, ["content", "trigger", "placement", "children", "contentClassName"]);
|
|
18
18
|
if (!children) {
|
|
19
19
|
return null;
|
|
20
20
|
}
|
|
21
|
-
return (_jsx(PopoverPrivate, Object.assign({ fallbackPlacements: [], placement: placement, popoverContent: _jsx("div",
|
|
21
|
+
return (_jsx(PopoverPrivate, Object.assign({ fallbackPlacements: [], placement: placement, popoverContent: _jsx("div", { className: styles.notificationPanelPopoverWrap, children: _jsx("div", { className: cn(styles.notificationPanelPopover, contentClassName), children: content }) }), trigger: trigger, hasArrow: false, heightStrategy: 'lte' }, otherProps, { children: children })));
|
|
22
22
|
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Notification",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.5.1",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -32,19 +32,19 @@
|
|
|
32
32
|
"license": "Apache-2.0",
|
|
33
33
|
"scripts": {},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@snack-uikit/button": "0.
|
|
36
|
-
"@snack-uikit/chips": "0.
|
|
37
|
-
"@snack-uikit/droplist": "0.
|
|
38
|
-
"@snack-uikit/icon-predefined": "0.
|
|
39
|
-
"@snack-uikit/icons": "0.19.
|
|
40
|
-
"@snack-uikit/link": "0.
|
|
41
|
-
"@snack-uikit/popover-private": "0.
|
|
42
|
-
"@snack-uikit/scroll": "0.
|
|
43
|
-
"@snack-uikit/skeleton": "0.3.
|
|
44
|
-
"@snack-uikit/truncate-string": "0.
|
|
45
|
-
"@snack-uikit/typography": "0.
|
|
46
|
-
"@snack-uikit/utils": "3.
|
|
35
|
+
"@snack-uikit/button": "0.15.0",
|
|
36
|
+
"@snack-uikit/chips": "0.10.1",
|
|
37
|
+
"@snack-uikit/droplist": "0.12.1",
|
|
38
|
+
"@snack-uikit/icon-predefined": "0.4.0",
|
|
39
|
+
"@snack-uikit/icons": "0.19.1",
|
|
40
|
+
"@snack-uikit/link": "0.9.1",
|
|
41
|
+
"@snack-uikit/popover-private": "0.12.1",
|
|
42
|
+
"@snack-uikit/scroll": "0.5.0",
|
|
43
|
+
"@snack-uikit/skeleton": "0.3.2",
|
|
44
|
+
"@snack-uikit/truncate-string": "0.4.1",
|
|
45
|
+
"@snack-uikit/typography": "0.6.0",
|
|
46
|
+
"@snack-uikit/utils": "3.2.0",
|
|
47
47
|
"classnames": "2.3.2"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "62f43bf0cbfd611d0b746117400f67096b1790f6"
|
|
50
50
|
}
|
|
@@ -8,9 +8,10 @@ import { Typography } from '@snack-uikit/typography';
|
|
|
8
8
|
import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
|
|
9
9
|
|
|
10
10
|
import { NotificationCardFunction } from './components';
|
|
11
|
-
import {
|
|
11
|
+
import { APPEARANCE, TEST_IDS } from './constants';
|
|
12
12
|
import { getIcon } from './helpers';
|
|
13
13
|
import styles from './styles.module.scss';
|
|
14
|
+
import { Appearance } from './types';
|
|
14
15
|
|
|
15
16
|
export type NotificationCardProps = WithSupportProps<{
|
|
16
17
|
/** Идентификатор уведомления */
|
|
@@ -45,7 +46,7 @@ export type NotificationCardProps = WithSupportProps<{
|
|
|
45
46
|
/** Компонент карточки уведомления */
|
|
46
47
|
export function NotificationCard({
|
|
47
48
|
id,
|
|
48
|
-
appearance =
|
|
49
|
+
appearance = APPEARANCE.Neutral,
|
|
49
50
|
label,
|
|
50
51
|
unread,
|
|
51
52
|
title,
|
|
@@ -58,10 +59,10 @@ export function NotificationCard({
|
|
|
58
59
|
className,
|
|
59
60
|
...rest
|
|
60
61
|
}: NotificationCardProps) {
|
|
61
|
-
const { icon, linkOnColor } = useMemo(
|
|
62
|
+
const { icon, linkOnColor } = useMemo<{ icon: ReturnType<typeof getIcon>; linkOnColor: LinkProps['onColor'] }>(
|
|
62
63
|
() => ({
|
|
63
64
|
icon: getIcon(appearance),
|
|
64
|
-
linkOnColor: appearance ===
|
|
65
|
+
linkOnColor: appearance === APPEARANCE.ErrorCritical ? 'red' : undefined,
|
|
65
66
|
}),
|
|
66
67
|
[appearance],
|
|
67
68
|
);
|
|
@@ -122,7 +123,7 @@ export function NotificationCard({
|
|
|
122
123
|
)}
|
|
123
124
|
|
|
124
125
|
{label && (
|
|
125
|
-
<Typography.LightLabelS tag=
|
|
126
|
+
<Typography.LightLabelS tag='div' className={styles.notificationCardLabel}>
|
|
126
127
|
<TruncateString maxLines={1} text={label} data-test-id={TEST_IDS.label} />
|
|
127
128
|
</Typography.LightLabelS>
|
|
128
129
|
)}
|
|
@@ -130,17 +131,13 @@ export function NotificationCard({
|
|
|
130
131
|
<div className={styles.notificationCardTitle}>
|
|
131
132
|
<div className={styles.notificationCardTitleIcon}>{icon}</div>
|
|
132
133
|
|
|
133
|
-
<Typography.SansTitleS tag=
|
|
134
|
+
<Typography.SansTitleS tag='div' className={styles.notificationCardTitleText}>
|
|
134
135
|
<TruncateString maxLines={2} text={title} data-test-id={TEST_IDS.title} />
|
|
135
136
|
</Typography.SansTitleS>
|
|
136
137
|
</div>
|
|
137
138
|
|
|
138
139
|
{content && (
|
|
139
|
-
<Typography.SansBodyS
|
|
140
|
-
tag={Typography.tags.div}
|
|
141
|
-
className={styles.notificationCardContent}
|
|
142
|
-
data-test-id={TEST_IDS.content}
|
|
143
|
-
>
|
|
140
|
+
<Typography.SansBodyS tag='div' className={styles.notificationCardContent} data-test-id={TEST_IDS.content}>
|
|
144
141
|
{content}
|
|
145
142
|
</Typography.SansBodyS>
|
|
146
143
|
)}
|
|
@@ -152,8 +149,8 @@ export function NotificationCard({
|
|
|
152
149
|
{...link}
|
|
153
150
|
onClick={handleLinkClick}
|
|
154
151
|
onColor={linkOnColor}
|
|
155
|
-
onSurface=
|
|
156
|
-
size=
|
|
152
|
+
onSurface='decor'
|
|
153
|
+
size='s'
|
|
157
154
|
data-test-id={TEST_IDS.link}
|
|
158
155
|
/>
|
|
159
156
|
)}
|
|
@@ -168,5 +165,3 @@ export function NotificationCard({
|
|
|
168
165
|
</div>
|
|
169
166
|
);
|
|
170
167
|
}
|
|
171
|
-
|
|
172
|
-
NotificationCard.appearances = Appearance;
|
|
@@ -30,14 +30,14 @@ export function NotificationCardFunction({ actions, open, setDroplistOpen }: Not
|
|
|
30
30
|
<Droplist
|
|
31
31
|
open={open}
|
|
32
32
|
onOpenChange={setDroplistOpen}
|
|
33
|
-
placement=
|
|
33
|
+
placement='bottom-end'
|
|
34
34
|
firstElementRefCallback={firstElementRefCallback}
|
|
35
35
|
onFocusLeave={handleDroplistFocusLeave}
|
|
36
36
|
triggerRef={triggerElementRef}
|
|
37
37
|
useScroll
|
|
38
38
|
triggerElement={
|
|
39
39
|
<ButtonFunction
|
|
40
|
-
size=
|
|
40
|
+
size='s'
|
|
41
41
|
icon={<KebabSVG />}
|
|
42
42
|
onKeyDown={handleTriggerKeyDown}
|
|
43
43
|
data-test-id={TEST_IDS.actions.droplistTrigger}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export
|
|
2
|
-
Neutral
|
|
3
|
-
Error
|
|
4
|
-
ErrorCritical
|
|
5
|
-
Warning
|
|
6
|
-
Success
|
|
7
|
-
}
|
|
1
|
+
export const APPEARANCE = {
|
|
2
|
+
Neutral: 'neutral',
|
|
3
|
+
Error: 'error',
|
|
4
|
+
ErrorCritical: 'errorCritical',
|
|
5
|
+
Warning: 'warning',
|
|
6
|
+
Success: 'success',
|
|
7
|
+
} as const;
|
|
8
8
|
|
|
9
9
|
export const TEST_IDS = {
|
|
10
10
|
label: 'notification-card__label',
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { AlarmFilledSVG, CheckFilledSVG, CrossFilledSVG, InfoFilledSVG } from '@snack-uikit/icons';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { APPEARANCE } from './constants';
|
|
4
|
+
import { Appearance } from './types';
|
|
4
5
|
|
|
5
6
|
export function getIcon(appearance: Appearance) {
|
|
6
7
|
switch (appearance) {
|
|
7
|
-
case
|
|
8
|
+
case APPEARANCE.Success:
|
|
8
9
|
return <CheckFilledSVG size={16} />;
|
|
9
|
-
case
|
|
10
|
-
case
|
|
10
|
+
case APPEARANCE.Error:
|
|
11
|
+
case APPEARANCE.ErrorCritical:
|
|
11
12
|
return <CrossFilledSVG size={16} />;
|
|
12
|
-
case
|
|
13
|
+
case APPEARANCE.Warning:
|
|
13
14
|
return <AlarmFilledSVG size={16} />;
|
|
14
|
-
case
|
|
15
|
+
case APPEARANCE.Neutral:
|
|
15
16
|
return <InfoFilledSVG size={16} />;
|
|
16
17
|
default:
|
|
17
18
|
return null;
|
|
@@ -2,7 +2,6 @@ import { MouseEventHandler, ReactNode, useMemo } from 'react';
|
|
|
2
2
|
|
|
3
3
|
import { ButtonFunction, ButtonFunctionProps } from '@snack-uikit/button';
|
|
4
4
|
import { ChipToggle, ChipToggleProps } from '@snack-uikit/chips';
|
|
5
|
-
import { PopoverPrivate } from '@snack-uikit/popover-private';
|
|
6
5
|
import { Scroll } from '@snack-uikit/scroll';
|
|
7
6
|
import { SkeletonContextProvider, WithSkeleton } from '@snack-uikit/skeleton';
|
|
8
7
|
import { TruncateString } from '@snack-uikit/truncate-string';
|
|
@@ -83,7 +82,7 @@ export function NotificationPanel({
|
|
|
83
82
|
{...chip}
|
|
84
83
|
key={chip.label}
|
|
85
84
|
data-test-id={`${TEST_IDS.chip}-${chip.label}`}
|
|
86
|
-
size=
|
|
85
|
+
size='xs'
|
|
87
86
|
disabled={chip.disabled || loading}
|
|
88
87
|
/>
|
|
89
88
|
))}
|
|
@@ -99,7 +98,7 @@ export function NotificationPanel({
|
|
|
99
98
|
</div>
|
|
100
99
|
</div>
|
|
101
100
|
|
|
102
|
-
<Scroll size=
|
|
101
|
+
<Scroll size='m' className={styles.notificationPanelBody}>
|
|
103
102
|
{loading ? (
|
|
104
103
|
<SkeletonContextProvider loading={loading || false}>
|
|
105
104
|
{skeletons.map(skeleton => (
|
|
@@ -124,10 +123,6 @@ export function NotificationPanel({
|
|
|
124
123
|
);
|
|
125
124
|
}
|
|
126
125
|
|
|
127
|
-
NotificationPanel.placements = PopoverPrivate.placements;
|
|
128
|
-
NotificationPanel.triggers = PopoverPrivate.triggers;
|
|
129
|
-
NotificationPanel.widthStrategies = PopoverPrivate.widthStrategies;
|
|
130
|
-
|
|
131
126
|
export namespace NotificationPanel {
|
|
132
127
|
export const Blank: typeof NotificationPanelBlank = NotificationPanelBlank;
|
|
133
128
|
export type BlankProps = NotificationPanelBlankProps;
|
|
@@ -24,7 +24,7 @@ export type NotificationPanelBlankProps = WithSupportProps<{
|
|
|
24
24
|
/** Компонента для "заглушки" вместо карточек в панели */
|
|
25
25
|
export function NotificationPanelBlank({
|
|
26
26
|
icon,
|
|
27
|
-
iconAppearance =
|
|
27
|
+
iconAppearance = 'neutral',
|
|
28
28
|
title,
|
|
29
29
|
description,
|
|
30
30
|
className,
|
|
@@ -32,18 +32,11 @@ export function NotificationPanelBlank({
|
|
|
32
32
|
}: NotificationPanelBlankProps) {
|
|
33
33
|
return (
|
|
34
34
|
<div className={cn(styles.notificationPanelBlank, className)} {...extractSupportProps(rest)}>
|
|
35
|
-
{icon &&
|
|
36
|
-
<IconPredefined
|
|
37
|
-
icon={icon}
|
|
38
|
-
appearance={iconAppearance}
|
|
39
|
-
size={IconPredefined.sizes.L}
|
|
40
|
-
data-test-id={TEST_IDS.blank.icon}
|
|
41
|
-
/>
|
|
42
|
-
)}
|
|
35
|
+
{icon && <IconPredefined icon={icon} appearance={iconAppearance} size='l' data-test-id={TEST_IDS.blank.icon} />}
|
|
43
36
|
|
|
44
37
|
<div className={styles.notificationPanelBlankContent}>
|
|
45
38
|
<Typography.SansTitleS
|
|
46
|
-
tag=
|
|
39
|
+
tag='div'
|
|
47
40
|
className={styles.notificationPanelBlankTitle}
|
|
48
41
|
data-test-id={TEST_IDS.blank.title}
|
|
49
42
|
>
|
|
@@ -51,7 +44,7 @@ export function NotificationPanelBlank({
|
|
|
51
44
|
</Typography.SansTitleS>
|
|
52
45
|
|
|
53
46
|
<Typography.SansBodyM
|
|
54
|
-
tag=
|
|
47
|
+
tag='div'
|
|
55
48
|
className={styles.notificationPanelBlankDescription}
|
|
56
49
|
data-test-id={TEST_IDS.blank.description}
|
|
57
50
|
>
|
|
@@ -61,5 +54,3 @@ export function NotificationPanelBlank({
|
|
|
61
54
|
</div>
|
|
62
55
|
);
|
|
63
56
|
}
|
|
64
|
-
|
|
65
|
-
NotificationPanelBlank.iconAppearances = IconPredefined.appearances;
|
|
@@ -18,7 +18,7 @@ export type NotificationPanelSettingsProps = {
|
|
|
18
18
|
export function NotificationPanelSettings({ actions, button }: NotificationPanelSettingsProps) {
|
|
19
19
|
const buttonProps: ButtonSimpleProps = {
|
|
20
20
|
...button,
|
|
21
|
-
size:
|
|
21
|
+
size: 's',
|
|
22
22
|
icon: button.icon || <KebabSVG />,
|
|
23
23
|
'data-test-id': TEST_IDS.settings.droplistTrigger,
|
|
24
24
|
};
|
|
@@ -33,7 +33,7 @@ export function NotificationPanelSettingsDroplist({ actions, button }: Notificat
|
|
|
33
33
|
useScroll
|
|
34
34
|
triggerRef={triggerElementRef}
|
|
35
35
|
triggerElement={<ButtonSimple {...button} onKeyDown={handleTriggerKeyDown} />}
|
|
36
|
-
placement=
|
|
36
|
+
placement='bottom-end'
|
|
37
37
|
data-test-id={TEST_IDS.settings.droplist}
|
|
38
38
|
>
|
|
39
39
|
{actions.map(action => (
|
|
@@ -30,8 +30,8 @@ export type NotificationPanelPopoverProps = WithSupportProps<
|
|
|
30
30
|
|
|
31
31
|
export function NotificationPanelPopover({
|
|
32
32
|
content,
|
|
33
|
-
trigger =
|
|
34
|
-
placement =
|
|
33
|
+
trigger = 'click',
|
|
34
|
+
placement = 'bottom-end',
|
|
35
35
|
children,
|
|
36
36
|
contentClassName,
|
|
37
37
|
...otherProps
|
|
@@ -51,7 +51,7 @@ export function NotificationPanelPopover({
|
|
|
51
51
|
}
|
|
52
52
|
trigger={trigger}
|
|
53
53
|
hasArrow={false}
|
|
54
|
-
heightStrategy=
|
|
54
|
+
heightStrategy='lte'
|
|
55
55
|
{...otherProps}
|
|
56
56
|
>
|
|
57
57
|
{children}
|