@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
@@ -0,0 +1,51 @@
1
+ :root {
2
+ --color-light-bg-neutral: #dbdee1;
3
+ --color-light-bg-secondary-inverted: #233549;
4
+ --color-light-bg-tertiary: #e7e9eb;
5
+ --color-light-text-primary: #0b1f35;
6
+ --color-light-text-primary-inverted: #fff;
7
+ --color-light-text-secondary: #546272;
8
+ }
9
+ :root {
10
+
11
+ /* Hard */
12
+
13
+ /* Up */
14
+
15
+ /* Hard up */
16
+ }
17
+ :root {
18
+ --border-radius-m: 8px;
19
+ }
20
+ .tag.tag {
21
+ color: var(--color-light-text-secondary);
22
+ border-radius: var(--border-radius-m);
23
+ border: none;
24
+ flex-shrink: 0;
25
+ min-width: auto;
26
+ min-height: auto;
27
+ width: 32px;
28
+ height: 32px;
29
+ padding: 0
30
+ }
31
+ .tag.tag:disabled:not(.checked) {
32
+ opacity: 0.3;
33
+ }
34
+ .tag.tag:hover:not(:disabled) {
35
+ background-color: var(--color-light-bg-tertiary);
36
+ color: var(--color-light-text-primary);
37
+ }
38
+ .tag.tag:active:not(:disabled) {
39
+ background-color: var(--color-light-bg-neutral);
40
+ }
41
+ .tag.tag.checked {
42
+ cursor: default;
43
+ background-color: var(--color-light-bg-secondary-inverted);
44
+ color: var(--color-light-text-primary-inverted);
45
+ }
46
+ .tag.tag.checked:hover:not(:disabled) {
47
+ color: var(--color-light-text-primary-inverted);
48
+ }
49
+ .tag.tag.checked:active:not(:disabled) {
50
+ color: var(--color-light-text-primary);
51
+ }
@@ -0,0 +1 @@
1
+ export * from "./Component";
@@ -0,0 +1,21 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ require('react');
6
+ require('classnames');
7
+ require('@alfalab/icons-glyph/ChevronBackMIcon');
8
+ require('@alfalab/icons-glyph/ChevronForwardMIcon');
9
+ 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
+ require('./components/default-view/index.js');
14
+ require('./components/per-page-view/index.module.css');
15
+ require('./components/per-page-view/index.js');
16
+ require('./index.module.css');
17
+ var Component = require('./Component.js');
18
+
19
+
20
+
21
+ exports.Pagination = Component.Pagination;
@@ -0,0 +1,31 @@
1
+ :root {
2
+ --color-light-text-primary: #0b1f35;
3
+ }
4
+ :root {
5
+
6
+ /* Hard */
7
+
8
+ /* Up */
9
+
10
+ /* Hard up */
11
+ }
12
+ :root {
13
+ --gap-xs: 8px;
14
+ }
15
+ .component {
16
+ font-size: 14px;
17
+ line-height: 20px;
18
+ font-weight: 400;
19
+
20
+ display: flex;
21
+ align-items: center;
22
+ color: var(--color-light-text-primary);
23
+ font-feature-settings: "tnum";
24
+ font-variant-numeric: tabular-nums;
25
+ }
26
+ .default > * {
27
+ margin-right: var(--gap-xs)
28
+ }
29
+ .default > *:last-child {
30
+ margin-right: 0;
31
+ }
@@ -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,33 @@
1
+ import React from 'react';
2
+ import cn from 'classnames';
3
+ import { ChevronBackMIcon } from '@alfalab/icons-glyph/ChevronBackMIcon';
4
+ import { ChevronForwardMIcon } from '@alfalab/icons-glyph/ChevronForwardMIcon';
5
+ import { Tag } from './components/tag/index.js';
6
+ import '@alfalab/core-components-tag/dist/esm';
7
+ import { DefaultView } from './components/default-view/index.js';
8
+ import { PerPageView } from './components/per-page-view/index.js';
9
+
10
+ var styles = {"component":"pagination__component_1bqlk","default":"pagination__default_1bqlk"};
11
+ require('./index.css')
12
+
13
+ var Pagination = function (_a) {
14
+ 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;
15
+ var handlePageClick = function (pageIndex) {
16
+ onPageChange(pageIndex);
17
+ };
18
+ var handleNextPageClick = function () {
19
+ handlePageClick(Math.min(pagesCount - 1, currentPageIndex + 1));
20
+ };
21
+ var handlePrevPageClick = function () {
22
+ handlePageClick(Math.max(0, currentPageIndex - 1));
23
+ };
24
+ var shouldRenderPrevArrow = view === 'per-page' || !hideArrows || currentPageIndex > 0;
25
+ var shouldRenderNextArrow = view === 'per-page' || !hideArrows || currentPageIndex < pagesCount - 1;
26
+ return (React.createElement("div", { className: cn(styles.component, className, styles[view]), "data-test-id": dataTestId },
27
+ shouldRenderPrevArrow && (React.createElement(Tag, { className: styles.arrow, disabled: currentPageIndex <= 0, onClick: handlePrevPageClick, rightAddons: React.createElement(ChevronBackMIcon, { width: 16, height: 16 }) })),
28
+ view === 'default' && (React.createElement(DefaultView, { activePadding: activePadding, sidePadding: sidePadding, currentPageIndex: currentPageIndex, pagesCount: pagesCount, onPageChange: handlePageClick })),
29
+ view === 'per-page' && (React.createElement(PerPageView, { currentPageIndex: currentPageIndex, pagesCount: pagesCount })),
30
+ shouldRenderNextArrow && (React.createElement(Tag, { className: styles.arrow, disabled: currentPageIndex >= pagesCount - 1, onClick: handleNextPageClick, rightAddons: React.createElement(ChevronForwardMIcon, { width: 16, height: 16 }) }))));
31
+ };
32
+
33
+ export { 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,48 @@
1
+ import React, { useCallback } from 'react';
2
+ import 'classnames';
3
+ import { Tag } from '../tag/index.js';
4
+ import '@alfalab/core-components-tag/dist/esm';
5
+
6
+ var styles = {"dots":"pagination__dots_kix4e"};
7
+ require('./index.css')
8
+
9
+ var DefaultView = function (_a) {
10
+ 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;
11
+ var maxHalfCount = sidePadding + activePadding + 1;
12
+ var maxElementsCount = maxHalfCount * 2 + 1;
13
+ var itemsFit = pagesCount <= maxElementsCount;
14
+ var elementsCount = itemsFit ? pagesCount : maxElementsCount;
15
+ var getPageIndex = useCallback(function (elementIndex) {
16
+ var lastIndex = pagesCount - 1;
17
+ var reverseIndex = lastIndex - currentPageIndex;
18
+ var lastElementIndex = elementsCount - 1;
19
+ var reverseElementIndex = lastElementIndex - elementIndex;
20
+ var hasCollapsedItems = function (index) { return !itemsFit && index >= maxHalfCount; };
21
+ if (elementIndex < sidePadding) {
22
+ return elementIndex;
23
+ }
24
+ if (elementIndex === sidePadding && hasCollapsedItems(currentPageIndex)) {
25
+ return null;
26
+ }
27
+ if (reverseElementIndex === sidePadding && hasCollapsedItems(reverseIndex)) {
28
+ return null;
29
+ }
30
+ if (reverseElementIndex < sidePadding) {
31
+ return lastIndex - reverseElementIndex;
32
+ }
33
+ var computedIndex = currentPageIndex - maxHalfCount + elementIndex;
34
+ return Math.min(lastIndex - reverseElementIndex, Math.max(elementIndex, computedIndex));
35
+ }, [currentPageIndex, elementsCount, itemsFit, maxHalfCount, pagesCount, sidePadding]);
36
+ return (React.createElement(React.Fragment, null, Array(elementsCount)
37
+ .fill('')
38
+ .map(function (_, i) {
39
+ var pageIndex = getPageIndex(i);
40
+ if (pageIndex === null) {
41
+ return (React.createElement("div", { key: i.toString(), className: styles.dots }, "..."));
42
+ }
43
+ var active = currentPageIndex === pageIndex;
44
+ return (React.createElement(Tag, { key: i.toString(), checked: active, disabled: active, onClick: function () { return onPageChange(pageIndex); } }, pageIndex + 1));
45
+ })));
46
+ };
47
+
48
+ export { 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,15 @@
1
+ import React from 'react';
2
+
3
+ var styles = {"component":"pagination__component_begf8"};
4
+ require('./index.css')
5
+
6
+ var PerPageView = function (_a) {
7
+ var pagesCount = _a.pagesCount, currentPageIndex = _a.currentPageIndex;
8
+ return (React.createElement("span", { className: styles.component },
9
+ currentPageIndex + 1,
10
+ " \u0438\u0437 ",
11
+ pagesCount,
12
+ " \u0441\u0442\u0440\u0430\u043D\u0438\u0446"));
13
+ };
14
+
15
+ export { 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,53 @@
1
+ import React from 'react';
2
+ import cn from 'classnames';
3
+ import { Tag as Tag$1 } from '@alfalab/core-components-tag/dist/esm';
4
+
5
+ /*! *****************************************************************************
6
+ Copyright (c) Microsoft Corporation.
7
+
8
+ Permission to use, copy, modify, and/or distribute this software for any
9
+ purpose with or without fee is hereby granted.
10
+
11
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
12
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
14
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
16
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17
+ PERFORMANCE OF THIS SOFTWARE.
18
+ ***************************************************************************** */
19
+ var __assign = function () {
20
+ __assign = Object.assign || function __assign(t) {
21
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
22
+ s = arguments[i];
23
+ for (var p in s)
24
+ if (Object.prototype.hasOwnProperty.call(s, p))
25
+ t[p] = s[p];
26
+ }
27
+ return t;
28
+ };
29
+ return __assign.apply(this, arguments);
30
+ };
31
+ function __rest(s, e) {
32
+ var t = {};
33
+ for (var p in s)
34
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
35
+ t[p] = s[p];
36
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
37
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
38
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
39
+ t[p[i]] = s[p[i]];
40
+ }
41
+ return t;
42
+ }
43
+
44
+ var styles = {"tag":"pagination__tag_1gidc","checked":"pagination__checked_1gidc"};
45
+ require('./index.css')
46
+
47
+ var Tag = function (_a) {
48
+ var _b;
49
+ var className = _a.className, checked = _a.checked, restProps = __rest(_a, ["className", "checked"]);
50
+ return (React.createElement(Tag$1, __assign({}, restProps, { checked: checked, size: 'xxs', className: cn(className, styles.tag, (_b = {}, _b[styles.checked] = checked, _b)) })));
51
+ };
52
+
53
+ export { Tag };
@@ -0,0 +1,32 @@
1
+ /* hash: 1ncx7 */
2
+ :root {
3
+ --color-light-text-primary: #0b1f35;
4
+ }
5
+ :root {
6
+
7
+ /* Hard */
8
+
9
+ /* Up */
10
+
11
+ /* Hard up */
12
+ }
13
+ :root {
14
+ --gap-xs: 8px;
15
+ }
16
+ .pagination__component_1bqlk {
17
+ font-size: 14px;
18
+ line-height: 20px;
19
+ font-weight: 400;
20
+
21
+ display: flex;
22
+ align-items: center;
23
+ color: var(--color-light-text-primary);
24
+ font-feature-settings: "tnum";
25
+ font-variant-numeric: tabular-nums;
26
+ }
27
+ .pagination__default_1bqlk > * {
28
+ margin-right: var(--gap-xs)
29
+ }
30
+ .pagination__default_1bqlk > *:last-child {
31
+ margin-right: 0;
32
+ }
@@ -0,0 +1 @@
1
+ export * from "./Component";
@@ -0,0 +1,9 @@
1
+ import 'react';
2
+ import 'classnames';
3
+ import '@alfalab/icons-glyph/ChevronBackMIcon';
4
+ import '@alfalab/icons-glyph/ChevronForwardMIcon';
5
+ import './components/tag/index.js';
6
+ import '@alfalab/core-components-tag/dist/esm';
7
+ import './components/default-view/index.js';
8
+ import './components/per-page-view/index.js';
9
+ export { Pagination } from './Component.js';
package/dist/index.css ADDED
@@ -0,0 +1,32 @@
1
+ /* hash: 1ncx7 */
2
+ :root {
3
+ --color-light-text-primary: #0b1f35;
4
+ }
5
+ :root {
6
+
7
+ /* Hard */
8
+
9
+ /* Up */
10
+
11
+ /* Hard up */
12
+ }
13
+ :root {
14
+ --gap-xs: 8px;
15
+ }
16
+ .pagination__component_1bqlk {
17
+ font-size: 14px;
18
+ line-height: 20px;
19
+ font-weight: 400;
20
+
21
+ display: flex;
22
+ align-items: center;
23
+ color: var(--color-light-text-primary);
24
+ font-feature-settings: "tnum";
25
+ font-variant-numeric: tabular-nums;
26
+ }
27
+ .pagination__default_1bqlk > * {
28
+ margin-right: var(--gap-xs)
29
+ }
30
+ .pagination__default_1bqlk > *:last-child {
31
+ margin-right: 0;
32
+ }
@@ -0,0 +1 @@
1
+ export * from "./Component";
package/dist/index.js ADDED
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ require('react');
6
+ require('classnames');
7
+ require('@alfalab/icons-glyph/ChevronBackMIcon');
8
+ require('@alfalab/icons-glyph/ChevronForwardMIcon');
9
+ require('./components/tag/index.js');
10
+ require('@alfalab/core-components-tag');
11
+ require('./components/default-view/index.js');
12
+ require('./components/per-page-view/index.js');
13
+ var Component = require('./Component.js');
14
+
15
+
16
+
17
+ exports.Pagination = Component.Pagination;
@@ -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,32 @@
1
+ import React from 'react';
2
+ import cn from 'classnames';
3
+ import { ChevronBackMIcon } from '@alfalab/icons-glyph/ChevronBackMIcon';
4
+ import { ChevronForwardMIcon } from '@alfalab/icons-glyph/ChevronForwardMIcon';
5
+ import '@alfalab/core-components-tag/dist/modern';
6
+ import { Tag } from './components/tag/index.js';
7
+ import { DefaultView } from './components/default-view/index.js';
8
+ import { PerPageView } from './components/per-page-view/index.js';
9
+
10
+ var styles = {"component":"pagination__component_1bqlk","default":"pagination__default_1bqlk"};
11
+ require('./index.css')
12
+
13
+ const Pagination = ({ currentPageIndex = 0, pagesCount, className, sidePadding = 1, activePadding = 2, hideArrows = true, view = 'default', onPageChange = () => null, dataTestId, }) => {
14
+ const handlePageClick = (pageIndex) => {
15
+ onPageChange(pageIndex);
16
+ };
17
+ const handleNextPageClick = () => {
18
+ handlePageClick(Math.min(pagesCount - 1, currentPageIndex + 1));
19
+ };
20
+ const handlePrevPageClick = () => {
21
+ handlePageClick(Math.max(0, currentPageIndex - 1));
22
+ };
23
+ const shouldRenderPrevArrow = view === 'per-page' || !hideArrows || currentPageIndex > 0;
24
+ const shouldRenderNextArrow = view === 'per-page' || !hideArrows || currentPageIndex < pagesCount - 1;
25
+ return (React.createElement("div", { className: cn(styles.component, className, styles[view]), "data-test-id": dataTestId },
26
+ shouldRenderPrevArrow && (React.createElement(Tag, { className: styles.arrow, disabled: currentPageIndex <= 0, onClick: handlePrevPageClick, rightAddons: React.createElement(ChevronBackMIcon, { width: 16, height: 16 }) })),
27
+ view === 'default' && (React.createElement(DefaultView, { activePadding: activePadding, sidePadding: sidePadding, currentPageIndex: currentPageIndex, pagesCount: pagesCount, onPageChange: handlePageClick })),
28
+ view === 'per-page' && (React.createElement(PerPageView, { currentPageIndex: currentPageIndex, pagesCount: pagesCount })),
29
+ shouldRenderNextArrow && (React.createElement(Tag, { className: styles.arrow, disabled: currentPageIndex >= pagesCount - 1, onClick: handleNextPageClick, rightAddons: React.createElement(ChevronForwardMIcon, { width: 16, height: 16 }) }))));
30
+ };
31
+
32
+ export { 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 };