@megafon/ui-core 4.11.4 → 4.13.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 +22 -0
- package/dist/es/components/Carousel/Carousel.css +52 -13
- package/dist/es/components/Carousel/Carousel.d.ts +6 -1
- package/dist/es/components/Carousel/Carousel.js +21 -6
- package/dist/es/components/Carousel/useGradient.d.ts +18 -0
- package/dist/es/components/Carousel/useGradient.js +52 -0
- package/dist/es/components/NavArrow/NavArrow.css +11 -2
- package/dist/es/components/Search/Search.d.ts +3 -0
- package/dist/es/components/Search/Search.js +10 -7
- package/dist/es/components/Select/Select.d.ts +16 -0
- package/dist/es/components/Select/Select.js +12 -7
- package/dist/es/components/Switcher/Switcher.d.ts +2 -1
- package/dist/es/components/Switcher/Switcher.js +4 -3
- package/dist/es/components/Tabs/Tab.d.ts +2 -0
- package/dist/es/components/Tabs/Tab.js +1 -0
- package/dist/es/components/Tabs/Tabs.js +15 -2
- package/dist/es/components/TextField/TextField.d.ts +1 -0
- package/dist/es/components/TextField/TextField.js +4 -3
- package/dist/es/index.d.ts +1 -0
- package/dist/es/index.js +1 -0
- package/dist/lib/components/Carousel/Carousel.css +52 -13
- package/dist/lib/components/Carousel/Carousel.d.ts +6 -1
- package/dist/lib/components/Carousel/Carousel.js +53 -27
- package/dist/lib/components/Carousel/useGradient.d.ts +18 -0
- package/dist/lib/components/Carousel/useGradient.js +69 -0
- package/dist/lib/components/NavArrow/NavArrow.css +11 -2
- package/dist/lib/components/Search/Search.d.ts +3 -0
- package/dist/lib/components/Search/Search.js +10 -7
- package/dist/lib/components/Select/Select.d.ts +16 -0
- package/dist/lib/components/Select/Select.js +12 -7
- package/dist/lib/components/Switcher/Switcher.d.ts +2 -1
- package/dist/lib/components/Switcher/Switcher.js +4 -3
- package/dist/lib/components/Tabs/Tab.d.ts +2 -0
- package/dist/lib/components/Tabs/Tab.js +1 -0
- package/dist/lib/components/Tabs/Tabs.js +15 -2
- package/dist/lib/components/TextField/TextField.d.ts +1 -0
- package/dist/lib/components/TextField/TextField.js +4 -3
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.js +8 -0
- package/package.json +3 -3
|
@@ -44,6 +44,49 @@
|
|
|
44
44
|
padding-left: 16px;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
+
.mfui-carousel__swiper_gradient:before,
|
|
48
|
+
.mfui-carousel__swiper_gradient:after {
|
|
49
|
+
content: '';
|
|
50
|
+
position: absolute;
|
|
51
|
+
top: 0;
|
|
52
|
+
z-index: 5;
|
|
53
|
+
width: var(--gap);
|
|
54
|
+
height: 85%;
|
|
55
|
+
}
|
|
56
|
+
@media screen and (max-width: 1023px) {
|
|
57
|
+
.mfui-carousel__swiper_gradient:before,
|
|
58
|
+
.mfui-carousel__swiper_gradient:after {
|
|
59
|
+
display: none;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
.mfui-carousel__swiper_gradient:before {
|
|
63
|
+
left: 0;
|
|
64
|
+
background: -webkit-gradient(linear, right top, left top, from(transparent), to(var(--gradientColor)));
|
|
65
|
+
background: linear-gradient(270deg, transparent 0%, var(--gradientColor) 100%);
|
|
66
|
+
}
|
|
67
|
+
.mfui-carousel__swiper_gradient:after {
|
|
68
|
+
right: 0;
|
|
69
|
+
background: -webkit-gradient(linear, right top, left top, from(var(--gradientColor)), to(transparent));
|
|
70
|
+
background: linear-gradient(270deg, var(--gradientColor) 0%, transparent 100%);
|
|
71
|
+
}
|
|
72
|
+
.mfui-carousel__swiper_gradient-color_default {
|
|
73
|
+
--gradientColor: var(--base);
|
|
74
|
+
}
|
|
75
|
+
.mfui-carousel__swiper_gradient-color_green {
|
|
76
|
+
--gradientColor: var(--brandGreen);
|
|
77
|
+
}
|
|
78
|
+
.mfui-carousel__swiper_gradient-color_black {
|
|
79
|
+
--gradientColor: var(--stcBlack);
|
|
80
|
+
}
|
|
81
|
+
.mfui-carousel__swiper_gradient-color_spbSky0 {
|
|
82
|
+
--gradientColor: var(--spbSky0);
|
|
83
|
+
}
|
|
84
|
+
.mfui-carousel__swiper_gradient-color_spbSky1 {
|
|
85
|
+
--gradientColor: var(--spbSky1);
|
|
86
|
+
}
|
|
87
|
+
.mfui-carousel__swiper_gradient-color_spbSky2 {
|
|
88
|
+
--gradientColor: var(--spbSky2);
|
|
89
|
+
}
|
|
47
90
|
.mfui-carousel .swiper-wrapper {
|
|
48
91
|
z-index: 1;
|
|
49
92
|
display: -webkit-box;
|
|
@@ -105,6 +148,7 @@
|
|
|
105
148
|
display: -webkit-box;
|
|
106
149
|
display: -ms-flexbox;
|
|
107
150
|
display: flex;
|
|
151
|
+
gap: 12px;
|
|
108
152
|
-webkit-box-align: center;
|
|
109
153
|
-ms-flex-align: center;
|
|
110
154
|
align-items: center;
|
|
@@ -136,9 +180,10 @@
|
|
|
136
180
|
box-sizing: border-box;
|
|
137
181
|
width: 8px;
|
|
138
182
|
height: 8px;
|
|
139
|
-
padding: 1px;
|
|
140
183
|
border-radius: 50%;
|
|
141
184
|
cursor: pointer;
|
|
185
|
+
-webkit-transition: width 0.5s, background-color 0.3s;
|
|
186
|
+
transition: width 0.5s, background-color 0.3s;
|
|
142
187
|
}
|
|
143
188
|
.mfui-carousel .swiper-pagination-bullet:before {
|
|
144
189
|
content: '';
|
|
@@ -146,9 +191,8 @@
|
|
|
146
191
|
width: 100%;
|
|
147
192
|
height: 100%;
|
|
148
193
|
border-radius: 50%;
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
margin-right: 8px;
|
|
194
|
+
-webkit-transition: border-radius 0.5s;
|
|
195
|
+
transition: border-radius 0.5s;
|
|
152
196
|
}
|
|
153
197
|
.mfui-carousel_nav-theme_green .swiper-pagination-bullet:before {
|
|
154
198
|
background-color: var(--stcWhite50);
|
|
@@ -157,20 +201,15 @@
|
|
|
157
201
|
background-color: var(--spbSky2);
|
|
158
202
|
}
|
|
159
203
|
.mfui-carousel .swiper-pagination-bullet-active {
|
|
160
|
-
|
|
204
|
+
width: 20px;
|
|
161
205
|
cursor: default;
|
|
162
206
|
}
|
|
163
|
-
.mfui-
|
|
164
|
-
|
|
165
|
-
cursor: default;
|
|
207
|
+
.mfui-carousel .swiper-pagination-bullet-active:before {
|
|
208
|
+
border-radius: 4px;
|
|
166
209
|
}
|
|
167
210
|
.mfui-carousel_nav-theme_green .swiper-pagination-bullet-active:before {
|
|
168
211
|
background-color: var(--base);
|
|
169
212
|
}
|
|
170
|
-
.mfui-carousel_nav-theme_light .swiper-pagination-bullet-active {
|
|
171
|
-
padding: 0;
|
|
172
|
-
cursor: default;
|
|
173
|
-
}
|
|
174
213
|
.mfui-carousel_nav-theme_light .swiper-pagination-bullet-active:before {
|
|
175
|
-
background-color: var(--
|
|
214
|
+
background-color: var(--brandGreen);
|
|
176
215
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import SwiperCore from 'swiper';
|
|
3
3
|
import { PaginationOptions } from 'swiper/types/components/pagination';
|
|
4
|
+
import { GradientTheme } from './useGradient';
|
|
4
5
|
import './Carousel.less';
|
|
5
6
|
export declare const NavTheme: {
|
|
6
7
|
readonly LIGHT: "light";
|
|
@@ -82,6 +83,10 @@ export interface ICarouselProps {
|
|
|
82
83
|
onPrevClick?: (index: number) => void;
|
|
83
84
|
/** Обработчик смены слайда (должен быть обернут в useCallback) */
|
|
84
85
|
onChange?: (currentIndex: number, previousIndex: number, slidesPerView?: number | 'auto') => void;
|
|
86
|
+
/** Наличие градиента по краям контейнера */
|
|
87
|
+
gradient?: boolean;
|
|
88
|
+
/** Цвет градиента */
|
|
89
|
+
gradientColor?: GradientTheme;
|
|
85
90
|
}
|
|
86
91
|
declare const Carousel: React.FC<ICarouselProps>;
|
|
87
92
|
export default Carousel;
|
|
@@ -23,7 +23,7 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
23
23
|
|
|
24
24
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
25
25
|
|
|
26
|
-
var
|
|
26
|
+
var _react = _interopRequireDefault(require("react"));
|
|
27
27
|
|
|
28
28
|
var _uiHelpers = require("@megafon/ui-helpers");
|
|
29
29
|
|
|
@@ -43,6 +43,8 @@ var _usePrevious = _interopRequireDefault(require("../../hooks/usePrevious"));
|
|
|
43
43
|
|
|
44
44
|
var _checkBreakpointsPropTypes = _interopRequireDefault(require("./checkBreakpointsPropTypes"));
|
|
45
45
|
|
|
46
|
+
var _useGradient = _interopRequireWildcard(require("./useGradient"));
|
|
47
|
+
|
|
46
48
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
47
49
|
|
|
48
50
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -130,24 +132,28 @@ var Carousel = function Carousel(_ref) {
|
|
|
130
132
|
onPrevClick = _ref.onPrevClick,
|
|
131
133
|
onChange = _ref.onChange,
|
|
132
134
|
_ref$slideToClickedSl = _ref.slideToClickedSlide,
|
|
133
|
-
slideToClickedSlide = _ref$slideToClickedSl === void 0 ? false : _ref$slideToClickedSl
|
|
135
|
+
slideToClickedSlide = _ref$slideToClickedSl === void 0 ? false : _ref$slideToClickedSl,
|
|
136
|
+
_ref$gradient = _ref.gradient,
|
|
137
|
+
gradient = _ref$gradient === void 0 ? false : _ref$gradient,
|
|
138
|
+
_ref$gradientColor = _ref.gradientColor,
|
|
139
|
+
gradientColor = _ref$gradientColor === void 0 ? _useGradient.GradientTheme.DEFAULT : _ref$gradientColor;
|
|
134
140
|
|
|
135
|
-
var _React$useState =
|
|
141
|
+
var _React$useState = _react["default"].useState(),
|
|
136
142
|
_React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2),
|
|
137
143
|
swiperInstance = _React$useState2[0],
|
|
138
144
|
setSwiperInstance = _React$useState2[1];
|
|
139
145
|
|
|
140
|
-
var _React$useState3 =
|
|
146
|
+
var _React$useState3 = _react["default"].useState(true),
|
|
141
147
|
_React$useState4 = (0, _slicedToArray2["default"])(_React$useState3, 2),
|
|
142
148
|
isBeginning = _React$useState4[0],
|
|
143
149
|
setBeginning = _React$useState4[1];
|
|
144
150
|
|
|
145
|
-
var _React$useState5 =
|
|
151
|
+
var _React$useState5 = _react["default"].useState(false),
|
|
146
152
|
_React$useState6 = (0, _slicedToArray2["default"])(_React$useState5, 2),
|
|
147
153
|
isEnd = _React$useState6[0],
|
|
148
154
|
setEnd = _React$useState6[1];
|
|
149
155
|
|
|
150
|
-
var _React$useState7 =
|
|
156
|
+
var _React$useState7 = _react["default"].useState(false),
|
|
151
157
|
_React$useState8 = (0, _slicedToArray2["default"])(_React$useState7, 2),
|
|
152
158
|
isLocked = _React$useState8[0],
|
|
153
159
|
setLocked = _React$useState8[1];
|
|
@@ -155,7 +161,13 @@ var Carousel = function Carousel(_ref) {
|
|
|
155
161
|
var childrenLen = Array.isArray(children) ? children.length : 0;
|
|
156
162
|
var prevChildrenLen = (0, _usePrevious["default"])(childrenLen) || 0;
|
|
157
163
|
var isChildrenLenDiff = childrenLen !== prevChildrenLen;
|
|
158
|
-
var
|
|
164
|
+
var gradientStyles = (0, _useGradient["default"])(gradient, {
|
|
165
|
+
instance: swiperInstance,
|
|
166
|
+
slidesSettings: slidesSettings,
|
|
167
|
+
isLocked: isLocked
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
var increaseAutoplayDelay = _react["default"].useCallback(function (_ref2) {
|
|
159
171
|
var params = _ref2.params,
|
|
160
172
|
autoplay = _ref2.autoplay;
|
|
161
173
|
|
|
@@ -168,7 +180,8 @@ var Carousel = function Carousel(_ref) {
|
|
|
168
180
|
params.autoplay.delay = autoPlayDelay * 3;
|
|
169
181
|
autoplay.start();
|
|
170
182
|
}, [autoPlayDelay]);
|
|
171
|
-
|
|
183
|
+
|
|
184
|
+
var handlePrevClick = _react["default"].useCallback(function () {
|
|
172
185
|
if (!swiperInstance) {
|
|
173
186
|
return;
|
|
174
187
|
}
|
|
@@ -177,7 +190,8 @@ var Carousel = function Carousel(_ref) {
|
|
|
177
190
|
onPrevClick === null || onPrevClick === void 0 ? void 0 : onPrevClick(swiperInstance.realIndex);
|
|
178
191
|
increaseAutoplayDelay(swiperInstance);
|
|
179
192
|
}, [swiperInstance, onPrevClick, increaseAutoplayDelay]);
|
|
180
|
-
|
|
193
|
+
|
|
194
|
+
var handleNextClick = _react["default"].useCallback(function () {
|
|
181
195
|
if (!swiperInstance) {
|
|
182
196
|
return;
|
|
183
197
|
}
|
|
@@ -186,15 +200,18 @@ var Carousel = function Carousel(_ref) {
|
|
|
186
200
|
onNextClick === null || onNextClick === void 0 ? void 0 : onNextClick(swiperInstance.realIndex);
|
|
187
201
|
increaseAutoplayDelay(swiperInstance);
|
|
188
202
|
}, [swiperInstance, onNextClick, increaseAutoplayDelay]);
|
|
189
|
-
|
|
203
|
+
|
|
204
|
+
var handleSwiper = _react["default"].useCallback(function (swiper) {
|
|
190
205
|
setSwiperInstance(swiper);
|
|
191
206
|
setLocked(swiper.isBeginning && swiper.isEnd);
|
|
192
207
|
getSwiper === null || getSwiper === void 0 ? void 0 : getSwiper(swiper);
|
|
193
208
|
}, [getSwiper]);
|
|
194
|
-
|
|
209
|
+
|
|
210
|
+
var handleReachBeginnig = _react["default"].useCallback(function () {
|
|
195
211
|
setBeginning(true);
|
|
196
212
|
}, []);
|
|
197
|
-
|
|
213
|
+
|
|
214
|
+
var handleReachEnd = _react["default"].useCallback(function (_ref3) {
|
|
198
215
|
var params = _ref3.params,
|
|
199
216
|
autoplay = _ref3.autoplay;
|
|
200
217
|
setEnd(true);
|
|
@@ -203,11 +220,13 @@ var Carousel = function Carousel(_ref) {
|
|
|
203
220
|
autoplay.stop();
|
|
204
221
|
}
|
|
205
222
|
}, []);
|
|
206
|
-
|
|
223
|
+
|
|
224
|
+
var handleFromEdge = _react["default"].useCallback(function (swiper) {
|
|
207
225
|
setBeginning(swiper.isBeginning);
|
|
208
226
|
setEnd(swiper.isEnd);
|
|
209
227
|
}, []);
|
|
210
|
-
|
|
228
|
+
|
|
229
|
+
var handleSlideChange = _react["default"].useCallback(function (_ref4) {
|
|
211
230
|
var realIndex = _ref4.realIndex,
|
|
212
231
|
previousIndex = _ref4.previousIndex,
|
|
213
232
|
params = _ref4.params;
|
|
@@ -230,7 +249,7 @@ var Carousel = function Carousel(_ref) {
|
|
|
230
249
|
}; // https://github.com/nolimits4web/Swiper/issues/2346
|
|
231
250
|
|
|
232
251
|
|
|
233
|
-
var handleSwiperResize =
|
|
252
|
+
var handleSwiperResize = _react["default"].useCallback(function () {
|
|
234
253
|
(0, _lodash["default"])(function (swiper) {
|
|
235
254
|
handleNavDisplay(swiper);
|
|
236
255
|
|
|
@@ -263,7 +282,7 @@ var Carousel = function Carousel(_ref) {
|
|
|
263
282
|
}
|
|
264
283
|
};
|
|
265
284
|
|
|
266
|
-
|
|
285
|
+
_react["default"].useEffect(function () {
|
|
267
286
|
if (!swiperInstance) {
|
|
268
287
|
return undefined;
|
|
269
288
|
}
|
|
@@ -277,23 +296,28 @@ var Carousel = function Carousel(_ref) {
|
|
|
277
296
|
return function () {
|
|
278
297
|
window.removeEventListener('resize', windowResizeHandlerThrottled);
|
|
279
298
|
};
|
|
280
|
-
}, [swiperInstance]);
|
|
281
|
-
|
|
299
|
+
}, [slidesSettings, swiperInstance]);
|
|
300
|
+
|
|
301
|
+
_react["default"].useEffect(function () {
|
|
282
302
|
if (swiperInstance && isChildrenLenDiff) {
|
|
283
303
|
handleNavDisplay(swiperInstance);
|
|
284
304
|
}
|
|
285
305
|
}, [isChildrenLenDiff, swiperInstance]);
|
|
286
|
-
|
|
306
|
+
|
|
307
|
+
return /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
|
|
287
308
|
ref: rootRef,
|
|
288
309
|
className: cn({
|
|
289
310
|
'nav-theme': navTheme
|
|
290
311
|
}, [className, rootClass]),
|
|
291
|
-
onClick: handleRootClick
|
|
292
|
-
|
|
312
|
+
onClick: handleRootClick,
|
|
313
|
+
style: gradientStyles
|
|
314
|
+
}), /*#__PURE__*/_react["default"].createElement(_react2.Swiper, (0, _extends2["default"])({}, containerModifier ? {
|
|
293
315
|
containerModifierClass: containerModifier
|
|
294
316
|
} : {}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.slider), {
|
|
295
317
|
className: cn('swiper', {
|
|
296
|
-
'default-inner-indents': !innerIndentsClass
|
|
318
|
+
'default-inner-indents': !innerIndentsClass,
|
|
319
|
+
gradient: gradient,
|
|
320
|
+
'gradient-color': gradient && gradientColor
|
|
297
321
|
}, [innerIndentsClass, containerClass]),
|
|
298
322
|
breakpoints: slidesSettings,
|
|
299
323
|
watchSlidesVisibility: true,
|
|
@@ -321,14 +345,14 @@ var Carousel = function Carousel(_ref) {
|
|
|
321
345
|
onSlideChange: handleSlideChange,
|
|
322
346
|
onTouchEnd: increaseAutoplayDelay,
|
|
323
347
|
onResize: handleSwiperResize
|
|
324
|
-
}),
|
|
325
|
-
return /*#__PURE__*/
|
|
348
|
+
}), _react["default"].Children.map(children, function (child, i) {
|
|
349
|
+
return /*#__PURE__*/_react["default"].createElement(_react2.SwiperSlide, (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.slide, i + 1), {
|
|
326
350
|
key: i,
|
|
327
351
|
className: cn('slide', slideClass),
|
|
328
352
|
onFocus: handleSlideFocus(i),
|
|
329
353
|
onMouseDown: disableFocusOnSlideClick
|
|
330
354
|
}), child);
|
|
331
|
-
})), /*#__PURE__*/
|
|
355
|
+
})), /*#__PURE__*/_react["default"].createElement(_NavArrow["default"], {
|
|
332
356
|
dataAttrs: {
|
|
333
357
|
root: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.prev
|
|
334
358
|
},
|
|
@@ -339,7 +363,7 @@ var Carousel = function Carousel(_ref) {
|
|
|
339
363
|
onClick: handlePrevClick,
|
|
340
364
|
disabled: !loop && isBeginning,
|
|
341
365
|
theme: _NavArrow.Theme.PURPLE
|
|
342
|
-
}), /*#__PURE__*/
|
|
366
|
+
}), /*#__PURE__*/_react["default"].createElement(_NavArrow["default"], {
|
|
343
367
|
dataAttrs: {
|
|
344
368
|
root: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.next
|
|
345
369
|
},
|
|
@@ -403,7 +427,9 @@ Carousel.propTypes = {
|
|
|
403
427
|
getSwiper: PropTypes.func,
|
|
404
428
|
onNextClick: PropTypes.func,
|
|
405
429
|
onPrevClick: PropTypes.func,
|
|
406
|
-
onChange: PropTypes.func
|
|
430
|
+
onChange: PropTypes.func,
|
|
431
|
+
gradient: PropTypes.oneOfType([PropTypes.bool]),
|
|
432
|
+
gradientColor: PropTypes.oneOf(Object.values(_useGradient.GradientTheme))
|
|
407
433
|
};
|
|
408
434
|
var _default = Carousel;
|
|
409
435
|
exports["default"] = _default;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
import SwiperCore from 'swiper';
|
|
3
|
+
import { SlidesSettingsType } from './Carousel';
|
|
4
|
+
declare type SwiperConfig = {
|
|
5
|
+
instance: SwiperCore | undefined;
|
|
6
|
+
slidesSettings: SlidesSettingsType;
|
|
7
|
+
isLocked: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare enum GradientTheme {
|
|
10
|
+
DEFAULT = "default",
|
|
11
|
+
GREEN = "green",
|
|
12
|
+
BLACK = "black",
|
|
13
|
+
SPB_SKY_0 = "spbSky0",
|
|
14
|
+
SPB_SKY_1 = "spbSky1",
|
|
15
|
+
SPB_SKY_2 = "spbSky2"
|
|
16
|
+
}
|
|
17
|
+
declare const _default: (gradient: boolean, swiper: SwiperConfig) => CSSProperties;
|
|
18
|
+
export default _default;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = exports.GradientTheme = void 0;
|
|
7
|
+
|
|
8
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
+
|
|
10
|
+
var _react = require("react");
|
|
11
|
+
|
|
12
|
+
var _uiHelpers = require("@megafon/ui-helpers");
|
|
13
|
+
|
|
14
|
+
var _lodash = _interopRequireDefault(require("lodash.throttle"));
|
|
15
|
+
|
|
16
|
+
var _throttleTime = _interopRequireDefault(require("../../constants/throttleTime"));
|
|
17
|
+
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
|
+
|
|
20
|
+
var GradientTheme;
|
|
21
|
+
exports.GradientTheme = GradientTheme;
|
|
22
|
+
|
|
23
|
+
(function (GradientTheme) {
|
|
24
|
+
GradientTheme["DEFAULT"] = "default";
|
|
25
|
+
GradientTheme["GREEN"] = "green";
|
|
26
|
+
GradientTheme["BLACK"] = "black";
|
|
27
|
+
GradientTheme["SPB_SKY_0"] = "spbSky0";
|
|
28
|
+
GradientTheme["SPB_SKY_1"] = "spbSky1";
|
|
29
|
+
GradientTheme["SPB_SKY_2"] = "spbSky2";
|
|
30
|
+
})(GradientTheme || (exports.GradientTheme = GradientTheme = {}));
|
|
31
|
+
|
|
32
|
+
var _default = function _default(gradient, swiper) {
|
|
33
|
+
var _useState = (0, _react.useState)(0),
|
|
34
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
35
|
+
slidesGap = _useState2[0],
|
|
36
|
+
setSlidesGap = _useState2[1];
|
|
37
|
+
|
|
38
|
+
var swiperInstance = swiper.instance,
|
|
39
|
+
slidesSettings = swiper.slidesSettings,
|
|
40
|
+
isLocked = swiper.isLocked;
|
|
41
|
+
var isGradientEnable = gradient && !isLocked;
|
|
42
|
+
(0, _react.useEffect)(function () {
|
|
43
|
+
var isTouch = window.innerWidth < _uiHelpers.breakpoints.DESKTOP_SMALL_START;
|
|
44
|
+
var isPossibleToSetGap = isGradientEnable && swiperInstance && !isTouch;
|
|
45
|
+
|
|
46
|
+
if (!isPossibleToSetGap) {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
var setCurrenSlidesGap = function setCurrenSlidesGap() {
|
|
51
|
+
var currentBreakpoint = swiperInstance.getBreakpoint(slidesSettings);
|
|
52
|
+
var currentSpaceBetweenValue = slidesSettings[currentBreakpoint].spaceBetween;
|
|
53
|
+
setSlidesGap(currentSpaceBetweenValue);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
setCurrenSlidesGap();
|
|
57
|
+
var throttledHandler = (0, _lodash["default"])(setCurrenSlidesGap, _throttleTime["default"].resize);
|
|
58
|
+
window.addEventListener('resize', throttledHandler);
|
|
59
|
+
return function () {
|
|
60
|
+
window.removeEventListener('resize', throttledHandler);
|
|
61
|
+
};
|
|
62
|
+
}, [gradient, slidesSettings, swiperInstance, isLocked, isGradientEnable]);
|
|
63
|
+
var gradientStyles = {
|
|
64
|
+
'--gap': "".concat(slidesGap, "px")
|
|
65
|
+
};
|
|
66
|
+
return isGradientEnable ? gradientStyles : {};
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
exports["default"] = _default;
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
border-radius: 50%;
|
|
10
10
|
outline: none;
|
|
11
11
|
cursor: pointer;
|
|
12
|
+
-webkit-transition: background-color 0.3s, opacity 0.3s;
|
|
13
|
+
transition: background-color 0.3s, opacity 0.3s;
|
|
12
14
|
-webkit-appearance: none;
|
|
13
15
|
-moz-appearance: none;
|
|
14
16
|
appearance: none;
|
|
@@ -17,6 +19,7 @@
|
|
|
17
19
|
.mfui-nav-arrow:disabled {
|
|
18
20
|
cursor: default;
|
|
19
21
|
opacity: 0.3;
|
|
22
|
+
pointer-events: none;
|
|
20
23
|
}
|
|
21
24
|
.mfui-nav-arrow__icon {
|
|
22
25
|
display: block;
|
|
@@ -27,12 +30,18 @@
|
|
|
27
30
|
.mfui-nav-arrow_theme_purple {
|
|
28
31
|
background-color: var(--brandPurple);
|
|
29
32
|
}
|
|
30
|
-
.mfui-nav-arrow_theme_purple:hover
|
|
33
|
+
.mfui-nav-arrow_theme_purple:hover {
|
|
31
34
|
background-color: var(--buttonHoverPurple);
|
|
32
35
|
}
|
|
36
|
+
.mfui-nav-arrow_theme_purple:active {
|
|
37
|
+
background-color: var(--buttonDown);
|
|
38
|
+
}
|
|
33
39
|
.mfui-nav-arrow_theme_dark {
|
|
34
40
|
background-color: var(--stcBlack20);
|
|
35
41
|
}
|
|
36
|
-
.mfui-nav-arrow_theme_dark:hover
|
|
42
|
+
.mfui-nav-arrow_theme_dark:hover {
|
|
37
43
|
background-color: var(--stcBlack50);
|
|
38
44
|
}
|
|
45
|
+
.mfui-nav-arrow_theme_dark:active {
|
|
46
|
+
background-color: var(--buttonDown);
|
|
47
|
+
}
|
|
@@ -22,9 +22,12 @@ export interface ISearchProps {
|
|
|
22
22
|
/** Дополнительные data атрибуты к внутренним элементам */
|
|
23
23
|
dataAttrs?: {
|
|
24
24
|
root?: Record<string, string>;
|
|
25
|
+
control?: Record<string, string>;
|
|
25
26
|
searchField?: Record<string, string>;
|
|
26
27
|
submit?: Record<string, string>;
|
|
27
28
|
item?: Record<string, string>;
|
|
29
|
+
itemTitle?: Record<string, string>;
|
|
30
|
+
notice?: Record<string, string>;
|
|
28
31
|
};
|
|
29
32
|
/** Значение */
|
|
30
33
|
value?: string;
|
|
@@ -227,12 +227,12 @@ var Search = function Search(_ref) {
|
|
|
227
227
|
open: isFocused,
|
|
228
228
|
disabled: disabled
|
|
229
229
|
}, [className])
|
|
230
|
-
}), /*#__PURE__*/_react["default"].createElement("div", {
|
|
230
|
+
}), /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.control), {
|
|
231
231
|
className: cn('control', {
|
|
232
232
|
error: verification === Verification.ERROR,
|
|
233
233
|
success: verification === Verification.VALID
|
|
234
234
|
}, [classes === null || classes === void 0 ? void 0 : classes.control])
|
|
235
|
-
}, /*#__PURE__*/_react["default"].createElement("label", {
|
|
235
|
+
}), /*#__PURE__*/_react["default"].createElement("label", {
|
|
236
236
|
className: cn('search-wrapper', {
|
|
237
237
|
labeled: !!label,
|
|
238
238
|
'no-label': !label
|
|
@@ -280,23 +280,26 @@ var Search = function Search(_ref) {
|
|
|
280
280
|
onMouseDown: handleSelectSubmit(i),
|
|
281
281
|
onMouseEnter: handleHoverItem(i),
|
|
282
282
|
key: i
|
|
283
|
-
}), /*#__PURE__*/_react["default"].createElement("div", {
|
|
283
|
+
}), /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.itemTitle, i + 1), {
|
|
284
284
|
className: cn('item-title', [classes === null || classes === void 0 ? void 0 : classes.listItemTitle])
|
|
285
|
-
}, searchView || highlightString(itemValue)));
|
|
286
|
-
})))), noticeText && /*#__PURE__*/_react["default"].createElement("div", {
|
|
285
|
+
}), searchView || highlightString(itemValue)));
|
|
286
|
+
})))), noticeText && /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.notice), {
|
|
287
287
|
className: cn('notice', {
|
|
288
288
|
error: verification === Verification.ERROR,
|
|
289
289
|
success: verification === Verification.VALID
|
|
290
290
|
})
|
|
291
|
-
}, noticeText));
|
|
291
|
+
}), noticeText));
|
|
292
292
|
};
|
|
293
293
|
|
|
294
294
|
Search.propTypes = {
|
|
295
295
|
dataAttrs: PropTypes.shape({
|
|
296
296
|
root: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
297
|
+
control: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
297
298
|
searchField: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
298
299
|
submit: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
299
|
-
item: PropTypes.objectOf(PropTypes.string.isRequired)
|
|
300
|
+
item: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
301
|
+
itemTitle: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
302
|
+
notice: PropTypes.objectOf(PropTypes.string.isRequired)
|
|
300
303
|
}),
|
|
301
304
|
value: PropTypes.string,
|
|
302
305
|
label: PropTypes.string,
|
|
@@ -75,9 +75,13 @@ export interface ISelectProps<T extends SelectItemValueType> {
|
|
|
75
75
|
dataAttrs?: {
|
|
76
76
|
root?: Record<string, string>;
|
|
77
77
|
label?: Record<string, string>;
|
|
78
|
+
control?: Record<string, string>;
|
|
78
79
|
title?: Record<string, string>;
|
|
80
|
+
titleInner?: Record<string, string>;
|
|
79
81
|
input?: Record<string, string>;
|
|
80
82
|
noticeText?: Record<string, string>;
|
|
83
|
+
list?: Record<string, string>;
|
|
84
|
+
listInner?: Record<string, string>;
|
|
81
85
|
listItem?: Record<string, string>;
|
|
82
86
|
listItemTitle?: Record<string, string>;
|
|
83
87
|
notFound?: Record<string, string>;
|
|
@@ -120,15 +124,27 @@ declare const Select: {
|
|
|
120
124
|
label: PropTypes.Requireable<{
|
|
121
125
|
[x: string]: string;
|
|
122
126
|
}>;
|
|
127
|
+
control: PropTypes.Requireable<{
|
|
128
|
+
[x: string]: string;
|
|
129
|
+
}>;
|
|
123
130
|
title: PropTypes.Requireable<{
|
|
124
131
|
[x: string]: string;
|
|
125
132
|
}>;
|
|
133
|
+
titleInner: PropTypes.Requireable<{
|
|
134
|
+
[x: string]: string;
|
|
135
|
+
}>;
|
|
126
136
|
input: PropTypes.Requireable<{
|
|
127
137
|
[x: string]: string;
|
|
128
138
|
}>;
|
|
129
139
|
noticeText: PropTypes.Requireable<{
|
|
130
140
|
[x: string]: string;
|
|
131
141
|
}>;
|
|
142
|
+
list: PropTypes.Requireable<{
|
|
143
|
+
[x: string]: string;
|
|
144
|
+
}>;
|
|
145
|
+
listInner: PropTypes.Requireable<{
|
|
146
|
+
[x: string]: string;
|
|
147
|
+
}>;
|
|
132
148
|
listItem: PropTypes.Requireable<{
|
|
133
149
|
[x: string]: string;
|
|
134
150
|
}>;
|
|
@@ -235,6 +235,7 @@ var Select = function Select(_ref) {
|
|
|
235
235
|
comparableInputValue: title,
|
|
236
236
|
items: items
|
|
237
237
|
});
|
|
238
|
+
e.persist();
|
|
238
239
|
onSelect === null || onSelect === void 0 ? void 0 : onSelect(e, item);
|
|
239
240
|
onClosed === null || onClosed === void 0 ? void 0 : onClosed();
|
|
240
241
|
};
|
|
@@ -390,11 +391,11 @@ var Select = function Select(_ref) {
|
|
|
390
391
|
role: "button",
|
|
391
392
|
tabIndex: 0,
|
|
392
393
|
onClick: handleSelectClick
|
|
393
|
-
}), /*#__PURE__*/React.createElement("div", {
|
|
394
|
+
}), /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.titleInner), {
|
|
394
395
|
className: cn('title-inner', {
|
|
395
396
|
'hide-value': !item
|
|
396
397
|
}, [classes === null || classes === void 0 ? void 0 : classes.titleInner])
|
|
397
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
398
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
398
399
|
className: cn('title-value')
|
|
399
400
|
}, inputTitle), label && renderLabel()));
|
|
400
401
|
};
|
|
@@ -414,14 +415,14 @@ var Select = function Select(_ref) {
|
|
|
414
415
|
|
|
415
416
|
var renderChildren = function renderChildren() {
|
|
416
417
|
var currentItems = type === SelectTypes.COMBOBOX ? itemsList : items;
|
|
417
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
418
|
+
return /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.list), {
|
|
418
419
|
className: cn('list', [classes.list])
|
|
419
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
420
|
+
}), /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.listInner), {
|
|
420
421
|
className: cn('list-inner', {
|
|
421
422
|
"short": shortList
|
|
422
423
|
}, [classes.listInner]),
|
|
423
424
|
ref: itemWrapperNode
|
|
424
|
-
}, currentItems.map(function (_ref3, i) {
|
|
425
|
+
}), currentItems.map(function (_ref3, i) {
|
|
425
426
|
var title = _ref3.title,
|
|
426
427
|
value = _ref3.value,
|
|
427
428
|
view = _ref3.view,
|
|
@@ -458,12 +459,12 @@ var Select = function Select(_ref) {
|
|
|
458
459
|
ref: selectNode
|
|
459
460
|
}), /*#__PURE__*/React.createElement("div", {
|
|
460
461
|
className: cn('inner')
|
|
461
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
462
|
+
}, /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.control), {
|
|
462
463
|
className: cn('control', {
|
|
463
464
|
labeled: !!label
|
|
464
465
|
}, classes.control),
|
|
465
466
|
onKeyDown: handleKeyDown
|
|
466
|
-
}, type === SelectTypes.COMBOBOX && renderCombobox(), type === SelectTypes.CLASSIC && renderTitle()), renderChildren()), noticeText && /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.noticeText), {
|
|
467
|
+
}), type === SelectTypes.COMBOBOX && renderCombobox(), type === SelectTypes.CLASSIC && renderTitle()), renderChildren()), noticeText && /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.noticeText), {
|
|
467
468
|
className: cn('text', {
|
|
468
469
|
error: verification === Verification.ERROR,
|
|
469
470
|
success: verification === Verification.VALID
|
|
@@ -496,9 +497,13 @@ Select.propTypes = {
|
|
|
496
497
|
dataAttrs: PropTypes.shape({
|
|
497
498
|
root: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
498
499
|
label: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
500
|
+
control: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
499
501
|
title: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
502
|
+
titleInner: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
500
503
|
input: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
501
504
|
noticeText: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
505
|
+
list: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
506
|
+
listInner: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
502
507
|
listItem: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
503
508
|
listItemTitle: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
504
509
|
notFound: PropTypes.objectOf(PropTypes.string.isRequired)
|
|
@@ -6,6 +6,7 @@ export interface ISwitcherProps {
|
|
|
6
6
|
dataAttrs?: {
|
|
7
7
|
root?: Record<string, string>;
|
|
8
8
|
input?: Record<string, string>;
|
|
9
|
+
loader?: Record<string, string>;
|
|
9
10
|
};
|
|
10
11
|
/** Дополнительный класс корневого элемента */
|
|
11
12
|
className?: string;
|
|
@@ -13,7 +14,7 @@ export interface ISwitcherProps {
|
|
|
13
14
|
checked?: boolean;
|
|
14
15
|
/** Отключение переключателя */
|
|
15
16
|
disabled?: boolean;
|
|
16
|
-
/**
|
|
17
|
+
/** Состояние загрузки */
|
|
17
18
|
showLoader?: boolean;
|
|
18
19
|
/** Размер текста лейбла */
|
|
19
20
|
textSize?: 'small' | 'medium';
|