@megafon/ui-core 8.2.1 → 8.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/dist/es/components/Banner/Banner.css +1 -1
  2. package/dist/es/components/Banner/Banner.d.ts +26 -0
  3. package/dist/es/components/Banner/Banner.js +25 -1
  4. package/dist/es/components/Banner/BannerDot.css +1 -1
  5. package/dist/es/components/Banner/BannerDot.d.ts +3 -0
  6. package/dist/es/components/Banner/BannerDot.js +23 -11
  7. package/dist/es/components/Modal/_ModalContent/ModalContent.css +1 -1
  8. package/dist/es/components/Modal/_ModalContent/ModalContent.js +10 -2
  9. package/dist/es/components/Pagination/Pagination.css +1 -1
  10. package/dist/es/components/Pagination/Pagination.d.ts +18 -9
  11. package/dist/es/components/Pagination/Pagination.js +91 -19
  12. package/dist/es/components/Pagination/components/PaginationButton/PaginationButton.css +1 -1
  13. package/dist/es/components/Pagination/components/PaginationButton/PaginationButton.d.ts +9 -4
  14. package/dist/es/components/Pagination/components/PaginationButton/PaginationButton.js +13 -3
  15. package/dist/es/components/Pagination/components/PaginationButtons/PaginationButtons.css +1 -1
  16. package/dist/es/components/Pagination/components/PaginationButtons/PaginationButtons.d.ts +12 -6
  17. package/dist/es/components/Pagination/components/PaginationButtons/PaginationButtons.js +42 -25
  18. package/dist/es/components/Pagination/components/PaginationNavigation/PaginationNavigation.css +1 -1
  19. package/dist/es/components/Pagination/components/PaginationNavigation/PaginationNavigation.d.ts +13 -4
  20. package/dist/es/components/Pagination/components/PaginationNavigation/PaginationNavigation.js +105 -11
  21. package/dist/es/components/Pagination/helpers.d.ts +8 -2
  22. package/dist/es/components/Pagination/helpers.js +28 -2
  23. package/dist/es/components/Pagination/types.d.ts +25 -0
  24. package/dist/es/components/Pagination/types.js +4 -0
  25. package/dist/es/components/Pagination/usePagination.d.ts +10 -5
  26. package/dist/es/components/Pagination/usePagination.js +86 -54
  27. package/dist/es/components/Tooltip/Tooltip.css +1 -1
  28. package/dist/es/components/Tooltip/Tooltip.js +21 -2
  29. package/dist/es/components/UploadForm/UploadField/UploadField.d.ts +2 -0
  30. package/dist/es/components/UploadForm/UploadField/UploadField.js +2 -0
  31. package/dist/es/components/UploadForm/UploadField/components/_UploadFieldDropArea/UploadFieldDropArea.css +1 -1
  32. package/dist/es/components/UploadForm/UploadFileItem/UploadFileItem.css +1 -1
  33. package/dist/es/components/UploadForm/UploadFileItem/UploadFileItem.d.ts +11 -0
  34. package/dist/es/components/UploadForm/UploadFileItem/UploadFileItem.js +29 -5
  35. package/dist/es/components/ValueField/ValueField.d.ts +3 -0
  36. package/dist/es/components/ValueField/ValueField.js +5 -3
  37. package/dist/es/hooks/useResolution.d.ts +1 -0
  38. package/dist/es/hooks/useResolution.js +24 -7
  39. package/dist/lib/components/Banner/Banner.css +1 -1
  40. package/dist/lib/components/Banner/Banner.d.ts +26 -0
  41. package/dist/lib/components/Banner/Banner.js +26 -2
  42. package/dist/lib/components/Banner/BannerDot.css +1 -1
  43. package/dist/lib/components/Banner/BannerDot.d.ts +3 -0
  44. package/dist/lib/components/Banner/BannerDot.js +23 -11
  45. package/dist/lib/components/Modal/_ModalContent/ModalContent.css +1 -1
  46. package/dist/lib/components/Modal/_ModalContent/ModalContent.js +10 -2
  47. package/dist/lib/components/Pagination/Pagination.css +1 -1
  48. package/dist/lib/components/Pagination/Pagination.d.ts +18 -9
  49. package/dist/lib/components/Pagination/Pagination.js +90 -18
  50. package/dist/lib/components/Pagination/components/PaginationButton/PaginationButton.css +1 -1
  51. package/dist/lib/components/Pagination/components/PaginationButton/PaginationButton.d.ts +9 -4
  52. package/dist/lib/components/Pagination/components/PaginationButton/PaginationButton.js +13 -3
  53. package/dist/lib/components/Pagination/components/PaginationButtons/PaginationButtons.css +1 -1
  54. package/dist/lib/components/Pagination/components/PaginationButtons/PaginationButtons.d.ts +12 -6
  55. package/dist/lib/components/Pagination/components/PaginationButtons/PaginationButtons.js +45 -25
  56. package/dist/lib/components/Pagination/components/PaginationNavigation/PaginationNavigation.css +1 -1
  57. package/dist/lib/components/Pagination/components/PaginationNavigation/PaginationNavigation.d.ts +13 -4
  58. package/dist/lib/components/Pagination/components/PaginationNavigation/PaginationNavigation.js +105 -11
  59. package/dist/lib/components/Pagination/helpers.d.ts +8 -2
  60. package/dist/lib/components/Pagination/helpers.js +29 -3
  61. package/dist/lib/components/Pagination/types.d.ts +25 -0
  62. package/dist/lib/components/Pagination/types.js +10 -0
  63. package/dist/lib/components/Pagination/usePagination.d.ts +10 -5
  64. package/dist/lib/components/Pagination/usePagination.js +87 -55
  65. package/dist/lib/components/Tooltip/Tooltip.css +1 -1
  66. package/dist/lib/components/Tooltip/Tooltip.js +21 -2
  67. package/dist/lib/components/UploadForm/UploadField/UploadField.d.ts +2 -0
  68. package/dist/lib/components/UploadForm/UploadField/UploadField.js +2 -0
  69. package/dist/lib/components/UploadForm/UploadField/components/_UploadFieldDropArea/UploadFieldDropArea.css +1 -1
  70. package/dist/lib/components/UploadForm/UploadFileItem/UploadFileItem.css +1 -1
  71. package/dist/lib/components/UploadForm/UploadFileItem/UploadFileItem.d.ts +11 -0
  72. package/dist/lib/components/UploadForm/UploadFileItem/UploadFileItem.js +29 -5
  73. package/dist/lib/components/ValueField/ValueField.d.ts +3 -0
  74. package/dist/lib/components/ValueField/ValueField.js +5 -3
  75. package/dist/lib/hooks/useResolution.d.ts +1 -0
  76. package/dist/lib/hooks/useResolution.js +24 -7
  77. package/package.json +2 -2
  78. package/styles/colors.css +9 -10
@@ -6,11 +6,16 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports["default"] = void 0;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
10
  var React = _interopRequireWildcard(require("react"));
10
11
  var _uiHelpers = require("@megafon/ui-helpers");
12
+ var _Caption = _interopRequireDefault(require("../Caption/Caption"));
13
+ var _ValueField = _interopRequireDefault(require("../ValueField/ValueField"));
11
14
  var _PaginationButtons = _interopRequireDefault(require("./components/PaginationButtons/PaginationButtons"));
12
- var _PaginationNavigation = _interopRequireDefault(require("./components/PaginationNavigation/PaginationNavigation"));
13
- var _usePagination = _interopRequireWildcard(require("./usePagination"));
15
+ var _PaginationNavigation = _interopRequireWildcard(require("./components/PaginationNavigation/PaginationNavigation"));
16
+ var _helpers = require("./helpers");
17
+ var _types = require("./types");
18
+ var _usePagination2 = _interopRequireWildcard(require("./usePagination"));
14
19
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
15
20
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
16
21
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
@@ -18,11 +23,25 @@ var cn = (0, _uiHelpers.cnCreate)('mfui-pagination');
18
23
  var Pagination = function Pagination(_ref) {
19
24
  var totalPages = _ref.totalPages,
20
25
  activePage = _ref.activePage,
21
- dataAttrs = _ref.dataAttrs,
26
+ _ref$type = _ref.type,
27
+ type = _ref$type === void 0 ? _types.PaginationTypes.CLASSIC : _ref$type,
22
28
  _ref$theme = _ref.theme,
23
29
  theme = _ref$theme === void 0 ? 'default' : _ref$theme,
24
- onChange = _ref.onChange;
25
- var paginationItems = (0, _usePagination["default"])(totalPages, activePage);
30
+ showSelectPage = _ref.showSelectPage,
31
+ onChange = _ref.onChange,
32
+ className = _ref.className,
33
+ dataAttrs = _ref.dataAttrs;
34
+ var _usePagination = (0, _usePagination2["default"])(type, totalPages, activePage),
35
+ paginationItems = _usePagination.paginationItems,
36
+ skipPrevPage = _usePagination.skipPrevPage,
37
+ skipNextPage = _usePagination.skipNextPage;
38
+ var _React$useState = React.useState(''),
39
+ _React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2),
40
+ inputValue = _React$useState2[0],
41
+ setInputValue = _React$useState2[1];
42
+ var inputRef = React.useRef(null);
43
+ var isModernType = type === _types.PaginationTypes.MODERN;
44
+ var buttonForm = isModernType ? 'brick' : 'round';
26
45
  var handleBackClick = React.useCallback(function () {
27
46
  onChange(activePage - 1);
28
47
  }, [activePage, onChange]);
@@ -30,36 +49,89 @@ var Pagination = function Pagination(_ref) {
30
49
  onChange(activePage + 1);
31
50
  }, [activePage, onChange]);
32
51
  var handlePageButtonClick = React.useCallback(function (value) {
52
+ if (value === _usePagination2.BUTTONS.SKIP_PREV) {
53
+ onChange(skipPrevPage);
54
+ return;
55
+ }
56
+ if (value === _usePagination2.BUTTONS.SKIP_NEXT) {
57
+ onChange(skipNextPage);
58
+ return;
59
+ }
33
60
  value && onChange(value);
34
- }, [onChange]);
61
+ }, [onChange, skipNextPage, skipPrevPage]);
62
+ var handleInputSubmit = React.useCallback(function () {
63
+ var _a;
64
+ if (!inputValue) {
65
+ return;
66
+ }
67
+ var pageNumber = (0, _helpers.getInputRangeValue)(inputValue, totalPages, _usePagination2.BUTTONS.FIRST);
68
+ onChange(pageNumber);
69
+ setInputValue('');
70
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
71
+ }, [inputValue, onChange, totalPages]);
72
+ var handleInputChange = React.useCallback(function (e) {
73
+ var targetValue = (0, _helpers.removeFirstZeros)(e.target.value);
74
+ setInputValue(targetValue);
75
+ }, []);
35
76
  return /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
36
- className: cn()
37
- }), /*#__PURE__*/React.createElement(_PaginationNavigation["default"], {
77
+ className: cn([className])
78
+ }), /*#__PURE__*/React.createElement("div", {
79
+ className: cn('wrapper')
80
+ }, /*#__PURE__*/React.createElement(_PaginationNavigation["default"], {
81
+ className: cn('button'),
38
82
  dataAttrs: {
39
83
  root: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.prev
40
84
  },
41
85
  direction: "left",
42
- disabled: activePage === _usePagination.Button.FIRST,
43
- onClick: handleBackClick,
44
- className: cn('button'),
45
- theme: theme
86
+ form: buttonForm,
87
+ disabled: activePage === _usePagination2.BUTTONS.FIRST,
88
+ hint: isModernType ? _PaginationNavigation.HINTS.PREV : null,
89
+ theme: theme,
90
+ onClick: handleBackClick
46
91
  }), /*#__PURE__*/React.createElement(_PaginationButtons["default"], {
47
92
  dataAttrs: {
48
- root: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.button
93
+ button: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.button,
94
+ skipNext: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.skipNext,
95
+ skipPrev: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.skipPrev
49
96
  },
50
97
  items: paginationItems,
51
98
  activeButton: activePage,
52
- hiddenButton: _usePagination.Button.HIDDEN,
99
+ skipButtonPrev: _usePagination2.BUTTONS.SKIP_PREV,
100
+ skipButtonNext: _usePagination2.BUTTONS.SKIP_NEXT,
101
+ type: type,
102
+ form: buttonForm,
103
+ showHints: isModernType,
53
104
  theme: theme,
54
105
  onClick: handlePageButtonClick
55
106
  }), /*#__PURE__*/React.createElement(_PaginationNavigation["default"], {
107
+ className: cn('button'),
56
108
  dataAttrs: {
57
109
  root: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.next
58
110
  },
111
+ direction: "right",
112
+ form: buttonForm,
59
113
  disabled: activePage === totalPages,
60
- onClick: handleNextClick,
61
- className: cn('button'),
62
- theme: theme
63
- }));
114
+ hint: isModernType ? _PaginationNavigation.HINTS.NEXT : null,
115
+ theme: theme,
116
+ onClick: handleNextClick
117
+ })), showSelectPage && /*#__PURE__*/React.createElement("div", {
118
+ className: cn('input')
119
+ }, /*#__PURE__*/React.createElement(_Caption["default"], {
120
+ className: cn('input-caption'),
121
+ color: theme === 'light' ? 'white' : 'default',
122
+ hasMargin: false
123
+ }, "\u041D\u0430 \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u0443"), /*#__PURE__*/React.createElement(_ValueField["default"], {
124
+ className: cn('input-field'),
125
+ isControlled: true,
126
+ placeholder: "\u2116",
127
+ theme: (0, _helpers.setValueFieldTheme)(theme),
128
+ value: inputValue,
129
+ onChange: handleInputChange,
130
+ onBlur: handleInputSubmit,
131
+ dataAttrs: {
132
+ input: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.input
133
+ },
134
+ inputRef: inputRef
135
+ })));
64
136
  };
65
137
  var _default = exports["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-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;background-color:transparent;border:1px solid transparent;border-radius:50%;cursor:pointer;height:32px;padding:0;width:32px}.mfui-pagination-button svg{width:100%}.mfui-pagination-button:disabled{pointer-events:none}.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)}.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)}
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
- theme?: 'default' | 'light';
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?: PaginationValueType) => void;
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;
@@ -16,22 +16,32 @@ var PaginationButton = function PaginationButton(_ref) {
16
16
  isActive = _ref$isActive === void 0 ? false : _ref$isActive,
17
17
  _ref$theme = _ref.theme,
18
18
  theme = _ref$theme === void 0 ? 'default' : _ref$theme,
19
+ form = _ref.form,
20
+ autoWidth = _ref.autoWidth,
19
21
  className = _ref.className,
20
22
  children = _ref.children,
21
23
  onClick = _ref.onClick,
24
+ onMouseEnter = _ref.onMouseEnter,
25
+ onMouseLeave = _ref.onMouseLeave,
22
26
  value = _ref.value,
23
- dataAttrs = _ref.dataAttrs;
27
+ dataAttrs = _ref.dataAttrs,
28
+ rootRef = _ref.rootRef;
24
29
  var handleClick = function handleClick() {
25
30
  onClick === null || onClick === void 0 ? void 0 : onClick(value);
26
31
  };
27
32
  return /*#__PURE__*/_react["default"].createElement("button", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
28
33
  className: cn({
29
34
  active: isActive,
30
- theme: theme
35
+ theme: theme,
36
+ form: form,
37
+ 'auto-width': autoWidth
31
38
  }, className),
39
+ type: "button",
32
40
  disabled: disabled,
33
41
  onClick: handleClick,
34
- type: "button"
42
+ onMouseEnter: onMouseEnter,
43
+ onMouseLeave: onMouseLeave,
44
+ ref: rootRef
35
45
  }), children);
36
46
  };
37
47
  var _default = exports["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 { PaginationValueType } from '../PaginationButton/PaginationButton';
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
- theme?: 'default' | 'light';
6
+ type: PaginationTypesType;
7
+ form: ButtonFormType;
8
+ theme: ThemeType;
9
+ showHints: boolean;
7
10
  activeButton: number;
8
- hiddenButton: string;
11
+ skipButtonPrev: string;
12
+ skipButtonNext: string;
9
13
  dataAttrs?: {
10
- root?: Record<string, string>;
14
+ button?: Record<string, string>;
15
+ skipNext?: Record<string, string>;
16
+ skipPrev?: Record<string, string>;
11
17
  };
12
- onClick: (value?: PaginationValueType) => void;
18
+ onClick: (value?: ValueType) => void;
13
19
  }
14
20
  declare const PaginationButtons: React.FC<IPaginationButtonsProps>;
15
21
  export default PaginationButtons;
@@ -1,60 +1,80 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports["default"] = void 0;
7
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
8
8
  require("core-js/modules/es.array.map.js");
9
9
  var _react = _interopRequireDefault(require("react"));
10
10
  var _uiHelpers = require("@megafon/ui-helpers");
11
+ var _types = require("../../types");
11
12
  var _PaginationButton = _interopRequireDefault(require("../PaginationButton/PaginationButton"));
13
+ var _PaginationNavigation = _interopRequireWildcard(require("../PaginationNavigation/PaginationNavigation"));
14
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
15
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
12
16
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
13
- var NothingIcon = function NothingIcon(props) {
14
- return /*#__PURE__*/_react["default"].createElement("svg", (0, _extends2["default"])({
15
- viewBox: "0 0 20 20"
16
- }, props), /*#__PURE__*/_react["default"].createElement("path", {
17
- 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"
18
- }));
19
- };
20
17
  var cn = (0, _uiHelpers.cnCreate)('mfui-pagination-buttons');
21
18
  var PaginationButtons = function PaginationButtons(_ref) {
22
19
  var items = _ref.items,
20
+ type = _ref.type,
23
21
  theme = _ref.theme,
22
+ form = _ref.form,
23
+ showHints = _ref.showHints,
24
24
  onClick = _ref.onClick,
25
25
  activeButton = _ref.activeButton,
26
- hiddenButton = _ref.hiddenButton,
26
+ skipButtonPrev = _ref.skipButtonPrev,
27
+ skipButtonNext = _ref.skipButtonNext,
27
28
  dataAttrs = _ref.dataAttrs;
29
+ var isModernType = type === _types.PaginationTypes.MODERN;
28
30
  return /*#__PURE__*/_react["default"].createElement("div", {
29
31
  className: cn()
30
32
  }, items.map(function (pageNumber, index) {
31
- var isHiddenButton = hiddenButton === pageNumber;
33
+ var isSkipButtonPrev = skipButtonPrev === pageNumber;
34
+ var isSkipButtonNext = skipButtonNext === pageNumber;
32
35
  var dataIndex = typeof pageNumber === 'number' ? pageNumber : undefined;
33
- if (isHiddenButton) {
34
- return /*#__PURE__*/_react["default"].createElement(_PaginationButton["default"], {
35
- disabled: true,
36
+ if (isSkipButtonPrev || isSkipButtonNext) {
37
+ var hint = isSkipButtonNext ? _PaginationNavigation.HINTS.SKIP_NEXT : _PaginationNavigation.HINTS.SKIP_PREV;
38
+ return /*#__PURE__*/_react["default"].createElement(_PaginationNavigation["default"], {
36
39
  key: index,
40
+ className: cn('button', {
41
+ form: form
42
+ }),
37
43
  theme: theme,
38
- className: cn('button'),
44
+ form: form,
45
+ value: pageNumber,
46
+ variant: "skip",
47
+ disabled: !isModernType,
48
+ direction: isSkipButtonNext ? 'right' : 'left',
49
+ hint: showHints ? hint : null,
50
+ onClick: onClick,
39
51
  dataAttrs: {
40
- root: {
41
- 'data-testid': 'hiddenButton'
42
- }
52
+ root: isSkipButtonNext ? dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.skipNext : dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.skipPrev
43
53
  }
44
- }, /*#__PURE__*/_react["default"].createElement(NothingIcon, null));
54
+ });
45
55
  }
46
56
  var isActive = pageNumber === activeButton;
57
+ var digitCount = String(pageNumber).length;
58
+ var pageNumberStyle = isModernType ? {
59
+ width: 10 * digitCount
60
+ } : undefined;
47
61
  return /*#__PURE__*/_react["default"].createElement(_PaginationButton["default"], {
62
+ key: index,
63
+ className: cn('button', {
64
+ form: form
65
+ }),
48
66
  dataAttrs: {
49
- root: (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root, dataIndex)
67
+ root: (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.button, dataIndex)
50
68
  },
51
- isActive: isActive,
52
- key: index,
53
- className: cn('button'),
54
- onClick: onClick,
69
+ theme: theme,
70
+ form: form,
55
71
  value: pageNumber,
56
- theme: theme
57
- }, pageNumber);
72
+ autoWidth: isModernType,
73
+ isActive: isActive,
74
+ onClick: onClick
75
+ }, /*#__PURE__*/_react["default"].createElement("div", {
76
+ style: pageNumberStyle
77
+ }, pageNumber));
58
78
  }));
59
79
  };
60
80
  var _default = exports["default"] = PaginationButtons;
@@ -1 +1 @@
1
- h1,h2,h3,h4,h5{margin:0}.mfui-pagination-navigation_direction_left .mfui-pagination-navigation__icon{-webkit-transform:rotate(180deg);transform:rotate(180deg)}.mfui-pagination-navigation svg{width:100%}.mfui-pagination-navigation:disabled svg{opacity:.25}
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}
@@ -1,16 +1,25 @@
1
1
  import React from 'react';
2
- import { PaginationValueType } from '../PaginationButton/PaginationButton';
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
- theme?: 'default' | 'light';
14
+ variant?: 'default' | 'skip';
7
15
  disabled?: boolean;
8
- isActive?: boolean;
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?: PaginationValueType) => void;
22
+ onClick?: (value?: ValueType) => void;
14
23
  }
15
24
  declare const PaginationNavigation: React.FC<IPaginationNavigationProps>;
16
25
  export default PaginationNavigation;
@@ -3,12 +3,22 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports["default"] = void 0;
6
+ exports["default"] = exports.HINTS = void 0;
7
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
7
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ require("core-js/modules/web.timers.js");
8
10
  var _react = _interopRequireDefault(require("react"));
9
11
  var _uiHelpers = require("@megafon/ui-helpers");
12
+ var _Tooltip = _interopRequireDefault(require("../../../Tooltip/Tooltip"));
10
13
  var _PaginationButton = _interopRequireDefault(require("../PaginationButton/PaginationButton"));
11
14
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
15
+ var NothingIcon = function NothingIcon(props) {
16
+ return /*#__PURE__*/_react["default"].createElement("svg", (0, _extends2["default"])({
17
+ viewBox: "0 0 20 20"
18
+ }, props), /*#__PURE__*/_react["default"].createElement("path", {
19
+ 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"
20
+ }));
21
+ };
12
22
  var ArrowRightIcon = function ArrowRightIcon(props) {
13
23
  return /*#__PURE__*/_react["default"].createElement("svg", (0, _extends2["default"])({
14
24
  viewBox: "0 0 32 32"
@@ -16,27 +26,111 @@ var ArrowRightIcon = function ArrowRightIcon(props) {
16
26
  d: "M12.5 20.8l4.8-4.8-4.8-4.8 1.6-1.7 6.4 6.5-6.4 6.5z"
17
27
  }));
18
28
  };
29
+ var ArrowsRightIcon = function ArrowsRightIcon(props) {
30
+ return /*#__PURE__*/_react["default"].createElement("svg", (0, _extends2["default"])({
31
+ viewBox: "0 0 20 20"
32
+ }, props), /*#__PURE__*/_react["default"].createElement("path", {
33
+ 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"
34
+ }));
35
+ };
36
+ var HINTS = exports.HINTS = {
37
+ PREV: 'Предыдущая страница',
38
+ SKIP_PREV: 'Предыдущие 4 страницы',
39
+ SKIP_NEXT: 'Следующие 4 страницы',
40
+ NEXT: 'Следующая страница'
41
+ };
42
+ var delayShow = 250;
43
+ var delayHide = 50;
19
44
  var cn = (0, _uiHelpers.cnCreate)('mfui-pagination-navigation');
20
45
  var PaginationNavigation = function PaginationNavigation(_ref) {
21
- var _ref$direction = _ref.direction,
46
+ var variant = _ref.variant,
47
+ _ref$direction = _ref.direction,
22
48
  direction = _ref$direction === void 0 ? 'right' : _ref$direction,
23
49
  theme = _ref.theme,
50
+ form = _ref.form,
24
51
  disabled = _ref.disabled,
25
- isActive = _ref.isActive,
52
+ value = _ref.value,
53
+ hint = _ref.hint,
26
54
  onClick = _ref.onClick,
27
55
  className = _ref.className,
28
56
  dataAttrs = _ref.dataAttrs;
29
- return /*#__PURE__*/_react["default"].createElement(_PaginationButton["default"], {
30
- dataAttrs: dataAttrs,
31
- className: cn({
57
+ var isTouch = (0, _uiHelpers.detectTouch)();
58
+ var _React$useState = _react["default"].useState(null),
59
+ _React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2),
60
+ timeoutId = _React$useState2[0],
61
+ setTimeoutId = _React$useState2[1];
62
+ var _React$useState3 = _react["default"].useState(false),
63
+ _React$useState4 = (0, _slicedToArray2["default"])(_React$useState3, 2),
64
+ isHovered = _React$useState4[0],
65
+ setIsHovered = _React$useState4[1];
66
+ var triggerRef = _react["default"].useRef(null);
67
+ var hasHint = !!hint && !disabled && !isTouch;
68
+ var handleClick = _react["default"].useCallback(function () {
69
+ onClick === null || onClick === void 0 ? void 0 : onClick(value);
70
+ }, [onClick, value]);
71
+ var handleHover = _react["default"].useCallback(function (isHovering) {
72
+ if (timeoutId) {
73
+ clearTimeout(timeoutId);
74
+ }
75
+ var delay = isHovering ? delayShow : delayHide;
76
+ var newTimeoutId = setTimeout(function () {
77
+ setIsHovered(isHovering);
78
+ }, delay);
79
+ setTimeoutId(newTimeoutId);
80
+ }, [timeoutId]);
81
+ var handleMouseEnter = _react["default"].useCallback(function () {
82
+ return handleHover(true);
83
+ }, [handleHover]);
84
+ var handleMouseLeave = _react["default"].useCallback(function () {
85
+ return handleHover(false);
86
+ }, [handleHover]);
87
+ var renderIcon = function renderIcon() {
88
+ if (variant === 'skip') {
89
+ return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(NothingIcon, {
90
+ className: cn('skip-icon-base')
91
+ }), !disabled && /*#__PURE__*/_react["default"].createElement(ArrowsRightIcon, {
92
+ className: cn('skip-icon-hover')
93
+ }));
94
+ }
95
+ return /*#__PURE__*/_react["default"].createElement(ArrowRightIcon, {
96
+ className: cn('arrow-icon')
97
+ });
98
+ };
99
+ _react["default"].useEffect(function () {
100
+ if (disabled) {
101
+ setIsHovered(false);
102
+ timeoutId && clearTimeout(timeoutId);
103
+ }
104
+ return function () {
105
+ if (timeoutId) {
106
+ clearTimeout(timeoutId);
107
+ }
108
+ };
109
+ }, [disabled, timeoutId]);
110
+ return /*#__PURE__*/_react["default"].createElement("div", {
111
+ className: cn([className])
112
+ }, /*#__PURE__*/_react["default"].createElement(_PaginationButton["default"], {
113
+ className: cn('button', {
32
114
  direction: direction
33
- }, className),
115
+ }),
116
+ dataAttrs: dataAttrs,
34
117
  disabled: disabled,
35
- isActive: isActive,
36
118
  theme: theme,
37
- onClick: onClick
38
- }, /*#__PURE__*/_react["default"].createElement(ArrowRightIcon, {
119
+ form: form,
120
+ onClick: handleClick,
121
+ onMouseEnter: hasHint ? handleMouseEnter : undefined,
122
+ onMouseLeave: hasHint ? handleMouseLeave : undefined,
123
+ rootRef: triggerRef
124
+ }, /*#__PURE__*/_react["default"].createElement("div", {
39
125
  className: cn('icon')
40
- }));
126
+ }, renderIcon())), hasHint && /*#__PURE__*/_react["default"].createElement(_Tooltip["default"], {
127
+ isOpened: isHovered,
128
+ triggerEvent: "controlled",
129
+ triggerElement: triggerRef,
130
+ colorTheme: "blue",
131
+ placement: "bottom",
132
+ fallbackPlacements: ['bottom'],
133
+ offset: "small"
134
+ }, hint));
41
135
  };
42
136
  var _default = exports["default"] = PaginationNavigation;
@@ -1,2 +1,8 @@
1
- declare const getRange: (from: number, to: number, step?: number) => number[];
2
- export default getRange;
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;
@@ -3,8 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports["default"] = void 0;
7
- var getRange = function getRange(from, to) {
6
+ exports.setValueFieldTheme = exports.removeFirstZeros = exports.getRange = exports.getInputRangeValue = void 0;
7
+ require("core-js/modules/es.number.constructor.js");
8
+ require("core-js/modules/es.regexp.exec.js");
9
+ require("core-js/modules/es.regexp.test.js");
10
+ require("core-js/modules/es.string.replace.js");
11
+ var getRange = exports.getRange = function getRange(from, to) {
8
12
  var step = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
9
13
  var i = from;
10
14
  var range = [];
@@ -14,4 +18,26 @@ var getRange = function getRange(from, to) {
14
18
  }
15
19
  return range;
16
20
  };
17
- var _default = exports["default"] = getRange;
21
+ var removeFirstZeros = exports.removeFirstZeros = function removeFirstZeros(value) {
22
+ return /^0.+/.test(value) ? value.replace(/^(0)+/, '') : value;
23
+ };
24
+ var getInputRangeValue = exports.getInputRangeValue = function getInputRangeValue(value, maxValue, minValue) {
25
+ var numberValue = Number(value);
26
+ if (numberValue > maxValue) {
27
+ return maxValue;
28
+ }
29
+ if (numberValue < minValue) {
30
+ return minValue;
31
+ }
32
+ return numberValue;
33
+ };
34
+ var setValueFieldTheme = exports.setValueFieldTheme = function setValueFieldTheme(theme) {
35
+ switch (theme) {
36
+ case 'light':
37
+ return 'color';
38
+ case 'gray':
39
+ return 'gray';
40
+ default:
41
+ return 'default';
42
+ }
43
+ };
@@ -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 {};
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PaginationTypes = void 0;
7
+ var PaginationTypes = exports.PaginationTypes = {
8
+ CLASSIC: 'classic',
9
+ MODERN: 'modern'
10
+ };