@megafon/ui-core 8.2.0 → 8.3.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/dist/es/components/Pagination/Pagination.css +1 -1
- package/dist/es/components/Pagination/Pagination.d.ts +18 -9
- package/dist/es/components/Pagination/Pagination.js +91 -19
- package/dist/es/components/Pagination/components/PaginationButton/PaginationButton.css +1 -1
- package/dist/es/components/Pagination/components/PaginationButton/PaginationButton.d.ts +9 -4
- package/dist/es/components/Pagination/components/PaginationButton/PaginationButton.js +13 -3
- package/dist/es/components/Pagination/components/PaginationButtons/PaginationButtons.css +1 -1
- package/dist/es/components/Pagination/components/PaginationButtons/PaginationButtons.d.ts +12 -6
- package/dist/es/components/Pagination/components/PaginationButtons/PaginationButtons.js +42 -25
- package/dist/es/components/Pagination/components/PaginationNavigation/PaginationNavigation.css +1 -1
- package/dist/es/components/Pagination/components/PaginationNavigation/PaginationNavigation.d.ts +13 -4
- package/dist/es/components/Pagination/components/PaginationNavigation/PaginationNavigation.js +105 -11
- package/dist/es/components/Pagination/helpers.d.ts +8 -2
- package/dist/es/components/Pagination/helpers.js +28 -2
- package/dist/es/components/Pagination/types.d.ts +25 -0
- package/dist/es/components/Pagination/types.js +4 -0
- package/dist/es/components/Pagination/usePagination.d.ts +10 -5
- package/dist/es/components/Pagination/usePagination.js +86 -54
- package/dist/es/components/Tooltip/Tooltip.css +1 -1
- package/dist/es/components/Tooltip/Tooltip.js +21 -2
- package/dist/es/components/UploadForm/UploadField/UploadField.d.ts +2 -0
- package/dist/es/components/UploadForm/UploadField/UploadField.js +2 -0
- package/dist/es/components/UploadForm/UploadField/components/_UploadFieldDropArea/UploadFieldDropArea.css +1 -1
- package/dist/es/components/UploadForm/UploadFileItem/UploadFileItem.css +1 -1
- package/dist/es/components/UploadForm/UploadFileItem/UploadFileItem.d.ts +11 -0
- package/dist/es/components/UploadForm/UploadFileItem/UploadFileItem.js +29 -5
- package/dist/es/components/ValueField/ValueField.d.ts +3 -0
- package/dist/es/components/ValueField/ValueField.js +5 -3
- package/dist/es/hooks/useResolution.d.ts +1 -0
- package/dist/es/hooks/useResolution.js +24 -7
- package/dist/lib/components/Pagination/Pagination.css +1 -1
- package/dist/lib/components/Pagination/Pagination.d.ts +18 -9
- package/dist/lib/components/Pagination/Pagination.js +90 -18
- package/dist/lib/components/Pagination/components/PaginationButton/PaginationButton.css +1 -1
- package/dist/lib/components/Pagination/components/PaginationButton/PaginationButton.d.ts +9 -4
- package/dist/lib/components/Pagination/components/PaginationButton/PaginationButton.js +13 -3
- package/dist/lib/components/Pagination/components/PaginationButtons/PaginationButtons.css +1 -1
- package/dist/lib/components/Pagination/components/PaginationButtons/PaginationButtons.d.ts +12 -6
- package/dist/lib/components/Pagination/components/PaginationButtons/PaginationButtons.js +45 -25
- package/dist/lib/components/Pagination/components/PaginationNavigation/PaginationNavigation.css +1 -1
- package/dist/lib/components/Pagination/components/PaginationNavigation/PaginationNavigation.d.ts +13 -4
- package/dist/lib/components/Pagination/components/PaginationNavigation/PaginationNavigation.js +105 -11
- package/dist/lib/components/Pagination/helpers.d.ts +8 -2
- package/dist/lib/components/Pagination/helpers.js +29 -3
- package/dist/lib/components/Pagination/types.d.ts +25 -0
- package/dist/lib/components/Pagination/types.js +10 -0
- package/dist/lib/components/Pagination/usePagination.d.ts +10 -5
- package/dist/lib/components/Pagination/usePagination.js +87 -55
- package/dist/lib/components/Tooltip/Tooltip.css +1 -1
- package/dist/lib/components/Tooltip/Tooltip.js +21 -2
- package/dist/lib/components/UploadForm/UploadField/UploadField.d.ts +2 -0
- package/dist/lib/components/UploadForm/UploadField/UploadField.js +2 -0
- package/dist/lib/components/UploadForm/UploadField/components/_UploadFieldDropArea/UploadFieldDropArea.css +1 -1
- package/dist/lib/components/UploadForm/UploadFileItem/UploadFileItem.css +1 -1
- package/dist/lib/components/UploadForm/UploadFileItem/UploadFileItem.d.ts +11 -0
- package/dist/lib/components/UploadForm/UploadFileItem/UploadFileItem.js +29 -5
- package/dist/lib/components/ValueField/ValueField.d.ts +3 -0
- package/dist/lib/components/ValueField/ValueField.js +5 -3
- package/dist/lib/hooks/useResolution.d.ts +1 -0
- package/dist/lib/hooks/useResolution.js +24 -7
- package/package.json +3 -3
- package/styles/colors.css +5 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
h1,h2,h3,h4,h5{margin:0}.mfui-pagination{display:-webkit-box;display:-ms-flexbox;display:flex}
|
|
1
|
+
h1,h2,h3,h4,h5{margin:0}.mfui-pagination{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;gap:12px;-webkit-box-align:center;-ms-flex-align:center;align-items:center}@media screen and (max-width:767px){.mfui-pagination{-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;gap:16px}}.mfui-pagination__input,.mfui-pagination__wrapper{display:-webkit-box;display:-ms-flexbox;display:flex}.mfui-pagination__input{gap:8px;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.mfui-pagination__input-caption{min-width:-webkit-max-content;min-width:-moz-max-content;min-width:max-content}.mfui-pagination__input-field{width:90px}
|
|
@@ -1,22 +1,31 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { PaginationTypesType, ThemeType, ValueType } from './types';
|
|
2
3
|
import './Pagination.scss';
|
|
3
|
-
import { PaginationValueType } from './components/PaginationButton/PaginationButton';
|
|
4
4
|
interface IPaginationProps {
|
|
5
|
+
/** Общее количество страниц */
|
|
6
|
+
totalPages: number;
|
|
7
|
+
/** Номер текущей страницы */
|
|
8
|
+
activePage: number;
|
|
9
|
+
/** Тип компонента. DEPRECATED: 'classic' */
|
|
10
|
+
type?: PaginationTypesType;
|
|
11
|
+
/** Цветовая тема компонента */
|
|
12
|
+
theme?: ThemeType;
|
|
13
|
+
/** Отобразить поле ввода номера страницы */
|
|
14
|
+
showSelectPage?: boolean;
|
|
15
|
+
/** Обработчик изменения активной страницы */
|
|
16
|
+
onChange: (value: ValueType) => void;
|
|
17
|
+
/** Дополнительный класс корневого элемента */
|
|
18
|
+
className?: string;
|
|
5
19
|
/** Дополнительные data атрибуты к внутренним элементам */
|
|
6
20
|
dataAttrs?: {
|
|
7
21
|
root?: Record<string, string>;
|
|
8
22
|
prev?: Record<string, string>;
|
|
9
23
|
next?: Record<string, string>;
|
|
10
24
|
button?: Record<string, string>;
|
|
25
|
+
skipPrev?: Record<string, string>;
|
|
26
|
+
skipNext?: Record<string, string>;
|
|
27
|
+
input?: Record<string, string>;
|
|
11
28
|
};
|
|
12
|
-
/** Общее количество страниц */
|
|
13
|
-
totalPages: number;
|
|
14
|
-
/** Номер текущей страницы */
|
|
15
|
-
activePage: number;
|
|
16
|
-
/** Тема компонента */
|
|
17
|
-
theme?: 'default' | 'light';
|
|
18
|
-
/** Обработчик изменения активной страницы */
|
|
19
|
-
onChange: (value: PaginationValueType) => void;
|
|
20
29
|
}
|
|
21
30
|
declare const Pagination: React.FC<IPaginationProps>;
|
|
22
31
|
export default Pagination;
|
|
@@ -1,19 +1,38 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
3
|
import * as React from 'react';
|
|
3
4
|
import { cnCreate, filterDataAttrs } from '@megafon/ui-helpers';
|
|
4
|
-
import "
|
|
5
|
+
import Caption from "../Caption/Caption";
|
|
6
|
+
import ValueField from "../ValueField/ValueField";
|
|
5
7
|
import PaginationButtons from "./components/PaginationButtons/PaginationButtons";
|
|
6
|
-
import PaginationNavigation from "./components/PaginationNavigation/PaginationNavigation";
|
|
7
|
-
import
|
|
8
|
+
import PaginationNavigation, { HINTS } from "./components/PaginationNavigation/PaginationNavigation";
|
|
9
|
+
import { getInputRangeValue, removeFirstZeros, setValueFieldTheme } from "./helpers";
|
|
10
|
+
import { PaginationTypes } from "./types";
|
|
11
|
+
import usePagination, { BUTTONS } from "./usePagination";
|
|
12
|
+
import "./Pagination.css";
|
|
8
13
|
var cn = cnCreate('mfui-pagination');
|
|
9
14
|
var Pagination = function Pagination(_ref) {
|
|
10
15
|
var totalPages = _ref.totalPages,
|
|
11
16
|
activePage = _ref.activePage,
|
|
12
|
-
|
|
17
|
+
_ref$type = _ref.type,
|
|
18
|
+
type = _ref$type === void 0 ? PaginationTypes.CLASSIC : _ref$type,
|
|
13
19
|
_ref$theme = _ref.theme,
|
|
14
20
|
theme = _ref$theme === void 0 ? 'default' : _ref$theme,
|
|
15
|
-
|
|
16
|
-
|
|
21
|
+
showSelectPage = _ref.showSelectPage,
|
|
22
|
+
onChange = _ref.onChange,
|
|
23
|
+
className = _ref.className,
|
|
24
|
+
dataAttrs = _ref.dataAttrs;
|
|
25
|
+
var _usePagination = usePagination(type, totalPages, activePage),
|
|
26
|
+
paginationItems = _usePagination.paginationItems,
|
|
27
|
+
skipPrevPage = _usePagination.skipPrevPage,
|
|
28
|
+
skipNextPage = _usePagination.skipNextPage;
|
|
29
|
+
var _React$useState = React.useState(''),
|
|
30
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
31
|
+
inputValue = _React$useState2[0],
|
|
32
|
+
setInputValue = _React$useState2[1];
|
|
33
|
+
var inputRef = React.useRef(null);
|
|
34
|
+
var isModernType = type === PaginationTypes.MODERN;
|
|
35
|
+
var buttonForm = isModernType ? 'brick' : 'round';
|
|
17
36
|
var handleBackClick = React.useCallback(function () {
|
|
18
37
|
onChange(activePage - 1);
|
|
19
38
|
}, [activePage, onChange]);
|
|
@@ -21,36 +40,89 @@ var Pagination = function Pagination(_ref) {
|
|
|
21
40
|
onChange(activePage + 1);
|
|
22
41
|
}, [activePage, onChange]);
|
|
23
42
|
var handlePageButtonClick = React.useCallback(function (value) {
|
|
43
|
+
if (value === BUTTONS.SKIP_PREV) {
|
|
44
|
+
onChange(skipPrevPage);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (value === BUTTONS.SKIP_NEXT) {
|
|
48
|
+
onChange(skipNextPage);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
24
51
|
value && onChange(value);
|
|
25
|
-
}, [onChange]);
|
|
52
|
+
}, [onChange, skipNextPage, skipPrevPage]);
|
|
53
|
+
var handleInputSubmit = React.useCallback(function () {
|
|
54
|
+
var _a;
|
|
55
|
+
if (!inputValue) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
var pageNumber = getInputRangeValue(inputValue, totalPages, BUTTONS.FIRST);
|
|
59
|
+
onChange(pageNumber);
|
|
60
|
+
setInputValue('');
|
|
61
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
62
|
+
}, [inputValue, onChange, totalPages]);
|
|
63
|
+
var handleInputChange = React.useCallback(function (e) {
|
|
64
|
+
var targetValue = removeFirstZeros(e.target.value);
|
|
65
|
+
setInputValue(targetValue);
|
|
66
|
+
}, []);
|
|
26
67
|
return /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
|
|
27
|
-
className: cn()
|
|
28
|
-
}), /*#__PURE__*/React.createElement(
|
|
68
|
+
className: cn([className])
|
|
69
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
70
|
+
className: cn('wrapper')
|
|
71
|
+
}, /*#__PURE__*/React.createElement(PaginationNavigation, {
|
|
72
|
+
className: cn('button'),
|
|
29
73
|
dataAttrs: {
|
|
30
74
|
root: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.prev
|
|
31
75
|
},
|
|
32
76
|
direction: "left",
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
theme: theme
|
|
77
|
+
form: buttonForm,
|
|
78
|
+
disabled: activePage === BUTTONS.FIRST,
|
|
79
|
+
hint: isModernType ? HINTS.PREV : null,
|
|
80
|
+
theme: theme,
|
|
81
|
+
onClick: handleBackClick
|
|
37
82
|
}), /*#__PURE__*/React.createElement(PaginationButtons, {
|
|
38
83
|
dataAttrs: {
|
|
39
|
-
|
|
84
|
+
button: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.button,
|
|
85
|
+
skipNext: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.skipNext,
|
|
86
|
+
skipPrev: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.skipPrev
|
|
40
87
|
},
|
|
41
88
|
items: paginationItems,
|
|
42
89
|
activeButton: activePage,
|
|
43
|
-
|
|
90
|
+
skipButtonPrev: BUTTONS.SKIP_PREV,
|
|
91
|
+
skipButtonNext: BUTTONS.SKIP_NEXT,
|
|
92
|
+
type: type,
|
|
93
|
+
form: buttonForm,
|
|
94
|
+
showHints: isModernType,
|
|
44
95
|
theme: theme,
|
|
45
96
|
onClick: handlePageButtonClick
|
|
46
97
|
}), /*#__PURE__*/React.createElement(PaginationNavigation, {
|
|
98
|
+
className: cn('button'),
|
|
47
99
|
dataAttrs: {
|
|
48
100
|
root: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.next
|
|
49
101
|
},
|
|
102
|
+
direction: "right",
|
|
103
|
+
form: buttonForm,
|
|
50
104
|
disabled: activePage === totalPages,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}))
|
|
105
|
+
hint: isModernType ? HINTS.NEXT : null,
|
|
106
|
+
theme: theme,
|
|
107
|
+
onClick: handleNextClick
|
|
108
|
+
})), showSelectPage && /*#__PURE__*/React.createElement("div", {
|
|
109
|
+
className: cn('input')
|
|
110
|
+
}, /*#__PURE__*/React.createElement(Caption, {
|
|
111
|
+
className: cn('input-caption'),
|
|
112
|
+
color: theme === 'light' ? 'white' : 'default',
|
|
113
|
+
hasMargin: false
|
|
114
|
+
}, "\u041D\u0430 \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u0443"), /*#__PURE__*/React.createElement(ValueField, {
|
|
115
|
+
className: cn('input-field'),
|
|
116
|
+
isControlled: true,
|
|
117
|
+
placeholder: "\u2116",
|
|
118
|
+
theme: setValueFieldTheme(theme),
|
|
119
|
+
value: inputValue,
|
|
120
|
+
onChange: handleInputChange,
|
|
121
|
+
onBlur: handleInputSubmit,
|
|
122
|
+
dataAttrs: {
|
|
123
|
+
input: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.input
|
|
124
|
+
},
|
|
125
|
+
inputRef: inputRef
|
|
126
|
+
})));
|
|
55
127
|
};
|
|
56
128
|
export default Pagination;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
h1,h2,h3,h4,h5{margin:0}.mfui-pagination-button{display:-webkit-box;display:-ms-flexbox;display:flex;font-size:15px;font-weight:500;line-height:24px;-webkit-box-
|
|
1
|
+
h1,h2,h3,h4,h5{margin:0}.mfui-pagination-button{display:-webkit-box;display:-ms-flexbox;display:flex;font-size:15px;font-weight:500;line-height:24px;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;border:1px solid transparent;border-radius:50%;height:32px;justify-content:center;padding:0;width:32px;-webkit-tap-highlight-color:rgba(0,0,0,0);background-color:transparent;cursor:pointer}.mfui-pagination-button svg{width:100%}.mfui-pagination-button:disabled{pointer-events:none}.mfui-pagination-button_form_brick{border-radius:8px;-webkit-box-sizing:border-box;box-sizing:border-box}.mfui-pagination-button_auto-width{min-width:32px;padding:0 8px;width:auto}.mfui-pagination-button_active{border-color:var(--brandGreen);pointer-events:none}.mfui-pagination-button_theme_default{color:var(--content)}.mfui-pagination-button_theme_default svg{fill:var(--content)}.mfui-pagination-button_theme_default:hover{background-color:var(--spbSky0)}.mfui-pagination-button_theme_default.mfui-pagination-button_active{border-color:var(--brandGreen);color:var(--brandGreen)}.mfui-pagination-button_theme_light{color:var(--stcWhite)}.mfui-pagination-button_theme_light svg{fill:var(--stcWhite)}.mfui-pagination-button_theme_light:hover{background-color:var(--stcWhite20)}.mfui-pagination-button_theme_light.mfui-pagination-button_active{border-color:var(--stcWhite)}.mfui-pagination-button_theme_gray{color:var(--content)}.mfui-pagination-button_theme_gray svg{fill:var(--content)}.mfui-pagination-button_theme_gray:hover{background-color:var(--base)}.mfui-pagination-button_theme_gray.mfui-pagination-button_active{border-color:var(--brandGreen);color:var(--brandGreen)}
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { ValueType, ThemeType, ButtonFormType } from '../../types';
|
|
2
3
|
import './PaginationButton.scss';
|
|
3
|
-
export type PaginationValueType = string | number;
|
|
4
4
|
export interface IPaginationButtonProps {
|
|
5
|
+
theme?: ThemeType;
|
|
6
|
+
form?: ButtonFormType;
|
|
7
|
+
value?: ValueType;
|
|
5
8
|
disabled?: boolean;
|
|
6
9
|
isActive?: boolean;
|
|
7
|
-
|
|
8
|
-
value?: PaginationValueType;
|
|
10
|
+
autoWidth?: boolean;
|
|
9
11
|
className?: string;
|
|
10
12
|
dataAttrs?: {
|
|
11
13
|
root?: Record<string, string>;
|
|
12
14
|
};
|
|
13
15
|
children?: React.ReactNode;
|
|
14
|
-
onClick?: (value?:
|
|
16
|
+
onClick?: (value?: ValueType) => void;
|
|
17
|
+
onMouseEnter?: () => void;
|
|
18
|
+
onMouseLeave?: () => void;
|
|
19
|
+
rootRef?: React.Ref<HTMLButtonElement>;
|
|
15
20
|
}
|
|
16
21
|
declare const PaginationButton: React.FC<IPaginationButtonProps>;
|
|
17
22
|
export default PaginationButton;
|
|
@@ -10,22 +10,32 @@ var PaginationButton = function PaginationButton(_ref) {
|
|
|
10
10
|
isActive = _ref$isActive === void 0 ? false : _ref$isActive,
|
|
11
11
|
_ref$theme = _ref.theme,
|
|
12
12
|
theme = _ref$theme === void 0 ? 'default' : _ref$theme,
|
|
13
|
+
form = _ref.form,
|
|
14
|
+
autoWidth = _ref.autoWidth,
|
|
13
15
|
className = _ref.className,
|
|
14
16
|
children = _ref.children,
|
|
15
17
|
onClick = _ref.onClick,
|
|
18
|
+
onMouseEnter = _ref.onMouseEnter,
|
|
19
|
+
onMouseLeave = _ref.onMouseLeave,
|
|
16
20
|
value = _ref.value,
|
|
17
|
-
dataAttrs = _ref.dataAttrs
|
|
21
|
+
dataAttrs = _ref.dataAttrs,
|
|
22
|
+
rootRef = _ref.rootRef;
|
|
18
23
|
var handleClick = function handleClick() {
|
|
19
24
|
onClick === null || onClick === void 0 ? void 0 : onClick(value);
|
|
20
25
|
};
|
|
21
26
|
return /*#__PURE__*/React.createElement("button", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
|
|
22
27
|
className: cn({
|
|
23
28
|
active: isActive,
|
|
24
|
-
theme: theme
|
|
29
|
+
theme: theme,
|
|
30
|
+
form: form,
|
|
31
|
+
'auto-width': autoWidth
|
|
25
32
|
}, className),
|
|
33
|
+
type: "button",
|
|
26
34
|
disabled: disabled,
|
|
27
35
|
onClick: handleClick,
|
|
28
|
-
|
|
36
|
+
onMouseEnter: onMouseEnter,
|
|
37
|
+
onMouseLeave: onMouseLeave,
|
|
38
|
+
ref: rootRef
|
|
29
39
|
}), children);
|
|
30
40
|
};
|
|
31
41
|
export default PaginationButton;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.mfui-pagination-buttons{display:-webkit-box;display:-ms-flexbox;display:flex}.mfui-pagination-buttons__button{-ms-flex-negative:0;flex-shrink:0;margin:0 4px}
|
|
1
|
+
h1,h2,h3,h4,h5{margin:0}.mfui-pagination-buttons{display:-webkit-box;display:-ms-flexbox;display:flex}.mfui-pagination-buttons__button{-ms-flex-negative:0;flex-shrink:0;margin:0 4px}@media screen and (max-width:767px){.mfui-pagination-buttons__button{margin:0 2px}}.mfui-pagination-buttons__button_form_brick{margin:0 2px}@media screen and (max-width:767px){.mfui-pagination-buttons__button_form_brick{margin:0}}
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { ValueType, ThemeType, ButtonFormType, PaginationTypesType } from '../../types';
|
|
3
3
|
import './PaginationButtons.scss';
|
|
4
|
-
interface IPaginationButtonsProps {
|
|
4
|
+
export interface IPaginationButtonsProps {
|
|
5
5
|
items: Array<string | number>;
|
|
6
|
-
|
|
6
|
+
type: PaginationTypesType;
|
|
7
|
+
form: ButtonFormType;
|
|
8
|
+
theme: ThemeType;
|
|
9
|
+
showHints: boolean;
|
|
7
10
|
activeButton: number;
|
|
8
|
-
|
|
11
|
+
skipButtonPrev: string;
|
|
12
|
+
skipButtonNext: string;
|
|
9
13
|
dataAttrs?: {
|
|
10
|
-
|
|
14
|
+
button?: Record<string, string>;
|
|
15
|
+
skipNext?: Record<string, string>;
|
|
16
|
+
skipPrev?: Record<string, string>;
|
|
11
17
|
};
|
|
12
|
-
onClick: (value?:
|
|
18
|
+
onClick: (value?: ValueType) => void;
|
|
13
19
|
}
|
|
14
20
|
declare const PaginationButtons: React.FC<IPaginationButtonsProps>;
|
|
15
21
|
export default PaginationButtons;
|
|
@@ -1,54 +1,71 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
1
|
import "core-js/modules/es.array.map.js";
|
|
3
2
|
import React from 'react';
|
|
4
3
|
import { cnCreate, filterDataAttrs } from '@megafon/ui-helpers';
|
|
4
|
+
import { PaginationTypes } from "../../types";
|
|
5
5
|
import PaginationButton from "../PaginationButton/PaginationButton";
|
|
6
|
+
import PaginationNavigation, { HINTS } from "../PaginationNavigation/PaginationNavigation";
|
|
6
7
|
import "./PaginationButtons.css";
|
|
7
|
-
var NothingIcon = function NothingIcon(props) {
|
|
8
|
-
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
9
|
-
viewBox: "0 0 20 20"
|
|
10
|
-
}, props), /*#__PURE__*/React.createElement("path", {
|
|
11
|
-
d: "M7 9a1 1 0 11-1 1 1 1 0 011-1zm2 1a1 1 0 101-1 1 1 0 00-1 1zm3 0a1 1 0 101-1 1 1 0 00-1 1z"
|
|
12
|
-
}));
|
|
13
|
-
};
|
|
14
8
|
var cn = cnCreate('mfui-pagination-buttons');
|
|
15
9
|
var PaginationButtons = function PaginationButtons(_ref) {
|
|
16
10
|
var items = _ref.items,
|
|
11
|
+
type = _ref.type,
|
|
17
12
|
theme = _ref.theme,
|
|
13
|
+
form = _ref.form,
|
|
14
|
+
showHints = _ref.showHints,
|
|
18
15
|
onClick = _ref.onClick,
|
|
19
16
|
activeButton = _ref.activeButton,
|
|
20
|
-
|
|
17
|
+
skipButtonPrev = _ref.skipButtonPrev,
|
|
18
|
+
skipButtonNext = _ref.skipButtonNext,
|
|
21
19
|
dataAttrs = _ref.dataAttrs;
|
|
20
|
+
var isModernType = type === PaginationTypes.MODERN;
|
|
22
21
|
return /*#__PURE__*/React.createElement("div", {
|
|
23
22
|
className: cn()
|
|
24
23
|
}, items.map(function (pageNumber, index) {
|
|
25
|
-
var
|
|
24
|
+
var isSkipButtonPrev = skipButtonPrev === pageNumber;
|
|
25
|
+
var isSkipButtonNext = skipButtonNext === pageNumber;
|
|
26
26
|
var dataIndex = typeof pageNumber === 'number' ? pageNumber : undefined;
|
|
27
|
-
if (
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
if (isSkipButtonPrev || isSkipButtonNext) {
|
|
28
|
+
var hint = isSkipButtonNext ? HINTS.SKIP_NEXT : HINTS.SKIP_PREV;
|
|
29
|
+
return /*#__PURE__*/React.createElement(PaginationNavigation, {
|
|
30
30
|
key: index,
|
|
31
|
+
className: cn('button', {
|
|
32
|
+
form: form
|
|
33
|
+
}),
|
|
31
34
|
theme: theme,
|
|
32
|
-
|
|
35
|
+
form: form,
|
|
36
|
+
value: pageNumber,
|
|
37
|
+
variant: "skip",
|
|
38
|
+
disabled: !isModernType,
|
|
39
|
+
direction: isSkipButtonNext ? 'right' : 'left',
|
|
40
|
+
hint: showHints ? hint : null,
|
|
41
|
+
onClick: onClick,
|
|
33
42
|
dataAttrs: {
|
|
34
|
-
root:
|
|
35
|
-
'data-testid': 'hiddenButton'
|
|
36
|
-
}
|
|
43
|
+
root: isSkipButtonNext ? dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.skipNext : dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.skipPrev
|
|
37
44
|
}
|
|
38
|
-
}
|
|
45
|
+
});
|
|
39
46
|
}
|
|
40
47
|
var isActive = pageNumber === activeButton;
|
|
48
|
+
var digitCount = String(pageNumber).length;
|
|
49
|
+
var pageNumberStyle = isModernType ? {
|
|
50
|
+
width: 10 * digitCount
|
|
51
|
+
} : undefined;
|
|
41
52
|
return /*#__PURE__*/React.createElement(PaginationButton, {
|
|
53
|
+
key: index,
|
|
54
|
+
className: cn('button', {
|
|
55
|
+
form: form
|
|
56
|
+
}),
|
|
42
57
|
dataAttrs: {
|
|
43
|
-
root: filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.
|
|
58
|
+
root: filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.button, dataIndex)
|
|
44
59
|
},
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
className: cn('button'),
|
|
48
|
-
onClick: onClick,
|
|
60
|
+
theme: theme,
|
|
61
|
+
form: form,
|
|
49
62
|
value: pageNumber,
|
|
50
|
-
|
|
51
|
-
|
|
63
|
+
autoWidth: isModernType,
|
|
64
|
+
isActive: isActive,
|
|
65
|
+
onClick: onClick
|
|
66
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
67
|
+
style: pageNumberStyle
|
|
68
|
+
}, pageNumber));
|
|
52
69
|
}));
|
|
53
70
|
};
|
|
54
71
|
export default PaginationButtons;
|
package/dist/es/components/Pagination/components/PaginationNavigation/PaginationNavigation.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
h1,h2,h3,h4,h5{margin:0}.mfui-pagination-
|
|
1
|
+
h1,h2,h3,h4,h5{margin:0}.mfui-pagination-navigation__icon{display:-webkit-box;display:-ms-flexbox;display:flex;position:relative;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center}.mfui-pagination-navigation__skip-icon-hover{height:20px;left:50%;opacity:0;position:absolute;top:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);width:20px}.mfui-pagination-navigation__button_direction_left .mfui-pagination-navigation__icon{-webkit-transform:rotate(180deg);transform:rotate(180deg)}.mfui-pagination-navigation__button:disabled .mfui-pagination-navigation__arrow-icon{opacity:.25}.mfui-pagination-navigation__button:not(:disabled):hover .mfui-pagination-navigation__skip-icon-base{opacity:0}.mfui-pagination-navigation__button:not(:disabled):hover .mfui-pagination-navigation__skip-icon-hover{opacity:1}
|
package/dist/es/components/Pagination/components/PaginationNavigation/PaginationNavigation.d.ts
CHANGED
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { ButtonFormType, ThemeType, ValueType } from '../../types';
|
|
3
3
|
import './PaginationNavigation.scss';
|
|
4
|
+
export declare const HINTS: {
|
|
5
|
+
PREV: string;
|
|
6
|
+
SKIP_PREV: string;
|
|
7
|
+
SKIP_NEXT: string;
|
|
8
|
+
NEXT: string;
|
|
9
|
+
};
|
|
4
10
|
interface IPaginationNavigationProps {
|
|
11
|
+
theme?: ThemeType;
|
|
12
|
+
form?: ButtonFormType;
|
|
5
13
|
direction?: 'left' | 'right';
|
|
6
|
-
|
|
14
|
+
variant?: 'default' | 'skip';
|
|
7
15
|
disabled?: boolean;
|
|
8
|
-
|
|
16
|
+
value?: string | number;
|
|
17
|
+
hint?: string | null;
|
|
9
18
|
className?: string;
|
|
10
19
|
dataAttrs?: {
|
|
11
20
|
root?: Record<string, string>;
|
|
12
21
|
};
|
|
13
|
-
onClick?: (value?:
|
|
22
|
+
onClick?: (value?: ValueType) => void;
|
|
14
23
|
}
|
|
15
24
|
declare const PaginationNavigation: React.FC<IPaginationNavigationProps>;
|
|
16
25
|
export default PaginationNavigation;
|
package/dist/es/components/Pagination/components/PaginationNavigation/PaginationNavigation.js
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
1
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
+
import "core-js/modules/web.timers.js";
|
|
2
4
|
import React from 'react';
|
|
3
|
-
import { cnCreate } from '@megafon/ui-helpers';
|
|
5
|
+
import { cnCreate, detectTouch } from '@megafon/ui-helpers';
|
|
6
|
+
import Tooltip from "../../../Tooltip/Tooltip";
|
|
4
7
|
import PaginationButton from "../PaginationButton/PaginationButton";
|
|
5
8
|
import "./PaginationNavigation.css";
|
|
9
|
+
var NothingIcon = function NothingIcon(props) {
|
|
10
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
11
|
+
viewBox: "0 0 20 20"
|
|
12
|
+
}, props), /*#__PURE__*/React.createElement("path", {
|
|
13
|
+
d: "M7 9a1 1 0 11-1 1 1 1 0 011-1zm2 1a1 1 0 101-1 1 1 0 00-1 1zm3 0a1 1 0 101-1 1 1 0 00-1 1z"
|
|
14
|
+
}));
|
|
15
|
+
};
|
|
6
16
|
var ArrowRightIcon = function ArrowRightIcon(props) {
|
|
7
17
|
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
8
18
|
viewBox: "0 0 32 32"
|
|
@@ -10,27 +20,111 @@ var ArrowRightIcon = function ArrowRightIcon(props) {
|
|
|
10
20
|
d: "M12.5 20.8l4.8-4.8-4.8-4.8 1.6-1.7 6.4 6.5-6.4 6.5z"
|
|
11
21
|
}));
|
|
12
22
|
};
|
|
23
|
+
var ArrowsRightIcon = function ArrowsRightIcon(props) {
|
|
24
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
25
|
+
viewBox: "0 0 20 20"
|
|
26
|
+
}, props), /*#__PURE__*/React.createElement("path", {
|
|
27
|
+
d: "M5 12.976L7.996 10 5 7.023 6.002 6 10 10l-3.998 4L5 12.976zM10 12.976L12.996 10 10 7.023 11.002 6 15 10l-3.998 4L10 12.976z"
|
|
28
|
+
}));
|
|
29
|
+
};
|
|
30
|
+
export var HINTS = {
|
|
31
|
+
PREV: 'Предыдущая страница',
|
|
32
|
+
SKIP_PREV: 'Предыдущие 4 страницы',
|
|
33
|
+
SKIP_NEXT: 'Следующие 4 страницы',
|
|
34
|
+
NEXT: 'Следующая страница'
|
|
35
|
+
};
|
|
36
|
+
var delayShow = 250;
|
|
37
|
+
var delayHide = 50;
|
|
13
38
|
var cn = cnCreate('mfui-pagination-navigation');
|
|
14
39
|
var PaginationNavigation = function PaginationNavigation(_ref) {
|
|
15
|
-
var
|
|
40
|
+
var variant = _ref.variant,
|
|
41
|
+
_ref$direction = _ref.direction,
|
|
16
42
|
direction = _ref$direction === void 0 ? 'right' : _ref$direction,
|
|
17
43
|
theme = _ref.theme,
|
|
44
|
+
form = _ref.form,
|
|
18
45
|
disabled = _ref.disabled,
|
|
19
|
-
|
|
46
|
+
value = _ref.value,
|
|
47
|
+
hint = _ref.hint,
|
|
20
48
|
onClick = _ref.onClick,
|
|
21
49
|
className = _ref.className,
|
|
22
50
|
dataAttrs = _ref.dataAttrs;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
51
|
+
var isTouch = detectTouch();
|
|
52
|
+
var _React$useState = React.useState(null),
|
|
53
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
54
|
+
timeoutId = _React$useState2[0],
|
|
55
|
+
setTimeoutId = _React$useState2[1];
|
|
56
|
+
var _React$useState3 = React.useState(false),
|
|
57
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
58
|
+
isHovered = _React$useState4[0],
|
|
59
|
+
setIsHovered = _React$useState4[1];
|
|
60
|
+
var triggerRef = React.useRef(null);
|
|
61
|
+
var hasHint = !!hint && !disabled && !isTouch;
|
|
62
|
+
var handleClick = React.useCallback(function () {
|
|
63
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(value);
|
|
64
|
+
}, [onClick, value]);
|
|
65
|
+
var handleHover = React.useCallback(function (isHovering) {
|
|
66
|
+
if (timeoutId) {
|
|
67
|
+
clearTimeout(timeoutId);
|
|
68
|
+
}
|
|
69
|
+
var delay = isHovering ? delayShow : delayHide;
|
|
70
|
+
var newTimeoutId = setTimeout(function () {
|
|
71
|
+
setIsHovered(isHovering);
|
|
72
|
+
}, delay);
|
|
73
|
+
setTimeoutId(newTimeoutId);
|
|
74
|
+
}, [timeoutId]);
|
|
75
|
+
var handleMouseEnter = React.useCallback(function () {
|
|
76
|
+
return handleHover(true);
|
|
77
|
+
}, [handleHover]);
|
|
78
|
+
var handleMouseLeave = React.useCallback(function () {
|
|
79
|
+
return handleHover(false);
|
|
80
|
+
}, [handleHover]);
|
|
81
|
+
var renderIcon = function renderIcon() {
|
|
82
|
+
if (variant === 'skip') {
|
|
83
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(NothingIcon, {
|
|
84
|
+
className: cn('skip-icon-base')
|
|
85
|
+
}), !disabled && /*#__PURE__*/React.createElement(ArrowsRightIcon, {
|
|
86
|
+
className: cn('skip-icon-hover')
|
|
87
|
+
}));
|
|
88
|
+
}
|
|
89
|
+
return /*#__PURE__*/React.createElement(ArrowRightIcon, {
|
|
90
|
+
className: cn('arrow-icon')
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
React.useEffect(function () {
|
|
94
|
+
if (disabled) {
|
|
95
|
+
setIsHovered(false);
|
|
96
|
+
timeoutId && clearTimeout(timeoutId);
|
|
97
|
+
}
|
|
98
|
+
return function () {
|
|
99
|
+
if (timeoutId) {
|
|
100
|
+
clearTimeout(timeoutId);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
}, [disabled, timeoutId]);
|
|
104
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
105
|
+
className: cn([className])
|
|
106
|
+
}, /*#__PURE__*/React.createElement(PaginationButton, {
|
|
107
|
+
className: cn('button', {
|
|
26
108
|
direction: direction
|
|
27
|
-
}
|
|
109
|
+
}),
|
|
110
|
+
dataAttrs: dataAttrs,
|
|
28
111
|
disabled: disabled,
|
|
29
|
-
isActive: isActive,
|
|
30
112
|
theme: theme,
|
|
31
|
-
|
|
32
|
-
|
|
113
|
+
form: form,
|
|
114
|
+
onClick: handleClick,
|
|
115
|
+
onMouseEnter: hasHint ? handleMouseEnter : undefined,
|
|
116
|
+
onMouseLeave: hasHint ? handleMouseLeave : undefined,
|
|
117
|
+
rootRef: triggerRef
|
|
118
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
33
119
|
className: cn('icon')
|
|
34
|
-
}))
|
|
120
|
+
}, renderIcon())), hasHint && /*#__PURE__*/React.createElement(Tooltip, {
|
|
121
|
+
isOpened: isHovered,
|
|
122
|
+
triggerEvent: "controlled",
|
|
123
|
+
triggerElement: triggerRef,
|
|
124
|
+
colorTheme: "blue",
|
|
125
|
+
placement: "bottom",
|
|
126
|
+
fallbackPlacements: ['bottom'],
|
|
127
|
+
offset: "small"
|
|
128
|
+
}, hint));
|
|
35
129
|
};
|
|
36
130
|
export default PaginationNavigation;
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { ComponentProps } from 'react';
|
|
2
|
+
import ValueField from '../ValueField/ValueField';
|
|
3
|
+
import { ThemeType } from './types';
|
|
4
|
+
export declare const getRange: (from: number, to: number, step?: number) => number[];
|
|
5
|
+
export declare const removeFirstZeros: (value: string) => string;
|
|
6
|
+
export declare const getInputRangeValue: (value: string | number, maxValue: number, minValue: number) => number;
|
|
7
|
+
export type ValueFieldThemeType = ComponentProps<typeof ValueField>['theme'];
|
|
8
|
+
export declare const setValueFieldTheme: (theme: ThemeType) => ValueFieldThemeType;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import "core-js/modules/es.number.constructor.js";
|
|
2
|
+
import "core-js/modules/es.regexp.exec.js";
|
|
3
|
+
import "core-js/modules/es.regexp.test.js";
|
|
4
|
+
import "core-js/modules/es.string.replace.js";
|
|
5
|
+
export var getRange = function getRange(from, to) {
|
|
2
6
|
var step = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
3
7
|
var i = from;
|
|
4
8
|
var range = [];
|
|
@@ -8,4 +12,26 @@ var getRange = function getRange(from, to) {
|
|
|
8
12
|
}
|
|
9
13
|
return range;
|
|
10
14
|
};
|
|
11
|
-
export
|
|
15
|
+
export var removeFirstZeros = function removeFirstZeros(value) {
|
|
16
|
+
return /^0.+/.test(value) ? value.replace(/^(0)+/, '') : value;
|
|
17
|
+
};
|
|
18
|
+
export var getInputRangeValue = function getInputRangeValue(value, maxValue, minValue) {
|
|
19
|
+
var numberValue = Number(value);
|
|
20
|
+
if (numberValue > maxValue) {
|
|
21
|
+
return maxValue;
|
|
22
|
+
}
|
|
23
|
+
if (numberValue < minValue) {
|
|
24
|
+
return minValue;
|
|
25
|
+
}
|
|
26
|
+
return numberValue;
|
|
27
|
+
};
|
|
28
|
+
export var setValueFieldTheme = function setValueFieldTheme(theme) {
|
|
29
|
+
switch (theme) {
|
|
30
|
+
case 'light':
|
|
31
|
+
return 'color';
|
|
32
|
+
case 'gray':
|
|
33
|
+
return 'gray';
|
|
34
|
+
default:
|
|
35
|
+
return 'default';
|
|
36
|
+
}
|
|
37
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const PaginationTypes: {
|
|
2
|
+
readonly CLASSIC: "classic";
|
|
3
|
+
readonly MODERN: "modern";
|
|
4
|
+
};
|
|
5
|
+
export type PaginationTypesType = (typeof PaginationTypes)[keyof typeof PaginationTypes];
|
|
6
|
+
export type ButtonFormType = 'brick' | 'round';
|
|
7
|
+
export type ValueType = string | number;
|
|
8
|
+
export type ThemeType = 'default' | 'light' | 'gray';
|
|
9
|
+
type SettingsType = {
|
|
10
|
+
neighbourCount: {
|
|
11
|
+
main: number;
|
|
12
|
+
mobile: number;
|
|
13
|
+
mobileXS: number;
|
|
14
|
+
};
|
|
15
|
+
visibleNumbers: {
|
|
16
|
+
main: number;
|
|
17
|
+
mobile: number;
|
|
18
|
+
mobileXS: number;
|
|
19
|
+
};
|
|
20
|
+
skipStep: number;
|
|
21
|
+
};
|
|
22
|
+
export type SettingsMapType = {
|
|
23
|
+
[key in PaginationTypesType]: SettingsType;
|
|
24
|
+
};
|
|
25
|
+
export {};
|