@sima-land/ui-nucleons 45.0.0-alpha.4 → 45.0.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_internal/custom-scrollbar/index.js +5 -27
- package/_internal/dropdown-loading/index.js +2 -3
- package/_internal/page-scroll-lock/context.js +3 -25
- package/alert/index.d.ts +2 -2
- package/alert/index.js +4 -30
- package/arrow-button/index.js +18 -19
- package/autocomplete/autocomplete.js +49 -76
- package/autocomplete-deprecated/index.d.ts +1 -1
- package/autocomplete-deprecated/index.js +43 -67
- package/avatar/avatar.module.scss +3 -1
- package/avatar/index.d.ts +1 -1
- package/avatar/index.js +7 -33
- package/avatar/user.d.ts +1 -1
- package/avatar/user.js +8 -29
- package/base-input/base-input.js +5 -31
- package/base-input-deprecated/index.d.ts +2 -2
- package/base-input-deprecated/index.js +8 -34
- package/bordered-layout/index.d.ts +1 -1
- package/bordered-layout/index.js +2 -3
- package/bottom-bar/bottom-bar.js +2 -3
- package/box/index.d.ts +1 -1
- package/box/index.js +2 -2
- package/button/index.d.ts +2 -2
- package/button/index.js +6 -32
- package/card/index.js +2 -8
- package/card/slots.d.ts +1 -1
- package/card/slots.js +9 -31
- package/carousel/draggable.d.ts +1 -1
- package/carousel/draggable.js +5 -28
- package/carousel/index.d.ts +1 -1
- package/carousel/index.js +17 -43
- package/checkbox/index.d.ts +2 -2
- package/checkbox/index.js +3 -29
- package/checkbox-field/index.d.ts +2 -2
- package/checkbox-field/index.js +3 -31
- package/chips/index.d.ts +1 -1
- package/chips/index.js +3 -25
- package/chips/item.d.ts +1 -1
- package/chips/item.js +3 -5
- package/clean-buttons/index.js +6 -28
- package/dot-nav/index.d.ts +1 -1
- package/dot-nav/index.js +12 -34
- package/dropdown/index.d.ts +2 -2
- package/dropdown/index.js +3 -26
- package/dropdown-item/index.d.ts +1 -1
- package/dropdown-item/index.js +4 -9
- package/expandable/index.d.ts +2 -2
- package/expandable/index.js +8 -36
- package/field-block/index.js +2 -9
- package/field-grid/index.d.ts +1 -1
- package/field-grid/index.js +43 -65
- package/file-icon/index.d.ts +1 -1
- package/file-icon/index.js +5 -10
- package/group-overflow/index.js +6 -30
- package/helpers/define-slots.d.ts +1 -1
- package/helpers/events.d.ts +1 -1
- package/helpers/on.d.ts +1 -1
- package/hint/hint-view.js +3 -3
- package/hint/hint.js +3 -8
- package/hint-deprecated/index.d.ts +2 -2
- package/hint-deprecated/index.js +3 -26
- package/hooks/breakpoint/index.js +3 -25
- package/info-text/index.js +15 -42
- package/input/index.js +8 -30
- package/layout/layout.js +2 -2
- package/layout/legacy.d.ts +5 -5
- package/layout/legacy.js +3 -25
- package/link/index.d.ts +6 -3
- package/link/index.js +3 -25
- package/loading-overlay/index.d.ts +1 -1
- package/loading-overlay/index.js +2 -3
- package/masked-field/index.d.ts +2 -2
- package/masked-field/index.js +3 -25
- package/masked-input/masked-input.js +3 -25
- package/modal/index.d.ts +1 -1
- package/modal/index.js +3 -10
- package/modal/slots.js +6 -29
- package/modal-overlay/index.js +3 -26
- package/no-index/index.d.ts +3 -3
- package/no-index/index.js +4 -8
- package/no-index-mark/index.d.ts +2 -2
- package/no-index-mark/index.js +7 -6
- package/package.json +6 -11
- package/pagination/index.d.ts +4 -20
- package/pagination/index.js +8 -15
- package/pagination/pagination-item.d.ts +8 -0
- package/pagination/pagination-item.js +31 -0
- package/pagination/pagination-item.module.scss +49 -0
- package/pagination/pagination.d.ts +8 -0
- package/pagination/pagination.js +78 -0
- package/pagination/pagination.module.scss +14 -70
- package/pagination/types.d.ts +28 -0
- package/pagination/types.js +2 -0
- package/pagination/utils.d.ts +15 -43
- package/pagination/utils.js +38 -87
- package/{pagination → pagination-deprecated}/base-pagination.d.ts +6 -1
- package/{pagination → pagination-deprecated}/base-pagination.js +33 -33
- package/pagination-deprecated/index.d.ts +22 -0
- package/pagination-deprecated/index.js +15 -0
- package/{pagination → pagination-deprecated}/page-button.d.ts +2 -1
- package/{pagination → pagination-deprecated}/page-button.js +3 -5
- package/pagination-deprecated/pagination.module.scss +76 -0
- package/pagination-deprecated/utils.d.ts +58 -0
- package/pagination-deprecated/utils.js +124 -0
- package/panel/index.js +3 -6
- package/phone-input/images/armenia.png +0 -0
- package/phone-input/images/azerbaijan.png +0 -0
- package/phone-input/images/belarus.png +0 -0
- package/phone-input/images/georgia.png +0 -0
- package/phone-input/images/kazakhstan.png +0 -0
- package/phone-input/images/kyrgyzstan.png +0 -0
- package/phone-input/images/moldova.png +0 -0
- package/phone-input/images/other.png +0 -0
- package/phone-input/images/russia.png +0 -0
- package/phone-input/images/tajikistan.png +0 -0
- package/phone-input/images/turkmenistan.png +0 -0
- package/phone-input/images/ukraine.png +0 -0
- package/phone-input/images/uzbekistan.png +0 -0
- package/phone-input/phone-input.js +13 -37
- package/phone-input/presets.js +2 -0
- package/phone-input-deprecated/index.d.ts +1 -1
- package/phone-input-deprecated/index.js +31 -57
- package/plate/index.d.ts +2 -2
- package/plate/index.js +3 -25
- package/popup/popup-view.js +3 -6
- package/popup/popup.js +4 -26
- package/portal/index.d.ts +1 -1
- package/price/index.js +2 -2
- package/radio-button/index.js +2 -4
- package/range/index.d.ts +1 -1
- package/range/index.js +6 -33
- package/rating/index.d.ts +1 -1
- package/rating/index.js +4 -9
- package/readme.md +4 -67
- package/screen/index.d.ts +5 -5
- package/screen/index.js +11 -37
- package/screen/slots.d.ts +3 -3
- package/screen/slots.js +9 -31
- package/select/parts/block.js +6 -28
- package/select/parts/button.js +7 -29
- package/select/parts/menu.js +12 -33
- package/select/select.js +4 -28
- package/select-deprecated/index.d.ts +1 -1
- package/select-deprecated/index.js +32 -56
- package/side-page/index.js +4 -30
- package/side-page/slots.js +4 -4
- package/spinner/index.d.ts +1 -1
- package/spinner/index.js +3 -5
- package/spinner/spinner.module.scss +3 -1
- package/stepper/index.d.ts +2 -2
- package/stepper/index.js +11 -38
- package/stroked-svg/index.d.ts +2 -2
- package/stroked-svg/index.js +3 -27
- package/styling/sizes.module.scss +3 -1
- package/super-ellipse-clip-path/index.js +2 -8
- package/switcher-row/index.js +5 -10
- package/tabs/index.d.ts +1 -1
- package/tabs/index.js +4 -26
- package/text/index.d.ts +2 -2
- package/text/index.js +3 -25
- package/text-button/index.d.ts +2 -2
- package/text-button/index.js +4 -7
- package/text-field/index.d.ts +2 -2
- package/text-field/index.js +25 -55
- package/textarea/index.js +4 -26
- package/timer/index.d.ts +1 -1
- package/timer/index.js +3 -25
- package/toggle/index.d.ts +2 -2
- package/toggle/index.js +3 -27
- package/tooltip/index.d.ts +2 -2
- package/tooltip/index.js +4 -28
- package/top-bar/top-bar.js +5 -45
- package/top-bar/utils.d.ts +2 -2
- package/top-bar/utils.js +6 -28
- package/touch-slider/index.d.ts +1 -1
- package/touch-slider/index.js +2 -4
- package/unknown-content/index.d.ts +1 -1
- package/unknown-content/index.js +3 -25
- package/upload-area/upload-area.js +8 -38
- package/with-hint/index.d.ts +1 -1
- package/with-hint/index.js +3 -28
- package/with-hint/positioning-hint.d.ts +1 -1
- package/with-hint/positioning-hint.js +3 -25
- package/with-tooltip/index.d.ts +1 -1
- package/with-tooltip/index.js +6 -31
- package/with-tooltip/positioning-tooltip.d.ts +1 -1
- package/with-tooltip/positioning-tooltip.js +4 -26
- package/file-icon/unknown.svg +0 -9
- package/rating/star.svg +0 -3
- package/upload-area/upload.svg +0 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sima-land/ui-nucleons",
|
|
3
|
-
"version": "45.0.0-alpha.
|
|
3
|
+
"version": "45.0.0-alpha.5",
|
|
4
4
|
"repository": "ssh://git@github.com:sima-land/ui-nucleons.git",
|
|
5
5
|
"author": "www.sima-land.ru team",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@floating-ui/react": "^0.17.0",
|
|
30
30
|
"@krutoo/input-mask": "^0.0.9",
|
|
31
|
-
"@sima-land/ui-quarks": "^3.6.0",
|
|
32
31
|
"body-scroll-lock": "3.1.5",
|
|
33
32
|
"classnames": "^2.3.1",
|
|
34
33
|
"date-fns": "^2.28.0",
|
|
@@ -46,7 +45,7 @@
|
|
|
46
45
|
"@babel/preset-typescript": "^7.16.7",
|
|
47
46
|
"@playwright/test": "^1.27.1",
|
|
48
47
|
"@rushstack/eslint-patch": "^1.1.1",
|
|
49
|
-
"@sima-land/linters": "^
|
|
48
|
+
"@sima-land/linters": "^3.0.0",
|
|
50
49
|
"@storybook/addon-actions": "^6.5.14",
|
|
51
50
|
"@storybook/addon-backgrounds": "^6.5.14",
|
|
52
51
|
"@storybook/addon-docs": "^6.5.14",
|
|
@@ -56,10 +55,6 @@
|
|
|
56
55
|
"@storybook/manager-webpack5": "^6.5.14",
|
|
57
56
|
"@storybook/react": "^6.5.14",
|
|
58
57
|
"@storybook/theming": "^6.5.14",
|
|
59
|
-
"@svgr/core": "^6.2.1",
|
|
60
|
-
"@svgr/plugin-jsx": "^6.2.1",
|
|
61
|
-
"@svgr/plugin-svgo": "^6.2.0",
|
|
62
|
-
"@svgr/webpack": "^6.2.1",
|
|
63
58
|
"@testing-library/react": "^12.1.4",
|
|
64
59
|
"@testing-library/user-event": "^14.4.3",
|
|
65
60
|
"@types/body-scroll-lock": "^3.1.0",
|
|
@@ -87,22 +82,22 @@
|
|
|
87
82
|
"jest-environment-jsdom": "^29.3.1",
|
|
88
83
|
"lint-staged": "^12.3.5",
|
|
89
84
|
"lorem-ipsum": "^2.0.8",
|
|
90
|
-
"postcss": "^8.4.
|
|
85
|
+
"postcss": "^8.4.24",
|
|
91
86
|
"prettier": "^2.5.1",
|
|
92
87
|
"react": "^17.0.2",
|
|
93
88
|
"react-docgen-typescript": "^2.2.2",
|
|
94
89
|
"react-dom": "^17.0.2",
|
|
95
90
|
"rimraf": "^3.0.2",
|
|
96
|
-
"sass": "^1.
|
|
91
|
+
"sass": "^1.63.6",
|
|
97
92
|
"sass-loader": "^12.6.0",
|
|
98
93
|
"style-loader": "^3.3.1",
|
|
99
|
-
"stylelint": "^
|
|
94
|
+
"stylelint": "^15.9.0",
|
|
100
95
|
"ts-node": "^10.9.1",
|
|
101
96
|
"typescript": "^4.9.4",
|
|
102
|
-
"typescript-plugin-css-modules": "^4.1.1",
|
|
103
97
|
"webpack": "^5.75.0"
|
|
104
98
|
},
|
|
105
99
|
"peerDependencies": {
|
|
100
|
+
"@sima-land/ui-quarks": "^4.2.0",
|
|
106
101
|
"react": ">=17",
|
|
107
102
|
"react-dom": ">=17"
|
|
108
103
|
}
|
package/pagination/index.d.ts
CHANGED
|
@@ -1,20 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
total: number;
|
|
6
|
-
/** Индекс текущей страницы. */
|
|
7
|
-
current: number;
|
|
8
|
-
/** Сработает при выборе страницы. */
|
|
9
|
-
onChange?: (data: {
|
|
10
|
-
value: number;
|
|
11
|
-
}) => void;
|
|
12
|
-
/** Функция возвращающая компонент кнопки. */
|
|
13
|
-
renderButton?: BasePaginationProps['renderButton'];
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Компонент списка кнопок навигации по страницам.
|
|
17
|
-
* @param props Свойства.
|
|
18
|
-
* @return Элемент.
|
|
19
|
-
*/
|
|
20
|
-
export declare const Pagination: React.FC<PaginationProps>;
|
|
1
|
+
export type { PaginationProps, PaginationItemProps, PaginationButton } from './types';
|
|
2
|
+
export { Pagination } from './pagination';
|
|
3
|
+
export { PaginationItem } from './pagination-item';
|
|
4
|
+
export { getPaginationItems, getNumbersAround } from './utils';
|
package/pagination/index.js
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Pagination = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const Pagination = ({ total, current, onChange, renderButton, }) => (react_1.default.createElement(base_pagination_1.BasePagination, { total: total, current: current, renderButton: renderButton, onButtonClick: content => {
|
|
15
|
-
Number.isFinite(content) && onChange && onChange({ value: content });
|
|
16
|
-
} }));
|
|
17
|
-
exports.Pagination = Pagination;
|
|
3
|
+
exports.getNumbersAround = exports.getPaginationItems = exports.PaginationItem = exports.Pagination = void 0;
|
|
4
|
+
var pagination_1 = require("./pagination");
|
|
5
|
+
Object.defineProperty(exports, "Pagination", { enumerable: true, get: function () { return pagination_1.Pagination; } });
|
|
6
|
+
var pagination_item_1 = require("./pagination-item");
|
|
7
|
+
Object.defineProperty(exports, "PaginationItem", { enumerable: true, get: function () { return pagination_item_1.PaginationItem; } });
|
|
8
|
+
var utils_1 = require("./utils");
|
|
9
|
+
Object.defineProperty(exports, "getPaginationItems", { enumerable: true, get: function () { return utils_1.getPaginationItems; } });
|
|
10
|
+
Object.defineProperty(exports, "getNumbersAround", { enumerable: true, get: function () { return utils_1.getNumbersAround; } });
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { PaginationItemProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Кнопка страницы.
|
|
5
|
+
* @param props Свойства.
|
|
6
|
+
* @return Элемент.
|
|
7
|
+
*/
|
|
8
|
+
export declare function PaginationItem({ rootRef, checked, disabled, children, rounds, onClick, className, href, role, ...rest }: PaginationItemProps): JSX.Element;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.PaginationItem = void 0;
|
|
18
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
|
+
const bind_1 = __importDefault(require("classnames/bind"));
|
|
20
|
+
const pagination_item_module_scss_1 = __importDefault(require("./pagination-item.module.scss"));
|
|
21
|
+
const cx = bind_1.default.bind(pagination_item_module_scss_1.default);
|
|
22
|
+
/**
|
|
23
|
+
* Кнопка страницы.
|
|
24
|
+
* @param props Свойства.
|
|
25
|
+
* @return Элемент.
|
|
26
|
+
*/
|
|
27
|
+
function PaginationItem(_a) {
|
|
28
|
+
var { rootRef, checked, disabled, children, rounds, onClick, className, href, role = !href ? 'button' : undefined } = _a, rest = __rest(_a, ["rootRef", "checked", "disabled", "children", "rounds", "onClick", "className", "href", "role"]);
|
|
29
|
+
return ((0, jsx_runtime_1.jsx)("a", Object.assign({}, rest, { ref: rootRef, href: disabled ? undefined : href, role: role, className: cx('root', `rounds-${rounds}`, { checked, disabled }, className), onClick: disabled ? undefined : onClick }, { children: children })));
|
|
30
|
+
}
|
|
31
|
+
exports.PaginationItem = PaginationItem;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
@use '../colors';
|
|
2
|
+
|
|
3
|
+
.root {
|
|
4
|
+
--pagination-item-color: #{colors.$basic-gray87};
|
|
5
|
+
--pagination-item-background: #fff;
|
|
6
|
+
--pagination-item-border-color: #{colors.$basic-gray12};
|
|
7
|
+
--pagination-item-font-size: 14px;
|
|
8
|
+
--pagination-item-line-height: 20px;
|
|
9
|
+
width: 40px;
|
|
10
|
+
height: 40px;
|
|
11
|
+
flex-shrink: 0;
|
|
12
|
+
color: var(--pagination-item-color);
|
|
13
|
+
background: var(--pagination-item-background);
|
|
14
|
+
box-shadow: inset 0 0 0 1px var(--pagination-item-border-color);
|
|
15
|
+
font-size: var(--pagination-item-font-size);
|
|
16
|
+
line-height: var(--pagination-item-line-height);
|
|
17
|
+
font-weight: 600;
|
|
18
|
+
display: flex;
|
|
19
|
+
align-items: center;
|
|
20
|
+
justify-content: center;
|
|
21
|
+
text-align: center;
|
|
22
|
+
overflow: hidden;
|
|
23
|
+
text-decoration: none;
|
|
24
|
+
font-style: normal;
|
|
25
|
+
&.checked {
|
|
26
|
+
cursor: default;
|
|
27
|
+
--pagination-item-color: #fff;
|
|
28
|
+
--pagination-item-background: #{colors.$basic-gray87};
|
|
29
|
+
--pagination-item-border-color: #{colors.$basic-gray87};
|
|
30
|
+
}
|
|
31
|
+
&.disabled {
|
|
32
|
+
--pagination-item-color: #{colors.$basic-gray24};
|
|
33
|
+
--pagination-item-background: #fff;
|
|
34
|
+
--pagination-item-border-color: #{colors.$basic-gray12};
|
|
35
|
+
}
|
|
36
|
+
&:not(.checked):not(.disabled):hover {
|
|
37
|
+
cursor: pointer;
|
|
38
|
+
--pagination-item-background: #{colors.$basic-gray4};
|
|
39
|
+
}
|
|
40
|
+
&.rounds-all {
|
|
41
|
+
border-radius: 4px;
|
|
42
|
+
}
|
|
43
|
+
&.rounds-left {
|
|
44
|
+
border-radius: 4px 0 0 4px;
|
|
45
|
+
}
|
|
46
|
+
&.rounds-right {
|
|
47
|
+
border-radius: 0 4px 4px 0;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { PaginationProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Кнопки навигации по страницам.
|
|
5
|
+
* @param props Свойства.
|
|
6
|
+
* @return Элемент.
|
|
7
|
+
*/
|
|
8
|
+
export declare function Pagination({ rootRef, current, total, onPageChange, getItems, renderItem, className, ...restProps }: PaginationProps): JSX.Element;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.Pagination = void 0;
|
|
18
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
|
+
const react_1 = require("react");
|
|
20
|
+
const utils_1 = require("./utils");
|
|
21
|
+
const pagination_item_1 = require("./pagination-item");
|
|
22
|
+
const Left_1 = __importDefault(require("@sima-land/ui-quarks/icons/16x16/Stroked/Arrows/Left"));
|
|
23
|
+
const Right_1 = __importDefault(require("@sima-land/ui-quarks/icons/16x16/Stroked/Arrows/Right"));
|
|
24
|
+
const bind_1 = __importDefault(require("classnames/bind"));
|
|
25
|
+
const pagination_module_scss_1 = __importDefault(require("./pagination.module.scss"));
|
|
26
|
+
const cx = bind_1.default.bind(pagination_module_scss_1.default);
|
|
27
|
+
/**
|
|
28
|
+
* Кнопки навигации по страницам.
|
|
29
|
+
* @param props Свойства.
|
|
30
|
+
* @return Элемент.
|
|
31
|
+
*/
|
|
32
|
+
function Pagination(_a) {
|
|
33
|
+
var { rootRef, current = 1, total = 1, onPageChange, getItems = utils_1.getPaginationItems, renderItem = renderPaginationItem, className } = _a, restProps = __rest(_a, ["rootRef", "current", "total", "onPageChange", "getItems", "renderItem", "className"]);
|
|
34
|
+
const items = (0, react_1.useMemo)(() => getItems({ current, total }), [current, total]);
|
|
35
|
+
const onChangeRef = (0, react_1.useRef)(onPageChange);
|
|
36
|
+
onChangeRef.current = onPageChange;
|
|
37
|
+
const getItemProps = (0, react_1.useCallback)((item, index, userProps = {}) => {
|
|
38
|
+
// eslint-disable-next-line require-jsdoc
|
|
39
|
+
const onClick = event => {
|
|
40
|
+
var _a, _b;
|
|
41
|
+
if (item.value !== current) {
|
|
42
|
+
(_a = onChangeRef.current) === null || _a === void 0 ? void 0 : _a.call(onChangeRef, event, item);
|
|
43
|
+
}
|
|
44
|
+
(_b = userProps.onClick) === null || _b === void 0 ? void 0 : _b.call(userProps, event);
|
|
45
|
+
};
|
|
46
|
+
if (item.type === 'page') {
|
|
47
|
+
let rounds;
|
|
48
|
+
if (index === 0 || items[index - 1].type === 'prev') {
|
|
49
|
+
rounds = 'left';
|
|
50
|
+
}
|
|
51
|
+
else if (index === items.length - 1 || items[index + 1].type === 'next') {
|
|
52
|
+
rounds = 'right';
|
|
53
|
+
}
|
|
54
|
+
return Object.assign(Object.assign({ rounds, checked: item.value === current, 'aria-label': `Перейти на страницу ${item.value}`, children: item.value }, userProps), { onClick, className: cx('page', userProps.className, item.value > 999 && 'large') });
|
|
55
|
+
}
|
|
56
|
+
if (item.type === 'prev') {
|
|
57
|
+
return Object.assign(Object.assign({ rounds: 'all', disabled: current <= 1, 'aria-label': 'Предыдущая страница', children: (0, jsx_runtime_1.jsx)(Left_1.default, { fill: 'currentColor' }) }, userProps), { onClick, className: cx('prev', userProps.className) });
|
|
58
|
+
}
|
|
59
|
+
if (item.type === 'more') {
|
|
60
|
+
return Object.assign(Object.assign({ 'aria-label': `Перейти на страницу ${item.value}`, children: '…' }, userProps), { onClick, className: cx('page', userProps.className) });
|
|
61
|
+
}
|
|
62
|
+
if (item.type === 'next') {
|
|
63
|
+
return Object.assign(Object.assign({ rounds: 'all', disabled: current >= total, 'aria-label': 'Следующая страница', children: (0, jsx_runtime_1.jsx)(Right_1.default, { fill: 'currentColor' }) }, userProps), { onClick, className: cx('next', userProps.className) });
|
|
64
|
+
}
|
|
65
|
+
return {};
|
|
66
|
+
}, [current, total, items]);
|
|
67
|
+
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ ref: rootRef, className: cx('root', className), role: 'navigation', "aria-label": '\u041D\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044F \u043F\u043E \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u0430\u043C' }, restProps, { children: items.map((item, index) => ((0, jsx_runtime_1.jsx)(react_1.Fragment, { children: renderItem(item, userProps => getItemProps(item, index, userProps)) }, index))) })));
|
|
68
|
+
}
|
|
69
|
+
exports.Pagination = Pagination;
|
|
70
|
+
/**
|
|
71
|
+
* Рендер кнопки по умолчанию.
|
|
72
|
+
* @param button Данные кнопки.
|
|
73
|
+
* @param getProps Вернет свойства для PaginationItem.
|
|
74
|
+
* @return Элемент.
|
|
75
|
+
*/
|
|
76
|
+
function renderPaginationItem(button, getProps) {
|
|
77
|
+
return (0, jsx_runtime_1.jsx)(pagination_item_1.PaginationItem, Object.assign({}, getProps()));
|
|
78
|
+
}
|
|
@@ -1,76 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
.root {
|
|
2
|
+
display: flex;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.prev {
|
|
6
|
+
margin-right: 9px;
|
|
7
|
+
}
|
|
2
8
|
|
|
3
|
-
.
|
|
4
|
-
|
|
5
|
-
.page-input-wrapper {
|
|
6
|
-
margin-left: 8px;
|
|
7
|
-
width: 64px;
|
|
8
|
-
.page-input {
|
|
9
|
-
text-align: center;
|
|
10
|
-
font-size: 16px;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
.submit-button {
|
|
14
|
-
margin-left: 8px;
|
|
15
|
-
}
|
|
16
|
-
.cancel-button {
|
|
17
|
-
margin-left: 32px;
|
|
18
|
-
}
|
|
9
|
+
.next {
|
|
10
|
+
margin-left: 8px;
|
|
19
11
|
}
|
|
20
12
|
|
|
21
|
-
.page
|
|
22
|
-
|
|
23
|
-
width: 38px;
|
|
24
|
-
height: 38px;
|
|
25
|
-
background: #fff;
|
|
26
|
-
border: 1px solid colors.$basic-gray12;
|
|
27
|
-
font-size: 14px;
|
|
28
|
-
outline: 0;
|
|
29
|
-
box-sizing: border-box;
|
|
30
|
-
padding: 0;
|
|
31
|
-
vertical-align: top;
|
|
32
|
-
user-select: none;
|
|
33
|
-
&.rounds-all {
|
|
34
|
-
border-radius: 4px;
|
|
35
|
-
}
|
|
36
|
-
&.rounds-left {
|
|
37
|
-
border-radius: 4px 0 0 4px;
|
|
38
|
-
}
|
|
39
|
-
&.rounds-right {
|
|
40
|
-
border-radius: 0 4px 4px 0;
|
|
41
|
-
&:not(.rounds-all) {
|
|
42
|
-
margin-right: 0;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
&:disabled {
|
|
46
|
-
color: colors.$basic-gray24;
|
|
47
|
-
}
|
|
48
|
-
&:not(.rounds-all) {
|
|
49
|
-
margin-right: -1px;
|
|
50
|
-
}
|
|
51
|
-
&:not(.selected):not(:disabled):hover {
|
|
52
|
-
background: #f5f5f5;
|
|
53
|
-
cursor: pointer;
|
|
54
|
-
}
|
|
55
|
-
&.selected {
|
|
56
|
-
position: relative;
|
|
57
|
-
background: colors.$basic-gray87;
|
|
58
|
-
border-color: colors.$basic-gray87;
|
|
59
|
-
color: #fff;
|
|
60
|
-
cursor: default;
|
|
61
|
-
&::after {
|
|
62
|
-
content: '';
|
|
63
|
-
position: absolute;
|
|
64
|
-
top: 0;
|
|
65
|
-
left: 0;
|
|
66
|
-
width: 100%;
|
|
67
|
-
height: 100%;
|
|
68
|
-
box-shadow: inherit;
|
|
69
|
-
border-radius: inherit;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
13
|
+
.page {
|
|
14
|
+
margin-left: -1px;
|
|
72
15
|
}
|
|
73
16
|
|
|
74
|
-
.
|
|
75
|
-
|
|
17
|
+
.large {
|
|
18
|
+
--pagination-item-font-size: 12px;
|
|
19
|
+
--pagination-item-line-height: 16px;
|
|
76
20
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { AnchorHTMLAttributes, HTMLAttributes, MouseEvent, ReactNode, Ref } from 'react';
|
|
2
|
+
export interface PaginationButton {
|
|
3
|
+
type: 'page' | 'prev' | 'next' | 'more';
|
|
4
|
+
value: number;
|
|
5
|
+
}
|
|
6
|
+
export interface PaginationItemProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
7
|
+
rounds?: 'all' | 'right' | 'left';
|
|
8
|
+
checked?: boolean;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
rootRef?: Ref<HTMLAnchorElement>;
|
|
11
|
+
}
|
|
12
|
+
export interface GetPaginationItemProps {
|
|
13
|
+
(userProps?: PaginationItemProps): PaginationItemProps;
|
|
14
|
+
}
|
|
15
|
+
export interface RenderPaginationItem {
|
|
16
|
+
(item: PaginationButton, getProps: GetPaginationItemProps): ReactNode;
|
|
17
|
+
}
|
|
18
|
+
export interface PaginationProps extends HTMLAttributes<HTMLDivElement> {
|
|
19
|
+
rootRef?: Ref<HTMLDivElement>;
|
|
20
|
+
current?: number;
|
|
21
|
+
total?: number;
|
|
22
|
+
onPageChange?: (event: MouseEvent<HTMLAnchorElement>, button: PaginationButton) => void;
|
|
23
|
+
getItems?: (payload: {
|
|
24
|
+
current: number;
|
|
25
|
+
total: number;
|
|
26
|
+
}) => PaginationButton[];
|
|
27
|
+
renderItem?: RenderPaginationItem;
|
|
28
|
+
}
|
package/pagination/utils.d.ts
CHANGED
|
@@ -1,54 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
value: number;
|
|
3
|
-
content: string | number;
|
|
4
|
-
}
|
|
5
|
-
type State = {
|
|
6
|
-
current: number;
|
|
7
|
-
range: number;
|
|
8
|
-
total: number;
|
|
9
|
-
};
|
|
10
|
-
export declare const cx: (...args: import("classnames").ArgumentArray) => string;
|
|
11
|
-
/**
|
|
12
|
-
* Фабрика объектов с данными о кнопке страницы.
|
|
13
|
-
* @param value Номер целевой страницы.
|
|
14
|
-
* @param content Содержимое кнопки.
|
|
15
|
-
* @return Список кнопок.
|
|
16
|
-
*/
|
|
17
|
-
export declare const PageButton: (value: number, content?: string | number) => IPageButton;
|
|
1
|
+
import type { PaginationButton } from './types';
|
|
18
2
|
/**
|
|
19
|
-
*
|
|
3
|
+
* Формирует список кнопок навигации по страницам по дизайн-гайдам.
|
|
20
4
|
* @param props Свойства.
|
|
21
|
-
* @param
|
|
22
|
-
* @
|
|
23
|
-
* @param props.buttonKeys Значения, которые будут использованы для не числовых кнопок.
|
|
24
|
-
* @param props.buttonKeys.more Значение для отображения кнопки группы пропущенных чисел.
|
|
25
|
-
* @return Список кнопок.
|
|
5
|
+
* @param config Конфиг.
|
|
6
|
+
* @return Список.
|
|
26
7
|
*/
|
|
27
|
-
export declare
|
|
28
|
-
current: number;
|
|
8
|
+
export declare function getPaginationItems({ total, current, }: {
|
|
29
9
|
total: number;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
})
|
|
34
|
-
/**
|
|
35
|
-
* Возвращает корректный диапазон вокруг текущего значения в соответствии с дизайнерской задумкой.
|
|
36
|
-
* По возможности показывает начало/конец списка при смещении.
|
|
37
|
-
* При current = 4, range = 5 вместо [2,3,4,5,6] вернет [1,2,3,4,5].
|
|
38
|
-
* @param props Свойства.
|
|
39
|
-
* @param props.current Число вокруг которого нужно сформировать список.
|
|
40
|
-
* @param props.range Размер списка.
|
|
41
|
-
* @param props.total Максимальное значение.
|
|
42
|
-
* @return Список номеров.
|
|
43
|
-
*/
|
|
44
|
-
export declare const getCorrectRangeNumbers: ({ current, range: rangeSize, total }: State) => number[];
|
|
10
|
+
current: number;
|
|
11
|
+
}, { arrows, }?: {
|
|
12
|
+
arrows?: boolean | 'active';
|
|
13
|
+
}): PaginationButton[];
|
|
45
14
|
/**
|
|
46
|
-
* Возвращает список чисел вокруг заданного.
|
|
15
|
+
* Возвращает список натуральных чисел вокруг заданного.
|
|
47
16
|
* @param props Свойства.
|
|
48
17
|
* @param props.current Число вокруг которого нужно сформировать список.
|
|
49
18
|
* @param props.range Размер списка.
|
|
50
19
|
* @param props.total Максимальное значение.
|
|
51
20
|
* @return Список номеров.
|
|
52
21
|
*/
|
|
53
|
-
export declare
|
|
54
|
-
|
|
22
|
+
export declare function getNumbersAround({ current, range: rangeSize, total, }: {
|
|
23
|
+
current: number;
|
|
24
|
+
range: number;
|
|
25
|
+
total: number;
|
|
26
|
+
}): number[];
|
package/pagination/utils.js
CHANGED
|
@@ -1,106 +1,57 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
const bind_1 = __importDefault(require("classnames/bind"));
|
|
8
|
-
const pagination_module_scss_1 = __importDefault(require("./pagination.module.scss"));
|
|
9
|
-
const lodash_1 = require("lodash");
|
|
10
|
-
exports.cx = bind_1.default.bind(pagination_module_scss_1.default);
|
|
3
|
+
exports.getNumbersAround = exports.getPaginationItems = void 0;
|
|
11
4
|
/**
|
|
12
|
-
*
|
|
13
|
-
* @param value Номер целевой страницы.
|
|
14
|
-
* @param content Содержимое кнопки.
|
|
15
|
-
* @return Список кнопок.
|
|
16
|
-
*/
|
|
17
|
-
const PageButton = (value, content = value) => ({
|
|
18
|
-
value,
|
|
19
|
-
content,
|
|
20
|
-
});
|
|
21
|
-
exports.PageButton = PageButton;
|
|
22
|
-
/**
|
|
23
|
-
* Возвращает список кнопок навигации.
|
|
5
|
+
* Формирует список кнопок навигации по страницам по дизайн-гайдам.
|
|
24
6
|
* @param props Свойства.
|
|
25
|
-
* @param
|
|
26
|
-
* @
|
|
27
|
-
* @param props.buttonKeys Значения, которые будут использованы для не числовых кнопок.
|
|
28
|
-
* @param props.buttonKeys.more Значение для отображения кнопки группы пропущенных чисел.
|
|
29
|
-
* @return Список кнопок.
|
|
7
|
+
* @param config Конфиг.
|
|
8
|
+
* @return Список.
|
|
30
9
|
*/
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
list.unshift((0, exports.PageButton)(1),
|
|
45
|
-
// не выводим многоточие когда вместо него можно поставить одно число
|
|
46
|
-
list[0].value === 3 ? (0, exports.PageButton)(2) : (0, exports.PageButton)(list[0].value - 1, buttonKeys.more));
|
|
47
|
-
}
|
|
10
|
+
function getPaginationItems({ total, current, }, { arrows = true, } = {}) {
|
|
11
|
+
const items = getNumbersAround({
|
|
12
|
+
total,
|
|
13
|
+
current,
|
|
14
|
+
range: 7,
|
|
15
|
+
}).map(value => ({ type: 'page', value }));
|
|
16
|
+
const size = items.length;
|
|
17
|
+
if (total > 7) {
|
|
18
|
+
// если первый элемент не является первой страницей
|
|
19
|
+
if (items[0].value !== 1) {
|
|
20
|
+
items.splice(0, 2, { type: 'page', value: 1 }, { type: 'more', value: items[2].value - 1 });
|
|
48
21
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
list.push((0, exports.PageButton)(total));
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
list.push(
|
|
56
|
-
// не выводим многоточие когда вместо него можно поставить одно число
|
|
57
|
-
total - list[list.length - 1].value > 2
|
|
58
|
-
? (0, exports.PageButton)(list[list.length - 1].value + 1, buttonKeys.more)
|
|
59
|
-
: (0, exports.PageButton)(total - 1), (0, exports.PageButton)(total));
|
|
60
|
-
}
|
|
22
|
+
// если последний элемент не является последней страницей
|
|
23
|
+
if (items[size - 1].value !== total) {
|
|
24
|
+
items.splice(-2, 2, { type: 'more', value: items[size - 2].value }, { type: 'page', value: total });
|
|
61
25
|
}
|
|
62
26
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
* По возможности показывает начало/конец списка при смещении.
|
|
69
|
-
* При current = 4, range = 5 вместо [2,3,4,5,6] вернет [1,2,3,4,5].
|
|
70
|
-
* @param props Свойства.
|
|
71
|
-
* @param props.current Число вокруг которого нужно сформировать список.
|
|
72
|
-
* @param props.range Размер списка.
|
|
73
|
-
* @param props.total Максимальное значение.
|
|
74
|
-
* @return Список номеров.
|
|
75
|
-
*/
|
|
76
|
-
const getCorrectRangeNumbers = ({ current, range: rangeSize, total }) => {
|
|
77
|
-
let result = [
|
|
78
|
-
...(0, exports.getRangeNumbers)({
|
|
79
|
-
current,
|
|
80
|
-
range: rangeSize,
|
|
81
|
-
total,
|
|
82
|
-
}),
|
|
83
|
-
];
|
|
84
|
-
if (total > rangeSize) {
|
|
85
|
-
if (current < rangeSize) {
|
|
86
|
-
result = (0, lodash_1.range)(1, rangeSize + 1);
|
|
27
|
+
switch (arrows) {
|
|
28
|
+
case true: {
|
|
29
|
+
items.unshift({ type: 'prev', value: Math.max(1, current - 1) });
|
|
30
|
+
items.push({ type: 'next', value: Math.min(total, current + 1) });
|
|
31
|
+
break;
|
|
87
32
|
}
|
|
88
|
-
|
|
89
|
-
|
|
33
|
+
case 'active': {
|
|
34
|
+
if (current !== 1) {
|
|
35
|
+
items.unshift({ type: 'prev', value: Math.max(1, current - 1) });
|
|
36
|
+
}
|
|
37
|
+
if (current !== total) {
|
|
38
|
+
items.push({ type: 'next', value: Math.min(total, current + 1) });
|
|
39
|
+
}
|
|
40
|
+
break;
|
|
90
41
|
}
|
|
91
42
|
}
|
|
92
|
-
return
|
|
93
|
-
}
|
|
94
|
-
exports.
|
|
43
|
+
return items;
|
|
44
|
+
}
|
|
45
|
+
exports.getPaginationItems = getPaginationItems;
|
|
95
46
|
/**
|
|
96
|
-
* Возвращает список чисел вокруг заданного.
|
|
47
|
+
* Возвращает список натуральных чисел вокруг заданного.
|
|
97
48
|
* @param props Свойства.
|
|
98
49
|
* @param props.current Число вокруг которого нужно сформировать список.
|
|
99
50
|
* @param props.range Размер списка.
|
|
100
51
|
* @param props.total Максимальное значение.
|
|
101
52
|
* @return Список номеров.
|
|
102
53
|
*/
|
|
103
|
-
|
|
54
|
+
function getNumbersAround({ current, range: rangeSize, total, }) {
|
|
104
55
|
const pageNumbers = [];
|
|
105
56
|
const readyRange = Math.min(rangeSize, total) || 0;
|
|
106
57
|
const halfRange = Math.floor(readyRange / 2);
|
|
@@ -116,5 +67,5 @@ const getRangeNumbers = ({ current, range: rangeSize, total }) => {
|
|
|
116
67
|
pageNumbers.push(i + 1);
|
|
117
68
|
}
|
|
118
69
|
return pageNumbers;
|
|
119
|
-
}
|
|
120
|
-
exports.
|
|
70
|
+
}
|
|
71
|
+
exports.getNumbersAround = getNumbersAround;
|