diginet-core-ui 1.3.94-beta.4 → 1.3.94-beta.6
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/assets/images/menu/eo/WEO76APP0001.svg +15 -0
- package/assets/images/menu/eo/WEO76APP0002.svg +15 -0
- package/assets/images/menu/eo/WEO76LIS0001.svg +10 -0
- package/assets/images/menu/eo/WEO76LIS0002.svg +11 -0
- package/assets/images/menu/eo/WEO76LIS0003.svg +3 -0
- package/assets/images/menu/eo/WEO76REQ0001.svg +14 -0
- package/assets/images/menu/eo/WEO76REQ0002.svg +14 -0
- package/components/button/icon.js +21 -21
- package/components/button/index.js +13 -13
- package/components/button/more.js +5 -19
- package/components/index.js +1 -1
- package/components/paging/page-info.js +3 -3
- package/components/paging/page-selector.js +354 -226
- package/components/popover/index.js +11 -0
- package/components/typography/index.js +10 -10
- package/icons/effect.js +13 -13
- package/icons/menu/v2/index.js +1 -1
- package/package.json +1 -1
- package/styles/general.js +4 -1
- package/utils/storybook/index.js +1 -0
- package/utils/storybook/refArgTypes.js +17 -0
- package/components/paging/page-selector2.js +0 -384
|
@@ -1,254 +1,382 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
/** @jsx jsx */
|
|
3
|
-
import
|
|
3
|
+
import { css, jsx } from '@emotion/core';
|
|
4
|
+
import { ButtonIcon } from "./..";
|
|
5
|
+
import OptionWrapper from "../others/option-wrapper";
|
|
6
|
+
import { getGlobal } from "../../global";
|
|
4
7
|
import PropTypes from 'prop-types';
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import { typography } from "../../styles/typography";
|
|
8
|
+
import { forwardRef, memo, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
9
|
+
import { bgColor, borderTop, boxBorder, displayFlex, flexRow, itemsCenter, parseWidthHeight, pd } from "../../styles/general";
|
|
8
10
|
import { useTheme } from "../../theme";
|
|
11
|
+
import { useElementSize } from "../../utils";
|
|
9
12
|
const {
|
|
10
|
-
|
|
13
|
+
typography: {
|
|
14
|
+
paragraph2
|
|
15
|
+
}
|
|
11
16
|
} = useTheme();
|
|
17
|
+
const getLastPage = (totalItems, itemsPerPage) => {
|
|
18
|
+
let _lastPage = 0;
|
|
19
|
+
if (totalItems && totalItems >= 0 && itemsPerPage && itemsPerPage > 0) {
|
|
20
|
+
_lastPage = Math.ceil(totalItems / itemsPerPage);
|
|
21
|
+
return _lastPage;
|
|
22
|
+
}
|
|
23
|
+
return _lastPage + 1;
|
|
24
|
+
};
|
|
25
|
+
const delayOnInput = getGlobal('delayOnInput');
|
|
12
26
|
const PagingSelector = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
27
|
+
action = {},
|
|
28
|
+
className,
|
|
29
|
+
currentPage,
|
|
30
|
+
hideEllipsis,
|
|
31
|
+
hideWithPage,
|
|
32
|
+
id,
|
|
33
|
+
itemsPerPage,
|
|
19
34
|
onChangePage,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
&::-webkit-scrollbar-thumb {
|
|
51
|
-
border-radius: 10px;
|
|
52
|
-
background-color: #c1c1c1;
|
|
53
|
-
}
|
|
54
|
-
`;
|
|
55
|
-
const PageItem = css`
|
|
56
|
-
width: ${size === 'small' ? 20 : 24}px;
|
|
57
|
-
height: ${size === 'small' ? 20 : 24}px;
|
|
58
|
-
font-size: ${size === 'small' ? 12 : 14}px;
|
|
59
|
-
background-color: ${theme.colors.system.rest};
|
|
60
|
-
border-radius: 50%;
|
|
61
|
-
text-align: center;
|
|
62
|
-
display: flex;
|
|
63
|
-
justify-content: center;
|
|
64
|
-
align-items: center;
|
|
65
|
-
margin: 0px 4px;
|
|
66
|
-
user-select: none;
|
|
67
|
-
cursor: pointer;
|
|
68
|
-
position: relative;
|
|
69
|
-
&:hover {
|
|
70
|
-
background-color: ${theme.colors.fill.hover};
|
|
71
|
-
&:not(.active) .css-${PageItemNum.name} {
|
|
72
|
-
color: ${theme.colors.system.active};
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
&.active {
|
|
76
|
-
background-color: ${theme.colors.brand};
|
|
77
|
-
}
|
|
78
|
-
`;
|
|
79
|
-
const setPagination = (newCurrentPage = 1) => {
|
|
80
|
-
const newLastPage = Math.ceil(totalItems / itemsPerPage);
|
|
81
|
-
if (newCurrentPage > newLastPage || newCurrentPage < 0) {
|
|
82
|
-
newCurrentPage = 1;
|
|
35
|
+
onChangePerPage,
|
|
36
|
+
onChangingPage,
|
|
37
|
+
onChangingPerPage,
|
|
38
|
+
style,
|
|
39
|
+
totalItems
|
|
40
|
+
}, reference) => {
|
|
41
|
+
const ref = useRef(null);
|
|
42
|
+
const timer = useRef(null);
|
|
43
|
+
const currentPageRef = useRef(currentPage);
|
|
44
|
+
const [totalItemsState, setTotalItemsState] = useState(totalItems);
|
|
45
|
+
const [itemsPerPageState, setItemsPerPageState] = useState(itemsPerPage || 10);
|
|
46
|
+
const [currentPageState, setCurrentPageState] = useState(currentPage);
|
|
47
|
+
const [disablePrevState, setDisablePrevState] = useState(true);
|
|
48
|
+
const [disableNextState, setDisableNextState] = useState(!(totalItems > itemsPerPage));
|
|
49
|
+
const [refSize, {
|
|
50
|
+
width: componentWidth
|
|
51
|
+
}] = useElementSize();
|
|
52
|
+
const lastPage = getLastPage(totalItemsState, itemsPerPageState);
|
|
53
|
+
const _onChangePage = async ({
|
|
54
|
+
page,
|
|
55
|
+
e,
|
|
56
|
+
changeBy
|
|
57
|
+
}) => {
|
|
58
|
+
let disablePrev = false;
|
|
59
|
+
let disableNext = false;
|
|
60
|
+
|
|
61
|
+
// If last page = 1. Disable all
|
|
62
|
+
if (lastPage === 1) {
|
|
63
|
+
disablePrev = true;
|
|
64
|
+
disableNext = true;
|
|
83
65
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (newCurrentPage < 4) {
|
|
89
|
-
newPaging.push(...[2, 3]);
|
|
90
|
-
let morePageRight = [];
|
|
91
|
-
if (newCurrentPage === 3) {
|
|
92
|
-
newPaging.push(4);
|
|
93
|
-
for (let r = newCurrentPage + 2; r < newLastPage; r++) {
|
|
94
|
-
morePageRight.push(r);
|
|
95
|
-
}
|
|
96
|
-
} else {
|
|
97
|
-
for (let r = 4; r < newLastPage; r++) {
|
|
98
|
-
morePageRight.push(r);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
if (morePageRight.length === 1) {
|
|
102
|
-
morePageRight = morePageRight[0];
|
|
103
|
-
}
|
|
104
|
-
newPaging.push(...[morePageRight, newLastPage]);
|
|
105
|
-
} else if (newCurrentPage > newLastPage - 3) {
|
|
106
|
-
let morePageLeft = [];
|
|
107
|
-
if (newCurrentPage - 2 === 2) {
|
|
108
|
-
morePageLeft = 2;
|
|
109
|
-
} else {
|
|
110
|
-
for (let l = 2; l < newCurrentPage - 1 - (newCurrentPage - newLastPage + 1); l++) {
|
|
111
|
-
morePageLeft.push(l);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
newPaging.push(morePageLeft);
|
|
115
|
-
if (newCurrentPage === newLastPage - 2) {
|
|
116
|
-
newPaging.push(newLastPage - 3);
|
|
117
|
-
}
|
|
118
|
-
newPaging.push(...[newLastPage - 2, newLastPage - 1, newLastPage]);
|
|
119
|
-
} else {
|
|
120
|
-
let morePageLeft = [],
|
|
121
|
-
morePageRight = [];
|
|
122
|
-
if (newCurrentPage - 2 === 2) {
|
|
123
|
-
morePageLeft = 2;
|
|
124
|
-
} else {
|
|
125
|
-
for (let l = 2; l < newCurrentPage - 1; l++) {
|
|
126
|
-
morePageLeft.push(l);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
if (newLastPage - 1 === newCurrentPage + 2) {
|
|
130
|
-
morePageRight = newCurrentPage + 2;
|
|
131
|
-
} else {
|
|
132
|
-
for (let r = newCurrentPage + 2; r < newLastPage; r++) {
|
|
133
|
-
morePageRight.push(r);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
newPaging.push(...[morePageLeft, newCurrentPage - 1, newCurrentPage, newCurrentPage + 1, morePageRight, newLastPage]);
|
|
137
|
-
}
|
|
138
|
-
} else {
|
|
139
|
-
for (let i = 2; i <= newLastPage; i++) {
|
|
140
|
-
newPaging.push(i);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
return newPaging;
|
|
144
|
-
} else if (paging.length !== 1) {
|
|
145
|
-
return [1];
|
|
66
|
+
|
|
67
|
+
// If current page = last page. Disable Next and Last
|
|
68
|
+
if (page + 1 >= lastPage) {
|
|
69
|
+
disableNext = true;
|
|
146
70
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
if (
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
71
|
+
|
|
72
|
+
// If current page = 0. Disable Previous and First
|
|
73
|
+
if (page === 0) {
|
|
74
|
+
disablePrev = true;
|
|
75
|
+
}
|
|
76
|
+
setDisablePrevState(disablePrev);
|
|
77
|
+
setDisableNextState(disableNext);
|
|
78
|
+
if (page === currentPageState) return;
|
|
79
|
+
if (onChangingPage) {
|
|
80
|
+
const event = {
|
|
81
|
+
...e,
|
|
82
|
+
cancel: false,
|
|
83
|
+
prevPage: currentPageState,
|
|
84
|
+
newPage: page,
|
|
85
|
+
changeBy: changeBy
|
|
86
|
+
};
|
|
87
|
+
await onChangingPage(event);
|
|
88
|
+
if (event.cancel) {
|
|
89
|
+
if (e !== null && e !== void 0 && e.reset) e.reset();
|
|
90
|
+
currentPageRef.current = currentPageState;
|
|
91
|
+
setCurrentPageState(currentPageState);
|
|
92
|
+
return;
|
|
162
93
|
}
|
|
163
94
|
}
|
|
95
|
+
currentPageRef.current = page;
|
|
96
|
+
setCurrentPageState(page);
|
|
97
|
+
if (onChangePage) onChangePage(page);
|
|
164
98
|
};
|
|
165
|
-
const
|
|
166
|
-
if (
|
|
167
|
-
|
|
168
|
-
|
|
99
|
+
const _onChangePerPage = async per => {
|
|
100
|
+
if (per === itemsPerPageState) return;
|
|
101
|
+
const lastPage = getLastPage(totalItemsState, per);
|
|
102
|
+
per = parseInt(per, 10);
|
|
103
|
+
let disableNext = false;
|
|
104
|
+
|
|
105
|
+
// If last page = 1. Disable all
|
|
106
|
+
if (lastPage === 1) {
|
|
107
|
+
disableNext = true;
|
|
108
|
+
}
|
|
109
|
+
if (onChangingPerPage) {
|
|
110
|
+
const event = {
|
|
111
|
+
cancel: false,
|
|
112
|
+
prevPerPage: itemsPerPageState,
|
|
113
|
+
newPerPage: per
|
|
114
|
+
};
|
|
115
|
+
await onChangingPerPage(event);
|
|
116
|
+
if (event.cancel) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
169
119
|
}
|
|
120
|
+
setItemsPerPageState(per);
|
|
121
|
+
// currentPageRef.current = 0;
|
|
122
|
+
// setCurrentPageState(0);
|
|
123
|
+
_onChangePage({
|
|
124
|
+
page: 0
|
|
125
|
+
});
|
|
126
|
+
setDisablePrevState(true);
|
|
127
|
+
setDisableNextState(disableNext);
|
|
128
|
+
if (onChangePerPage) onChangePerPage(per);
|
|
170
129
|
};
|
|
171
|
-
|
|
172
|
-
// Get totalItems, itemsPerPage to set last page
|
|
173
130
|
useEffect(() => {
|
|
174
|
-
|
|
175
|
-
}, [
|
|
131
|
+
setTotalItemsState(totalItems);
|
|
132
|
+
}, [totalItems]);
|
|
176
133
|
useEffect(() => {
|
|
177
|
-
|
|
178
|
-
}, [
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
134
|
+
_onChangePerPage(itemsPerPage);
|
|
135
|
+
}, [itemsPerPage]);
|
|
136
|
+
useEffect(() => {
|
|
137
|
+
_onChangePage({
|
|
138
|
+
page: currentPage,
|
|
139
|
+
changeBy: 'currentPage'
|
|
140
|
+
});
|
|
141
|
+
}, [currentPage]);
|
|
142
|
+
useEffect(() => {
|
|
143
|
+
_onChangePage({
|
|
144
|
+
page: totalItemsState / itemsPerPageState < currentPageState - 1 ? 0 : currentPageState,
|
|
145
|
+
changeBy: 'totalItems'
|
|
146
|
+
});
|
|
147
|
+
}, [totalItemsState]);
|
|
148
|
+
useEffect(() => {
|
|
149
|
+
_onChangePage({
|
|
150
|
+
page: totalItemsState / itemsPerPageState < currentPageState - 1 ? 0 : currentPageState,
|
|
151
|
+
changeBy: 'itemsPerPage'
|
|
152
|
+
});
|
|
153
|
+
}, [itemsPerPageState]);
|
|
154
|
+
useImperativeHandle(reference, () => {
|
|
155
|
+
const currentRef = ref.current || {};
|
|
156
|
+
currentRef.element = ref.current;
|
|
157
|
+
const _instance = {
|
|
158
|
+
onChangePage: page => _onChangePage({
|
|
159
|
+
page: page,
|
|
160
|
+
changeBy: 'ref'
|
|
161
|
+
}),
|
|
162
|
+
onChangePerPage: per => _onChangePerPage(per),
|
|
163
|
+
setTotalItems: items => setTotalItemsState(items),
|
|
164
|
+
...action
|
|
165
|
+
}; // methods
|
|
166
|
+
_instance.__proto__ = {}; // hidden methods
|
|
167
|
+
currentRef.instance = _instance;
|
|
168
|
+
currentRef.onChangePage = page => _onChangePage({
|
|
169
|
+
page: page,
|
|
170
|
+
changeBy: 'ref'
|
|
171
|
+
});
|
|
172
|
+
currentRef.onChangePerPage = per => _onChangePerPage(per);
|
|
173
|
+
currentRef.setTotalItems = items => setTotalItemsState(items);
|
|
174
|
+
return currentRef;
|
|
175
|
+
});
|
|
176
|
+
const renderButton = (key, page, isSelected, customDisplay) => {
|
|
177
|
+
if (page >= lastPage || page < 0) return;
|
|
178
|
+
return jsx(ButtonIcon, {
|
|
179
|
+
key: key,
|
|
180
|
+
css: paragraph2,
|
|
181
|
+
circular: true,
|
|
182
|
+
viewType: isSelected ? 'filled' : 'text',
|
|
183
|
+
size: 'small',
|
|
184
|
+
color: 'primary',
|
|
206
185
|
style: {
|
|
207
|
-
|
|
208
|
-
height: 18,
|
|
209
|
-
minWidth: 18,
|
|
210
|
-
minHeight: 18,
|
|
211
|
-
fontSize: 8,
|
|
212
|
-
margin: '0px 2px'
|
|
186
|
+
fontWeight: 'normal'
|
|
213
187
|
},
|
|
214
|
-
onClick: e =>
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
188
|
+
onClick: e => page !== currentPageState && _onChangePage({
|
|
189
|
+
page: page,
|
|
190
|
+
e: e
|
|
191
|
+
})
|
|
192
|
+
}, customDisplay || page + 1);
|
|
193
|
+
};
|
|
194
|
+
const checkShowSelector = () => {
|
|
195
|
+
switch (hideWithPage) {
|
|
196
|
+
case 'empty':
|
|
197
|
+
return totalItemsState !== 0;
|
|
198
|
+
case 'single':
|
|
199
|
+
return totalItemsState / itemsPerPageState > 1;
|
|
200
|
+
case 'none':
|
|
201
|
+
default:
|
|
202
|
+
return true;
|
|
225
203
|
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
204
|
+
};
|
|
205
|
+
return useMemo(() => {
|
|
206
|
+
const count = componentWidth >= 368 ? 10 : componentWidth >= 208 ? 5 : 1;
|
|
207
|
+
const pageArr = [...Array(count).keys()];
|
|
208
|
+
const halfArrLength = Math.floor(count / 2);
|
|
209
|
+
const quarterArrLength = Math.floor(count / 2.5);
|
|
210
|
+
const showEllipsis = !hideEllipsis && count !== lastPage && count >= 5;
|
|
211
|
+
const showSelector = checkShowSelector();
|
|
212
|
+
return showSelector && jsx("div", {
|
|
213
|
+
css: PageSelectorCSS,
|
|
214
|
+
ref: node => {
|
|
215
|
+
ref.current = node;
|
|
216
|
+
refSize(node);
|
|
217
|
+
},
|
|
218
|
+
id: id,
|
|
219
|
+
style: style,
|
|
220
|
+
className: ['DGN-UI-PagingSelector', className].join(' ').trim().replace(/\s+/g, ' ')
|
|
221
|
+
}, jsx(ButtonIcon, {
|
|
222
|
+
circular: true,
|
|
223
|
+
viewType: 'text',
|
|
224
|
+
size: 'small',
|
|
225
|
+
name: 'ArrowLeft',
|
|
226
|
+
disabled: disablePrevState,
|
|
227
|
+
onClick: e => {
|
|
228
|
+
currentPageRef.current = currentPageRef.current === 0 ? 0 : currentPageRef.current - 1;
|
|
229
|
+
if (timer.current) {
|
|
230
|
+
clearTimeout(timer.current);
|
|
231
|
+
}
|
|
232
|
+
timer.current = setTimeout(() => {
|
|
233
|
+
_onChangePage({
|
|
234
|
+
page: currentPageRef.current,
|
|
235
|
+
e: e
|
|
236
|
+
});
|
|
237
|
+
}, delayOnInput);
|
|
238
|
+
}
|
|
239
|
+
}), pageArr.map((_, idx) => {
|
|
240
|
+
if (currentPageState < halfArrLength) {
|
|
241
|
+
// các trang đầu
|
|
242
|
+
if (showEllipsis) {
|
|
243
|
+
if (idx === count - 1 && lastPage - 1 >= 10) {
|
|
244
|
+
return renderButton(idx, lastPage - 1);
|
|
245
|
+
} else {
|
|
246
|
+
return renderButton(idx, idx, idx === currentPageState, idx === count - 2 && '...');
|
|
247
|
+
}
|
|
248
|
+
} else return renderButton(idx, idx, idx === currentPageState);
|
|
249
|
+
} else if (currentPageState >= lastPage - halfArrLength) {
|
|
250
|
+
// các trang cuối
|
|
251
|
+
if (showEllipsis) {
|
|
252
|
+
if (idx === 0) {
|
|
253
|
+
return renderButton(idx, idx);
|
|
254
|
+
} else {
|
|
255
|
+
return renderButton(idx, lastPage - count + idx, lastPage - count + idx === currentPageState, idx === 1 && '...');
|
|
256
|
+
}
|
|
257
|
+
} else {
|
|
258
|
+
return renderButton(idx, lastPage - count + idx, lastPage - count + idx === currentPageState);
|
|
259
|
+
}
|
|
260
|
+
} else {
|
|
261
|
+
// các trang giữa
|
|
262
|
+
if (idx < quarterArrLength) {
|
|
263
|
+
if (showEllipsis) {
|
|
264
|
+
if (idx === 0) {
|
|
265
|
+
return renderButton(idx, idx);
|
|
266
|
+
} else {
|
|
267
|
+
return renderButton(idx, currentPageState - quarterArrLength + idx, false, idx === 1 && '...');
|
|
268
|
+
}
|
|
269
|
+
} else return renderButton(idx, currentPageState - quarterArrLength + idx);
|
|
270
|
+
} else if (idx === quarterArrLength) {
|
|
271
|
+
return renderButton(idx, currentPageState, true);
|
|
272
|
+
} else {
|
|
273
|
+
if (showEllipsis) {
|
|
274
|
+
if (idx === count - 1) {
|
|
275
|
+
return renderButton(idx, lastPage - 1);
|
|
276
|
+
} else {
|
|
277
|
+
return renderButton(idx, currentPageState - quarterArrLength + idx, false, idx === count - 2 && '...');
|
|
278
|
+
}
|
|
279
|
+
} else return renderButton(idx, currentPageState - quarterArrLength + idx);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}), jsx(ButtonIcon, {
|
|
283
|
+
circular: true,
|
|
284
|
+
viewType: 'text',
|
|
285
|
+
size: 'small',
|
|
286
|
+
name: 'ArrowRight',
|
|
287
|
+
disabled: disableNextState,
|
|
288
|
+
onClick: e => {
|
|
289
|
+
currentPageRef.current = currentPageRef.current === lastPage ? lastPage : currentPageRef.current + 1;
|
|
290
|
+
if (timer.current) {
|
|
291
|
+
clearTimeout(timer.current);
|
|
292
|
+
}
|
|
293
|
+
timer.current = setTimeout(() => {
|
|
294
|
+
_onChangePage({
|
|
295
|
+
page: currentPageRef.current,
|
|
296
|
+
e: e
|
|
297
|
+
});
|
|
298
|
+
}, delayOnInput);
|
|
299
|
+
}
|
|
300
|
+
}));
|
|
301
|
+
}, [className, hideEllipsis, hideWithPage, id, style, componentWidth, currentPageState, disableNextState, disablePrevState, itemsPerPageState, totalItemsState]);
|
|
231
302
|
}));
|
|
303
|
+
const PageSelectorCSS = css`
|
|
304
|
+
${displayFlex};
|
|
305
|
+
${flexRow};
|
|
306
|
+
${itemsCenter};
|
|
307
|
+
${boxBorder};
|
|
308
|
+
${parseWidthHeight('100%', 40)};
|
|
309
|
+
${pd([1])};
|
|
310
|
+
${bgColor('system/white')};
|
|
311
|
+
${borderTop(1, 'line/system')};
|
|
312
|
+
`;
|
|
232
313
|
PagingSelector.defaultProps = {
|
|
233
|
-
|
|
234
|
-
currentPage:
|
|
235
|
-
|
|
236
|
-
|
|
314
|
+
className: '',
|
|
315
|
+
currentPage: 0,
|
|
316
|
+
hideEllipsis: false,
|
|
317
|
+
hideWithPage: 'none',
|
|
318
|
+
style: {},
|
|
319
|
+
totalItems: 0
|
|
237
320
|
};
|
|
238
321
|
PagingSelector.propTypes = {
|
|
239
|
-
/**
|
|
240
|
-
|
|
241
|
-
/** current
|
|
322
|
+
/** Class for component. */
|
|
323
|
+
className: PropTypes.string,
|
|
324
|
+
/** Specifies the current page. */
|
|
242
325
|
currentPage: PropTypes.number,
|
|
243
|
-
/**
|
|
244
|
-
|
|
245
|
-
/**
|
|
326
|
+
/** If `true`, hide ellipsis. */
|
|
327
|
+
hideEllipsis: PropTypes.bool,
|
|
328
|
+
/** Hidden mode for page selector. */
|
|
329
|
+
hideWithPage: PropTypes.oneOf(['none', 'empty', 'single']),
|
|
330
|
+
/** The quantity of items per page. */
|
|
246
331
|
itemsPerPage: PropTypes.number,
|
|
247
|
-
/**
|
|
332
|
+
/** Callback fired when page number changed. */
|
|
333
|
+
onChangePage: PropTypes.func,
|
|
334
|
+
/** Callback fired when quantity on per page changed. */
|
|
335
|
+
onChangePerPage: PropTypes.func,
|
|
336
|
+
/**
|
|
337
|
+
* Callback fired when page number is changing.
|
|
338
|
+
*
|
|
339
|
+
* * prevPage: Page before changed
|
|
340
|
+
* * newPage: Page after changed
|
|
341
|
+
* * cancel(value): Function cancel change page
|
|
342
|
+
* * @param {value} - bool
|
|
343
|
+
*/
|
|
344
|
+
onChangingPage: PropTypes.func,
|
|
345
|
+
/**
|
|
346
|
+
* Callback fired when quantity on item per page is changing.
|
|
347
|
+
*
|
|
348
|
+
* * prevPerPage: Items per page before changed
|
|
349
|
+
* * newPerPage: Items per page after changed
|
|
350
|
+
* * cancel(value): Function cancel change items per page
|
|
351
|
+
* * @param {value} - bool
|
|
352
|
+
*/
|
|
353
|
+
onChangingPerPage: PropTypes.func,
|
|
354
|
+
/** Style inline of component. */
|
|
248
355
|
style: PropTypes.object,
|
|
249
|
-
/**
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
|
|
356
|
+
/** Total items. */
|
|
357
|
+
totalItems: PropTypes.number
|
|
358
|
+
/**
|
|
359
|
+
* ref methods (ref.current.instance.*method*)
|
|
360
|
+
*
|
|
361
|
+
* * onChangePage(page): Change page number
|
|
362
|
+
* * @param {page} - number
|
|
363
|
+
* * onChangePerPage(per): Change quantity on per page
|
|
364
|
+
* * @param {per} - number
|
|
365
|
+
* * setTotalItems(items): Set total items
|
|
366
|
+
* * @param {items} - number
|
|
367
|
+
*
|
|
368
|
+
* * option(): Gets all UI component properties
|
|
369
|
+
* * Returns value - object
|
|
370
|
+
* * option(optionName): Gets the value of a single property
|
|
371
|
+
* * @param {optionName} - string
|
|
372
|
+
* * Returns value - any
|
|
373
|
+
* * option(optionName, optionValue): Updates the value of a single property
|
|
374
|
+
* * @param {optionName} - string
|
|
375
|
+
* * @param {optionValue} - any
|
|
376
|
+
* * option(options): Updates the values of several properties
|
|
377
|
+
* * @param {options} - object
|
|
378
|
+
*/
|
|
253
379
|
};
|
|
254
|
-
|
|
380
|
+
|
|
381
|
+
export { PagingSelector };
|
|
382
|
+
export default OptionWrapper(PagingSelector);
|
|
@@ -619,6 +619,17 @@ Popover.propTypes = {
|
|
|
619
619
|
* * close: Close popover
|
|
620
620
|
* * setPosition(element): Set position of popover
|
|
621
621
|
* * @param {element} - element
|
|
622
|
+
*
|
|
623
|
+
* * option(): Gets all UI component properties
|
|
624
|
+
* * Returns value - object
|
|
625
|
+
* * option(optionName): Gets the value of a single property
|
|
626
|
+
* * @param {optionName} - string
|
|
627
|
+
* * Returns value - any
|
|
628
|
+
* * option(optionName, optionValue): Updates the value of a single property
|
|
629
|
+
* * @param {optionName} - string
|
|
630
|
+
* * @param {optionValue} - any
|
|
631
|
+
* * option(options): Updates the values of several properties
|
|
632
|
+
* * @param {options} - object
|
|
622
633
|
*/
|
|
623
634
|
ref: ref
|
|
624
635
|
};
|
|
@@ -143,16 +143,16 @@ Typography.defaultProps = {
|
|
|
143
143
|
type: 'p1'
|
|
144
144
|
};
|
|
145
145
|
|
|
146
|
-
/** type of text<br/>
|
|
147
|
-
* h1: Title <br/>
|
|
148
|
-
* h2: Header Popup <br/>
|
|
149
|
-
* h3: Header popup <br/>
|
|
150
|
-
* h4: Button, Tab, Title group <br/>
|
|
151
|
-
* h5: Label column, Title group <br/>
|
|
152
|
-
* h6: Label form <br/>
|
|
153
|
-
* p1: Body text <br/>
|
|
154
|
-
* p2: Body text <br/>
|
|
155
|
-
* p3: Notice, Tooltip <br/>
|
|
146
|
+
/** type of text<br/>
|
|
147
|
+
* h1: Title <br/>
|
|
148
|
+
* h2: Header Popup <br/>
|
|
149
|
+
* h3: Header popup <br/>
|
|
150
|
+
* h4: Button, Tab, Title group <br/>
|
|
151
|
+
* h5: Label column, Title group <br/>
|
|
152
|
+
* h6: Label form <br/>
|
|
153
|
+
* p1: Body text <br/>
|
|
154
|
+
* p2: Body text <br/>
|
|
155
|
+
* p3: Notice, Tooltip <br/>
|
|
156
156
|
*/
|
|
157
157
|
export const arrTypeTypography = ['t1', 't2', 't3', 't4', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p1', 'p2', 'p3', 'title1', 'title2', 'title3', 'title4', 'heading1', 'heading2', 'heading3', 'heading4', 'heading5', 'heading6', 'paragraph1', 'paragraph2', 'paragraph3'];
|
|
158
158
|
Typography.propTypes = {
|