@alfalab/core-components-pagination 1.1.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 (59) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/Component.d.ts +41 -0
  3. package/dist/Component.js +42 -0
  4. package/dist/components/default-view/index.css +22 -0
  5. package/dist/components/default-view/index.d.ts +5 -0
  6. package/dist/components/default-view/index.js +56 -0
  7. package/dist/components/per-page-view/index.css +16 -0
  8. package/dist/components/per-page-view/index.d.ts +5 -0
  9. package/dist/components/per-page-view/index.js +23 -0
  10. package/dist/components/tag/index.css +52 -0
  11. package/dist/components/tag/index.d.ts +4 -0
  12. package/dist/components/tag/index.js +62 -0
  13. package/dist/cssm/Component.d.ts +41 -0
  14. package/dist/cssm/Component.js +44 -0
  15. package/dist/cssm/components/default-view/index.d.ts +5 -0
  16. package/dist/cssm/components/default-view/index.js +56 -0
  17. package/dist/cssm/components/default-view/index.module.css +21 -0
  18. package/dist/cssm/components/per-page-view/index.d.ts +5 -0
  19. package/dist/cssm/components/per-page-view/index.js +22 -0
  20. package/dist/cssm/components/per-page-view/index.module.css +15 -0
  21. package/dist/cssm/components/tag/index.d.ts +4 -0
  22. package/dist/cssm/components/tag/index.js +61 -0
  23. package/dist/cssm/components/tag/index.module.css +51 -0
  24. package/dist/cssm/index.d.ts +1 -0
  25. package/dist/cssm/index.js +21 -0
  26. package/dist/cssm/index.module.css +31 -0
  27. package/dist/esm/Component.d.ts +41 -0
  28. package/dist/esm/Component.js +33 -0
  29. package/dist/esm/components/default-view/index.css +22 -0
  30. package/dist/esm/components/default-view/index.d.ts +5 -0
  31. package/dist/esm/components/default-view/index.js +48 -0
  32. package/dist/esm/components/per-page-view/index.css +16 -0
  33. package/dist/esm/components/per-page-view/index.d.ts +5 -0
  34. package/dist/esm/components/per-page-view/index.js +15 -0
  35. package/dist/esm/components/tag/index.css +52 -0
  36. package/dist/esm/components/tag/index.d.ts +4 -0
  37. package/dist/esm/components/tag/index.js +53 -0
  38. package/dist/esm/index.css +32 -0
  39. package/dist/esm/index.d.ts +1 -0
  40. package/dist/esm/index.js +9 -0
  41. package/dist/index.css +32 -0
  42. package/dist/index.d.ts +1 -0
  43. package/dist/index.js +17 -0
  44. package/dist/modern/Component.d.ts +41 -0
  45. package/dist/modern/Component.js +32 -0
  46. package/dist/modern/components/default-view/index.css +22 -0
  47. package/dist/modern/components/default-view/index.d.ts +5 -0
  48. package/dist/modern/components/default-view/index.js +47 -0
  49. package/dist/modern/components/per-page-view/index.css +16 -0
  50. package/dist/modern/components/per-page-view/index.d.ts +5 -0
  51. package/dist/modern/components/per-page-view/index.js +12 -0
  52. package/dist/modern/components/tag/index.css +52 -0
  53. package/dist/modern/components/tag/index.d.ts +4 -0
  54. package/dist/modern/components/tag/index.js +10 -0
  55. package/dist/modern/index.css +32 -0
  56. package/dist/modern/index.d.ts +1 -0
  57. package/dist/modern/index.js +9 -0
  58. package/dist/send-stats.js +82 -0
  59. package/package.json +25 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ # 1.1.0 (2021-12-29)
7
+
8
+
9
+ ### Features
10
+
11
+ * **table:** компоненты для построения таблиц ([#911](https://github.com/alfa-laboratory/core-components/issues/911)) ([4ac648a](https://github.com/alfa-laboratory/core-components/commit/4ac648abd4de08bf68babc2f122f432d5b14080e))
@@ -0,0 +1,41 @@
1
+ import { FC } from 'react';
2
+ type PaginationProps = {
3
+ /**
4
+ * Текущая страница (с нуля)
5
+ */
6
+ currentPageIndex: number;
7
+ /**
8
+ * Количество страниц
9
+ */
10
+ pagesCount: number;
11
+ /**
12
+ * Дополнительный класс
13
+ */
14
+ className?: string;
15
+ /**
16
+ * Скрывает стрелки, если выбрана первая или последняя страница
17
+ */
18
+ hideArrows?: boolean;
19
+ /**
20
+ * Количество видимых страниц по бокам
21
+ */
22
+ sidePadding?: number;
23
+ /**
24
+ * Количество видимых страниц вокруг выбранной
25
+ */
26
+ activePadding?: number;
27
+ /**
28
+ * Режим пагинации
29
+ */
30
+ view?: 'default' | 'per-page';
31
+ /**
32
+ * Обработчик переключения страницы
33
+ */
34
+ onPageChange?: (pageIndex: number) => void;
35
+ /**
36
+ * Идентификатор для систем автоматизированного тестирования
37
+ */
38
+ dataTestId?: string;
39
+ };
40
+ declare const Pagination: FC<PaginationProps>;
41
+ export { PaginationProps, Pagination };
@@ -0,0 +1,42 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ var cn = require('classnames');
7
+ var ChevronBackMIcon = require('@alfalab/icons-glyph/ChevronBackMIcon');
8
+ var ChevronForwardMIcon = require('@alfalab/icons-glyph/ChevronForwardMIcon');
9
+ var components_tag_index = require('./components/tag/index.js');
10
+ require('@alfalab/core-components-tag');
11
+ var components_defaultView_index = require('./components/default-view/index.js');
12
+ var components_perPageView_index = require('./components/per-page-view/index.js');
13
+
14
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
15
+
16
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
17
+ var cn__default = /*#__PURE__*/_interopDefaultLegacy(cn);
18
+
19
+ var styles = {"component":"pagination__component_1bqlk","default":"pagination__default_1bqlk"};
20
+ require('./index.css')
21
+
22
+ var Pagination = function (_a) {
23
+ var _b = _a.currentPageIndex, currentPageIndex = _b === void 0 ? 0 : _b, pagesCount = _a.pagesCount, className = _a.className, _c = _a.sidePadding, sidePadding = _c === void 0 ? 1 : _c, _d = _a.activePadding, activePadding = _d === void 0 ? 2 : _d, _e = _a.hideArrows, hideArrows = _e === void 0 ? true : _e, _f = _a.view, view = _f === void 0 ? 'default' : _f, _g = _a.onPageChange, onPageChange = _g === void 0 ? function () { return null; } : _g, dataTestId = _a.dataTestId;
24
+ var handlePageClick = function (pageIndex) {
25
+ onPageChange(pageIndex);
26
+ };
27
+ var handleNextPageClick = function () {
28
+ handlePageClick(Math.min(pagesCount - 1, currentPageIndex + 1));
29
+ };
30
+ var handlePrevPageClick = function () {
31
+ handlePageClick(Math.max(0, currentPageIndex - 1));
32
+ };
33
+ var shouldRenderPrevArrow = view === 'per-page' || !hideArrows || currentPageIndex > 0;
34
+ var shouldRenderNextArrow = view === 'per-page' || !hideArrows || currentPageIndex < pagesCount - 1;
35
+ return (React__default['default'].createElement("div", { className: cn__default['default'](styles.component, className, styles[view]), "data-test-id": dataTestId },
36
+ shouldRenderPrevArrow && (React__default['default'].createElement(components_tag_index.Tag, { className: styles.arrow, disabled: currentPageIndex <= 0, onClick: handlePrevPageClick, rightAddons: React__default['default'].createElement(ChevronBackMIcon.ChevronBackMIcon, { width: 16, height: 16 }) })),
37
+ view === 'default' && (React__default['default'].createElement(components_defaultView_index.DefaultView, { activePadding: activePadding, sidePadding: sidePadding, currentPageIndex: currentPageIndex, pagesCount: pagesCount, onPageChange: handlePageClick })),
38
+ view === 'per-page' && (React__default['default'].createElement(components_perPageView_index.PerPageView, { currentPageIndex: currentPageIndex, pagesCount: pagesCount })),
39
+ shouldRenderNextArrow && (React__default['default'].createElement(components_tag_index.Tag, { className: styles.arrow, disabled: currentPageIndex >= pagesCount - 1, onClick: handleNextPageClick, rightAddons: React__default['default'].createElement(ChevronForwardMIcon.ChevronForwardMIcon, { width: 16, height: 16 }) }))));
40
+ };
41
+
42
+ exports.Pagination = Pagination;
@@ -0,0 +1,22 @@
1
+ /* hash: a3bgi */
2
+ :root {
3
+ --color-light-text-secondary: #546272;
4
+ }
5
+ :root {
6
+
7
+ /* Hard */
8
+
9
+ /* Up */
10
+
11
+ /* Hard up */
12
+ }
13
+ .pagination__dots_kix4e {
14
+ width: 32px;
15
+ height: 32px;
16
+ text-align: center;
17
+ display: flex;
18
+ align-items: center;
19
+ justify-content: center;
20
+ color: var(--color-light-text-secondary);
21
+ cursor: default;
22
+ }
@@ -0,0 +1,5 @@
1
+ import { FC } from 'react';
2
+ import { PaginationProps } from "../../Component";
3
+ type DefaultViewProps = Pick<PaginationProps, 'sidePadding' | 'activePadding' | 'pagesCount' | 'currentPageIndex' | 'onPageChange'>;
4
+ declare const DefaultView: FC<DefaultViewProps>;
5
+ export { DefaultView };
@@ -0,0 +1,56 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ require('classnames');
7
+ var components_tag_index = require('../tag/index.js');
8
+ require('@alfalab/core-components-tag');
9
+
10
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
11
+
12
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
13
+
14
+ var styles = {"dots":"pagination__dots_kix4e"};
15
+ require('./index.css')
16
+
17
+ var DefaultView = function (_a) {
18
+ var _b = _a.sidePadding, sidePadding = _b === void 0 ? 2 : _b, _c = _a.activePadding, activePadding = _c === void 0 ? 1 : _c, pagesCount = _a.pagesCount, currentPageIndex = _a.currentPageIndex, _d = _a.onPageChange, onPageChange = _d === void 0 ? function () { return null; } : _d;
19
+ var maxHalfCount = sidePadding + activePadding + 1;
20
+ var maxElementsCount = maxHalfCount * 2 + 1;
21
+ var itemsFit = pagesCount <= maxElementsCount;
22
+ var elementsCount = itemsFit ? pagesCount : maxElementsCount;
23
+ var getPageIndex = React.useCallback(function (elementIndex) {
24
+ var lastIndex = pagesCount - 1;
25
+ var reverseIndex = lastIndex - currentPageIndex;
26
+ var lastElementIndex = elementsCount - 1;
27
+ var reverseElementIndex = lastElementIndex - elementIndex;
28
+ var hasCollapsedItems = function (index) { return !itemsFit && index >= maxHalfCount; };
29
+ if (elementIndex < sidePadding) {
30
+ return elementIndex;
31
+ }
32
+ if (elementIndex === sidePadding && hasCollapsedItems(currentPageIndex)) {
33
+ return null;
34
+ }
35
+ if (reverseElementIndex === sidePadding && hasCollapsedItems(reverseIndex)) {
36
+ return null;
37
+ }
38
+ if (reverseElementIndex < sidePadding) {
39
+ return lastIndex - reverseElementIndex;
40
+ }
41
+ var computedIndex = currentPageIndex - maxHalfCount + elementIndex;
42
+ return Math.min(lastIndex - reverseElementIndex, Math.max(elementIndex, computedIndex));
43
+ }, [currentPageIndex, elementsCount, itemsFit, maxHalfCount, pagesCount, sidePadding]);
44
+ return (React__default['default'].createElement(React__default['default'].Fragment, null, Array(elementsCount)
45
+ .fill('')
46
+ .map(function (_, i) {
47
+ var pageIndex = getPageIndex(i);
48
+ if (pageIndex === null) {
49
+ return (React__default['default'].createElement("div", { key: i.toString(), className: styles.dots }, "..."));
50
+ }
51
+ var active = currentPageIndex === pageIndex;
52
+ return (React__default['default'].createElement(components_tag_index.Tag, { key: i.toString(), checked: active, disabled: active, onClick: function () { return onPageChange(pageIndex); } }, pageIndex + 1));
53
+ })));
54
+ };
55
+
56
+ exports.DefaultView = DefaultView;
@@ -0,0 +1,16 @@
1
+ /* hash: 1ylzb */
2
+ :root {
3
+
4
+ /* Hard */
5
+
6
+ /* Up */
7
+
8
+ /* Hard up */
9
+ }
10
+ :root {
11
+ --gap-m: 16px;
12
+ }
13
+ .pagination__component_begf8 {
14
+ display: block;
15
+ margin: 0 var(--gap-m);
16
+ }
@@ -0,0 +1,5 @@
1
+ import { FC } from 'react';
2
+ import { PaginationProps } from "../../Component";
3
+ type PerPageViewProps = Pick<PaginationProps, 'pagesCount' | 'currentPageIndex'>;
4
+ declare const PerPageView: FC<PerPageViewProps>;
5
+ export { PerPageView };
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+
7
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
+
9
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
10
+
11
+ var styles = {"component":"pagination__component_begf8"};
12
+ require('./index.css')
13
+
14
+ var PerPageView = function (_a) {
15
+ var pagesCount = _a.pagesCount, currentPageIndex = _a.currentPageIndex;
16
+ return (React__default['default'].createElement("span", { className: styles.component },
17
+ currentPageIndex + 1,
18
+ " \u0438\u0437 ",
19
+ pagesCount,
20
+ " \u0441\u0442\u0440\u0430\u043D\u0438\u0446"));
21
+ };
22
+
23
+ exports.PerPageView = PerPageView;
@@ -0,0 +1,52 @@
1
+ /* hash: x8h03 */
2
+ :root {
3
+ --color-light-bg-neutral: #dbdee1;
4
+ --color-light-bg-secondary-inverted: #233549;
5
+ --color-light-bg-tertiary: #e7e9eb;
6
+ --color-light-text-primary: #0b1f35;
7
+ --color-light-text-primary-inverted: #fff;
8
+ --color-light-text-secondary: #546272;
9
+ }
10
+ :root {
11
+
12
+ /* Hard */
13
+
14
+ /* Up */
15
+
16
+ /* Hard up */
17
+ }
18
+ :root {
19
+ --border-radius-m: 8px;
20
+ }
21
+ .pagination__tag_1gidc.pagination__tag_1gidc {
22
+ color: var(--color-light-text-secondary);
23
+ border-radius: var(--border-radius-m);
24
+ border: none;
25
+ flex-shrink: 0;
26
+ min-width: auto;
27
+ min-height: auto;
28
+ width: 32px;
29
+ height: 32px;
30
+ padding: 0
31
+ }
32
+ .pagination__tag_1gidc.pagination__tag_1gidc:disabled:not(.pagination__checked_1gidc) {
33
+ opacity: 0.3;
34
+ }
35
+ .pagination__tag_1gidc.pagination__tag_1gidc:hover:not(:disabled) {
36
+ background-color: var(--color-light-bg-tertiary);
37
+ color: var(--color-light-text-primary);
38
+ }
39
+ .pagination__tag_1gidc.pagination__tag_1gidc:active:not(:disabled) {
40
+ background-color: var(--color-light-bg-neutral);
41
+ }
42
+ .pagination__tag_1gidc.pagination__tag_1gidc.pagination__checked_1gidc {
43
+ cursor: default;
44
+ background-color: var(--color-light-bg-secondary-inverted);
45
+ color: var(--color-light-text-primary-inverted);
46
+ }
47
+ .pagination__tag_1gidc.pagination__tag_1gidc.pagination__checked_1gidc:hover:not(:disabled) {
48
+ color: var(--color-light-text-primary-inverted);
49
+ }
50
+ .pagination__tag_1gidc.pagination__tag_1gidc.pagination__checked_1gidc:active:not(:disabled) {
51
+ color: var(--color-light-text-primary);
52
+ }
@@ -0,0 +1,4 @@
1
+ import { FC } from 'react';
2
+ import { TagProps } from "@alfalab/core-components-tag";
3
+ declare const Tag: FC<TagProps>;
4
+ export { Tag };
@@ -0,0 +1,62 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ var cn = require('classnames');
7
+ var coreComponentsTag = require('@alfalab/core-components-tag');
8
+
9
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
+
11
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
12
+ var cn__default = /*#__PURE__*/_interopDefaultLegacy(cn);
13
+
14
+ /*! *****************************************************************************
15
+ Copyright (c) Microsoft Corporation.
16
+
17
+ Permission to use, copy, modify, and/or distribute this software for any
18
+ purpose with or without fee is hereby granted.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
21
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
22
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
23
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
24
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
25
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
26
+ PERFORMANCE OF THIS SOFTWARE.
27
+ ***************************************************************************** */
28
+ var __assign = function () {
29
+ __assign = Object.assign || function __assign(t) {
30
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
31
+ s = arguments[i];
32
+ for (var p in s)
33
+ if (Object.prototype.hasOwnProperty.call(s, p))
34
+ t[p] = s[p];
35
+ }
36
+ return t;
37
+ };
38
+ return __assign.apply(this, arguments);
39
+ };
40
+ function __rest(s, e) {
41
+ var t = {};
42
+ for (var p in s)
43
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
44
+ t[p] = s[p];
45
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
46
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
47
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
48
+ t[p[i]] = s[p[i]];
49
+ }
50
+ return t;
51
+ }
52
+
53
+ var styles = {"tag":"pagination__tag_1gidc","checked":"pagination__checked_1gidc"};
54
+ require('./index.css')
55
+
56
+ var Tag = function (_a) {
57
+ var _b;
58
+ var className = _a.className, checked = _a.checked, restProps = __rest(_a, ["className", "checked"]);
59
+ return (React__default['default'].createElement(coreComponentsTag.Tag, __assign({}, restProps, { checked: checked, size: 'xxs', className: cn__default['default'](className, styles.tag, (_b = {}, _b[styles.checked] = checked, _b)) })));
60
+ };
61
+
62
+ exports.Tag = Tag;
@@ -0,0 +1,41 @@
1
+ import { FC } from 'react';
2
+ type PaginationProps = {
3
+ /**
4
+ * Текущая страница (с нуля)
5
+ */
6
+ currentPageIndex: number;
7
+ /**
8
+ * Количество страниц
9
+ */
10
+ pagesCount: number;
11
+ /**
12
+ * Дополнительный класс
13
+ */
14
+ className?: string;
15
+ /**
16
+ * Скрывает стрелки, если выбрана первая или последняя страница
17
+ */
18
+ hideArrows?: boolean;
19
+ /**
20
+ * Количество видимых страниц по бокам
21
+ */
22
+ sidePadding?: number;
23
+ /**
24
+ * Количество видимых страниц вокруг выбранной
25
+ */
26
+ activePadding?: number;
27
+ /**
28
+ * Режим пагинации
29
+ */
30
+ view?: 'default' | 'per-page';
31
+ /**
32
+ * Обработчик переключения страницы
33
+ */
34
+ onPageChange?: (pageIndex: number) => void;
35
+ /**
36
+ * Идентификатор для систем автоматизированного тестирования
37
+ */
38
+ dataTestId?: string;
39
+ };
40
+ declare const Pagination: FC<PaginationProps>;
41
+ export { PaginationProps, Pagination };
@@ -0,0 +1,44 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ var cn = require('classnames');
7
+ var ChevronBackMIcon = require('@alfalab/icons-glyph/ChevronBackMIcon');
8
+ var ChevronForwardMIcon = require('@alfalab/icons-glyph/ChevronForwardMIcon');
9
+ var components_tag_index = require('./components/tag/index.js');
10
+ require('@alfalab/core-components-tag/dist/cssm');
11
+ require('./components/tag/index.module.css');
12
+ require('./components/default-view/index.module.css');
13
+ var components_defaultView_index = require('./components/default-view/index.js');
14
+ require('./components/per-page-view/index.module.css');
15
+ var components_perPageView_index = require('./components/per-page-view/index.js');
16
+ var styles = require('./index.module.css');
17
+
18
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
19
+
20
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
21
+ var cn__default = /*#__PURE__*/_interopDefaultLegacy(cn);
22
+ var styles__default = /*#__PURE__*/_interopDefaultLegacy(styles);
23
+
24
+ var Pagination = function (_a) {
25
+ var _b = _a.currentPageIndex, currentPageIndex = _b === void 0 ? 0 : _b, pagesCount = _a.pagesCount, className = _a.className, _c = _a.sidePadding, sidePadding = _c === void 0 ? 1 : _c, _d = _a.activePadding, activePadding = _d === void 0 ? 2 : _d, _e = _a.hideArrows, hideArrows = _e === void 0 ? true : _e, _f = _a.view, view = _f === void 0 ? 'default' : _f, _g = _a.onPageChange, onPageChange = _g === void 0 ? function () { return null; } : _g, dataTestId = _a.dataTestId;
26
+ var handlePageClick = function (pageIndex) {
27
+ onPageChange(pageIndex);
28
+ };
29
+ var handleNextPageClick = function () {
30
+ handlePageClick(Math.min(pagesCount - 1, currentPageIndex + 1));
31
+ };
32
+ var handlePrevPageClick = function () {
33
+ handlePageClick(Math.max(0, currentPageIndex - 1));
34
+ };
35
+ var shouldRenderPrevArrow = view === 'per-page' || !hideArrows || currentPageIndex > 0;
36
+ var shouldRenderNextArrow = view === 'per-page' || !hideArrows || currentPageIndex < pagesCount - 1;
37
+ return (React__default['default'].createElement("div", { className: cn__default['default'](styles__default['default'].component, className, styles__default['default'][view]), "data-test-id": dataTestId },
38
+ shouldRenderPrevArrow && (React__default['default'].createElement(components_tag_index.Tag, { className: styles__default['default'].arrow, disabled: currentPageIndex <= 0, onClick: handlePrevPageClick, rightAddons: React__default['default'].createElement(ChevronBackMIcon.ChevronBackMIcon, { width: 16, height: 16 }) })),
39
+ view === 'default' && (React__default['default'].createElement(components_defaultView_index.DefaultView, { activePadding: activePadding, sidePadding: sidePadding, currentPageIndex: currentPageIndex, pagesCount: pagesCount, onPageChange: handlePageClick })),
40
+ view === 'per-page' && (React__default['default'].createElement(components_perPageView_index.PerPageView, { currentPageIndex: currentPageIndex, pagesCount: pagesCount })),
41
+ shouldRenderNextArrow && (React__default['default'].createElement(components_tag_index.Tag, { className: styles__default['default'].arrow, disabled: currentPageIndex >= pagesCount - 1, onClick: handleNextPageClick, rightAddons: React__default['default'].createElement(ChevronForwardMIcon.ChevronForwardMIcon, { width: 16, height: 16 }) }))));
42
+ };
43
+
44
+ exports.Pagination = Pagination;
@@ -0,0 +1,5 @@
1
+ import { FC } from 'react';
2
+ import { PaginationProps } from "../../Component";
3
+ type DefaultViewProps = Pick<PaginationProps, 'sidePadding' | 'activePadding' | 'pagesCount' | 'currentPageIndex' | 'onPageChange'>;
4
+ declare const DefaultView: FC<DefaultViewProps>;
5
+ export { DefaultView };
@@ -0,0 +1,56 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ require('classnames');
7
+ var components_tag_index = require('../tag/index.js');
8
+ require('@alfalab/core-components-tag/dist/cssm');
9
+ require('../tag/index.module.css');
10
+ var styles = require('./index.module.css');
11
+
12
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
+
14
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
15
+ var styles__default = /*#__PURE__*/_interopDefaultLegacy(styles);
16
+
17
+ var DefaultView = function (_a) {
18
+ var _b = _a.sidePadding, sidePadding = _b === void 0 ? 2 : _b, _c = _a.activePadding, activePadding = _c === void 0 ? 1 : _c, pagesCount = _a.pagesCount, currentPageIndex = _a.currentPageIndex, _d = _a.onPageChange, onPageChange = _d === void 0 ? function () { return null; } : _d;
19
+ var maxHalfCount = sidePadding + activePadding + 1;
20
+ var maxElementsCount = maxHalfCount * 2 + 1;
21
+ var itemsFit = pagesCount <= maxElementsCount;
22
+ var elementsCount = itemsFit ? pagesCount : maxElementsCount;
23
+ var getPageIndex = React.useCallback(function (elementIndex) {
24
+ var lastIndex = pagesCount - 1;
25
+ var reverseIndex = lastIndex - currentPageIndex;
26
+ var lastElementIndex = elementsCount - 1;
27
+ var reverseElementIndex = lastElementIndex - elementIndex;
28
+ var hasCollapsedItems = function (index) { return !itemsFit && index >= maxHalfCount; };
29
+ if (elementIndex < sidePadding) {
30
+ return elementIndex;
31
+ }
32
+ if (elementIndex === sidePadding && hasCollapsedItems(currentPageIndex)) {
33
+ return null;
34
+ }
35
+ if (reverseElementIndex === sidePadding && hasCollapsedItems(reverseIndex)) {
36
+ return null;
37
+ }
38
+ if (reverseElementIndex < sidePadding) {
39
+ return lastIndex - reverseElementIndex;
40
+ }
41
+ var computedIndex = currentPageIndex - maxHalfCount + elementIndex;
42
+ return Math.min(lastIndex - reverseElementIndex, Math.max(elementIndex, computedIndex));
43
+ }, [currentPageIndex, elementsCount, itemsFit, maxHalfCount, pagesCount, sidePadding]);
44
+ return (React__default['default'].createElement(React__default['default'].Fragment, null, Array(elementsCount)
45
+ .fill('')
46
+ .map(function (_, i) {
47
+ var pageIndex = getPageIndex(i);
48
+ if (pageIndex === null) {
49
+ return (React__default['default'].createElement("div", { key: i.toString(), className: styles__default['default'].dots }, "..."));
50
+ }
51
+ var active = currentPageIndex === pageIndex;
52
+ return (React__default['default'].createElement(components_tag_index.Tag, { key: i.toString(), checked: active, disabled: active, onClick: function () { return onPageChange(pageIndex); } }, pageIndex + 1));
53
+ })));
54
+ };
55
+
56
+ exports.DefaultView = DefaultView;
@@ -0,0 +1,21 @@
1
+ :root {
2
+ --color-light-text-secondary: #546272;
3
+ }
4
+ :root {
5
+
6
+ /* Hard */
7
+
8
+ /* Up */
9
+
10
+ /* Hard up */
11
+ }
12
+ .dots {
13
+ width: 32px;
14
+ height: 32px;
15
+ text-align: center;
16
+ display: flex;
17
+ align-items: center;
18
+ justify-content: center;
19
+ color: var(--color-light-text-secondary);
20
+ cursor: default;
21
+ }
@@ -0,0 +1,5 @@
1
+ import { FC } from 'react';
2
+ import { PaginationProps } from "../../Component";
3
+ type PerPageViewProps = Pick<PaginationProps, 'pagesCount' | 'currentPageIndex'>;
4
+ declare const PerPageView: FC<PerPageViewProps>;
5
+ export { PerPageView };
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ var styles = require('./index.module.css');
7
+
8
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
+
10
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
11
+ var styles__default = /*#__PURE__*/_interopDefaultLegacy(styles);
12
+
13
+ var PerPageView = function (_a) {
14
+ var pagesCount = _a.pagesCount, currentPageIndex = _a.currentPageIndex;
15
+ return (React__default['default'].createElement("span", { className: styles__default['default'].component },
16
+ currentPageIndex + 1,
17
+ " \u0438\u0437 ",
18
+ pagesCount,
19
+ " \u0441\u0442\u0440\u0430\u043D\u0438\u0446"));
20
+ };
21
+
22
+ exports.PerPageView = PerPageView;
@@ -0,0 +1,15 @@
1
+ :root {
2
+
3
+ /* Hard */
4
+
5
+ /* Up */
6
+
7
+ /* Hard up */
8
+ }
9
+ :root {
10
+ --gap-m: 16px;
11
+ }
12
+ .component {
13
+ display: block;
14
+ margin: 0 var(--gap-m);
15
+ }
@@ -0,0 +1,4 @@
1
+ import { FC } from 'react';
2
+ import { TagProps } from "@alfalab/core-components-tag";
3
+ declare const Tag: FC<TagProps>;
4
+ export { Tag };
@@ -0,0 +1,61 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ var cn = require('classnames');
7
+ var coreComponentsTag = require('@alfalab/core-components-tag/dist/cssm');
8
+ var styles = require('./index.module.css');
9
+
10
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
11
+
12
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
13
+ var cn__default = /*#__PURE__*/_interopDefaultLegacy(cn);
14
+ var styles__default = /*#__PURE__*/_interopDefaultLegacy(styles);
15
+
16
+ /*! *****************************************************************************
17
+ Copyright (c) Microsoft Corporation.
18
+
19
+ Permission to use, copy, modify, and/or distribute this software for any
20
+ purpose with or without fee is hereby granted.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
23
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
24
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
25
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
26
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
27
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
28
+ PERFORMANCE OF THIS SOFTWARE.
29
+ ***************************************************************************** */
30
+ var __assign = function () {
31
+ __assign = Object.assign || function __assign(t) {
32
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
33
+ s = arguments[i];
34
+ for (var p in s)
35
+ if (Object.prototype.hasOwnProperty.call(s, p))
36
+ t[p] = s[p];
37
+ }
38
+ return t;
39
+ };
40
+ return __assign.apply(this, arguments);
41
+ };
42
+ function __rest(s, e) {
43
+ var t = {};
44
+ for (var p in s)
45
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
46
+ t[p] = s[p];
47
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
48
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
49
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
50
+ t[p[i]] = s[p[i]];
51
+ }
52
+ return t;
53
+ }
54
+
55
+ var Tag = function (_a) {
56
+ var _b;
57
+ var className = _a.className, checked = _a.checked, restProps = __rest(_a, ["className", "checked"]);
58
+ return (React__default['default'].createElement(coreComponentsTag.Tag, __assign({}, restProps, { checked: checked, size: 'xxs', className: cn__default['default'](className, styles__default['default'].tag, (_b = {}, _b[styles__default['default'].checked] = checked, _b)) })));
59
+ };
60
+
61
+ exports.Tag = Tag;