@megafon/ui-core 5.4.0 → 5.4.2
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 +24 -0
- package/dist/es/components/Badges/components/PriceBadge/PriceBadge.css +8 -7
- package/dist/es/components/Notification/Notification.d.ts +3 -0
- package/dist/es/components/Notification/Notification.js +16 -9
- package/dist/es/components/Search/Search.d.ts +1 -0
- package/dist/es/components/Search/Search.js +5 -5
- package/dist/es/components/Snackbar/Snackbar.js +13 -5
- package/dist/es/hooks/useSwipe.d.ts +1 -2
- package/dist/es/hooks/useSwipe.js +26 -9
- package/dist/lib/components/Badges/components/PriceBadge/PriceBadge.css +8 -7
- package/dist/lib/components/Notification/Notification.d.ts +3 -0
- package/dist/lib/components/Notification/Notification.js +16 -9
- package/dist/lib/components/Search/Search.d.ts +1 -0
- package/dist/lib/components/Search/Search.js +4 -4
- package/dist/lib/components/Snackbar/Snackbar.js +12 -4
- package/dist/lib/hooks/useSwipe.d.ts +1 -2
- package/dist/lib/hooks/useSwipe.js +31 -9
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,30 @@
|
|
|
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.2](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/compare/@megafon/ui-core@5.4.1...@megafon/ui-core@5.4.2) (2023-12-14)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **notification:** added root ref, link class ([4b6e76c](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/commit/4b6e76cbeee4b17b46f0abae2c73ec879d9201de))
|
|
12
|
+
* **pricebadge:** change font-weight from 400 to 500 ([79e3480](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/commit/79e3480a8f6254101b687db949b3257c2fa00a32))
|
|
13
|
+
* **search:** add extra classes ([2bef678](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/commit/2bef67859c166644194bf39ea380465617e80ad7))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
## [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)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
* **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))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
6
30
|
# [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)
|
|
7
31
|
|
|
8
32
|
|
|
@@ -7,23 +7,24 @@
|
|
|
7
7
|
-webkit-box-align: center;
|
|
8
8
|
-ms-flex-align: center;
|
|
9
9
|
align-items: center;
|
|
10
|
-
padding: 2px;
|
|
11
|
-
padding-right: 8px;
|
|
12
10
|
width: -webkit-fit-content;
|
|
13
11
|
width: -moz-fit-content;
|
|
14
12
|
width: fit-content;
|
|
15
13
|
height: -webkit-fit-content;
|
|
16
14
|
height: -moz-fit-content;
|
|
17
15
|
height: fit-content;
|
|
16
|
+
padding: 2px;
|
|
17
|
+
padding-right: 8px;
|
|
18
18
|
border-radius: 8px;
|
|
19
|
+
font-weight: 500;
|
|
19
20
|
}
|
|
20
21
|
@media screen and (min-width: 1024px) {
|
|
21
22
|
.mfui-price-badge_adaptive {
|
|
22
23
|
font-size: 15px;
|
|
23
24
|
line-height: 24px;
|
|
25
|
+
min-height: 32px;
|
|
24
26
|
padding: 4px;
|
|
25
27
|
padding-right: 8px;
|
|
26
|
-
min-height: 32px;
|
|
27
28
|
border-radius: 12px;
|
|
28
29
|
}
|
|
29
30
|
}
|
|
@@ -64,9 +65,9 @@
|
|
|
64
65
|
fill: var(--fury);
|
|
65
66
|
}
|
|
66
67
|
.mfui-price-badge_size_big {
|
|
68
|
+
padding: 12px 12px 12px 4px;
|
|
67
69
|
font-size: 15px;
|
|
68
70
|
line-height: 18px;
|
|
69
|
-
padding: 12px 12px 12px 4px;
|
|
70
71
|
}
|
|
71
72
|
.mfui-price-badge__text {
|
|
72
73
|
font-family: inherit;
|
|
@@ -78,17 +79,17 @@
|
|
|
78
79
|
display: flex;
|
|
79
80
|
}
|
|
80
81
|
.mfui-price-badge__icon {
|
|
81
|
-
height: 20px;
|
|
82
82
|
width: 20px;
|
|
83
83
|
min-width: 20px;
|
|
84
|
+
height: 20px;
|
|
84
85
|
}
|
|
85
86
|
.mfui-price-badge_size_big .mfui-price-badge__icon {
|
|
86
|
-
height: 32px;
|
|
87
87
|
width: 32px;
|
|
88
88
|
min-width: 32px;
|
|
89
|
+
height: 32px;
|
|
89
90
|
}
|
|
90
91
|
.mfui-price-badge_size_big .mfui-price-badge__sub-title {
|
|
92
|
+
margin-top: 2px;
|
|
91
93
|
font-size: 12px;
|
|
92
94
|
line-height: 18px;
|
|
93
|
-
margin-top: 2px;
|
|
94
95
|
}
|
|
@@ -22,6 +22,7 @@ export interface INotificationProps {
|
|
|
22
22
|
root?: string;
|
|
23
23
|
container?: string;
|
|
24
24
|
content?: string;
|
|
25
|
+
link?: string;
|
|
25
26
|
};
|
|
26
27
|
/** Тип отображения */
|
|
27
28
|
type?: NotificationType;
|
|
@@ -67,6 +68,8 @@ export interface INotificationProps {
|
|
|
67
68
|
button?: Record<string, string>;
|
|
68
69
|
collapseButton?: Record<string, string>;
|
|
69
70
|
};
|
|
71
|
+
/** Ссылка на элемент */
|
|
72
|
+
rootRef?: React.Ref<HTMLDivElement>;
|
|
70
73
|
/** Обработчик на закрытие */
|
|
71
74
|
onClose?: () => void;
|
|
72
75
|
/** Обработчик клика по ссылке */
|
|
@@ -96,6 +96,7 @@ var Notification = function Notification(_ref) {
|
|
|
96
96
|
var rootClass = _ref$classes.root,
|
|
97
97
|
containerClass = _ref$classes.container,
|
|
98
98
|
contentClass = _ref$classes.content,
|
|
99
|
+
linkClass = _ref$classes.link,
|
|
99
100
|
children = _ref.children,
|
|
100
101
|
_ref$type = _ref.type,
|
|
101
102
|
type = _ref$type === void 0 ? 'info' : _ref$type,
|
|
@@ -122,6 +123,7 @@ var Notification = function Notification(_ref) {
|
|
|
122
123
|
href = _ref.href,
|
|
123
124
|
target = _ref.target,
|
|
124
125
|
icon = _ref.icon,
|
|
126
|
+
rootRef = _ref.rootRef,
|
|
125
127
|
dataAttrs = _ref.dataAttrs,
|
|
126
128
|
onClose = _ref.onClose,
|
|
127
129
|
onLinkClick = _ref.onLinkClick,
|
|
@@ -208,7 +210,7 @@ var Notification = function Notification(_ref) {
|
|
|
208
210
|
dataAttrs: {
|
|
209
211
|
root: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.link
|
|
210
212
|
},
|
|
211
|
-
className: cn('link'),
|
|
213
|
+
className: cn('link', [linkClass]),
|
|
212
214
|
onClick: onLinkClick,
|
|
213
215
|
rel: rel,
|
|
214
216
|
href: href,
|
|
@@ -271,18 +273,19 @@ var Notification = function Notification(_ref) {
|
|
|
271
273
|
};
|
|
272
274
|
|
|
273
275
|
return /*#__PURE__*/React.createElement(Tile, {
|
|
274
|
-
dataAttrs: {
|
|
275
|
-
root: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root
|
|
276
|
-
},
|
|
277
|
-
radius: "rounded",
|
|
278
|
-
shadowLevel: shadowLevel,
|
|
279
276
|
className: cn({
|
|
280
277
|
type: type,
|
|
281
278
|
colored: isColored
|
|
282
|
-
}, [className, rootClass])
|
|
279
|
+
}, [className, rootClass]),
|
|
280
|
+
radius: "rounded",
|
|
281
|
+
shadowLevel: shadowLevel,
|
|
282
|
+
dataAttrs: {
|
|
283
|
+
root: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root
|
|
284
|
+
}
|
|
283
285
|
}, /*#__PURE__*/React.createElement("div", {
|
|
284
286
|
"data-testid": "".concat(testIdPrefix, "-container"),
|
|
285
|
-
className: cn('container', [containerClass])
|
|
287
|
+
className: cn('container', [containerClass]),
|
|
288
|
+
ref: rootRef
|
|
286
289
|
}, /*#__PURE__*/React.createElement("div", {
|
|
287
290
|
className: cn('icon-container')
|
|
288
291
|
}, renderIcon()), /*#__PURE__*/React.createElement("div", {
|
|
@@ -326,7 +329,8 @@ Notification.propTypes = {
|
|
|
326
329
|
classes: PropTypes.shape({
|
|
327
330
|
root: PropTypes.string,
|
|
328
331
|
container: PropTypes.string,
|
|
329
|
-
content: PropTypes.string
|
|
332
|
+
content: PropTypes.string,
|
|
333
|
+
link: PropTypes.string
|
|
330
334
|
}),
|
|
331
335
|
shadowLevel: PropTypes.oneOf(Object.values(ShadowTypes)),
|
|
332
336
|
isColored: PropTypes.bool,
|
|
@@ -344,6 +348,9 @@ Notification.propTypes = {
|
|
|
344
348
|
href: PropTypes.string,
|
|
345
349
|
target: PropTypes.oneOf(['_self', '_blank', '_parent', '_top']),
|
|
346
350
|
icon: PropTypes.element,
|
|
351
|
+
rootRef: PropTypes.oneOfType([PropTypes.func, PropTypes.oneOfType([PropTypes.shape({
|
|
352
|
+
current: PropTypes.elementType
|
|
353
|
+
}), PropTypes.any])]),
|
|
347
354
|
dataAttrs: PropTypes.shape({
|
|
348
355
|
root: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
349
356
|
title: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
@@ -11,8 +11,8 @@ import React from 'react';
|
|
|
11
11
|
import { cnCreate, filterDataAttrs } from '@megafon/ui-helpers';
|
|
12
12
|
import debounce from 'lodash.debounce';
|
|
13
13
|
import * as PropTypes from 'prop-types';
|
|
14
|
-
import "./Search.css";
|
|
15
14
|
import Preloader from "../Preloader/Preloader";
|
|
15
|
+
import "./Search.css";
|
|
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(
|
|
136
|
+
handleItemSubmit(index);
|
|
137
137
|
};
|
|
138
|
-
}, [handleItemSubmit
|
|
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);
|
|
@@ -223,7 +223,7 @@ var Search = function Search(_ref) {
|
|
|
223
223
|
var renderSubmitButton = function renderSubmitButton() {
|
|
224
224
|
var Icon = isCompact ? SearchIcon16 : SearchIcon;
|
|
225
225
|
return /*#__PURE__*/React.createElement("button", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.submit), {
|
|
226
|
-
className: cn('submit-button'),
|
|
226
|
+
className: cn('submit-button', [classes === null || classes === void 0 ? void 0 : classes.submitButton]),
|
|
227
227
|
onClick: handleSearchSubmit,
|
|
228
228
|
type: "button"
|
|
229
229
|
}), /*#__PURE__*/React.createElement(Icon, {
|
|
@@ -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,
|
|
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
|
|
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:
|
|
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,
|
|
@@ -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:
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
103
|
-
|
|
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
|
|
@@ -7,23 +7,24 @@
|
|
|
7
7
|
-webkit-box-align: center;
|
|
8
8
|
-ms-flex-align: center;
|
|
9
9
|
align-items: center;
|
|
10
|
-
padding: 2px;
|
|
11
|
-
padding-right: 8px;
|
|
12
10
|
width: -webkit-fit-content;
|
|
13
11
|
width: -moz-fit-content;
|
|
14
12
|
width: fit-content;
|
|
15
13
|
height: -webkit-fit-content;
|
|
16
14
|
height: -moz-fit-content;
|
|
17
15
|
height: fit-content;
|
|
16
|
+
padding: 2px;
|
|
17
|
+
padding-right: 8px;
|
|
18
18
|
border-radius: 8px;
|
|
19
|
+
font-weight: 500;
|
|
19
20
|
}
|
|
20
21
|
@media screen and (min-width: 1024px) {
|
|
21
22
|
.mfui-price-badge_adaptive {
|
|
22
23
|
font-size: 15px;
|
|
23
24
|
line-height: 24px;
|
|
25
|
+
min-height: 32px;
|
|
24
26
|
padding: 4px;
|
|
25
27
|
padding-right: 8px;
|
|
26
|
-
min-height: 32px;
|
|
27
28
|
border-radius: 12px;
|
|
28
29
|
}
|
|
29
30
|
}
|
|
@@ -64,9 +65,9 @@
|
|
|
64
65
|
fill: var(--fury);
|
|
65
66
|
}
|
|
66
67
|
.mfui-price-badge_size_big {
|
|
68
|
+
padding: 12px 12px 12px 4px;
|
|
67
69
|
font-size: 15px;
|
|
68
70
|
line-height: 18px;
|
|
69
|
-
padding: 12px 12px 12px 4px;
|
|
70
71
|
}
|
|
71
72
|
.mfui-price-badge__text {
|
|
72
73
|
font-family: inherit;
|
|
@@ -78,17 +79,17 @@
|
|
|
78
79
|
display: flex;
|
|
79
80
|
}
|
|
80
81
|
.mfui-price-badge__icon {
|
|
81
|
-
height: 20px;
|
|
82
82
|
width: 20px;
|
|
83
83
|
min-width: 20px;
|
|
84
|
+
height: 20px;
|
|
84
85
|
}
|
|
85
86
|
.mfui-price-badge_size_big .mfui-price-badge__icon {
|
|
86
|
-
height: 32px;
|
|
87
87
|
width: 32px;
|
|
88
88
|
min-width: 32px;
|
|
89
|
+
height: 32px;
|
|
89
90
|
}
|
|
90
91
|
.mfui-price-badge_size_big .mfui-price-badge__sub-title {
|
|
92
|
+
margin-top: 2px;
|
|
91
93
|
font-size: 12px;
|
|
92
94
|
line-height: 18px;
|
|
93
|
-
margin-top: 2px;
|
|
94
95
|
}
|
|
@@ -22,6 +22,7 @@ export interface INotificationProps {
|
|
|
22
22
|
root?: string;
|
|
23
23
|
container?: string;
|
|
24
24
|
content?: string;
|
|
25
|
+
link?: string;
|
|
25
26
|
};
|
|
26
27
|
/** Тип отображения */
|
|
27
28
|
type?: NotificationType;
|
|
@@ -67,6 +68,8 @@ export interface INotificationProps {
|
|
|
67
68
|
button?: Record<string, string>;
|
|
68
69
|
collapseButton?: Record<string, string>;
|
|
69
70
|
};
|
|
71
|
+
/** Ссылка на элемент */
|
|
72
|
+
rootRef?: React.Ref<HTMLDivElement>;
|
|
70
73
|
/** Обработчик на закрытие */
|
|
71
74
|
onClose?: () => void;
|
|
72
75
|
/** Обработчик клика по ссылке */
|
|
@@ -121,6 +121,7 @@ var Notification = function Notification(_ref) {
|
|
|
121
121
|
var rootClass = _ref$classes.root,
|
|
122
122
|
containerClass = _ref$classes.container,
|
|
123
123
|
contentClass = _ref$classes.content,
|
|
124
|
+
linkClass = _ref$classes.link,
|
|
124
125
|
children = _ref.children,
|
|
125
126
|
_ref$type = _ref.type,
|
|
126
127
|
type = _ref$type === void 0 ? 'info' : _ref$type,
|
|
@@ -147,6 +148,7 @@ var Notification = function Notification(_ref) {
|
|
|
147
148
|
href = _ref.href,
|
|
148
149
|
target = _ref.target,
|
|
149
150
|
icon = _ref.icon,
|
|
151
|
+
rootRef = _ref.rootRef,
|
|
150
152
|
dataAttrs = _ref.dataAttrs,
|
|
151
153
|
onClose = _ref.onClose,
|
|
152
154
|
onLinkClick = _ref.onLinkClick,
|
|
@@ -233,7 +235,7 @@ var Notification = function Notification(_ref) {
|
|
|
233
235
|
dataAttrs: {
|
|
234
236
|
root: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.link
|
|
235
237
|
},
|
|
236
|
-
className: cn('link'),
|
|
238
|
+
className: cn('link', [linkClass]),
|
|
237
239
|
onClick: onLinkClick,
|
|
238
240
|
rel: rel,
|
|
239
241
|
href: href,
|
|
@@ -296,18 +298,19 @@ var Notification = function Notification(_ref) {
|
|
|
296
298
|
};
|
|
297
299
|
|
|
298
300
|
return /*#__PURE__*/_react["default"].createElement(_Tile["default"], {
|
|
299
|
-
dataAttrs: {
|
|
300
|
-
root: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root
|
|
301
|
-
},
|
|
302
|
-
radius: "rounded",
|
|
303
|
-
shadowLevel: shadowLevel,
|
|
304
301
|
className: cn({
|
|
305
302
|
type: type,
|
|
306
303
|
colored: isColored
|
|
307
|
-
}, [className, rootClass])
|
|
304
|
+
}, [className, rootClass]),
|
|
305
|
+
radius: "rounded",
|
|
306
|
+
shadowLevel: shadowLevel,
|
|
307
|
+
dataAttrs: {
|
|
308
|
+
root: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root
|
|
309
|
+
}
|
|
308
310
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
309
311
|
"data-testid": "".concat(testIdPrefix, "-container"),
|
|
310
|
-
className: cn('container', [containerClass])
|
|
312
|
+
className: cn('container', [containerClass]),
|
|
313
|
+
ref: rootRef
|
|
311
314
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
312
315
|
className: cn('icon-container')
|
|
313
316
|
}, renderIcon()), /*#__PURE__*/_react["default"].createElement("div", {
|
|
@@ -351,7 +354,8 @@ Notification.propTypes = {
|
|
|
351
354
|
classes: PropTypes.shape({
|
|
352
355
|
root: PropTypes.string,
|
|
353
356
|
container: PropTypes.string,
|
|
354
|
-
content: PropTypes.string
|
|
357
|
+
content: PropTypes.string,
|
|
358
|
+
link: PropTypes.string
|
|
355
359
|
}),
|
|
356
360
|
shadowLevel: PropTypes.oneOf(Object.values(ShadowTypes)),
|
|
357
361
|
isColored: PropTypes.bool,
|
|
@@ -369,6 +373,9 @@ Notification.propTypes = {
|
|
|
369
373
|
href: PropTypes.string,
|
|
370
374
|
target: PropTypes.oneOf(['_self', '_blank', '_parent', '_top']),
|
|
371
375
|
icon: PropTypes.element,
|
|
376
|
+
rootRef: PropTypes.oneOfType([PropTypes.func, PropTypes.oneOfType([PropTypes.shape({
|
|
377
|
+
current: PropTypes.elementType
|
|
378
|
+
}), PropTypes.any])]),
|
|
372
379
|
dataAttrs: PropTypes.shape({
|
|
373
380
|
root: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
374
381
|
title: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
@@ -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(
|
|
173
|
+
handleItemSubmit(index);
|
|
174
174
|
};
|
|
175
|
-
}, [handleItemSubmit
|
|
175
|
+
}, [handleItemSubmit]);
|
|
176
176
|
|
|
177
177
|
var handleFocus = _react["default"].useCallback(function (e) {
|
|
178
178
|
setFocus(true);
|
|
@@ -267,7 +267,7 @@ var Search = function Search(_ref) {
|
|
|
267
267
|
var renderSubmitButton = function renderSubmitButton() {
|
|
268
268
|
var Icon = isCompact ? SearchIcon16 : SearchIcon;
|
|
269
269
|
return /*#__PURE__*/_react["default"].createElement("button", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.submit), {
|
|
270
|
-
className: cn('submit-button'),
|
|
270
|
+
className: cn('submit-button', [classes === null || classes === void 0 ? void 0 : classes.submitButton]),
|
|
271
271
|
onClick: handleSearchSubmit,
|
|
272
272
|
type: "button"
|
|
273
273
|
}), /*#__PURE__*/_react["default"].createElement(Icon, {
|
|
@@ -155,7 +155,10 @@ var Snackbar = function Snackbar(_ref) {
|
|
|
155
155
|
isOpened = _useState2[0],
|
|
156
156
|
setIsOpened = _useState2[1];
|
|
157
157
|
|
|
158
|
-
var
|
|
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:
|
|
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,
|
|
@@ -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:
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
122
|
-
|
|
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.4.
|
|
3
|
+
"version": "5.4.2",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist",
|
|
6
6
|
"styles"
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@babel/preset-env": "^7.8.6",
|
|
51
51
|
"@babel/preset-react": "^7.8.3",
|
|
52
52
|
"@babel/preset-typescript": "^7.8.3",
|
|
53
|
-
"@megafon/ui-icons": "^2.
|
|
53
|
+
"@megafon/ui-icons": "^2.16.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",
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"dependencies": {
|
|
86
86
|
"@babel/runtime": "^7.8.4",
|
|
87
87
|
"@datepicker-react/hooks": "^2.7.0",
|
|
88
|
-
"@megafon/ui-helpers": "^2.5.
|
|
88
|
+
"@megafon/ui-helpers": "^2.5.4",
|
|
89
89
|
"@popperjs/core": "^2.5.3",
|
|
90
90
|
"core-js": "^3.6.4",
|
|
91
91
|
"date-fns": "^2.16.1",
|
|
@@ -96,5 +96,5 @@
|
|
|
96
96
|
"react-popper": "^2.2.3",
|
|
97
97
|
"swiper": "^6.5.6"
|
|
98
98
|
},
|
|
99
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "18cb80b0ac6513b2ad8f31167461aefbb226a6c2"
|
|
100
100
|
}
|