@progress/kendo-react-common
Version:
React Common package delivers common utilities that can be used with the KendoReact UI components. KendoReact Common Utilities package
44 lines (43 loc) • 1.18 kB
JavaScript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the package root for more information
*-------------------------------------------------------------------------------------------
*/
"use client";
import * as t from "react";
function o({
onFocus: u,
onBlur: l,
onSyncFocus: a,
onSyncBlur: i
}) {
const r = t.useRef(!1), c = t.useRef(0), s = t.useCallback(
(e) => {
clearTimeout(c.current), c.current = window.setTimeout(() => e());
},
[c]
), f = t.useCallback(
(...e) => {
clearTimeout(c.current), a && a.call(void 0, e[0]), !r.current && (r.current = !0, u && u.call(void 0, ...e));
},
[r, u, a]
), n = t.useCallback(
(...e) => {
i && i.call(void 0, e[0]), s(() => {
r.current && l && (r.current = !1, l.call(void 0, ...e));
});
},
[r, s, l, i]
);
return t.useEffect(() => () => {
clearTimeout(c.current);
}, []), {
onFocus: f,
onBlur: n
};
}
export {
o as useAsyncFocusBlur
};