diginet-core-ui 1.3.99 → 1.4.0
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/form-control/dropdown/index.js +33 -17
- package/package.json +1 -1
- package/readme.md +3 -0
|
@@ -33,6 +33,16 @@ const convertData = (dt, valueExpr) => {
|
|
|
33
33
|
valueTemp = valueTemp.map(i => i[valueExpr] || i);
|
|
34
34
|
return valueTemp;
|
|
35
35
|
};
|
|
36
|
+
const convertSearchDelayTime = searchDelayTime => {
|
|
37
|
+
var _searchDelayTime$matc, _searchDelayTime$matc2;
|
|
38
|
+
if (searchDelayTime === true) return getGlobal('delayOnInput');
|
|
39
|
+
const units = {
|
|
40
|
+
m: 60000,
|
|
41
|
+
s: 1000,
|
|
42
|
+
ms: 1
|
|
43
|
+
};
|
|
44
|
+
return typeof searchDelayTime === 'number' ? searchDelayTime : (((_searchDelayTime$matc = searchDelayTime.match(/[^a-z]+/i)) === null || _searchDelayTime$matc === void 0 ? void 0 : _searchDelayTime$matc[0]) || 1) * units[((_searchDelayTime$matc2 = searchDelayTime.match(/ms|s|m/i)) === null || _searchDelayTime$matc2 === void 0 ? void 0 : _searchDelayTime$matc2[0]) || 's'];
|
|
45
|
+
};
|
|
36
46
|
const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
37
47
|
action = {},
|
|
38
48
|
allowSearch,
|
|
@@ -86,6 +96,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
86
96
|
if (!reference) reference = useRef(null);
|
|
87
97
|
if (multiple && selectBox === undefined) selectBox = true;
|
|
88
98
|
if (typeof searchExpr === 'string') searchExpr = [searchExpr];
|
|
99
|
+
searchDelayTime = convertSearchDelayTime(searchDelayTime);
|
|
89
100
|
const ref = useRef(null);
|
|
90
101
|
const dropdownRef = useRef(null);
|
|
91
102
|
const timer = useRef(null);
|
|
@@ -96,7 +107,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
96
107
|
const dropdownListRef = useRef(null);
|
|
97
108
|
const searchRef = useRef(null);
|
|
98
109
|
// const lastSearchRef = useRef(null);
|
|
99
|
-
const timeout = useRef(null);
|
|
110
|
+
// const timeout = useRef(null);
|
|
100
111
|
const loadMoreTimer = useRef(null);
|
|
101
112
|
const dataChosen = useRef([]);
|
|
102
113
|
const [unique] = useState(randomString(6, {
|
|
@@ -848,7 +859,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
848
859
|
onInput === null || onInput === void 0 ? void 0 : onInput({
|
|
849
860
|
...(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current),
|
|
850
861
|
target: {
|
|
851
|
-
value:
|
|
862
|
+
value: ''
|
|
852
863
|
}
|
|
853
864
|
});
|
|
854
865
|
!!onChange && onChange({
|
|
@@ -1043,21 +1054,26 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1043
1054
|
closeDropdown();
|
|
1044
1055
|
};
|
|
1045
1056
|
}, []);
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1057
|
+
|
|
1058
|
+
// useEffect(() => {
|
|
1059
|
+
// if (searchDelayTime) {
|
|
1060
|
+
// if (searchDelayTime === true) searchDelayTime = getGlobal('delayOnInput');
|
|
1061
|
+
// const units = {
|
|
1062
|
+
// m: 60000,
|
|
1063
|
+
// s: 1000,
|
|
1064
|
+
// ms: 1,
|
|
1065
|
+
// };
|
|
1066
|
+
// timeout.current =
|
|
1067
|
+
// typeof searchDelayTime === 'number'
|
|
1068
|
+
// ? searchDelayTime
|
|
1069
|
+
// : (searchDelayTime.match(/[^a-z]+/i)?.[0] || 1) *
|
|
1070
|
+
// units[searchDelayTime.match(/ms|s|m/i)?.[0] || 's'];
|
|
1071
|
+
// return () => {
|
|
1072
|
+
// timeout.current = null;
|
|
1073
|
+
// };
|
|
1074
|
+
// }
|
|
1075
|
+
// }, [searchDelayTime]);
|
|
1076
|
+
|
|
1061
1077
|
useEffect(() => {
|
|
1062
1078
|
if (allValue[unique][allValue[unique].length - 1] !== valueProp) {
|
|
1063
1079
|
allValue[unique].push(valueProp);
|
package/package.json
CHANGED
package/readme.md
CHANGED