indicator-ui 0.0.338 → 0.0.339
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/dist/index.js +13 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -41552,35 +41552,34 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
41552
41552
|
/* harmony import */ var lodash_debounce__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(lodash_debounce__WEBPACK_IMPORTED_MODULE_0__);
|
|
41553
41553
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "react");
|
|
41554
41554
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
|
|
41555
|
-
/* harmony import */ var _useDeepCompareEffect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./useDeepCompareEffect */ "./src/hooks/useDeepCompareEffect.ts");
|
|
41556
|
-
|
|
41557
41555
|
|
|
41558
41556
|
|
|
41559
41557
|
function useDebouncedInvoker(callback) {
|
|
41560
41558
|
var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 100;
|
|
41561
41559
|
var callbackRef = (0,react__WEBPACK_IMPORTED_MODULE_1__.useRef)(callback);
|
|
41562
41560
|
callbackRef.current = callback;
|
|
41563
|
-
var debouncedRef = (0,react__WEBPACK_IMPORTED_MODULE_1__.useRef)(
|
|
41564
|
-
|
|
41561
|
+
var debouncedRef = (0,react__WEBPACK_IMPORTED_MODULE_1__.useRef)(null);
|
|
41562
|
+
// Инициализация и обновление debounce
|
|
41563
|
+
(0,react__WEBPACK_IMPORTED_MODULE_1__.useEffect)(function () {
|
|
41565
41564
|
debouncedRef.current = lodash_debounce__WEBPACK_IMPORTED_MODULE_0___default()(function () {
|
|
41566
|
-
|
|
41567
|
-
|
|
41568
|
-
|
|
41565
|
+
// Добавляем проверку перед вызовом
|
|
41566
|
+
if (typeof callbackRef.current === "function") {
|
|
41567
|
+
return callbackRef.current.apply(callbackRef, arguments);
|
|
41569
41568
|
}
|
|
41570
|
-
return (_callbackRef$current = callbackRef.current) === null || _callbackRef$current === void 0 ? void 0 : _callbackRef$current.call.apply(_callbackRef$current, [callbackRef].concat(args));
|
|
41571
41569
|
}, delay);
|
|
41572
41570
|
return function () {
|
|
41573
41571
|
var _debouncedRef$current;
|
|
41574
41572
|
(_debouncedRef$current = debouncedRef.current) === null || _debouncedRef$current === void 0 || _debouncedRef$current.cancel();
|
|
41573
|
+
debouncedRef.current = null;
|
|
41575
41574
|
};
|
|
41576
|
-
}, [delay
|
|
41577
|
-
// Возвращаем вызываемую функцию
|
|
41575
|
+
}, [delay]);
|
|
41578
41576
|
return (0,react__WEBPACK_IMPORTED_MODULE_1__.useCallback)(function () {
|
|
41579
|
-
|
|
41580
|
-
|
|
41581
|
-
|
|
41577
|
+
if (debouncedRef.current) {
|
|
41578
|
+
return debouncedRef.current.apply(debouncedRef, arguments);
|
|
41579
|
+
}
|
|
41580
|
+
if (typeof callbackRef.current === "function") {
|
|
41581
|
+
return callbackRef.current.apply(callbackRef, arguments);
|
|
41582
41582
|
}
|
|
41583
|
-
return (_debouncedRef$current2 = debouncedRef.current) === null || _debouncedRef$current2 === void 0 ? void 0 : _debouncedRef$current2.call.apply(_debouncedRef$current2, [debouncedRef].concat(args));
|
|
41584
41583
|
}, []);
|
|
41585
41584
|
}
|
|
41586
41585
|
|