@progress/kendo-react-common
Version:
React Common package delivers common utilities that can be used with the KendoReact UI components. KendoReact Common Utilities package
10 lines (9 loc) • 1.31 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";
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react");function d(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const u=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,u.get?u:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const a=d(f);function b({onFocus:e,onBlur:r,onSyncFocus:t,onSyncBlur:u}){const l=a.useRef(!1),n=a.useRef(0),i=a.useCallback(c=>{clearTimeout(n.current),n.current=window.setTimeout(()=>c())},[n]),s=a.useCallback((...c)=>{clearTimeout(n.current),t&&t.call(void 0,c[0]),!l.current&&(l.current=!0,e&&e.call(void 0,...c))},[l,e,t]),o=a.useCallback((...c)=>{u&&u.call(void 0,c[0]),i(()=>{l.current&&r&&(l.current=!1,r.call(void 0,...c))})},[l,i,r,u]);return a.useEffect(()=>()=>{clearTimeout(n.current)},[]),{onFocus:s,onBlur:o}}exports.useAsyncFocusBlur=b;