@megafon/ui-core 3.10.0 → 3.12.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 +39 -0
- package/dist/es/components/Banner/Banner.js +2 -8
- 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/es/components/Tabs/Tab.d.ts +1 -0
- package/dist/es/components/Tabs/Tab.js +2 -1
- package/dist/es/components/Tabs/Tabs.js +4 -4
- package/dist/lib/components/Banner/Banner.js +2 -8
- 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/dist/lib/components/Tabs/Tab.d.ts +1 -0
- package/dist/lib/components/Tabs/Tab.js +2 -1
- package/dist/lib/components/Tabs/Tabs.js +4 -4
- package/package.json +2 -2
|
@@ -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;
|
|
@@ -9,7 +9,8 @@ var Tab = function Tab(_ref) {
|
|
|
9
9
|
|
|
10
10
|
Tab.propTypes = {
|
|
11
11
|
dataAttrs: PropTypes.shape({
|
|
12
|
-
root: PropTypes.objectOf(PropTypes.string.isRequired)
|
|
12
|
+
root: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
13
|
+
inner: PropTypes.objectOf(PropTypes.string.isRequired)
|
|
13
14
|
}),
|
|
14
15
|
title: PropTypes.string,
|
|
15
16
|
icon: PropTypes.node,
|
|
@@ -270,15 +270,15 @@ var Tabs = function Tabs(_ref) {
|
|
|
270
270
|
var rootRefNode = rootRef.current;
|
|
271
271
|
rootRefNode && ((_a = intersectionObserverRef.current) === null || _a === void 0 ? void 0 : _a.unobserve(outerObserveContainer || rootRefNode));
|
|
272
272
|
}, [outerObserveContainer]);
|
|
273
|
-
var renderTab = React.useCallback(function (index, title, icon, href) {
|
|
273
|
+
var renderTab = React.useCallback(function (index, title, icon, href, attr) {
|
|
274
274
|
var ElementType = href ? 'a' : 'div';
|
|
275
|
-
return /*#__PURE__*/React.createElement(ElementType, {
|
|
275
|
+
return /*#__PURE__*/React.createElement(ElementType, _extends({
|
|
276
276
|
href: href,
|
|
277
277
|
className: cn('tab-inner', {
|
|
278
278
|
current: currentIndex === index
|
|
279
279
|
}),
|
|
280
280
|
onClick: handleTabInnerClick(index)
|
|
281
|
-
}, !!icon && /*#__PURE__*/React.createElement("div", {
|
|
281
|
+
}, filterDataAttrs(attr, index + 1)), !!icon && /*#__PURE__*/React.createElement("div", {
|
|
282
282
|
className: cn('tab-icon')
|
|
283
283
|
}, icon), !!title && /*#__PURE__*/React.createElement("div", {
|
|
284
284
|
className: cn('tab-title')
|
|
@@ -292,7 +292,7 @@ var Tabs = function Tabs(_ref) {
|
|
|
292
292
|
href = _child$props.href,
|
|
293
293
|
renderTabWrapper = _child$props.renderTabWrapper,
|
|
294
294
|
data = _child$props.dataAttrs;
|
|
295
|
-
var tab = renderTab(i, title, icon, href);
|
|
295
|
+
var tab = renderTab(i, title, icon, href, data === null || data === void 0 ? void 0 : data.inner);
|
|
296
296
|
var activeTabClassName = currentIndex === i ? activeTabClass : undefined;
|
|
297
297
|
return /*#__PURE__*/React.createElement(SwiperSlide, {
|
|
298
298
|
className: cn('slide')
|
|
@@ -188,12 +188,6 @@ var Banner = function Banner(_ref) {
|
|
|
188
188
|
setActiveIndex(realIndex);
|
|
189
189
|
onChange === null || onChange === void 0 ? void 0 : onChange(realIndex);
|
|
190
190
|
}, [onChange]);
|
|
191
|
-
var handleAutoplayStop = React.useCallback(function () {
|
|
192
|
-
setAutoPlaying(false);
|
|
193
|
-
}, []);
|
|
194
|
-
var handleAutoPlayStart = React.useCallback(function () {
|
|
195
|
-
setAutoPlaying(true);
|
|
196
|
-
}, []);
|
|
197
191
|
React.useEffect(function () {
|
|
198
192
|
var rootElement = rootRef.current;
|
|
199
193
|
|
|
@@ -203,9 +197,11 @@ var Banner = function Banner(_ref) {
|
|
|
203
197
|
|
|
204
198
|
rootElement === null || rootElement === void 0 ? void 0 : rootElement.addEventListener('mouseenter', function () {
|
|
205
199
|
swiperInstance === null || swiperInstance === void 0 ? void 0 : swiperInstance.autoplay.stop();
|
|
200
|
+
setAutoPlaying(false);
|
|
206
201
|
});
|
|
207
202
|
rootElement === null || rootElement === void 0 ? void 0 : rootElement.addEventListener('mouseleave', function () {
|
|
208
203
|
swiperInstance === null || swiperInstance === void 0 ? void 0 : swiperInstance.autoplay.start();
|
|
204
|
+
setAutoPlaying(true);
|
|
209
205
|
});
|
|
210
206
|
}, [autoPlay, pauseOnHover, swiperInstance === null || swiperInstance === void 0 ? void 0 : swiperInstance.autoplay]);
|
|
211
207
|
return /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
|
|
@@ -223,8 +219,6 @@ var Banner = function Banner(_ref) {
|
|
|
223
219
|
onReachEnd: handleReachEnd,
|
|
224
220
|
onFromEdge: handleFromEdge,
|
|
225
221
|
onSlideChange: handleSlideChange,
|
|
226
|
-
onAutoplayStop: handleAutoplayStop,
|
|
227
|
-
onAutoplayStart: handleAutoPlayStart,
|
|
228
222
|
onTouchEnd: increaseAutoplayDelay
|
|
229
223
|
}), React.Children.map(children, function (child, i) {
|
|
230
224
|
return /*#__PURE__*/React.createElement(_react2.SwiperSlide, (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.slide, i + 1), {
|
|
@@ -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
|
}
|
|
@@ -107,6 +107,8 @@ var Button = function Button(_ref) {
|
|
|
107
107
|
icon = _ref.icon,
|
|
108
108
|
disabled = _ref.disabled,
|
|
109
109
|
children = _ref.children,
|
|
110
|
+
_ref$ellipsis = _ref.ellipsis,
|
|
111
|
+
ellipsis = _ref$ellipsis === void 0 ? false : _ref$ellipsis,
|
|
110
112
|
onClick = _ref.onClick,
|
|
111
113
|
dataAttrs = _ref.dataAttrs,
|
|
112
114
|
buttonRef = _ref.buttonRef;
|
|
@@ -154,15 +156,19 @@ var Button = function Button(_ref) {
|
|
|
154
156
|
}
|
|
155
157
|
|
|
156
158
|
return /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.content), {
|
|
157
|
-
className: cn('content',
|
|
159
|
+
className: cn('content', {
|
|
160
|
+
ellipsis: ellipsis
|
|
161
|
+
}, contentClassName)
|
|
158
162
|
}), icon && /*#__PURE__*/_react["default"].createElement("div", {
|
|
159
163
|
className: cn('icon')
|
|
160
164
|
}, icon), children && /*#__PURE__*/_react["default"].createElement("span", {
|
|
161
|
-
className: cn('text'
|
|
165
|
+
className: cn('text', {
|
|
166
|
+
ellipsis: ellipsis
|
|
167
|
+
})
|
|
162
168
|
}, children), !icon && showArrow && /*#__PURE__*/_react["default"].createElement(Arrow, {
|
|
163
169
|
className: cn('icon-arrow')
|
|
164
170
|
}));
|
|
165
|
-
}, [children, icon, dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.content, contentClassName, showArrow]);
|
|
171
|
+
}, [children, icon, dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.content, contentClassName, showArrow, ellipsis]);
|
|
166
172
|
|
|
167
173
|
var contentType = _react["default"].useMemo(function () {
|
|
168
174
|
switch (true) {
|
|
@@ -273,6 +279,7 @@ Button.propTypes = {
|
|
|
273
279
|
buttonRef: _propTypes["default"].oneOfType([_propTypes["default"].func, _propTypes["default"].oneOfType([_propTypes["default"].shape({
|
|
274
280
|
current: _propTypes["default"].elementType
|
|
275
281
|
}), _propTypes["default"].any])]),
|
|
282
|
+
ellipsis: _propTypes["default"].bool,
|
|
276
283
|
onClick: _propTypes["default"].func
|
|
277
284
|
};
|
|
278
285
|
var _default = Button;
|