@cloud-ru/ds-uikit-product-notification 1.0.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.
Files changed (183) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE +201 -0
  3. package/README.md +728 -0
  4. package/dist/cjs/components/NotificationCard/NotificationCard.d.ts +43 -0
  5. package/dist/cjs/components/NotificationCard/NotificationCard.js +80 -0
  6. package/dist/cjs/components/NotificationCard/NotificationCardSkeleton.d.ts +7 -0
  7. package/dist/cjs/components/NotificationCard/NotificationCardSkeleton.js +16 -0
  8. package/dist/cjs/components/NotificationCard/helpers.d.ts +4 -0
  9. package/dist/cjs/components/NotificationCard/helpers.js +31 -0
  10. package/dist/cjs/components/NotificationCard/index.d.ts +2 -0
  11. package/dist/cjs/components/NotificationCard/index.js +18 -0
  12. package/dist/cjs/components/NotificationCard/styles.module.css +216 -0
  13. package/dist/cjs/components/NotificationPanel/NotificationPanel.d.ts +22 -0
  14. package/dist/cjs/components/NotificationPanel/NotificationPanel.js +23 -0
  15. package/dist/cjs/components/NotificationPanel/index.d.ts +1 -0
  16. package/dist/cjs/components/NotificationPanel/index.js +17 -0
  17. package/dist/cjs/components/NotificationPanel/styles.module.css +10 -0
  18. package/dist/cjs/components/NotificationPanelContent/NotificationPanelContent.d.ts +45 -0
  19. package/dist/cjs/components/NotificationPanelContent/NotificationPanelContent.js +43 -0
  20. package/dist/cjs/components/NotificationPanelContent/components/NotificationCardStack/NotificationCardStack.d.ts +18 -0
  21. package/dist/cjs/components/NotificationPanelContent/components/NotificationCardStack/NotificationCardStack.js +43 -0
  22. package/dist/cjs/components/NotificationPanelContent/components/NotificationCardStack/hooks.d.ts +17 -0
  23. package/dist/cjs/components/NotificationPanelContent/components/NotificationCardStack/hooks.js +22 -0
  24. package/dist/cjs/components/NotificationPanelContent/components/NotificationCardStack/index.d.ts +1 -0
  25. package/dist/cjs/components/NotificationPanelContent/components/NotificationCardStack/index.js +17 -0
  26. package/dist/cjs/components/NotificationPanelContent/components/NotificationCardStack/styles.module.css +69 -0
  27. package/dist/cjs/components/NotificationPanelContent/components/NotificationCardStack/utils.d.ts +4 -0
  28. package/dist/cjs/components/NotificationPanelContent/components/NotificationCardStack/utils.js +11 -0
  29. package/dist/cjs/components/NotificationPanelContent/components/NotificationPanelBlank/NotificationPanelBlank.d.ts +4 -0
  30. package/dist/cjs/components/NotificationPanelContent/components/NotificationPanelBlank/NotificationPanelBlank.js +15 -0
  31. package/dist/cjs/components/NotificationPanelContent/components/NotificationPanelBlank/index.d.ts +1 -0
  32. package/dist/cjs/components/NotificationPanelContent/components/NotificationPanelBlank/index.js +17 -0
  33. package/dist/cjs/components/NotificationPanelContent/components/NotificationPanelBlank/styles.module.css +3 -0
  34. package/dist/cjs/components/NotificationPanelContent/components/NotificationPanelGroup/NotificationPanelGroup.d.ts +12 -0
  35. package/dist/cjs/components/NotificationPanelContent/components/NotificationPanelGroup/NotificationPanelGroup.js +17 -0
  36. package/dist/cjs/components/NotificationPanelContent/components/NotificationPanelGroup/index.d.ts +1 -0
  37. package/dist/cjs/components/NotificationPanelContent/components/NotificationPanelGroup/index.js +17 -0
  38. package/dist/cjs/components/NotificationPanelContent/components/NotificationPanelGroup/styles.module.css +35 -0
  39. package/dist/cjs/components/NotificationPanelContent/components/NotificationPanelSettings/NotificationPanelSettings.d.ts +12 -0
  40. package/dist/cjs/components/NotificationPanelContent/components/NotificationPanelSettings/NotificationPanelSettings.js +24 -0
  41. package/dist/cjs/components/NotificationPanelContent/components/NotificationPanelSettings/NotificationPanelSettingsDroplist.d.ts +9 -0
  42. package/dist/cjs/components/NotificationPanelContent/components/NotificationPanelSettings/NotificationPanelSettingsDroplist.js +27 -0
  43. package/dist/cjs/components/NotificationPanelContent/components/NotificationPanelSettings/index.d.ts +1 -0
  44. package/dist/cjs/components/NotificationPanelContent/components/NotificationPanelSettings/index.js +17 -0
  45. package/dist/cjs/components/NotificationPanelContent/components/index.d.ts +4 -0
  46. package/dist/cjs/components/NotificationPanelContent/components/index.js +20 -0
  47. package/dist/cjs/components/NotificationPanelContent/helperComponents/StackTail/StackTail.d.ts +6 -0
  48. package/dist/cjs/components/NotificationPanelContent/helperComponents/StackTail/StackTail.js +11 -0
  49. package/dist/cjs/components/NotificationPanelContent/helperComponents/StackTail/index.d.ts +1 -0
  50. package/dist/cjs/components/NotificationPanelContent/helperComponents/StackTail/index.js +17 -0
  51. package/dist/cjs/components/NotificationPanelContent/helperComponents/StackTail/styles.module.css +49 -0
  52. package/dist/cjs/components/NotificationPanelContent/helperComponents/index.d.ts +1 -0
  53. package/dist/cjs/components/NotificationPanelContent/helperComponents/index.js +17 -0
  54. package/dist/cjs/components/NotificationPanelContent/index.d.ts +2 -0
  55. package/dist/cjs/components/NotificationPanelContent/index.js +18 -0
  56. package/dist/cjs/components/NotificationPanelContent/styles.module.css +98 -0
  57. package/dist/cjs/components/index.d.ts +3 -0
  58. package/dist/cjs/components/index.js +19 -0
  59. package/dist/cjs/constants.d.ts +57 -0
  60. package/dist/cjs/constants.js +60 -0
  61. package/dist/cjs/helperComponents/ActionsButton/ActionsButton.d.ts +19 -0
  62. package/dist/cjs/helperComponents/ActionsButton/ActionsButton.js +28 -0
  63. package/dist/cjs/helperComponents/ActionsButton/index.d.ts +1 -0
  64. package/dist/cjs/helperComponents/ActionsButton/index.js +17 -0
  65. package/dist/cjs/helperComponents/ActionsButton/styles.module.css +3 -0
  66. package/dist/cjs/index.d.ts +4 -0
  67. package/dist/cjs/index.js +22 -0
  68. package/dist/cjs/package.json +3 -0
  69. package/dist/cjs/style.css +483 -0
  70. package/dist/cjs/types.d.ts +12 -0
  71. package/dist/cjs/types.js +2 -0
  72. package/dist/cjs/utils.d.ts +3 -0
  73. package/dist/cjs/utils.js +7 -0
  74. package/dist/esm/components/NotificationCard/NotificationCard.d.ts +43 -0
  75. package/dist/esm/components/NotificationCard/NotificationCard.js +74 -0
  76. package/dist/esm/components/NotificationCard/NotificationCardSkeleton.d.ts +7 -0
  77. package/dist/esm/components/NotificationCard/NotificationCardSkeleton.js +10 -0
  78. package/dist/esm/components/NotificationCard/helpers.d.ts +4 -0
  79. package/dist/esm/components/NotificationCard/helpers.js +27 -0
  80. package/dist/esm/components/NotificationCard/index.d.ts +2 -0
  81. package/dist/esm/components/NotificationCard/index.js +2 -0
  82. package/dist/esm/components/NotificationCard/styles.module.css +216 -0
  83. package/dist/esm/components/NotificationPanel/NotificationPanel.d.ts +22 -0
  84. package/dist/esm/components/NotificationPanel/NotificationPanel.js +17 -0
  85. package/dist/esm/components/NotificationPanel/index.d.ts +1 -0
  86. package/dist/esm/components/NotificationPanel/index.js +1 -0
  87. package/dist/esm/components/NotificationPanel/styles.module.css +10 -0
  88. package/dist/esm/components/NotificationPanelContent/NotificationPanelContent.d.ts +45 -0
  89. package/dist/esm/components/NotificationPanelContent/NotificationPanelContent.js +37 -0
  90. package/dist/esm/components/NotificationPanelContent/components/NotificationCardStack/NotificationCardStack.d.ts +18 -0
  91. package/dist/esm/components/NotificationPanelContent/components/NotificationCardStack/NotificationCardStack.js +37 -0
  92. package/dist/esm/components/NotificationPanelContent/components/NotificationCardStack/hooks.d.ts +17 -0
  93. package/dist/esm/components/NotificationPanelContent/components/NotificationCardStack/hooks.js +19 -0
  94. package/dist/esm/components/NotificationPanelContent/components/NotificationCardStack/index.d.ts +1 -0
  95. package/dist/esm/components/NotificationPanelContent/components/NotificationCardStack/index.js +1 -0
  96. package/dist/esm/components/NotificationPanelContent/components/NotificationCardStack/styles.module.css +69 -0
  97. package/dist/esm/components/NotificationPanelContent/components/NotificationCardStack/utils.d.ts +4 -0
  98. package/dist/esm/components/NotificationPanelContent/components/NotificationCardStack/utils.js +7 -0
  99. package/dist/esm/components/NotificationPanelContent/components/NotificationPanelBlank/NotificationPanelBlank.d.ts +4 -0
  100. package/dist/esm/components/NotificationPanelContent/components/NotificationPanelBlank/NotificationPanelBlank.js +9 -0
  101. package/dist/esm/components/NotificationPanelContent/components/NotificationPanelBlank/index.d.ts +1 -0
  102. package/dist/esm/components/NotificationPanelContent/components/NotificationPanelBlank/index.js +1 -0
  103. package/dist/esm/components/NotificationPanelContent/components/NotificationPanelBlank/styles.module.css +3 -0
  104. package/dist/esm/components/NotificationPanelContent/components/NotificationPanelGroup/NotificationPanelGroup.d.ts +12 -0
  105. package/dist/esm/components/NotificationPanelContent/components/NotificationPanelGroup/NotificationPanelGroup.js +11 -0
  106. package/dist/esm/components/NotificationPanelContent/components/NotificationPanelGroup/index.d.ts +1 -0
  107. package/dist/esm/components/NotificationPanelContent/components/NotificationPanelGroup/index.js +1 -0
  108. package/dist/esm/components/NotificationPanelContent/components/NotificationPanelGroup/styles.module.css +35 -0
  109. package/dist/esm/components/NotificationPanelContent/components/NotificationPanelSettings/NotificationPanelSettings.d.ts +12 -0
  110. package/dist/esm/components/NotificationPanelContent/components/NotificationPanelSettings/NotificationPanelSettings.js +21 -0
  111. package/dist/esm/components/NotificationPanelContent/components/NotificationPanelSettings/NotificationPanelSettingsDroplist.d.ts +9 -0
  112. package/dist/esm/components/NotificationPanelContent/components/NotificationPanelSettings/NotificationPanelSettingsDroplist.js +21 -0
  113. package/dist/esm/components/NotificationPanelContent/components/NotificationPanelSettings/index.d.ts +1 -0
  114. package/dist/esm/components/NotificationPanelContent/components/NotificationPanelSettings/index.js +1 -0
  115. package/dist/esm/components/NotificationPanelContent/components/index.d.ts +4 -0
  116. package/dist/esm/components/NotificationPanelContent/components/index.js +4 -0
  117. package/dist/esm/components/NotificationPanelContent/helperComponents/StackTail/StackTail.d.ts +6 -0
  118. package/dist/esm/components/NotificationPanelContent/helperComponents/StackTail/StackTail.js +5 -0
  119. package/dist/esm/components/NotificationPanelContent/helperComponents/StackTail/index.d.ts +1 -0
  120. package/dist/esm/components/NotificationPanelContent/helperComponents/StackTail/index.js +1 -0
  121. package/dist/esm/components/NotificationPanelContent/helperComponents/StackTail/styles.module.css +49 -0
  122. package/dist/esm/components/NotificationPanelContent/helperComponents/index.d.ts +1 -0
  123. package/dist/esm/components/NotificationPanelContent/helperComponents/index.js +1 -0
  124. package/dist/esm/components/NotificationPanelContent/index.d.ts +2 -0
  125. package/dist/esm/components/NotificationPanelContent/index.js +2 -0
  126. package/dist/esm/components/NotificationPanelContent/styles.module.css +98 -0
  127. package/dist/esm/components/index.d.ts +3 -0
  128. package/dist/esm/components/index.js +3 -0
  129. package/dist/esm/constants.d.ts +57 -0
  130. package/dist/esm/constants.js +57 -0
  131. package/dist/esm/helperComponents/ActionsButton/ActionsButton.d.ts +19 -0
  132. package/dist/esm/helperComponents/ActionsButton/ActionsButton.js +22 -0
  133. package/dist/esm/helperComponents/ActionsButton/index.d.ts +1 -0
  134. package/dist/esm/helperComponents/ActionsButton/index.js +1 -0
  135. package/dist/esm/helperComponents/ActionsButton/styles.module.css +3 -0
  136. package/dist/esm/index.d.ts +4 -0
  137. package/dist/esm/index.js +4 -0
  138. package/dist/esm/style.css +483 -0
  139. package/dist/esm/types.d.ts +12 -0
  140. package/dist/esm/types.js +1 -0
  141. package/dist/esm/utils.d.ts +3 -0
  142. package/dist/esm/utils.js +4 -0
  143. package/dist/tsconfig.cjs.tsbuildinfo +1 -0
  144. package/dist/tsconfig.esm.tsbuildinfo +1 -0
  145. package/package.json +60 -0
  146. package/src/components/NotificationCard/NotificationCard.tsx +252 -0
  147. package/src/components/NotificationCard/NotificationCardSkeleton.tsx +40 -0
  148. package/src/components/NotificationCard/helpers.tsx +36 -0
  149. package/src/components/NotificationCard/index.ts +2 -0
  150. package/src/components/NotificationCard/styles.module.scss +165 -0
  151. package/src/components/NotificationPanel/NotificationPanel.tsx +56 -0
  152. package/src/components/NotificationPanel/index.ts +1 -0
  153. package/src/components/NotificationPanel/styles.module.scss +15 -0
  154. package/src/components/NotificationPanelContent/NotificationPanelContent.tsx +168 -0
  155. package/src/components/NotificationPanelContent/components/NotificationCardStack/NotificationCardStack.tsx +128 -0
  156. package/src/components/NotificationPanelContent/components/NotificationCardStack/hooks.ts +45 -0
  157. package/src/components/NotificationPanelContent/components/NotificationCardStack/index.ts +1 -0
  158. package/src/components/NotificationPanelContent/components/NotificationCardStack/styles.module.scss +90 -0
  159. package/src/components/NotificationPanelContent/components/NotificationCardStack/utils.ts +11 -0
  160. package/src/components/NotificationPanelContent/components/NotificationPanelBlank/NotificationPanelBlank.tsx +21 -0
  161. package/src/components/NotificationPanelContent/components/NotificationPanelBlank/index.ts +1 -0
  162. package/src/components/NotificationPanelContent/components/NotificationPanelBlank/styles.module.scss +5 -0
  163. package/src/components/NotificationPanelContent/components/NotificationPanelGroup/NotificationPanelGroup.tsx +31 -0
  164. package/src/components/NotificationPanelContent/components/NotificationPanelGroup/index.ts +1 -0
  165. package/src/components/NotificationPanelContent/components/NotificationPanelGroup/styles.module.scss +45 -0
  166. package/src/components/NotificationPanelContent/components/NotificationPanelSettings/NotificationPanelSettings.tsx +34 -0
  167. package/src/components/NotificationPanelContent/components/NotificationPanelSettings/NotificationPanelSettingsDroplist.tsx +43 -0
  168. package/src/components/NotificationPanelContent/components/NotificationPanelSettings/index.ts +1 -0
  169. package/src/components/NotificationPanelContent/components/index.ts +4 -0
  170. package/src/components/NotificationPanelContent/helperComponents/StackTail/StackTail.tsx +17 -0
  171. package/src/components/NotificationPanelContent/helperComponents/StackTail/index.ts +1 -0
  172. package/src/components/NotificationPanelContent/helperComponents/StackTail/styles.module.scss +85 -0
  173. package/src/components/NotificationPanelContent/helperComponents/index.ts +1 -0
  174. package/src/components/NotificationPanelContent/index.ts +2 -0
  175. package/src/components/NotificationPanelContent/styles.module.scss +116 -0
  176. package/src/components/index.ts +3 -0
  177. package/src/constants.ts +58 -0
  178. package/src/helperComponents/ActionsButton/ActionsButton.tsx +73 -0
  179. package/src/helperComponents/ActionsButton/index.ts +1 -0
  180. package/src/helperComponents/ActionsButton/styles.module.scss +3 -0
  181. package/src/index.ts +4 -0
  182. package/src/types.ts +15 -0
  183. package/src/utils.ts +6 -0
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@cloud-ru/ds-uikit-product-notification",
3
+ "version": "1.0.0",
4
+ "description": "Пакет уведомлений — карточка NotificationCard, лента NotificationPanelContent со стеками и группами и адаптивная обёртка NotificationPanel (drawer на desktop, bottom-sheet на mobile).",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/cloud-ru-tech/snack-v2.git",
8
+ "directory": "packages/uikit-product-notification"
9
+ },
10
+ "homepage": "https://github.com/cloud-ru-tech/snack-v2/tree/master/packages/uikit-product-notification",
11
+ "license": "Apache-2.0",
12
+ "author": "Nikita Ershov <niershov@cloud.ru>",
13
+ "type": "module",
14
+ "main": "./dist/cjs/index.js",
15
+ "module": "./dist/esm/index.js",
16
+ "types": "./dist/esm/index.d.ts",
17
+ "exports": {
18
+ ".": {
19
+ "source": "./src/index.ts",
20
+ "types": "./dist/esm/index.d.ts",
21
+ "import": "./dist/esm/index.js",
22
+ "require": "./dist/cjs/index.js"
23
+ }
24
+ },
25
+ "files": [
26
+ "dist",
27
+ "src",
28
+ "./CHANGELOG.md",
29
+ "./LICENSE"
30
+ ],
31
+ "sideEffects": [
32
+ "*.css",
33
+ "**/*.css"
34
+ ],
35
+ "dependencies": {
36
+ "classnames": "^2.5.1",
37
+ "@cloud-ru/ds-adaptive": "^1.0.0",
38
+ "@cloud-ru/ds-button": "^1.0.0",
39
+ "@cloud-ru/ds-chips": "^1.0.0",
40
+ "@cloud-ru/ds-divider": "^1.0.0",
41
+ "@cloud-ru/ds-drawer": "^1.0.0",
42
+ "@cloud-ru/ds-icons": "^1.0.0",
43
+ "@cloud-ru/ds-link": "^1.0.0",
44
+ "@cloud-ru/ds-list": "^1.0.0",
45
+ "@cloud-ru/ds-materials": "^1.0.0",
46
+ "@cloud-ru/ds-scroll": "^1.0.0",
47
+ "@cloud-ru/ds-segment-control": "^1.0.0",
48
+ "@cloud-ru/ds-info-block": "^1.0.0",
49
+ "@cloud-ru/ds-tag": "^1.0.0",
50
+ "@cloud-ru/ds-tooltip": "^1.0.0",
51
+ "@cloud-ru/ds-status": "^1.0.0",
52
+ "@cloud-ru/ds-skeleton": "^1.0.0",
53
+ "@cloud-ru/ds-typography": "^1.0.0",
54
+ "@cloud-ru/ds-truncate-string": "^1.0.0",
55
+ "@cloud-ru/ds-utils": "^1.0.0"
56
+ },
57
+ "publishConfig": {
58
+ "access": "public"
59
+ }
60
+ }
@@ -0,0 +1,252 @@
1
+ import { Button, ButtonProps } from '@cloud-ru/ds-button';
2
+ import { KebabSVG } from '@cloud-ru/ds-icons/interface/system';
3
+ import { Link, PickLinkProps } from '@cloud-ru/ds-link';
4
+ import { StatusIndicator } from '@cloud-ru/ds-status';
5
+ import { TruncateString } from '@cloud-ru/ds-truncate-string';
6
+ import { Typography } from '@cloud-ru/ds-typography';
7
+ import { extractSupportProps, WithSupportProps } from '@cloud-ru/ds-utils';
8
+ import cn from 'classnames';
9
+ import { KeyboardEventHandler, MouseEventHandler, ReactNode, useEffect, useMemo, useRef, useState } from 'react';
10
+
11
+ import { APPEARANCE, TEST_IDS } from '../../constants';
12
+ import { ActionsButton } from '../../helperComponents/ActionsButton';
13
+ import { Action, Appearance } from '../../types';
14
+ import { stopPropagationClick } from '../../utils';
15
+ import { getAppearanceLabel, getIcon } from './helpers';
16
+ import styles from './styles.module.scss';
17
+
18
+ type NotificationButtonProps = Omit<ButtonProps, 'size' | 'appearance' | 'view' | 'data-test-id'>;
19
+
20
+ export type NotificationCardProps = WithSupportProps<{
21
+ /** Идентификатор уведомления */
22
+ id: string;
23
+ /** Тип уведомления */
24
+ appearance?: Appearance;
25
+ /** Лейбл перед заголовком */
26
+ label?: string;
27
+ /** Управление состоянием прочитано/не прочитано */
28
+ unread?: boolean;
29
+ /** Заголовок уведомления */
30
+ title: string;
31
+ /** Описание уведомления — вторичный текст под заголовком */
32
+ description?: ReactNode;
33
+ /** Ссылка (рендерится как `<a href>` через `@cloud-ru/ds-link`) */
34
+ link?: PickLinkProps<'a', 'label' | 'insideText' | 'truncateVariant'>;
35
+ /** Дата уведомления */
36
+ date: string;
37
+ /**
38
+ * Колбэк клика по карточке. Делает карточку кликабельной (`role='button'`, фокус с клавиатуры).
39
+ * Активация по карточке срабатывает только при фокусе на самой карточке — вложенные кнопки,
40
+ * ссылка и меню действий активируются независимо.
41
+ */
42
+ onClick?: MouseEventHandler<HTMLDivElement>;
43
+ /** Колбэк при попадании карточки в область видимости на 80% */
44
+ onVisible?(cardId: string): void;
45
+ /** Кнопка главного действия у карточки (рендерится как Button view='tonal') */
46
+ primaryButton?: NotificationButtonProps;
47
+ /** Кнопка второстепенного действия у карточки (рендерится как Button view='simple') */
48
+ secondaryButton?: NotificationButtonProps;
49
+ /** Дополнительные действия у карточки */
50
+ actions?: Action[];
51
+ /** CSS-класс */
52
+ className?: string;
53
+ }>;
54
+
55
+ const VISIBILITY_THRESHOLD = 0.8;
56
+
57
+ /** Карточка уведомления */
58
+ export function NotificationCard({
59
+ id,
60
+ appearance = APPEARANCE.Default,
61
+ label,
62
+ unread,
63
+ title,
64
+ description,
65
+ link,
66
+ date,
67
+ onClick,
68
+ primaryButton,
69
+ secondaryButton,
70
+ actions,
71
+ onVisible,
72
+ className,
73
+ ...rest
74
+ }: NotificationCardProps) {
75
+ const icon = useMemo(() => getIcon(appearance), [appearance]);
76
+
77
+ const [isDroplistOpen, setDroplistOpen] = useState(false);
78
+ const cardRef = useRef<HTMLDivElement>(null);
79
+
80
+ // Держим последний колбэк в ref, чтобы инлайн-стрелка из родителя не пересоздавала
81
+ // IntersectionObserver на каждый ре-рендер списка карточек.
82
+ const onVisibleRef = useRef(onVisible);
83
+ useEffect(() => {
84
+ onVisibleRef.current = onVisible;
85
+ });
86
+
87
+ useEffect(() => {
88
+ if (!unread) {
89
+ return;
90
+ }
91
+
92
+ const node = cardRef.current;
93
+ if (!node) {
94
+ return;
95
+ }
96
+
97
+ const observer = new IntersectionObserver(
98
+ entries => {
99
+ const [entry] = entries;
100
+ if (entry.isIntersecting && entry.intersectionRatio >= VISIBILITY_THRESHOLD) {
101
+ onVisibleRef.current?.(id);
102
+ // Срабатываем один раз за время видимости — повторный въезд во viewport
103
+ // не должен слать дубль-колбэк.
104
+ observer.unobserve(node);
105
+ }
106
+ },
107
+ {
108
+ root: null,
109
+ threshold: VISIBILITY_THRESHOLD,
110
+ rootMargin: '0px',
111
+ },
112
+ );
113
+
114
+ observer.observe(node);
115
+
116
+ return () => {
117
+ observer.disconnect();
118
+ };
119
+ }, [id, unread]);
120
+
121
+ const showFooter = Boolean(link || date);
122
+
123
+ const handleLinkClick: MouseEventHandler<HTMLAnchorElement> = e => {
124
+ e.stopPropagation();
125
+ link?.onClick?.(e);
126
+ };
127
+
128
+ const handleKeyDown: KeyboardEventHandler<HTMLDivElement> = e => {
129
+ if (!onClick) return;
130
+
131
+ // Обрабатываем активацию только при фокусе на самой карточке: Enter/Space на вложенных
132
+ // кнопках/ссылке/меню действий должны активировать их, а не клик по карточке.
133
+ if (e.target !== e.currentTarget) return;
134
+
135
+ if (e.key === 'Enter' || e.key === ' ') {
136
+ e.preventDefault();
137
+ cardRef.current?.click();
138
+ }
139
+ };
140
+
141
+ return (
142
+ <div
143
+ role='button'
144
+ tabIndex={0}
145
+ ref={cardRef}
146
+ onKeyDown={handleKeyDown}
147
+ onClick={onClick}
148
+ {...extractSupportProps(rest)}
149
+ data-appearance={appearance}
150
+ data-unread={unread || undefined}
151
+ data-clickable={Boolean(onClick) || undefined}
152
+ data-droplist-open={isDroplistOpen || undefined}
153
+ className={cn(styles.notificationCard, className)}
154
+ >
155
+ <span className={styles.stateLayer} data-state='emptyNeutralOnBackground' aria-hidden />
156
+
157
+ {unread && <span className={styles.visuallyHidden}>Непрочитанное уведомление</span>}
158
+
159
+ {actions?.length ? (
160
+ <ActionsButton
161
+ className={styles.notificationCardFunction}
162
+ actions={actions}
163
+ open={isDroplistOpen}
164
+ setDroplistOpen={setDroplistOpen}
165
+ icon={<KebabSVG />}
166
+ triggerAriaLabel='Действия с уведомлением'
167
+ testIds={TEST_IDS.card.actions}
168
+ />
169
+ ) : null}
170
+
171
+ {label && (
172
+ <Typography variant='body' size='s' as='div' className={styles.notificationCardLabel}>
173
+ <TruncateString maxLines={1} text={label} data-test-id={TEST_IDS.card.label} />
174
+ </Typography>
175
+ )}
176
+
177
+ <div className={styles.notificationCardTitle}>
178
+ <div className={styles.notificationCardTitleIcon} role='img' aria-label={getAppearanceLabel(appearance)}>
179
+ {icon}
180
+ </div>
181
+
182
+ <Typography variant='label' size='l' as='div' className={styles.notificationCardTitleText}>
183
+ <TruncateString maxLines={2} text={title} data-test-id={TEST_IDS.card.title} />
184
+ </Typography>
185
+ </div>
186
+
187
+ {description != null && description !== '' && (
188
+ <Typography
189
+ variant='body'
190
+ size='s'
191
+ as='div'
192
+ className={styles.notificationCardContent}
193
+ data-test-id={TEST_IDS.card.description}
194
+ >
195
+ {description}
196
+ </Typography>
197
+ )}
198
+
199
+ {(primaryButton || secondaryButton) && (
200
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
201
+ <div className={styles.notificationCardButtons} onClick={stopPropagationClick}>
202
+ {secondaryButton && (
203
+ <Button
204
+ {...secondaryButton}
205
+ view='simple'
206
+ appearance='neutral'
207
+ size='m'
208
+ data-test-id={TEST_IDS.card.secondaryButton}
209
+ />
210
+ )}
211
+
212
+ {primaryButton && (
213
+ <Button
214
+ {...primaryButton}
215
+ view='tonal'
216
+ appearance='neutral'
217
+ size='m'
218
+ data-test-id={TEST_IDS.card.primaryButton}
219
+ />
220
+ )}
221
+ </div>
222
+ )}
223
+
224
+ {showFooter && (
225
+ <Typography variant='body' size='s' as='div' className={styles.notificationCardFooter}>
226
+ {link && <Link {...link} onClick={handleLinkClick} appearance='primary' data-test-id={TEST_IDS.card.link} />}
227
+
228
+ {date && (
229
+ <Typography
230
+ variant='body'
231
+ size='s'
232
+ as='span'
233
+ className={styles.notificationCardDate}
234
+ data-test-id={TEST_IDS.card.date}
235
+ >
236
+ {date}
237
+ </Typography>
238
+ )}
239
+ </Typography>
240
+ )}
241
+
242
+ {unread && (
243
+ <StatusIndicator
244
+ className={styles.statusIndicator}
245
+ size='3xs'
246
+ appearance='green'
247
+ data-test-id={TEST_IDS.card.statusIndicator}
248
+ />
249
+ )}
250
+ </div>
251
+ );
252
+ }
@@ -0,0 +1,40 @@
1
+ import { SkeletonText } from '@cloud-ru/ds-skeleton';
2
+ import { extractSupportProps, WithSupportProps } from '@cloud-ru/ds-utils';
3
+ import cn from 'classnames';
4
+
5
+ import { TEST_IDS } from '../../constants';
6
+ import styles from './styles.module.scss';
7
+
8
+ export type NotificationCardSkeletonProps = WithSupportProps<{
9
+ /** CSS-класс */
10
+ className?: string;
11
+ }>;
12
+
13
+ /** Скелетон карточки уведомления для состояния загрузки */
14
+ export function NotificationCardSkeleton({ className, ...rest }: NotificationCardSkeletonProps = {}) {
15
+ return (
16
+ <div
17
+ className={cn(styles.notificationCard, className)}
18
+ data-test-id={TEST_IDS.card.skeleton}
19
+ {...extractSupportProps(rest)}
20
+ >
21
+ <SkeletonText width={140} variant='label' size='s' lines={1} />
22
+
23
+ <div className={styles.notificationCardTitle}>
24
+ <div className={styles.notificationCardTitleIcon}>
25
+ <SkeletonText width={16} variant='title' size='s' lines={1} />
26
+ </div>
27
+ <SkeletonText width={140} variant='title' size='s' lines={1} />
28
+ </div>
29
+
30
+ <div className={styles.notificationCardContent}>
31
+ <SkeletonText lines={3} variant='body' size='s' />
32
+ </div>
33
+
34
+ <div className={styles.notificationCardFooter}>
35
+ <SkeletonText width={140} variant='body' size='s' lines={1} />
36
+ <SkeletonText width={140} variant='label' size='s' lines={1} />
37
+ </div>
38
+ </div>
39
+ );
40
+ }
@@ -0,0 +1,36 @@
1
+ import {
2
+ NotifierCriticalFilledSVG,
3
+ NotifierInfoFilledSVG,
4
+ NotifierSuccessFilledSVG,
5
+ NotifierWarningFilledSVG,
6
+ } from '@cloud-ru/ds-icons/interface/system';
7
+
8
+ import { APPEARANCE } from '../../constants';
9
+ import { Appearance } from '../../types';
10
+
11
+ export function getIcon(appearance: Appearance) {
12
+ switch (appearance) {
13
+ case APPEARANCE.Success:
14
+ return <NotifierSuccessFilledSVG size={16} />;
15
+ case APPEARANCE.Error:
16
+ return <NotifierCriticalFilledSVG size={16} />;
17
+ case APPEARANCE.Warning:
18
+ return <NotifierWarningFilledSVG size={16} />;
19
+ case APPEARANCE.Default:
20
+ default: {
21
+ return <NotifierInfoFilledSVG size={16} />;
22
+ }
23
+ }
24
+ }
25
+
26
+ const APPEARANCE_LABEL: Record<Appearance, string> = {
27
+ [APPEARANCE.Default]: 'Информация',
28
+ [APPEARANCE.Error]: 'Ошибка',
29
+ [APPEARANCE.Warning]: 'Предупреждение',
30
+ [APPEARANCE.Success]: 'Успешно',
31
+ };
32
+
33
+ /** Текстовое описание типа уведомления для скринридера (иконка severity не озвучивается). */
34
+ export function getAppearanceLabel(appearance: Appearance) {
35
+ return APPEARANCE_LABEL[appearance];
36
+ }
@@ -0,0 +1,2 @@
1
+ export * from './NotificationCard';
2
+ export * from './NotificationCardSkeleton';
@@ -0,0 +1,165 @@
1
+ @use '@cloud-ru/ds-figma-variables/build/scss/styles/styles.module' as base;
2
+ @use '@cloud-ru/ds-materials' as m;
3
+
4
+ $appearance-icon-colors: (
5
+ 'default': base.$sn-theme-color-neutral-accent,
6
+ 'error': base.$sn-theme-color-red-accent,
7
+ 'warning': base.$sn-theme-color-yellow-accent,
8
+ 'success': base.$sn-theme-color-green-accent,
9
+ );
10
+
11
+ $appearance-unread-bg: (
12
+ 'default': base.$sn-theme-color-neutral-decorTransparent,
13
+ 'error': base.$sn-theme-color-red-decorTransparent,
14
+ 'warning': base.$sn-theme-color-yellow-decorTransparent,
15
+ 'success': base.$sn-theme-color-green-decorTransparent,
16
+ );
17
+
18
+ .stateLayer {
19
+ pointer-events: none;
20
+ visibility: initial;
21
+ }
22
+
23
+ .notificationCardTitleIcon {
24
+ display: flex;
25
+ flex-shrink: 0;
26
+ align-items: center;
27
+ justify-content: center;
28
+
29
+ width: base.$sn-primitive-dimension-20;
30
+ height: base.$sn-primitive-dimension-20;
31
+ }
32
+
33
+ .notificationCardFunction {
34
+ pointer-events: none;
35
+
36
+ position: absolute;
37
+ top: base.$sn-primitive-dimension-8;
38
+ right: base.$sn-primitive-dimension-8;
39
+
40
+ opacity: 0;
41
+ }
42
+
43
+ .notificationCard {
44
+ cursor: default;
45
+
46
+ position: relative;
47
+
48
+ display: flex;
49
+ flex-direction: column;
50
+ gap: base.$sn-primitive-dimension-8;
51
+
52
+ padding: base.$sn-primitive-dimension-12;
53
+ border: base.$sn-primitive-strokeWeight-strokeRegular solid base.$sn-theme-color-available-borderColor;
54
+ border-radius: base.$sn-density-radius-2xs;
55
+
56
+ background-color: transparent;
57
+ outline: none;
58
+
59
+ @include m.has-state-layer-as-child(#{stateLayer});
60
+
61
+ &[data-clickable] {
62
+ cursor: pointer;
63
+ }
64
+
65
+ &:focus-visible {
66
+ outline: base.$sn-primitive-strokeWeight-strokeSemiBold solid base.$sn-theme-color-available-complementary;
67
+ outline-offset: 0;
68
+ }
69
+
70
+ &[data-droplist-open],
71
+ &:hover,
72
+ &:focus-visible,
73
+ &:focus-within:not(:focus) {
74
+ .notificationCardFunction {
75
+ pointer-events: auto;
76
+ opacity: 1;
77
+ }
78
+ }
79
+
80
+ @each $appearance, $color in $appearance-icon-colors {
81
+ &[data-appearance='#{$appearance}'] .notificationCardTitleIcon {
82
+ color: $color;
83
+ }
84
+ }
85
+
86
+ @each $appearance, $color in $appearance-unread-bg {
87
+ &[data-appearance='#{$appearance}'][data-unread] {
88
+ background-color: $color;
89
+ }
90
+ }
91
+ }
92
+
93
+ .notificationCardLabel {
94
+ display: block;
95
+ color: base.$sn-theme-color-available-version-textTertiary;
96
+ }
97
+
98
+ .notificationCardTitle {
99
+ display: flex;
100
+ gap: base.$sn-primitive-dimension-4;
101
+ align-items: center;
102
+ }
103
+
104
+ .notificationCardTitleText {
105
+ flex: 1 1 auto;
106
+ min-width: 0;
107
+ color: base.$sn-theme-color-available-version-textMain;
108
+ }
109
+
110
+ .notificationCardContent {
111
+ color: base.$sn-theme-color-available-version-textSecondary;
112
+ overflow-wrap: break-word;
113
+ white-space: pre-line;
114
+ }
115
+
116
+ .notificationCardButtons {
117
+ display: flex;
118
+ gap: base.$sn-primitive-dimension-4;
119
+ justify-content: flex-end;
120
+ }
121
+
122
+ .notificationCardFooter {
123
+ display: flex;
124
+ align-items: center;
125
+ justify-content: space-between;
126
+ color: base.$sn-theme-color-available-version-textTertiary;
127
+ }
128
+
129
+ .notificationCardDate {
130
+ display: flex;
131
+ flex: 1 1 auto;
132
+ gap: base.$sn-primitive-dimension-4;
133
+ align-items: center;
134
+ justify-content: flex-end;
135
+
136
+ min-width: 0;
137
+
138
+ white-space: nowrap;
139
+ }
140
+
141
+ // Скоупим под `.notificationCard`, чтобы правило позиционирования выигрывало у
142
+ // одноимённого класса `.statusIndicator` из `@cloud-ru/ds-status` (равная специфичность →
143
+ // в production-сборке порядок CSS может перевернуться, индикатор теряет
144
+ // `position: absolute` и растягивается на всю ширину карточки).
145
+ .notificationCard .statusIndicator {
146
+ pointer-events: none;
147
+ position: absolute;
148
+ top: base.$sn-primitive-dimension-4;
149
+ right: base.$sn-primitive-dimension-4;
150
+ }
151
+
152
+ .visuallyHidden {
153
+ pointer-events: none;
154
+
155
+ position: absolute;
156
+
157
+ overflow: hidden;
158
+
159
+ width: base.$sn-primitive-dimension-1;
160
+ height: base.$sn-primitive-dimension-1;
161
+
162
+ white-space: nowrap;
163
+
164
+ clip-path: inset(50%);
165
+ }
@@ -0,0 +1,56 @@
1
+ import { isMobileLayout, useAdaptiveLayout } from '@cloud-ru/ds-adaptive';
2
+ import { DrawerCustom, DrawerCustomProps, POSITION, WIDTH } from '@cloud-ru/ds-drawer';
3
+ import { WithSupportProps } from '@cloud-ru/ds-utils';
4
+ import cn from 'classnames';
5
+ import { ReactElement } from 'react';
6
+
7
+ import { NotificationPanelContent, NotificationPanelContentProps } from '../NotificationPanelContent';
8
+ import styles from './styles.module.scss';
9
+
10
+ type SharedOverlayProps = Pick<
11
+ DrawerCustomProps,
12
+ 'open' | 'onClose' | 'className' | 'rootClassName' | 'showBlackout' | 'container' | 'closeOnPopstate'
13
+ >;
14
+
15
+ /**
16
+ * Только desktop: `position` и `width` применяются лишь к Drawer-поверхности
17
+ * (desktop). На mobile (BottomSheet) молча игнорируются.
18
+ */
19
+ export type NotificationPanelProps = WithSupportProps<
20
+ {
21
+ /** Контент панели (`NotificationPanelContent`), отображаемый внутри обёртки */
22
+ content: ReactElement<NotificationPanelContentProps, typeof NotificationPanelContent>;
23
+ } & SharedOverlayProps &
24
+ Partial<Pick<DrawerCustomProps, 'position' | 'width'>>
25
+ >;
26
+
27
+ /**
28
+ * Адаптивная обёртка панели уведомлений. Рендерит `NotificationPanelContent` в `DrawerCustom`, который сам
29
+ * авто-свапается по `AdaptiveProvider`: на desktop — дровер, на mobile — bottom-sheet. Композит НЕ
30
+ * выбирает поверхность сам (канон adaptive-components: swap у `DrawerCustom`) — контекст читается лишь
31
+ * для surface-специфичного класса обёртки (на дровере нужен `height: 100%`, на sheet — нет).
32
+ * `position`/`width` — desktop-only (на mobile-поверхности игнорируются самим дровером).
33
+ */
34
+ export function NotificationPanel({
35
+ content,
36
+ position = POSITION.Right,
37
+ width = WIDTH.S,
38
+ className,
39
+ showBlackout,
40
+ ...rest
41
+ }: NotificationPanelProps) {
42
+ const { layoutType } = useAdaptiveLayout();
43
+ const surfaceClassName = isMobileLayout(layoutType) ? styles.notificationPanelSheet : styles.notificationPanelDrawer;
44
+
45
+ return (
46
+ <DrawerCustom
47
+ position={position}
48
+ width={width}
49
+ className={cn(surfaceClassName, className)}
50
+ showBlackout={showBlackout}
51
+ {...rest}
52
+ >
53
+ {content}
54
+ </DrawerCustom>
55
+ );
56
+ }
@@ -0,0 +1 @@
1
+ export * from './NotificationPanel';
@@ -0,0 +1,15 @@
1
+ @use '@cloud-ru/ds-figma-variables/build/scss/styles/styles.module' as base;
2
+
3
+ .notificationPanelDrawer {
4
+ display: flex;
5
+ flex-direction: column;
6
+ height: 100%;
7
+ }
8
+
9
+ // BottomSheet сам ограничивает высоту (max-height вьюпорта) и держит `.content`
10
+ // как flex-колонку с min-height:0 — панель внутри (`.wrapper` height:100%) получает
11
+ // ограниченную высоту, поэтому её внутренний `Scroll` работает.
12
+ .notificationPanelSheet {
13
+ display: flex;
14
+ flex-direction: column;
15
+ }