export const createArray = ( startPosition , count ) => { const array = [ ] ; for ( let i = 0 ; i < count ; i += 1 ) { array . push ( startPosition + i ) ; } return array ; } ; export const getFiniteNumberOrZero = ( value ) => Number . isFinite ( value ) ? value : 0 ; export const doesElementContainFocus = ( element ) : boolean => element . matches ( ':focus-within' ) ; export const findFocusedElement = ( container ) : HTMLElement | null => { const element = container . querySelector < HTMLElement > ( ':focus' ) ; return element ; } ; export const clickFocusedElement = ( container ) : boolean => { const element = findFocusedElement ( container ) ; if ( element ) { element . click ( ) ; return true ; } return false ; } ; export const getOffsetBetweenElements = ( targetEl , startEl ) => { let element = startEl ; let top = 0 ; let left = 0 ; while ( element && targetEl !== element ) { const { offsetTop , offsetLeft , offsetParent } = element ; if ( targetEl . contains ( offsetParent ) ) { top += offsetTop ; left += offsetLeft ; } else { top += offsetTop - targetEl . offsetTop ; left += offsetLeft - targetEl . offsetLeft ; break ; } element = offsetParent as HTMLElement ; } return { offsetTop : top , offsetLeft : left , } ; } ;