UNPKG

@progress/kendo-react-common

Version:

React Common package delivers common utilities that can be used with the KendoReact UI components. KendoReact Common Utilities package

71 lines (70 loc) 1.85 kB
/** * @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 n from "react"; import { useDroppable as m } from "./hooks/useDroppable.mjs"; const d = n.forwardRef((e, c) => { const t = n.useRef(null), l = n.useRef(null), r = n.useCallback( () => t.current && t.current.element ? t.current.element : t.current, [t] ); n.useImperativeHandle(l, () => ({ element: r() || void 0 })), n.useImperativeHandle(c, () => l.current), n.useImperativeHandle(e.childRef, () => t.current); const o = n.useCallback( (a) => { e.onDragEnter && e.onDragEnter({ element: r(), target: l.current, event: a }); }, [e.onDragEnter, r] ), u = n.useCallback( (a) => { e.onDragOver && e.onDragOver({ element: r(), target: l.current, event: a }); }, [r, e.onDragOver] ), D = n.useCallback( (a) => { e.onDragLeave && e.onDragLeave({ element: r(), target: l.current, event: a }); }, [e.onDragLeave, r] ), g = n.useCallback( (a) => { e.onDrop && e.onDrop({ element: r(), target: l.current, event: a }); }, [e.onDrop, r] ); return m( t, { onDragEnter: o, onDragOver: u, onDragLeave: D, onDrop: g }, { context: e.context } ), e.children ? n.cloneElement(n.Children.only(e.children), { ref: t }) : null; }); d.displayName = "KendoReactDroppable"; export { d as Droppable };