@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
@@ -0,0 +1,85 @@
1
+ @use '@cloud-ru/ds-figma-variables/build/scss/styles/styles.module' as base;
2
+
3
+ // Хвост анимируется за половину общей длительности — он успевает уйти, пока
4
+ // реальные карточки стопки выезжают на его место.
5
+ $halfDuration: calc(var(--snack-notification-stack-animation-duration) / 2);
6
+
7
+ // Высота «корешка» — заглушка под клип: видна только нижняя кромка, реальная
8
+ // высота не важна. Сдвиг — насколько корешки уезжают вниз при раскрытии, чтобы
9
+ // освободить место выезжающей стопке (значения подобраны как в snack-uikit).
10
+ $tail-card-height: 200px;
11
+ $tail-slide-distance: 416px;
12
+
13
+ .container {
14
+ position: relative;
15
+ height: 0;
16
+ }
17
+
18
+ .animationContainer {
19
+ position: absolute;
20
+ top: 0;
21
+ bottom: calc(-1 * #{base.$sn-primitive-dimension-8});
22
+
23
+ overflow: hidden;
24
+
25
+ width: 100%;
26
+
27
+ // На схлопывании корешки возвращаются с небольшой задержкой — появляются уже
28
+ // после того, как стопка уехала вверх.
29
+ transition: bottom $halfDuration calc(#{$halfDuration} / 1.7) ease-out;
30
+
31
+ [data-open] & {
32
+ bottom: calc(-1 * #{$tail-slide-distance});
33
+ transition: bottom $halfDuration ease-out;
34
+ }
35
+ }
36
+
37
+ .card {
38
+ position: absolute;
39
+
40
+ overflow: hidden;
41
+
42
+ height: $tail-card-height;
43
+ border: base.$sn-primitive-strokeWeight-strokeRegular solid base.$sn-theme-color-available-borderColor;
44
+ border-radius: base.$sn-density-radius-2xs;
45
+
46
+ background-color: base.$sn-theme-color-neutral-background1Level;
47
+
48
+ // На схлопывании корешки разъезжаются обратно к своим отступам с задержкой,
49
+ // догоняя вернувшийся контейнер.
50
+ transition:
51
+ right $halfDuration $halfDuration ease,
52
+ left $halfDuration $halfDuration ease,
53
+ opacity $halfDuration $halfDuration ease;
54
+
55
+ &::after {
56
+ content: '';
57
+ position: absolute;
58
+ inset: 0;
59
+ background-color: base.$sn-theme-color-neutral-decorTransparent;
60
+ }
61
+
62
+ &[data-level='2'] {
63
+ right: base.$sn-primitive-dimension-4;
64
+ bottom: 50%;
65
+ left: base.$sn-primitive-dimension-4;
66
+ }
67
+
68
+ &[data-level='3'] {
69
+ right: base.$sn-primitive-dimension-8;
70
+ bottom: 0;
71
+ left: base.$sn-primitive-dimension-8;
72
+ }
73
+
74
+ // На раскрытии корешки разъезжаются на всю ширину и затухают (без задержки),
75
+ // визуально «превращаясь» в выезжающие карточки стопки.
76
+ [data-open] & {
77
+ right: 0;
78
+ left: 0;
79
+ opacity: 0;
80
+ transition:
81
+ right $halfDuration ease,
82
+ left $halfDuration ease,
83
+ opacity $halfDuration ease;
84
+ }
85
+ }
@@ -0,0 +1 @@
1
+ export * from './StackTail';
@@ -0,0 +1,2 @@
1
+ export * from './NotificationPanelContent';
2
+ export * from './components';
@@ -0,0 +1,116 @@
1
+ @use '@cloud-ru/ds-figma-variables/build/scss/styles/styles.module' as base;
2
+
3
+ .notificationPanelHeader {
4
+ display: flex;
5
+ flex-direction: column;
6
+ gap: base.$sn-primitive-dimension-4;
7
+ padding-block: base.$sn-primitive-dimension-24;
8
+ }
9
+
10
+ .notificationPanelHeadline {
11
+ display: flex;
12
+ gap: base.$sn-primitive-dimension-8;
13
+ align-items: center;
14
+
15
+ height: base.$sn-primitive-dimension-32;
16
+ padding-inline: base.$sn-primitive-dimension-24;
17
+ }
18
+
19
+ .notificationPanelTitle {
20
+ flex: 1 1 auto;
21
+ min-width: 0;
22
+ color: base.$sn-theme-color-available-version-textMain;
23
+ }
24
+
25
+ .notificationPanelHeaderActions {
26
+ display: flex;
27
+ align-items: center;
28
+ justify-content: flex-end;
29
+ }
30
+
31
+ .actionsRow {
32
+ display: flex;
33
+ gap: base.$sn-primitive-dimension-8;
34
+ align-items: center;
35
+ justify-content: space-between;
36
+
37
+ padding-top: base.$sn-primitive-dimension-12;
38
+ padding-inline: base.$sn-primitive-dimension-24;
39
+ }
40
+
41
+ .notificationPanelBody {
42
+ display: flex;
43
+ flex-direction: column;
44
+ gap: base.$sn-primitive-dimension-8;
45
+
46
+ min-height: 100%;
47
+ padding-right: base.$sn-primitive-dimension-24;
48
+ padding-bottom: base.$sn-primitive-dimension-16;
49
+ padding-left: base.$sn-primitive-dimension-24;
50
+ }
51
+
52
+ .notificationPanelFooterButton {
53
+ cursor: pointer;
54
+
55
+ padding: base.$sn-primitive-dimension-12 base.$sn-primitive-dimension-24;
56
+ border: none;
57
+ border-top: base.$sn-primitive-strokeWeight-strokeRegular solid base.$sn-theme-color-available-borderColor;
58
+
59
+ color: base.$sn-theme-color-neutral-text;
60
+
61
+ background-color: transparent;
62
+
63
+ &:hover {
64
+ background-color: base.$sn-theme-color-neutral-decorTransparent;
65
+ }
66
+
67
+ &:focus-visible {
68
+ outline: base.$sn-primitive-strokeWeight-strokeSemiBold solid base.$sn-theme-color-available-complementary;
69
+ outline-offset: 0;
70
+ }
71
+ }
72
+
73
+ .wrapper {
74
+ display: flex;
75
+ flex-direction: column;
76
+
77
+ height: 100%;
78
+ min-height: 0;
79
+
80
+ background-color: base.$sn-theme-color-neutral-background1Level;
81
+
82
+ &[data-layout-type='mobile'] {
83
+ .notificationPanelHeader {
84
+ gap: 0;
85
+ padding-block: base.$sn-primitive-dimension-8;
86
+ }
87
+
88
+ .notificationPanelHeadline {
89
+ padding-bottom: base.$sn-primitive-dimension-8;
90
+ padding-inline: base.$sn-primitive-dimension-16;
91
+ }
92
+
93
+ .actionsRow {
94
+ padding-top: 0;
95
+ padding-inline: base.$sn-primitive-dimension-16;
96
+ }
97
+
98
+ .notificationPanelBody {
99
+ padding: base.$sn-primitive-dimension-8 base.$sn-primitive-dimension-16 base.$sn-primitive-dimension-16;
100
+ }
101
+ }
102
+ }
103
+
104
+ .scrollArea {
105
+ flex: 1 1 auto;
106
+ min-height: 0;
107
+ }
108
+
109
+ .scrollStub {
110
+ width: 100%;
111
+ height: base.$sn-primitive-dimension-1;
112
+ }
113
+
114
+ .inlineFlex {
115
+ display: inline-flex;
116
+ }
@@ -0,0 +1,3 @@
1
+ export * from './NotificationCard';
2
+ export * from './NotificationPanelContent';
3
+ export * from './NotificationPanel';
@@ -0,0 +1,58 @@
1
+ export const APPEARANCE = {
2
+ Default: 'default',
3
+ Error: 'error',
4
+ Warning: 'warning',
5
+ Success: 'success',
6
+ } as const;
7
+
8
+ export const TEST_IDS = {
9
+ card: {
10
+ root: 'notification-card',
11
+ label: 'notification-card__label',
12
+ title: 'notification-card__title',
13
+ description: 'notification-card__description',
14
+ link: 'notification-card__link',
15
+ date: 'notification-card__date',
16
+ statusIndicator: 'notification-card__status-indicator',
17
+ skeleton: 'notification-card__skeleton',
18
+ actions: {
19
+ wrapper: 'notification-card__actions',
20
+ droplist: 'notification-card__droplist',
21
+ droplistTrigger: 'notification-card__droplist-trigger',
22
+ droplistAction: 'notification-card__droplist-action',
23
+ },
24
+ primaryButton: 'notification-card__primary-button',
25
+ secondaryButton: 'notification-card__secondary-button',
26
+ },
27
+ panel: {
28
+ root: 'notification-panel',
29
+ title: 'notification-panel__title',
30
+ segments: 'notification-panel__segments',
31
+ chipToggle: 'notification-panel__chip-toggle',
32
+ settings: {
33
+ droplist: 'notification-panel__settings__droplist',
34
+ droplistTrigger: 'notification-panel__settings__droplist-trigger',
35
+ droplistAction: 'notification-panel__settings__droplist-action',
36
+ },
37
+ readAll: 'notification-panel__read-all',
38
+ footerButton: 'notification-panel__footer-button',
39
+ blank: 'notification-panel__blank',
40
+ error: 'notification-panel__error',
41
+ group: {
42
+ root: 'notification-panel__group',
43
+ title: 'notification-panel__group__title',
44
+ },
45
+ cardStack: {
46
+ headline: 'notification-panel__card-stack__headline',
47
+ wrapper: 'notification-panel__card-stack__wrapper',
48
+ title: 'notification-panel__card-stack__title',
49
+ openButton: 'notification-panel__card-stack__open-button',
50
+ actions: {
51
+ wrapper: 'notification-panel__card-stack__actions',
52
+ droplist: 'notification-panel__card-stack__droplist',
53
+ droplistTrigger: 'notification-panel__card-stack__droplist-trigger',
54
+ droplistAction: 'notification-panel__card-stack__droplist-action',
55
+ },
56
+ },
57
+ },
58
+ } as const;
@@ -0,0 +1,73 @@
1
+ import { Button } from '@cloud-ru/ds-button';
2
+ import { Droplist } from '@cloud-ru/ds-list';
3
+ import { Tag } from '@cloud-ru/ds-tag';
4
+ import cn from 'classnames';
5
+ import { Dispatch, ReactElement, SetStateAction } from 'react';
6
+
7
+ import { Action } from '../../types';
8
+ import { stopPropagationClick } from '../../utils';
9
+ import styles from './styles.module.scss';
10
+
11
+ export type ActionsButtonTestIds = {
12
+ wrapper: string;
13
+ droplist: string;
14
+ droplistTrigger: string;
15
+ droplistAction: string;
16
+ };
17
+
18
+ export type ActionsButtonProps = {
19
+ actions: Action[];
20
+ open: boolean;
21
+ setDroplistOpen: Dispatch<SetStateAction<boolean>>;
22
+ icon: ReactElement;
23
+ /** Доступное имя кнопки-триггера (icon-only кнопка иначе безымянна для скринридера). */
24
+ triggerAriaLabel: string;
25
+ testIds: ActionsButtonTestIds;
26
+ className?: string;
27
+ };
28
+
29
+ export function ActionsButton({
30
+ actions,
31
+ open,
32
+ setDroplistOpen,
33
+ icon,
34
+ triggerAriaLabel,
35
+ testIds,
36
+ className,
37
+ }: ActionsButtonProps) {
38
+ return (
39
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
40
+ <div className={cn(styles.inlineFlex, className)} data-test-id={testIds.wrapper} onClick={stopPropagationClick}>
41
+ <Droplist
42
+ size='m'
43
+ trigger='clickAndFocusVisible'
44
+ open={open}
45
+ onOpenChange={setDroplistOpen}
46
+ placement='bottom-end'
47
+ scroll
48
+ data-test-id={testIds.droplist}
49
+ items={actions.map(({ onClick, disabled, content, tagLabel, icon: itemIcon }, index) => ({
50
+ onClick: e => {
51
+ setDroplistOpen(false);
52
+ onClick?.(e);
53
+ },
54
+ disabled,
55
+ content,
56
+ beforeContent: itemIcon,
57
+ afterContent: tagLabel ? <Tag label={tagLabel} /> : undefined,
58
+ 'data-test-id': `${testIds.droplistAction}-${index}`,
59
+ }))}
60
+ triggerClassName={styles.inlineFlex}
61
+ >
62
+ <Button
63
+ view='function'
64
+ appearance='neutral'
65
+ size='m'
66
+ icon={icon}
67
+ aria-label={triggerAriaLabel}
68
+ data-test-id={testIds.droplistTrigger}
69
+ />
70
+ </Droplist>
71
+ </div>
72
+ );
73
+ }
@@ -0,0 +1 @@
1
+ export * from './ActionsButton';
@@ -0,0 +1,3 @@
1
+ .inlineFlex {
2
+ display: inline-flex;
3
+ }
package/src/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ export * from './components';
2
+ export * from './constants';
3
+ export * from './types';
4
+ export { setNonce } from '@cloud-ru/ds-scroll';
package/src/types.ts ADDED
@@ -0,0 +1,15 @@
1
+ import { BaseItemProps } from '@cloud-ru/ds-list';
2
+ import { ValueOf } from '@cloud-ru/ds-utils';
3
+ import { ReactElement } from 'react';
4
+
5
+ import { APPEARANCE } from './constants';
6
+
7
+ export type Appearance = ValueOf<typeof APPEARANCE>;
8
+
9
+ /** Действие в выпадающем меню карточки или панели уведомлений */
10
+ export type Action = {
11
+ /** Иконка слева от текста */
12
+ icon?: ReactElement;
13
+ /** Лейбл-тег справа от текста */
14
+ tagLabel?: string;
15
+ } & Pick<BaseItemProps, 'content' | 'onClick' | 'disabled'>;
package/src/utils.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { MouseEvent } from 'react';
2
+
3
+ /** Останавливает всплытие клика — чтобы вложенные контролы не активировали кликабельную карточку. */
4
+ export function stopPropagationClick(e: MouseEvent<HTMLElement>) {
5
+ e.stopPropagation();
6
+ }