@megafon/ui-core 5.3.0 → 5.4.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 CHANGED
@@ -3,6 +3,37 @@
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.4.1](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/compare/@megafon/ui-core@5.4.0...@megafon/ui-core@5.4.1) (2023-11-27)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **search:** change index to correct one on mouse down to item in dropdown ([363e1bc](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/commit/363e1bc43f884fecec1057e74f071ab1e9904e24))
12
+
13
+
14
+
15
+
16
+
17
+ # [5.4.0](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/compare/@megafon/ui-core@5.3.0...@megafon/ui-core@5.4.0) (2023-11-22)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **snackbar:** fix swipe ([ce8b5eb](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/commit/ce8b5ebd8bae725befab8adc08dbaa879f430bd4))
23
+ * **snackbar:** fix transform ([286e976](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/commit/286e976a6bf395de41392efcd3cbf66ecc949a1a))
24
+ * **snackbar:** refactoring ([6f49ad1](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/commit/6f49ad130d8ce2e810660ae0bbb7a270269d29e0))
25
+ * **snackbar:** refactoring ([b58f943](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/commit/b58f943f364995da610374140287b64a229b7aed))
26
+ * **tabs:** fix text color in not active tab ([d0bd99b](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/commit/d0bd99b710ce97813df671eeeb4edf6f8ae5be44))
27
+
28
+
29
+ ### Features
30
+
31
+ * **pricebadge:** add new iconType profile ([0259dd8](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/commit/0259dd8c3989e4041bb0a4d9100e0a76352c1377))
32
+
33
+
34
+
35
+
36
+
6
37
  # [5.3.0](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/compare/@megafon/ui-core@5.2.3...@megafon/ui-core@5.3.0) (2023-11-08)
7
38
 
8
39
 
@@ -12,6 +12,7 @@ export declare const PriceBadgeIcon: {
12
12
  readonly CHECK: "check";
13
13
  readonly ATTENTION: "attention";
14
14
  readonly INFO: "info";
15
+ readonly PROFILE: "profile";
15
16
  };
16
17
  export declare const PriseBadgeSize: {
17
18
  readonly SMALL: "small";
@@ -5,6 +5,22 @@ import { cnCreate, filterDataAttrs } from '@megafon/ui-helpers';
5
5
  import * as PropTypes from 'prop-types';
6
6
  import "./PriceBadge.css";
7
7
 
8
+ var ProfileIcon = function ProfileIcon(props) {
9
+ return /*#__PURE__*/React.createElement("svg", _extends({
10
+ viewBox: "0 0 20 20"
11
+ }, props), /*#__PURE__*/React.createElement("path", {
12
+ d: "M5.22 18h9.55L16 13.47A8.28 8.28 0 0010 11a8.302 8.302 0 00-6 2.5L5.22 18zM14 6a4 4 0 10-8 0 4 4 0 008 0z"
13
+ }));
14
+ };
15
+
16
+ var ProfileIconBig = function ProfileIconBig(props) {
17
+ return /*#__PURE__*/React.createElement("svg", _extends({
18
+ viewBox: "0 0 32 32"
19
+ }, props), /*#__PURE__*/React.createElement("path", {
20
+ d: "M23 28l2-7.43-.32-.31A12.67 12.67 0 0016 17a12.68 12.68 0 00-8.68 3.27l-.32.3L9 28h14zM10 9a6 6 0 1012 0 6 6 0 00-12 0z"
21
+ }));
22
+ };
23
+
8
24
  var AttentionIcon = function AttentionIcon(props) {
9
25
  return /*#__PURE__*/React.createElement("svg", _extends({
10
26
  viewBox: "0 0 20 20"
@@ -108,7 +124,8 @@ export var PriceBadgeIcon = {
108
124
  PRICE: 'price',
109
125
  CHECK: 'check',
110
126
  ATTENTION: 'attention',
111
- INFO: 'info'
127
+ INFO: 'info',
128
+ PROFILE: 'profile'
112
129
  };
113
130
  export var PriseBadgeSize = {
114
131
  SMALL: 'small',
@@ -134,6 +151,9 @@ var getPriceBadgeIcon = function getPriceBadgeIcon(iconType, size) {
134
151
  case iconType === PriceBadgeIcon.INFO && isBigIcon:
135
152
  return InfoIconBig;
136
153
 
154
+ case iconType === PriceBadgeIcon.PROFILE && isBigIcon:
155
+ return ProfileIconBig;
156
+
137
157
  case iconType === PriceBadgeIcon.PRICE:
138
158
  return PriceIcon;
139
159
 
@@ -146,6 +166,9 @@ var getPriceBadgeIcon = function getPriceBadgeIcon(iconType, size) {
146
166
  case iconType === PriceBadgeIcon.INFO:
147
167
  return InfoIcon;
148
168
 
169
+ case iconType === PriceBadgeIcon.PROFILE:
170
+ return ProfileIcon;
171
+
149
172
  default:
150
173
  return TimerIcon;
151
174
  }
@@ -9,10 +9,10 @@ import "core-js/modules/es.array.map.js";
9
9
  import "core-js/modules/es.object.values.js";
10
10
  import React from 'react';
11
11
  import { cnCreate, filterDataAttrs } from '@megafon/ui-helpers';
12
+ import Preloader from "../Preloader/Preloader";
12
13
  import debounce from 'lodash.debounce';
13
14
  import * as PropTypes from 'prop-types';
14
15
  import "./Search.css";
15
- import Preloader from "../Preloader/Preloader";
16
16
 
17
17
  var SearchIcon16 = function SearchIcon16(props) {
18
18
  return /*#__PURE__*/React.createElement("svg", _extends({
@@ -131,11 +131,11 @@ var Search = function Search(_ref) {
131
131
  var chosenValue = items[index].value;
132
132
  onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(chosenValue);
133
133
  }, [disabled, items, onSubmit]);
134
- var handleSelectSubmit = React.useCallback(function () {
134
+ var handleSelectSubmit = React.useCallback(function (index) {
135
135
  return function () {
136
- handleItemSubmit(activeIndex);
136
+ handleItemSubmit(index);
137
137
  };
138
- }, [handleItemSubmit, activeIndex]);
138
+ }, [handleItemSubmit]);
139
139
  var handleFocus = React.useCallback(function (e) {
140
140
  setFocus(true);
141
141
  onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
@@ -6,7 +6,7 @@ var _DEFAULT_SNACKBARS;
6
6
 
7
7
  import "core-js/modules/web.timers.js";
8
8
  import "core-js/modules/es.object.values.js";
9
- import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
9
+ import React, { useCallback, useEffect, useMemo, useState } from 'react';
10
10
  import { cnCreate, filterDataAttrs } from '@megafon/ui-helpers';
11
11
  import * as PropTypes from 'prop-types';
12
12
  import Button from "../Button/Button";
@@ -128,7 +128,10 @@ var Snackbar = function Snackbar(_ref) {
128
128
  isOpened = _useState2[0],
129
129
  setIsOpened = _useState2[1];
130
130
 
131
- var containerRef = useRef(null);
131
+ var _useState3 = useState(null),
132
+ _useState4 = _slicedToArray(_useState3, 2),
133
+ containerRef = _useState4[0],
134
+ setContainerRef = _useState4[1];
132
135
 
133
136
  var _useSwipe = useSwipe(containerRef),
134
137
  transform = _useSwipe.transform,
@@ -142,6 +145,11 @@ var Snackbar = function Snackbar(_ref) {
142
145
  var isHiddenIcon = isTimerType || !hasIcon && isInfoType;
143
146
  var isCustomIcon = isInfoType && icon;
144
147
  var currentButtonText = buttonText && !isTimerType ? buttonText : defaultSnackbar.buttonText;
148
+
149
+ var setRef = function setRef(instance) {
150
+ return setContainerRef(instance);
151
+ };
152
+
145
153
  var handleClose = useCallback(function () {
146
154
  setIsOpened(false);
147
155
  }, []);
@@ -191,10 +199,10 @@ var Snackbar = function Snackbar(_ref) {
191
199
  className: cn({
192
200
  move: isTransitionMoveStep
193
201
  }, [className, classes.root]),
194
- ref: containerRef,
195
- style: {
202
+ ref: setRef,
203
+ style: transform !== 'none' ? {
196
204
  transform: transform
197
- }
205
+ } : undefined
198
206
  }, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root)), /*#__PURE__*/React.createElement(Tile, {
199
207
  className: cn('tile', {
200
208
  type: type,
@@ -146,24 +146,30 @@
146
146
  box-sizing: border-box;
147
147
  height: 36px;
148
148
  padding: 2px 12px;
149
- color: var(--spbSky3);
149
+ color: var(--content);
150
150
  white-space: nowrap;
151
151
  text-align: center;
152
152
  text-decoration: none;
153
153
  cursor: pointer;
154
154
  -webkit-transition: color 0.3s, fill 0.3s;
155
155
  transition: color 0.3s, fill 0.3s;
156
- fill: var(--spbSky3);
156
+ fill: var(--content);
157
157
  }
158
158
  .mfui-tabs__tab-inner:hover {
159
159
  text-decoration: none;
160
160
  }
161
+ .mfui-tabs__tab-inner:not(.mfui-tabs__tab-inner_current) {
162
+ opacity: 0.8;
163
+ }
161
164
  @media screen and (min-width: 1024px) {
162
165
  .mfui-tabs__tab-inner:not(.mfui-tabs__tab-inner_current):hover {
163
166
  color: var(--content);
164
167
  fill: var(--content);
165
168
  }
166
169
  }
170
+ .mfui-tabs__tab-inner:not(.mfui-tabs__tab-inner_current):hover {
171
+ opacity: 1;
172
+ }
167
173
  .mfui-tabs__tab-inner:not(.mfui-tabs__tab-inner_current):active {
168
174
  color: var(--buttonDown);
169
175
  fill: var(--buttonDown);
@@ -255,11 +261,13 @@
255
261
  background-color: var(--stcBlack20);
256
262
  }
257
263
  .mfui-tabs_tab-color_green:not(.mfui-tabs_sticky) .mfui-tabs__tab-inner:not(.mfui-tabs_tab-color_green:not(.mfui-tabs_sticky) .mfui-tabs__tab-inner_current) {
258
- color: #ffffffb2;
259
- fill: #ffffffb2;
264
+ color: var(--stcWhite);
265
+ opacity: 0.8;
266
+ fill: var(--stcWhite);
260
267
  }
261
268
  .mfui-tabs_tab-color_green:not(.mfui-tabs_sticky) .mfui-tabs__tab-inner:not(.mfui-tabs_tab-color_green:not(.mfui-tabs_sticky) .mfui-tabs__tab-inner_current):hover {
262
269
  color: var(--stcWhite);
270
+ opacity: 1;
263
271
  fill: var(--stcWhite);
264
272
  }
265
273
  .mfui-tabs_tab-color_green:not(.mfui-tabs_sticky) .mfui-tabs__tab-inner_current {
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
1
  export declare enum TransitionSteps {
3
2
  INITIAL_STEP = "initial-step",
4
3
  MOVE_STEP = "move-step",
@@ -10,5 +9,5 @@ declare type UseSwipeReturnType = {
10
9
  /** Текущий этап смахивания элемента */
11
10
  transitionStep: TransitionSteps;
12
11
  };
13
- declare function useSwipe(element: React.MutableRefObject<null>): UseSwipeReturnType;
12
+ declare function useSwipe(element: HTMLElement | null): UseSwipeReturnType;
14
13
  export default useSwipe;
@@ -1,4 +1,9 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import "core-js/modules/es.regexp.exec.js";
3
+ import "core-js/modules/es.string.match.js";
4
+ import "core-js/modules/es.string.split.js";
5
+ import "core-js/modules/es.number.is-nan.js";
6
+ import "core-js/modules/es.number.constructor.js";
2
7
  import * as React from 'react';
3
8
  import useResolution from "./useResolution";
4
9
  export var TransitionSteps;
@@ -31,14 +36,17 @@ function useSwipe(element) {
31
36
  setTransform = _React$useState6[1];
32
37
 
33
38
  var animationFrameId = React.useRef(0);
34
- var currentElement = element.current;
39
+ var currentElement = element;
35
40
  var isTransitionMoveStep = transitionStep === TransitionSteps.MOVE_STEP;
41
+ var currentTransform = currentElement ? getComputedStyle(currentElement).transform : '';
36
42
  var handleWindowTouchMove = React.useCallback(function (e) {
37
43
  if (animationFrameId) {
38
44
  window.cancelAnimationFrame(animationFrameId.current);
39
45
  }
40
46
 
41
47
  animationFrameId.current = window.requestAnimationFrame(function () {
48
+ var _a;
49
+
42
50
  setTransitionStep(TransitionSteps.MOVE_STEP);
43
51
 
44
52
  if (!currentElement) {
@@ -51,10 +59,12 @@ function useSwipe(element) {
51
59
  }
52
60
 
53
61
  var positionsDiff = initialTouchPosition - e.touches[0].clientX;
54
- positionsDiff !== 0 && setTransform("translateX(".concat(-positionsDiff, "px)"));
62
+ var values = !!currentTransform && currentTransform !== 'none' ? (_a = currentTransform.match(/\(((?:[0-9][,\s]*)+)\)/)) === null || _a === void 0 ? void 0 : _a[0].split(', ') : undefined;
63
+ var currentTranslateX = !values || Number.isNaN(Number(values === null || values === void 0 ? void 0 : values[4])) ? 0 : Number(values === null || values === void 0 ? void 0 : values[4]);
64
+ positionsDiff !== 0 && setTransform("translateX(".concat(currentTranslateX - positionsDiff, "px)"));
55
65
  animationFrameId.current = 0;
56
66
  });
57
- }, [currentElement, animationFrameId, initialTouchPosition]);
67
+ }, [currentElement, animationFrameId, initialTouchPosition, currentTransform]);
58
68
  var handleWindowTouchEnd = React.useCallback(function (e) {
59
69
  var _a;
60
70
 
@@ -93,16 +103,23 @@ function useSwipe(element) {
93
103
  }
94
104
  }, [currentElement, isTransitionMoveStep, initialTouchPosition, animationFrameId]);
95
105
  React.useEffect(function () {
96
- if (isMobile) {
97
- window.addEventListener('touchmove', handleWindowTouchMove);
98
- window.addEventListener('touchend', handleWindowTouchEnd);
106
+ if (!isMobile || !currentElement) {
107
+ return;
99
108
  }
100
109
 
110
+ currentElement.addEventListener('touchmove', handleWindowTouchMove);
111
+ currentElement.addEventListener('touchend', handleWindowTouchEnd);
112
+ /* eslint-disable-next-line consistent-return */
113
+
101
114
  return function () {
102
- window.removeEventListener('touchmove', handleWindowTouchMove);
103
- window.removeEventListener('touchend', handleWindowTouchEnd);
115
+ if (!currentElement) {
116
+ return;
117
+ }
118
+
119
+ currentElement.removeEventListener('touchmove', handleWindowTouchMove);
120
+ currentElement.removeEventListener('touchend', handleWindowTouchEnd);
104
121
  };
105
- }, [isMobile, handleWindowTouchMove, handleWindowTouchEnd]);
122
+ }, [isMobile, handleWindowTouchMove, handleWindowTouchEnd, currentElement]);
106
123
  return {
107
124
  transform: transform,
108
125
  transitionStep: transitionStep
@@ -12,6 +12,7 @@ export declare const PriceBadgeIcon: {
12
12
  readonly CHECK: "check";
13
13
  readonly ATTENTION: "attention";
14
14
  readonly INFO: "info";
15
+ readonly PROFILE: "profile";
15
16
  };
16
17
  export declare const PriseBadgeSize: {
17
18
  readonly SMALL: "small";
@@ -23,6 +23,22 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
23
23
 
24
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
25
25
 
26
+ var ProfileIcon = function ProfileIcon(props) {
27
+ return /*#__PURE__*/React.createElement("svg", (0, _extends2["default"])({
28
+ viewBox: "0 0 20 20"
29
+ }, props), /*#__PURE__*/React.createElement("path", {
30
+ d: "M5.22 18h9.55L16 13.47A8.28 8.28 0 0010 11a8.302 8.302 0 00-6 2.5L5.22 18zM14 6a4 4 0 10-8 0 4 4 0 008 0z"
31
+ }));
32
+ };
33
+
34
+ var ProfileIconBig = function ProfileIconBig(props) {
35
+ return /*#__PURE__*/React.createElement("svg", (0, _extends2["default"])({
36
+ viewBox: "0 0 32 32"
37
+ }, props), /*#__PURE__*/React.createElement("path", {
38
+ d: "M23 28l2-7.43-.32-.31A12.67 12.67 0 0016 17a12.68 12.68 0 00-8.68 3.27l-.32.3L9 28h14zM10 9a6 6 0 1012 0 6 6 0 00-12 0z"
39
+ }));
40
+ };
41
+
26
42
  var AttentionIcon = function AttentionIcon(props) {
27
43
  return /*#__PURE__*/React.createElement("svg", (0, _extends2["default"])({
28
44
  viewBox: "0 0 20 20"
@@ -127,7 +143,8 @@ var PriceBadgeIcon = {
127
143
  PRICE: 'price',
128
144
  CHECK: 'check',
129
145
  ATTENTION: 'attention',
130
- INFO: 'info'
146
+ INFO: 'info',
147
+ PROFILE: 'profile'
131
148
  };
132
149
  exports.PriceBadgeIcon = PriceBadgeIcon;
133
150
  var PriseBadgeSize = {
@@ -155,6 +172,9 @@ var getPriceBadgeIcon = function getPriceBadgeIcon(iconType, size) {
155
172
  case iconType === PriceBadgeIcon.INFO && isBigIcon:
156
173
  return InfoIconBig;
157
174
 
175
+ case iconType === PriceBadgeIcon.PROFILE && isBigIcon:
176
+ return ProfileIconBig;
177
+
158
178
  case iconType === PriceBadgeIcon.PRICE:
159
179
  return PriceIcon;
160
180
 
@@ -167,6 +187,9 @@ var getPriceBadgeIcon = function getPriceBadgeIcon(iconType, size) {
167
187
  case iconType === PriceBadgeIcon.INFO:
168
188
  return InfoIcon;
169
189
 
190
+ case iconType === PriceBadgeIcon.PROFILE:
191
+ return ProfileIcon;
192
+
170
193
  default:
171
194
  return TimerIcon;
172
195
  }
@@ -29,12 +29,12 @@ var _react = _interopRequireDefault(require("react"));
29
29
 
30
30
  var _uiHelpers = require("@megafon/ui-helpers");
31
31
 
32
+ var _Preloader = _interopRequireDefault(require("../Preloader/Preloader"));
33
+
32
34
  var _lodash = _interopRequireDefault(require("lodash.debounce"));
33
35
 
34
36
  var PropTypes = _interopRequireWildcard(require("prop-types"));
35
37
 
36
- var _Preloader = _interopRequireDefault(require("../Preloader/Preloader"));
37
-
38
38
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
39
39
 
40
40
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
@@ -168,11 +168,11 @@ var Search = function Search(_ref) {
168
168
  onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(chosenValue);
169
169
  }, [disabled, items, onSubmit]);
170
170
 
171
- var handleSelectSubmit = _react["default"].useCallback(function () {
171
+ var handleSelectSubmit = _react["default"].useCallback(function (index) {
172
172
  return function () {
173
- handleItemSubmit(activeIndex);
173
+ handleItemSubmit(index);
174
174
  };
175
- }, [handleItemSubmit, activeIndex]);
175
+ }, [handleItemSubmit]);
176
176
 
177
177
  var handleFocus = _react["default"].useCallback(function (e) {
178
178
  setFocus(true);
@@ -155,7 +155,10 @@ var Snackbar = function Snackbar(_ref) {
155
155
  isOpened = _useState2[0],
156
156
  setIsOpened = _useState2[1];
157
157
 
158
- var containerRef = (0, _react.useRef)(null);
158
+ var _useState3 = (0, _react.useState)(null),
159
+ _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
160
+ containerRef = _useState4[0],
161
+ setContainerRef = _useState4[1];
159
162
 
160
163
  var _useSwipe = (0, _useSwipe2["default"])(containerRef),
161
164
  transform = _useSwipe.transform,
@@ -169,6 +172,11 @@ var Snackbar = function Snackbar(_ref) {
169
172
  var isHiddenIcon = isTimerType || !hasIcon && isInfoType;
170
173
  var isCustomIcon = isInfoType && icon;
171
174
  var currentButtonText = buttonText && !isTimerType ? buttonText : defaultSnackbar.buttonText;
175
+
176
+ var setRef = function setRef(instance) {
177
+ return setContainerRef(instance);
178
+ };
179
+
172
180
  var handleClose = (0, _react.useCallback)(function () {
173
181
  setIsOpened(false);
174
182
  }, []);
@@ -218,10 +226,10 @@ var Snackbar = function Snackbar(_ref) {
218
226
  className: cn({
219
227
  move: isTransitionMoveStep
220
228
  }, [className, classes.root]),
221
- ref: containerRef,
222
- style: {
229
+ ref: setRef,
230
+ style: transform !== 'none' ? {
223
231
  transform: transform
224
- }
232
+ } : undefined
225
233
  }, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root)), /*#__PURE__*/_react["default"].createElement(_Tile["default"], {
226
234
  className: cn('tile', {
227
235
  type: type,
@@ -146,24 +146,30 @@
146
146
  box-sizing: border-box;
147
147
  height: 36px;
148
148
  padding: 2px 12px;
149
- color: var(--spbSky3);
149
+ color: var(--content);
150
150
  white-space: nowrap;
151
151
  text-align: center;
152
152
  text-decoration: none;
153
153
  cursor: pointer;
154
154
  -webkit-transition: color 0.3s, fill 0.3s;
155
155
  transition: color 0.3s, fill 0.3s;
156
- fill: var(--spbSky3);
156
+ fill: var(--content);
157
157
  }
158
158
  .mfui-tabs__tab-inner:hover {
159
159
  text-decoration: none;
160
160
  }
161
+ .mfui-tabs__tab-inner:not(.mfui-tabs__tab-inner_current) {
162
+ opacity: 0.8;
163
+ }
161
164
  @media screen and (min-width: 1024px) {
162
165
  .mfui-tabs__tab-inner:not(.mfui-tabs__tab-inner_current):hover {
163
166
  color: var(--content);
164
167
  fill: var(--content);
165
168
  }
166
169
  }
170
+ .mfui-tabs__tab-inner:not(.mfui-tabs__tab-inner_current):hover {
171
+ opacity: 1;
172
+ }
167
173
  .mfui-tabs__tab-inner:not(.mfui-tabs__tab-inner_current):active {
168
174
  color: var(--buttonDown);
169
175
  fill: var(--buttonDown);
@@ -255,11 +261,13 @@
255
261
  background-color: var(--stcBlack20);
256
262
  }
257
263
  .mfui-tabs_tab-color_green:not(.mfui-tabs_sticky) .mfui-tabs__tab-inner:not(.mfui-tabs_tab-color_green:not(.mfui-tabs_sticky) .mfui-tabs__tab-inner_current) {
258
- color: #ffffffb2;
259
- fill: #ffffffb2;
264
+ color: var(--stcWhite);
265
+ opacity: 0.8;
266
+ fill: var(--stcWhite);
260
267
  }
261
268
  .mfui-tabs_tab-color_green:not(.mfui-tabs_sticky) .mfui-tabs__tab-inner:not(.mfui-tabs_tab-color_green:not(.mfui-tabs_sticky) .mfui-tabs__tab-inner_current):hover {
262
269
  color: var(--stcWhite);
270
+ opacity: 1;
263
271
  fill: var(--stcWhite);
264
272
  }
265
273
  .mfui-tabs_tab-color_green:not(.mfui-tabs_sticky) .mfui-tabs__tab-inner_current {
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
1
  export declare enum TransitionSteps {
3
2
  INITIAL_STEP = "initial-step",
4
3
  MOVE_STEP = "move-step",
@@ -10,5 +9,5 @@ declare type UseSwipeReturnType = {
10
9
  /** Текущий этап смахивания элемента */
11
10
  transitionStep: TransitionSteps;
12
11
  };
13
- declare function useSwipe(element: React.MutableRefObject<null>): UseSwipeReturnType;
12
+ declare function useSwipe(element: HTMLElement | null): UseSwipeReturnType;
14
13
  export default useSwipe;
@@ -9,6 +9,16 @@ exports["default"] = exports.TransitionSteps = void 0;
9
9
 
10
10
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
11
 
12
+ require("core-js/modules/es.regexp.exec.js");
13
+
14
+ require("core-js/modules/es.string.match.js");
15
+
16
+ require("core-js/modules/es.string.split.js");
17
+
18
+ require("core-js/modules/es.number.is-nan.js");
19
+
20
+ require("core-js/modules/es.number.constructor.js");
21
+
12
22
  var React = _interopRequireWildcard(require("react"));
13
23
 
14
24
  var _useResolution2 = _interopRequireDefault(require("./useResolution"));
@@ -50,14 +60,17 @@ function useSwipe(element) {
50
60
  setTransform = _React$useState6[1];
51
61
 
52
62
  var animationFrameId = React.useRef(0);
53
- var currentElement = element.current;
63
+ var currentElement = element;
54
64
  var isTransitionMoveStep = transitionStep === TransitionSteps.MOVE_STEP;
65
+ var currentTransform = currentElement ? getComputedStyle(currentElement).transform : '';
55
66
  var handleWindowTouchMove = React.useCallback(function (e) {
56
67
  if (animationFrameId) {
57
68
  window.cancelAnimationFrame(animationFrameId.current);
58
69
  }
59
70
 
60
71
  animationFrameId.current = window.requestAnimationFrame(function () {
72
+ var _a;
73
+
61
74
  setTransitionStep(TransitionSteps.MOVE_STEP);
62
75
 
63
76
  if (!currentElement) {
@@ -70,10 +83,12 @@ function useSwipe(element) {
70
83
  }
71
84
 
72
85
  var positionsDiff = initialTouchPosition - e.touches[0].clientX;
73
- positionsDiff !== 0 && setTransform("translateX(".concat(-positionsDiff, "px)"));
86
+ var values = !!currentTransform && currentTransform !== 'none' ? (_a = currentTransform.match(/\(((?:[0-9][,\s]*)+)\)/)) === null || _a === void 0 ? void 0 : _a[0].split(', ') : undefined;
87
+ var currentTranslateX = !values || Number.isNaN(Number(values === null || values === void 0 ? void 0 : values[4])) ? 0 : Number(values === null || values === void 0 ? void 0 : values[4]);
88
+ positionsDiff !== 0 && setTransform("translateX(".concat(currentTranslateX - positionsDiff, "px)"));
74
89
  animationFrameId.current = 0;
75
90
  });
76
- }, [currentElement, animationFrameId, initialTouchPosition]);
91
+ }, [currentElement, animationFrameId, initialTouchPosition, currentTransform]);
77
92
  var handleWindowTouchEnd = React.useCallback(function (e) {
78
93
  var _a;
79
94
 
@@ -112,16 +127,23 @@ function useSwipe(element) {
112
127
  }
113
128
  }, [currentElement, isTransitionMoveStep, initialTouchPosition, animationFrameId]);
114
129
  React.useEffect(function () {
115
- if (isMobile) {
116
- window.addEventListener('touchmove', handleWindowTouchMove);
117
- window.addEventListener('touchend', handleWindowTouchEnd);
130
+ if (!isMobile || !currentElement) {
131
+ return;
118
132
  }
119
133
 
134
+ currentElement.addEventListener('touchmove', handleWindowTouchMove);
135
+ currentElement.addEventListener('touchend', handleWindowTouchEnd);
136
+ /* eslint-disable-next-line consistent-return */
137
+
120
138
  return function () {
121
- window.removeEventListener('touchmove', handleWindowTouchMove);
122
- window.removeEventListener('touchend', handleWindowTouchEnd);
139
+ if (!currentElement) {
140
+ return;
141
+ }
142
+
143
+ currentElement.removeEventListener('touchmove', handleWindowTouchMove);
144
+ currentElement.removeEventListener('touchend', handleWindowTouchEnd);
123
145
  };
124
- }, [isMobile, handleWindowTouchMove, handleWindowTouchEnd]);
146
+ }, [isMobile, handleWindowTouchMove, handleWindowTouchEnd, currentElement]);
125
147
  return {
126
148
  transform: transform,
127
149
  transitionStep: transitionStep
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@megafon/ui-core",
3
- "version": "5.3.0",
3
+ "version": "5.4.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.14.1",
53
+ "@megafon/ui-icons": "^2.15.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",
@@ -96,5 +96,5 @@
96
96
  "react-popper": "^2.2.3",
97
97
  "swiper": "^6.5.6"
98
98
  },
99
- "gitHead": "0a8f8d140ed863cb8bb9f05e4226edcb7925c74d"
99
+ "gitHead": "d65bc4cd4de9180971e4285c2d0b5beec27d0542"
100
100
  }