UNPKG

bootstrap-vue-next

Version:

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

98 lines (97 loc) 2.83 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 Object.defineProperty(exports, "attemptFocus", { enumerable: true, get: function() { return attemptFocus; } }); Object.defineProperty(exports, "getActiveElement", { enumerable: true, get: function() { return getActiveElement; } }); Object.defineProperty(exports, "getModalZIndex", { enumerable: true, get: function() { return getModalZIndex; } }); Object.defineProperty(exports, "getSafeDocument", { enumerable: true, get: function() { return getSafeDocument; } }); Object.defineProperty(exports, "getSafeWindow", { enumerable: true, get: function() { return getSafeWindow; } }); Object.defineProperty(exports, "isEmptySlot", { enumerable: true, get: function() { return isEmptySlot; } }); Object.defineProperty(exports, "isVisible", { enumerable: true, get: function() { return isVisible; } }); Object.defineProperty(exports, "sortSlotElementsByPosition", { enumerable: true, get: function() { return sortSlotElementsByPosition; } }); //# sourceMappingURL=dom-Bs6DzM72.js.map