@megafon/ui-core 4.12.0 → 4.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/es/components/Button/Button.js +1 -0
  3. package/dist/es/components/Carousel/Carousel.css +53 -14
  4. package/dist/es/components/Carousel/Carousel.d.ts +6 -1
  5. package/dist/es/components/Carousel/Carousel.js +21 -6
  6. package/dist/es/components/Carousel/useGradient.d.ts +18 -0
  7. package/dist/es/components/Carousel/useGradient.js +52 -0
  8. package/dist/es/components/NavArrow/NavArrow.css +11 -2
  9. package/dist/es/components/Preloader/Preloader.d.ts +2 -0
  10. package/dist/es/components/Preloader/Preloader.js +8 -2
  11. package/dist/es/components/Search/Search.d.ts +3 -0
  12. package/dist/es/components/Search/Search.js +10 -7
  13. package/dist/es/components/Switcher/Switcher.d.ts +2 -1
  14. package/dist/es/components/Switcher/Switcher.js +4 -3
  15. package/dist/es/components/TextField/TextField.d.ts +1 -0
  16. package/dist/es/components/TextField/TextField.js +4 -3
  17. package/dist/es/index.d.ts +1 -0
  18. package/dist/es/index.js +1 -0
  19. package/dist/lib/components/Button/Button.js +1 -0
  20. package/dist/lib/components/Carousel/Carousel.css +53 -14
  21. package/dist/lib/components/Carousel/Carousel.d.ts +6 -1
  22. package/dist/lib/components/Carousel/Carousel.js +53 -27
  23. package/dist/lib/components/Carousel/useGradient.d.ts +18 -0
  24. package/dist/lib/components/Carousel/useGradient.js +69 -0
  25. package/dist/lib/components/NavArrow/NavArrow.css +11 -2
  26. package/dist/lib/components/Preloader/Preloader.d.ts +2 -0
  27. package/dist/lib/components/Preloader/Preloader.js +8 -2
  28. package/dist/lib/components/Search/Search.d.ts +3 -0
  29. package/dist/lib/components/Search/Search.js +10 -7
  30. package/dist/lib/components/Switcher/Switcher.d.ts +2 -1
  31. package/dist/lib/components/Switcher/Switcher.js +4 -3
  32. package/dist/lib/components/TextField/TextField.d.ts +1 -0
  33. package/dist/lib/components/TextField/TextField.js +4 -3
  34. package/dist/lib/index.d.ts +1 -0
  35. package/dist/lib/index.js +8 -0
  36. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -3,6 +3,34 @@
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
+ # [4.14.0](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@4.13.0...@megafon/ui-core@4.14.0) (2023-03-07)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **button:** disable delay for loader ([a19c599](https://github.com/MegafonWebLab/megafon-ui/commit/a19c599f884d5dc9d485c56c6c7914e76d1c3fb6))
12
+
13
+
14
+ ### Features
15
+
16
+ * **carousel:** fix z-index of naw arrow ([b6b1ae1](https://github.com/MegafonWebLab/megafon-ui/commit/b6b1ae18e8641d8168bc97598df62a1ce0eac1f4))
17
+ * **preloader:** add new prop hasDelay ([356305d](https://github.com/MegafonWebLab/megafon-ui/commit/356305d70451d38e91e638970eb9b597cac86ea7))
18
+
19
+
20
+
21
+
22
+
23
+ # [4.13.0](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@4.12.0...@megafon/ui-core@4.13.0) (2023-02-22)
24
+
25
+
26
+ ### Features
27
+
28
+ * **carousel:** add property for gradient ([9900586](https://github.com/MegafonWebLab/megafon-ui/commit/99005866bc54d60f3447742f129f036391fb3a68))
29
+
30
+
31
+
32
+
33
+
6
34
  # [4.12.0](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@4.11.4...@megafon/ui-core@4.12.0) (2023-02-13)
7
35
 
8
36
 
@@ -157,6 +157,7 @@ var Button = function Button(_ref) {
157
157
  }, [icon, children]);
158
158
  var renderedLoader = React.useMemo(function () {
159
159
  return /*#__PURE__*/React.createElement(Preloader, {
160
+ delay: false,
160
161
  className: cn('preloader'),
161
162
  dataAttrs: {
162
163
  root: filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.loader)
@@ -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;
@@ -73,7 +116,7 @@
73
116
  .mfui-carousel__arrow {
74
117
  position: absolute;
75
118
  top: 50%;
76
- z-index: 2;
119
+ z-index: 6;
77
120
  -webkit-transform: translateY(calc(-50% - 40px / 2));
78
121
  transform: translateY(calc(-50% - 40px / 2));
79
122
  }
@@ -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
- .mfui-carousel .swiper-pagination-bullet:not(:last-child) {
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
- padding: 0;
204
+ width: 20px;
161
205
  cursor: default;
162
206
  }
163
- .mfui-carousel_nav-theme_green .swiper-pagination-bullet-active {
164
- padding: 0;
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(--brandPurple);
214
+ background-color: var(--brandGreen);
176
215
  }
@@ -1,6 +1,7 @@
1
- import * as React from 'react';
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;
@@ -9,7 +9,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
9
9
 
10
10
  var _defaultSlidesSetting;
11
11
 
12
- import * as React from 'react';
12
+ import React from 'react';
13
13
  import { breakpoints, cnCreate, filterDataAttrs } from '@megafon/ui-helpers';
14
14
  import throttle from 'lodash.throttle';
15
15
  import * as PropTypes from 'prop-types';
@@ -19,6 +19,7 @@ import NavArrow, { Theme as ArrowTheme } from "../NavArrow/NavArrow";
19
19
  import throttleTime from "../../constants/throttleTime";
20
20
  import usePrevious from "../../hooks/usePrevious";
21
21
  import checkBreakpointsPropTypes from "./checkBreakpointsPropTypes";
22
+ import useGradient, { GradientTheme } from "./useGradient";
22
23
  import "./Carousel.css";
23
24
  SwiperCore.use([Autoplay, Pagination, EffectFade]);
24
25
  export var NavTheme = {
@@ -96,7 +97,11 @@ var Carousel = function Carousel(_ref) {
96
97
  onPrevClick = _ref.onPrevClick,
97
98
  onChange = _ref.onChange,
98
99
  _ref$slideToClickedSl = _ref.slideToClickedSlide,
99
- slideToClickedSlide = _ref$slideToClickedSl === void 0 ? false : _ref$slideToClickedSl;
100
+ slideToClickedSlide = _ref$slideToClickedSl === void 0 ? false : _ref$slideToClickedSl,
101
+ _ref$gradient = _ref.gradient,
102
+ gradient = _ref$gradient === void 0 ? false : _ref$gradient,
103
+ _ref$gradientColor = _ref.gradientColor,
104
+ gradientColor = _ref$gradientColor === void 0 ? GradientTheme.DEFAULT : _ref$gradientColor;
100
105
 
101
106
  var _React$useState = React.useState(),
102
107
  _React$useState2 = _slicedToArray(_React$useState, 2),
@@ -121,6 +126,11 @@ var Carousel = function Carousel(_ref) {
121
126
  var childrenLen = Array.isArray(children) ? children.length : 0;
122
127
  var prevChildrenLen = usePrevious(childrenLen) || 0;
123
128
  var isChildrenLenDiff = childrenLen !== prevChildrenLen;
129
+ var gradientStyles = useGradient(gradient, {
130
+ instance: swiperInstance,
131
+ slidesSettings: slidesSettings,
132
+ isLocked: isLocked
133
+ });
124
134
  var increaseAutoplayDelay = React.useCallback(function (_ref2) {
125
135
  var params = _ref2.params,
126
136
  autoplay = _ref2.autoplay;
@@ -245,7 +255,7 @@ var Carousel = function Carousel(_ref) {
245
255
  return function () {
246
256
  window.removeEventListener('resize', windowResizeHandlerThrottled);
247
257
  };
248
- }, [swiperInstance]);
258
+ }, [slidesSettings, swiperInstance]);
249
259
  React.useEffect(function () {
250
260
  if (swiperInstance && isChildrenLenDiff) {
251
261
  handleNavDisplay(swiperInstance);
@@ -256,12 +266,15 @@ var Carousel = function Carousel(_ref) {
256
266
  className: cn({
257
267
  'nav-theme': navTheme
258
268
  }, [className, rootClass]),
259
- onClick: handleRootClick
269
+ onClick: handleRootClick,
270
+ style: gradientStyles
260
271
  }), /*#__PURE__*/React.createElement(Swiper, _extends({}, containerModifier ? {
261
272
  containerModifierClass: containerModifier
262
273
  } : {}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.slider), {
263
274
  className: cn('swiper', {
264
- 'default-inner-indents': !innerIndentsClass
275
+ 'default-inner-indents': !innerIndentsClass,
276
+ gradient: gradient,
277
+ 'gradient-color': gradient && gradientColor
265
278
  }, [innerIndentsClass, containerClass]),
266
279
  breakpoints: slidesSettings,
267
280
  watchSlidesVisibility: true,
@@ -371,6 +384,8 @@ Carousel.propTypes = {
371
384
  getSwiper: PropTypes.func,
372
385
  onNextClick: PropTypes.func,
373
386
  onPrevClick: PropTypes.func,
374
- onChange: PropTypes.func
387
+ onChange: PropTypes.func,
388
+ gradient: PropTypes.oneOfType([PropTypes.bool]),
389
+ gradientColor: PropTypes.oneOf(Object.values(GradientTheme))
375
390
  };
376
391
  export default Carousel;
@@ -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,52 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import { useState, useEffect } from 'react';
3
+ import { breakpoints } from '@megafon/ui-helpers';
4
+ import throttle from 'lodash.throttle';
5
+ import throttleTime from "../../constants/throttleTime";
6
+ export var GradientTheme;
7
+
8
+ (function (GradientTheme) {
9
+ GradientTheme["DEFAULT"] = "default";
10
+ GradientTheme["GREEN"] = "green";
11
+ GradientTheme["BLACK"] = "black";
12
+ GradientTheme["SPB_SKY_0"] = "spbSky0";
13
+ GradientTheme["SPB_SKY_1"] = "spbSky1";
14
+ GradientTheme["SPB_SKY_2"] = "spbSky2";
15
+ })(GradientTheme || (GradientTheme = {}));
16
+
17
+ export default (function (gradient, swiper) {
18
+ var _useState = useState(0),
19
+ _useState2 = _slicedToArray(_useState, 2),
20
+ slidesGap = _useState2[0],
21
+ setSlidesGap = _useState2[1];
22
+
23
+ var swiperInstance = swiper.instance,
24
+ slidesSettings = swiper.slidesSettings,
25
+ isLocked = swiper.isLocked;
26
+ var isGradientEnable = gradient && !isLocked;
27
+ useEffect(function () {
28
+ var isTouch = window.innerWidth < breakpoints.DESKTOP_SMALL_START;
29
+ var isPossibleToSetGap = isGradientEnable && swiperInstance && !isTouch;
30
+
31
+ if (!isPossibleToSetGap) {
32
+ return undefined;
33
+ }
34
+
35
+ var setCurrenSlidesGap = function setCurrenSlidesGap() {
36
+ var currentBreakpoint = swiperInstance.getBreakpoint(slidesSettings);
37
+ var currentSpaceBetweenValue = slidesSettings[currentBreakpoint].spaceBetween;
38
+ setSlidesGap(currentSpaceBetweenValue);
39
+ };
40
+
41
+ setCurrenSlidesGap();
42
+ var throttledHandler = throttle(setCurrenSlidesGap, throttleTime.resize);
43
+ window.addEventListener('resize', throttledHandler);
44
+ return function () {
45
+ window.removeEventListener('resize', throttledHandler);
46
+ };
47
+ }, [gradient, slidesSettings, swiperInstance, isLocked, isGradientEnable]);
48
+ var gradientStyles = {
49
+ '--gap': "".concat(slidesGap, "px")
50
+ };
51
+ return isGradientEnable ? gradientStyles : {};
52
+ });
@@ -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:not(:disabled) {
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:not(:disabled) {
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
+ }
@@ -12,6 +12,8 @@ export declare const PreloaderSizes: {
12
12
  };
13
13
  export declare type PreloaderSizesType = typeof PreloaderSizes[keyof typeof PreloaderSizes];
14
14
  export interface IPreloaderProps {
15
+ /** Задержка отрисовки */
16
+ delay?: boolean;
15
17
  /** Цветовая тема */
16
18
  color?: PreloaderColorsType;
17
19
  /** Размер на всех разрешениях экрана */
@@ -22,6 +22,8 @@ var Preloader = function Preloader(_ref) {
22
22
  color = _ref$color === void 0 ? 'default' : _ref$color,
23
23
  _ref$sizeAll = _ref.sizeAll,
24
24
  sizeAll = _ref$sizeAll === void 0 ? 'medium' : _ref$sizeAll,
25
+ _ref$delay = _ref.delay,
26
+ delay = _ref$delay === void 0 ? true : _ref$delay,
25
27
  sizeWide = _ref.sizeWide,
26
28
  sizeDesktop = _ref.sizeDesktop,
27
29
  sizeTablet = _ref.sizeTablet,
@@ -29,19 +31,23 @@ var Preloader = function Preloader(_ref) {
29
31
  className = _ref.className,
30
32
  dataAttrs = _ref.dataAttrs;
31
33
 
32
- var _React$useState = React.useState(false),
34
+ var _React$useState = React.useState(!delay),
33
35
  _React$useState2 = _slicedToArray(_React$useState, 2),
34
36
  isShowed = _React$useState2[0],
35
37
  setIsShowed = _React$useState2[1];
36
38
 
37
39
  React.useEffect(function () {
40
+ if (isShowed) {
41
+ return undefined;
42
+ }
43
+
38
44
  var timerId = setTimeout(function () {
39
45
  setIsShowed(true);
40
46
  }, 250);
41
47
  return function () {
42
48
  clearTimeout(timerId);
43
49
  };
44
- }, []);
50
+ }, [isShowed]);
45
51
  return isShowed ? /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
46
52
  className: cn({
47
53
  color: color,
@@ -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;
@@ -185,12 +185,12 @@ var Search = function Search(_ref) {
185
185
  open: isFocused,
186
186
  disabled: disabled
187
187
  }, [className])
188
- }), /*#__PURE__*/React.createElement("div", {
188
+ }), /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.control), {
189
189
  className: cn('control', {
190
190
  error: verification === Verification.ERROR,
191
191
  success: verification === Verification.VALID
192
192
  }, [classes === null || classes === void 0 ? void 0 : classes.control])
193
- }, /*#__PURE__*/React.createElement("label", {
193
+ }), /*#__PURE__*/React.createElement("label", {
194
194
  className: cn('search-wrapper', {
195
195
  labeled: !!label,
196
196
  'no-label': !label
@@ -238,23 +238,26 @@ var Search = function Search(_ref) {
238
238
  onMouseDown: handleSelectSubmit(i),
239
239
  onMouseEnter: handleHoverItem(i),
240
240
  key: i
241
- }), /*#__PURE__*/React.createElement("div", {
241
+ }), /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.itemTitle, i + 1), {
242
242
  className: cn('item-title', [classes === null || classes === void 0 ? void 0 : classes.listItemTitle])
243
- }, searchView || highlightString(itemValue)));
244
- })))), noticeText && /*#__PURE__*/React.createElement("div", {
243
+ }), searchView || highlightString(itemValue)));
244
+ })))), noticeText && /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.notice), {
245
245
  className: cn('notice', {
246
246
  error: verification === Verification.ERROR,
247
247
  success: verification === Verification.VALID
248
248
  })
249
- }, noticeText));
249
+ }), noticeText));
250
250
  };
251
251
 
252
252
  Search.propTypes = {
253
253
  dataAttrs: PropTypes.shape({
254
254
  root: PropTypes.objectOf(PropTypes.string.isRequired),
255
+ control: PropTypes.objectOf(PropTypes.string.isRequired),
255
256
  searchField: PropTypes.objectOf(PropTypes.string.isRequired),
256
257
  submit: PropTypes.objectOf(PropTypes.string.isRequired),
257
- item: PropTypes.objectOf(PropTypes.string.isRequired)
258
+ item: PropTypes.objectOf(PropTypes.string.isRequired),
259
+ itemTitle: PropTypes.objectOf(PropTypes.string.isRequired),
260
+ notice: PropTypes.objectOf(PropTypes.string.isRequired)
258
261
  }),
259
262
  value: PropTypes.string,
260
263
  label: PropTypes.string,
@@ -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
- /** Cостояние загрузки */
17
+ /** Состояние загрузки */
17
18
  showLoader?: boolean;
18
19
  /** Размер текста лейбла */
19
20
  textSize?: 'small' | 'medium';
@@ -50,9 +50,9 @@ var Switcher = function Switcher(_ref) {
50
50
  onClick: handleChange,
51
51
  onKeyDown: handleChange,
52
52
  tabIndex: isInteractiveDisabled ? undefined : 0
53
- }), showLoader && !disabled && /*#__PURE__*/React.createElement("div", {
53
+ }), showLoader && !disabled && /*#__PURE__*/React.createElement("div", _extends({
54
54
  className: cn('loader')
55
- }), /*#__PURE__*/React.createElement("div", {
55
+ }, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.loader))), /*#__PURE__*/React.createElement("div", {
56
56
  className: cn('pointer')
57
57
  })), isRightContent && /*#__PURE__*/React.createElement("div", {
58
58
  className: cn('content', {
@@ -64,7 +64,8 @@ var Switcher = function Switcher(_ref) {
64
64
  Switcher.propTypes = {
65
65
  dataAttrs: PropTypes.shape({
66
66
  root: PropTypes.objectOf(PropTypes.string.isRequired),
67
- input: PropTypes.objectOf(PropTypes.string.isRequired)
67
+ input: PropTypes.objectOf(PropTypes.string.isRequired),
68
+ loader: PropTypes.objectOf(PropTypes.string.isRequired)
68
69
  }),
69
70
  className: PropTypes.string,
70
71
  textSize: PropTypes.oneOf(['small', 'medium']),
@@ -77,6 +77,7 @@ export declare type TextFieldProps = {
77
77
  notice?: Record<string, string>;
78
78
  input?: Record<string, string>;
79
79
  iconBox?: Record<string, string>;
80
+ resizer?: Record<string, string>;
80
81
  };
81
82
  /** Атрибут элемента input */
82
83
  inputMode?: 'numeric' | 'tel' | 'decimal' | 'email' | 'url' | 'search' | 'none';
@@ -465,10 +465,10 @@ var TextField = function TextField(_ref) {
465
465
  className: cn('field-wrapper', {
466
466
  textarea: textarea && textareaType
467
467
  })
468
- }, renderField(), textareaType === TextareaTypes.FLEXIBLE && !hideResizeButton && /*#__PURE__*/React.createElement("div", {
468
+ }, renderField(), textareaType === TextareaTypes.FLEXIBLE && !hideResizeButton && /*#__PURE__*/React.createElement("div", _extends({
469
469
  className: cn('resizer'),
470
470
  ref: resizerRef
471
- }, /*#__PURE__*/React.createElement(ResizeIcon, null))), /*#__PURE__*/React.createElement("div", {
471
+ }, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.resizer)), /*#__PURE__*/React.createElement(ResizeIcon, null))), /*#__PURE__*/React.createElement("div", {
472
472
  className: cn('field-bottom-wrapper', {
473
473
  filled: !!currentNoticeText || !!symbolCounter
474
474
  })
@@ -527,7 +527,8 @@ TextField.propTypes = {
527
527
  label: PropTypes.objectOf(PropTypes.string.isRequired),
528
528
  notice: PropTypes.objectOf(PropTypes.string.isRequired),
529
529
  input: PropTypes.objectOf(PropTypes.string.isRequired),
530
- iconBox: PropTypes.objectOf(PropTypes.string.isRequired)
530
+ iconBox: PropTypes.objectOf(PropTypes.string.isRequired),
531
+ resizer: PropTypes.objectOf(PropTypes.string.isRequired)
531
532
  })
532
533
  };
533
534
  export default TextField;
@@ -43,4 +43,5 @@ export { default as Tile } from './components/Tile/Tile';
43
43
  export { default as Timer } from './components/Badges/components/TimerBadge/Timer/Timer';
44
44
  export { default as TimerBadge } from './components/Badges/components/TimerBadge/TimerBadge';
45
45
  export { default as Tooltip } from './components/Tooltip/Tooltip';
46
+ export { default as useGradient } from './components/Carousel/useGradient';
46
47
  export { default as usePagination } from './components/Pagination/usePagination';
package/dist/es/index.js CHANGED
@@ -43,4 +43,5 @@ export { default as Tile } from "./components/Tile/Tile";
43
43
  export { default as Timer } from "./components/Badges/components/TimerBadge/Timer/Timer";
44
44
  export { default as TimerBadge } from "./components/Badges/components/TimerBadge/TimerBadge";
45
45
  export { default as Tooltip } from "./components/Tooltip/Tooltip";
46
+ export { default as useGradient } from "./components/Carousel/useGradient";
46
47
  export { default as usePagination } from "./components/Pagination/usePagination";
@@ -190,6 +190,7 @@ var Button = function Button(_ref) {
190
190
 
191
191
  var renderedLoader = _react["default"].useMemo(function () {
192
192
  return /*#__PURE__*/_react["default"].createElement(_Preloader["default"], {
193
+ delay: false,
193
194
  className: cn('preloader'),
194
195
  dataAttrs: {
195
196
  root: (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.loader)
@@ -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;
@@ -73,7 +116,7 @@
73
116
  .mfui-carousel__arrow {
74
117
  position: absolute;
75
118
  top: 50%;
76
- z-index: 2;
119
+ z-index: 6;
77
120
  -webkit-transform: translateY(calc(-50% - 40px / 2));
78
121
  transform: translateY(calc(-50% - 40px / 2));
79
122
  }
@@ -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
- .mfui-carousel .swiper-pagination-bullet:not(:last-child) {
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
- padding: 0;
204
+ width: 20px;
161
205
  cursor: default;
162
206
  }
163
- .mfui-carousel_nav-theme_green .swiper-pagination-bullet-active {
164
- padding: 0;
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(--brandPurple);
214
+ background-color: var(--brandGreen);
176
215
  }
@@ -1,6 +1,7 @@
1
- import * as React from 'react';
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 React = _interopRequireWildcard(require("react"));
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 = 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 = React.useState(true),
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 = React.useState(false),
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 = React.useState(false),
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 increaseAutoplayDelay = React.useCallback(function (_ref2) {
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
- var handlePrevClick = React.useCallback(function () {
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
- var handleNextClick = React.useCallback(function () {
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
- var handleSwiper = React.useCallback(function (swiper) {
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
- var handleReachBeginnig = React.useCallback(function () {
209
+
210
+ var handleReachBeginnig = _react["default"].useCallback(function () {
195
211
  setBeginning(true);
196
212
  }, []);
197
- var handleReachEnd = React.useCallback(function (_ref3) {
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
- var handleFromEdge = React.useCallback(function (swiper) {
223
+
224
+ var handleFromEdge = _react["default"].useCallback(function (swiper) {
207
225
  setBeginning(swiper.isBeginning);
208
226
  setEnd(swiper.isEnd);
209
227
  }, []);
210
- var handleSlideChange = React.useCallback(function (_ref4) {
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 = React.useCallback(function () {
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
- React.useEffect(function () {
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
- React.useEffect(function () {
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
- return /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
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
- }), /*#__PURE__*/React.createElement(_react2.Swiper, (0, _extends2["default"])({}, containerModifier ? {
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
- }), React.Children.map(children, function (child, i) {
325
- return /*#__PURE__*/React.createElement(_react2.SwiperSlide, (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.slide, i + 1), {
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__*/React.createElement(_NavArrow["default"], {
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__*/React.createElement(_NavArrow["default"], {
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:not(:disabled) {
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:not(:disabled) {
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
+ }
@@ -12,6 +12,8 @@ export declare const PreloaderSizes: {
12
12
  };
13
13
  export declare type PreloaderSizesType = typeof PreloaderSizes[keyof typeof PreloaderSizes];
14
14
  export interface IPreloaderProps {
15
+ /** Задержка отрисовки */
16
+ delay?: boolean;
15
17
  /** Цветовая тема */
16
18
  color?: PreloaderColorsType;
17
19
  /** Размер на всех разрешениях экрана */
@@ -45,6 +45,8 @@ var Preloader = function Preloader(_ref) {
45
45
  color = _ref$color === void 0 ? 'default' : _ref$color,
46
46
  _ref$sizeAll = _ref.sizeAll,
47
47
  sizeAll = _ref$sizeAll === void 0 ? 'medium' : _ref$sizeAll,
48
+ _ref$delay = _ref.delay,
49
+ delay = _ref$delay === void 0 ? true : _ref$delay,
48
50
  sizeWide = _ref.sizeWide,
49
51
  sizeDesktop = _ref.sizeDesktop,
50
52
  sizeTablet = _ref.sizeTablet,
@@ -52,19 +54,23 @@ var Preloader = function Preloader(_ref) {
52
54
  className = _ref.className,
53
55
  dataAttrs = _ref.dataAttrs;
54
56
 
55
- var _React$useState = React.useState(false),
57
+ var _React$useState = React.useState(!delay),
56
58
  _React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2),
57
59
  isShowed = _React$useState2[0],
58
60
  setIsShowed = _React$useState2[1];
59
61
 
60
62
  React.useEffect(function () {
63
+ if (isShowed) {
64
+ return undefined;
65
+ }
66
+
61
67
  var timerId = setTimeout(function () {
62
68
  setIsShowed(true);
63
69
  }, 250);
64
70
  return function () {
65
71
  clearTimeout(timerId);
66
72
  };
67
- }, []);
73
+ }, [isShowed]);
68
74
  return isShowed ? /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
69
75
  className: cn({
70
76
  color: color,
@@ -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,
@@ -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
- /** Cостояние загрузки */
17
+ /** Состояние загрузки */
17
18
  showLoader?: boolean;
18
19
  /** Размер текста лейбла */
19
20
  textSize?: 'small' | 'medium';
@@ -68,9 +68,9 @@ var Switcher = function Switcher(_ref) {
68
68
  onClick: handleChange,
69
69
  onKeyDown: handleChange,
70
70
  tabIndex: isInteractiveDisabled ? undefined : 0
71
- }), showLoader && !disabled && /*#__PURE__*/React.createElement("div", {
71
+ }), showLoader && !disabled && /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({
72
72
  className: cn('loader')
73
- }), /*#__PURE__*/React.createElement("div", {
73
+ }, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.loader))), /*#__PURE__*/React.createElement("div", {
74
74
  className: cn('pointer')
75
75
  })), isRightContent && /*#__PURE__*/React.createElement("div", {
76
76
  className: cn('content', {
@@ -82,7 +82,8 @@ var Switcher = function Switcher(_ref) {
82
82
  Switcher.propTypes = {
83
83
  dataAttrs: PropTypes.shape({
84
84
  root: PropTypes.objectOf(PropTypes.string.isRequired),
85
- input: PropTypes.objectOf(PropTypes.string.isRequired)
85
+ input: PropTypes.objectOf(PropTypes.string.isRequired),
86
+ loader: PropTypes.objectOf(PropTypes.string.isRequired)
86
87
  }),
87
88
  className: PropTypes.string,
88
89
  textSize: PropTypes.oneOf(['small', 'medium']),
@@ -77,6 +77,7 @@ export declare type TextFieldProps = {
77
77
  notice?: Record<string, string>;
78
78
  input?: Record<string, string>;
79
79
  iconBox?: Record<string, string>;
80
+ resizer?: Record<string, string>;
80
81
  };
81
82
  /** Атрибут элемента input */
82
83
  inputMode?: 'numeric' | 'tel' | 'decimal' | 'email' | 'url' | 'search' | 'none';
@@ -489,10 +489,10 @@ var TextField = function TextField(_ref) {
489
489
  className: cn('field-wrapper', {
490
490
  textarea: textarea && textareaType
491
491
  })
492
- }, renderField(), textareaType === TextareaTypes.FLEXIBLE && !hideResizeButton && /*#__PURE__*/React.createElement("div", {
492
+ }, renderField(), textareaType === TextareaTypes.FLEXIBLE && !hideResizeButton && /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({
493
493
  className: cn('resizer'),
494
494
  ref: resizerRef
495
- }, /*#__PURE__*/React.createElement(ResizeIcon, null))), /*#__PURE__*/React.createElement("div", {
495
+ }, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.resizer)), /*#__PURE__*/React.createElement(ResizeIcon, null))), /*#__PURE__*/React.createElement("div", {
496
496
  className: cn('field-bottom-wrapper', {
497
497
  filled: !!currentNoticeText || !!symbolCounter
498
498
  })
@@ -551,7 +551,8 @@ TextField.propTypes = {
551
551
  label: PropTypes.objectOf(PropTypes.string.isRequired),
552
552
  notice: PropTypes.objectOf(PropTypes.string.isRequired),
553
553
  input: PropTypes.objectOf(PropTypes.string.isRequired),
554
- iconBox: PropTypes.objectOf(PropTypes.string.isRequired)
554
+ iconBox: PropTypes.objectOf(PropTypes.string.isRequired),
555
+ resizer: PropTypes.objectOf(PropTypes.string.isRequired)
555
556
  })
556
557
  };
557
558
  var _default = TextField;
@@ -43,4 +43,5 @@ export { default as Tile } from './components/Tile/Tile';
43
43
  export { default as Timer } from './components/Badges/components/TimerBadge/Timer/Timer';
44
44
  export { default as TimerBadge } from './components/Badges/components/TimerBadge/TimerBadge';
45
45
  export { default as Tooltip } from './components/Tooltip/Tooltip';
46
+ export { default as useGradient } from './components/Carousel/useGradient';
46
47
  export { default as usePagination } from './components/Pagination/usePagination';
package/dist/lib/index.js CHANGED
@@ -273,6 +273,12 @@ Object.defineProperty(exports, "Tooltip", {
273
273
  return _Tooltip["default"];
274
274
  }
275
275
  });
276
+ Object.defineProperty(exports, "useGradient", {
277
+ enumerable: true,
278
+ get: function get() {
279
+ return _useGradient["default"];
280
+ }
281
+ });
276
282
  Object.defineProperty(exports, "usePagination", {
277
283
  enumerable: true,
278
284
  get: function get() {
@@ -370,6 +376,8 @@ var _TimerBadge = _interopRequireDefault(require("./components/Badges/components
370
376
 
371
377
  var _Tooltip = _interopRequireDefault(require("./components/Tooltip/Tooltip"));
372
378
 
379
+ var _useGradient = _interopRequireDefault(require("./components/Carousel/useGradient"));
380
+
373
381
  var _usePagination = _interopRequireDefault(require("./components/Pagination/usePagination"));
374
382
 
375
383
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@megafon/ui-core",
3
- "version": "4.12.0",
3
+ "version": "4.14.0",
4
4
  "files": [
5
5
  "dist",
6
6
  "styles"
@@ -100,5 +100,5 @@
100
100
  "react-popper": "^2.2.3",
101
101
  "swiper": "^6.5.6"
102
102
  },
103
- "gitHead": "8aa400bad61aac6015ab7eff10b6aa24dcdbd8f6"
103
+ "gitHead": "b9b0a048d2faba323bebaddbf302aed8e0894506"
104
104
  }