@megafon/ui-core 5.4.6 → 5.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/dist/es/components/Button/Button.css +65 -21
- package/dist/es/components/Calendar/Calendar.js +3 -1
- package/dist/es/components/Calendar/components/Month/Month.js +1 -1
- package/dist/es/components/Chip/Chip.css +111 -0
- package/dist/es/components/Chip/Chip.d.ts +36 -0
- package/dist/es/components/Chip/Chip.js +61 -0
- package/dist/es/components/Search/Search.css +56 -4
- package/dist/es/components/Search/Search.d.ts +22 -0
- package/dist/es/components/Search/Search.js +170 -22
- package/dist/es/components/Tabs/Tabs.d.ts +1 -0
- package/dist/es/components/Tabs/Tabs.js +4 -3
- package/dist/es/hooks/useSwipe.js +47 -22
- package/dist/es/index.d.ts +1 -0
- package/dist/es/index.js +1 -0
- package/dist/lib/components/Button/Button.css +65 -21
- package/dist/lib/components/Calendar/Calendar.js +3 -1
- package/dist/lib/components/Chip/Chip.css +111 -0
- package/dist/lib/components/Chip/Chip.d.ts +36 -0
- package/dist/lib/components/Chip/Chip.js +82 -0
- package/dist/lib/components/Search/Search.css +56 -4
- package/dist/lib/components/Search/Search.d.ts +22 -0
- package/dist/lib/components/Search/Search.js +179 -22
- package/dist/lib/components/Tabs/Tabs.d.ts +1 -0
- package/dist/lib/components/Tabs/Tabs.js +4 -3
- package/dist/lib/hooks/useSwipe.js +47 -22
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.js +8 -0
- package/package.json +2 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
+
import "core-js/modules/es.array.slice.js";
|
|
3
4
|
import "core-js/modules/es.regexp.exec.js";
|
|
4
5
|
import "core-js/modules/es.string.replace.js";
|
|
5
6
|
import "core-js/modules/es.string.split.js";
|
|
@@ -11,6 +12,8 @@ import React from 'react';
|
|
|
11
12
|
import { cnCreate, filterDataAttrs } from '@megafon/ui-helpers';
|
|
12
13
|
import debounce from 'lodash.debounce';
|
|
13
14
|
import * as PropTypes from 'prop-types';
|
|
15
|
+
import Caption from "../Caption/Caption";
|
|
16
|
+
import Header from "../Header/Header";
|
|
14
17
|
import Preloader from "../Preloader/Preloader";
|
|
15
18
|
import "./Search.css";
|
|
16
19
|
|
|
@@ -40,6 +43,7 @@ var ClearIcon = function ClearIcon(props) {
|
|
|
40
43
|
};
|
|
41
44
|
|
|
42
45
|
var SEARCH_QUERY_REGEX = /[^A-Z-a-zА-ЯЁа-яё0-9]/g;
|
|
46
|
+
var MAX_POPULAR_ITEMS_LENGTH = 5;
|
|
43
47
|
export var Verification = {
|
|
44
48
|
VALID: 'valid',
|
|
45
49
|
ERROR: 'error'
|
|
@@ -72,10 +76,16 @@ var Search = function Search(_ref) {
|
|
|
72
76
|
_ref$type = _ref.type,
|
|
73
77
|
type = _ref$type === void 0 ? 'textfield' : _ref$type,
|
|
74
78
|
showLoader = _ref.showLoader,
|
|
79
|
+
showNotFound = _ref.showNotFound,
|
|
80
|
+
textNotFound = _ref.textNotFound,
|
|
81
|
+
_ref$popularItems = _ref.popularItems,
|
|
82
|
+
popularItems = _ref$popularItems === void 0 ? [] : _ref$popularItems,
|
|
83
|
+
popularTitle = _ref.popularTitle,
|
|
75
84
|
onChange = _ref.onChange,
|
|
76
85
|
onSubmit = _ref.onSubmit,
|
|
77
86
|
onBlur = _ref.onBlur,
|
|
78
|
-
onFocus = _ref.onFocus
|
|
87
|
+
onFocus = _ref.onFocus,
|
|
88
|
+
onPopularItemClick = _ref.onPopularItemClick;
|
|
79
89
|
|
|
80
90
|
var _React$useState = React.useState(value),
|
|
81
91
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
@@ -92,15 +102,24 @@ var Search = function Search(_ref) {
|
|
|
92
102
|
isFocused = _React$useState6[0],
|
|
93
103
|
setFocus = _React$useState6[1];
|
|
94
104
|
|
|
105
|
+
var _React$useState7 = React.useState(-1),
|
|
106
|
+
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
107
|
+
popularActiveIndex = _React$useState8[0],
|
|
108
|
+
setPopularActiveIndex = _React$useState8[1];
|
|
109
|
+
|
|
95
110
|
var debouncedOnChange = React.useRef(debounce(function (inputValue) {
|
|
96
111
|
return onChange && onChange(inputValue);
|
|
97
112
|
}, changeDelay));
|
|
98
113
|
var highlightedItem = React.useRef(null);
|
|
99
114
|
var fieldNode = React.useRef(null);
|
|
115
|
+
var correctPopularItems = React.useMemo(function () {
|
|
116
|
+
return popularItems.slice(0, MAX_POPULAR_ITEMS_LENGTH);
|
|
117
|
+
}, [popularItems]);
|
|
100
118
|
var isCompact = type === 'compact';
|
|
101
119
|
var showClearIcon = isCompact && !!searchQuery;
|
|
102
120
|
var showTextFieldSubmit = !hideIcon && !isCompact && !showLoader;
|
|
103
121
|
var showAdditionalElement = !hideIcon || showLoader || showClearIcon;
|
|
122
|
+
var showPopularItems = !!correctPopularItems.length;
|
|
104
123
|
var handleChange = React.useCallback(function (e) {
|
|
105
124
|
var _e$target$value = e.target.value,
|
|
106
125
|
inputValue = _e$target$value === void 0 ? '' : _e$target$value;
|
|
@@ -120,6 +139,11 @@ var Search = function Search(_ref) {
|
|
|
120
139
|
setActiveIndex(index);
|
|
121
140
|
};
|
|
122
141
|
}, []);
|
|
142
|
+
var handlePopularItemHover = React.useCallback(function (index) {
|
|
143
|
+
return function () {
|
|
144
|
+
setPopularActiveIndex(index);
|
|
145
|
+
};
|
|
146
|
+
}, []);
|
|
123
147
|
var handleSearchSubmit = React.useCallback(function () {
|
|
124
148
|
onSubmit && searchQuery && onSubmit(searchQuery);
|
|
125
149
|
}, [searchQuery, onSubmit]);
|
|
@@ -149,26 +173,90 @@ var Search = function Search(_ref) {
|
|
|
149
173
|
setActiveIndex(-1);
|
|
150
174
|
}
|
|
151
175
|
}, [activeIndex]);
|
|
152
|
-
var
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
176
|
+
var handlePopularItemMouseDown = React.useCallback(function (e) {
|
|
177
|
+
e.preventDefault();
|
|
178
|
+
}, []);
|
|
179
|
+
var handlePopularItemMouseUp = React.useCallback(function () {
|
|
180
|
+
var _a;
|
|
181
|
+
|
|
182
|
+
var chosenValue = popularItems[popularActiveIndex].title;
|
|
183
|
+
(_a = fieldNode === null || fieldNode === void 0 ? void 0 : fieldNode.current) === null || _a === void 0 ? void 0 : _a.blur();
|
|
184
|
+
onPopularItemClick === null || onPopularItemClick === void 0 ? void 0 : onPopularItemClick(chosenValue);
|
|
185
|
+
}, [onPopularItemClick, popularActiveIndex, popularItems]);
|
|
186
|
+
var handleKeyDownPopularItems = React.useCallback(function (e) {
|
|
187
|
+
var _a;
|
|
188
|
+
|
|
189
|
+
switch (true) {
|
|
190
|
+
case e.key === 'ArrowDown' && popularActiveIndex < popularItems.length - 1:
|
|
191
|
+
setPopularActiveIndex(function (index) {
|
|
192
|
+
return index + 1;
|
|
193
|
+
});
|
|
194
|
+
e.preventDefault();
|
|
195
|
+
break;
|
|
196
|
+
|
|
197
|
+
case e.key === 'ArrowUp' && popularActiveIndex > -1:
|
|
198
|
+
setPopularActiveIndex(function (index) {
|
|
199
|
+
return index - 1;
|
|
200
|
+
});
|
|
201
|
+
e.preventDefault();
|
|
202
|
+
break;
|
|
203
|
+
|
|
204
|
+
case e.key === 'Enter' && popularActiveIndex > -1:
|
|
205
|
+
{
|
|
206
|
+
var currentHref = (_a = popularItems[popularActiveIndex]) === null || _a === void 0 ? void 0 : _a.href;
|
|
207
|
+
handlePopularItemMouseUp();
|
|
208
|
+
|
|
209
|
+
if (currentHref) {
|
|
210
|
+
window.location.href = currentHref;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
default:
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return false;
|
|
221
|
+
}, [popularActiveIndex, popularItems, handlePopularItemMouseUp]);
|
|
222
|
+
var handleKeyDownItems = React.useCallback(function (e) {
|
|
223
|
+
switch (true) {
|
|
224
|
+
case e.key === 'ArrowDown' && activeIndex < items.length - 1:
|
|
225
|
+
setActiveIndex(function (index) {
|
|
226
|
+
return index + 1;
|
|
227
|
+
});
|
|
228
|
+
e.preventDefault();
|
|
229
|
+
break;
|
|
230
|
+
|
|
231
|
+
case e.key === 'ArrowUp' && activeIndex > -1:
|
|
232
|
+
setActiveIndex(function (index) {
|
|
233
|
+
return index - 1;
|
|
234
|
+
});
|
|
235
|
+
e.preventDefault();
|
|
236
|
+
break;
|
|
237
|
+
|
|
238
|
+
case e.key === 'Enter' && activeIndex > -1:
|
|
239
|
+
handleItemSubmit(activeIndex);
|
|
240
|
+
e.preventDefault();
|
|
241
|
+
break;
|
|
242
|
+
|
|
243
|
+
case e.key === 'Enter' && activeIndex === -1:
|
|
244
|
+
handleSearchSubmit();
|
|
245
|
+
break;
|
|
246
|
+
|
|
247
|
+
default:
|
|
248
|
+
break;
|
|
168
249
|
}
|
|
169
250
|
|
|
170
251
|
return false;
|
|
171
|
-
}, [activeIndex,
|
|
252
|
+
}, [activeIndex, handleItemSubmit, handleSearchSubmit, items.length]);
|
|
253
|
+
var handleKeyDown = React.useCallback(function (e) {
|
|
254
|
+
if (showNotFound && showPopularItems) {
|
|
255
|
+
return handleKeyDownPopularItems(e);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
return handleKeyDownItems(e);
|
|
259
|
+
}, [handleKeyDownItems, handleKeyDownPopularItems, showNotFound, showPopularItems]);
|
|
172
260
|
|
|
173
261
|
var handleClearClick = function handleClearClick() {
|
|
174
262
|
var _a; // TODO: После обновления TS до 4 версии, установить @types/lodash.debounce и убрать disable
|
|
@@ -266,6 +354,53 @@ var Search = function Search(_ref) {
|
|
|
266
354
|
})));
|
|
267
355
|
};
|
|
268
356
|
|
|
357
|
+
var renderPopularItems = function renderPopularItems() {
|
|
358
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
359
|
+
className: cn('popular-list')
|
|
360
|
+
}, correctPopularItems.map(function (_ref3, i) {
|
|
361
|
+
var title = _ref3.title,
|
|
362
|
+
href = _ref3.href,
|
|
363
|
+
icon = _ref3.icon;
|
|
364
|
+
var Elem = href ? 'a' : 'div';
|
|
365
|
+
return /*#__PURE__*/React.createElement(Elem, _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.popularItem, i + 1), {
|
|
366
|
+
className: cn('popular-item', {
|
|
367
|
+
active: popularActiveIndex === i
|
|
368
|
+
}, [classes === null || classes === void 0 ? void 0 : classes.popularItem]),
|
|
369
|
+
key: i,
|
|
370
|
+
href: href,
|
|
371
|
+
onMouseDown: handlePopularItemMouseDown,
|
|
372
|
+
onMouseUp: handlePopularItemMouseUp,
|
|
373
|
+
onMouseEnter: handlePopularItemHover(i)
|
|
374
|
+
}), icon && /*#__PURE__*/React.createElement("span", {
|
|
375
|
+
className: cn('popular-icon')
|
|
376
|
+
}, icon), /*#__PURE__*/React.createElement(Header, {
|
|
377
|
+
className: cn('popular-item-title'),
|
|
378
|
+
as: "h5"
|
|
379
|
+
}, title));
|
|
380
|
+
}));
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
var renderNotFound = function renderNotFound() {
|
|
384
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
385
|
+
className: cn('list', {
|
|
386
|
+
'not-found': true
|
|
387
|
+
})
|
|
388
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
389
|
+
className: cn('list-inner')
|
|
390
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
391
|
+
className: cn('not-found-text', {
|
|
392
|
+
'show-popular': showPopularItems
|
|
393
|
+
}, [classes === null || classes === void 0 ? void 0 : classes.textNotFound])
|
|
394
|
+
}, textNotFound || 'Ничего не нашлось'), showPopularItems && /*#__PURE__*/React.createElement("div", {
|
|
395
|
+
className: cn('popular-wrap')
|
|
396
|
+
}, /*#__PURE__*/React.createElement(Caption, {
|
|
397
|
+
className: cn('popular-title', [classes === null || classes === void 0 ? void 0 : classes.popularTitle]),
|
|
398
|
+
variant: "medium",
|
|
399
|
+
color: "gray",
|
|
400
|
+
hasMargin: false
|
|
401
|
+
}, popularTitle || 'Популярные действия'), renderPopularItems())));
|
|
402
|
+
};
|
|
403
|
+
|
|
269
404
|
return /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
|
|
270
405
|
className: cn({
|
|
271
406
|
open: isFocused,
|
|
@@ -304,7 +439,7 @@ var Search = function Search(_ref) {
|
|
|
304
439
|
delay: false,
|
|
305
440
|
className: cn('loader'),
|
|
306
441
|
sizeAll: "small"
|
|
307
|
-
}), showClearIcon && renderClearButton()), !!items.length && renderList()), noticeText && /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.notice), {
|
|
442
|
+
}), showClearIcon && renderClearButton()), !!items.length && !showNotFound && renderList(), showNotFound && renderNotFound()), noticeText && /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.notice), {
|
|
308
443
|
className: cn('notice', {
|
|
309
444
|
error: verification === Verification.ERROR,
|
|
310
445
|
success: verification === Verification.VALID
|
|
@@ -320,7 +455,8 @@ Search.propTypes = {
|
|
|
320
455
|
submit: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
321
456
|
item: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
322
457
|
itemTitle: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
323
|
-
notice: PropTypes.objectOf(PropTypes.string.isRequired)
|
|
458
|
+
notice: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
459
|
+
popularItem: PropTypes.objectOf(PropTypes.string.isRequired)
|
|
324
460
|
}),
|
|
325
461
|
value: PropTypes.string,
|
|
326
462
|
label: PropTypes.string,
|
|
@@ -343,11 +479,23 @@ Search.propTypes = {
|
|
|
343
479
|
input: PropTypes.string,
|
|
344
480
|
listItemTitle: PropTypes.string,
|
|
345
481
|
control: PropTypes.string,
|
|
346
|
-
icon: PropTypes.string
|
|
482
|
+
icon: PropTypes.string,
|
|
483
|
+
textNotFound: PropTypes.string,
|
|
484
|
+
popularTitle: PropTypes.string,
|
|
485
|
+
popularItem: PropTypes.string
|
|
347
486
|
}),
|
|
487
|
+
showNotFound: PropTypes.bool,
|
|
488
|
+
textNotFound: PropTypes.string,
|
|
489
|
+
popularItems: PropTypes.arrayOf(PropTypes.shape({
|
|
490
|
+
title: PropTypes.string.isRequired,
|
|
491
|
+
href: PropTypes.string,
|
|
492
|
+
icon: PropTypes.element
|
|
493
|
+
}).isRequired),
|
|
494
|
+
popularTitle: PropTypes.string,
|
|
348
495
|
onChange: PropTypes.func,
|
|
349
496
|
onSubmit: PropTypes.func,
|
|
350
497
|
onBlur: PropTypes.func,
|
|
351
|
-
onFocus: PropTypes.func
|
|
498
|
+
onFocus: PropTypes.func,
|
|
499
|
+
onPopularItemClick: PropTypes.func
|
|
352
500
|
};
|
|
353
501
|
export default Search;
|
|
@@ -329,10 +329,10 @@ var Tabs = function Tabs(_ref) {
|
|
|
329
329
|
return /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.panel, i + 1), {
|
|
330
330
|
className: cn('panel', {
|
|
331
331
|
current: isCurrentPanel
|
|
332
|
-
})
|
|
332
|
+
}, [classes === null || classes === void 0 ? void 0 : classes.panel])
|
|
333
333
|
}), panel);
|
|
334
334
|
});
|
|
335
|
-
}, [children, currentIndex, dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.panel, renderOnlyCurrentPanel]);
|
|
335
|
+
}, [children, currentIndex, dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.panel, renderOnlyCurrentPanel, classes === null || classes === void 0 ? void 0 : classes.panel]);
|
|
336
336
|
React.useEffect(function () {
|
|
337
337
|
if (!sticky) {
|
|
338
338
|
return undefined;
|
|
@@ -459,7 +459,8 @@ Tabs.propTypes = {
|
|
|
459
459
|
swiperWrapper: PropTypes.string,
|
|
460
460
|
innerIndents: PropTypes.string,
|
|
461
461
|
tab: PropTypes.string,
|
|
462
|
-
activeTab: PropTypes.string
|
|
462
|
+
activeTab: PropTypes.string,
|
|
463
|
+
panel: PropTypes.string
|
|
463
464
|
}),
|
|
464
465
|
dataAttrs: PropTypes.shape({
|
|
465
466
|
root: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
@@ -22,18 +22,23 @@ function useSwipe(element) {
|
|
|
22
22
|
|
|
23
23
|
var _React$useState = React.useState(null),
|
|
24
24
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
initialTouchPositionX = _React$useState2[0],
|
|
26
|
+
setInitialTouchPositionX = _React$useState2[1];
|
|
27
27
|
|
|
28
|
-
var _React$useState3 = React.useState(
|
|
28
|
+
var _React$useState3 = React.useState(null),
|
|
29
29
|
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
initialTouchPositionY = _React$useState4[0],
|
|
31
|
+
setInitialTouchPositionY = _React$useState4[1];
|
|
32
32
|
|
|
33
|
-
var _React$useState5 = React.useState(
|
|
33
|
+
var _React$useState5 = React.useState(TransitionSteps.INITIAL_STEP),
|
|
34
34
|
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
transitionStep = _React$useState6[0],
|
|
36
|
+
setTransitionStep = _React$useState6[1];
|
|
37
|
+
|
|
38
|
+
var _React$useState7 = React.useState(''),
|
|
39
|
+
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
40
|
+
transform = _React$useState8[0],
|
|
41
|
+
setTransform = _React$useState8[1];
|
|
37
42
|
|
|
38
43
|
var animationFrameId = React.useRef(0);
|
|
39
44
|
var currentElement = element;
|
|
@@ -47,38 +52,58 @@ function useSwipe(element) {
|
|
|
47
52
|
animationFrameId.current = window.requestAnimationFrame(function () {
|
|
48
53
|
var _a;
|
|
49
54
|
|
|
50
|
-
|
|
55
|
+
if (!initialTouchPositionY) {
|
|
56
|
+
setInitialTouchPositionY(e.touches[0].clientY);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
51
59
|
|
|
52
|
-
if (!
|
|
60
|
+
if (!initialTouchPositionX) {
|
|
61
|
+
setInitialTouchPositionX(e.touches[0].clientX);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
var positionsDiffX = initialTouchPositionX - e.touches[0].clientX;
|
|
66
|
+
var positionsDiffY = initialTouchPositionY - e.touches[0].clientY;
|
|
67
|
+
|
|
68
|
+
if (Math.abs(positionsDiffY) > Math.abs(positionsDiffX)) {
|
|
53
69
|
return;
|
|
54
70
|
}
|
|
55
71
|
|
|
56
|
-
|
|
57
|
-
|
|
72
|
+
setTransitionStep(TransitionSteps.MOVE_STEP);
|
|
73
|
+
|
|
74
|
+
if (!currentElement) {
|
|
58
75
|
return;
|
|
59
76
|
}
|
|
60
77
|
|
|
61
|
-
var positionsDiff =
|
|
78
|
+
var positionsDiff = initialTouchPositionX - e.touches[0].clientX;
|
|
62
79
|
var values = !!currentTransform && currentTransform !== 'none' ? (_a = currentTransform.match(/\(((?:[0-9][,\s]*)+)\)/)) === null || _a === void 0 ? void 0 : _a[0].split(', ') : undefined;
|
|
63
80
|
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
81
|
positionsDiff !== 0 && setTransform("translateX(".concat(currentTranslateX - positionsDiff, "px)"));
|
|
65
82
|
animationFrameId.current = 0;
|
|
66
83
|
});
|
|
67
|
-
}, [
|
|
84
|
+
}, [initialTouchPositionX, initialTouchPositionY, currentElement, currentTransform]);
|
|
68
85
|
var handleWindowTouchEnd = React.useCallback(function (e) {
|
|
69
|
-
var _a;
|
|
86
|
+
var _a, _b;
|
|
70
87
|
|
|
71
|
-
if (!currentElement || !isTransitionMoveStep || !
|
|
88
|
+
if (!currentElement || !isTransitionMoveStep || !initialTouchPositionX || !initialTouchPositionY) {
|
|
72
89
|
return;
|
|
73
90
|
}
|
|
74
91
|
|
|
75
92
|
window.cancelAnimationFrame(animationFrameId.current);
|
|
93
|
+
var touchPositionY = (_a = e.changedTouches[0]) === null || _a === void 0 ? void 0 : _a.clientY;
|
|
94
|
+
var touchPositionX = (_b = e.changedTouches[0]) === null || _b === void 0 ? void 0 : _b.clientX;
|
|
95
|
+
|
|
96
|
+
if (Math.abs(touchPositionY - initialTouchPositionY) > Math.abs(touchPositionX - initialTouchPositionX)) {
|
|
97
|
+
setInitialTouchPositionX(null);
|
|
98
|
+
setInitialTouchPositionY(null);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
76
102
|
var windowCenterPosition = window.innerWidth / 2;
|
|
77
|
-
var
|
|
78
|
-
var
|
|
79
|
-
var
|
|
80
|
-
|
|
81
|
-
setInitialTouchPosition(null);
|
|
103
|
+
var isRightSwipe = touchPositionX > initialTouchPositionX;
|
|
104
|
+
var isLeftSwipe = touchPositionX < initialTouchPositionX;
|
|
105
|
+
var isMoreHalfSwiped = Math.abs(initialTouchPositionX - touchPositionX) > windowCenterPosition;
|
|
106
|
+
setInitialTouchPositionX(null);
|
|
82
107
|
|
|
83
108
|
switch (true) {
|
|
84
109
|
case isMoreHalfSwiped && isRightSwipe:
|
|
@@ -101,7 +126,7 @@ function useSwipe(element) {
|
|
|
101
126
|
setTransitionStep(TransitionSteps.INITIAL_STEP);
|
|
102
127
|
}
|
|
103
128
|
}
|
|
104
|
-
}, [currentElement, isTransitionMoveStep,
|
|
129
|
+
}, [currentElement, isTransitionMoveStep, initialTouchPositionX, initialTouchPositionY]);
|
|
105
130
|
React.useEffect(function () {
|
|
106
131
|
if (!isMobile || !currentElement) {
|
|
107
132
|
return;
|
package/dist/es/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export { default as Caption } from './components/Caption/Caption';
|
|
|
7
7
|
export { default as Carousel } from './components/Carousel/Carousel';
|
|
8
8
|
export { default as Checkbox } from './components/Checkbox/Checkbox';
|
|
9
9
|
export { default as checkBreakpointsPropTypes } from './components/Carousel/checkBreakpointsPropTypes';
|
|
10
|
+
export { default as Chip } from './components/Chip/Chip';
|
|
10
11
|
export { default as Collapse } from './components/Collapse/Collapse';
|
|
11
12
|
export { default as ContentArea } from './components/ContentArea/ContentArea';
|
|
12
13
|
export { default as Counter } from './components/Counter/Counter';
|
package/dist/es/index.js
CHANGED
|
@@ -7,6 +7,7 @@ export { default as Caption } from "./components/Caption/Caption";
|
|
|
7
7
|
export { default as Carousel } from "./components/Carousel/Carousel";
|
|
8
8
|
export { default as Checkbox } from "./components/Checkbox/Checkbox";
|
|
9
9
|
export { default as checkBreakpointsPropTypes } from "./components/Carousel/checkBreakpointsPropTypes";
|
|
10
|
+
export { default as Chip } from "./components/Chip/Chip";
|
|
10
11
|
export { default as Collapse } from "./components/Collapse/Collapse";
|
|
11
12
|
export { default as ContentArea } from "./components/ContentArea/ContentArea";
|
|
12
13
|
export { default as Counter } from "./components/Counter/Counter";
|
|
@@ -40,10 +40,14 @@
|
|
|
40
40
|
line-height: 14px;
|
|
41
41
|
}
|
|
42
42
|
.mfui-button_size-all_extra-small .mfui-button__icon,
|
|
43
|
-
.mfui-button_size-all_extra-small .mfui-button__icon-arrow
|
|
43
|
+
.mfui-button_size-all_extra-small .mfui-button__icon-arrow,
|
|
44
|
+
.mfui-button_size-all_extra-small.mfui-button_content-type_icon-text .mfui-button__icon {
|
|
44
45
|
width: 20px;
|
|
45
46
|
height: 20px;
|
|
46
47
|
}
|
|
48
|
+
.mfui-button_size-all_extra-small.mfui-button_content-type_icon-text .mfui-button__icon {
|
|
49
|
+
margin-right: 2px;
|
|
50
|
+
}
|
|
47
51
|
.mfui-button_size-all_small {
|
|
48
52
|
min-width: 40px;
|
|
49
53
|
height: 40px;
|
|
@@ -54,12 +58,17 @@
|
|
|
54
58
|
width: 20px;
|
|
55
59
|
height: 20px;
|
|
56
60
|
}
|
|
61
|
+
.mfui-button_size-all_small.mfui-button_content-type_icon-text .mfui-button__icon {
|
|
62
|
+
width: 32px;
|
|
63
|
+
height: 32px;
|
|
64
|
+
}
|
|
57
65
|
.mfui-button_size-all_medium {
|
|
58
66
|
min-width: 52px;
|
|
59
67
|
height: 52px;
|
|
60
68
|
}
|
|
61
69
|
.mfui-button_size-all_medium .mfui-button__icon,
|
|
62
|
-
.mfui-button_size-all_medium .mfui-button__icon-arrow
|
|
70
|
+
.mfui-button_size-all_medium .mfui-button__icon-arrow,
|
|
71
|
+
.mfui-button_size-all_medium.mfui-button_content-type_icon-text .mfui-button__icon {
|
|
63
72
|
width: 32px;
|
|
64
73
|
height: 32px;
|
|
65
74
|
}
|
|
@@ -68,7 +77,8 @@
|
|
|
68
77
|
height: 60px;
|
|
69
78
|
}
|
|
70
79
|
.mfui-button_size-all_large .mfui-button__icon,
|
|
71
|
-
.mfui-button_size-all_large .mfui-button__icon-arrow
|
|
80
|
+
.mfui-button_size-all_large .mfui-button__icon-arrow,
|
|
81
|
+
.mfui-button_size-all_large.mfui-button_content-type_icon-text .mfui-button__icon {
|
|
72
82
|
width: 32px;
|
|
73
83
|
height: 32px;
|
|
74
84
|
}
|
|
@@ -99,10 +109,14 @@
|
|
|
99
109
|
line-height: 14px;
|
|
100
110
|
}
|
|
101
111
|
.mfui-button_size-desktop_extra-small .mfui-button__icon,
|
|
102
|
-
.mfui-button_size-desktop_extra-small .mfui-button__icon-arrow
|
|
112
|
+
.mfui-button_size-desktop_extra-small .mfui-button__icon-arrow,
|
|
113
|
+
.mfui-button_size-desktop_extra-small.mfui-button_content-type_icon-text .mfui-button__icon {
|
|
103
114
|
width: 20px;
|
|
104
115
|
height: 20px;
|
|
105
116
|
}
|
|
117
|
+
.mfui-button_size-desktop_extra-small.mfui-button_content-type_icon-text .mfui-button__icon {
|
|
118
|
+
margin-right: 2px;
|
|
119
|
+
}
|
|
106
120
|
.mfui-button_size-desktop_small {
|
|
107
121
|
min-width: 40px;
|
|
108
122
|
height: 40px;
|
|
@@ -113,12 +127,17 @@
|
|
|
113
127
|
width: 20px;
|
|
114
128
|
height: 20px;
|
|
115
129
|
}
|
|
130
|
+
.mfui-button_size-desktop_small.mfui-button_content-type_icon-text .mfui-button__icon {
|
|
131
|
+
width: 32px;
|
|
132
|
+
height: 32px;
|
|
133
|
+
}
|
|
116
134
|
.mfui-button_size-desktop_medium {
|
|
117
135
|
min-width: 52px;
|
|
118
136
|
height: 52px;
|
|
119
137
|
}
|
|
120
138
|
.mfui-button_size-desktop_medium .mfui-button__icon,
|
|
121
|
-
.mfui-button_size-desktop_medium .mfui-button__icon-arrow
|
|
139
|
+
.mfui-button_size-desktop_medium .mfui-button__icon-arrow,
|
|
140
|
+
.mfui-button_size-desktop_medium.mfui-button_content-type_icon-text .mfui-button__icon {
|
|
122
141
|
width: 32px;
|
|
123
142
|
height: 32px;
|
|
124
143
|
}
|
|
@@ -127,7 +146,8 @@
|
|
|
127
146
|
height: 60px;
|
|
128
147
|
}
|
|
129
148
|
.mfui-button_size-desktop_large .mfui-button__icon,
|
|
130
|
-
.mfui-button_size-desktop_large .mfui-button__icon-arrow
|
|
149
|
+
.mfui-button_size-desktop_large .mfui-button__icon-arrow,
|
|
150
|
+
.mfui-button_size-desktop_large.mfui-button_content-type_icon-text .mfui-button__icon {
|
|
131
151
|
width: 32px;
|
|
132
152
|
height: 32px;
|
|
133
153
|
}
|
|
@@ -159,10 +179,14 @@
|
|
|
159
179
|
line-height: 14px;
|
|
160
180
|
}
|
|
161
181
|
.mfui-button_size-wide_extra-small .mfui-button__icon,
|
|
162
|
-
.mfui-button_size-wide_extra-small .mfui-button__icon-arrow
|
|
182
|
+
.mfui-button_size-wide_extra-small .mfui-button__icon-arrow,
|
|
183
|
+
.mfui-button_size-wide_extra-small.mfui-button_content-type_icon-text .mfui-button__icon {
|
|
163
184
|
width: 20px;
|
|
164
185
|
height: 20px;
|
|
165
186
|
}
|
|
187
|
+
.mfui-button_size-wide_extra-small.mfui-button_content-type_icon-text .mfui-button__icon {
|
|
188
|
+
margin-right: 2px;
|
|
189
|
+
}
|
|
166
190
|
.mfui-button_size-wide_small {
|
|
167
191
|
min-width: 40px;
|
|
168
192
|
height: 40px;
|
|
@@ -173,12 +197,17 @@
|
|
|
173
197
|
width: 20px;
|
|
174
198
|
height: 20px;
|
|
175
199
|
}
|
|
200
|
+
.mfui-button_size-wide_small.mfui-button_content-type_icon-text .mfui-button__icon {
|
|
201
|
+
width: 32px;
|
|
202
|
+
height: 32px;
|
|
203
|
+
}
|
|
176
204
|
.mfui-button_size-wide_medium {
|
|
177
205
|
min-width: 52px;
|
|
178
206
|
height: 52px;
|
|
179
207
|
}
|
|
180
208
|
.mfui-button_size-wide_medium .mfui-button__icon,
|
|
181
|
-
.mfui-button_size-wide_medium .mfui-button__icon-arrow
|
|
209
|
+
.mfui-button_size-wide_medium .mfui-button__icon-arrow,
|
|
210
|
+
.mfui-button_size-wide_medium.mfui-button_content-type_icon-text .mfui-button__icon {
|
|
182
211
|
width: 32px;
|
|
183
212
|
height: 32px;
|
|
184
213
|
}
|
|
@@ -187,7 +216,8 @@
|
|
|
187
216
|
height: 60px;
|
|
188
217
|
}
|
|
189
218
|
.mfui-button_size-wide_large .mfui-button__icon,
|
|
190
|
-
.mfui-button_size-wide_large .mfui-button__icon-arrow
|
|
219
|
+
.mfui-button_size-wide_large .mfui-button__icon-arrow,
|
|
220
|
+
.mfui-button_size-wide_large.mfui-button_content-type_icon-text .mfui-button__icon {
|
|
191
221
|
width: 32px;
|
|
192
222
|
height: 32px;
|
|
193
223
|
}
|
|
@@ -219,10 +249,14 @@
|
|
|
219
249
|
line-height: 14px;
|
|
220
250
|
}
|
|
221
251
|
.mfui-button_size-tablet_extra-small .mfui-button__icon,
|
|
222
|
-
.mfui-button_size-tablet_extra-small .mfui-button__icon-arrow
|
|
252
|
+
.mfui-button_size-tablet_extra-small .mfui-button__icon-arrow,
|
|
253
|
+
.mfui-button_size-tablet_extra-small.mfui-button_content-type_icon-text .mfui-button__icon {
|
|
223
254
|
width: 20px;
|
|
224
255
|
height: 20px;
|
|
225
256
|
}
|
|
257
|
+
.mfui-button_size-tablet_extra-small.mfui-button_content-type_icon-text .mfui-button__icon {
|
|
258
|
+
margin-right: 2px;
|
|
259
|
+
}
|
|
226
260
|
.mfui-button_size-tablet_small {
|
|
227
261
|
min-width: 40px;
|
|
228
262
|
height: 40px;
|
|
@@ -233,12 +267,17 @@
|
|
|
233
267
|
width: 20px;
|
|
234
268
|
height: 20px;
|
|
235
269
|
}
|
|
270
|
+
.mfui-button_size-tablet_small.mfui-button_content-type_icon-text .mfui-button__icon {
|
|
271
|
+
width: 32px;
|
|
272
|
+
height: 32px;
|
|
273
|
+
}
|
|
236
274
|
.mfui-button_size-tablet_medium {
|
|
237
275
|
min-width: 52px;
|
|
238
276
|
height: 52px;
|
|
239
277
|
}
|
|
240
278
|
.mfui-button_size-tablet_medium .mfui-button__icon,
|
|
241
|
-
.mfui-button_size-tablet_medium .mfui-button__icon-arrow
|
|
279
|
+
.mfui-button_size-tablet_medium .mfui-button__icon-arrow,
|
|
280
|
+
.mfui-button_size-tablet_medium.mfui-button_content-type_icon-text .mfui-button__icon {
|
|
242
281
|
width: 32px;
|
|
243
282
|
height: 32px;
|
|
244
283
|
}
|
|
@@ -247,7 +286,8 @@
|
|
|
247
286
|
height: 60px;
|
|
248
287
|
}
|
|
249
288
|
.mfui-button_size-tablet_large .mfui-button__icon,
|
|
250
|
-
.mfui-button_size-tablet_large .mfui-button__icon-arrow
|
|
289
|
+
.mfui-button_size-tablet_large .mfui-button__icon-arrow,
|
|
290
|
+
.mfui-button_size-tablet_large.mfui-button_content-type_icon-text .mfui-button__icon {
|
|
251
291
|
width: 32px;
|
|
252
292
|
height: 32px;
|
|
253
293
|
}
|
|
@@ -279,10 +319,14 @@
|
|
|
279
319
|
line-height: 14px;
|
|
280
320
|
}
|
|
281
321
|
.mfui-button_size-mobile_extra-small .mfui-button__icon,
|
|
282
|
-
.mfui-button_size-mobile_extra-small .mfui-button__icon-arrow
|
|
322
|
+
.mfui-button_size-mobile_extra-small .mfui-button__icon-arrow,
|
|
323
|
+
.mfui-button_size-mobile_extra-small.mfui-button_content-type_icon-text .mfui-button__icon {
|
|
283
324
|
width: 20px;
|
|
284
325
|
height: 20px;
|
|
285
326
|
}
|
|
327
|
+
.mfui-button_size-mobile_extra-small.mfui-button_content-type_icon-text .mfui-button__icon {
|
|
328
|
+
margin-right: 2px;
|
|
329
|
+
}
|
|
286
330
|
.mfui-button_size-mobile_small {
|
|
287
331
|
min-width: 40px;
|
|
288
332
|
height: 40px;
|
|
@@ -293,12 +337,17 @@
|
|
|
293
337
|
width: 20px;
|
|
294
338
|
height: 20px;
|
|
295
339
|
}
|
|
340
|
+
.mfui-button_size-mobile_small.mfui-button_content-type_icon-text .mfui-button__icon {
|
|
341
|
+
width: 32px;
|
|
342
|
+
height: 32px;
|
|
343
|
+
}
|
|
296
344
|
.mfui-button_size-mobile_medium {
|
|
297
345
|
min-width: 52px;
|
|
298
346
|
height: 52px;
|
|
299
347
|
}
|
|
300
348
|
.mfui-button_size-mobile_medium .mfui-button__icon,
|
|
301
|
-
.mfui-button_size-mobile_medium .mfui-button__icon-arrow
|
|
349
|
+
.mfui-button_size-mobile_medium .mfui-button__icon-arrow,
|
|
350
|
+
.mfui-button_size-mobile_medium.mfui-button_content-type_icon-text .mfui-button__icon {
|
|
302
351
|
width: 32px;
|
|
303
352
|
height: 32px;
|
|
304
353
|
}
|
|
@@ -307,7 +356,8 @@
|
|
|
307
356
|
height: 60px;
|
|
308
357
|
}
|
|
309
358
|
.mfui-button_size-mobile_large .mfui-button__icon,
|
|
310
|
-
.mfui-button_size-mobile_large .mfui-button__icon-arrow
|
|
359
|
+
.mfui-button_size-mobile_large .mfui-button__icon-arrow,
|
|
360
|
+
.mfui-button_size-mobile_large.mfui-button_content-type_icon-text .mfui-button__icon {
|
|
311
361
|
width: 32px;
|
|
312
362
|
height: 32px;
|
|
313
363
|
}
|
|
@@ -395,14 +445,8 @@
|
|
|
395
445
|
padding: 0;
|
|
396
446
|
}
|
|
397
447
|
.mfui-button_content-type_icon-text .mfui-button__icon {
|
|
398
|
-
width: 32px;
|
|
399
|
-
height: 32px;
|
|
400
448
|
margin-right: 4px;
|
|
401
449
|
}
|
|
402
|
-
.mfui-button_content-type_icon-text.mfui-button_size-all_small .mfui-button__icon,
|
|
403
|
-
.mfui-button_content-type_icon-text.mfui-button_size-all_extra-small .mfui-button__icon {
|
|
404
|
-
display: none;
|
|
405
|
-
}
|
|
406
450
|
.mfui-button_type_text.mfui-button_theme_green {
|
|
407
451
|
width: -webkit-fit-content;
|
|
408
452
|
width: -moz-fit-content;
|