diginet-core-ui 1.3.67 → 1.3.68
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/components/avatar/index.js +19 -19
- package/components/badge/index.js +5 -5
- package/components/button/icon.js +21 -21
- package/components/button/index.js +13 -13
- package/components/form-control/attachment/index.js +21 -21
- package/components/form-control/calendar/function.js +113 -113
- package/components/form-control/input-base/index.js +47 -10
- package/components/form-control/money-input/index.js +6 -2
- package/components/form-control/number-input/index2.js +13 -4
- package/components/form-control/phone-input/index.js +6 -2
- package/components/form-control/text-input/index.js +13 -3
- package/components/paging/page-info.js +285 -101
- package/components/paging/page-selector2.js +95 -56
- package/components/popover/index.js +21 -21
- package/icons/effect.js +15 -15
- package/package.json +1 -1
- package/readme.md +6 -0
- package/styles/utils.js +10 -10
- package/utils/classNames.js +30 -0
- package/utils/index.js +1 -0
- package/utils/useInput.js +1 -8
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
|
-
import { memo, useState, useRef, useEffect, useMemo, forwardRef, useImperativeHandle } from 'react';
|
|
4
|
+
import { memo, useState, useRef, useEffect, useMemo, forwardRef, useImperativeHandle, useLayoutEffect, useCallback } from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { jsx, css } from '@emotion/core';
|
|
7
7
|
import OptionWrapper from '../others/option-wrapper';
|
|
8
8
|
import { ButtonIcon, NumberInput, Dropdown, Typography, Divider } from '../';
|
|
9
9
|
import { getGlobal } from '../../global';
|
|
10
10
|
import theme from '../../theme/settings';
|
|
11
|
-
import { alignCenter, borderBox, flexRow,
|
|
11
|
+
import { alignCenter, borderBox, flexRow, noPadding, textCenter, cursorPointer, parseHeight, whiteSpaceNoWrap, justifyCenter } from '../../styles/general';
|
|
12
12
|
const {
|
|
13
13
|
colors: {
|
|
14
14
|
system: {
|
|
@@ -42,37 +42,42 @@ const getLastPage = (totalItems, itemsPerPage) => {
|
|
|
42
42
|
|
|
43
43
|
const delayOnInput = getGlobal('delayOnInput');
|
|
44
44
|
const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
45
|
-
id,
|
|
46
|
-
typeShort,
|
|
47
45
|
bgColor,
|
|
48
|
-
style,
|
|
49
46
|
className,
|
|
50
|
-
totalItems,
|
|
51
|
-
itemsPerPage,
|
|
52
47
|
currentPage,
|
|
48
|
+
hideWithPage,
|
|
49
|
+
id,
|
|
50
|
+
itemsPerPage,
|
|
53
51
|
listPerPage,
|
|
54
52
|
onChangePage,
|
|
55
53
|
onChangePerPage,
|
|
56
54
|
onChangingPage,
|
|
57
|
-
onChangingPerPage
|
|
55
|
+
onChangingPerPage,
|
|
56
|
+
style,
|
|
57
|
+
totalItems,
|
|
58
|
+
typeShort
|
|
58
59
|
}, reference) => {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const ref = useRef(null);
|
|
60
|
+
let ref = useRef(null);
|
|
62
61
|
const timer = useRef(null);
|
|
63
62
|
const currentPageRef = useRef(null);
|
|
63
|
+
const numberRef = useRef(null);
|
|
64
|
+
const totalRef = useRef(null);
|
|
64
65
|
const [totalItemsState, setTotalItemsState] = useState(totalItems);
|
|
65
66
|
const [itemsPerPageState, setItemsPerPageState] = useState(itemsPerPage || listPerPage[0] || 10);
|
|
66
67
|
const [currentPageState, setCurrentPageState] = useState(currentPage);
|
|
67
68
|
const [listPerPageState, setListPerPageState] = useState(listPerPage);
|
|
68
69
|
const [disablePrevState, setDisablePrevState] = useState(true);
|
|
69
70
|
const [disableNextState, setDisableNextState] = useState(!(totalItems > itemsPerPage));
|
|
71
|
+
const [inputPageValue, setInputPageValue] = useState(currentPage);
|
|
70
72
|
|
|
71
|
-
const _pagingInfoCSS = pagingInfoCSS(bgColor, typeShort);
|
|
73
|
+
const _pagingInfoCSS = pagingInfoCSS(bgColor, typeShort); // const _dynamicWidthCSS = dynamicWidthCSS(currentPageState.toString()?.length || 3);
|
|
72
74
|
|
|
73
|
-
const _dynamicWidthCSS = dynamicWidthCSS(((_currentPageState$toS = currentPageState.toString()) === null || _currentPageState$toS === void 0 ? void 0 : _currentPageState$toS.length) || 3);
|
|
74
75
|
|
|
75
|
-
const _onChangePage = async (
|
|
76
|
+
const _onChangePage = async ({
|
|
77
|
+
page,
|
|
78
|
+
e,
|
|
79
|
+
changeBy
|
|
80
|
+
}) => {
|
|
76
81
|
const lastPage = getLastPage(totalItemsState, itemsPerPageState);
|
|
77
82
|
let disablePrev = false;
|
|
78
83
|
let disableNext = false; // If last page = 1. Disable all
|
|
@@ -92,29 +97,36 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
92
97
|
disablePrev = true;
|
|
93
98
|
}
|
|
94
99
|
|
|
95
|
-
|
|
100
|
+
setDisablePrevState(disablePrev);
|
|
101
|
+
setDisableNextState(disableNext);
|
|
102
|
+
if (page === currentPageState) return;
|
|
103
|
+
|
|
104
|
+
if (onChangingPage) {
|
|
96
105
|
const event = { ...e,
|
|
97
106
|
cancel: false,
|
|
98
107
|
prevPage: currentPageState,
|
|
99
|
-
newPage: page
|
|
108
|
+
newPage: page,
|
|
109
|
+
changeBy: changeBy
|
|
100
110
|
};
|
|
101
111
|
await onChangingPage(event);
|
|
102
112
|
|
|
103
113
|
if (event.cancel) {
|
|
104
114
|
if (e !== null && e !== void 0 && e.reset) e.reset();
|
|
115
|
+
currentPageRef.current = currentPageState;
|
|
105
116
|
setCurrentPageState(currentPageState);
|
|
117
|
+
setInputPageValue(currentPageState);
|
|
106
118
|
return;
|
|
107
119
|
}
|
|
108
120
|
}
|
|
109
121
|
|
|
110
122
|
currentPageRef.current = page;
|
|
111
123
|
setCurrentPageState(page);
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
if (onChangePage && !isInit) onChangePage(page);
|
|
124
|
+
setInputPageValue(page);
|
|
125
|
+
if (onChangePage) onChangePage(page);
|
|
115
126
|
};
|
|
116
127
|
|
|
117
128
|
const _onChangePerPage = async per => {
|
|
129
|
+
if (per === itemsPerPageState) return;
|
|
118
130
|
const lastPage = getLastPage(totalItemsState, per);
|
|
119
131
|
per = parseInt(per, 10);
|
|
120
132
|
let disableNext = false; // If last page = 1. Disable all
|
|
@@ -136,14 +148,20 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
136
148
|
}
|
|
137
149
|
}
|
|
138
150
|
|
|
139
|
-
currentPageRef.current = 0;
|
|
140
|
-
|
|
151
|
+
setItemsPerPageState(per); // currentPageRef.current = 0;
|
|
152
|
+
// setCurrentPageState(0);
|
|
153
|
+
// setInputPageValue(0);
|
|
154
|
+
|
|
155
|
+
_onChangePage({
|
|
156
|
+
page: 0
|
|
157
|
+
});
|
|
158
|
+
|
|
141
159
|
setDisablePrevState(true);
|
|
142
160
|
setDisableNextState(disableNext);
|
|
143
161
|
if (onChangePerPage) onChangePerPage(per);
|
|
144
162
|
};
|
|
145
163
|
|
|
146
|
-
const onTypePaging =
|
|
164
|
+
const onTypePaging = e => {
|
|
147
165
|
var _e$value;
|
|
148
166
|
|
|
149
167
|
if (timer.current) {
|
|
@@ -155,7 +173,10 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
155
173
|
const page = !value || parseInt(value) < 0 ? 1 : parseInt(value) > lastPage ? lastPage : parseInt(value);
|
|
156
174
|
currentPage = page - 1;
|
|
157
175
|
timer.current = setTimeout(() => {
|
|
158
|
-
_onChangePage(
|
|
176
|
+
_onChangePage({
|
|
177
|
+
page: page - 1,
|
|
178
|
+
e: e
|
|
179
|
+
});
|
|
159
180
|
}, delayOnInput);
|
|
160
181
|
};
|
|
161
182
|
|
|
@@ -169,35 +190,127 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
169
190
|
setTotalItemsState(totalItems);
|
|
170
191
|
}, [totalItems]);
|
|
171
192
|
useEffect(() => {
|
|
172
|
-
|
|
173
|
-
clearTimeout(timer.current);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
timer.current = setTimeout(() => {
|
|
177
|
-
_onChangePage(0, true);
|
|
178
|
-
}, delayOnInput);
|
|
179
|
-
}, [totalItemsState, itemsPerPageState]);
|
|
180
|
-
useEffect(() => {
|
|
181
|
-
setItemsPerPageState(itemsPerPage);
|
|
193
|
+
_onChangePerPage(itemsPerPage);
|
|
182
194
|
}, [itemsPerPage]);
|
|
183
195
|
useEffect(() => {
|
|
184
|
-
|
|
185
|
-
|
|
196
|
+
_onChangePage({
|
|
197
|
+
page: currentPage,
|
|
198
|
+
changeBy: 'currentPage'
|
|
199
|
+
});
|
|
186
200
|
}, [currentPage]);
|
|
187
201
|
useEffect(() => {
|
|
188
202
|
setListPerPageState(listPerPage);
|
|
189
203
|
}, [listPerPage]);
|
|
204
|
+
useEffect(() => {
|
|
205
|
+
_onChangePage({
|
|
206
|
+
page: totalItemsState / itemsPerPageState < currentPageState - 1 ? 0 : currentPageState,
|
|
207
|
+
changeBy: 'totalItems'
|
|
208
|
+
});
|
|
209
|
+
}, [totalItemsState]);
|
|
210
|
+
useEffect(() => {
|
|
211
|
+
_onChangePage({
|
|
212
|
+
page: totalItemsState / itemsPerPageState < currentPageState - 1 ? 0 : currentPageState,
|
|
213
|
+
changeBy: 'itemsPerPage'
|
|
214
|
+
});
|
|
215
|
+
}, [itemsPerPageState]);
|
|
190
216
|
useImperativeHandle(reference, () => ({
|
|
191
217
|
element: ref.current,
|
|
192
218
|
instance: {
|
|
193
|
-
onChangePage: page => _onChangePage(
|
|
219
|
+
onChangePage: page => _onChangePage({
|
|
220
|
+
page: page,
|
|
221
|
+
changeBy: 'ref'
|
|
222
|
+
}),
|
|
194
223
|
onChangePerPage: per => _onChangePerPage(per),
|
|
195
224
|
setTotalItems: items => setTotalItemsState(items)
|
|
196
225
|
},
|
|
197
|
-
onChangePage: page => _onChangePage(
|
|
226
|
+
onChangePage: page => _onChangePage({
|
|
227
|
+
page: page,
|
|
228
|
+
changeBy: 'ref'
|
|
229
|
+
}),
|
|
198
230
|
onChangePerPage: per => _onChangePerPage(per),
|
|
199
231
|
setTotalItems: items => setTotalItemsState(items)
|
|
200
232
|
}));
|
|
233
|
+
|
|
234
|
+
const updateSize = () => {
|
|
235
|
+
if (timer.current) {
|
|
236
|
+
clearTimeout(timer.current);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
timer.current = setTimeout(() => {
|
|
240
|
+
var _ref$current;
|
|
241
|
+
|
|
242
|
+
let conti = true;
|
|
243
|
+
[...(((_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.children) || [])].reverse().forEach(item => {
|
|
244
|
+
if (item !== null && item !== void 0 && item.style) {
|
|
245
|
+
item.style.display = 'flex';
|
|
246
|
+
|
|
247
|
+
if (!conti) {
|
|
248
|
+
item.style.opacity = 1;
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
conti = hiddenEle(item);
|
|
254
|
+
});
|
|
255
|
+
}, 300);
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
useLayoutEffect(() => {
|
|
259
|
+
window.addEventListener('resize', updateSize);
|
|
260
|
+
updateSize();
|
|
261
|
+
return () => window.removeEventListener('resize', updateSize);
|
|
262
|
+
}, []);
|
|
263
|
+
|
|
264
|
+
const hiddenEle = child => {
|
|
265
|
+
setTimeout(() => {
|
|
266
|
+
var _ref$current2;
|
|
267
|
+
|
|
268
|
+
const infoChild = child === null || child === void 0 ? void 0 : child.getBoundingClientRect();
|
|
269
|
+
const infoParent = (_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.getBoundingClientRect();
|
|
270
|
+
if (!infoChild || !infoParent) return; // getBoundingClientRect includes margin => phải trừ đi margin
|
|
271
|
+
|
|
272
|
+
const style = window.getComputedStyle(child) || child.currentStyle;
|
|
273
|
+
const margin = parseInt((style === null || style === void 0 ? void 0 : style.marginLeft) || 0) + parseInt((style === null || style === void 0 ? void 0 : style.marginRight) || 0);
|
|
274
|
+
|
|
275
|
+
if (infoChild.right - margin >= infoParent.width) {
|
|
276
|
+
child.style.opacity = 0;
|
|
277
|
+
child.style.setProperty('display', 'none', 'important');
|
|
278
|
+
} else {
|
|
279
|
+
child.style.opacity = 1;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
return infoChild.right >= infoParent.width;
|
|
283
|
+
});
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
const setWithNumber = useCallback((totalRefs = totalRef, numberRefs = numberRef) => {
|
|
287
|
+
var _totalRefs;
|
|
288
|
+
|
|
289
|
+
if (!totalRefs) totalRefs = totalRef.current;
|
|
290
|
+
if (!numberRefs) numberRefs = numberRef.current;
|
|
291
|
+
if (!totalRefs || !numberRefs) return;
|
|
292
|
+
const infoText = (_totalRefs = totalRefs) === null || _totalRefs === void 0 ? void 0 : _totalRefs.getBoundingClientRect();
|
|
293
|
+
|
|
294
|
+
if (infoText && numberRefs) {
|
|
295
|
+
numberRefs.style.width = `${infoText.width * 2 + 6}px`;
|
|
296
|
+
numberRefs.style.minWidth = `${infoText.width * 2 + 6}px`;
|
|
297
|
+
}
|
|
298
|
+
}, [totalRef, numberRef]);
|
|
299
|
+
|
|
300
|
+
const checkShowPaging = () => {
|
|
301
|
+
switch (hideWithPage) {
|
|
302
|
+
case 'empty':
|
|
303
|
+
return totalItemsState !== 0;
|
|
304
|
+
|
|
305
|
+
case 'single':
|
|
306
|
+
return totalItemsState / itemsPerPageState > 1;
|
|
307
|
+
|
|
308
|
+
case 'none':
|
|
309
|
+
default:
|
|
310
|
+
return true;
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
|
|
201
314
|
return useMemo(() => {
|
|
202
315
|
const lastPage = getLastPage(totalItemsState, itemsPerPageState);
|
|
203
316
|
let listPerPageData = !listPerPageState.includes(itemsPerPageState) ? [{
|
|
@@ -210,7 +323,8 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
210
323
|
}]);
|
|
211
324
|
listPerPageData = [...new Map(listPerPageData.map(v => [JSON.stringify(v), v])).values()];
|
|
212
325
|
listPerPageData.sort((a, b) => a.id - b.id);
|
|
213
|
-
|
|
326
|
+
const showPaging = checkShowPaging();
|
|
327
|
+
return showPaging && jsx("div", {
|
|
214
328
|
ref: ref,
|
|
215
329
|
css: _pagingInfoCSS,
|
|
216
330
|
id: id,
|
|
@@ -218,73 +332,127 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
218
332
|
className: ['DGN-UI-PagingInfo', className].join(' ').trim().replace(/\s+/g, ' ')
|
|
219
333
|
}, jsx(ButtonIcon, {
|
|
220
334
|
circular: true,
|
|
221
|
-
viewType: '
|
|
335
|
+
viewType: 'ghost',
|
|
222
336
|
size: 'small',
|
|
223
337
|
name: 'ArrowDoubleLeft',
|
|
224
338
|
disabled: disablePrevState,
|
|
225
|
-
onClick: e =>
|
|
339
|
+
onClick: e => {
|
|
340
|
+
setInputPageValue(0);
|
|
341
|
+
currentPageRef.current = 0;
|
|
342
|
+
|
|
343
|
+
if (timer.current) {
|
|
344
|
+
clearTimeout(timer.current);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
timer.current = setTimeout(() => {
|
|
348
|
+
_onChangePage({
|
|
349
|
+
page: 0,
|
|
350
|
+
e: e
|
|
351
|
+
});
|
|
352
|
+
}, delayOnInput);
|
|
353
|
+
}
|
|
226
354
|
}), jsx(ButtonIcon, {
|
|
227
355
|
circular: true,
|
|
228
|
-
viewType: '
|
|
356
|
+
viewType: 'ghost',
|
|
229
357
|
size: 'small',
|
|
230
358
|
name: 'ArrowLeft',
|
|
231
359
|
disabled: disablePrevState,
|
|
232
360
|
onClick: e => {
|
|
233
|
-
|
|
361
|
+
setInputPageValue(inputPageValue - 1);
|
|
362
|
+
currentPageRef.current = currentPageRef.current === 0 ? 0 : currentPageRef.current - 1;
|
|
234
363
|
|
|
235
364
|
if (timer.current) {
|
|
236
365
|
clearTimeout(timer.current);
|
|
237
366
|
}
|
|
238
367
|
|
|
239
368
|
timer.current = setTimeout(() => {
|
|
240
|
-
_onChangePage(
|
|
369
|
+
_onChangePage({
|
|
370
|
+
page: currentPageRef.current,
|
|
371
|
+
e: e
|
|
372
|
+
});
|
|
241
373
|
}, delayOnInput);
|
|
242
374
|
}
|
|
243
|
-
}), jsx(
|
|
244
|
-
css:
|
|
375
|
+
}), jsx("div", {
|
|
376
|
+
css: ViewNumberInput,
|
|
377
|
+
ref: refs => {
|
|
378
|
+
numberRef.current = refs;
|
|
379
|
+
setWithNumber(null, refs);
|
|
380
|
+
}
|
|
381
|
+
}, jsx(NumberInput, {
|
|
245
382
|
disabledNegative: true,
|
|
246
383
|
className: 'inputPage',
|
|
247
|
-
value:
|
|
384
|
+
value: inputPageValue ? String(inputPageValue + 1) : '1',
|
|
248
385
|
min: 1,
|
|
386
|
+
autoWidth: true,
|
|
387
|
+
inputStyle: {
|
|
388
|
+
minWidth: 10
|
|
389
|
+
},
|
|
390
|
+
width: 'auto',
|
|
391
|
+
placeholder: '',
|
|
249
392
|
max: lastPage,
|
|
250
393
|
onKeyDown: checkKeyPress,
|
|
251
|
-
onChange: e => onTypePaging(e
|
|
394
|
+
onChange: e => onTypePaging(e)
|
|
252
395
|
}), "/", jsx(Typography, {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
}
|
|
257
|
-
|
|
396
|
+
ref: refs => {
|
|
397
|
+
totalRef.current = refs;
|
|
398
|
+
setWithNumber(refs, null);
|
|
399
|
+
},
|
|
400
|
+
css: css`
|
|
401
|
+
${whiteSpaceNoWrap}
|
|
402
|
+
`,
|
|
403
|
+
type: 'p2'
|
|
404
|
+
}, lastPage)), jsx(ButtonIcon, {
|
|
258
405
|
circular: true,
|
|
259
|
-
viewType: '
|
|
406
|
+
viewType: 'ghost',
|
|
260
407
|
size: 'small',
|
|
261
408
|
name: 'ArrowRight',
|
|
262
409
|
disabled: disableNextState,
|
|
263
410
|
onClick: e => {
|
|
264
|
-
|
|
411
|
+
setInputPageValue(inputPageValue + 1);
|
|
412
|
+
currentPageRef.current = currentPageRef.current === lastPage ? lastPage : currentPageRef.current + 1;
|
|
265
413
|
|
|
266
414
|
if (timer.current) {
|
|
267
415
|
clearTimeout(timer.current);
|
|
268
416
|
}
|
|
269
417
|
|
|
270
418
|
timer.current = setTimeout(() => {
|
|
271
|
-
_onChangePage(
|
|
419
|
+
_onChangePage({
|
|
420
|
+
page: currentPageRef.current,
|
|
421
|
+
e: e
|
|
422
|
+
});
|
|
272
423
|
}, delayOnInput);
|
|
273
424
|
}
|
|
274
425
|
}), jsx(ButtonIcon, {
|
|
275
426
|
circular: true,
|
|
276
|
-
viewType: '
|
|
427
|
+
viewType: 'ghost',
|
|
277
428
|
size: 'small',
|
|
278
429
|
name: 'ArrowDoubleRight',
|
|
279
430
|
disabled: disableNextState,
|
|
280
|
-
onClick: e =>
|
|
281
|
-
|
|
431
|
+
onClick: e => {
|
|
432
|
+
setInputPageValue(lastPage - 1);
|
|
433
|
+
currentPageRef.current = lastPage - 1;
|
|
434
|
+
|
|
435
|
+
if (timer.current) {
|
|
436
|
+
clearTimeout(timer.current);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
timer.current = setTimeout(() => {
|
|
440
|
+
_onChangePage({
|
|
441
|
+
page: lastPage - 1,
|
|
442
|
+
e: e
|
|
443
|
+
});
|
|
444
|
+
}, delayOnInput);
|
|
445
|
+
}
|
|
446
|
+
}), jsx(Typography, {
|
|
447
|
+
type: 'p2',
|
|
448
|
+
ref: hiddenEle,
|
|
449
|
+
className: "txt-line-number"
|
|
450
|
+
}, typeShort ? jsx(Divider, {
|
|
282
451
|
direction: 'vertical',
|
|
283
452
|
height: 24,
|
|
284
453
|
color: category
|
|
285
|
-
})
|
|
286
|
-
|
|
287
|
-
}, getGlobal('lineNumber')), jsx(Dropdown, {
|
|
454
|
+
}) : getGlobal('lineNumber'), jsx(Dropdown, {
|
|
455
|
+
allowSearch: false,
|
|
288
456
|
viewType: 'underlined',
|
|
289
457
|
dataSource: listPerPageData,
|
|
290
458
|
value: itemsPerPageState,
|
|
@@ -298,32 +466,38 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
298
466
|
dropdownItemStyle: {
|
|
299
467
|
color: active
|
|
300
468
|
}
|
|
301
|
-
}),
|
|
469
|
+
})), jsx(Typography, {
|
|
470
|
+
type: 'p2',
|
|
471
|
+
ref: hiddenEle,
|
|
472
|
+
className: 'total-items'
|
|
473
|
+
}, typeShort ? jsx(Divider, {
|
|
302
474
|
direction: 'vertical',
|
|
303
475
|
height: 24,
|
|
304
476
|
color: category
|
|
305
|
-
})
|
|
306
|
-
|
|
307
|
-
}, !typeShort && getGlobal('total') + ':', " ", totalItemsState));
|
|
308
|
-
}, [typeShort, bgColor, style, className, totalItemsState, itemsPerPageState, currentPageState, listPerPageState, disablePrevState, disableNextState]);
|
|
477
|
+
}) : getGlobal('total') + ':', totalItemsState));
|
|
478
|
+
}, [typeShort, bgColor, style, className, hideWithPage, totalItemsState, itemsPerPageState, currentPageState, listPerPageState, disablePrevState, disableNextState, inputPageValue]);
|
|
309
479
|
}));
|
|
480
|
+
const ViewNumberInput = css`
|
|
481
|
+
${flexRow};
|
|
482
|
+
${alignCenter};
|
|
483
|
+
${justifyCenter};
|
|
484
|
+
transition: all 0.1s;
|
|
485
|
+
margin: ${spacing([0, 1])};
|
|
486
|
+
`;
|
|
310
487
|
|
|
311
488
|
const pagingInfoCSS = (bgColor, typeShort) => css`
|
|
312
489
|
${flexRow};
|
|
313
490
|
${alignCenter};
|
|
314
491
|
${paragraph2};
|
|
315
492
|
${borderBox};
|
|
316
|
-
${border(1, system)};
|
|
317
493
|
${parseHeight(40)}
|
|
318
|
-
border-
|
|
319
|
-
border-right: none;
|
|
494
|
+
border-top: solid 1px ${system};
|
|
320
495
|
padding: ${spacing([1, 0])};
|
|
321
496
|
background-color: ${bgColor};
|
|
322
497
|
color: ${main};
|
|
323
498
|
.inputPage {
|
|
324
|
-
${noMargin};
|
|
325
499
|
${textCenter};
|
|
326
|
-
|
|
500
|
+
margin: ${spacing([0, 0.5])};
|
|
327
501
|
.DGN-UI-InputBase {
|
|
328
502
|
${noPadding};
|
|
329
503
|
input {
|
|
@@ -335,7 +509,11 @@ const pagingInfoCSS = (bgColor, typeShort) => css`
|
|
|
335
509
|
}
|
|
336
510
|
}
|
|
337
511
|
.txt-line-number {
|
|
338
|
-
|
|
512
|
+
${whiteSpaceNoWrap};
|
|
513
|
+
${alignCenter};
|
|
514
|
+
opacity: 0;
|
|
515
|
+
display: flex !important;
|
|
516
|
+
transition: opacity 0.3s ease;
|
|
339
517
|
}
|
|
340
518
|
.DGN-UI-Divider {
|
|
341
519
|
margin: ${spacing([0, 2])};
|
|
@@ -347,7 +525,8 @@ const pagingInfoCSS = (bgColor, typeShort) => css`
|
|
|
347
525
|
.DGN-UI-Dropdown-Form {
|
|
348
526
|
min-height: 24px;
|
|
349
527
|
padding: 0;
|
|
350
|
-
input
|
|
528
|
+
input,
|
|
529
|
+
span {
|
|
351
530
|
${paragraph2};
|
|
352
531
|
${noPadding};
|
|
353
532
|
${cursorPointer};
|
|
@@ -366,14 +545,15 @@ const pagingInfoCSS = (bgColor, typeShort) => css`
|
|
|
366
545
|
}
|
|
367
546
|
}
|
|
368
547
|
.total-items {
|
|
548
|
+
${whiteSpaceNoWrap};
|
|
549
|
+
${flexRow};
|
|
550
|
+
${alignCenter};
|
|
369
551
|
margin-left: ${`${spacing(typeShort ? [0] : [4])}`};
|
|
552
|
+
opacity: 0;
|
|
553
|
+
transition: opacity 0.3s ease;
|
|
370
554
|
}
|
|
371
555
|
`;
|
|
372
556
|
|
|
373
|
-
const dynamicWidthCSS = characters => css`
|
|
374
|
-
width: ${characters}ch;
|
|
375
|
-
`;
|
|
376
|
-
|
|
377
557
|
PagingInfo.defaultProps = {
|
|
378
558
|
typeShort: false,
|
|
379
559
|
bgColor: white,
|
|
@@ -381,7 +561,8 @@ PagingInfo.defaultProps = {
|
|
|
381
561
|
className: '',
|
|
382
562
|
totalItems: 0,
|
|
383
563
|
currentPage: 0,
|
|
384
|
-
listPerPage: [10, 15, 20, 30, 50]
|
|
564
|
+
listPerPage: [10, 15, 20, 30, 50],
|
|
565
|
+
hideWithPage: 'none'
|
|
385
566
|
};
|
|
386
567
|
PagingInfo.propTypes = {
|
|
387
568
|
/** Background color for component. */
|
|
@@ -393,6 +574,9 @@ PagingInfo.propTypes = {
|
|
|
393
574
|
/** Specifies the current page. */
|
|
394
575
|
currentPage: PropTypes.number,
|
|
395
576
|
|
|
577
|
+
/** Hidden mode for page selector. */
|
|
578
|
+
hideWithPage: PropTypes.oneOf(['none', 'empty', 'single']),
|
|
579
|
+
|
|
396
580
|
/** The quantity of items per page. */
|
|
397
581
|
itemsPerPage: PropTypes.number,
|
|
398
582
|
|
|
@@ -405,23 +589,23 @@ PagingInfo.propTypes = {
|
|
|
405
589
|
/** Callback fired when quantity on per page changed. */
|
|
406
590
|
onChangePerPage: PropTypes.func,
|
|
407
591
|
|
|
408
|
-
/**
|
|
409
|
-
* Callback fired when page number is changing.
|
|
410
|
-
*
|
|
411
|
-
* * prevPage: Page before changed
|
|
412
|
-
* * newPage: Page after changed
|
|
413
|
-
* * cancel(value): Function cancel change page
|
|
414
|
-
* * @param {value} - bool
|
|
592
|
+
/**
|
|
593
|
+
* Callback fired when page number is changing.
|
|
594
|
+
*
|
|
595
|
+
* * prevPage: Page before changed
|
|
596
|
+
* * newPage: Page after changed
|
|
597
|
+
* * cancel(value): Function cancel change page
|
|
598
|
+
* * @param {value} - bool
|
|
415
599
|
*/
|
|
416
600
|
onChangingPage: PropTypes.func,
|
|
417
601
|
|
|
418
|
-
/**
|
|
419
|
-
* Callback fired when quantity on item per page is changing.
|
|
420
|
-
*
|
|
421
|
-
* * prevPerPage: Items per page before changed
|
|
422
|
-
* * newPerPage: Items per page after changed
|
|
423
|
-
* * cancel(value): Function cancel change items per page
|
|
424
|
-
* * @param {value} - bool
|
|
602
|
+
/**
|
|
603
|
+
* Callback fired when quantity on item per page is changing.
|
|
604
|
+
*
|
|
605
|
+
* * prevPerPage: Items per page before changed
|
|
606
|
+
* * newPerPage: Items per page after changed
|
|
607
|
+
* * cancel(value): Function cancel change items per page
|
|
608
|
+
* * @param {value} - bool
|
|
425
609
|
*/
|
|
426
610
|
onChangingPerPage: PropTypes.func,
|
|
427
611
|
|
|
@@ -434,15 +618,15 @@ PagingInfo.propTypes = {
|
|
|
434
618
|
/** Compact type for mobile. */
|
|
435
619
|
typeShort: PropTypes.bool,
|
|
436
620
|
|
|
437
|
-
/**
|
|
438
|
-
* ref methods (ref.current.instance.*method*)
|
|
439
|
-
*
|
|
440
|
-
* * onChangePage(page): Change page number
|
|
441
|
-
* * @param {page} - number
|
|
442
|
-
* * onChangePerPage(per): Change quantity on per page
|
|
443
|
-
* * @param {per} - number
|
|
444
|
-
* * setTotalItems(items): Set total items
|
|
445
|
-
* * @param {items} - number
|
|
621
|
+
/**
|
|
622
|
+
* ref methods (ref.current.instance.*method*)
|
|
623
|
+
*
|
|
624
|
+
* * onChangePage(page): Change page number
|
|
625
|
+
* * @param {page} - number
|
|
626
|
+
* * onChangePerPage(per): Change quantity on per page
|
|
627
|
+
* * @param {per} - number
|
|
628
|
+
* * setTotalItems(items): Set total items
|
|
629
|
+
* * @param {items} - number
|
|
446
630
|
*/
|
|
447
631
|
reference: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
448
632
|
current: PropTypes.instanceOf(Element)
|