diginet-core-ui 1.3.78 → 1.3.79
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/accordion/details.js +2 -6
- package/components/accordion/group.js +2 -9
- package/components/accordion/index.js +2 -15
- package/components/accordion/summary.js +4 -27
- package/components/alert/index.js +98 -137
- package/components/alert/notify.js +97 -166
- package/components/avatar/index.js +4 -63
- package/components/badge/index.js +7 -34
- package/components/button/icon.js +120 -186
- package/components/button/index.js +136 -205
- package/components/button/more.js +0 -12
- package/components/button/ripple-effect.js +46 -44
- package/components/card/body.js +2 -7
- package/components/card/extra.js +2 -7
- package/components/card/footer.js +2 -7
- package/components/card/header.js +2 -7
- package/components/card/index.js +2 -22
- package/components/chart/Pie/Circle.js +0 -1
- package/components/chart/Pie/Sector.js +0 -17
- package/components/chart/Pie/Sectors.js +0 -10
- package/components/chart/Pie/index.js +4 -36
- package/components/chart/Pie-v2/Circle.js +0 -1
- package/components/chart/Pie-v2/Sector.js +0 -13
- package/components/chart/Pie-v2/Sectors.js +0 -20
- package/components/chart/Pie-v2/index.js +11 -38
- package/components/chart/bar/Axis.js +0 -12
- package/components/chart/bar/Bar.js +13 -35
- package/components/chart/bar/Grid.js +0 -18
- package/components/chart/bar/Labels.js +0 -18
- package/components/chart/bar/Points.js +0 -17
- package/components/chart/bar/index.js +6 -26
- package/components/chart/bar-v2/Axis.js +0 -12
- package/components/chart/bar-v2/Bar.js +15 -36
- package/components/chart/bar-v2/Grid.js +0 -18
- package/components/chart/bar-v2/Labels.js +0 -18
- package/components/chart/bar-v2/Points.js +0 -17
- package/components/chart/bar-v2/index.js +6 -26
- package/components/chart/line/Axis.js +4 -16
- package/components/chart/line/Grid.js +2 -19
- package/components/chart/line/Labels.js +0 -18
- package/components/chart/line/Path.js +23 -33
- package/components/chart/line/Point.js +6 -40
- package/components/chart/line/Title.js +0 -3
- package/components/chart/line/index.js +12 -35
- package/components/chart/line-v2/Axis.js +0 -13
- package/components/chart/line-v2/Grid.js +0 -18
- package/components/chart/line-v2/Labels.js +0 -18
- package/components/chart/line-v2/Path.js +23 -33
- package/components/chart/line-v2/Point.js +6 -35
- package/components/chart/line-v2/Title.js +0 -3
- package/components/chart/line-v2/index.js +12 -30
- package/components/check-text/index.js +0 -8
- package/components/check-text/interview-confirmation.js +0 -7
- package/components/check-text/interview-status.js +0 -7
- package/components/chip/attach.js +4 -17
- package/components/chip/index.js +6 -33
- package/components/collapse/index.js +0 -13
- package/components/divider/index.js +0 -8
- package/components/form-control/attachment/index.js +24 -202
- package/components/form-control/calendar/function.js +40 -94
- package/components/form-control/calendar/index.js +5 -30
- package/components/form-control/calendar/range.js +11 -28
- package/components/form-control/checkbox/index.js +4 -37
- package/components/form-control/control/index.js +3 -13
- package/components/form-control/date-picker/index-old.js +18 -0
- package/components/form-control/date-picker/index.js +23 -99
- package/components/form-control/date-range-picker/index.js +86 -221
- package/components/form-control/dropdown/index.js +72 -289
- package/components/form-control/dropdown-box/index.js +6 -35
- package/components/form-control/form/index.js +0 -2
- package/components/form-control/form-group/index.js +1 -6
- package/components/form-control/helper-text/index.js +2 -9
- package/components/form-control/input-base/index.js +218 -399
- package/components/form-control/label/index.js +2 -12
- package/components/form-control/money-input/index.js +43 -132
- package/components/form-control/number-input/index.js +15 -113
- package/components/form-control/number-input/index2.js +78 -119
- package/components/form-control/phone-input/index.js +16 -78
- package/components/form-control/radio/index.js +4 -23
- package/components/form-control/text-input/index.js +33 -256
- package/components/form-control/time-picker/index.js +14 -71
- package/components/form-control/time-picker/swiper.js +21 -73
- package/components/form-control/toggle/index.js +4 -19
- package/components/form-view/helper-text.js +2 -2
- package/components/form-view/index.js +0 -14
- package/components/form-view/input.js +2 -13
- package/components/form-view/label.js +0 -2
- package/components/grid/Col.js +2 -15
- package/components/grid/Container.js +2 -21
- package/components/grid/Row.js +2 -21
- package/components/grid/index.js +2 -43
- package/components/image/index.js +2 -22
- package/components/index.js +62 -31
- package/components/list/list-item-action.js +0 -9
- package/components/list/list-item-icon.js +0 -9
- package/components/list/list-item-text.js +0 -5
- package/components/list/list-item.js +0 -11
- package/components/list/list.js +0 -13
- package/components/list/sub-header.js +0 -4
- package/components/modal/body.js +2 -6
- package/components/modal/footer.js +2 -11
- package/components/modal/header.js +2 -12
- package/components/modal/index.js +2 -10
- package/components/modal/modal.js +11 -52
- package/components/others/extra/index.js +3 -10
- package/components/others/import/index.js +0 -7
- package/components/others/option-wrapper/index.js +4 -7
- package/components/others/scrollbar/index.js +0 -3
- package/components/paging/page-info.js +39 -101
- package/components/paging/page-selector.js +7 -35
- package/components/paging/page-selector2.js +35 -74
- package/components/paper/index.js +0 -11
- package/components/popover/body.js +2 -6
- package/components/popover/footer.js +2 -11
- package/components/popover/header.js +2 -7
- package/components/popover/index.js +39 -123
- package/components/popup/danger_popup.js +0 -19
- package/components/popup/index.js +2 -48
- package/components/popup/proposals_popup.js +10 -49
- package/components/popup/v2/index.js +0 -31
- package/components/progress/circular.js +19 -81
- package/components/progress/linear.js +4 -20
- package/components/rating/index.js +0 -24
- package/components/slider/slider-container.js +3 -40
- package/components/slider/slider-item.js +10 -25
- package/components/status/index.js +2 -16
- package/components/tab/tab-container.js +2 -16
- package/components/tab/tab-header.js +4 -24
- package/components/tab/tab-panel.js +4 -16
- package/components/tab/tab.js +4 -28
- package/components/tooltip/index.js +12 -97
- package/components/tooltip/portal.js +0 -2
- package/components/transfer/index.js +22 -67
- package/components/tree-view/index.js +62 -202
- package/components/typography/index.js +3 -31
- package/global/index.js +0 -8
- package/icons/basic.js +0 -48
- package/icons/effect.js +17 -29
- package/icons/general/clock/clock.js +0 -2
- package/icons/general/color-handler/background.js +0 -2
- package/icons/general/color-handler/text.js +0 -2
- package/icons/general/emoji/emoji.js +0 -2
- package/icons/general/font-properties/bold.js +0 -2
- package/icons/general/font-properties/font-family.js +0 -2
- package/icons/general/font-properties/font-size.js +0 -2
- package/icons/general/font-properties/italic.js +0 -2
- package/icons/general/font-properties/underline.js +0 -2
- package/icons/general/hyperlink/hyperlink.js +0 -2
- package/icons/general/indent/decrease.js +0 -2
- package/icons/general/indent/increase.js +0 -2
- package/icons/general/list/bullets.js +0 -2
- package/icons/general/list/numbering.js +0 -2
- package/icons/general/picture/picture.js +0 -2
- package/icons/general/steps/redo.js +0 -2
- package/icons/general/steps/undo.js +0 -2
- package/icons/general/text-align/center.js +0 -2
- package/icons/general/text-align/justify.js +0 -2
- package/icons/general/text-align/left.js +0 -2
- package/icons/general/text-align/right.js +0 -2
- package/icons/menu/dhr.js +2 -1
- package/icons/menu/index.js +2 -2
- package/icons/menu/v2/index.js +0 -10
- package/package.json +1 -1
- package/readme.md +11 -1
- package/styles/animation.js +15 -58
- package/styles/color-helper.js +24 -54
- package/styles/colors.js +17 -9
- package/styles/general.js +6 -2
- package/styles/typography.js +4 -4
- package/styles/utils.js +2 -2
- package/theme/createBreakpoints.js +7 -18
- package/theme/make-styles.js +2 -5
- package/theme/set-theme.js +3 -6
- package/theme/settings.js +3 -2
- package/theme/theme-provider.js +0 -1
- package/utils/array/array.js +14 -23
- package/utils/classNames.js +0 -5
- package/utils/console.js +0 -6
- package/utils/date.js +13 -82
- package/utils/error/error.js +1 -9
- package/utils/error/errors.js +1 -48
- package/utils/getFileType.js +0 -9
- package/utils/handleBreakpoints.js +0 -5
- package/utils/intersectionObserver.js +0 -5
- package/utils/iterator.js +0 -9
- package/utils/map-parent.js +3 -10
- package/utils/object/extend.js +0 -10
- package/utils/object/object.js +12 -11
- package/utils/parseHTML.js +0 -1
- package/utils/promisify.js +0 -5
- package/utils/randomString.js +0 -7
- package/utils/remove-unicode.js +0 -1
- package/utils/render-portal.js +1 -9
- package/utils/renderHTML.js +4 -6
- package/utils/renderIcon.js +4 -14
- package/utils/sb-template.js +6 -5
- package/utils/string/capitalize.js +0 -1
- package/utils/string/capitalizeSentenceCase.js +0 -2
- package/utils/string/string.js +0 -13
- package/utils/type.js +0 -21
- package/utils/updatePosition.js +4 -5
- package/utils/useDelayUnmount.js +0 -4
- package/utils/useElementSize.js +9 -3
- package/utils/useEventListener.js +12 -6
- package/utils/useInput.js +0 -6
- package/utils/useMediaQuery.js +8 -10
- package/utils/useOnClickOutside.js +0 -2
- package/utils/usePortal.js +3 -10
- package/utils/validate.js +6 -20
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
/* eslint-disable react/prop-types */
|
|
2
|
-
|
|
3
2
|
/** @jsxRuntime classic */
|
|
4
|
-
|
|
5
3
|
/** @jsx jsx */
|
|
6
4
|
import { memo, useState, useEffect, useMemo, useRef } from 'react';
|
|
7
5
|
import PropTypes from 'prop-types';
|
|
@@ -16,7 +14,6 @@ const icons = {
|
|
|
16
14
|
<path fillRule="evenodd" clip-rule="evenodd" d="M7.00011 6.99993C7.22711 6.99993 7.45511 7.07693 7.64011 7.23193L13.6401 12.2319C14.0641 12.5859 14.1211 13.2159 13.7681 13.6399C13.4141 14.0649 12.7851 14.1209 12.3601 13.7679L6.98911 9.29293L1.62711 13.6069C1.19711 13.9529 0.566109 13.8849 0.221108 13.4549C-0.125891 13.0249 -0.0568903 12.3959 0.373109 12.0489L6.37311 7.22093C6.55611 7.07393 6.77811 6.99993 7.00011 6.99993ZM6.98901 2.29243L1.62701 6.60743C1.19701 6.95243 0.56601 6.88443 0.22101 6.45543C-0.12499 6.02443 -0.0569899 5.39543 0.37301 5.04843L6.37301 0.220434C6.55601 0.0734332 6.77801 0.000434244 7.00001 0.000434264C7.22801 0.000434283 7.45501 0.077434 7.64001 0.232434L13.64 5.23243C14.065 5.58543 14.122 6.21543 13.768 6.64043C13.415 7.06443 12.785 7.12243 12.36 6.76843L6.98901 2.29243Z" fill="currentColor"/>
|
|
17
15
|
</svg>`
|
|
18
16
|
};
|
|
19
|
-
|
|
20
17
|
const Extra = ({
|
|
21
18
|
type,
|
|
22
19
|
displayText,
|
|
@@ -28,8 +25,8 @@ const Extra = ({
|
|
|
28
25
|
const textRef = useRef(null);
|
|
29
26
|
const iconRef = useRef(null);
|
|
30
27
|
const [typeState, setTypeState] = useState(type);
|
|
31
|
-
/* Start styled */
|
|
32
28
|
|
|
29
|
+
/* Start styled */
|
|
33
30
|
const extraIcon = css`
|
|
34
31
|
display: flex;
|
|
35
32
|
align-items: center;
|
|
@@ -64,7 +61,6 @@ const Extra = ({
|
|
|
64
61
|
/* End styled */
|
|
65
62
|
|
|
66
63
|
/* Start handler */
|
|
67
|
-
|
|
68
64
|
const handleClick = () => {
|
|
69
65
|
if (typeState === 'expand') {
|
|
70
66
|
iconRef.current.innerHTML = icons.collapse;
|
|
@@ -75,12 +71,10 @@ const Extra = ({
|
|
|
75
71
|
textRef.current.innerHTML = displayText || 'Xem thêm';
|
|
76
72
|
setTypeState('expand');
|
|
77
73
|
}
|
|
78
|
-
|
|
79
74
|
if (onClick) onClick({
|
|
80
75
|
type: typeState === 'expand' ? 'collapse' : 'expand'
|
|
81
76
|
});
|
|
82
77
|
};
|
|
83
|
-
|
|
84
78
|
useEffect(() => {
|
|
85
79
|
iconRef.current.innerHTML = type === 'expand' ? icons.expand : icons.collapse;
|
|
86
80
|
setTypeState(type);
|
|
@@ -91,7 +85,6 @@ const Extra = ({
|
|
|
91
85
|
/* End handler */
|
|
92
86
|
|
|
93
87
|
/* Start component */
|
|
94
|
-
|
|
95
88
|
const iconComp = useMemo(() => jsx("div", {
|
|
96
89
|
ref: iconRef,
|
|
97
90
|
css: extraIcon
|
|
@@ -102,14 +95,14 @@ const Extra = ({
|
|
|
102
95
|
}, displayText), []);
|
|
103
96
|
/* End component */
|
|
104
97
|
|
|
105
|
-
return jsx("div", {
|
|
98
|
+
return jsx("div", {
|
|
99
|
+
...props,
|
|
106
100
|
ref: extraRef,
|
|
107
101
|
css: extra,
|
|
108
102
|
onClick: handleClick,
|
|
109
103
|
style: style
|
|
110
104
|
}, iconComp, textComp);
|
|
111
105
|
};
|
|
112
|
-
|
|
113
106
|
Extra.defaultProps = {
|
|
114
107
|
type: 'expand'
|
|
115
108
|
};
|
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Button, Typography, Notify as AlertNotify } from '../..';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
-
|
|
5
4
|
const ImportComp = ({
|
|
6
5
|
components,
|
|
7
6
|
from = 'components',
|
|
8
7
|
importDefault = false
|
|
9
8
|
}) => {
|
|
10
9
|
let text = Array.isArray(components) ? components.join(', ') : components;
|
|
11
|
-
|
|
12
10
|
if (!importDefault) {
|
|
13
11
|
text = `{ ${text} }`;
|
|
14
12
|
}
|
|
15
|
-
|
|
16
13
|
const importText = `import ${text} from 'diginet-core-ui/${from}';`;
|
|
17
14
|
let Notify = null;
|
|
18
|
-
|
|
19
15
|
const onCopyImport = () => {
|
|
20
16
|
if (!components) {
|
|
21
17
|
Notify(`Không có components để copy`, {
|
|
@@ -23,7 +19,6 @@ const ImportComp = ({
|
|
|
23
19
|
});
|
|
24
20
|
return;
|
|
25
21
|
}
|
|
26
|
-
|
|
27
22
|
const el = document.createElement('input');
|
|
28
23
|
el.value = importText;
|
|
29
24
|
document.body.appendChild(el);
|
|
@@ -32,7 +27,6 @@ const ImportComp = ({
|
|
|
32
27
|
document.body.removeChild(el);
|
|
33
28
|
Notify(`Đã copy ${text} from ${from}`);
|
|
34
29
|
};
|
|
35
|
-
|
|
36
30
|
return components ? /*#__PURE__*/React.createElement("div", {
|
|
37
31
|
style: {
|
|
38
32
|
display: 'flex',
|
|
@@ -69,7 +63,6 @@ const ImportComp = ({
|
|
|
69
63
|
color: 'warning'
|
|
70
64
|
}, "(Khoan h\u1EB5n d\xF9ng)"));
|
|
71
65
|
};
|
|
72
|
-
|
|
73
66
|
ImportComp.propTypes = {
|
|
74
67
|
components: PropTypes.string,
|
|
75
68
|
from: PropTypes.string,
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
|
-
|
|
3
2
|
/** @jsx jsx */
|
|
4
3
|
import { useState, forwardRef, useEffect } from 'react';
|
|
5
4
|
import { jsx } from '@emotion/core';
|
|
6
|
-
|
|
7
5
|
const OptionWrapper = WrappedComponent => {
|
|
8
6
|
return /*#__PURE__*/forwardRef((props, ref) => {
|
|
9
7
|
const [options, setOptions] = useState({});
|
|
10
|
-
|
|
11
8
|
const option = (option, optionValue) => {
|
|
12
9
|
if (typeof option === 'undefined') {
|
|
13
10
|
return props;
|
|
@@ -16,16 +13,17 @@ const OptionWrapper = WrappedComponent => {
|
|
|
16
13
|
[option]: optionValue
|
|
17
14
|
});
|
|
18
15
|
} else if (typeof option === 'object') {
|
|
19
|
-
setOptions({
|
|
16
|
+
setOptions({
|
|
17
|
+
...options,
|
|
20
18
|
...option
|
|
21
19
|
});
|
|
22
20
|
}
|
|
23
21
|
};
|
|
24
|
-
|
|
25
22
|
useEffect(() => {
|
|
26
23
|
setOptions({});
|
|
27
24
|
}, [props]);
|
|
28
|
-
return jsx(WrappedComponent, {
|
|
25
|
+
return jsx(WrappedComponent, {
|
|
26
|
+
...props,
|
|
29
27
|
...options,
|
|
30
28
|
action: {
|
|
31
29
|
option
|
|
@@ -34,5 +32,4 @@ const OptionWrapper = WrappedComponent => {
|
|
|
34
32
|
});
|
|
35
33
|
});
|
|
36
34
|
};
|
|
37
|
-
|
|
38
35
|
export default OptionWrapper;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
|
-
|
|
3
2
|
/** @jsx jsx */
|
|
4
3
|
import { memo } from 'react';
|
|
5
4
|
import PropTypes from 'prop-types';
|
|
@@ -19,7 +18,6 @@ const getPosition = {
|
|
|
19
18
|
text-align: left;
|
|
20
19
|
`
|
|
21
20
|
};
|
|
22
|
-
|
|
23
21
|
const scrollbar = ({
|
|
24
22
|
backgroundScroll,
|
|
25
23
|
backgroundThumb,
|
|
@@ -72,7 +70,6 @@ const scrollbar = ({
|
|
|
72
70
|
...props
|
|
73
71
|
}, children);
|
|
74
72
|
};
|
|
75
|
-
|
|
76
73
|
scrollbar.defaultProps = {
|
|
77
74
|
backgroundScroll: white,
|
|
78
75
|
backgroundThumb: dark12,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
|
-
|
|
3
2
|
/** @jsx jsx */
|
|
4
3
|
import { memo, useState, useRef, useEffect, useMemo, forwardRef, useImperativeHandle, useLayoutEffect, useCallback } from 'react';
|
|
5
4
|
import PropTypes from 'prop-types';
|
|
@@ -28,18 +27,14 @@ const {
|
|
|
28
27
|
},
|
|
29
28
|
spacing
|
|
30
29
|
} = theme;
|
|
31
|
-
|
|
32
30
|
const getLastPage = (totalItems, itemsPerPage) => {
|
|
33
31
|
let _lastPage = 0;
|
|
34
|
-
|
|
35
32
|
if (totalItems && totalItems >= 0 && itemsPerPage && itemsPerPage > 0) {
|
|
36
33
|
_lastPage = Math.ceil(totalItems / itemsPerPage);
|
|
37
34
|
return _lastPage;
|
|
38
35
|
}
|
|
39
|
-
|
|
40
36
|
return _lastPage + 1;
|
|
41
37
|
};
|
|
42
|
-
|
|
43
38
|
const delayOnInput = getGlobal('delayOnInput');
|
|
44
39
|
const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
45
40
|
action = {},
|
|
@@ -70,9 +65,8 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
70
65
|
const [disablePrevState, setDisablePrevState] = useState(true);
|
|
71
66
|
const [disableNextState, setDisableNextState] = useState(!(totalItems > itemsPerPage));
|
|
72
67
|
const [inputPageValue, setInputPageValue] = useState(currentPage);
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
68
|
+
const _pagingInfoCSS = pagingInfoCSS(bgColor, typeShort);
|
|
69
|
+
// const _dynamicWidthCSS = dynamicWidthCSS(currentPageState.toString()?.length || 3);
|
|
76
70
|
|
|
77
71
|
const _onChangePage = async ({
|
|
78
72
|
page,
|
|
@@ -81,36 +75,35 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
81
75
|
}) => {
|
|
82
76
|
const lastPage = getLastPage(totalItemsState, itemsPerPageState);
|
|
83
77
|
let disablePrev = false;
|
|
84
|
-
let disableNext = false;
|
|
78
|
+
let disableNext = false;
|
|
85
79
|
|
|
80
|
+
// If last page = 1. Disable all
|
|
86
81
|
if (lastPage === 1) {
|
|
87
82
|
disablePrev = true;
|
|
88
83
|
disableNext = true;
|
|
89
|
-
}
|
|
90
|
-
|
|
84
|
+
}
|
|
91
85
|
|
|
86
|
+
// If current page = last page. Disable Next and Last
|
|
92
87
|
if (page + 1 >= lastPage) {
|
|
93
88
|
disableNext = true;
|
|
94
|
-
}
|
|
95
|
-
|
|
89
|
+
}
|
|
96
90
|
|
|
91
|
+
// If current page = 0. Disable Previous and First
|
|
97
92
|
if (page === 0) {
|
|
98
93
|
disablePrev = true;
|
|
99
94
|
}
|
|
100
|
-
|
|
101
95
|
setDisablePrevState(disablePrev);
|
|
102
96
|
setDisableNextState(disableNext);
|
|
103
97
|
if (page === currentPageState) return;
|
|
104
|
-
|
|
105
98
|
if (onChangingPage) {
|
|
106
|
-
const event = {
|
|
99
|
+
const event = {
|
|
100
|
+
...e,
|
|
107
101
|
cancel: false,
|
|
108
102
|
prevPage: currentPageState,
|
|
109
103
|
newPage: page,
|
|
110
104
|
changeBy: changeBy
|
|
111
105
|
};
|
|
112
106
|
await onChangingPage(event);
|
|
113
|
-
|
|
114
107
|
if (event.cancel) {
|
|
115
108
|
if (e !== null && e !== void 0 && e.reset) e.reset();
|
|
116
109
|
currentPageRef.current = currentPageState;
|
|
@@ -119,23 +112,21 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
119
112
|
return;
|
|
120
113
|
}
|
|
121
114
|
}
|
|
122
|
-
|
|
123
115
|
currentPageRef.current = page;
|
|
124
116
|
setCurrentPageState(page);
|
|
125
117
|
setInputPageValue(page);
|
|
126
118
|
if (onChangePage) onChangePage(page);
|
|
127
119
|
};
|
|
128
|
-
|
|
129
120
|
const _onChangePerPage = async per => {
|
|
130
121
|
if (per === itemsPerPageState) return;
|
|
131
122
|
const lastPage = getLastPage(totalItemsState, per);
|
|
132
123
|
per = parseInt(per, 10);
|
|
133
|
-
let disableNext = false;
|
|
124
|
+
let disableNext = false;
|
|
134
125
|
|
|
126
|
+
// If last page = 1. Disable all
|
|
135
127
|
if (lastPage === 1) {
|
|
136
128
|
disableNext = true;
|
|
137
129
|
}
|
|
138
|
-
|
|
139
130
|
if (onChangingPerPage) {
|
|
140
131
|
const event = {
|
|
141
132
|
cancel: false,
|
|
@@ -143,32 +134,26 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
143
134
|
newPerPage: per
|
|
144
135
|
};
|
|
145
136
|
await onChangingPerPage(event);
|
|
146
|
-
|
|
147
137
|
if (event.cancel) {
|
|
148
138
|
return;
|
|
149
139
|
}
|
|
150
140
|
}
|
|
151
|
-
|
|
152
|
-
|
|
141
|
+
setItemsPerPageState(per);
|
|
142
|
+
// currentPageRef.current = 0;
|
|
153
143
|
// setCurrentPageState(0);
|
|
154
144
|
// setInputPageValue(0);
|
|
155
|
-
|
|
156
145
|
_onChangePage({
|
|
157
146
|
page: 0
|
|
158
147
|
});
|
|
159
|
-
|
|
160
148
|
setDisablePrevState(true);
|
|
161
149
|
setDisableNextState(disableNext);
|
|
162
150
|
if (onChangePerPage) onChangePerPage(per);
|
|
163
151
|
};
|
|
164
|
-
|
|
165
152
|
const onTypePaging = e => {
|
|
166
153
|
var _e$value;
|
|
167
|
-
|
|
168
154
|
if (timer.current) {
|
|
169
155
|
clearTimeout(timer.current);
|
|
170
156
|
}
|
|
171
|
-
|
|
172
157
|
const value = (_e$value = e === null || e === void 0 ? void 0 : e.value) !== null && _e$value !== void 0 ? _e$value : e;
|
|
173
158
|
const lastPage = getLastPage(totalItemsState, itemsPerPageState);
|
|
174
159
|
const page = !value || parseInt(value) < 0 ? 1 : parseInt(value) > lastPage ? lastPage : parseInt(value);
|
|
@@ -180,13 +165,11 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
180
165
|
});
|
|
181
166
|
}, delayOnInput);
|
|
182
167
|
};
|
|
183
|
-
|
|
184
168
|
const checkKeyPress = e => {
|
|
185
169
|
if (/,/.test(e.key)) {
|
|
186
170
|
e.preventDefault();
|
|
187
171
|
}
|
|
188
172
|
};
|
|
189
|
-
|
|
190
173
|
useEffect(() => {
|
|
191
174
|
setTotalItemsState(totalItems);
|
|
192
175
|
}, [totalItems]);
|
|
@@ -226,103 +209,81 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
226
209
|
setTotalItems: items => setTotalItemsState(items),
|
|
227
210
|
...action
|
|
228
211
|
}; // methods
|
|
229
|
-
|
|
230
212
|
_instance.__proto__ = {}; // hidden methods
|
|
231
|
-
|
|
232
213
|
currentRef.instance = _instance;
|
|
233
|
-
|
|
234
214
|
currentRef.onChangePage = page => _onChangePage({
|
|
235
215
|
page: page,
|
|
236
216
|
changeBy: 'ref'
|
|
237
217
|
});
|
|
238
|
-
|
|
239
218
|
currentRef.onChangePerPage = per => _onChangePerPage(per);
|
|
240
|
-
|
|
241
219
|
currentRef.setTotalItems = items => setTotalItemsState(items);
|
|
242
|
-
|
|
243
220
|
return currentRef;
|
|
244
221
|
});
|
|
245
|
-
|
|
246
222
|
const updateSize = () => {
|
|
247
223
|
if (timer.current) {
|
|
248
224
|
clearTimeout(timer.current);
|
|
249
225
|
}
|
|
250
|
-
|
|
251
226
|
timer.current = setTimeout(() => {
|
|
252
227
|
var _ref$current;
|
|
253
|
-
|
|
254
228
|
let conti = true;
|
|
255
229
|
[...(((_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.children) || [])].reverse().forEach(item => {
|
|
256
230
|
if (item !== null && item !== void 0 && item.style) {
|
|
257
231
|
item.style.display = 'flex';
|
|
258
|
-
|
|
259
232
|
if (!conti) {
|
|
260
233
|
item.style.opacity = 1;
|
|
261
234
|
return;
|
|
262
235
|
}
|
|
263
236
|
}
|
|
264
|
-
|
|
265
237
|
conti = hiddenEle(item);
|
|
266
238
|
});
|
|
267
239
|
}, 300);
|
|
268
240
|
};
|
|
269
|
-
|
|
270
241
|
useLayoutEffect(() => {
|
|
271
242
|
window.addEventListener('resize', updateSize);
|
|
272
243
|
updateSize();
|
|
273
244
|
return () => window.removeEventListener('resize', updateSize);
|
|
274
245
|
}, []);
|
|
275
|
-
|
|
276
246
|
const hiddenEle = child => {
|
|
277
247
|
setTimeout(() => {
|
|
278
248
|
var _ref$current2;
|
|
279
|
-
|
|
280
249
|
const infoChild = child === null || child === void 0 ? void 0 : child.getBoundingClientRect();
|
|
281
250
|
const infoParent = (_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.getBoundingClientRect();
|
|
282
|
-
if (!infoChild || !infoParent) return;
|
|
251
|
+
if (!infoChild || !infoParent) return;
|
|
283
252
|
|
|
253
|
+
// getBoundingClientRect includes margin => phải trừ đi margin
|
|
284
254
|
const style = window.getComputedStyle(child) || child.currentStyle;
|
|
285
255
|
const margin = parseInt((style === null || style === void 0 ? void 0 : style.marginLeft) || 0) + parseInt((style === null || style === void 0 ? void 0 : style.marginRight) || 0);
|
|
286
|
-
|
|
287
256
|
if (infoChild.right - margin >= infoParent.width) {
|
|
288
257
|
child.style.opacity = 0;
|
|
289
258
|
child.style.setProperty('display', 'none', 'important');
|
|
290
259
|
} else {
|
|
291
260
|
child.style.opacity = 1;
|
|
292
261
|
}
|
|
293
|
-
|
|
294
262
|
return infoChild.right >= infoParent.width;
|
|
295
263
|
});
|
|
296
264
|
};
|
|
297
|
-
|
|
298
265
|
const setWithNumber = useCallback((totalRefs = totalRef, numberRefs = numberRef) => {
|
|
299
266
|
var _totalRefs;
|
|
300
|
-
|
|
301
267
|
if (!totalRefs) totalRefs = totalRef.current;
|
|
302
268
|
if (!numberRefs) numberRefs = numberRef.current;
|
|
303
269
|
if (!totalRefs || !numberRefs) return;
|
|
304
270
|
const infoText = (_totalRefs = totalRefs) === null || _totalRefs === void 0 ? void 0 : _totalRefs.getBoundingClientRect();
|
|
305
|
-
|
|
306
271
|
if (infoText && numberRefs) {
|
|
307
272
|
numberRefs.style.width = `${infoText.width * 2 + 6}px`;
|
|
308
273
|
numberRefs.style.minWidth = `${infoText.width * 2 + 6}px`;
|
|
309
274
|
}
|
|
310
275
|
}, [totalRef, numberRef]);
|
|
311
|
-
|
|
312
276
|
const checkShowPaging = () => {
|
|
313
277
|
switch (hideWithPage) {
|
|
314
278
|
case 'empty':
|
|
315
279
|
return totalItemsState !== 0;
|
|
316
|
-
|
|
317
280
|
case 'single':
|
|
318
281
|
return totalItemsState / itemsPerPageState > 1;
|
|
319
|
-
|
|
320
282
|
case 'none':
|
|
321
283
|
default:
|
|
322
284
|
return true;
|
|
323
285
|
}
|
|
324
286
|
};
|
|
325
|
-
|
|
326
287
|
return useMemo(() => {
|
|
327
288
|
const lastPage = getLastPage(totalItemsState, itemsPerPageState);
|
|
328
289
|
let listPerPageData = !listPerPageState.includes(itemsPerPageState) ? [{
|
|
@@ -351,11 +312,9 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
351
312
|
onClick: e => {
|
|
352
313
|
setInputPageValue(0);
|
|
353
314
|
currentPageRef.current = 0;
|
|
354
|
-
|
|
355
315
|
if (timer.current) {
|
|
356
316
|
clearTimeout(timer.current);
|
|
357
317
|
}
|
|
358
|
-
|
|
359
318
|
timer.current = setTimeout(() => {
|
|
360
319
|
_onChangePage({
|
|
361
320
|
page: 0,
|
|
@@ -372,11 +331,9 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
372
331
|
onClick: e => {
|
|
373
332
|
setInputPageValue(inputPageValue - 1);
|
|
374
333
|
currentPageRef.current = currentPageRef.current === 0 ? 0 : currentPageRef.current - 1;
|
|
375
|
-
|
|
376
334
|
if (timer.current) {
|
|
377
335
|
clearTimeout(timer.current);
|
|
378
336
|
}
|
|
379
|
-
|
|
380
337
|
timer.current = setTimeout(() => {
|
|
381
338
|
_onChangePage({
|
|
382
339
|
page: currentPageRef.current,
|
|
@@ -422,11 +379,9 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
422
379
|
onClick: e => {
|
|
423
380
|
setInputPageValue(inputPageValue + 1);
|
|
424
381
|
currentPageRef.current = currentPageRef.current === lastPage ? lastPage : currentPageRef.current + 1;
|
|
425
|
-
|
|
426
382
|
if (timer.current) {
|
|
427
383
|
clearTimeout(timer.current);
|
|
428
384
|
}
|
|
429
|
-
|
|
430
385
|
timer.current = setTimeout(() => {
|
|
431
386
|
_onChangePage({
|
|
432
387
|
page: currentPageRef.current,
|
|
@@ -443,11 +398,9 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
443
398
|
onClick: e => {
|
|
444
399
|
setInputPageValue(lastPage - 1);
|
|
445
400
|
currentPageRef.current = lastPage - 1;
|
|
446
|
-
|
|
447
401
|
if (timer.current) {
|
|
448
402
|
clearTimeout(timer.current);
|
|
449
403
|
}
|
|
450
|
-
|
|
451
404
|
timer.current = setTimeout(() => {
|
|
452
405
|
_onChangePage({
|
|
453
406
|
page: lastPage - 1,
|
|
@@ -496,7 +449,6 @@ const ViewNumberInput = css`
|
|
|
496
449
|
transition: all 0.1s;
|
|
497
450
|
margin: ${spacing([0, 1])};
|
|
498
451
|
`;
|
|
499
|
-
|
|
500
452
|
const pagingInfoCSS = (bgColor, typeShort) => css`
|
|
501
453
|
${flexRow};
|
|
502
454
|
${alignCenter};
|
|
@@ -565,7 +517,6 @@ const pagingInfoCSS = (bgColor, typeShort) => css`
|
|
|
565
517
|
transition: opacity 0.3s ease;
|
|
566
518
|
}
|
|
567
519
|
`;
|
|
568
|
-
|
|
569
520
|
PagingInfo.defaultProps = {
|
|
570
521
|
typeShort: false,
|
|
571
522
|
bgColor: white,
|
|
@@ -579,66 +530,53 @@ PagingInfo.defaultProps = {
|
|
|
579
530
|
PagingInfo.propTypes = {
|
|
580
531
|
/** Background color for component. */
|
|
581
532
|
bgColor: PropTypes.string,
|
|
582
|
-
|
|
583
533
|
/** Class for component. */
|
|
584
534
|
className: PropTypes.string,
|
|
585
|
-
|
|
586
535
|
/** Specifies the current page. */
|
|
587
536
|
currentPage: PropTypes.number,
|
|
588
|
-
|
|
589
537
|
/** Hidden mode for page selector. */
|
|
590
538
|
hideWithPage: PropTypes.oneOf(['none', 'empty', 'single']),
|
|
591
|
-
|
|
592
539
|
/** The quantity of items per page. */
|
|
593
540
|
itemsPerPage: PropTypes.number,
|
|
594
|
-
|
|
595
541
|
/** The list to choose the number of elements to display per page. */
|
|
596
542
|
listPerPage: PropTypes.array,
|
|
597
|
-
|
|
598
543
|
/** Callback fired when page number changed. */
|
|
599
544
|
onChangePage: PropTypes.func,
|
|
600
|
-
|
|
601
545
|
/** Callback fired when quantity on per page changed. */
|
|
602
546
|
onChangePerPage: PropTypes.func,
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
*
|
|
606
|
-
*
|
|
607
|
-
* *
|
|
608
|
-
* *
|
|
609
|
-
*
|
|
610
|
-
* * @param {value} - bool
|
|
547
|
+
/**
|
|
548
|
+
* Callback fired when page number is changing.
|
|
549
|
+
*
|
|
550
|
+
* * prevPage: Page before changed
|
|
551
|
+
* * newPage: Page after changed
|
|
552
|
+
* * cancel(value): Function cancel change page
|
|
553
|
+
* * @param {value} - bool
|
|
611
554
|
*/
|
|
612
555
|
onChangingPage: PropTypes.func,
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
*
|
|
616
|
-
*
|
|
617
|
-
* *
|
|
618
|
-
* *
|
|
619
|
-
*
|
|
620
|
-
* * @param {value} - bool
|
|
556
|
+
/**
|
|
557
|
+
* Callback fired when quantity on item per page is changing.
|
|
558
|
+
*
|
|
559
|
+
* * prevPerPage: Items per page before changed
|
|
560
|
+
* * newPerPage: Items per page after changed
|
|
561
|
+
* * cancel(value): Function cancel change items per page
|
|
562
|
+
* * @param {value} - bool
|
|
621
563
|
*/
|
|
622
564
|
onChangingPerPage: PropTypes.func,
|
|
623
|
-
|
|
624
565
|
/** Style inline of component. */
|
|
625
566
|
style: PropTypes.object,
|
|
626
|
-
|
|
627
567
|
/** Total items. */
|
|
628
568
|
totalItems: PropTypes.number,
|
|
629
|
-
|
|
630
569
|
/** Compact type for mobile. */
|
|
631
570
|
typeShort: PropTypes.bool,
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
*
|
|
635
|
-
*
|
|
636
|
-
*
|
|
637
|
-
*
|
|
638
|
-
*
|
|
639
|
-
*
|
|
640
|
-
*
|
|
641
|
-
* * @param {items} - number
|
|
571
|
+
/**
|
|
572
|
+
* ref methods (ref.current.instance.*method*)
|
|
573
|
+
*
|
|
574
|
+
* * onChangePage(page): Change page number
|
|
575
|
+
* * @param {page} - number
|
|
576
|
+
* * onChangePerPage(per): Change quantity on per page
|
|
577
|
+
* * @param {per} - number
|
|
578
|
+
* * setTotalItems(items): Set total items
|
|
579
|
+
* * @param {items} - number
|
|
642
580
|
*/
|
|
643
581
|
reference: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
644
582
|
current: PropTypes.instanceOf(Element)
|