diginet-core-ui 1.4.55 → 1.4.56-beta.2
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/dhr/MHRP29N0033.svg +18 -0
- package/assets/images/menu/dhr/MHRP29N0034.svg +18 -0
- package/components/accordion/details.js +1 -1
- package/components/accordion/group.js +1 -1
- package/components/accordion/index.js +1 -1
- package/components/accordion/summary.js +1 -1
- package/components/alert/index.js +1 -1
- package/components/alert/notify.js +1 -1
- package/components/avatar/index.js +2 -2
- package/components/badge/index.js +1 -1
- package/components/breadcrumb/index.js +1 -1
- package/components/button/icon.js +1 -1
- package/components/button/index.js +1 -1
- package/components/button/more.js +2 -2
- package/components/button/ripple-effect.js +1 -1
- package/components/card/body.js +1 -1
- package/components/card/extra.js +1 -1
- package/components/card/footer.js +1 -1
- package/components/card/header.js +1 -1
- package/components/card/index.js +1 -1
- package/components/chart/Pie/Circle.js +1 -1
- package/components/chart/Pie/Sector.js +1 -1
- package/components/chart/Pie/index.js +1 -1
- package/components/chart/Pie-v2/Circle.js +1 -1
- package/components/chart/Pie-v2/Sector.js +1 -1
- package/components/chart/Pie-v2/index.js +1 -1
- package/components/chart/bar/Bar.js +1 -1
- package/components/chart/bar/index.js +1 -1
- package/components/chart/bar-v2/Bar.js +1 -1
- package/components/chart/bar-v2/index.js +1 -1
- package/components/chart/line/index.js +1 -1
- package/components/chart/line-v2/index.js +1 -1
- package/components/check-text/index.js +1 -1
- package/components/check-text/interview-confirmation.js +1 -1
- package/components/check-text/interview-status.js +1 -1
- package/components/chip/index.js +1 -1
- package/components/collapse/index.js +1 -1
- package/components/divider/index.js +1 -1
- package/components/form-control/attachment/index.js +22 -22
- package/components/form-control/calendar/function.js +1 -1
- package/components/form-control/calendar/index.js +2 -2
- package/components/form-control/calendar/range.js +1 -1
- package/components/form-control/checkbox/index.js +1 -1
- package/components/form-control/control/index.js +1 -1
- package/components/form-control/date-input/index.js +1 -1
- package/components/form-control/date-picker/index.js +1 -1
- package/components/form-control/date-range-picker/index.js +154 -23
- package/components/form-control/dropdown/index.js +84 -25
- package/components/form-control/dropdown-box/index.js +64 -22
- package/components/form-control/form-group/index.js +1 -1
- package/components/form-control/helper-text/index.js +1 -1
- package/components/form-control/input-base/UncontrolledInputBase.js +1 -1
- package/components/form-control/input-base/index.js +1 -1
- package/components/form-control/label/index.js +1 -1
- package/components/form-control/money-input/index.js +1 -1
- package/components/form-control/number-input/index2.js +10 -4
- package/components/form-control/password-input/index.js +1 -1
- package/components/form-control/phone-input/index.js +1 -1
- package/components/form-control/radio/index.js +1 -1
- package/components/form-control/text-input/index.js +1 -1
- package/components/form-control/time-picker/index.js +1 -1
- package/components/form-control/time-picker/v2/index.js +1 -1
- package/components/form-control/toggle/index.js +1 -1
- package/components/form-view/input.js +1 -1
- package/components/grid/index.js +1 -1
- package/components/image/index.js +1 -1
- package/components/list/list-item-action.js +1 -1
- package/components/list/list-item-icon.js +1 -1
- package/components/list/list-item-text.js +1 -1
- package/components/list/list-item.js +1 -1
- package/components/list/list.js +1 -1
- package/components/list/sub-header.js +1 -1
- package/components/modal/body.js +1 -1
- package/components/modal/footer.js +1 -1
- package/components/modal/header.js +1 -1
- package/components/modal/index.js +1 -1
- package/components/modal/modal.js +1 -1
- package/components/others/option-wrapper/index.js +1 -1
- package/components/paging/page-info.js +35 -35
- package/components/paging/page-selector.js +1 -1
- package/components/paper/index.js +1 -1
- package/components/popover/body.js +1 -1
- package/components/popover/footer.js +1 -1
- package/components/popover/header.js +1 -1
- package/components/popover/index.js +14 -14
- package/components/popup/index.js +1 -1
- package/components/popup/v2/index.js +1 -1
- package/components/progress/circular.js +1 -1
- package/components/progress/linear.js +1 -1
- package/components/rating/index.js +1 -1
- package/components/skeleton/index.js +1 -1
- package/components/slider/slider-container.js +1 -1
- package/components/slider/slider-item.js +1 -1
- package/components/status/index.js +1 -1
- package/components/tab/tab-container.js +1 -1
- package/components/tab/tab-header.js +1 -1
- package/components/tab/tab-panel.js +1 -1
- package/components/tab/tab.js +1 -1
- package/components/tooltip/index.js +1 -1
- package/components/transfer/index.js +1 -1
- package/components/tree-view/index.js +1 -1
- package/components/typography/index.js +1 -1
- package/icons/basic.js +26 -0
- package/icons/effect.js +1 -1
- package/icons/menu/v2/index.js +1 -1
- package/package.json +78 -44
- package/readme.md +7 -0
- package/utils/type.js +29 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
/** @jsx jsx */
|
|
3
3
|
import { css, jsx } from '@emotion/core';
|
|
4
|
-
import { Button, ButtonIcon, Divider, HelperText, InputBase, Label, Typography } from "../..";
|
|
4
|
+
import { Button, ButtonIcon, Divider, HelperText, InputBase, Label, Typography, CircularProgress, Popover } from "../..";
|
|
5
5
|
import { getGlobal } from "../../../global";
|
|
6
6
|
import locale from "../../../locale";
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import { forwardRef, memo, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
9
9
|
import { render } from 'react-dom';
|
|
10
|
-
import { bgColor, borderRadius4px, cursorPointer, displayBlock, displayFlex, displayNone, flexCol, flexRow, invisible, justifyBetween, justifyEnd, itemsCenter, left, parseHeight, parseMaxWidth, parseMinWidth, parseWidth, pointerEventsNone, positionFixed, shadowLarge, textCenter, top, userSelectNone, whiteSpaceNoWrap, z } from "../../../styles/general";
|
|
10
|
+
import { bgColor, borderRadius4px, cursorPointer, displayBlock, displayFlex, displayNone, flexCol, flexRow, invisible, justifyBetween, justifyEnd, itemsCenter, left, parseHeight, parseMaxWidth, parseMinWidth, parseWidth, pointerEventsNone, positionFixed, shadowLarge, textCenter, top, userSelectNone, whiteSpaceNoWrap, z, justifyCenter, positionAbsolute, borderRadius, parseWidthHeight } from "../../../styles/general";
|
|
11
11
|
import { useTheme } from "../../../theme";
|
|
12
12
|
import { capitalizeSentenceCase, classNames, isEqual, date as moment, randomString, updatePosition } from "../../../utils";
|
|
13
13
|
import { getColor } from "../../../styles/utils";
|
|
@@ -66,7 +66,7 @@ const isAfter = (max, time) => {
|
|
|
66
66
|
const parseDate = day => {
|
|
67
67
|
return Date.parse(new Date(day));
|
|
68
68
|
};
|
|
69
|
-
const DateRangePicker = /*#__PURE__*/memo(
|
|
69
|
+
const DateRangePicker = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((inProps, reference) => {
|
|
70
70
|
var _periodOptions$dataSo;
|
|
71
71
|
// props priority: `inProps` > `themeDefaultProps`
|
|
72
72
|
const props = useThemeProps({
|
|
@@ -131,9 +131,15 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
|
|
|
131
131
|
const [, setValueFr] = useState(Date.now());
|
|
132
132
|
const [, setValueTo] = useState(Date.now());
|
|
133
133
|
const [, setSelected] = useState(Date.now());
|
|
134
|
+
const [loadingState, setLoadingState] = useState(periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.loading);
|
|
135
|
+
const [totalState, setTotalState] = useState(periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.total);
|
|
136
|
+
const [dataSourceState, setDataSourceState] = useState((periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.dataSource) || []);
|
|
137
|
+
const [openState, setOpenState] = useState(false);
|
|
134
138
|
const selectedPeriodRef = useRef('');
|
|
135
139
|
const selectedPeriodIndex = useRef(null);
|
|
136
140
|
const focusBtnRef = useRef('today');
|
|
141
|
+
const loadMoreTimer = useRef(null);
|
|
142
|
+
const dropdownListRef = useRef(null);
|
|
137
143
|
const [valueState, setValueState] = useState();
|
|
138
144
|
const navigatorFromRefs = {
|
|
139
145
|
doubleLeft: useRef(null),
|
|
@@ -218,6 +224,8 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
|
|
|
218
224
|
const onDayClick = e => {
|
|
219
225
|
const el = e.currentTarget;
|
|
220
226
|
const v = parseInt(el.dataset.time, 10);
|
|
227
|
+
selectedPeriodRef.current = '';
|
|
228
|
+
focusBtnRef.current = '';
|
|
221
229
|
if (values.current.length === 0) {
|
|
222
230
|
//push
|
|
223
231
|
el.classList.add(unique.day.active);
|
|
@@ -520,7 +528,8 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
|
|
|
520
528
|
const setButtonState = () => {
|
|
521
529
|
const isVisible = isEqual(values.current, tempValues.current);
|
|
522
530
|
const query = function (selector) {
|
|
523
|
-
|
|
531
|
+
var _footerRef$current;
|
|
532
|
+
return (_footerRef$current = footerRef.current) === null || _footerRef$current === void 0 ? void 0 : _footerRef$current.querySelector(selector);
|
|
524
533
|
};
|
|
525
534
|
const close = query(`.${unique.close}`);
|
|
526
535
|
const cancel = query(`.${unique.cancel}`);
|
|
@@ -534,19 +543,20 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
|
|
|
534
543
|
visibility: 'visible'
|
|
535
544
|
};
|
|
536
545
|
if (isVisible) {
|
|
537
|
-
Object.assign(close.style, visible);
|
|
538
|
-
Object.assign(cancel.style, hidden);
|
|
539
|
-
Object.assign(confirm.style, hidden);
|
|
546
|
+
Object.assign((close === null || close === void 0 ? void 0 : close.style) || {}, visible);
|
|
547
|
+
Object.assign((cancel === null || cancel === void 0 ? void 0 : cancel.style) || {}, hidden);
|
|
548
|
+
Object.assign((confirm === null || confirm === void 0 ? void 0 : confirm.style) || {}, hidden);
|
|
540
549
|
} else {
|
|
541
|
-
Object.assign(cancel.style, visible);
|
|
542
|
-
Object.assign(confirm.style, visible);
|
|
543
|
-
Object.assign(close.style, hidden);
|
|
550
|
+
Object.assign((cancel === null || cancel === void 0 ? void 0 : cancel.style) || {}, visible);
|
|
551
|
+
Object.assign((confirm === null || confirm === void 0 ? void 0 : confirm.style) || {}, visible);
|
|
552
|
+
Object.assign((close === null || close === void 0 ? void 0 : close.style) || {}, hidden);
|
|
544
553
|
}
|
|
545
554
|
};
|
|
546
555
|
const onCancel = () => {
|
|
547
556
|
updateValues(tempValues.current);
|
|
548
557
|
setButtonState();
|
|
549
558
|
closePicker();
|
|
559
|
+
setOpenState(false);
|
|
550
560
|
};
|
|
551
561
|
const onConfirm = () => {
|
|
552
562
|
setButtonState();
|
|
@@ -556,6 +566,7 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
|
|
|
556
566
|
onChangeValue(values.current);
|
|
557
567
|
}
|
|
558
568
|
closePicker();
|
|
569
|
+
setOpenState(false);
|
|
559
570
|
};
|
|
560
571
|
const onSwap = open => {
|
|
561
572
|
if (!isEnable) return;
|
|
@@ -701,6 +712,22 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
|
|
|
701
712
|
controls && setButtonState();
|
|
702
713
|
});
|
|
703
714
|
};
|
|
715
|
+
const openPeriodPicker = () => {
|
|
716
|
+
// const arr = pickerRef.current.getElementsByTagName('td');
|
|
717
|
+
updateTempValues(values.current.length === 1 ? [values.current[0], values.current[0]] : values.current);
|
|
718
|
+
setOpenState(true);
|
|
719
|
+
setTimeout(() => {
|
|
720
|
+
renderPicker();
|
|
721
|
+
// pickerRef.current.addEventListener('mouseover', e => onPickerHover(e, arr));
|
|
722
|
+
window.addEventListener('resize', onResize);
|
|
723
|
+
window.addEventListener('scroll', onScroll);
|
|
724
|
+
document.addEventListener('mousedown', onClickOutside);
|
|
725
|
+
if (pressESCToClose) {
|
|
726
|
+
document.addEventListener('keydown', pressESCHandler);
|
|
727
|
+
}
|
|
728
|
+
controls && setButtonState();
|
|
729
|
+
});
|
|
730
|
+
};
|
|
704
731
|
const closePicker = () => {
|
|
705
732
|
const backGr = document.getElementById(unique.backGr);
|
|
706
733
|
if (!backGr) return;
|
|
@@ -725,10 +752,12 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
|
|
|
725
752
|
}
|
|
726
753
|
ipRef.current && ipRef.current.blur();
|
|
727
754
|
updateTempValues([]);
|
|
755
|
+
setOpenState(false);
|
|
728
756
|
};
|
|
729
757
|
const onClickOutside = e => {
|
|
730
758
|
if (ipConRef.current && !ipConRef.current.contains(e.target) && ipRef.current && !ipRef.current.contains(e.target) && pickerRef.current && !pickerRef.current.contains(e.target)) {
|
|
731
759
|
controls ? onCancel() : closePicker();
|
|
760
|
+
setOpenState(false);
|
|
732
761
|
}
|
|
733
762
|
};
|
|
734
763
|
const triggerFocus = () => {
|
|
@@ -743,9 +772,13 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
|
|
|
743
772
|
const onInputFocus = () => {
|
|
744
773
|
if (!isEnable) return;
|
|
745
774
|
const el = ipConRef.current;
|
|
746
|
-
if (
|
|
747
|
-
|
|
748
|
-
|
|
775
|
+
if ((periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.enable) === true) {
|
|
776
|
+
openPeriodPicker();
|
|
777
|
+
} else {
|
|
778
|
+
if (!el.classList.contains(unique.focus)) {
|
|
779
|
+
el.classList.add(unique.focus);
|
|
780
|
+
openPicker();
|
|
781
|
+
}
|
|
749
782
|
}
|
|
750
783
|
};
|
|
751
784
|
const setInputValue = (time, reset, unshift = false) => {
|
|
@@ -806,8 +839,8 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
|
|
|
806
839
|
const firstday = new Date(currentDay.setDate(first)).setHours(0, 0, 0);
|
|
807
840
|
const lastday = new Date(currentDay.setDate(last)).setHours(0, 0, 0);
|
|
808
841
|
value = [firstday.valueOf(), lastday.valueOf()];
|
|
809
|
-
valueFr.current = firstday;
|
|
810
|
-
valueTo.current = lastday;
|
|
842
|
+
valueFr.current = new Date(firstday);
|
|
843
|
+
valueTo.current = new Date(lastday);
|
|
811
844
|
break;
|
|
812
845
|
}
|
|
813
846
|
case 'thisMonth':
|
|
@@ -830,8 +863,8 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
|
|
|
830
863
|
lastday = new Date(lastDayArray[2], lastDayArray[1], lastDayArray[0]);
|
|
831
864
|
}
|
|
832
865
|
value = [firstday.valueOf(), lastday.valueOf()];
|
|
833
|
-
valueFr.current = firstday;
|
|
834
|
-
valueTo.current = lastday;
|
|
866
|
+
valueFr.current = new Date(firstday);
|
|
867
|
+
valueTo.current = new Date(lastday);
|
|
835
868
|
selectedPeriodIndex.current = `period${periodData === null || periodData === void 0 ? void 0 : periodData.idx}`;
|
|
836
869
|
selectedPeriodRef.current = periodData === null || periodData === void 0 ? void 0 : periodData[periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.displayExpr];
|
|
837
870
|
document.getElementById(selectedPeriodIndex.current).style.background = getColor('fill/hover');
|
|
@@ -915,6 +948,15 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
|
|
|
915
948
|
closePicker();
|
|
916
949
|
};
|
|
917
950
|
}, [actionIconAt, clearAble, controls, disabled, displayFormat, max, min, pressESCToClose, readOnly, startFromZero, unitCount, viewType]);
|
|
951
|
+
useEffect(() => {
|
|
952
|
+
setLoadingState(periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.loading);
|
|
953
|
+
}, [periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.loading]);
|
|
954
|
+
useEffect(() => {
|
|
955
|
+
setTotalState(periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.total);
|
|
956
|
+
}, [periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.total]);
|
|
957
|
+
useEffect(() => {
|
|
958
|
+
setDataSourceState((periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.dataSource) || []);
|
|
959
|
+
}, [periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.dataSource]);
|
|
918
960
|
useImperativeHandle(reference, () => {
|
|
919
961
|
const currentRef = ref.current || {};
|
|
920
962
|
currentRef.element = ref.current;
|
|
@@ -1030,6 +1072,33 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
|
|
|
1030
1072
|
className: unique.table.table,
|
|
1031
1073
|
ref: tableToRef
|
|
1032
1074
|
}, renderHeader(unique), jsx("tbody", null))));
|
|
1075
|
+
const onLoadMoreHandler = e => {
|
|
1076
|
+
e.persist();
|
|
1077
|
+
if (loadMoreTimer.current) {
|
|
1078
|
+
clearTimeout(loadMoreTimer.current);
|
|
1079
|
+
}
|
|
1080
|
+
const {
|
|
1081
|
+
onLoadMore,
|
|
1082
|
+
limit
|
|
1083
|
+
} = periodOptions;
|
|
1084
|
+
loadMoreTimer.current = setTimeout(() => {
|
|
1085
|
+
if (onLoadMore && (dataSourceState === null || dataSourceState === void 0 ? void 0 : dataSourceState.length) < totalState && !loadingState) {
|
|
1086
|
+
const {
|
|
1087
|
+
scrollTop,
|
|
1088
|
+
scrollHeight,
|
|
1089
|
+
offsetHeight
|
|
1090
|
+
} = e.target;
|
|
1091
|
+
if (scrollHeight <= Math.ceil(scrollTop + 2) + offsetHeight && dropdownListRef.current) {
|
|
1092
|
+
var _dropdownListRef$curr;
|
|
1093
|
+
const length = (_dropdownListRef$curr = dropdownListRef.current.children) === null || _dropdownListRef$curr === void 0 ? void 0 : _dropdownListRef$curr.length;
|
|
1094
|
+
!!onLoadMore && onLoadMore({
|
|
1095
|
+
skip: length,
|
|
1096
|
+
limit: limit
|
|
1097
|
+
});
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
}, 300);
|
|
1101
|
+
};
|
|
1033
1102
|
const rightCalendarPeriodComp = jsx("div", {
|
|
1034
1103
|
css: _PeriodContainerCSS
|
|
1035
1104
|
}, jsx(Typography, {
|
|
@@ -1038,7 +1107,20 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
|
|
|
1038
1107
|
style: {
|
|
1039
1108
|
marginBottom: 8
|
|
1040
1109
|
}
|
|
1041
|
-
}, selectPeriodText),
|
|
1110
|
+
}, selectPeriodText), loadingState ? jsx("div", {
|
|
1111
|
+
css: LoadingProgressCSS,
|
|
1112
|
+
className: 'DGN-Dropdown-Loading-Progress'
|
|
1113
|
+
}, jsx(CircularProgress, {
|
|
1114
|
+
size: 24
|
|
1115
|
+
})) : null, jsx("div", {
|
|
1116
|
+
style: {
|
|
1117
|
+
width: '100%',
|
|
1118
|
+
maxHeight: 175,
|
|
1119
|
+
overflowY: 'scroll'
|
|
1120
|
+
},
|
|
1121
|
+
ref: dropdownListRef,
|
|
1122
|
+
onScroll: onLoadMoreHandler
|
|
1123
|
+
}, periodOptions === null || periodOptions === void 0 ? void 0 : (_periodOptions$dataSo = periodOptions.dataSource) === null || _periodOptions$dataSo === void 0 ? void 0 : _periodOptions$dataSo.map((p, idx) => {
|
|
1042
1124
|
const isSelected = (p === null || p === void 0 ? void 0 : p[periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.displayExpr]) === selectedPeriodRef.current;
|
|
1043
1125
|
return jsx("div", {
|
|
1044
1126
|
id: `period${idx}`,
|
|
@@ -1055,7 +1137,7 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
|
|
|
1055
1137
|
color: 'inherit',
|
|
1056
1138
|
type: 'p1'
|
|
1057
1139
|
}, p === null || p === void 0 ? void 0 : p[periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.displayExpr]));
|
|
1058
|
-
}));
|
|
1140
|
+
})));
|
|
1059
1141
|
const tooltipComp = jsx("div", {
|
|
1060
1142
|
className: unique.tooltip,
|
|
1061
1143
|
ref: tooltipRef
|
|
@@ -1087,7 +1169,40 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
|
|
|
1087
1169
|
...labelProps,
|
|
1088
1170
|
disabled: disabled,
|
|
1089
1171
|
required: required
|
|
1090
|
-
}, label) : null, jsx(
|
|
1172
|
+
}, label) : null, periodOptions !== null && periodOptions !== void 0 && periodOptions.enable ? jsx(Popover, {
|
|
1173
|
+
open: openState,
|
|
1174
|
+
className: 'DGN-UI-Popover-Period',
|
|
1175
|
+
anchorOrigin: {
|
|
1176
|
+
horizontal: 'left',
|
|
1177
|
+
vertical: 'bottom'
|
|
1178
|
+
},
|
|
1179
|
+
anchor: jsx("div", null, jsx(InputBase, {
|
|
1180
|
+
inputProps: {
|
|
1181
|
+
placeholder: !readOnly && !disabled ? placeholder : '',
|
|
1182
|
+
...inputProps
|
|
1183
|
+
},
|
|
1184
|
+
readOnly: true,
|
|
1185
|
+
ref: ipConRef,
|
|
1186
|
+
inputRef: ipRef,
|
|
1187
|
+
disabled: disabled,
|
|
1188
|
+
viewType: viewType,
|
|
1189
|
+
inputStyle: {
|
|
1190
|
+
textAlign: textAlign,
|
|
1191
|
+
textOverflow: 'ellipsis',
|
|
1192
|
+
...inputStyle
|
|
1193
|
+
},
|
|
1194
|
+
startIcon: startIcon,
|
|
1195
|
+
startIconProps: {
|
|
1196
|
+
className: 'non-effect allow-disabled'
|
|
1197
|
+
},
|
|
1198
|
+
endIcon: endIcon,
|
|
1199
|
+
value: valueState
|
|
1200
|
+
}), error ? jsx(HelperText, {
|
|
1201
|
+
...helperTextProps,
|
|
1202
|
+
disabled: disabled
|
|
1203
|
+
}, error) : null),
|
|
1204
|
+
onOpen: openPeriodPicker
|
|
1205
|
+
}, pickerComp) : jsx("div", null, jsx(InputBase, {
|
|
1091
1206
|
inputProps: {
|
|
1092
1207
|
placeholder: !readOnly && !disabled ? placeholder : '',
|
|
1093
1208
|
...inputProps
|
|
@@ -1112,7 +1227,7 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
|
|
|
1112
1227
|
}), error ? jsx(HelperText, {
|
|
1113
1228
|
...helperTextProps,
|
|
1114
1229
|
disabled: disabled
|
|
1115
|
-
}, error) : null);
|
|
1230
|
+
}, error) : null));
|
|
1116
1231
|
}));
|
|
1117
1232
|
const unique = {
|
|
1118
1233
|
backGr: 'DGN-UI-Portal',
|
|
@@ -1304,7 +1419,18 @@ const pickerCSS = {
|
|
|
1304
1419
|
transform: 'scale(0)'
|
|
1305
1420
|
}
|
|
1306
1421
|
};
|
|
1307
|
-
|
|
1422
|
+
const LoadingProgressCSS = css`
|
|
1423
|
+
${displayFlex};
|
|
1424
|
+
${flexRow};
|
|
1425
|
+
${justifyCenter};
|
|
1426
|
+
${itemsCenter};
|
|
1427
|
+
${positionAbsolute};
|
|
1428
|
+
${borderRadius(4)};
|
|
1429
|
+
${parseWidthHeight('100%')}
|
|
1430
|
+
${bgColor('rgba(255, 255, 255, 0.6)')};
|
|
1431
|
+
${z(2)};
|
|
1432
|
+
${top(0)};
|
|
1433
|
+
`;
|
|
1308
1434
|
// DateRangePicker.defaultProps = {
|
|
1309
1435
|
// actionIconAt: 'end',
|
|
1310
1436
|
// clearAble: false,
|
|
@@ -1365,7 +1491,12 @@ DateRangePicker.propTypes = {
|
|
|
1365
1491
|
* displayExpr: "DisplayName",
|
|
1366
1492
|
* valueFromExpr: "DateFrom",
|
|
1367
1493
|
* valueToExpr: "DateTo",
|
|
1368
|
-
* valueFormat: "DD/MM/YYYY"
|
|
1494
|
+
* valueFormat: "DD/MM/YYYY",
|
|
1495
|
+
* limit: 5,
|
|
1496
|
+
* skip: 0,
|
|
1497
|
+
* total: 100,
|
|
1498
|
+
* onLoadMore: () => {},
|
|
1499
|
+
* loading: false
|
|
1369
1500
|
* }
|
|
1370
1501
|
*/
|
|
1371
1502
|
periodOptions: PropTypes.object,
|
|
@@ -11,6 +11,7 @@ import { animation, bgColor, border, borderBottom, borderBottomColor, borderColo
|
|
|
11
11
|
import { useTheme } from "../../../theme";
|
|
12
12
|
import useThemeProps from "../../../theme/utils/useThemeProps";
|
|
13
13
|
import { classNames, getProp, isMobile, randomString } from "../../../utils";
|
|
14
|
+
import { isEmpty, typeOf } from "../../../utils/type";
|
|
14
15
|
const currentValue = {},
|
|
15
16
|
isSearch = {},
|
|
16
17
|
allValue = {};
|
|
@@ -47,7 +48,7 @@ const uniqBy = (arr, iteratee) => {
|
|
|
47
48
|
return true;
|
|
48
49
|
});
|
|
49
50
|
};
|
|
50
|
-
const Dropdown = /*#__PURE__*/memo(
|
|
51
|
+
const Dropdown = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((inProps, reference) => {
|
|
51
52
|
if (!reference) reference = useRef(null);
|
|
52
53
|
const theme = useTheme();
|
|
53
54
|
const {
|
|
@@ -135,6 +136,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
|
|
|
135
136
|
const loadMoreTimer = useRef(null);
|
|
136
137
|
const dataChosen = useRef([]);
|
|
137
138
|
const popupRef = useRef(null);
|
|
139
|
+
const valueObjectDefaultInit = useRef({});
|
|
138
140
|
const filter = useRef({
|
|
139
141
|
skip: skip || 0,
|
|
140
142
|
limit: limit || 50
|
|
@@ -322,8 +324,9 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
|
|
|
322
324
|
let text = '';
|
|
323
325
|
let isReplace = true;
|
|
324
326
|
if (data || data === 0) {
|
|
327
|
+
var _data$displayExpr;
|
|
325
328
|
displayExpr = displayExpr || valueExpr;
|
|
326
|
-
let mask = data === null || data === void 0 ? void 0 : data[displayExpr];
|
|
329
|
+
let mask = typeOf(data === null || data === void 0 ? void 0 : data[displayExpr], 'array') ? ((_data$displayExpr = data[displayExpr]) === null || _data$displayExpr === void 0 ? void 0 : _data$displayExpr[0]) || '' : data === null || data === void 0 ? void 0 : data[displayExpr];
|
|
327
330
|
// convert {id} - {name} to {<data[id]>} - {<data[name]>}
|
|
328
331
|
if (selectAll && (data === null || data === void 0 ? void 0 : data[valueExpr]) === 'all') {
|
|
329
332
|
isReplace = false;
|
|
@@ -342,6 +345,43 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
|
|
|
342
345
|
var _dataSourceUsable2;
|
|
343
346
|
const items = [];
|
|
344
347
|
let dataSourceUsable = [...dataSourceState];
|
|
348
|
+
if (vlObjDefaultState && (vlObjDefaultState === null || vlObjDefaultState === void 0 ? void 0 : vlObjDefaultState.length) > 0 && isEmpty(txtSearch)) {
|
|
349
|
+
// Sẽ Xem Lại
|
|
350
|
+
// if (vlObjDefaultState && vlObjDefaultState?.length > 0) {
|
|
351
|
+
const length = vlObjDefaultState === null || vlObjDefaultState === void 0 ? void 0 : vlObjDefaultState.length;
|
|
352
|
+
let existItemQuantity = 0;
|
|
353
|
+
for (let index = length - 1; index >= 0; index--) {
|
|
354
|
+
if ((vlObjDefaultState[index][valueExpr] || vlObjDefaultState[index][valueExpr] === 0) && !dataSourceUsable.some(data => data[valueExpr] === vlObjDefaultState[index][valueExpr])) {
|
|
355
|
+
if (isMultipleVal(vlObjDefaultState[index])) {
|
|
356
|
+
if (isEmpty(valueObjectDefaultInit.current)) {
|
|
357
|
+
let dataCloneDeep = {};
|
|
358
|
+
for (const name in vlObjDefaultState[index]) {
|
|
359
|
+
var _vlObjDefaultState$in;
|
|
360
|
+
if (name) dataCloneDeep[name] = (((_vlObjDefaultState$in = vlObjDefaultState[index]) === null || _vlObjDefaultState$in === void 0 ? void 0 : _vlObjDefaultState$in[name]) || []).map(item => item);
|
|
361
|
+
}
|
|
362
|
+
if (!isEmpty(dataCloneDeep)) valueObjectDefaultInit.current = dataCloneDeep;
|
|
363
|
+
const valueObjectDefaultOrigin = {
|
|
364
|
+
...valueObjectDefaultInit.current
|
|
365
|
+
} || {};
|
|
366
|
+
const arr = (valueObjectDefaultOrigin === null || valueObjectDefaultOrigin === void 0 ? void 0 : valueObjectDefaultOrigin[valueExpr]) || [];
|
|
367
|
+
for (let i = 0; i < arr.length; i++) {
|
|
368
|
+
let objData = {};
|
|
369
|
+
for (const name in valueObjectDefaultOrigin) {
|
|
370
|
+
var _valueObjectDefaultOr;
|
|
371
|
+
if (name) objData[name] = (valueObjectDefaultOrigin === null || valueObjectDefaultOrigin === void 0 ? void 0 : (_valueObjectDefaultOr = valueObjectDefaultOrigin[name]) === null || _valueObjectDefaultOr === void 0 ? void 0 : _valueObjectDefaultOr[i]) || '';
|
|
372
|
+
}
|
|
373
|
+
dataSourceUsable.unshift(objData);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
} else dataSourceUsable.unshift(vlObjDefaultState[index]);
|
|
377
|
+
} else {
|
|
378
|
+
// Nếu số lượng phần tử của valueObjectDefault tồn tại trong dataSource nhiều hơn hoặc bằng limit thì không remove nữa
|
|
379
|
+
if (++existItemQuantity > limit) {
|
|
380
|
+
continue;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
345
385
|
|
|
346
386
|
// search dataSource dựa trên txtSearch
|
|
347
387
|
if (!onInput) {
|
|
@@ -358,20 +398,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
|
|
|
358
398
|
});
|
|
359
399
|
}
|
|
360
400
|
}
|
|
361
|
-
if (vlObjDefaultState && (vlObjDefaultState === null || vlObjDefaultState === void 0 ? void 0 : vlObjDefaultState.length) > 0) {
|
|
362
|
-
const length = vlObjDefaultState === null || vlObjDefaultState === void 0 ? void 0 : vlObjDefaultState.length;
|
|
363
|
-
let existItemQuantity = 0;
|
|
364
|
-
for (let index = length - 1; index >= 0; index--) {
|
|
365
|
-
if ((vlObjDefaultState[index][valueExpr] || vlObjDefaultState[index][valueExpr] === 0) && !dataSourceUsable.some(data => data[valueExpr] === vlObjDefaultState[index][valueExpr])) {
|
|
366
|
-
dataSourceUsable.unshift(vlObjDefaultState[index]);
|
|
367
|
-
} else {
|
|
368
|
-
// Nếu số lượng phần tử của valueObjectDefault tồn tại trong dataSource nhiều hơn hoặc bằng limit thì không remove nữa
|
|
369
|
-
if (++existItemQuantity > limit) {
|
|
370
|
-
continue;
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
401
|
const length = (_dataSourceUsable2 = dataSourceUsable) === null || _dataSourceUsable2 === void 0 ? void 0 : _dataSourceUsable2.length;
|
|
376
402
|
for (let index = 0; index < length; index++) {
|
|
377
403
|
const data = dataSourceUsable[index];
|
|
@@ -399,10 +425,11 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
|
|
|
399
425
|
data,
|
|
400
426
|
index
|
|
401
427
|
}) : jsx(Typography, {
|
|
428
|
+
lineClamp: 1,
|
|
402
429
|
type: 'p1'
|
|
403
430
|
}, displayText);
|
|
404
431
|
if (multiple && selectBox) {
|
|
405
|
-
let checked = valueMulti.includes(value);
|
|
432
|
+
let checked = typeOf(value, 'array') ? valueMulti.some(item => value.includes(item)) : valueMulti.includes(value);
|
|
406
433
|
if (selectAll && value === 'all') checked = selectAll && value === 'all' && valueMulti.length > 0;
|
|
407
434
|
const isMaximumSelection = maximumSelectionLength === (valueMulti === null || valueMulti === void 0 ? void 0 : valueMulti.length);
|
|
408
435
|
itemDisabled = itemDisabled || isMaximumSelection && !checked;
|
|
@@ -423,7 +450,12 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
|
|
|
423
450
|
value: value,
|
|
424
451
|
disabled: itemDisabled,
|
|
425
452
|
onChange: e => onChangeValue(e, displayText, value, icon, data, index)
|
|
426
|
-
},
|
|
453
|
+
}, jsx("div", {
|
|
454
|
+
style: {
|
|
455
|
+
display: 'flex',
|
|
456
|
+
alignItems: 'center'
|
|
457
|
+
}
|
|
458
|
+
}, icon, text))));
|
|
427
459
|
} else {
|
|
428
460
|
items.push(jsx("div", {
|
|
429
461
|
key: index,
|
|
@@ -486,7 +518,9 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
|
|
|
486
518
|
const dataSourceUsable = [...dataSourceState];
|
|
487
519
|
// Nếu có load more thì đẩy đội tượng mặc định lên đầu
|
|
488
520
|
let notExistItem = 0;
|
|
489
|
-
if (onLoadMore && vlObjDefaultState !== null && vlObjDefaultState !== void 0 && vlObjDefaultState.length) {
|
|
521
|
+
if (onLoadMore && vlObjDefaultState !== null && vlObjDefaultState !== void 0 && vlObjDefaultState.length && isEmpty(txtSearch)) {
|
|
522
|
+
// Sẽ Xem Lại
|
|
523
|
+
// if (onLoadMore && vlObjDefaultState?.length) {
|
|
490
524
|
const length = vlObjDefaultState.length;
|
|
491
525
|
for (let index = length - 1; index >= 0; index--) {
|
|
492
526
|
if (!dataSourceUsable.some(data => data[valueExpr] === vlObjDefaultState[index][valueExpr])) {
|
|
@@ -550,7 +584,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
|
|
|
550
584
|
} else {
|
|
551
585
|
item = jsx(Fragment, null, icon, text);
|
|
552
586
|
}
|
|
553
|
-
if (!dropdownListRef.current) {
|
|
587
|
+
if (!dropdownListRef.current || isEmpty(txtSearch)) {
|
|
554
588
|
return;
|
|
555
589
|
}
|
|
556
590
|
ReactDOM.render(item, dropdownListRef.current.appendChild(dropdownItem));
|
|
@@ -997,7 +1031,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
|
|
|
997
1031
|
if (valueProp !== undefined && (!dropdownListRef.current || children || JSON.stringify(valueProp) !== JSON.stringify(currentValue[unique]))) {
|
|
998
1032
|
setValueIntoInput(valueProp);
|
|
999
1033
|
if (oneLiner && multiple) {
|
|
1000
|
-
const valueArray = sortMultiple(valueProp);
|
|
1034
|
+
const valueArray = sortMultiple(valueProp, true);
|
|
1001
1035
|
setValueMultiDisplay(valueArray === null || valueArray === void 0 ? void 0 : valueArray.display);
|
|
1002
1036
|
setValueMultiOverflow(valueArray === null || valueArray === void 0 ? void 0 : valueArray.overflow);
|
|
1003
1037
|
if ((valueArray === null || valueArray === void 0 ? void 0 : valueArray.overflow.length) === 0 && openMultipleOverflow) {
|
|
@@ -1098,9 +1132,34 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
|
|
|
1098
1132
|
disabled: disabled,
|
|
1099
1133
|
...labelProps
|
|
1100
1134
|
}, label) : null, [label, required, disabled, labelProps]);
|
|
1135
|
+
const isMultipleVal = (objData = {}) => {
|
|
1136
|
+
let status = false;
|
|
1137
|
+
if (typeOf(objData === null || objData === void 0 ? void 0 : objData[valueExpr], 'array') && !isEmpty(objData === null || objData === void 0 ? void 0 : objData[valueExpr]) || typeOf(objData === null || objData === void 0 ? void 0 : objData[displayExpr], 'array') && !isEmpty(objData === null || objData === void 0 ? void 0 : objData[displayExpr])) {
|
|
1138
|
+
status = true;
|
|
1139
|
+
}
|
|
1140
|
+
return status;
|
|
1141
|
+
};
|
|
1101
1142
|
const getData = () => {
|
|
1143
|
+
var _valObjDefault;
|
|
1102
1144
|
let dataFilter = JSON.parse(JSON.stringify(dataSourceState));
|
|
1103
|
-
|
|
1145
|
+
let valObjDefault = vlObjDefaultState;
|
|
1146
|
+
if (isMultipleVal((_valObjDefault = valObjDefault) === null || _valObjDefault === void 0 ? void 0 : _valObjDefault[0])) {
|
|
1147
|
+
var _vlObjDefaultState$;
|
|
1148
|
+
valObjDefault = [];
|
|
1149
|
+
const arr = (vlObjDefaultState === null || vlObjDefaultState === void 0 ? void 0 : (_vlObjDefaultState$ = vlObjDefaultState[0]) === null || _vlObjDefaultState$ === void 0 ? void 0 : _vlObjDefaultState$[valueExpr]) || [];
|
|
1150
|
+
for (let i = 0; i < arr.length; i++) {
|
|
1151
|
+
let objData = {};
|
|
1152
|
+
for (const name in vlObjDefaultState[0]) {
|
|
1153
|
+
var _vlObjDefaultState$2;
|
|
1154
|
+
if (name) objData[name] = (_vlObjDefaultState$2 = vlObjDefaultState[0]) === null || _vlObjDefaultState$2 === void 0 ? void 0 : _vlObjDefaultState$2[name][i];
|
|
1155
|
+
}
|
|
1156
|
+
if (!isEmpty(objData)) valObjDefault.push(objData);
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
dataFilter = uniqBy([...valObjDefault, ...dataFilter], data => {
|
|
1160
|
+
let result = data === null || data === void 0 ? void 0 : data[valueExpr];
|
|
1161
|
+
return result;
|
|
1162
|
+
});
|
|
1104
1163
|
return dataFilter;
|
|
1105
1164
|
};
|
|
1106
1165
|
const getTextWidth = text => {
|
|
@@ -1127,8 +1186,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
|
|
|
1127
1186
|
const inputWidth = inputElement === null || inputElement === void 0 ? void 0 : inputElement.clientWidth;
|
|
1128
1187
|
const items = [];
|
|
1129
1188
|
if ((valueMulti === null || valueMulti === void 0 ? void 0 : valueMulti.length) > 0) {
|
|
1189
|
+
const dataFilter = getData();
|
|
1130
1190
|
value.map((vl, index) => {
|
|
1131
|
-
const dataFilter = getData();
|
|
1132
1191
|
const data = dataFilter.find(v => v[valueExpr] === vl || v === vl);
|
|
1133
1192
|
if (data) {
|
|
1134
1193
|
const displayText = displayValue(data);
|
|
@@ -1181,8 +1240,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
|
|
|
1181
1240
|
const renderMultipleItem = value => {
|
|
1182
1241
|
const items = [];
|
|
1183
1242
|
if ((valueMulti === null || valueMulti === void 0 ? void 0 : valueMulti.length) > 0) {
|
|
1243
|
+
const dataFilter = getData();
|
|
1184
1244
|
value.map((vl, index) => {
|
|
1185
|
-
const dataFilter = getData();
|
|
1186
1245
|
const data = dataFilter.find(v => v[valueExpr] === vl || v === vl);
|
|
1187
1246
|
if (data) {
|
|
1188
1247
|
const displayText = displayValue(data);
|
|
@@ -1251,8 +1310,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
|
|
|
1251
1310
|
const renderOverflowPopover = value => {
|
|
1252
1311
|
const items = [];
|
|
1253
1312
|
if ((valueMulti === null || valueMulti === void 0 ? void 0 : valueMulti.length) > 0) {
|
|
1313
|
+
const dataFilter = getData();
|
|
1254
1314
|
value.map((vl, index) => {
|
|
1255
|
-
const dataFilter = getData();
|
|
1256
1315
|
const data = dataFilter.find(v => v[valueExpr] === vl || v === vl);
|
|
1257
1316
|
if (data) {
|
|
1258
1317
|
const displayText = displayValue(data);
|