@megafon/ui-core 3.10.1 → 3.11.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/CHANGELOG.md +17 -0
- package/dist/es/components/Button/Button.css +37 -0
- package/dist/es/components/Button/Button.d.ts +2 -0
- package/dist/es/components/Button/Button.js +10 -3
- package/dist/es/components/Notification/Notification.css +131 -33
- package/dist/es/components/Notification/Notification.d.ts +20 -0
- package/dist/es/components/Notification/Notification.js +176 -10
- package/dist/lib/components/Button/Button.css +37 -0
- package/dist/lib/components/Button/Button.d.ts +2 -0
- package/dist/lib/components/Button/Button.js +10 -3
- package/dist/lib/components/Notification/Notification.css +131 -33
- package/dist/lib/components/Notification/Notification.d.ts +20 -0
- package/dist/lib/components/Notification/Notification.js +179 -10
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,23 @@
|
|
|
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
|
+
# [3.11.0](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@3.10.1...@megafon/ui-core@3.11.0) (2022-06-21)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **button:** fix font styles for extra small size ([f475b05](https://github.com/MegafonWebLab/megafon-ui/commit/f475b05ab9d62aa56645fb90ccdef88996e72a70))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* **button:** add prop ellipsis ([1978277](https://github.com/MegafonWebLab/megafon-ui/commit/1978277a918cb680e32259042c1a7e3c58056b1b))
|
|
17
|
+
* **notification:** add ability to display button and collapse ([a5fe2f0](https://github.com/MegafonWebLab/megafon-ui/commit/a5fe2f0730b71469c2fb06a148b0e4574adb2d7b))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
6
23
|
## [3.10.1](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@3.10.0...@megafon/ui-core@3.10.1) (2022-06-07)
|
|
7
24
|
|
|
8
25
|
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
padding: 0 32px;
|
|
9
9
|
border: none;
|
|
10
10
|
border-radius: 30px;
|
|
11
|
+
overflow: hidden;
|
|
11
12
|
color: var(--stcWhite);
|
|
12
13
|
font-weight: 500;
|
|
13
14
|
text-align: center;
|
|
@@ -21,7 +22,12 @@
|
|
|
21
22
|
appearance: none;
|
|
22
23
|
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
|
23
24
|
}
|
|
25
|
+
.mfui-button_size-all_extra-small {
|
|
26
|
+
padding: 0 16px;
|
|
27
|
+
}
|
|
24
28
|
.mfui-button_size-all_extra-small .mfui-button__inner {
|
|
29
|
+
font-size: 12px;
|
|
30
|
+
line-height: 16px;
|
|
25
31
|
min-width: 26px;
|
|
26
32
|
height: 26px;
|
|
27
33
|
}
|
|
@@ -54,7 +60,12 @@
|
|
|
54
60
|
height: 40px;
|
|
55
61
|
}
|
|
56
62
|
@media screen and (min-width: 1280px) {
|
|
63
|
+
.mfui-button_size-wide_extra-small {
|
|
64
|
+
padding: 0 16px;
|
|
65
|
+
}
|
|
57
66
|
.mfui-button_size-wide_extra-small .mfui-button__inner {
|
|
67
|
+
font-size: 12px;
|
|
68
|
+
line-height: 16px;
|
|
58
69
|
min-width: 26px;
|
|
59
70
|
height: 26px;
|
|
60
71
|
}
|
|
@@ -88,7 +99,12 @@
|
|
|
88
99
|
}
|
|
89
100
|
}
|
|
90
101
|
@media screen and (min-width: 1024px) {
|
|
102
|
+
.mfui-button_size-desktop_extra-small {
|
|
103
|
+
padding: 0 16px;
|
|
104
|
+
}
|
|
91
105
|
.mfui-button_size-desktop_extra-small .mfui-button__inner {
|
|
106
|
+
font-size: 12px;
|
|
107
|
+
line-height: 16px;
|
|
92
108
|
min-width: 26px;
|
|
93
109
|
height: 26px;
|
|
94
110
|
}
|
|
@@ -122,7 +138,12 @@
|
|
|
122
138
|
}
|
|
123
139
|
}
|
|
124
140
|
@media screen and (min-width: 768px) and (max-width: 1023px) {
|
|
141
|
+
.mfui-button_size-tablet_extra-small {
|
|
142
|
+
padding: 0 16px;
|
|
143
|
+
}
|
|
125
144
|
.mfui-button_size-tablet_extra-small .mfui-button__inner {
|
|
145
|
+
font-size: 12px;
|
|
146
|
+
line-height: 16px;
|
|
126
147
|
min-width: 26px;
|
|
127
148
|
height: 26px;
|
|
128
149
|
}
|
|
@@ -156,7 +177,12 @@
|
|
|
156
177
|
}
|
|
157
178
|
}
|
|
158
179
|
@media screen and (max-width: 767px) {
|
|
180
|
+
.mfui-button_size-mobile_extra-small {
|
|
181
|
+
padding: 0 16px;
|
|
182
|
+
}
|
|
159
183
|
.mfui-button_size-mobile_extra-small .mfui-button__inner {
|
|
184
|
+
font-size: 12px;
|
|
185
|
+
line-height: 16px;
|
|
160
186
|
min-width: 26px;
|
|
161
187
|
height: 26px;
|
|
162
188
|
}
|
|
@@ -213,6 +239,11 @@
|
|
|
213
239
|
.mfui-button__text {
|
|
214
240
|
margin-bottom: 2px;
|
|
215
241
|
}
|
|
242
|
+
.mfui-button__text_ellipsis {
|
|
243
|
+
overflow: hidden;
|
|
244
|
+
white-space: nowrap;
|
|
245
|
+
text-overflow: ellipsis;
|
|
246
|
+
}
|
|
216
247
|
.mfui-button__content {
|
|
217
248
|
display: -webkit-box;
|
|
218
249
|
display: -ms-flexbox;
|
|
@@ -221,6 +252,12 @@
|
|
|
221
252
|
-ms-flex-align: center;
|
|
222
253
|
align-items: center;
|
|
223
254
|
}
|
|
255
|
+
.mfui-button__content_ellipsis {
|
|
256
|
+
width: inherit;
|
|
257
|
+
max-width: -webkit-fit-content;
|
|
258
|
+
max-width: -moz-fit-content;
|
|
259
|
+
max-width: fit-content;
|
|
260
|
+
}
|
|
224
261
|
.mfui-button__icon-arrow {
|
|
225
262
|
width: 32px;
|
|
226
263
|
height: 32px;
|
|
@@ -74,6 +74,8 @@ export interface IButtonProps {
|
|
|
74
74
|
disabled?: boolean;
|
|
75
75
|
/** Ссылка на элемент */
|
|
76
76
|
buttonRef?: Ref<HTMLButtonElement | HTMLAnchorElement>;
|
|
77
|
+
/** Обрезать текст при недостаточной ширине и добавлять многоточие */
|
|
78
|
+
ellipsis?: boolean;
|
|
77
79
|
/** Обработчик клика по кнопке */
|
|
78
80
|
onClick?: (e: React.SyntheticEvent<EventTarget>) => void;
|
|
79
81
|
}
|
|
@@ -81,6 +81,8 @@ var Button = function Button(_ref) {
|
|
|
81
81
|
icon = _ref.icon,
|
|
82
82
|
disabled = _ref.disabled,
|
|
83
83
|
children = _ref.children,
|
|
84
|
+
_ref$ellipsis = _ref.ellipsis,
|
|
85
|
+
ellipsis = _ref$ellipsis === void 0 ? false : _ref$ellipsis,
|
|
84
86
|
onClick = _ref.onClick,
|
|
85
87
|
dataAttrs = _ref.dataAttrs,
|
|
86
88
|
buttonRef = _ref.buttonRef;
|
|
@@ -123,15 +125,19 @@ var Button = function Button(_ref) {
|
|
|
123
125
|
}
|
|
124
126
|
|
|
125
127
|
return /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.content), {
|
|
126
|
-
className: cn('content',
|
|
128
|
+
className: cn('content', {
|
|
129
|
+
ellipsis: ellipsis
|
|
130
|
+
}, contentClassName)
|
|
127
131
|
}), icon && /*#__PURE__*/React.createElement("div", {
|
|
128
132
|
className: cn('icon')
|
|
129
133
|
}, icon), children && /*#__PURE__*/React.createElement("span", {
|
|
130
|
-
className: cn('text'
|
|
134
|
+
className: cn('text', {
|
|
135
|
+
ellipsis: ellipsis
|
|
136
|
+
})
|
|
131
137
|
}, children), !icon && showArrow && /*#__PURE__*/React.createElement(Arrow, {
|
|
132
138
|
className: cn('icon-arrow')
|
|
133
139
|
}));
|
|
134
|
-
}, [children, icon, dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.content, contentClassName, showArrow]);
|
|
140
|
+
}, [children, icon, dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.content, contentClassName, showArrow, ellipsis]);
|
|
135
141
|
var contentType = React.useMemo(function () {
|
|
136
142
|
switch (true) {
|
|
137
143
|
case icon && !children:
|
|
@@ -238,6 +244,7 @@ Button.propTypes = {
|
|
|
238
244
|
buttonRef: PropTypes.oneOfType([PropTypes.func, PropTypes.oneOfType([PropTypes.shape({
|
|
239
245
|
current: PropTypes.elementType
|
|
240
246
|
}), PropTypes.any])]),
|
|
247
|
+
ellipsis: PropTypes.bool,
|
|
241
248
|
onClick: PropTypes.func
|
|
242
249
|
};
|
|
243
250
|
export default Button;
|
|
@@ -7,17 +7,13 @@ h5 {
|
|
|
7
7
|
}
|
|
8
8
|
.mfui-notification {
|
|
9
9
|
position: relative;
|
|
10
|
-
padding:
|
|
10
|
+
padding: 20px 12px 20px 32px;
|
|
11
|
+
border-radius: 12px;
|
|
11
12
|
background-color: var(--base);
|
|
12
13
|
}
|
|
13
|
-
@media screen and (
|
|
14
|
+
@media screen and (max-width: 767px) {
|
|
14
15
|
.mfui-notification {
|
|
15
|
-
padding:
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
@media screen and (min-width: 1024px) {
|
|
19
|
-
.mfui-notification {
|
|
20
|
-
padding: 20px 32px;
|
|
16
|
+
padding: 16px 12px;
|
|
21
17
|
}
|
|
22
18
|
}
|
|
23
19
|
.mfui-notification__container {
|
|
@@ -38,14 +34,43 @@ h5 {
|
|
|
38
34
|
padding-right: 20px;
|
|
39
35
|
}
|
|
40
36
|
.mfui-notification__text {
|
|
41
|
-
font-size:
|
|
42
|
-
line-height:
|
|
37
|
+
font-size: 12px;
|
|
38
|
+
line-height: 16px;
|
|
39
|
+
position: relative;
|
|
43
40
|
max-width: 100%;
|
|
44
41
|
margin: 0;
|
|
45
42
|
color: var(--content);
|
|
43
|
+
-webkit-transition: height 300ms;
|
|
44
|
+
transition: height 300ms;
|
|
46
45
|
}
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
@media screen and (min-width: 768px) {
|
|
47
|
+
.mfui-notification__text {
|
|
48
|
+
font-size: 15px;
|
|
49
|
+
line-height: 24px;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
.mfui-notification__short-text {
|
|
53
|
+
position: static;
|
|
54
|
+
visibility: visible;
|
|
55
|
+
opacity: 1;
|
|
56
|
+
-webkit-transition: opacity 200ms;
|
|
57
|
+
transition: opacity 200ms;
|
|
58
|
+
}
|
|
59
|
+
.mfui-notification__short-text_hidden,
|
|
60
|
+
.mfui-notification__full-text {
|
|
61
|
+
position: absolute;
|
|
62
|
+
top: 0;
|
|
63
|
+
visibility: hidden;
|
|
64
|
+
opacity: 0;
|
|
65
|
+
-webkit-transition: opacity 300ms, visibility 300ms;
|
|
66
|
+
transition: opacity 300ms, visibility 300ms;
|
|
67
|
+
}
|
|
68
|
+
.mfui-notification__full-text_visible {
|
|
69
|
+
position: static;
|
|
70
|
+
visibility: visible;
|
|
71
|
+
opacity: 1;
|
|
72
|
+
-webkit-transition: opacity 200ms;
|
|
73
|
+
transition: opacity 200ms;
|
|
49
74
|
}
|
|
50
75
|
.mfui-notification__content {
|
|
51
76
|
display: -webkit-box;
|
|
@@ -61,23 +86,8 @@ h5 {
|
|
|
61
86
|
-ms-flex-item-align: center;
|
|
62
87
|
align-self: center;
|
|
63
88
|
width: 100%;
|
|
64
|
-
max-width: 212px;
|
|
65
89
|
margin-left: 12px;
|
|
66
|
-
|
|
67
|
-
@media screen and (min-width: 768px) {
|
|
68
|
-
.mfui-notification__content {
|
|
69
|
-
max-width: 540px;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
@media screen and (min-width: 1024px) {
|
|
73
|
-
.mfui-notification__content {
|
|
74
|
-
max-width: 640px;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
@media screen and (min-width: 1280px) {
|
|
78
|
-
.mfui-notification__content {
|
|
79
|
-
max-width: 840px;
|
|
80
|
-
}
|
|
90
|
+
overflow: hidden;
|
|
81
91
|
}
|
|
82
92
|
.mfui-notification__icon-container {
|
|
83
93
|
display: -webkit-box;
|
|
@@ -104,6 +114,45 @@ h5 {
|
|
|
104
114
|
min-width: 32px;
|
|
105
115
|
height: 32px;
|
|
106
116
|
}
|
|
117
|
+
.mfui-notification__text-container {
|
|
118
|
+
width: 85%;
|
|
119
|
+
margin-right: 56px;
|
|
120
|
+
}
|
|
121
|
+
@media screen and (min-width: 768px) {
|
|
122
|
+
.mfui-notification__text-container {
|
|
123
|
+
margin-right: 72px;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
.mfui-notification__bottom {
|
|
127
|
+
z-index: 1;
|
|
128
|
+
display: -webkit-box;
|
|
129
|
+
display: -ms-flexbox;
|
|
130
|
+
display: flex;
|
|
131
|
+
gap: 16px;
|
|
132
|
+
-webkit-box-align: end;
|
|
133
|
+
-ms-flex-align: end;
|
|
134
|
+
align-items: flex-end;
|
|
135
|
+
-webkit-box-pack: justify;
|
|
136
|
+
-ms-flex-pack: justify;
|
|
137
|
+
justify-content: space-between;
|
|
138
|
+
width: 100%;
|
|
139
|
+
margin-top: 8px;
|
|
140
|
+
}
|
|
141
|
+
@media screen and (min-width: 768px) {
|
|
142
|
+
.mfui-notification__bottom {
|
|
143
|
+
gap: 20px;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
.mfui-notification__bottom-block {
|
|
147
|
+
display: -webkit-box;
|
|
148
|
+
display: -ms-flexbox;
|
|
149
|
+
display: flex;
|
|
150
|
+
gap: 16px;
|
|
151
|
+
overflow: hidden;
|
|
152
|
+
}
|
|
153
|
+
.mfui-notification__bottom_has-button {
|
|
154
|
+
margin-top: 12px;
|
|
155
|
+
}
|
|
107
156
|
.mfui-notification__link {
|
|
108
157
|
font-size: 15px;
|
|
109
158
|
line-height: 24px;
|
|
@@ -114,16 +163,58 @@ h5 {
|
|
|
114
163
|
-webkit-box-align: center;
|
|
115
164
|
-ms-flex-align: center;
|
|
116
165
|
align-items: center;
|
|
117
|
-
margin-top: 8px;
|
|
118
166
|
cursor: pointer;
|
|
119
167
|
}
|
|
120
|
-
|
|
168
|
+
@media screen and (max-width: 767px) {
|
|
169
|
+
.mfui-notification__link {
|
|
170
|
+
font-size: 12px;
|
|
171
|
+
line-height: 16px;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
.mfui-notification__link-arrow,
|
|
175
|
+
.mfui-notification__collapse-arrow {
|
|
121
176
|
width: 20px;
|
|
122
177
|
min-width: 20px;
|
|
123
178
|
height: 20px;
|
|
124
|
-
margin-top: 4px;
|
|
125
179
|
fill: var(--systemBlue);
|
|
126
180
|
}
|
|
181
|
+
.mfui-notification__link-arrow {
|
|
182
|
+
margin-bottom: -2px;
|
|
183
|
+
}
|
|
184
|
+
@media screen and (min-width: 768px) {
|
|
185
|
+
.mfui-notification__link-arrow {
|
|
186
|
+
margin-bottom: -4px;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
.mfui-notification__collapse-button {
|
|
190
|
+
font-size: 15px;
|
|
191
|
+
line-height: 24px;
|
|
192
|
+
font-weight: 500;
|
|
193
|
+
display: -webkit-box;
|
|
194
|
+
display: -ms-flexbox;
|
|
195
|
+
display: flex;
|
|
196
|
+
-webkit-box-align: center;
|
|
197
|
+
-ms-flex-align: center;
|
|
198
|
+
align-items: center;
|
|
199
|
+
height: -webkit-fit-content;
|
|
200
|
+
height: -moz-fit-content;
|
|
201
|
+
height: fit-content;
|
|
202
|
+
padding: 0;
|
|
203
|
+
border: none;
|
|
204
|
+
color: var(--systemBlue);
|
|
205
|
+
text-align: right;
|
|
206
|
+
background-color: transparent;
|
|
207
|
+
cursor: pointer;
|
|
208
|
+
}
|
|
209
|
+
@media screen and (max-width: 767px) {
|
|
210
|
+
.mfui-notification__collapse-button {
|
|
211
|
+
font-size: 12px;
|
|
212
|
+
line-height: 16px;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
.mfui-notification__collapse_hidden {
|
|
216
|
+
visibility: hidden;
|
|
217
|
+
}
|
|
127
218
|
.mfui-notification__close {
|
|
128
219
|
position: absolute;
|
|
129
220
|
top: 8px;
|
|
@@ -153,10 +244,17 @@ h5 {
|
|
|
153
244
|
height: 32px;
|
|
154
245
|
}
|
|
155
246
|
}
|
|
247
|
+
.mfui-notification__close:hover {
|
|
248
|
+
background-color: var(--spbSky1);
|
|
249
|
+
}
|
|
250
|
+
.mfui-notification__close:active {
|
|
251
|
+
background-color: var(--spbSky2);
|
|
252
|
+
}
|
|
156
253
|
.mfui-notification__close-icon {
|
|
157
254
|
width: 10px;
|
|
158
255
|
height: 10px;
|
|
159
|
-
|
|
256
|
+
opacity: 0.5;
|
|
257
|
+
fill: var(--content);
|
|
160
258
|
}
|
|
161
259
|
.mfui-notification_type_error .mfui-notification__icon-container {
|
|
162
260
|
background-color: var(--fury20);
|
|
@@ -219,7 +317,7 @@ h5 {
|
|
|
219
317
|
.mfui-notification_colored.mfui-notification_type_error .mfui-notification__link {
|
|
220
318
|
color: var(--stcWhite);
|
|
221
319
|
}
|
|
222
|
-
.mfui-notification_colored.mfui-notification_type_error .mfui-
|
|
320
|
+
.mfui-notification_colored.mfui-notification_type_error .mfui-notification__link-arrow {
|
|
223
321
|
fill: var(--stcWhite);
|
|
224
322
|
}
|
|
225
323
|
.mfui-notification_colored.mfui-notification_type_error .mfui-notification__icon-container {
|
|
@@ -33,6 +33,20 @@ export interface INotificationProps {
|
|
|
33
33
|
hasCloseButton?: boolean;
|
|
34
34
|
/** Заголовок */
|
|
35
35
|
title?: string;
|
|
36
|
+
/** Короткий текст, отображаемый при закрытом расхлопе */
|
|
37
|
+
shortText?: string;
|
|
38
|
+
/** заголовок закрытого расхлопа */
|
|
39
|
+
closeCollapseTitle?: string;
|
|
40
|
+
/** заголовок открытого расхлопа */
|
|
41
|
+
openCollapseTitle?: string;
|
|
42
|
+
/** Управление состоянием открыт/закрыт расхлопа "Подробнее" */
|
|
43
|
+
isCollapseOpened?: boolean;
|
|
44
|
+
/** Текст кнопки */
|
|
45
|
+
buttonText?: string;
|
|
46
|
+
/** Лоадер кнопки */
|
|
47
|
+
buttonLoader?: boolean;
|
|
48
|
+
/** Заблокировать кнопку */
|
|
49
|
+
buttonDisable?: boolean;
|
|
36
50
|
/** Текст ссылки внизу уведомления */
|
|
37
51
|
link?: string;
|
|
38
52
|
/** rel - аргумент тега <a> для ссылки */
|
|
@@ -50,11 +64,17 @@ export interface INotificationProps {
|
|
|
50
64
|
text?: Record<string, string>;
|
|
51
65
|
link?: Record<string, string>;
|
|
52
66
|
close?: Record<string, string>;
|
|
67
|
+
button?: Record<string, string>;
|
|
68
|
+
collapseButton?: Record<string, string>;
|
|
53
69
|
};
|
|
54
70
|
/** Обработчик на закрытие */
|
|
55
71
|
onClose?: () => void;
|
|
56
72
|
/** Обработчик клика по ссылке */
|
|
57
73
|
onLinkClick?: () => void;
|
|
74
|
+
/** Обработчик клика по кнопке */
|
|
75
|
+
onButtonClick?: () => void;
|
|
76
|
+
/** Обработчик клика по кнопке расхлопа */
|
|
77
|
+
onCollapseButtonClick?: (value: boolean) => void;
|
|
58
78
|
}
|
|
59
79
|
declare const Notification: React.FC<INotificationProps>;
|
|
60
80
|
export default Notification;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import "core-js/modules/es.object.values";
|
|
2
2
|
import "core-js/modules/es.string.link";
|
|
3
|
+
import "core-js/modules/web.timers";
|
|
4
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
5
|
import _extends from "@babel/runtime/helpers/extends";
|
|
4
|
-
import React from 'react';
|
|
6
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
5
7
|
import { cnCreate, filterDataAttrs } from '@megafon/ui-helpers';
|
|
6
8
|
import * as PropTypes from 'prop-types';
|
|
9
|
+
import Button from "../Button/Button";
|
|
7
10
|
import Header from "../Header/Header";
|
|
8
11
|
import TextLink from "../TextLink/TextLink";
|
|
9
12
|
import Tile from "../Tile/Tile";
|
|
@@ -19,6 +22,26 @@ var ErrorIcon = function ErrorIcon(props) {
|
|
|
19
22
|
}));
|
|
20
23
|
};
|
|
21
24
|
|
|
25
|
+
var ArrowDown = function ArrowDown(props) {
|
|
26
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
27
|
+
viewBox: "0 0 20 20"
|
|
28
|
+
}, props), /*#__PURE__*/React.createElement("path", {
|
|
29
|
+
d: "M6 8h8l-4 5z",
|
|
30
|
+
fillRule: "evenodd",
|
|
31
|
+
clipRule: "evenodd"
|
|
32
|
+
}));
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
var ArrowUp = function ArrowUp(props) {
|
|
36
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
37
|
+
viewBox: "0 0 20 20"
|
|
38
|
+
}, props), /*#__PURE__*/React.createElement("path", {
|
|
39
|
+
d: "M14 12H6l4-5z",
|
|
40
|
+
fillRule: "evenodd",
|
|
41
|
+
clipRule: "evenodd"
|
|
42
|
+
}));
|
|
43
|
+
};
|
|
44
|
+
|
|
22
45
|
var RightArrow = function RightArrow(props) {
|
|
23
46
|
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
24
47
|
viewBox: "0 0 20 20"
|
|
@@ -61,6 +84,7 @@ var CancelIcon = function CancelIcon(props) {
|
|
|
61
84
|
}));
|
|
62
85
|
};
|
|
63
86
|
|
|
87
|
+
var TIMEOUT_DELAY = 400;
|
|
64
88
|
export var NotificationTypes = {
|
|
65
89
|
SUCCESS: 'success',
|
|
66
90
|
WARNING: 'warning',
|
|
@@ -91,6 +115,18 @@ var Notification = function Notification(_ref) {
|
|
|
91
115
|
isColored = _ref$isColored === void 0 ? true : _ref$isColored,
|
|
92
116
|
hasCloseButton = _ref.hasCloseButton,
|
|
93
117
|
title = _ref.title,
|
|
118
|
+
shortText = _ref.shortText,
|
|
119
|
+
_ref$closeCollapseTit = _ref.closeCollapseTitle,
|
|
120
|
+
closeCollapseTitle = _ref$closeCollapseTit === void 0 ? 'Подробнее' : _ref$closeCollapseTit,
|
|
121
|
+
_ref$openCollapseTitl = _ref.openCollapseTitle,
|
|
122
|
+
openCollapseTitle = _ref$openCollapseTitl === void 0 ? 'Свернуть' : _ref$openCollapseTitl,
|
|
123
|
+
_ref$isCollapseOpened = _ref.isCollapseOpened,
|
|
124
|
+
isCollapseOpened = _ref$isCollapseOpened === void 0 ? false : _ref$isCollapseOpened,
|
|
125
|
+
buttonText = _ref.buttonText,
|
|
126
|
+
_ref$buttonLoader = _ref.buttonLoader,
|
|
127
|
+
buttonLoader = _ref$buttonLoader === void 0 ? false : _ref$buttonLoader,
|
|
128
|
+
_ref$buttonDisable = _ref.buttonDisable,
|
|
129
|
+
buttonDisable = _ref$buttonDisable === void 0 ? false : _ref$buttonDisable,
|
|
94
130
|
link = _ref.link,
|
|
95
131
|
rel = _ref.rel,
|
|
96
132
|
href = _ref.href,
|
|
@@ -98,7 +134,84 @@ var Notification = function Notification(_ref) {
|
|
|
98
134
|
icon = _ref.icon,
|
|
99
135
|
dataAttrs = _ref.dataAttrs,
|
|
100
136
|
onClose = _ref.onClose,
|
|
101
|
-
onLinkClick = _ref.onLinkClick
|
|
137
|
+
onLinkClick = _ref.onLinkClick,
|
|
138
|
+
onButtonClick = _ref.onButtonClick,
|
|
139
|
+
onCollapseButtonClick = _ref.onCollapseButtonClick;
|
|
140
|
+
var shortTextRef = useRef(null);
|
|
141
|
+
var fullTextRef = useRef(null);
|
|
142
|
+
var wrapTextRef = useRef(null);
|
|
143
|
+
|
|
144
|
+
var _useState = useState(isCollapseOpened),
|
|
145
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
146
|
+
showFullText = _useState2[0],
|
|
147
|
+
setShowFullText = _useState2[1];
|
|
148
|
+
|
|
149
|
+
var _useState3 = useState(false),
|
|
150
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
151
|
+
updateTextHeight = _useState4[0],
|
|
152
|
+
setUpdateTextHeight = _useState4[1];
|
|
153
|
+
|
|
154
|
+
var initialTextClasses = {
|
|
155
|
+
"short": {
|
|
156
|
+
hidden: shortText && showFullText
|
|
157
|
+
},
|
|
158
|
+
full: {
|
|
159
|
+
visible: showFullText
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
var _useState5 = useState(initialTextClasses),
|
|
164
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
165
|
+
textClasses = _useState6[0],
|
|
166
|
+
setTextClass = _useState6[1];
|
|
167
|
+
|
|
168
|
+
var hasBottom = shortText || buttonText || link;
|
|
169
|
+
var isErrorType = type === NotificationTypes.ERROR;
|
|
170
|
+
useEffect(function () {
|
|
171
|
+
setShowFullText(isCollapseOpened);
|
|
172
|
+
}, [isCollapseOpened]);
|
|
173
|
+
useEffect(function () {
|
|
174
|
+
if (!fullTextRef.current || !shortTextRef.current || !wrapTextRef.current) {
|
|
175
|
+
return undefined;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
var visibleElement = showFullText ? shortTextRef.current : fullTextRef.current;
|
|
179
|
+
|
|
180
|
+
var _visibleElement$getBo = visibleElement.getBoundingClientRect(),
|
|
181
|
+
height = _visibleElement$getBo.height;
|
|
182
|
+
|
|
183
|
+
wrapTextRef.current.style.height = "".concat(height, "px");
|
|
184
|
+
return setUpdateTextHeight(!updateTextHeight); // не должен запускаться при изменении флага updateTextHeight;
|
|
185
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
186
|
+
}, [showFullText]);
|
|
187
|
+
useEffect(function () {
|
|
188
|
+
if (!fullTextRef.current || !shortTextRef.current || !wrapTextRef.current) {
|
|
189
|
+
return undefined;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
var hiddenElement = showFullText ? fullTextRef.current : shortTextRef.current;
|
|
193
|
+
|
|
194
|
+
var _hiddenElement$getBou = hiddenElement.getBoundingClientRect(),
|
|
195
|
+
height = _hiddenElement$getBou.height;
|
|
196
|
+
|
|
197
|
+
wrapTextRef.current.style.height = "".concat(height, "px");
|
|
198
|
+
setTextClass(initialTextClasses);
|
|
199
|
+
var timeoutId = setTimeout(function () {
|
|
200
|
+
if (wrapTextRef.current) {
|
|
201
|
+
wrapTextRef.current.style.height = 'auto';
|
|
202
|
+
}
|
|
203
|
+
}, TIMEOUT_DELAY);
|
|
204
|
+
return function () {
|
|
205
|
+
clearTimeout(timeoutId);
|
|
206
|
+
}; // не должен запускаться при изменении флага showFullText;
|
|
207
|
+
// запускается по флагу updateTextHeight, который изменяется в предыдущем эффекте.
|
|
208
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
209
|
+
}, [updateTextHeight]);
|
|
210
|
+
|
|
211
|
+
var handleCollapseButtonClick = function handleCollapseButtonClick() {
|
|
212
|
+
setShowFullText(!showFullText);
|
|
213
|
+
onCollapseButtonClick === null || onCollapseButtonClick === void 0 ? void 0 : onCollapseButtonClick(!showFullText);
|
|
214
|
+
};
|
|
102
215
|
|
|
103
216
|
var renderLink = function renderLink() {
|
|
104
217
|
return /*#__PURE__*/React.createElement(TextLink, {
|
|
@@ -111,10 +224,38 @@ var Notification = function Notification(_ref) {
|
|
|
111
224
|
href: href,
|
|
112
225
|
target: target
|
|
113
226
|
}, link, /*#__PURE__*/React.createElement(RightArrow, {
|
|
114
|
-
className: cn('
|
|
227
|
+
className: cn('link-arrow')
|
|
115
228
|
}));
|
|
116
229
|
};
|
|
117
230
|
|
|
231
|
+
var renderButton = function renderButton() {
|
|
232
|
+
return /*#__PURE__*/React.createElement(Button, {
|
|
233
|
+
className: cn('button'),
|
|
234
|
+
dataAttrs: {
|
|
235
|
+
root: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.button
|
|
236
|
+
},
|
|
237
|
+
sizeAll: "small",
|
|
238
|
+
sizeMobile: "extra-small",
|
|
239
|
+
theme: isErrorType && isColored ? 'white' : 'green',
|
|
240
|
+
showLoader: buttonLoader,
|
|
241
|
+
disabled: buttonDisable,
|
|
242
|
+
ellipsis: !buttonLoader,
|
|
243
|
+
onClick: onButtonClick
|
|
244
|
+
}, buttonText);
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
var renderCollapseButton = function renderCollapseButton() {
|
|
248
|
+
return /*#__PURE__*/React.createElement("button", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.collapseButton), {
|
|
249
|
+
type: "button",
|
|
250
|
+
className: cn('collapse-button'),
|
|
251
|
+
onClick: handleCollapseButtonClick
|
|
252
|
+
}), showFullText ? openCollapseTitle : closeCollapseTitle, /*#__PURE__*/React.createElement("div", {
|
|
253
|
+
className: cn('collapse-arrow', {
|
|
254
|
+
close: showFullText
|
|
255
|
+
})
|
|
256
|
+
}, showFullText ? /*#__PURE__*/React.createElement(ArrowUp, null) : /*#__PURE__*/React.createElement(ArrowDown, null)));
|
|
257
|
+
};
|
|
258
|
+
|
|
118
259
|
var renderIcon = function renderIcon() {
|
|
119
260
|
if (icon) {
|
|
120
261
|
return icon;
|
|
@@ -155,19 +296,33 @@ var Notification = function Notification(_ref) {
|
|
|
155
296
|
className: cn('icon-container')
|
|
156
297
|
}, renderIcon()), /*#__PURE__*/React.createElement("div", {
|
|
157
298
|
className: cn('content', [contentClass])
|
|
299
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
300
|
+
className: cn('text-container')
|
|
158
301
|
}, title && /*#__PURE__*/React.createElement(Header, {
|
|
159
302
|
dataAttrs: {
|
|
160
303
|
root: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.title
|
|
161
304
|
},
|
|
162
305
|
as: "h5",
|
|
163
|
-
className: cn('title'
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
},
|
|
306
|
+
className: cn('title')
|
|
307
|
+
}, title), /*#__PURE__*/React.createElement("div", _extends({
|
|
308
|
+
ref: wrapTextRef
|
|
309
|
+
}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.text), {
|
|
167
310
|
className: cn('text', {
|
|
168
311
|
'close-padding': hasCloseButton && !title
|
|
169
312
|
})
|
|
170
|
-
}),
|
|
313
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
314
|
+
ref: shortTextRef,
|
|
315
|
+
className: cn('short-text', textClasses["short"])
|
|
316
|
+
}, shortText || children), shortText && /*#__PURE__*/React.createElement("div", {
|
|
317
|
+
ref: fullTextRef,
|
|
318
|
+
className: cn('full-text', textClasses.full)
|
|
319
|
+
}, children))), hasBottom && /*#__PURE__*/React.createElement("div", {
|
|
320
|
+
className: cn('bottom', {
|
|
321
|
+
'has-button': !!buttonText
|
|
322
|
+
})
|
|
323
|
+
}, (buttonText || link) && /*#__PURE__*/React.createElement("div", {
|
|
324
|
+
className: cn('bottom-block')
|
|
325
|
+
}, buttonText && renderButton(), link && !shortText && renderLink()), shortText && renderCollapseButton()))), hasCloseButton && /*#__PURE__*/React.createElement("button", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.close), {
|
|
171
326
|
className: cn('close'),
|
|
172
327
|
type: "button",
|
|
173
328
|
onClick: onClose
|
|
@@ -188,6 +343,13 @@ Notification.propTypes = {
|
|
|
188
343
|
isColored: PropTypes.bool,
|
|
189
344
|
hasCloseButton: PropTypes.bool,
|
|
190
345
|
title: PropTypes.string,
|
|
346
|
+
shortText: PropTypes.string,
|
|
347
|
+
closeCollapseTitle: PropTypes.string,
|
|
348
|
+
openCollapseTitle: PropTypes.string,
|
|
349
|
+
isCollapseOpened: PropTypes.bool,
|
|
350
|
+
buttonText: PropTypes.string,
|
|
351
|
+
buttonLoader: PropTypes.bool,
|
|
352
|
+
buttonDisable: PropTypes.bool,
|
|
191
353
|
link: PropTypes.string,
|
|
192
354
|
rel: PropTypes.string,
|
|
193
355
|
href: PropTypes.string,
|
|
@@ -198,9 +360,13 @@ Notification.propTypes = {
|
|
|
198
360
|
title: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
199
361
|
text: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
200
362
|
link: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
201
|
-
close: PropTypes.objectOf(PropTypes.string.isRequired)
|
|
363
|
+
close: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
364
|
+
button: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
365
|
+
collapseButton: PropTypes.objectOf(PropTypes.string.isRequired)
|
|
202
366
|
}),
|
|
203
367
|
onClose: PropTypes.func,
|
|
204
|
-
onLinkClick: PropTypes.func
|
|
368
|
+
onLinkClick: PropTypes.func,
|
|
369
|
+
onButtonClick: PropTypes.func,
|
|
370
|
+
onCollapseButtonClick: PropTypes.func
|
|
205
371
|
};
|
|
206
372
|
export default Notification;
|