export { getAppUrl, getAppUrls, extractCsrfToken } from './app'; export { capitalizeText, capitalizeWords, formatCurrency, formatDateDisplay, formatValue, } from './format'; export { levenshteinDistance } from './levenshtein'; export function getParentElmtByClassName(elmt, className: string) { let parentElmt = elmt.parentElement; while (parentElmt) { if (parentElmt.classList.contains(className)) { break; } parentElmt = parentElmt.parentElement; } return parentElmt; } export function getRelativeBoundingClientRect( clientRect1: any, clientRect2: any ) { const relativeClientRect = { x: 0, y: 0, top: 0, right: 0, bottom: 0, left: 0, }; relativeClientRect.x = clientRect1.x - clientRect2.x; relativeClientRect.y = clientRect1.y - clientRect2.y; relativeClientRect.top = clientRect1.top - clientRect2.top; relativeClientRect.right = clientRect1.right - clientRect2.right; relativeClientRect.bottom = clientRect1.bottom - clientRect2.bottom; relativeClientRect.left = clientRect1.left - clientRect2.left; return relativeClientRect; } /** * Generates string of random numbers. Primarily used in making unique ids for components. * @param {number} length Length of the string * @returns {string} */ export function randNumStr(length = 16): string { const n = 10e16; const m: number = Math.ceil(length / 16); let str = ''; for (let i = 0; i < m; i++) { str += (Math.random() * n).toString(); } return str.slice(0, length); } export function removeAllChildNodes(parent) { if(parent){ while (parent.firstChild) { parent.removeChild(parent.firstChild); } } }