@cloud-ru/ds-uikit-product-notification 2.0.31 → 2.0.32-preview-04e34550.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -1
- package/dist/cjs/components/NotificationCard/NotificationCard.d.ts +3 -2
- package/dist/cjs/components/NotificationCard/NotificationCard.js +2 -2
- package/dist/cjs/components/NotificationPanel/components/NotificationCardStack/NotificationCardStack.d.ts +3 -2
- package/dist/cjs/components/NotificationPanel/components/NotificationCardStack/NotificationCardStack.js +2 -2
- package/dist/cjs/components/NotificationPanel/components/NotificationPanelSettings/NotificationPanelSettings.d.ts +3 -2
- package/dist/cjs/components/NotificationPanel/components/NotificationPanelSettings/NotificationPanelSettings.js +2 -2
- package/dist/cjs/components/NotificationPanel/components/NotificationPanelSettings/NotificationPanelSettingsDroplist.d.ts +3 -2
- package/dist/cjs/components/NotificationPanel/components/NotificationPanelSettings/NotificationPanelSettingsDroplist.js +2 -2
- package/dist/cjs/helperComponents/ActionsButton/ActionsButton.d.ts +3 -2
- package/dist/cjs/helperComponents/ActionsButton/ActionsButton.js +2 -2
- package/dist/esm/components/NotificationCard/NotificationCard.d.ts +3 -2
- package/dist/esm/components/NotificationCard/NotificationCard.js +2 -2
- package/dist/esm/components/NotificationPanel/components/NotificationCardStack/NotificationCardStack.d.ts +3 -2
- package/dist/esm/components/NotificationPanel/components/NotificationCardStack/NotificationCardStack.js +2 -2
- package/dist/esm/components/NotificationPanel/components/NotificationPanelSettings/NotificationPanelSettings.d.ts +3 -2
- package/dist/esm/components/NotificationPanel/components/NotificationPanelSettings/NotificationPanelSettings.js +2 -2
- package/dist/esm/components/NotificationPanel/components/NotificationPanelSettings/NotificationPanelSettingsDroplist.d.ts +3 -2
- package/dist/esm/components/NotificationPanel/components/NotificationPanelSettings/NotificationPanelSettingsDroplist.js +2 -2
- package/dist/esm/helperComponents/ActionsButton/ActionsButton.d.ts +3 -2
- package/dist/esm/helperComponents/ActionsButton/ActionsButton.js +2 -2
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +19 -19
- package/src/components/NotificationCard/NotificationCard.tsx +41 -34
- package/src/components/NotificationPanel/components/NotificationCardStack/NotificationCardStack.tsx +21 -14
- package/src/components/NotificationPanel/components/NotificationPanelSettings/NotificationPanelSettings.tsx +17 -3
- package/src/components/NotificationPanel/components/NotificationPanelSettings/NotificationPanelSettingsDroplist.tsx +10 -3
- package/src/helperComponents/ActionsButton/ActionsButton.tsx +6 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloud-ru/ds-uikit-product-notification",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.32-preview-04e34550.0",
|
|
4
4
|
"description": "Пакет уведомлений — карточка NotificationCard, лента NotificationPanelContent со стеками и группами и адаптивная обёртка NotificationPanel (drawer на desktop, bottom-sheet на mobile).",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -34,24 +34,24 @@
|
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"classnames": "^2.5.1",
|
|
37
|
-
"@cloud-ru/ds-adaptive": "
|
|
38
|
-
"@cloud-ru/ds-button": "
|
|
39
|
-
"@cloud-ru/ds-
|
|
40
|
-
"@cloud-ru/ds-drawer": "
|
|
41
|
-
"@cloud-ru/ds-
|
|
42
|
-
"@cloud-ru/ds-
|
|
43
|
-
"@cloud-ru/ds-
|
|
44
|
-
"@cloud-ru/ds-list": "
|
|
45
|
-
"@cloud-ru/ds-materials": "
|
|
46
|
-
"@cloud-ru/ds-
|
|
47
|
-
"@cloud-ru/ds-
|
|
48
|
-
"@cloud-ru/ds-skeleton": "
|
|
49
|
-
"@cloud-ru/ds-
|
|
50
|
-
"@cloud-ru/ds-
|
|
51
|
-
"@cloud-ru/ds-
|
|
52
|
-
"@cloud-ru/ds-
|
|
53
|
-
"@cloud-ru/ds-
|
|
54
|
-
"@cloud-ru/ds-utils": "
|
|
37
|
+
"@cloud-ru/ds-adaptive": "1.0.2",
|
|
38
|
+
"@cloud-ru/ds-button": "1.0.4",
|
|
39
|
+
"@cloud-ru/ds-icons": "1.6.0",
|
|
40
|
+
"@cloud-ru/ds-drawer": "2.1.2",
|
|
41
|
+
"@cloud-ru/ds-info-block": "1.0.3",
|
|
42
|
+
"@cloud-ru/ds-chips": "1.1.13-preview-04e34550.0",
|
|
43
|
+
"@cloud-ru/ds-link": "1.0.15",
|
|
44
|
+
"@cloud-ru/ds-list": "2.3.7-preview-04e34550.0",
|
|
45
|
+
"@cloud-ru/ds-materials": "2.0.1",
|
|
46
|
+
"@cloud-ru/ds-segment-control": "1.0.15",
|
|
47
|
+
"@cloud-ru/ds-scroll": "1.0.5",
|
|
48
|
+
"@cloud-ru/ds-skeleton": "1.0.2",
|
|
49
|
+
"@cloud-ru/ds-status": "1.1.10",
|
|
50
|
+
"@cloud-ru/ds-tag": "1.1.14",
|
|
51
|
+
"@cloud-ru/ds-tooltip": "1.0.13",
|
|
52
|
+
"@cloud-ru/ds-truncate-string": "1.0.14",
|
|
53
|
+
"@cloud-ru/ds-typography": "1.0.2",
|
|
54
|
+
"@cloud-ru/ds-utils": "1.2.0"
|
|
55
55
|
},
|
|
56
56
|
"publishConfig": {
|
|
57
57
|
"access": "public"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Button, ButtonProps } from '@cloud-ru/ds-button';
|
|
2
2
|
import { KebabSVG } from '@cloud-ru/ds-icons/interface/system';
|
|
3
3
|
import { Link, PickLinkProps } from '@cloud-ru/ds-link';
|
|
4
|
+
import { DroplistProps } from '@cloud-ru/ds-list';
|
|
4
5
|
import { StatusIndicator } from '@cloud-ru/ds-status';
|
|
5
6
|
import { TruncateString } from '@cloud-ru/ds-truncate-string';
|
|
6
7
|
import { Typography } from '@cloud-ru/ds-typography';
|
|
@@ -17,40 +18,42 @@ import styles from './styles.module.scss';
|
|
|
17
18
|
|
|
18
19
|
type NotificationButtonProps = Omit<ButtonProps, 'size' | 'appearance' | 'view' | 'data-test-id'>;
|
|
19
20
|
|
|
20
|
-
export type NotificationCardProps = WithSupportProps<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
21
|
+
export type NotificationCardProps = WithSupportProps<
|
|
22
|
+
{
|
|
23
|
+
/** Идентификатор уведомления */
|
|
24
|
+
id: string;
|
|
25
|
+
/** Тип уведомления */
|
|
26
|
+
appearance?: Appearance;
|
|
27
|
+
/** Лейбл перед заголовком */
|
|
28
|
+
label?: string;
|
|
29
|
+
/** Управление состоянием прочитано/не прочитано */
|
|
30
|
+
unread?: boolean;
|
|
31
|
+
/** Заголовок уведомления */
|
|
32
|
+
title: string;
|
|
33
|
+
/** Описание уведомления — вторичный текст под заголовком */
|
|
34
|
+
description?: ReactNode;
|
|
35
|
+
/** Ссылка (рендерится как `<a href>` через `@cloud-ru/ds-link`) */
|
|
36
|
+
link?: PickLinkProps<'a', 'label' | 'insideText' | 'truncateVariant'>;
|
|
37
|
+
/** Дата уведомления */
|
|
38
|
+
date: string;
|
|
39
|
+
/**
|
|
40
|
+
* Колбэк клика по карточке. Делает карточку кликабельной (`role='button'`, фокус с клавиатуры).
|
|
41
|
+
* Активация по карточке срабатывает только при фокусе на самой карточке — вложенные кнопки,
|
|
42
|
+
* ссылка и меню действий активируются независимо.
|
|
43
|
+
*/
|
|
44
|
+
onClick?: MouseEventHandler<HTMLDivElement>;
|
|
45
|
+
/** Колбэк при попадании карточки в область видимости на 80% */
|
|
46
|
+
onVisible?(cardId: string): void;
|
|
47
|
+
/** Кнопка главного действия у карточки (рендерится как Button view='tonal') */
|
|
48
|
+
primaryButton?: NotificationButtonProps;
|
|
49
|
+
/** Кнопка второстепенного действия у карточки (рендерится как Button view='simple') */
|
|
50
|
+
secondaryButton?: NotificationButtonProps;
|
|
51
|
+
/** Дополнительные действия у карточки */
|
|
52
|
+
actions?: Action[];
|
|
53
|
+
/** CSS-класс */
|
|
54
|
+
className?: string;
|
|
55
|
+
} & Pick<DroplistProps, 'itemRender' | 'groupItemRender'>
|
|
56
|
+
>;
|
|
54
57
|
|
|
55
58
|
const VISIBILITY_THRESHOLD = 0.8;
|
|
56
59
|
|
|
@@ -70,6 +73,8 @@ export function NotificationCard({
|
|
|
70
73
|
actions,
|
|
71
74
|
onVisible,
|
|
72
75
|
className,
|
|
76
|
+
itemRender,
|
|
77
|
+
groupItemRender,
|
|
73
78
|
...rest
|
|
74
79
|
}: NotificationCardProps) {
|
|
75
80
|
const icon = useMemo(() => getIcon(appearance), [appearance]);
|
|
@@ -165,6 +170,8 @@ export function NotificationCard({
|
|
|
165
170
|
icon={<KebabSVG />}
|
|
166
171
|
triggerAriaLabel='Действия с уведомлением'
|
|
167
172
|
testIds={TEST_IDS.card.actions}
|
|
173
|
+
itemRender={itemRender}
|
|
174
|
+
groupItemRender={groupItemRender}
|
|
168
175
|
/>
|
|
169
176
|
) : null}
|
|
170
177
|
|
package/src/components/NotificationPanel/components/NotificationCardStack/NotificationCardStack.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Button } from '@cloud-ru/ds-button';
|
|
2
2
|
import { ChevronDownSVG, ChevronUpSVG, KebabSVG } from '@cloud-ru/ds-icons/interface/system';
|
|
3
|
+
import { DroplistProps } from '@cloud-ru/ds-list';
|
|
3
4
|
import { TruncateString } from '@cloud-ru/ds-truncate-string';
|
|
4
5
|
import { Typography } from '@cloud-ru/ds-typography';
|
|
5
6
|
import { extractSupportProps, WithSupportProps } from '@cloud-ru/ds-utils';
|
|
@@ -15,20 +16,22 @@ import { cloneCard } from './utils';
|
|
|
15
16
|
|
|
16
17
|
const ANIMATION_DURATION = 0.3;
|
|
17
18
|
|
|
18
|
-
export type NotificationCardStackProps = WithSupportProps<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
19
|
+
export type NotificationCardStackProps = WithSupportProps<
|
|
20
|
+
{
|
|
21
|
+
/** Заголовок стопки карточек */
|
|
22
|
+
title: string;
|
|
23
|
+
/** Состояние открыт/закрыт по умолчанию */
|
|
24
|
+
defaultOpen?: boolean;
|
|
25
|
+
/** Колбек смены состояния открыт/закрыт */
|
|
26
|
+
onOpenChanged?(open: boolean): void;
|
|
27
|
+
/** Карточки в стопке, видна первая карточка, остальные схлопываются под нее. */
|
|
28
|
+
children: Iterable<ReactNode>;
|
|
29
|
+
/** Список действий в выпадающем меню */
|
|
30
|
+
actions?: Action[];
|
|
31
|
+
/** Состояние непрочитанных карточек */
|
|
32
|
+
unread?: boolean;
|
|
33
|
+
} & Pick<DroplistProps, 'itemRender' | 'groupItemRender'>
|
|
34
|
+
>;
|
|
32
35
|
|
|
33
36
|
export function NotificationCardStack({
|
|
34
37
|
children,
|
|
@@ -37,6 +40,8 @@ export function NotificationCardStack({
|
|
|
37
40
|
title,
|
|
38
41
|
actions,
|
|
39
42
|
unread,
|
|
43
|
+
itemRender,
|
|
44
|
+
groupItemRender,
|
|
40
45
|
...rest
|
|
41
46
|
}: NotificationCardStackProps) {
|
|
42
47
|
const [actionsOpen, setActionsOpen] = useState(false);
|
|
@@ -96,6 +101,8 @@ export function NotificationCardStack({
|
|
|
96
101
|
icon={<KebabSVG />}
|
|
97
102
|
triggerAriaLabel='Действия со стопкой'
|
|
98
103
|
testIds={TEST_IDS.panel.cardStack.actions}
|
|
104
|
+
itemRender={itemRender}
|
|
105
|
+
groupItemRender={groupItemRender}
|
|
99
106
|
/>
|
|
100
107
|
)}
|
|
101
108
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Button, ButtonProps } from '@cloud-ru/ds-button';
|
|
2
2
|
import { SettingsSVG } from '@cloud-ru/ds-icons/interface/system';
|
|
3
|
+
import { DroplistProps } from '@cloud-ru/ds-list';
|
|
3
4
|
import { ElementType } from 'react';
|
|
4
5
|
|
|
5
6
|
import { TEST_IDS } from '../../../../constants';
|
|
@@ -12,10 +13,16 @@ export type NotificationPanelSettingsProps = {
|
|
|
12
13
|
/** Кнопка дополнительного действия панели */
|
|
13
14
|
button?: Omit<ButtonProps<ElementType>, 'label' | 'size' | 'view' | 'data-test-id'>;
|
|
14
15
|
size?: 's' | 'm';
|
|
15
|
-
}
|
|
16
|
+
} & Pick<DroplistProps, 'itemRender' | 'groupItemRender'>;
|
|
16
17
|
|
|
17
18
|
/** Кнопка настроек панели уведомлений (с выпадающим списком действий, если переданы). */
|
|
18
|
-
export function NotificationPanelSettings({
|
|
19
|
+
export function NotificationPanelSettings({
|
|
20
|
+
actions,
|
|
21
|
+
button,
|
|
22
|
+
size = 'm',
|
|
23
|
+
itemRender,
|
|
24
|
+
groupItemRender,
|
|
25
|
+
}: NotificationPanelSettingsProps) {
|
|
19
26
|
const buttonProps: ButtonProps<ElementType> = {
|
|
20
27
|
...button,
|
|
21
28
|
view: 'function',
|
|
@@ -30,5 +37,12 @@ export function NotificationPanelSettings({ actions, button, size = 'm' }: Notif
|
|
|
30
37
|
return <Button {...buttonProps} />;
|
|
31
38
|
}
|
|
32
39
|
|
|
33
|
-
return
|
|
40
|
+
return (
|
|
41
|
+
<NotificationPanelSettingsDroplist
|
|
42
|
+
actions={actions}
|
|
43
|
+
button={buttonProps}
|
|
44
|
+
itemRender={itemRender}
|
|
45
|
+
groupItemRender={groupItemRender}
|
|
46
|
+
/>
|
|
47
|
+
);
|
|
34
48
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Button, ButtonProps } from '@cloud-ru/ds-button';
|
|
2
|
-
import { Droplist } from '@cloud-ru/ds-list';
|
|
2
|
+
import { Droplist, DroplistProps } from '@cloud-ru/ds-list';
|
|
3
3
|
import { Tag } from '@cloud-ru/ds-tag';
|
|
4
4
|
import { ElementType, useState } from 'react';
|
|
5
5
|
|
|
@@ -10,9 +10,14 @@ import styles from '../../styles.module.scss';
|
|
|
10
10
|
type NotificationPanelSettingsDroplistProps = {
|
|
11
11
|
actions: Action[];
|
|
12
12
|
button: ButtonProps<ElementType>;
|
|
13
|
-
}
|
|
13
|
+
} & Pick<DroplistProps, 'itemRender' | 'groupItemRender'>;
|
|
14
14
|
|
|
15
|
-
export function NotificationPanelSettingsDroplist({
|
|
15
|
+
export function NotificationPanelSettingsDroplist({
|
|
16
|
+
actions,
|
|
17
|
+
button,
|
|
18
|
+
itemRender,
|
|
19
|
+
groupItemRender,
|
|
20
|
+
}: NotificationPanelSettingsDroplistProps) {
|
|
16
21
|
const [isDroplistOpen, setDroplistOpen] = useState(false);
|
|
17
22
|
|
|
18
23
|
return (
|
|
@@ -36,6 +41,8 @@ export function NotificationPanelSettingsDroplist({ actions, button }: Notificat
|
|
|
36
41
|
afterContent: tagLabel ? <Tag label={tagLabel} /> : undefined,
|
|
37
42
|
'data-test-id': `${TEST_IDS.panel.settings.droplistAction}-${index}`,
|
|
38
43
|
}))}
|
|
44
|
+
itemRender={itemRender}
|
|
45
|
+
groupItemRender={groupItemRender}
|
|
39
46
|
>
|
|
40
47
|
<Button {...button} />
|
|
41
48
|
</Droplist>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Button } from '@cloud-ru/ds-button';
|
|
2
|
-
import { Droplist } from '@cloud-ru/ds-list';
|
|
2
|
+
import { Droplist, DroplistProps } from '@cloud-ru/ds-list';
|
|
3
3
|
import { Tag } from '@cloud-ru/ds-tag';
|
|
4
4
|
import cn from 'classnames';
|
|
5
5
|
import { Dispatch, ReactElement, SetStateAction } from 'react';
|
|
@@ -24,7 +24,7 @@ export type ActionsButtonProps = {
|
|
|
24
24
|
triggerAriaLabel: string;
|
|
25
25
|
testIds: ActionsButtonTestIds;
|
|
26
26
|
className?: string;
|
|
27
|
-
}
|
|
27
|
+
} & Pick<DroplistProps, 'itemRender' | 'groupItemRender'>;
|
|
28
28
|
|
|
29
29
|
export function ActionsButton({
|
|
30
30
|
actions,
|
|
@@ -34,6 +34,8 @@ export function ActionsButton({
|
|
|
34
34
|
triggerAriaLabel,
|
|
35
35
|
testIds,
|
|
36
36
|
className,
|
|
37
|
+
itemRender,
|
|
38
|
+
groupItemRender,
|
|
37
39
|
}: ActionsButtonProps) {
|
|
38
40
|
return (
|
|
39
41
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
@@ -58,6 +60,8 @@ export function ActionsButton({
|
|
|
58
60
|
'data-test-id': `${testIds.droplistAction}-${index}`,
|
|
59
61
|
}))}
|
|
60
62
|
triggerClassName={styles.inlineFlex}
|
|
63
|
+
itemRender={itemRender}
|
|
64
|
+
groupItemRender={groupItemRender}
|
|
61
65
|
>
|
|
62
66
|
<Button
|
|
63
67
|
view='function'
|