@megafon/ui-core 5.17.0 → 5.18.1
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 +22 -0
- package/dist/es/components/Banner/Banner.js +11 -10
- package/dist/es/components/ContentView/ContentView.d.ts +1 -0
- package/dist/es/components/ContentView/ContentView.js +9 -3
- package/dist/lib/components/Banner/Banner.js +11 -10
- package/dist/lib/components/ContentView/ContentView.d.ts +1 -0
- package/dist/lib/components/ContentView/ContentView.js +8 -2
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
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
|
+
## [5.18.1](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/compare/@megafon/ui-core@5.18.0...@megafon/ui-core@5.18.1) (2024-07-17)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **banner:** disable autoplay for single slide ([7f8780b](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/commit/7f8780b806c165a91aae63a051af299736ddd667))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [5.18.0](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/compare/@megafon/ui-core@5.17.0...@megafon/ui-core@5.18.0) (2024-07-08)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* **contentview:** add props to ContentView component ([ffa2dcc](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/commit/ffa2dcc51305f96190aa65157733a3b624e462ac))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
6
28
|
# [5.17.0](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/compare/@megafon/ui-core@5.16.0...@megafon/ui-core@5.17.0) (2024-07-01)
|
|
7
29
|
|
|
8
30
|
|
|
@@ -73,6 +73,8 @@ var Banner = function Banner(_ref) {
|
|
|
73
73
|
onPrevClick = _ref.onPrevClick,
|
|
74
74
|
onDotClick = _ref.onDotClick,
|
|
75
75
|
onChange = _ref.onChange;
|
|
76
|
+
var isSingleSlide = React.Children.count(children) === 1;
|
|
77
|
+
var canAutoPlay = autoPlay && !isSingleSlide;
|
|
76
78
|
|
|
77
79
|
var _React$useState = React.useState(false),
|
|
78
80
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
@@ -94,7 +96,7 @@ var Banner = function Banner(_ref) {
|
|
|
94
96
|
isEnd = _React$useState8[0],
|
|
95
97
|
setEnd = _React$useState8[1];
|
|
96
98
|
|
|
97
|
-
var _React$useState9 = React.useState(
|
|
99
|
+
var _React$useState9 = React.useState(canAutoPlay),
|
|
98
100
|
_React$useState10 = _slicedToArray(_React$useState9, 2),
|
|
99
101
|
isAutoPlaying = _React$useState10[0],
|
|
100
102
|
setAutoPlaying = _React$useState10[1];
|
|
@@ -114,7 +116,6 @@ var Banner = function Banner(_ref) {
|
|
|
114
116
|
isIncreasedDelay = _React$useState16[0],
|
|
115
117
|
setIsIncreasedDelay = _React$useState16[1];
|
|
116
118
|
|
|
117
|
-
var isSingleSlide = React.Children.count(children) === 1;
|
|
118
119
|
var showDotTimer = loop ? isAutoPlaying : isAutoPlaying && !isEnd;
|
|
119
120
|
var dotTimerDelay = delay / 1000;
|
|
120
121
|
var rootRef = React.useRef(null);
|
|
@@ -122,7 +123,7 @@ var Banner = function Banner(_ref) {
|
|
|
122
123
|
var params = _ref2.params,
|
|
123
124
|
autoplay = _ref2.autoplay;
|
|
124
125
|
|
|
125
|
-
if (_typeof(params.autoplay) !== 'object' || !
|
|
126
|
+
if (_typeof(params.autoplay) !== 'object' || !canAutoPlay || noIncreaseAutoplayDelay) {
|
|
126
127
|
return;
|
|
127
128
|
}
|
|
128
129
|
|
|
@@ -132,7 +133,7 @@ var Banner = function Banner(_ref) {
|
|
|
132
133
|
setDelay(autoPlayDelay * 3);
|
|
133
134
|
setIsIncreasedDelay(true);
|
|
134
135
|
autoplay.start();
|
|
135
|
-
}, [
|
|
136
|
+
}, [canAutoPlay, autoPlayDelay, noIncreaseAutoplayDelay]);
|
|
136
137
|
var handlePrevClick = React.useCallback(function () {
|
|
137
138
|
if (!swiperInstance) {
|
|
138
139
|
return;
|
|
@@ -196,7 +197,7 @@ var Banner = function Banner(_ref) {
|
|
|
196
197
|
React.useEffect(function () {
|
|
197
198
|
var rootElement = rootRef.current;
|
|
198
199
|
|
|
199
|
-
if (!pauseOnHover || !
|
|
200
|
+
if (!pauseOnHover || !canAutoPlay) {
|
|
200
201
|
return;
|
|
201
202
|
}
|
|
202
203
|
|
|
@@ -208,17 +209,17 @@ var Banner = function Banner(_ref) {
|
|
|
208
209
|
swiperInstance === null || swiperInstance === void 0 ? void 0 : swiperInstance.autoplay.start();
|
|
209
210
|
setAutoPlaying(true);
|
|
210
211
|
});
|
|
211
|
-
}, [
|
|
212
|
+
}, [canAutoPlay, pauseOnHover, swiperInstance === null || swiperInstance === void 0 ? void 0 : swiperInstance.autoplay]);
|
|
212
213
|
React.useEffect(function () {
|
|
213
|
-
setAutoPlaying(
|
|
214
|
+
setAutoPlaying(canAutoPlay);
|
|
214
215
|
|
|
215
|
-
if (
|
|
216
|
+
if (canAutoPlay) {
|
|
216
217
|
swiperInstance === null || swiperInstance === void 0 ? void 0 : swiperInstance.autoplay.start();
|
|
217
218
|
return;
|
|
218
219
|
}
|
|
219
220
|
|
|
220
221
|
swiperInstance === null || swiperInstance === void 0 ? void 0 : swiperInstance.autoplay.stop();
|
|
221
|
-
}, [
|
|
222
|
+
}, [canAutoPlay, swiperInstance === null || swiperInstance === void 0 ? void 0 : swiperInstance.autoplay]);
|
|
222
223
|
var renderNavArrows = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(NavArrow, {
|
|
223
224
|
className: cn('arrow', {
|
|
224
225
|
prev: true,
|
|
@@ -275,7 +276,7 @@ var Banner = function Banner(_ref) {
|
|
|
275
276
|
}, /*#__PURE__*/React.createElement(Swiper, _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.swiper), {
|
|
276
277
|
className: cn('swiper', [classes.swiper]),
|
|
277
278
|
loop: loop,
|
|
278
|
-
autoplay:
|
|
279
|
+
autoplay: canAutoPlay ? getAutoPlayConfig(autoPlayDelay) : false,
|
|
279
280
|
watchSlidesVisibility: true,
|
|
280
281
|
noSwipingClass: classes.noSwiping,
|
|
281
282
|
breakpoints: showNextSlide ? SLIDES_SETTINGS : undefined,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import "core-js/modules/es.string.link.js";
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import { cnCreate, filterDataAttrs } from '@megafon/ui-helpers';
|
|
4
|
+
import { cnCreate, convert, filterDataAttrs, titleConvertConfig } from '@megafon/ui-helpers';
|
|
5
5
|
import * as PropTypes from 'prop-types';
|
|
6
6
|
import Button from "../Button/Button";
|
|
7
7
|
import "./ContentView.css";
|
|
@@ -31,14 +31,14 @@ var ContentView = function ContentView(_ref) {
|
|
|
31
31
|
}, !!type && /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.bgImage), {
|
|
32
32
|
className: cn('bg-image', {
|
|
33
33
|
type: type
|
|
34
|
-
})
|
|
34
|
+
}, [classes.bgImage])
|
|
35
35
|
})), !!src && !type && /*#__PURE__*/React.createElement("img", {
|
|
36
36
|
className: cn('image'),
|
|
37
37
|
src: src,
|
|
38
38
|
alt: alt
|
|
39
39
|
}), /*#__PURE__*/React.createElement("div", {
|
|
40
40
|
className: cn('title', [classes.title])
|
|
41
|
-
}, title), !!children && /*#__PURE__*/React.createElement("div", {
|
|
41
|
+
}, convert(title, titleConvertConfig)), !!children && /*#__PURE__*/React.createElement("div", {
|
|
42
42
|
className: cn('text')
|
|
43
43
|
}, children)), showButtons && /*#__PURE__*/React.createElement("div", {
|
|
44
44
|
className: cn('buttons')
|
|
@@ -68,6 +68,12 @@ var ContentView = function ContentView(_ref) {
|
|
|
68
68
|
|
|
69
69
|
ContentView.propTypes = {
|
|
70
70
|
className: PropTypes.string,
|
|
71
|
+
classes: PropTypes.shape({
|
|
72
|
+
title: PropTypes.string,
|
|
73
|
+
button: PropTypes.string,
|
|
74
|
+
link: PropTypes.string,
|
|
75
|
+
bgImage: PropTypes.string
|
|
76
|
+
}),
|
|
71
77
|
title: PropTypes.string.isRequired,
|
|
72
78
|
type: PropTypes.oneOf(['waiting', 'error', 'submit', 'success', 'fail', 'update', 'alarm', 'empty', 'searchNoResult']),
|
|
73
79
|
alt: PropTypes.string,
|
|
@@ -104,6 +104,8 @@ var Banner = function Banner(_ref) {
|
|
|
104
104
|
onPrevClick = _ref.onPrevClick,
|
|
105
105
|
onDotClick = _ref.onDotClick,
|
|
106
106
|
onChange = _ref.onChange;
|
|
107
|
+
var isSingleSlide = React.Children.count(children) === 1;
|
|
108
|
+
var canAutoPlay = autoPlay && !isSingleSlide;
|
|
107
109
|
|
|
108
110
|
var _React$useState = React.useState(false),
|
|
109
111
|
_React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2),
|
|
@@ -125,7 +127,7 @@ var Banner = function Banner(_ref) {
|
|
|
125
127
|
isEnd = _React$useState8[0],
|
|
126
128
|
setEnd = _React$useState8[1];
|
|
127
129
|
|
|
128
|
-
var _React$useState9 = React.useState(
|
|
130
|
+
var _React$useState9 = React.useState(canAutoPlay),
|
|
129
131
|
_React$useState10 = (0, _slicedToArray2["default"])(_React$useState9, 2),
|
|
130
132
|
isAutoPlaying = _React$useState10[0],
|
|
131
133
|
setAutoPlaying = _React$useState10[1];
|
|
@@ -145,7 +147,6 @@ var Banner = function Banner(_ref) {
|
|
|
145
147
|
isIncreasedDelay = _React$useState16[0],
|
|
146
148
|
setIsIncreasedDelay = _React$useState16[1];
|
|
147
149
|
|
|
148
|
-
var isSingleSlide = React.Children.count(children) === 1;
|
|
149
150
|
var showDotTimer = loop ? isAutoPlaying : isAutoPlaying && !isEnd;
|
|
150
151
|
var dotTimerDelay = delay / 1000;
|
|
151
152
|
var rootRef = React.useRef(null);
|
|
@@ -153,7 +154,7 @@ var Banner = function Banner(_ref) {
|
|
|
153
154
|
var params = _ref2.params,
|
|
154
155
|
autoplay = _ref2.autoplay;
|
|
155
156
|
|
|
156
|
-
if ((0, _typeof2["default"])(params.autoplay) !== 'object' || !
|
|
157
|
+
if ((0, _typeof2["default"])(params.autoplay) !== 'object' || !canAutoPlay || noIncreaseAutoplayDelay) {
|
|
157
158
|
return;
|
|
158
159
|
}
|
|
159
160
|
|
|
@@ -163,7 +164,7 @@ var Banner = function Banner(_ref) {
|
|
|
163
164
|
setDelay(autoPlayDelay * 3);
|
|
164
165
|
setIsIncreasedDelay(true);
|
|
165
166
|
autoplay.start();
|
|
166
|
-
}, [
|
|
167
|
+
}, [canAutoPlay, autoPlayDelay, noIncreaseAutoplayDelay]);
|
|
167
168
|
var handlePrevClick = React.useCallback(function () {
|
|
168
169
|
if (!swiperInstance) {
|
|
169
170
|
return;
|
|
@@ -227,7 +228,7 @@ var Banner = function Banner(_ref) {
|
|
|
227
228
|
React.useEffect(function () {
|
|
228
229
|
var rootElement = rootRef.current;
|
|
229
230
|
|
|
230
|
-
if (!pauseOnHover || !
|
|
231
|
+
if (!pauseOnHover || !canAutoPlay) {
|
|
231
232
|
return;
|
|
232
233
|
}
|
|
233
234
|
|
|
@@ -239,17 +240,17 @@ var Banner = function Banner(_ref) {
|
|
|
239
240
|
swiperInstance === null || swiperInstance === void 0 ? void 0 : swiperInstance.autoplay.start();
|
|
240
241
|
setAutoPlaying(true);
|
|
241
242
|
});
|
|
242
|
-
}, [
|
|
243
|
+
}, [canAutoPlay, pauseOnHover, swiperInstance === null || swiperInstance === void 0 ? void 0 : swiperInstance.autoplay]);
|
|
243
244
|
React.useEffect(function () {
|
|
244
|
-
setAutoPlaying(
|
|
245
|
+
setAutoPlaying(canAutoPlay);
|
|
245
246
|
|
|
246
|
-
if (
|
|
247
|
+
if (canAutoPlay) {
|
|
247
248
|
swiperInstance === null || swiperInstance === void 0 ? void 0 : swiperInstance.autoplay.start();
|
|
248
249
|
return;
|
|
249
250
|
}
|
|
250
251
|
|
|
251
252
|
swiperInstance === null || swiperInstance === void 0 ? void 0 : swiperInstance.autoplay.stop();
|
|
252
|
-
}, [
|
|
253
|
+
}, [canAutoPlay, swiperInstance === null || swiperInstance === void 0 ? void 0 : swiperInstance.autoplay]);
|
|
253
254
|
var renderNavArrows = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_NavArrow["default"], {
|
|
254
255
|
className: cn('arrow', {
|
|
255
256
|
prev: true,
|
|
@@ -306,7 +307,7 @@ var Banner = function Banner(_ref) {
|
|
|
306
307
|
}, /*#__PURE__*/React.createElement(_react2.Swiper, (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.swiper), {
|
|
307
308
|
className: cn('swiper', [classes.swiper]),
|
|
308
309
|
loop: loop,
|
|
309
|
-
autoplay:
|
|
310
|
+
autoplay: canAutoPlay ? getAutoPlayConfig(autoPlayDelay) : false,
|
|
310
311
|
watchSlidesVisibility: true,
|
|
311
312
|
noSwipingClass: classes.noSwiping,
|
|
312
313
|
breakpoints: showNextSlide ? _slidesSettings["default"] : undefined,
|
|
@@ -51,14 +51,14 @@ var ContentView = function ContentView(_ref) {
|
|
|
51
51
|
}, !!type && /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.bgImage), {
|
|
52
52
|
className: cn('bg-image', {
|
|
53
53
|
type: type
|
|
54
|
-
})
|
|
54
|
+
}, [classes.bgImage])
|
|
55
55
|
})), !!src && !type && /*#__PURE__*/React.createElement("img", {
|
|
56
56
|
className: cn('image'),
|
|
57
57
|
src: src,
|
|
58
58
|
alt: alt
|
|
59
59
|
}), /*#__PURE__*/React.createElement("div", {
|
|
60
60
|
className: cn('title', [classes.title])
|
|
61
|
-
}, title), !!children && /*#__PURE__*/React.createElement("div", {
|
|
61
|
+
}, (0, _uiHelpers.convert)(title, _uiHelpers.titleConvertConfig)), !!children && /*#__PURE__*/React.createElement("div", {
|
|
62
62
|
className: cn('text')
|
|
63
63
|
}, children)), showButtons && /*#__PURE__*/React.createElement("div", {
|
|
64
64
|
className: cn('buttons')
|
|
@@ -88,6 +88,12 @@ var ContentView = function ContentView(_ref) {
|
|
|
88
88
|
|
|
89
89
|
ContentView.propTypes = {
|
|
90
90
|
className: PropTypes.string,
|
|
91
|
+
classes: PropTypes.shape({
|
|
92
|
+
title: PropTypes.string,
|
|
93
|
+
button: PropTypes.string,
|
|
94
|
+
link: PropTypes.string,
|
|
95
|
+
bgImage: PropTypes.string
|
|
96
|
+
}),
|
|
91
97
|
title: PropTypes.string.isRequired,
|
|
92
98
|
type: PropTypes.oneOf(['waiting', 'error', 'submit', 'success', 'fail', 'update', 'alarm', 'empty', 'searchNoResult']),
|
|
93
99
|
alt: PropTypes.string,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@megafon/ui-core",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.18.1",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist",
|
|
6
6
|
"styles"
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@babel/preset-env": "^7.8.6",
|
|
51
51
|
"@babel/preset-react": "^7.8.3",
|
|
52
52
|
"@babel/preset-typescript": "^7.8.3",
|
|
53
|
-
"@megafon/ui-icons": "^2.
|
|
53
|
+
"@megafon/ui-icons": "^2.26.0",
|
|
54
54
|
"@svgr/core": "^2.4.1",
|
|
55
55
|
"@testing-library/jest-dom": "5.16.2",
|
|
56
56
|
"@testing-library/react": "12.1.2",
|
|
@@ -99,5 +99,5 @@
|
|
|
99
99
|
"react-popper": "^2.2.3",
|
|
100
100
|
"swiper": "^6.5.6"
|
|
101
101
|
},
|
|
102
|
-
"gitHead": "
|
|
102
|
+
"gitHead": "e39d4dae5d51999d67300d83f502e1d20293798f"
|
|
103
103
|
}
|