diginet-core-ui 1.3.82-beta.2 → 1.3.82-beta.4
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/paging/page-info.js +28 -31
- package/package.json +1 -1
|
@@ -1,32 +1,33 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
/** @jsx jsx */
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import { jsx, css } from '@emotion/core';
|
|
3
|
+
import { css, jsx } from '@emotion/core';
|
|
4
|
+
import { ButtonIcon, Divider, Dropdown, NumberInput, Typography } from "./..";
|
|
6
5
|
import OptionWrapper from "../others/option-wrapper";
|
|
7
|
-
import { ButtonIcon, NumberInput, Dropdown, Typography, Divider } from "../";
|
|
8
6
|
import { getGlobal } from "../../global";
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { forwardRef, memo, useCallback, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
9
|
+
import { alignCenter, borderBox, cursorPointer, flexRow, justifyCenter, noPadding, parseHeight, parseMinHeight, parseMinWidth, parseMinWidthHeight, parseWidthHeight, textCenter, whiteSpaceNoWrap } from "../../styles/general";
|
|
10
|
+
import { useTheme } from "../../theme";
|
|
11
|
+
import { classNames } from "../../utils";
|
|
11
12
|
const {
|
|
12
13
|
colors: {
|
|
13
14
|
system: {
|
|
14
|
-
active,
|
|
15
|
-
white
|
|
15
|
+
active: systemActive,
|
|
16
|
+
white: systemWhite
|
|
16
17
|
},
|
|
17
18
|
line: {
|
|
18
|
-
system,
|
|
19
|
-
category
|
|
19
|
+
system: lineSystem,
|
|
20
|
+
category: lineCategory
|
|
20
21
|
},
|
|
21
22
|
text: {
|
|
22
|
-
main
|
|
23
|
+
main: textMain
|
|
23
24
|
}
|
|
24
25
|
},
|
|
25
26
|
typography: {
|
|
26
27
|
paragraph2
|
|
27
28
|
},
|
|
28
29
|
spacing
|
|
29
|
-
} =
|
|
30
|
+
} = useTheme();
|
|
30
31
|
const getLastPage = (totalItems, itemsPerPage) => {
|
|
31
32
|
let _lastPage = 0;
|
|
32
33
|
if (totalItems && totalItems >= 0 && itemsPerPage && itemsPerPage > 0) {
|
|
@@ -66,8 +67,6 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
66
67
|
const [disableNextState, setDisableNextState] = useState(!(totalItems > itemsPerPage));
|
|
67
68
|
const [inputPageValue, setInputPageValue] = useState(currentPage);
|
|
68
69
|
const _pagingInfoCSS = pagingInfoCSS(bgColor, typeShort);
|
|
69
|
-
// const _dynamicWidthCSS = dynamicWidthCSS(currentPageState.toString()?.length || 3);
|
|
70
|
-
|
|
71
70
|
const _onChangePage = async ({
|
|
72
71
|
page,
|
|
73
72
|
e,
|
|
@@ -253,13 +252,13 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
253
252
|
// getBoundingClientRect includes margin => phải trừ đi margin
|
|
254
253
|
const style = window.getComputedStyle(child) || child.currentStyle;
|
|
255
254
|
const margin = parseInt((style === null || style === void 0 ? void 0 : style.marginLeft) || 0) + parseInt((style === null || style === void 0 ? void 0 : style.marginRight) || 0);
|
|
256
|
-
if (infoChild.right - margin >= infoParent.
|
|
255
|
+
if (infoChild.right - margin >= infoParent.right) {
|
|
257
256
|
child.style.opacity = 0;
|
|
258
257
|
child.style.setProperty('display', 'none', 'important');
|
|
259
258
|
} else {
|
|
260
259
|
child.style.opacity = 1;
|
|
261
260
|
}
|
|
262
|
-
return infoChild.right >= infoParent.
|
|
261
|
+
return infoChild.right >= infoParent.right;
|
|
263
262
|
});
|
|
264
263
|
};
|
|
265
264
|
const setWithNumber = useCallback((totalRefs = totalRef, numberRefs = numberRef) => {
|
|
@@ -302,7 +301,7 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
302
301
|
css: _pagingInfoCSS,
|
|
303
302
|
id: id,
|
|
304
303
|
style: style,
|
|
305
|
-
className:
|
|
304
|
+
className: classNames('DGN-UI-PagingInfo', className)
|
|
306
305
|
}, jsx(ButtonIcon, {
|
|
307
306
|
circular: true,
|
|
308
307
|
viewType: 'ghost',
|
|
@@ -415,7 +414,7 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
415
414
|
}, typeShort ? jsx(Divider, {
|
|
416
415
|
direction: 'vertical',
|
|
417
416
|
height: 24,
|
|
418
|
-
color:
|
|
417
|
+
color: lineCategory
|
|
419
418
|
}) : getGlobal('lineNumber'), jsx(Dropdown, {
|
|
420
419
|
allowSearch: false,
|
|
421
420
|
viewType: 'underlined',
|
|
@@ -429,7 +428,7 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
429
428
|
readOnly: true
|
|
430
429
|
},
|
|
431
430
|
dropdownItemStyle: {
|
|
432
|
-
color:
|
|
431
|
+
color: systemActive
|
|
433
432
|
}
|
|
434
433
|
})), jsx(Typography, {
|
|
435
434
|
type: 'p2',
|
|
@@ -438,7 +437,7 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
438
437
|
}, typeShort ? jsx(Divider, {
|
|
439
438
|
direction: 'vertical',
|
|
440
439
|
height: 24,
|
|
441
|
-
color:
|
|
440
|
+
color: lineCategory
|
|
442
441
|
}) : getGlobal('total') + ':', totalItemsState));
|
|
443
442
|
}, [typeShort, bgColor, style, className, hideWithPage, totalItemsState, itemsPerPageState, currentPageState, listPerPageState, disablePrevState, disableNextState, inputPageValue]);
|
|
444
443
|
}));
|
|
@@ -454,11 +453,11 @@ const pagingInfoCSS = (bgColor, typeShort) => css`
|
|
|
454
453
|
${alignCenter};
|
|
455
454
|
${paragraph2};
|
|
456
455
|
${borderBox};
|
|
457
|
-
${parseHeight(40)}
|
|
458
|
-
border-top: solid 1px ${
|
|
456
|
+
${parseHeight(40)};
|
|
457
|
+
border-top: solid 1px ${lineSystem};
|
|
459
458
|
padding: ${spacing([1, 0])};
|
|
460
459
|
background-color: ${bgColor};
|
|
461
|
-
color: ${
|
|
460
|
+
color: ${textMain};
|
|
462
461
|
.inputPage {
|
|
463
462
|
${textCenter};
|
|
464
463
|
margin: ${spacing([0, 0.5])};
|
|
@@ -467,7 +466,7 @@ const pagingInfoCSS = (bgColor, typeShort) => css`
|
|
|
467
466
|
input {
|
|
468
467
|
${paragraph2};
|
|
469
468
|
${textCenter};
|
|
470
|
-
color: ${
|
|
469
|
+
color: ${systemActive};
|
|
471
470
|
text-align: left;
|
|
472
471
|
}
|
|
473
472
|
}
|
|
@@ -485,9 +484,9 @@ const pagingInfoCSS = (bgColor, typeShort) => css`
|
|
|
485
484
|
.DGN-UI-Dropdown {
|
|
486
485
|
margin-left: ${`${spacing(typeShort ? [0] : [2])}`};
|
|
487
486
|
margin-bottom: 0;
|
|
488
|
-
|
|
487
|
+
${parseMinWidth(52)};
|
|
489
488
|
.DGN-UI-Dropdown-Form {
|
|
490
|
-
|
|
489
|
+
${parseMinHeight(24)};
|
|
491
490
|
padding: 0;
|
|
492
491
|
input,
|
|
493
492
|
span {
|
|
@@ -500,10 +499,8 @@ const pagingInfoCSS = (bgColor, typeShort) => css`
|
|
|
500
499
|
div,
|
|
501
500
|
span,
|
|
502
501
|
svg {
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
height: 20px;
|
|
506
|
-
min-height: 20px;
|
|
502
|
+
${parseWidthHeight(20)};
|
|
503
|
+
${parseMinWidthHeight(20)};
|
|
507
504
|
}
|
|
508
505
|
}
|
|
509
506
|
}
|
|
@@ -519,7 +516,7 @@ const pagingInfoCSS = (bgColor, typeShort) => css`
|
|
|
519
516
|
`;
|
|
520
517
|
PagingInfo.defaultProps = {
|
|
521
518
|
typeShort: false,
|
|
522
|
-
bgColor:
|
|
519
|
+
bgColor: systemWhite,
|
|
523
520
|
style: {},
|
|
524
521
|
className: '',
|
|
525
522
|
totalItems: 0,
|