import { DraggableEvent } from 'react-draggable' ; import { MouseEvent as ReactMouseEvent } from 'react' ; import { Dimensions , XYPosition , NodeExtent } from '../types' ; export const isInputDOMNode = ( e ) => { const target = e ?. target as HTMLElement ; return ( [ 'INPUT' , 'SELECT' , 'TEXTAREA' , 'BUTTON' ] . includes ( target ?. nodeName ) || target ?. hasAttribute ( 'contenteditable' ) ) ; } ; export const getDimensions = ( node ) : Dimensions => ( { width : node . offsetWidth , height : node . offsetHeight , } ) ; export const clamp = ( val , min = 0 , max = 1 ) : number => Math . min ( Math . max ( val , min ) , max ) ; export const clampPosition = ( position , extent ) => ( { x : clamp ( position . x , extent [ 0 ] [ 0 ] , extent [ 1 ] [ 0 ] ) , y : clamp ( position . y , extent [ 0 ] [ 1 ] , extent [ 1 ] [ 1 ] ) , } ) ; export const getHostForElement = ( element ) : Document | ShadowRoot => ( element . getRootNode ?. ( ) as Document | ShadowRoot ) || window ?. document ;