@xaypay/tui 0.0.3 → 0.0.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/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/tui.iml +12 -0
- package/.idea/vcs.xml +6 -0
- package/.idea/workspace.xml +1755 -0
- package/.storybook/main.js +1 -1
- package/dist/index.es.js +866 -15
- package/dist/index.js +903 -14
- package/package.json +9 -4
- package/src/assets/heart-filled.svg +17 -0
- package/src/assets/heart-outline.svg +14 -0
- package/src/assets/like-filled.svg +21 -0
- package/src/assets/like-outline.svg +21 -0
- package/src/assets/star-filled.svg +21 -0
- package/src/assets/star-outline.svg +5 -0
- package/src/assets_old/icons/Read Me.txt +7 -0
- package/src/assets_old/icons/demo-files/demo.css +152 -0
- package/src/assets_old/icons/demo-files/demo.js +30 -0
- package/src/assets_old/icons/demo.html +150 -0
- package/src/assets_old/icons/fonts/icomoon.eot +0 -0
- package/src/assets_old/icons/fonts/icomoon.svg +18 -0
- package/src/assets_old/icons/fonts/icomoon.ttf +0 -0
- package/src/assets_old/icons/fonts/icomoon.woff +0 -0
- package/src/assets_old/icons/selection.json +1 -0
- package/src/assets_old/icons/style.css +51 -0
- package/src/components/autocomplate/autocomplate.module.css +74 -0
- package/src/components/autocomplate/autocomplate.stories.js +11 -0
- package/src/components/autocomplate/index.js +117 -0
- package/src/components/button/button.module.css +63 -1
- package/src/components/button/button.stories.js +10 -10
- package/src/components/button/index.js +12 -9
- package/src/components/captcha/blue.png +0 -0
- package/src/components/captcha/captcha.module.css +66 -0
- package/src/components/captcha/captcha.stories.js +17 -0
- package/src/components/captcha/green.png +0 -0
- package/src/components/captcha/index.js +63 -0
- package/src/components/captcha/red.png +0 -0
- package/src/components/checkbox/checkbox.module.css +57 -0
- package/src/components/checkbox/checkbox.stories.js +10 -0
- package/src/components/checkbox/index.js +87 -0
- package/src/components/icon/HeartFilled.js +26 -0
- package/src/components/icon/HeartOutline.js +25 -0
- package/src/components/icon/Icon.js +6 -0
- package/src/components/icon/LikeFilled.js +24 -0
- package/src/components/icon/LikeOutline.js +24 -0
- package/src/components/icon/StarFilled.js +24 -0
- package/src/components/icon/StarOutline.js +24 -0
- package/src/components/icon/index.js +6 -0
- package/src/components/input/index.js +90 -0
- package/src/components/input/input.module.css +89 -0
- package/src/components/input/input.stories.js +38 -0
- package/src/components/modal/index.js +24 -0
- package/src/components/modal/modal.module.css +35 -0
- package/src/components/modal/modal.stories.js +29 -0
- package/src/components/multiselect/index.js +76 -0
- package/src/components/multiselect/multiselect.module.css +137 -0
- package/src/components/multiselect/multiselect.stories.js +19 -0
- package/src/components/pagination/index.js +119 -0
- package/src/components/pagination/pagination.module.css +80 -0
- package/src/components/pagination/pagination.stories.js +371 -0
- package/src/components/pagination/paginationRange.js +70 -0
- package/src/components/radio/index.js +68 -0
- package/src/components/radio/radio.module.css +59 -0
- package/src/components/radio/radio.stories.js +10 -0
- package/src/components/select/index.js +130 -0
- package/src/components/select/select.module.css +100 -0
- package/src/components/select/select.stories.js +21 -0
- package/src/components/typography/index.js +53 -0
- package/src/components/typography/typography.module.css +60 -0
- package/src/components/typography/typography.stories.js +29 -0
- package/src/index.js +10 -1
- package/storybook-static/favicon.ico +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Multiselect } from "./index";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
component: Multiselect,
|
|
6
|
+
title: "Components/Multiselect",
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const Template = (args) => <Multiselect {...args} />;
|
|
10
|
+
|
|
11
|
+
export const Default = Template.bind({});
|
|
12
|
+
Default.args = {
|
|
13
|
+
jsonOptionsData: '[{"id":"1", "name":"Կենտրոն"}]',
|
|
14
|
+
jsonSelectedOptionsData: '[{"id":"0", "name":"Արաբկիր"}, {"id":"2", "name":"Մալաթիա"}]',
|
|
15
|
+
label: 'label',
|
|
16
|
+
onchange: (newValue)=> {
|
|
17
|
+
console.log(newValue);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { React, useState, useEffect } from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import classnames from "classnames";
|
|
4
|
+
import styles from "./pagination.module.css";
|
|
5
|
+
import { PaginationRange, Dots } from "./paginationRange";
|
|
6
|
+
import Icon from '../icon/Icon'
|
|
7
|
+
|
|
8
|
+
export const Pagination = ({
|
|
9
|
+
onChange,
|
|
10
|
+
totalCount,
|
|
11
|
+
siblingCount,
|
|
12
|
+
currentPage,
|
|
13
|
+
offset,
|
|
14
|
+
className,
|
|
15
|
+
}) => {
|
|
16
|
+
const [siblingCountNumber, setSibilingCountNumber] = useState(2);
|
|
17
|
+
const [currentPageNumber, setCurrentPage] = useState(1);
|
|
18
|
+
const [currentTotalCount, setcurrentTotalCount] = useState(10);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
setcurrentTotalCount(totalCount);
|
|
21
|
+
}, [totalCount]);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
setSibilingCountNumber(siblingCount);
|
|
24
|
+
}, [siblingCount]);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
setCurrentPage(currentPage);
|
|
27
|
+
}, [currentPage]);
|
|
28
|
+
|
|
29
|
+
const onPageChange = (page) => {
|
|
30
|
+
setCurrentPage(page);
|
|
31
|
+
};
|
|
32
|
+
onChange(currentPageNumber);
|
|
33
|
+
const paginationRange = PaginationRange({
|
|
34
|
+
currentPageNumber,
|
|
35
|
+
currentTotalCount,
|
|
36
|
+
siblingCountNumber,
|
|
37
|
+
offset,
|
|
38
|
+
});
|
|
39
|
+
if (currentPageNumber === 0 || paginationRange.length < 2) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
const classProps = classnames(styles.list, className ? className : styles["pagination-bar"]);
|
|
43
|
+
|
|
44
|
+
const onNext = () => {
|
|
45
|
+
onPageChange(currentPageNumber + 1);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const onPrevious = () => {
|
|
49
|
+
onPageChange(currentPageNumber - 1);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const onNextFive = () => {
|
|
53
|
+
currentPageNumber !== lastPage - 4 ?
|
|
54
|
+
onPageChange(currentPageNumber + 5) : onPageChange(currentPageNumber + 4);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const onPreviousFive = (e) => {
|
|
58
|
+
currentPageNumber !== 5
|
|
59
|
+
? onPageChange(currentPageNumber - 5)
|
|
60
|
+
: onPageChange(currentPageNumber - 4);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
let lastPage = paginationRange[paginationRange.length - 1];
|
|
64
|
+
return (
|
|
65
|
+
<ul className={classProps}>
|
|
66
|
+
<button className={styles["pagination-btn"]} onClick={onPrevious} disabled={currentPage === 1 ? true : false}>
|
|
67
|
+
<Icon className="icon-arrow-back"/>
|
|
68
|
+
</button>
|
|
69
|
+
|
|
70
|
+
{paginationRange.map((pageNumber, id) => {
|
|
71
|
+
if (pageNumber === Dots) {
|
|
72
|
+
let currentPageIndex = paginationRange.indexOf(currentPageNumber);
|
|
73
|
+
return (
|
|
74
|
+
<li key={id} className={classnames(styles['pagination-jump-next'],styles.listItem)} onClick={id < currentPageIndex ? onPreviousFive : onNextFive}
|
|
75
|
+
disabled={currentPageIndex === 0 ? true : false}>
|
|
76
|
+
<span className={styles['pagination-jump-next-txt']}>...</span>
|
|
77
|
+
<span className={styles['pagination-jump-next-arrow']}>
|
|
78
|
+
<Icon className="icon-arrow-jump-next"/>
|
|
79
|
+
</span>
|
|
80
|
+
</li>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<li
|
|
86
|
+
onClick={() => onPageChange(pageNumber)}
|
|
87
|
+
key={id}
|
|
88
|
+
className={classnames(
|
|
89
|
+
`${
|
|
90
|
+
pageNumber === currentPageNumber
|
|
91
|
+
? styles.selected
|
|
92
|
+
: styles.listItem
|
|
93
|
+
}`, styles['pagination-item']
|
|
94
|
+
)}
|
|
95
|
+
>
|
|
96
|
+
{pageNumber}
|
|
97
|
+
</li>
|
|
98
|
+
);
|
|
99
|
+
})}
|
|
100
|
+
<button
|
|
101
|
+
onClick={onNext}
|
|
102
|
+
className={styles["pagination-btn"]}
|
|
103
|
+
disabled={currentPageNumber === lastPage ? true : false}
|
|
104
|
+
>
|
|
105
|
+
<Icon className='icon-arrow'/>
|
|
106
|
+
</button>
|
|
107
|
+
</ul>
|
|
108
|
+
);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
Pagination.propTypes = {
|
|
112
|
+
offset: PropTypes.number,
|
|
113
|
+
totalCount: PropTypes.number,
|
|
114
|
+
className: PropTypes.string,
|
|
115
|
+
siblingCount: PropTypes.number,
|
|
116
|
+
currentPage: PropTypes.number,
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
Pagination.defaultProps = { offset: 2, siblingCount: 2 };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
|
|
2
|
+
.listItem:focus {
|
|
3
|
+
background-color: #4CAF50;
|
|
4
|
+
color: white;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.listItem:hover:not(.active) {
|
|
8
|
+
background-color: #ddd;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.pagination-bar {
|
|
12
|
+
display: flex;
|
|
13
|
+
flex-direction: row;
|
|
14
|
+
flex-wrap: nowrap;
|
|
15
|
+
gap: 8px;
|
|
16
|
+
}
|
|
17
|
+
.pagination-btn {
|
|
18
|
+
width: 34px;
|
|
19
|
+
height: 34px;
|
|
20
|
+
display: flex;
|
|
21
|
+
align-items: center;
|
|
22
|
+
justify-content: center;
|
|
23
|
+
background-color: rgba(255, 255, 255, 1);
|
|
24
|
+
box-shadow: 0 0 0 1px rgba(238,238,238, 1);
|
|
25
|
+
border-radius: 6px;
|
|
26
|
+
cursor: pointer;
|
|
27
|
+
border: none;
|
|
28
|
+
outline: none;
|
|
29
|
+
}
|
|
30
|
+
.pagination-item, .pagination-jump-next {
|
|
31
|
+
flex: 0 0 auto;
|
|
32
|
+
display: flex;
|
|
33
|
+
align-items: center;
|
|
34
|
+
justify-content: center;
|
|
35
|
+
width: 34px;
|
|
36
|
+
height: 34px;
|
|
37
|
+
position: relative;
|
|
38
|
+
font-size: 16px;
|
|
39
|
+
line-height: 22px;
|
|
40
|
+
background-color: rgba(255, 255, 255, 1);
|
|
41
|
+
box-shadow: 0 0 0 1px rgba(238,238,238, 1);
|
|
42
|
+
border-radius: 6px;
|
|
43
|
+
cursor: pointer;
|
|
44
|
+
transition: background-color 240ms;
|
|
45
|
+
}
|
|
46
|
+
.pagination-item:hover {
|
|
47
|
+
background-color: rgba(238, 238, 238, 1);
|
|
48
|
+
}
|
|
49
|
+
.pagination-item.selected {
|
|
50
|
+
background-color: rgba(0, 35, 106, 1);
|
|
51
|
+
color: rgba(255, 255, 255, 1);
|
|
52
|
+
}
|
|
53
|
+
.pagination-jump-next-txt, .pagination-jump-next-arrow {
|
|
54
|
+
position: absolute;
|
|
55
|
+
top: 0;
|
|
56
|
+
left: 0;
|
|
57
|
+
right: 0;
|
|
58
|
+
bottom: 0;
|
|
59
|
+
font-size: 12px;
|
|
60
|
+
line-height: 14px;
|
|
61
|
+
margin: auto;
|
|
62
|
+
display: flex;
|
|
63
|
+
align-items: center;
|
|
64
|
+
justify-content: center;
|
|
65
|
+
transition: opacity 240ms, color 240ms;
|
|
66
|
+
}
|
|
67
|
+
.pagination-jump-next-arrow {
|
|
68
|
+
opacity: 0;
|
|
69
|
+
}
|
|
70
|
+
.pagination-jump-next:hover .pagination-jump-next-arrow {
|
|
71
|
+
opacity: 1;
|
|
72
|
+
}
|
|
73
|
+
.pagination-jump-next:hover .pagination-jump-next-txt {
|
|
74
|
+
opacity: 0;
|
|
75
|
+
}
|
|
76
|
+
i {
|
|
77
|
+
font-size: 12px;
|
|
78
|
+
line-height: 12px;
|
|
79
|
+
color: #3C393E;
|
|
80
|
+
}
|
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
import { React, useState, useMemo, useEffect } from "react";
|
|
2
|
+
import { Pagination } from "./index";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
component: Pagination,
|
|
6
|
+
title: "Components/Pagination",
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const data = [
|
|
10
|
+
{
|
|
11
|
+
id: 1,
|
|
12
|
+
first_name: "Jessamyn",
|
|
13
|
+
last_name: "Espinazo",
|
|
14
|
+
email: "jespinazo0@chicagotribune.com",
|
|
15
|
+
phone: "162-166-0977",
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
id: 2,
|
|
19
|
+
first_name: "Isac",
|
|
20
|
+
last_name: "Tooher",
|
|
21
|
+
email: "itooher1@psu.edu",
|
|
22
|
+
phone: "655-567-3619",
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: 3,
|
|
26
|
+
first_name: "Tabbatha",
|
|
27
|
+
last_name: "Proschke",
|
|
28
|
+
email: "tproschke2@weibo.com",
|
|
29
|
+
phone: "327-612-4850",
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
id: 4,
|
|
33
|
+
first_name: "Ninetta",
|
|
34
|
+
last_name: "Mabb",
|
|
35
|
+
email: "nmabb3@canalblog.com",
|
|
36
|
+
phone: "971-296-0911",
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: 5,
|
|
40
|
+
first_name: "Danni",
|
|
41
|
+
last_name: "Wallentin",
|
|
42
|
+
email: "dwallentin4@comcast.net",
|
|
43
|
+
phone: "983-297-0506",
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: 6,
|
|
47
|
+
first_name: "Neely",
|
|
48
|
+
last_name: "Purkins",
|
|
49
|
+
email: "npurkins5@mediafire.com",
|
|
50
|
+
phone: "379-119-4237",
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
id: 7,
|
|
54
|
+
first_name: "Jessika",
|
|
55
|
+
last_name: "Kinkaid",
|
|
56
|
+
email: "jkinkaid6@eventbrite.com",
|
|
57
|
+
phone: "771-888-6284",
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
id: 8,
|
|
61
|
+
first_name: "Julianna",
|
|
62
|
+
last_name: "Swindall",
|
|
63
|
+
email: "jswindall7@aol.com",
|
|
64
|
+
phone: "252-614-0486",
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
id: 9,
|
|
68
|
+
first_name: "Corrinne",
|
|
69
|
+
last_name: "Geeve",
|
|
70
|
+
email: "cgeeve8@wisc.edu",
|
|
71
|
+
phone: "450-872-8646",
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
id: 10,
|
|
75
|
+
first_name: "Trumann",
|
|
76
|
+
last_name: "Flux",
|
|
77
|
+
email: "tflux9@census.gov",
|
|
78
|
+
phone: "249-892-1585",
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
id: 11,
|
|
82
|
+
first_name: "Annalise",
|
|
83
|
+
last_name: "Keinrat",
|
|
84
|
+
email: "akeinrata@i2i.jp",
|
|
85
|
+
phone: "659-283-4601",
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
id: 12,
|
|
89
|
+
first_name: "Cal",
|
|
90
|
+
last_name: "Haverson",
|
|
91
|
+
email: "chaversonb@multiply.com",
|
|
92
|
+
phone: "689-567-9516",
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
id: 13,
|
|
96
|
+
first_name: "Erik",
|
|
97
|
+
last_name: "McGillivrie",
|
|
98
|
+
email: "emcgillivriec@theglobeandmail.com",
|
|
99
|
+
phone: "334-579-0995",
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
id: 14,
|
|
103
|
+
first_name: "Cherilyn",
|
|
104
|
+
last_name: "Tuddenham",
|
|
105
|
+
email: "ctuddenhamd@indiegogo.com",
|
|
106
|
+
phone: "408-721-4575",
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
id: 15,
|
|
110
|
+
first_name: "Merola",
|
|
111
|
+
last_name: "MacDowal",
|
|
112
|
+
email: "mmacdowale@omniture.com",
|
|
113
|
+
phone: "863-234-5628",
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
id: 16,
|
|
117
|
+
first_name: "Olenolin",
|
|
118
|
+
last_name: "O'Shiels",
|
|
119
|
+
email: "ooshielsf@smh.com.au",
|
|
120
|
+
phone: "646-127-1652",
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
id: 17,
|
|
124
|
+
first_name: "Donnie",
|
|
125
|
+
last_name: "Oliphant",
|
|
126
|
+
email: "doliphantg@i2i.jp",
|
|
127
|
+
phone: "975-457-5826",
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
id: 18,
|
|
131
|
+
first_name: "Carly",
|
|
132
|
+
last_name: "Bulleyn",
|
|
133
|
+
email: "cbulleynh@fc2.com",
|
|
134
|
+
phone: "938-211-6682",
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
id: 19,
|
|
138
|
+
first_name: "Walt",
|
|
139
|
+
last_name: "Meace",
|
|
140
|
+
email: "wmeacei@printfriendly.com",
|
|
141
|
+
phone: "688-775-4039",
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
id: 20,
|
|
145
|
+
first_name: "Debbie",
|
|
146
|
+
last_name: "Rockhall",
|
|
147
|
+
email: "drockhallj@weebly.com",
|
|
148
|
+
phone: "120-270-4052",
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
id: 21,
|
|
152
|
+
first_name: "Devonna",
|
|
153
|
+
last_name: "Oylett",
|
|
154
|
+
email: "doylettk@jalbum.net",
|
|
155
|
+
phone: "364-921-6359",
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
id: 22,
|
|
159
|
+
first_name: "Jourdan",
|
|
160
|
+
last_name: "Grahamslaw",
|
|
161
|
+
email: "jgrahamslawl@irs.gov",
|
|
162
|
+
phone: "939-973-9940",
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
id: 23,
|
|
166
|
+
first_name: "Brana",
|
|
167
|
+
last_name: "Haste",
|
|
168
|
+
email: "bhastem@typepad.com",
|
|
169
|
+
phone: "142-349-6034",
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
id: 24,
|
|
173
|
+
first_name: "Wilmer",
|
|
174
|
+
last_name: "Trenouth",
|
|
175
|
+
email: "wtrenouthn@netvibes.com",
|
|
176
|
+
phone: "346-897-1305",
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
id: 25,
|
|
180
|
+
first_name: "Brandtr",
|
|
181
|
+
last_name: "Esler",
|
|
182
|
+
email: "beslero@wikispaces.com",
|
|
183
|
+
phone: "638-763-4382",
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
id: 26,
|
|
187
|
+
first_name: "Andonis",
|
|
188
|
+
last_name: "Durbin",
|
|
189
|
+
email: "adurbinp@newyorker.com",
|
|
190
|
+
phone: "531-854-8916",
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
id: 27,
|
|
194
|
+
first_name: "Cynthia",
|
|
195
|
+
last_name: "How to preserve",
|
|
196
|
+
email: "chowtopreserveq@de.vu",
|
|
197
|
+
phone: "119-342-9726",
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
id: 28,
|
|
201
|
+
first_name: "Jennee",
|
|
202
|
+
last_name: "Cowdroy",
|
|
203
|
+
email: "jcowdroyr@marketwatch.com",
|
|
204
|
+
phone: "804-307-6112",
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
id: 29,
|
|
208
|
+
first_name: "Lorin",
|
|
209
|
+
last_name: "D'Hooghe",
|
|
210
|
+
email: "ldhooghes@wix.com",
|
|
211
|
+
phone: "374-113-9906",
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
id: 30,
|
|
215
|
+
first_name: "Letti",
|
|
216
|
+
last_name: "Acreman",
|
|
217
|
+
email: "lacremant@ted.com",
|
|
218
|
+
phone: "157-463-7705",
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
id: 31,
|
|
222
|
+
first_name: "Drucie",
|
|
223
|
+
last_name: "Watkins",
|
|
224
|
+
email: "dwatkinsu@japanpost.jp",
|
|
225
|
+
phone: "778-273-9630",
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
id: 32,
|
|
229
|
+
first_name: "Ev",
|
|
230
|
+
last_name: "Christy",
|
|
231
|
+
email: "echristyv@addthis.com",
|
|
232
|
+
phone: "575-366-6055",
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
id: 33,
|
|
236
|
+
first_name: "Nick",
|
|
237
|
+
last_name: "Moores",
|
|
238
|
+
email: "nmooresw@privacy.gov.au",
|
|
239
|
+
phone: "905-406-0567",
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
id: 34,
|
|
243
|
+
first_name: "Mollie",
|
|
244
|
+
last_name: "Strut",
|
|
245
|
+
email: "mstrutx@ftc.gov",
|
|
246
|
+
phone: "838-952-4289",
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
id: 35,
|
|
250
|
+
first_name: "Dasha",
|
|
251
|
+
last_name: "Gerring",
|
|
252
|
+
email: "dgerringy@histats.com",
|
|
253
|
+
phone: "147-553-3272",
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
id: 36,
|
|
257
|
+
first_name: "Hazel",
|
|
258
|
+
last_name: "Barber",
|
|
259
|
+
email: "hbarberz@walmart.com",
|
|
260
|
+
phone: "830-229-8318",
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
id: 37,
|
|
264
|
+
first_name: "Danila",
|
|
265
|
+
last_name: "Gidman",
|
|
266
|
+
email: "dgidman10@networkadvertising.org",
|
|
267
|
+
phone: "474-241-8816",
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
id: 38,
|
|
271
|
+
first_name: "Gladi",
|
|
272
|
+
last_name: "Torry",
|
|
273
|
+
email: "gtorry11@usgs.gov",
|
|
274
|
+
phone: "865-594-2480",
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
id: 39,
|
|
278
|
+
first_name: "Mair",
|
|
279
|
+
last_name: "Garnam",
|
|
280
|
+
email: "mgarnam12@miitbeian.gov.cn",
|
|
281
|
+
phone: "890-209-7033",
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
id: 40,
|
|
285
|
+
first_name: "Wilie",
|
|
286
|
+
last_name: "Sebire",
|
|
287
|
+
email: "wsebire13@pen.io",
|
|
288
|
+
phone: "303-945-1363",
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
id: 41,
|
|
292
|
+
first_name: "Corrie",
|
|
293
|
+
last_name: "Terrett",
|
|
294
|
+
email: "cterrett14@comcast.net",
|
|
295
|
+
phone: "410-942-4578",
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
id: 42,
|
|
299
|
+
first_name: "Dene",
|
|
300
|
+
last_name: "Mullender",
|
|
301
|
+
email: "dmullender15@sun.com",
|
|
302
|
+
phone: "901-439-2803",
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
id: 43,
|
|
306
|
+
first_name: "Prue",
|
|
307
|
+
last_name: "Digginson",
|
|
308
|
+
email: "pdigginson16@discuz.net",
|
|
309
|
+
phone: "149-648-9075",
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
id: 44,
|
|
313
|
+
first_name: "Blithe",
|
|
314
|
+
last_name: "Huriche",
|
|
315
|
+
email: "bhuriche17@dion.ne.jp",
|
|
316
|
+
phone: "572-905-5251",
|
|
317
|
+
},
|
|
318
|
+
];
|
|
319
|
+
const Template = ({ offset, currentPage, siblingCount, totalCount }) => {
|
|
320
|
+
const [currentPageNumber, setCurrentPageNumber] = useState(currentPage);
|
|
321
|
+
const currentTableData = useMemo(() => {
|
|
322
|
+
const firstPageIndex = (currentPageNumber - 1) * offset;
|
|
323
|
+
const lastPageIndex = firstPageIndex + offset;
|
|
324
|
+
return data.slice(firstPageIndex, lastPageIndex);
|
|
325
|
+
}, [offset, currentPageNumber]);
|
|
326
|
+
|
|
327
|
+
return (
|
|
328
|
+
<>
|
|
329
|
+
<table>
|
|
330
|
+
<thead>
|
|
331
|
+
<tr>
|
|
332
|
+
<th>ID</th>
|
|
333
|
+
<th>FIRST NAME</th>
|
|
334
|
+
<th>LAST NAME</th>
|
|
335
|
+
<th>EMAIL</th>
|
|
336
|
+
<th>PHONE</th>
|
|
337
|
+
</tr>
|
|
338
|
+
</thead>
|
|
339
|
+
<tbody>
|
|
340
|
+
{currentTableData.map((item, id) => {
|
|
341
|
+
return (
|
|
342
|
+
<tr key={id}>
|
|
343
|
+
<td>{item.id}</td>
|
|
344
|
+
<td>{item.first_name}</td>
|
|
345
|
+
<td>{item.last_name}</td>
|
|
346
|
+
<td>{item.email}</td>
|
|
347
|
+
<td>{item.phone}</td>
|
|
348
|
+
</tr>
|
|
349
|
+
);
|
|
350
|
+
})}
|
|
351
|
+
</tbody>
|
|
352
|
+
</table>
|
|
353
|
+
<Pagination
|
|
354
|
+
currentPage={currentPage}
|
|
355
|
+
totalCount={totalCount}
|
|
356
|
+
offset={offset}
|
|
357
|
+
siblingCount={siblingCount}
|
|
358
|
+
onChange={(page) => setCurrentPageNumber(page)}
|
|
359
|
+
/>
|
|
360
|
+
</>
|
|
361
|
+
);
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
export const Default = Template.bind({});
|
|
365
|
+
|
|
366
|
+
Default.args = {
|
|
367
|
+
offset: 10,
|
|
368
|
+
currentPage: 4,
|
|
369
|
+
siblingCount: 2,
|
|
370
|
+
totalCount: 44
|
|
371
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import React, { useMemo } from "react";
|
|
2
|
+
// import styles from "./pagination.module.scss";
|
|
3
|
+
|
|
4
|
+
export const Dots = "...";
|
|
5
|
+
|
|
6
|
+
const range = (start, end) => {
|
|
7
|
+
const length = end - start + 1;
|
|
8
|
+
return Array.from({ length }, (_, idx) => idx + start);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const PaginationRange = ({
|
|
12
|
+
currentTotalCount,
|
|
13
|
+
offset,
|
|
14
|
+
siblingCountNumber,
|
|
15
|
+
currentPageNumber,
|
|
16
|
+
}) => {
|
|
17
|
+
const paginationRange = useMemo(() => {
|
|
18
|
+
const totalPageCount = Math.ceil(currentTotalCount / offset);
|
|
19
|
+
|
|
20
|
+
//currentPage + 2*Dots + start + end = 5
|
|
21
|
+
const totalPageNumber = siblingCountNumber + 5;
|
|
22
|
+
if (totalPageNumber >= totalPageCount) {
|
|
23
|
+
return range(1, totalPageCount);
|
|
24
|
+
}
|
|
25
|
+
const rightSiblingIndex = Math.min(
|
|
26
|
+
currentPageNumber + siblingCountNumber,
|
|
27
|
+
totalPageCount
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
const leftSiblingIndex = Math.max(
|
|
31
|
+
currentPageNumber - siblingCountNumber,
|
|
32
|
+
1
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const shouldShowLeftDots = leftSiblingIndex > 2;
|
|
36
|
+
const shouldShowRightDots = rightSiblingIndex < totalPageCount - 2;
|
|
37
|
+
const firstPageIndex = 1;
|
|
38
|
+
const lastPageIndex = totalPageCount;
|
|
39
|
+
if (!shouldShowLeftDots && shouldShowRightDots) {
|
|
40
|
+
let leftItemCount =
|
|
41
|
+
currentPageNumber === 4 && lastPageIndex > 7
|
|
42
|
+
? 4 + siblingCountNumber
|
|
43
|
+
: 3 + siblingCountNumber;
|
|
44
|
+
|
|
45
|
+
let leftRange = range(1, leftItemCount);
|
|
46
|
+
|
|
47
|
+
return [...leftRange, Dots, totalPageCount];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (shouldShowLeftDots && !shouldShowRightDots) {
|
|
51
|
+
let rightItemCount =
|
|
52
|
+
currentPageNumber === lastPageIndex - 3 && lastPageIndex > 7
|
|
53
|
+
? (rightItemCount = 4 + siblingCountNumber)
|
|
54
|
+
: (rightItemCount = 3 + siblingCountNumber);
|
|
55
|
+
|
|
56
|
+
let rightRange = range(
|
|
57
|
+
totalPageCount - rightItemCount + 1,
|
|
58
|
+
totalPageCount
|
|
59
|
+
);
|
|
60
|
+
return [firstPageIndex, Dots, ...rightRange];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (shouldShowLeftDots && shouldShowRightDots) {
|
|
64
|
+
let middleRange = range(leftSiblingIndex, rightSiblingIndex);
|
|
65
|
+
return [firstPageIndex, Dots, ...middleRange, Dots, lastPageIndex];
|
|
66
|
+
}
|
|
67
|
+
}, [currentTotalCount, offset, siblingCountNumber, currentPageNumber]);
|
|
68
|
+
|
|
69
|
+
return paginationRange;
|
|
70
|
+
};
|