@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.
- package/CHANGELOG.md +11 -0
- package/dist/Component.d.ts +41 -0
- package/dist/Component.js +42 -0
- package/dist/components/default-view/index.css +22 -0
- package/dist/components/default-view/index.d.ts +5 -0
- package/dist/components/default-view/index.js +56 -0
- package/dist/components/per-page-view/index.css +16 -0
- package/dist/components/per-page-view/index.d.ts +5 -0
- package/dist/components/per-page-view/index.js +23 -0
- package/dist/components/tag/index.css +52 -0
- package/dist/components/tag/index.d.ts +4 -0
- package/dist/components/tag/index.js +62 -0
- package/dist/cssm/Component.d.ts +41 -0
- package/dist/cssm/Component.js +44 -0
- package/dist/cssm/components/default-view/index.d.ts +5 -0
- package/dist/cssm/components/default-view/index.js +56 -0
- package/dist/cssm/components/default-view/index.module.css +21 -0
- package/dist/cssm/components/per-page-view/index.d.ts +5 -0
- package/dist/cssm/components/per-page-view/index.js +22 -0
- package/dist/cssm/components/per-page-view/index.module.css +15 -0
- package/dist/cssm/components/tag/index.d.ts +4 -0
- package/dist/cssm/components/tag/index.js +61 -0
- package/dist/cssm/components/tag/index.module.css +51 -0
- package/dist/cssm/index.d.ts +1 -0
- package/dist/cssm/index.js +21 -0
- package/dist/cssm/index.module.css +31 -0
- package/dist/esm/Component.d.ts +41 -0
- package/dist/esm/Component.js +33 -0
- package/dist/esm/components/default-view/index.css +22 -0
- package/dist/esm/components/default-view/index.d.ts +5 -0
- package/dist/esm/components/default-view/index.js +48 -0
- package/dist/esm/components/per-page-view/index.css +16 -0
- package/dist/esm/components/per-page-view/index.d.ts +5 -0
- package/dist/esm/components/per-page-view/index.js +15 -0
- package/dist/esm/components/tag/index.css +52 -0
- package/dist/esm/components/tag/index.d.ts +4 -0
- package/dist/esm/components/tag/index.js +53 -0
- package/dist/esm/index.css +32 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +9 -0
- package/dist/index.css +32 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +17 -0
- package/dist/modern/Component.d.ts +41 -0
- package/dist/modern/Component.js +32 -0
- package/dist/modern/components/default-view/index.css +22 -0
- package/dist/modern/components/default-view/index.d.ts +5 -0
- package/dist/modern/components/default-view/index.js +47 -0
- package/dist/modern/components/per-page-view/index.css +16 -0
- package/dist/modern/components/per-page-view/index.d.ts +5 -0
- package/dist/modern/components/per-page-view/index.js +12 -0
- package/dist/modern/components/tag/index.css +52 -0
- package/dist/modern/components/tag/index.d.ts +4 -0
- package/dist/modern/components/tag/index.js +10 -0
- package/dist/modern/index.css +32 -0
- package/dist/modern/index.d.ts +1 -0
- package/dist/modern/index.js +9 -0
- package/dist/send-stats.js +82 -0
- package/package.json +25 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import 'classnames';
|
|
3
|
+
import '@alfalab/core-components-tag/dist/modern';
|
|
4
|
+
import { Tag } from '../tag/index.js';
|
|
5
|
+
|
|
6
|
+
var styles = {"dots":"pagination__dots_kix4e"};
|
|
7
|
+
require('./index.css')
|
|
8
|
+
|
|
9
|
+
const DefaultView = ({ sidePadding = 2, activePadding = 1, pagesCount, currentPageIndex, onPageChange = () => null, }) => {
|
|
10
|
+
const maxHalfCount = sidePadding + activePadding + 1;
|
|
11
|
+
const maxElementsCount = maxHalfCount * 2 + 1;
|
|
12
|
+
const itemsFit = pagesCount <= maxElementsCount;
|
|
13
|
+
const elementsCount = itemsFit ? pagesCount : maxElementsCount;
|
|
14
|
+
const getPageIndex = useCallback((elementIndex) => {
|
|
15
|
+
const lastIndex = pagesCount - 1;
|
|
16
|
+
const reverseIndex = lastIndex - currentPageIndex;
|
|
17
|
+
const lastElementIndex = elementsCount - 1;
|
|
18
|
+
const reverseElementIndex = lastElementIndex - elementIndex;
|
|
19
|
+
const hasCollapsedItems = (index) => !itemsFit && index >= maxHalfCount;
|
|
20
|
+
if (elementIndex < sidePadding) {
|
|
21
|
+
return elementIndex;
|
|
22
|
+
}
|
|
23
|
+
if (elementIndex === sidePadding && hasCollapsedItems(currentPageIndex)) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
if (reverseElementIndex === sidePadding && hasCollapsedItems(reverseIndex)) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
if (reverseElementIndex < sidePadding) {
|
|
30
|
+
return lastIndex - reverseElementIndex;
|
|
31
|
+
}
|
|
32
|
+
const computedIndex = currentPageIndex - maxHalfCount + elementIndex;
|
|
33
|
+
return Math.min(lastIndex - reverseElementIndex, Math.max(elementIndex, computedIndex));
|
|
34
|
+
}, [currentPageIndex, elementsCount, itemsFit, maxHalfCount, pagesCount, sidePadding]);
|
|
35
|
+
return (React.createElement(React.Fragment, null, Array(elementsCount)
|
|
36
|
+
.fill('')
|
|
37
|
+
.map((_, i) => {
|
|
38
|
+
const pageIndex = getPageIndex(i);
|
|
39
|
+
if (pageIndex === null) {
|
|
40
|
+
return (React.createElement("div", { key: i.toString(), className: styles.dots }, "..."));
|
|
41
|
+
}
|
|
42
|
+
const active = currentPageIndex === pageIndex;
|
|
43
|
+
return (React.createElement(Tag, { key: i.toString(), checked: active, disabled: active, onClick: () => onPageChange(pageIndex) }, pageIndex + 1));
|
|
44
|
+
})));
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export { DefaultView };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
var styles = {"component":"pagination__component_begf8"};
|
|
4
|
+
require('./index.css')
|
|
5
|
+
|
|
6
|
+
const PerPageView = ({ pagesCount, currentPageIndex }) => (React.createElement("span", { className: styles.component },
|
|
7
|
+
currentPageIndex + 1,
|
|
8
|
+
" \u0438\u0437 ",
|
|
9
|
+
pagesCount,
|
|
10
|
+
" \u0441\u0442\u0440\u0430\u043D\u0438\u0446"));
|
|
11
|
+
|
|
12
|
+
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,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
import { Tag as Tag$1 } from '@alfalab/core-components-tag/dist/modern';
|
|
4
|
+
|
|
5
|
+
var styles = {"tag":"pagination__tag_1gidc","checked":"pagination__checked_1gidc"};
|
|
6
|
+
require('./index.css')
|
|
7
|
+
|
|
8
|
+
const Tag = ({ className, checked, ...restProps }) => (React.createElement(Tag$1, Object.assign({}, restProps, { checked: checked, size: 'xxs', className: cn(className, styles.tag, { [styles.checked]: checked }) })));
|
|
9
|
+
|
|
10
|
+
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 '@alfalab/core-components-tag/dist/modern';
|
|
6
|
+
import './components/tag/index.js';
|
|
7
|
+
import './components/default-view/index.js';
|
|
8
|
+
import './components/per-page-view/index.js';
|
|
9
|
+
export { Pagination } from './Component.js';
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
const http = require('http');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const { promisify } = require('util');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
const readFile = promisify(fs.readFile);
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
const remoteHost = process.env.NIS_HOST || 'digital';
|
|
10
|
+
const remotePort = process.env.NIS_PORT || 80;
|
|
11
|
+
const remotePath = process.env.NIS_PATH || '/npm-install-stats/api/install-stats';
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
const [_, node, os, arch] =
|
|
15
|
+
/node\/v(\d+\.\d+\.\d+) (\w+) (\w+)/.exec(process.env.npm_config_user_agent) || [];
|
|
16
|
+
const [__, npm] = /npm\/(\d+\.\d+\.\d+)/.exec(process.env.npm_config_user_agent) || [];
|
|
17
|
+
const [___, yarn] = /yarn\/(\d+\.\d+\.\d+)/.exec(process.env.npm_config_user_agent) || [];
|
|
18
|
+
|
|
19
|
+
let ownPackageJson, packageJson;
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
const result = await Promise.all([
|
|
23
|
+
readFile(path.join(process.cwd(), 'package.json'), 'utf-8'),
|
|
24
|
+
readFile(path.join(process.cwd(), '../../../package.json'), 'utf-8'),
|
|
25
|
+
]);
|
|
26
|
+
|
|
27
|
+
ownPackageJson = JSON.parse(result[0]);
|
|
28
|
+
packageJson = JSON.parse(result[1]);
|
|
29
|
+
} catch (err) {
|
|
30
|
+
ownPackageJson = '';
|
|
31
|
+
packageJson = '';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const data = {
|
|
35
|
+
node,
|
|
36
|
+
npm,
|
|
37
|
+
yarn,
|
|
38
|
+
os,
|
|
39
|
+
arch,
|
|
40
|
+
ownPackageJson: JSON.stringify(ownPackageJson),
|
|
41
|
+
packageJson: JSON.stringify(packageJson),
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const body = JSON.stringify(data);
|
|
45
|
+
|
|
46
|
+
const options = {
|
|
47
|
+
host: remoteHost,
|
|
48
|
+
port: remotePort,
|
|
49
|
+
path: remotePath,
|
|
50
|
+
method: 'POST',
|
|
51
|
+
headers: {
|
|
52
|
+
'Content-Type': 'application/json',
|
|
53
|
+
'Content-Length': body.length,
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
return new Promise((resolve, reject) => {
|
|
58
|
+
const req = http.request(options, res => {
|
|
59
|
+
res.on('end', () => {
|
|
60
|
+
resolve();
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
req.on('error', () => {
|
|
65
|
+
reject();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
req.write(body);
|
|
69
|
+
req.end();
|
|
70
|
+
});
|
|
71
|
+
} catch (error) {
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
main()
|
|
77
|
+
.then(() => {
|
|
78
|
+
process.exit(0);
|
|
79
|
+
})
|
|
80
|
+
.catch(() => {
|
|
81
|
+
process.exit(0);
|
|
82
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@alfalab/core-components-pagination",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"keywords": [],
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"module": "./dist/esm/index.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"peerDependencies": {
|
|
16
|
+
"react": "^16.9.0 || ^17.0.1",
|
|
17
|
+
"react-dom": "^16.9.0 || ^17.0.1"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@alfalab/core-components-button": "^5.0.3",
|
|
21
|
+
"@alfalab/core-components-tag": "^4.0.0",
|
|
22
|
+
"classnames": "^2.2.6"
|
|
23
|
+
},
|
|
24
|
+
"gitHead": "94999e533968aa575e92106dffa8bbbb8e7ac71d"
|
|
25
|
+
}
|