UNPKG

@lobehub/ui

Version:

Lobe UI is an open-source UI component library for building AIGC web apps

31 lines (30 loc) • 1.03 kB
//#region src/base-ui/FocusScope/domUtils.ts const isItemVisible = (el) => { if (typeof el.checkVisibility === "function") return el.checkVisibility({ checkOpacity: true, checkVisibilityCSS: true }); for (let node = el; node; node = node.parentElement) { const style = getComputedStyle(node); if (style.display === "none" || style.visibility === "hidden") return false; } return true; }; const hasSize = (el) => { const rect = el.getBoundingClientRect(); return rect.width > 0 && rect.height > 0; }; const isTextInputTarget = (target) => { if (!(target instanceof HTMLElement)) return false; if (target.isContentEditable) return true; return [ "INPUT", "SELECT", "TEXTAREA" ].includes(target.tagName); }; const hasModifier = (event) => event.metaKey || event.ctrlKey || event.altKey; const scopeSelector = (id) => `[data-focus-scope="${id.replaceAll("\"", "\\\"")}"]`; //#endregion export { hasModifier, hasSize, isItemVisible, isTextInputTarget, scopeSelector }; //# sourceMappingURL=domUtils.mjs.map