UNPKG

bootstrap-vue-next

Version:

Seamless integration of Vue 3, Bootstrap 5, and TypeScript for modern, type-safe UI development

51 lines (50 loc) 2.04 kB
//#region src/utils/dom.ts var getSafeDocument = () => typeof document !== "undefined" ? document : null; var getSafeWindow = () => typeof window !== "undefined" ? window : null; var getActiveElement = (excludes = []) => { const doc = getSafeDocument(); if (doc === null) return null; const { activeElement } = doc; return activeElement && !excludes?.some((el) => el === activeElement) ? activeElement : null; }; /** * @deprecated only used in BFormGroup, which is not an SFC... Function could probably be replaced with pure Vue */ var attemptFocus = (el, options = {}) => { const isActiveElement = (el) => el === getActiveElement(); try { el.focus(options); } catch (e) { console.error(e); } return isActiveElement(el); }; var isEmptySlot = (el) => (el?.() ?? []).length === 0; /** * @deprecated only used in BFormGroup, which is not an SFC... Function could probably be replaced with pure Vue */ var isVisible = (el) => { if (el.getAttribute("display") === "none") return false; const bcr = el.getBoundingClientRect(); return bcr && bcr.height > 0 && bcr.width > 0; }; var sortSlotElementsByPosition = (a, b) => { if (typeof Node === "undefined" || !Node || !a || !b) return 0; const position = a.compareDocumentPosition(b); if (position & Node.DOCUMENT_POSITION_FOLLOWING) return -1; if (position & Node.DOCUMENT_POSITION_PRECEDING) return 1; return 0; }; var defaultZModelIndex = 1055; var getModalZIndex = (element) => { const win = getSafeWindow(); const doc = getSafeDocument(); if (win === null || doc === null) return defaultZModelIndex; const target = element ?? doc.body; const raw = win.getComputedStyle(target).getPropertyValue("--bs-modal-zindex").trim(); const parsed = Number.parseInt(raw, 10); return Number.isFinite(parsed) ? parsed : defaultZModelIndex; }; //#endregion export { getSafeWindow as a, sortSlotElementsByPosition as c, getSafeDocument as i, getActiveElement as n, isEmptySlot as o, getModalZIndex as r, isVisible as s, attemptFocus as t }; //# sourceMappingURL=dom-AhkaSoh8.mjs.map