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.
@@ -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: inputRef === null || inputRef === void 0 ? void 0 : inputRef.current.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
- useEffect(() => {
1047
- if (searchDelayTime) {
1048
- var _searchDelayTime$matc, _searchDelayTime$matc2;
1049
- if (searchDelayTime === true) searchDelayTime = getGlobal('delayOnInput');
1050
- const units = {
1051
- m: 60000,
1052
- s: 1000,
1053
- ms: 1
1054
- };
1055
- timeout.current = 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'];
1056
- return () => {
1057
- timeout.current = null;
1058
- };
1059
- }
1060
- }, [searchDelayTime]);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diginet-core-ui",
3
- "version": "1.3.99",
3
+ "version": "1.4.0",
4
4
  "description": "The DigiNet core ui",
5
5
  "homepage": "https://diginet.com.vn",
6
6
  "main": "index.js",
package/readme.md CHANGED
@@ -38,6 +38,9 @@ npm test
38
38
  ```
39
39
 
40
40
  ## Changelog
41
+ ## 1.4.0
42
+ - \[Fixed\]: Dropdown – Fix bug not delay when searchDelayTime is true
43
+
41
44
  ## 1.3.99
42
45
  - \[Changed\]: Typography – Add new text style
43
46
  - \[Fixed\]: Tab – Fix background UI not match design