UNPKG

ngx-bootstrap

Version:
1 lines 89.5 kB
{"version":3,"file":"ngx-bootstrap-positioning.mjs","sources":["../../../../src/positioning/models/index.ts","../../../../src/positioning/utils/getStyleComputedProperty.ts","../../../../src/positioning/utils/getOffsetParent.ts","../../../../src/positioning/utils/isOffsetContainer.ts","../../../../src/positioning/utils/getRoot.ts","../../../../src/positioning/utils/findCommonOffsetParent.ts","../../../../src/positioning/utils/getFixedPositionOffsetParent.ts","../../../../src/positioning/utils/getBordersSize.ts","../../../../src/positioning/utils/getWindowSizes.ts","../../../../src/positioning/utils/getClientRect.ts","../../../../src/positioning/utils/isNumeric.ts","../../../../src/positioning/utils/getBoundingClientRect.ts","../../../../src/positioning/utils/getOffsetRectRelativeToArbitraryNode.ts","../../../../src/positioning/utils/getParentNode.ts","../../../../src/positioning/utils/getScrollParent.ts","../../../../src/positioning/utils/getScroll.ts","../../../../src/positioning/utils/getViewportOffsetRectRelativeToArtbitraryNode.ts","../../../../src/positioning/utils/isFixed.ts","../../../../src/positioning/utils/getBoundaries.ts","../../../../src/positioning/utils/computeAutoPlacement.ts","../../../../src/positioning/utils/getOffsets.ts","../../../../src/positioning/utils/getOppositePlacement.ts","../../../../src/positioning/utils/getOppositeVariation.ts","../../../../src/positioning/utils/getOuterSizes.ts","../../../../src/positioning/utils/getReferenceOffsets.ts","../../../../src/positioning/utils/getTargetOffsets.ts","../../../../src/positioning/utils/isModifierEnabled.ts","../../../../src/positioning/utils/checkMargin.ts","../../../../src/positioning/utils/updateContainerClass.ts","../../../../src/positioning/utils/setStyles.ts","../../../../src/positioning/modifiers/arrow.ts","../../../../src/positioning/modifiers/flip.ts","../../../../src/positioning/modifiers/initData.ts","../../../../src/positioning/modifiers/preventOverflow.ts","../../../../src/positioning/modifiers/shift.ts","../../../../src/positioning/ng-positioning.ts","../../../../src/positioning/positioning.service.ts","../../../../src/positioning/ngx-bootstrap-positioning.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-duplicate-enum-values */\nexport interface Offsets {\n width: number;\n height: number;\n bottom?: number;\n left?: number;\n right?: number;\n top?: number;\n marginTop?: number;\n marginLeft?: number;\n}\n\nexport interface Data {\n options: Options;\n instance: {\n target: HTMLElement;\n host: HTMLElement;\n arrow?: HTMLElement;\n };\n offsets: {\n target: Offsets;\n host: Offsets;\n arrow?: Record<string, string | number | HTMLElement>;\n };\n positionFixed: boolean;\n placement: string;\n placementAuto: boolean;\n}\n\nexport interface Options {\n placement?: string;\n modifiers: {\n flip?: {\n enabled: boolean;\n };\n preventOverflow?: {\n enabled: boolean;\n boundariesElement?: string;\n };\n };\n allowedPositions?: string[];\n}\n\nexport enum MapPlacementInToRL {\n top = 'top',\n bottom = 'bottom',\n left = 'left',\n right = 'right',\n auto = 'auto',\n end = 'right',\n start = 'left',\n 'top left' = 'top left',\n 'top right' = 'top right',\n 'right top' = 'right top',\n 'right bottom' = 'right bottom',\n 'bottom right' = 'bottom right',\n 'bottom left' = 'bottom left',\n 'left bottom' = 'left bottom',\n 'left top' = 'left top',\n 'top start' = 'top left',\n 'top end' = 'top right',\n 'end top' = 'right top',\n 'end bottom' = 'right bottom',\n 'bottom end' = 'bottom right',\n 'bottom start' = 'bottom left',\n 'start bottom' = 'start bottom',\n 'start top' = 'left top'\n}\n\nexport enum PlacementForBs5 {\n top = 'top',\n bottom = 'bottom',\n left = 'start',\n right = 'end',\n auto = 'auto',\n end = 'end',\n start = 'start',\n 'top left' = 'top start',\n 'top right' = 'top end',\n 'right top' = 'end top',\n 'right bottom' = 'end bottom',\n 'bottom right' = 'bottom end',\n 'bottom left' = 'bottom start',\n 'left bottom' = 'start bottom',\n 'left top' = 'start top',\n 'top start' = 'top start',\n 'top end' = 'top end',\n 'end top' = 'end top',\n 'end bottom' = 'end bottom',\n 'bottom end' = 'bottom end',\n 'bottom start' = 'bottom start',\n 'start bottom' = 'start bottom',\n 'start top' = 'start top'\n}\n\ntype VerticalPosition = 'top' | 'bottom';\ntype HorizontalPosition = 'left' | 'right';\ntype RtlFriendlyHorizontalPosition = 'start' | 'end';\n\nexport type AvailableBSPositions =\n | VerticalPosition\n | HorizontalPosition\n | RtlFriendlyHorizontalPosition\n | 'auto'\n | `${VerticalPosition} ${HorizontalPosition}`\n | `${HorizontalPosition} ${VerticalPosition}`\n | `${VerticalPosition} ${RtlFriendlyHorizontalPosition}`\n | `${RtlFriendlyHorizontalPosition} ${VerticalPosition}`;\n\n/** @deprecated use AvailablePositions */\nexport type AvailbleBSPositions = AvailableBSPositions;\n","/**\n * Get CSS computed property of the given element\n */\nexport function getStyleComputedProperty(element: Element): CSSStyleDeclaration;\nexport function getStyleComputedProperty(element: Element, property?: string): string | string[];\nexport function getStyleComputedProperty(element: Element, property?: string): string | string[] | CSSStyleDeclaration {\n if (element.nodeType !== 1) {\n return [];\n }\n // NOTE: 1 DOM access here\n const window = element.ownerDocument.defaultView;\n const css = window?.getComputedStyle(element, null);\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return property ? css && css[property] : css;\n}\n","/**\n * Returns the offset parent of the given element\n */\nimport { getStyleComputedProperty } from './getStyleComputedProperty';\n\nexport function getOffsetParent(element: HTMLElement): HTMLElement {\n if (!element) {\n return document.documentElement;\n }\n\n const noOffsetParent = null;\n\n // NOTE: 1 DOM access here\n let offsetParent = element?.offsetParent;\n\n // Skip hidden elements which don't have an offsetParent\n let sibling: HTMLElement | undefined = void 0;\n\n while (offsetParent === noOffsetParent\n && element.nextElementSibling\n && sibling !== element.nextElementSibling) {\n\n // todo: valorkin fix\n sibling = element.nextElementSibling as HTMLElement;\n offsetParent = sibling.offsetParent;\n }\n\n const nodeName = offsetParent && offsetParent.nodeName;\n\n if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') {\n return sibling ? sibling.ownerDocument.documentElement : document.documentElement;\n }\n\n // .offsetParent will return the closest TH, TD or TABLE in case\n if (\n offsetParent &&\n ['TH', 'TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 &&\n getStyleComputedProperty(offsetParent, 'position') === 'static'\n ) {\n return getOffsetParent(offsetParent as HTMLElement);\n }\n\n return offsetParent as HTMLElement;\n}\n","import { getOffsetParent } from './getOffsetParent';\n\n// todo: valorkin fix\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isOffsetContainer(element: any) {\n const { nodeName } = element;\n if (nodeName === 'BODY') {\n return false;\n }\n\n return (\n nodeName === 'HTML' || getOffsetParent(element.firstElementChild) === element\n );\n}\n","/**\n * Finds the root node (document, shadowDOM root) of the given element\n */\nexport function getRoot(node: Node|ShadowRoot): Node|ShadowRoot {\n if (node.parentNode !== null) {\n return getRoot(node.parentNode);\n }\n\n return node;\n}\n","/**\n * Finds the offset parent common to the two provided nodes\n */\nimport { isOffsetContainer } from './isOffsetContainer';\nimport { getRoot } from './getRoot';\nimport { getOffsetParent } from './getOffsetParent';\n\nexport function findCommonOffsetParent(element1: HTMLElement, element2: HTMLElement): HTMLElement {\n // This check is needed to avoid errors in case one of the elements isn't defined for any reason\n if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) {\n return document.documentElement;\n }\n\n // Here we make sure to give as \"start\" the element that comes first in the DOM\n const order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING;\n\n const start = order ? element1 : element2;\n const end = order ? element2 : element1;\n\n // Get common ancestor container\n const range = document.createRange();\n range.setStart(start, 0);\n range.setEnd(end, 0);\n\n // todo: valorkin fix\n const commonAncestorContainer = range.commonAncestorContainer as unknown as HTMLElement;\n\n // Both nodes are inside #document\n if (\n (element1 !== commonAncestorContainer &&\n element2 !== commonAncestorContainer) ||\n start.contains(end)\n ) {\n if (isOffsetContainer(commonAncestorContainer)) {\n return commonAncestorContainer;\n }\n\n return getOffsetParent(commonAncestorContainer);\n }\n\n // one of the nodes is inside shadowDOM, find which one\n const element1root = getRoot(element1) as ShadowRoot;\n if (element1root.host) {\n return findCommonOffsetParent(element1root.host as HTMLElement, element2);\n } else {\n return findCommonOffsetParent(element1, (getRoot(element2) as ShadowRoot).host as HTMLElement);\n }\n}\n","/**\n * Finds the first parent of an element that has a transformed property defined\n */\n\nimport { getStyleComputedProperty } from './getStyleComputedProperty';\n\nexport function getFixedPositionOffsetParent(element: HTMLElement): HTMLElement {\n // This check is needed to avoid errors in case one of the elements isn't defined for any reason\n if (!element || !element.parentElement) {\n return document.documentElement;\n }\n\n let el = element.parentElement;\n\n while (el?.parentElement && getStyleComputedProperty(el, 'transform') === 'none') {\n el = el.parentElement;\n }\n\n return el || document.documentElement;\n}\n","/**\n * Helper to detect borders of a given element\n */\n\nexport function getBordersSize(styles: CSSStyleDeclaration, axis: string): number {\n const sideA = axis === 'x' ? 'Left' : 'Top';\n const sideB = sideA === 'Left' ? 'Right' : 'Bottom';\n\n return (\n parseFloat((styles as never)[`border${sideA}Width`]) +\n parseFloat((styles as never)[`border${sideB}Width`])\n );\n}\n","function getSize(axis: string, body: HTMLElement, html: HTMLElement) {\n const _body = body as unknown as Record<string, number>;\n const _html = html as never;\n\n return Math.max(\n _body[`offset${axis}`],\n _body[`scroll${axis}`],\n _html[`client${axis}`],\n _html[`offset${axis}`],\n _html[`scroll${axis}`],\n 0\n );\n}\n\nexport function getWindowSizes(document: Document) {\n const body = document.body;\n const html = document.documentElement;\n\n return {\n height: getSize('Height', body, html),\n width: getSize('Width', body, html)\n };\n}\n","/**\n * Given element offsets, generate an output similar to getBoundingClientRect\n */\nimport { Offsets } from '../models';\n\nexport function getClientRect(offsets: Offsets): Offsets {\n return {\n ...offsets,\n right: (offsets.left || 0) + offsets.width,\n bottom: (offsets.top || 0) + offsets.height\n };\n}\n","/**\n * Tells if a given input is a number\n */\nexport function isNumeric(n: string): boolean {\n return n !== '' && !isNaN(parseFloat(n)) && isFinite(Number(n));\n}\n\nexport function isNumber(value?: unknown): value is number {\n return typeof value === 'number' || Object.prototype.toString.call(value) === '[object Number]';\n}\n","/**\n * Get bounding client rect of given element\n */\nimport { getStyleComputedProperty } from './getStyleComputedProperty';\nimport { getBordersSize } from './getBordersSize';\nimport { getWindowSizes } from './getWindowSizes';\nimport { getClientRect } from './getClientRect';\nimport { Offsets } from '../models';\nimport { isNumber } from './isNumeric';\n\nexport function getBoundingClientRect(element: HTMLElement): Offsets {\n const rect: Offsets = element.getBoundingClientRect();\n\n // IE10 10 FIX: Please, don't ask, the element isn't\n // considered in DOM in some circumstances...\n // This isn't reproducible in IE10 compatibility mode of IE11\n // try {\n // if (isIE(10)) {\n // const scrollTop = getScroll(element, 'top');\n // const scrollLeft = getScroll(element, 'left');\n // if (rect && isNumber(rect.top) && isNumber(rect.left) && isNumber(rect.bottom) && isNumber(rect.right)) {\n // rect.top += scrollTop;\n // rect.left += scrollLeft;\n // rect.bottom += scrollTop;\n // rect.right += scrollLeft;\n // }\n // }\n // } catch (e) {\n // return rect;\n // }\n\n if (!(rect && isNumber(rect.top) && isNumber(rect.left) && isNumber(rect.bottom) && isNumber(rect.right))) {\n return rect;\n }\n\n const result: Offsets = {\n left: rect.left,\n top: rect.top,\n width: rect.right - rect.left,\n height: rect.bottom - rect.top\n };\n\n // subtract scrollbar size from sizes\n const sizes = element.nodeName === 'HTML' ? getWindowSizes(element.ownerDocument) : undefined;\n const width = sizes?.width || element.clientWidth\n || isNumber(rect.right) && isNumber(result.left) && rect.right - result.left || 0;\n const height = sizes?.height || element.clientHeight\n || isNumber(rect.bottom) && isNumber(result.top) && rect.bottom - result.top || 0;\n\n let horizScrollbar = element.offsetWidth - width;\n let vertScrollbar = element.offsetHeight - height;\n\n // if an hypothetical scrollbar is detected, we must be sure it's not a `border`\n // we make this check conditional for performance reasons\n if (horizScrollbar || vertScrollbar) {\n const styles = getStyleComputedProperty(element);\n horizScrollbar -= getBordersSize(styles, 'x');\n vertScrollbar -= getBordersSize(styles, 'y');\n\n result.width -= horizScrollbar;\n result.height -= vertScrollbar;\n }\n\n return getClientRect(result);\n}\n","import { getBoundingClientRect } from './getBoundingClientRect';\nimport { getClientRect } from './getClientRect';\nimport { getStyleComputedProperty } from './getStyleComputedProperty';\nimport { Offsets } from '../models';\nimport { isNumber } from './isNumeric';\n\nexport function getOffsetRectRelativeToArbitraryNode(\n children: HTMLElement,\n parent: HTMLElement,\n fixedPosition = false\n): Offsets {\n const isHTML = parent.nodeName === 'HTML';\n const childrenRect = getBoundingClientRect(children);\n const parentRect = getBoundingClientRect(parent);\n\n const styles = getStyleComputedProperty(parent);\n const borderTopWidth = parseFloat(styles.borderTopWidth);\n const borderLeftWidth = parseFloat(styles.borderLeftWidth);\n\n // In cases where the parent is fixed, we must ignore negative scroll in offset calc\n if (fixedPosition && isHTML) {\n parentRect.top = Math.max(parentRect.top ?? 0, 0);\n parentRect.left = Math.max(parentRect.left ?? 0, 0);\n }\n\n const offsets: Offsets = getClientRect({\n top: (childrenRect.top ?? 0) - (parentRect.top ?? 0) - borderTopWidth,\n left: (childrenRect.left ?? 0) - (parentRect.left ?? 0) - borderLeftWidth,\n width: childrenRect.width,\n height: childrenRect.height\n });\n\n offsets.marginTop = 0;\n offsets.marginLeft = 0;\n\n // Subtract margins of documentElement in case it's being used as parent\n // we do this only on HTML because it's the only element that behaves\n // differently when margins are applied to it. The margins are included in\n // the box of the documentElement, in the other cases not.\n if (isHTML) {\n const marginTop = parseFloat(styles.marginTop);\n const marginLeft = parseFloat(styles.marginLeft);\n\n if (isNumber(offsets.top)) {\n offsets.top -= borderTopWidth - marginTop;\n }\n if (isNumber(offsets.bottom)) {\n offsets.bottom -= borderTopWidth - marginTop;\n }\n if (isNumber(offsets.left)) {\n offsets.left -= borderLeftWidth - marginLeft;\n }\n if (isNumber(offsets.right)) {\n offsets.right -= borderLeftWidth - marginLeft;\n }\n\n // Attach marginTop and marginLeft because in some circumstances we may need them\n offsets.marginTop = marginTop;\n offsets.marginLeft = marginLeft;\n }\n\n return offsets;\n}\n","/**\n * Returns the parentNode or the host of the element\n */\n// todo: valorkin fix\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function getParentNode(element: any): any {\n if (element.nodeName === 'HTML') {\n return element;\n }\n\n return element.parentNode || element.host;\n}\n","/**\n * Returns the scrolling parent of the given element\n */\nimport { getStyleComputedProperty } from './getStyleComputedProperty';\nimport { getParentNode } from './getParentNode';\n\n// todo: valorkin fix\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function getScrollParent(element: any): any {\n // Return body, `getScroll` will take care to get the correct `scrollTop` from it\n if (!element) {\n return document.body;\n }\n\n switch (element.nodeName) {\n case 'HTML':\n case 'BODY':\n return element.ownerDocument.body;\n case '#document':\n return element.body;\n default:\n }\n\n // Firefox want us to check `-x` and `-y` variations as well\n const { overflow, overflowX, overflowY } = getStyleComputedProperty(element);\n if (/(auto|scroll|overlay)/.test(String(overflow) + String(overflowY) + String(overflowX))) {\n return element;\n }\n\n return getScrollParent(getParentNode(element));\n}\n","/**\n * Gets the scroll value of the given element in the given side (top and left)\n */\nexport function getScroll(element: HTMLElement, side = 'top') {\n const upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft';\n const nodeName = element.nodeName;\n\n if (nodeName === 'BODY' || nodeName === 'HTML') {\n const html = element.ownerDocument.documentElement;\n const scrollingElement = element.ownerDocument.scrollingElement || html;\n\n return scrollingElement[upperSide];\n }\n\n return element[upperSide];\n}\n","import { getClientRect } from './getClientRect';\nimport { getOffsetRectRelativeToArbitraryNode } from './getOffsetRectRelativeToArbitraryNode';\nimport { getScroll } from './getScroll';\nimport { Offsets } from '../models';\n\nexport function getViewportOffsetRectRelativeToArtbitraryNode(element: HTMLElement, excludeScroll = false): Offsets {\n const html = element.ownerDocument.documentElement;\n const relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html);\n const width = Math.max(html.clientWidth, window.innerWidth || 0);\n const height = Math.max(html.clientHeight, window.innerHeight || 0);\n\n const scrollTop = !excludeScroll ? getScroll(html) : 0;\n const scrollLeft = !excludeScroll ? getScroll(html, 'left') : 0;\n\n const offset = {\n top: scrollTop - Number(relativeOffset?.top) + Number(relativeOffset?.marginTop),\n left: scrollLeft - Number(relativeOffset?.left) + Number(relativeOffset?.marginLeft),\n width,\n height\n };\n\n return getClientRect(offset);\n}\n","/**\n * Check if the given element is fixed or is inside a fixed parent\n */\nimport { getStyleComputedProperty } from './getStyleComputedProperty';\nimport { getParentNode } from './getParentNode';\n\nexport function isFixed(element: HTMLElement): boolean {\n const nodeName = element.nodeName;\n if (nodeName === 'BODY' || nodeName === 'HTML') {\n return false;\n }\n if (getStyleComputedProperty(element, 'position') === 'fixed') {\n return true;\n }\n\n return isFixed(getParentNode(element));\n}\n","/**\n * Computed the boundaries limits and return them\n */\nimport { Offsets } from '../models';\nimport { findCommonOffsetParent } from './findCommonOffsetParent';\nimport { getFixedPositionOffsetParent } from './getFixedPositionOffsetParent';\nimport { getOffsetRectRelativeToArbitraryNode } from './getOffsetRectRelativeToArbitraryNode';\nimport { getParentNode } from './getParentNode';\nimport { getScrollParent } from './getScrollParent';\nimport { getViewportOffsetRectRelativeToArtbitraryNode } from './getViewportOffsetRectRelativeToArtbitraryNode';\nimport { getWindowSizes } from './getWindowSizes';\nimport { isFixed } from './isFixed';\nimport { isNumber } from './isNumeric';\n\nexport function getBoundaries(\n target: HTMLElement,\n host: HTMLElement,\n padding = 0,\n boundariesElement: string,\n fixedPosition = false\n): Partial<Offsets> {\n // NOTE: 1 DOM access here\n\n let boundaries: Partial<Offsets> = { top: 0, left: 0 };\n const offsetParent = fixedPosition ? getFixedPositionOffsetParent(target) : findCommonOffsetParent(target, host);\n\n // Handle viewport case\n if (boundariesElement === 'viewport') {\n boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition);\n } else {\n // Handle other cases based on DOM element used as boundaries\n let boundariesNode;\n if (boundariesElement === 'scrollParent') {\n boundariesNode = getScrollParent(getParentNode(host));\n if (boundariesNode.nodeName === 'BODY') {\n boundariesNode = target.ownerDocument.documentElement;\n }\n } else if (boundariesElement === 'window') {\n boundariesNode = target.ownerDocument.documentElement;\n } else {\n boundariesNode = boundariesElement;\n }\n\n const offsets = getOffsetRectRelativeToArbitraryNode(\n boundariesNode,\n offsetParent,\n fixedPosition\n );\n\n // In case of HTML, we need a different computation\n if (offsets && boundariesNode.nodeName === 'HTML' && !isFixed(offsetParent)) {\n const { height, width } = getWindowSizes(target.ownerDocument);\n if (isNumber(boundaries.top) && isNumber(offsets.top) && isNumber(offsets.marginTop)) {\n boundaries.top += offsets.top - offsets.marginTop;\n }\n if (isNumber(boundaries.top)) {\n boundaries.bottom = Number(height) + Number(offsets.top);\n }\n if (isNumber(boundaries.left) && isNumber(offsets.left) && isNumber(offsets.marginLeft)) {\n boundaries.left += offsets.left - offsets.marginLeft;\n }\n if (isNumber(boundaries.top)) {\n boundaries.right = Number(width) + Number(offsets.left);\n }\n } else if (offsets) {\n // for all the other DOM elements, this one is good\n boundaries = offsets;\n }\n }\n\n // Add paddings\n if (isNumber(boundaries.left)) {\n boundaries.left += padding;\n }\n if (isNumber(boundaries.top)) {\n boundaries.top += padding;\n }\n if (isNumber(boundaries.right)) {\n boundaries.right -= padding;\n }\n if (isNumber(boundaries.bottom)) {\n boundaries.bottom -= padding;\n }\n\n return boundaries;\n}\n","/**\n * Utility used to transform the `auto` placement to the placement with more\n * available space.\n */\nimport { getBoundaries } from './getBoundaries';\nimport { Offsets, PlacementForBs5 } from '../models';\nimport { getBsVer } from 'ngx-bootstrap/utils';\n\nfunction getArea({ width, height }: { width: number; height: number }) {\n return width * height;\n}\n\nexport function computeAutoPlacement(\n placement: string,\n refRect: Offsets,\n target: HTMLElement,\n host: HTMLElement,\n allowedPositions = ['top', 'bottom', 'right', 'left'],\n boundariesElement = 'viewport',\n padding = 0\n) {\n if (placement.indexOf('auto') === -1) {\n return placement;\n }\n\n const boundaries = getBoundaries(target, host, padding, boundariesElement);\n\n type Rects = { top: Offsets; right: Offsets; bottom: Offsets; left: Offsets };\n const rects: Rects = {\n top: {\n width: boundaries?.width ?? 0,\n height: (refRect?.top ?? 0) - (boundaries?.top ?? 0)\n },\n right: {\n width: (boundaries?.right ?? 0) - (refRect?.right ?? 0),\n height: boundaries?.height ?? 0\n },\n bottom: {\n width: boundaries?.width ?? 0,\n height: (boundaries?.bottom ?? 0) - (refRect?.bottom ?? 0)\n },\n left: {\n width: (refRect.left ?? 0) - (boundaries?.left ?? 0),\n height: boundaries?.height ?? 0\n }\n };\n\n const sortedAreas = Object.keys(rects)\n .map((key) => ({\n position: key,\n ...rects[key as keyof Rects],\n area: getArea(rects[key as keyof Rects] as { width: number; height: number })\n }))\n .sort((a, b) => b.area - a.area);\n\n let filteredAreas = sortedAreas.filter(({ width, height }) => {\n return width >= target.clientWidth && height >= target.clientHeight;\n });\n\n filteredAreas = filteredAreas.filter(({ position }) => {\n return allowedPositions.some((allowedPosition: string) => {\n return allowedPosition === position;\n });\n });\n\n const computedPlacement: string = filteredAreas.length > 0 ? filteredAreas[0].position : sortedAreas[0].position;\n\n const variation = placement.split(' ')[1];\n // for tooltip on auto position\n target.className = target.className.replace(\n /bs-tooltip-auto/g,\n `bs-tooltip-${\n getBsVer().isBs5 ? PlacementForBs5[computedPlacement as keyof typeof PlacementForBs5] : computedPlacement\n }`\n );\n\n return computedPlacement + (variation ? `-${variation}` : '');\n}\n","import { Data, Offsets } from '../models';\n\nexport function getOffsets(data: Data): Offsets {\n return {\n width: data.offsets.target.width,\n height: data.offsets.target.height,\n left: Math.floor(data.offsets.target.left ?? 0),\n top: Math.round(data.offsets.target.top ?? 0),\n bottom: Math.round(data.offsets.target.bottom ?? 0),\n right: Math.floor(data.offsets.target.right ?? 0)\n };\n}\n","/**\n * Get the opposite placement of the given one\n */\nexport function getOppositePlacement(placement: string): string {\n const hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };\n\n return placement.replace(/left|right|bottom|top/g, matched => hash[matched as keyof typeof hash]);\n}\n","/**\n * Get the opposite placement variation of the given one\n */\nexport function getOppositeVariation(variation: string) {\n if (variation === 'right') {\n return 'left';\n } else if (variation === 'left') {\n return 'right';\n }\n\n return variation;\n}\n","/**\n * Get the outer sizes of the given element (offset size + margins)\n */\nimport { Offsets } from '../models';\n\nconst parse = (value?: string, def = 0) => value ? parseFloat(value) : def;\nexport function getOuterSizes(element: HTMLElement): Offsets {\n const window = element.ownerDocument.defaultView;\n const styles = window?.getComputedStyle(element);\n const x = parse(styles?.marginTop) + parse(styles?.marginBottom);\n const y = parse(styles?.marginLeft) + parse(styles?.marginRight);\n\n return {\n width: Number(element.offsetWidth) + y,\n height: Number(element.offsetHeight) + x\n };\n}\n","/**\n * Get offsets to the reference element\n */\nimport { findCommonOffsetParent } from './findCommonOffsetParent';\nimport { getOffsetRectRelativeToArbitraryNode } from './getOffsetRectRelativeToArbitraryNode';\nimport { getFixedPositionOffsetParent } from './getFixedPositionOffsetParent';\nimport { Offsets } from '../models';\n\nexport function getReferenceOffsets(\n target: HTMLElement,\n host: HTMLElement,\n fixedPosition?: boolean\n): Offsets {\n const commonOffsetParent = fixedPosition\n ? getFixedPositionOffsetParent(target)\n : findCommonOffsetParent(target, host);\n\n return getOffsetRectRelativeToArbitraryNode(host, commonOffsetParent, fixedPosition);\n}\n","/**\n * Get offsets to the target\n */\nimport { getOppositePlacement } from './getOppositePlacement';\nimport { getOuterSizes } from './getOuterSizes';\nimport { Offsets } from '../models';\n\n\nexport function getTargetOffsets(\n target: HTMLElement,\n hostOffsets: Offsets,\n position: string\n): Offsets {\n const placement = position.split(' ')[0];\n // Get target node sizes\n const targetRect = getOuterSizes(target);\n\n // Add position, width and height to our offsets object\n const targetOffsets = {\n width: targetRect.width,\n height: targetRect.height\n };\n\n // depending by the target placement we have to compute its offsets slightly differently\n const isHoriz = ['right', 'left'].indexOf(placement) !== -1;\n const mainSide = isHoriz ? 'top' : 'left';\n const secondarySide = isHoriz ? 'left' : 'top';\n const measurement = isHoriz ? 'height' : 'width';\n const secondaryMeasurement = !isHoriz ? 'height' : 'width';\n\n targetOffsets[mainSide as keyof typeof targetOffsets] =\n (hostOffsets[mainSide] ?? 0) +\n hostOffsets[measurement] / 2 -\n targetRect[measurement] / 2;\n\n targetOffsets[secondarySide as keyof typeof targetOffsets] = placement === secondarySide\n ? (hostOffsets[secondarySide] ?? 0)- targetRect[secondaryMeasurement]\n : hostOffsets[getOppositePlacement(secondarySide) as keyof typeof hostOffsets] ?? 0;\n\n return targetOffsets;\n}\n","/**\n * Helper used to know if the given modifier is enabled.\n */\nimport { Options } from '../models';\n\nexport function isModifierEnabled(options: Options, modifierName: string): boolean {\n return !!options.modifiers[modifierName as keyof typeof options.modifiers]?.enabled;\n}\n","import { getBsVer } from 'ngx-bootstrap/utils';\nimport { AvailableBSPositions } from '../models';\n\nconst availablePositions = {\n top: ['top', 'top start', 'top end'],\n bottom: ['bottom', 'bottom start', 'bottom end'],\n start: ['start', 'start top', 'start bottom'],\n end: ['end', 'end top', 'end bottom']\n};\n\nexport function checkPopoverMargin(\n placement: AvailableBSPositions,\n checkPosition: 'top' | 'bottom' | 'start' | 'end'\n): boolean {\n if (!getBsVer().isBs5) {\n return false;\n }\n\n return availablePositions[checkPosition].includes(placement);\n}\n\nexport function checkMargins(placement: AvailableBSPositions): string {\n if (!getBsVer().isBs5) {\n return '';\n }\n\n if (checkPopoverMargin(placement, 'end')) {\n return 'ms-2';\n }\n\n if (checkPopoverMargin(placement, 'start')) {\n return 'me-2';\n }\n\n if (checkPopoverMargin(placement, 'top')) {\n return 'mb-2';\n }\n\n if (checkPopoverMargin(placement, 'bottom')) {\n return 'mt-2';\n }\n\n return '';\n}\n","/**\n * Update class for the given popper\n */\nimport { Renderer2 } from '@angular/core';\nimport { AvailableBSPositions, Data, PlacementForBs5 } from '../models';\nimport { checkMargins } from './checkMargin';\nimport { getBsVer } from 'ngx-bootstrap/utils';\n\nexport function updateContainerClass(data: Data, renderer?: Renderer2): void {\n const target = data.instance.target;\n\n let containerClass = target.className;\n\n const dataPlacement = getBsVer().isBs5\n ? PlacementForBs5[data.placement as keyof typeof PlacementForBs5]\n : data.placement;\n if (data.placementAuto) {\n containerClass = containerClass.replace(/bs-popover-auto/g, `bs-popover-${dataPlacement}`);\n containerClass = containerClass.replace(/ms-2|me-2|mb-2|mt-2/g, '');\n containerClass = containerClass.replace(/bs-tooltip-auto/g, `bs-tooltip-${dataPlacement}`);\n containerClass = containerClass.replace(/\\sauto/g, ` ${dataPlacement}`);\n\n if (containerClass.indexOf('popover') !== -1) {\n containerClass = containerClass + ' ' + checkMargins(dataPlacement as AvailableBSPositions);\n }\n\n if (containerClass.indexOf('popover') !== -1 && containerClass.indexOf('popover-auto') === -1) {\n containerClass += ' popover-auto';\n }\n\n if (containerClass.indexOf('tooltip') !== -1 && containerClass.indexOf('tooltip-auto') === -1) {\n containerClass += ' tooltip-auto';\n }\n }\n containerClass = containerClass.replace(/left|right|top|bottom|end|start/g, `${dataPlacement.split(' ')[0]}`);\n\n if (renderer) {\n renderer.setAttribute(target, 'class', containerClass);\n\n return;\n }\n\n target.className = containerClass;\n}\n","/**\n * Set the style to the given popper\n */\nimport { Renderer2 } from '@angular/core';\n\nimport { isNumeric } from './isNumeric';\n\nexport function setStyles(element: HTMLElement | null, styles?: Record<string, string|number|HTMLElement>, renderer?: Renderer2) {\n if (!element || !styles) {\n return;\n }\n Object.keys(styles).forEach((prop) => {\n let unit = '';\n // add unit if the value is numeric and is one of the following\n if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 &&\n isNumeric(styles[prop] as string)) {\n unit = 'px';\n }\n\n if (renderer) {\n renderer.setStyle(element, prop, `${String(styles[prop])}${unit}`);\n\n return;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (element.style as any)[prop] = String(styles[prop]) + unit;\n });\n}\n","import { getClientRect, getOuterSizes, getStyleComputedProperty } from '../utils';\nimport { Data } from '../models';\n\nexport function arrow(data: Data) {\n let targetOffsets = data.offsets.target;\n // if arrowElement is a string, suppose it's a CSS selector\n const arrowElement: HTMLElement | null = data.instance.target.querySelector('.arrow');\n\n // if arrowElement is not found, don't run the modifier\n if (!arrowElement) {\n return data;\n }\n\n const isVertical = ['left', 'right'].indexOf(data.placement.split(' ')[0]) !== -1;\n\n const len = isVertical ? 'height' : 'width';\n const sideCapitalized = isVertical ? 'Top' : 'Left';\n const side = sideCapitalized.toLowerCase() as keyof typeof targetOffsets;\n const altSide = isVertical ? 'left' : 'top';\n const opSide = isVertical ? 'bottom' : 'right';\n const arrowElementSize = getOuterSizes(arrowElement)[len];\n const placementVariation = data.placement.split(' ')[1];\n\n // top/left side\n if ((data.offsets.host[opSide] ?? 0) - arrowElementSize < (targetOffsets[side] ?? 0)) {\n (targetOffsets)[side] -=\n (targetOffsets[side] ?? 0) - ((data.offsets.host[opSide] ?? 0) - arrowElementSize);\n }\n // bottom/right side\n if (Number((data).offsets.host[side]) + Number(arrowElementSize) > (targetOffsets[opSide] ?? 0)) {\n (targetOffsets)[side] +=\n Number((data).offsets.host[side]) + Number(arrowElementSize) - Number((targetOffsets)[opSide]);\n }\n targetOffsets = getClientRect(targetOffsets);\n\n // Compute the sideValue using the updated target offsets\n // take target margin in account because we don't have this info available\n const css = getStyleComputedProperty(data.instance.target) as unknown as Record<string, string>;\n const targetMarginSide = parseFloat(css[`margin${sideCapitalized}`]) || 0;\n const targetBorderSide = parseFloat(css[`border${sideCapitalized}Width`]) || 0;\n\n // compute center of the target\n let center: number;\n if (!placementVariation) {\n center = Number((data).offsets.host[side]) + Number(data.offsets.host[len] / 2 - arrowElementSize / 2);\n } else {\n const targetBorderRadius = parseFloat(css[\"borderRadius\"]) || 0;\n const targetSideArrowOffset = Number(targetMarginSide + targetBorderSide + targetBorderRadius);\n center = side === placementVariation ?\n Number((data).offsets.host[side]) + targetSideArrowOffset :\n Number((data).offsets.host[side]) + Number(data.offsets.host[len] - targetSideArrowOffset);\n }\n\n let sideValue =\n center - (targetOffsets[side] ?? 0) - targetMarginSide - targetBorderSide;\n\n // prevent arrowElement from being placed not contiguously to its target\n sideValue = Math.max(Math.min(targetOffsets[len] - (arrowElementSize + 5), sideValue), 0);\n data.offsets.arrow = {\n [side]: Math.round(sideValue),\n [altSide]: '' // make sure to unset any eventual altSide value from the DOM node\n };\n\n data.instance.arrow = arrowElement;\n\n return data;\n}\n","import { Data } from '../models';\nimport {\n computeAutoPlacement,\n getBoundaries,\n getClientRect,\n getOppositeVariation,\n getTargetOffsets,\n isModifierEnabled\n} from '../utils';\n\nexport function flip(data: Data): Data {\n data.offsets.target = getClientRect(data.offsets.target);\n\n if (!isModifierEnabled(data.options, 'flip')) {\n\n data.offsets.target = {\n ...data.offsets.target,\n ...getTargetOffsets(\n data.instance.target,\n data.offsets.host,\n data.placement\n )\n };\n\n return data;\n }\n\n const boundaries = getBoundaries(\n data.instance.target,\n data.instance.host,\n 0, // padding\n 'viewport',\n false // positionFixed\n );\n\n let placement = data.placement.split(' ')[0];\n let variation = data.placement.split(' ')[1] || '';\n\n const offsetsHost = data.offsets.host;\n const target = data.instance.target;\n const host = data.instance.host;\n\n const adaptivePosition = computeAutoPlacement('auto', offsetsHost, target, host, data.options.allowedPositions);\n const flipOrder = [placement, adaptivePosition];\n\n flipOrder.forEach((step, index) => {\n if (placement !== step || flipOrder.length === index + 1) {\n return;\n }\n\n placement = data.placement.split(' ')[0];\n\n // using floor because the host offsets may contain decimals we are not going to consider here\n const overlapsRef =\n (placement === 'left' &&\n Math.floor(data.offsets.target.right ?? 0) > Math.floor(data.offsets.host.left ?? 0)) ||\n (placement === 'right' &&\n Math.floor(data.offsets.target.left ?? 0) < Math.floor(data.offsets.host.right ?? 0)) ||\n (placement === 'top' &&\n Math.floor(data.offsets.target.bottom ?? 0) > Math.floor(data.offsets.host.top ?? 0)) ||\n (placement === 'bottom' &&\n Math.floor(data.offsets.target.top ?? 0) < Math.floor(data.offsets.host.bottom ?? 0));\n\n const overflowsLeft = Math.floor(data.offsets.target.left ?? 0) < Math.floor(boundaries.left ?? 0);\n const overflowsRight = Math.floor(data.offsets.target.right ?? 0) > Math.floor(boundaries.right ?? 0);\n const overflowsTop = Math.floor(data.offsets.target.top ?? 0) < Math.floor(boundaries.top ?? 0);\n const overflowsBottom = Math.floor(data.offsets.target.bottom ?? 0) > Math.floor(boundaries.bottom ?? 0);\n\n const overflowsBoundaries =\n (placement === 'left' && overflowsLeft) ||\n (placement === 'right' && overflowsRight) ||\n (placement === 'top' && overflowsTop) ||\n (placement === 'bottom' && overflowsBottom);\n\n // flip the variation if required\n const isVertical = ['top', 'bottom'].indexOf(placement) !== -1;\n const flippedVariation =\n ((isVertical && variation === 'left' && overflowsLeft) ||\n (isVertical && variation === 'right' && overflowsRight) ||\n (!isVertical && variation === 'left' && overflowsTop) ||\n (!isVertical && variation === 'right' && overflowsBottom));\n\n if (overlapsRef || overflowsBoundaries || flippedVariation) {\n if (overlapsRef || overflowsBoundaries) {\n placement = flipOrder[index + 1];\n }\n\n if (flippedVariation) {\n variation = getOppositeVariation(variation);\n }\n\n data.placement = placement + (variation ? ` ${variation}` : '');\n\n data.offsets.target = {\n ...data.offsets.target,\n ...getTargetOffsets(\n data.instance.target,\n data.offsets.host,\n data.placement\n )\n };\n }\n });\n\n return data;\n}\n","import {\n computeAutoPlacement,\n getReferenceOffsets,\n getTargetOffsets\n} from '../utils';\n\nimport { Data, Options } from '../models';\n\nexport function initData(\n targetElement: HTMLElement|null, hostElement: HTMLElement|null, position: string, options?: Options\n): Data|undefined {\n\n if (!targetElement || !hostElement) {\n return ;\n }\n\n const hostElPosition = getReferenceOffsets(targetElement, hostElement);\n\n if (!position.match(/^(auto)*\\s*(left|right|top|bottom|start|end)*$/)\n && !position.match(/^(left|right|top|bottom|start|end)*(?: (left|right|top|bottom|start|end))*$/)) {\n position = 'auto';\n }\n\n const placementAuto = !!position.match(/auto/g);\n\n // support old placements 'auto left|right|top|bottom'\n let placement = position.match(/auto\\s(left|right|top|bottom|start|end)/)\n ? position.split(' ')[1] || 'auto'\n : position;\n\n // Normalize placements that have identical main placement and variation (\"right right\" => \"right\").\n const matches = placement.match(/^(left|right|top|bottom|start|end)* ?(?!\\1)(left|right|top|bottom|start|end)?/);\n if (matches) {\n placement = matches[1] + (matches[2] ? ` ${matches[2]}` : '');\n }\n\n // \"left right\", \"top bottom\" etc. placements also considered incorrect.\n if (['left right', 'right left', 'top bottom', 'bottom top'].indexOf(placement) !== -1) {\n placement = 'auto';\n }\n\n placement = computeAutoPlacement(\n placement,\n hostElPosition,\n targetElement,\n hostElement,\n options ? options.allowedPositions : undefined\n );\n\n const targetOffset = getTargetOffsets(targetElement, hostElPosition, placement);\n\n return {\n options: options || {modifiers: {}},\n instance: {\n target: targetElement,\n host: hostElement,\n arrow: void 0\n },\n offsets: {\n target: targetOffset,\n host: hostElPosition,\n arrow: void 0\n },\n positionFixed: false,\n placement,\n placementAuto\n };\n}\n","import { getBoundaries, isModifierEnabled } from '../utils';\nimport { Data, Offsets } from '../models';\n\nexport function preventOverflow(data: Data) {\n if (!isModifierEnabled(data.options, 'preventOverflow')) {\n return data;\n }\n\n // NOTE: DOM access here\n // resets the target Offsets's position so that the document size can be calculated excluding\n // the size of the targetOffsets element itself\n const transformProp = 'transform';\n const targetStyles = data.instance.target.style; // assignment to help minification\n const { top, left, [transformProp]: transform } = targetStyles;\n targetStyles.top = '';\n targetStyles.left = '';\n targetStyles[transformProp] = '';\n\n const boundaries = getBoundaries(\n data.instance.target,\n data.instance.host,\n 0, // padding\n data.options.modifiers.preventOverflow?.boundariesElement || 'scrollParent',\n false // positionFixed\n );\n\n // NOTE: DOM access here\n // restores the original style properties after the offsets have been computed\n targetStyles.top = top;\n targetStyles.left = left;\n targetStyles[transformProp] = transform;\n\n const order = ['left', 'right', 'top', 'bottom'];\n\n const check = {\n primary(placement: keyof Offsets) {\n let value = data.offsets.target[placement];\n // options.escapeWithReference\n if ((data.offsets.target[placement] ?? 0) < (boundaries[placement] ?? 0)) {\n value = Math.max(data.offsets.target[placement] ?? 0, boundaries[placement] ?? 0);\n }\n\n return { [placement]: value };\n },\n secondary(placement: keyof Offsets) {\n const isPlacementHorizontal = placement === 'right';\n const mainSide = isPlacementHorizontal ? 'left' : 'top';\n const measurement = isPlacementHorizontal ? 'width' : 'height';\n let value = data.offsets.target[mainSide];\n\n // escapeWithReference\n if ((data.offsets.target[placement] ?? 0) > (boundaries[placement] ?? 0)) {\n value = Math.min(\n data.offsets.target[mainSide] ?? 0,\n (boundaries[placement] ?? 0) - data.offsets.target[measurement]\n );\n }\n\n return { [mainSide]: value };\n }\n };\n\n order.forEach((placement) => {\n const side = ['left', 'top', 'start'].indexOf(placement) !== -1 ? check['primary'] : check['secondary'];\n\n data.offsets.target = {\n ...data.offsets.target,\n ...side(placement as keyof Offsets)\n };\n });\n\n return data;\n}\n","import { Data } from '../models';\n\nexport function shift(data: Data): Data {\n const placement = data.placement;\n const basePlacement = placement.split(' ')[0];\n const shiftVariation = placement.split(' ')[1];\n\n if (shiftVariation) {\n const { host, target } = data.offsets;\n const isVertical = ['bottom', 'top'].indexOf(basePlacement) !== -1;\n const side = isVertical ? 'left' : 'top';\n const measurement = isVertical ? 'width' : 'height';\n\n const shiftOffsets = {\n start: { [side]: host[side] },\n end: {\n [side]: (host[side] ?? 0) + host[measurement] - target[measurement]\n }\n };\n\n data.offsets.target = {\n ...target, ...{\n [side]: (side === shiftVariation ? shiftOffsets.start[side] : shiftOffsets.end[side])\n }\n };\n }\n\n return data;\n}\n","/**\n * @copyright Valor Software\n * @copyright Federico Zivolo and contributors\n */\nimport { Renderer2 } from '@angular/core';\nimport { Data, Offsets, Options, MapPlacementInToRL } from './models';\n\nimport { arrow, flip, initData, preventOverflow, shift } from './modifiers';\n\nimport { getOffsets, getReferenceOffsets, setStyles, updateContainerClass } from './utils';\n\n\nexport class Positioning {\n position(hostElement: HTMLElement, targetElement: HTMLElement/*, round = true*/): Offsets | undefined {\n return this.offset(hostElement, targetElement/*, false*/);\n }\n\n offset(hostElement: HTMLElement, targetElement: HTMLElement/*, round = true*/): Offsets | undefined {\n return getReferenceOffsets(targetElement, hostElement);\n }\n\n positionElements(\n hostElement: HTMLElement | null,\n targetElement: HTMLElement | null,\n position: string,\n appendToBody?: boolean,\n options?: Options\n ): Data | undefined {\n const chainOfModifiers = [flip, shift, preventOverflow, arrow];\n const _position = MapPlacementInToRL[position as keyof typeof MapPlacementInToRL];\n const data = initData(targetElement, hostElement, _position, options);\n if (!data) {\n return;\n }\n\n return chainOfModifiers.reduce(\n (modifiedData, modifier) => modifier(modifiedData),\n data\n );\n }\n}\n\nconst positionService = new Positioning();\n\nexport function positionElements(\n hostElement: HTMLElement | null,\n targetElement: HTMLElement | null,\n placement: string,\n appendToBody?: boolean,\n options?: Options,\n renderer?: Renderer2\n): void {\n\n const data = positionService.positionElements(\n hostElement,\n targetElement,\n placement,\n appendToBody,\n options\n );\n\n if (!data) {\n return;\n }\n\n const offsets = getOffsets(data);\n\n setStyles(targetElement, {\n 'will-change': 'transform',\n top: '0px',\n left: '0px',\n transform: `translate3d(${offsets.left}px, ${offsets.top}px, 0px)`\n }, renderer);\n\n if (data.instance.arrow) {\n setStyles(data.instance.arrow, data.offsets.arrow, renderer);\n }\n\n updateContainerClass(data, renderer);\n}\n","import { Injectable, ElementRef, RendererFactory2, Inject, PLATFORM_ID, NgZone } from '@angular/core';\nimport { isPlatformBrowser } from '@angular/common';\n\nimport { positionElements } from './ng-positioning';\n\nimport { fromEvent, merge, of, animationFrameScheduler, Subject, Observable } from 'rxjs';\nimport { Options } from './models';\n\n\nexport interface PositioningOptions {\n /** The DOM element, ElementRef, or a selector string of an element which will be moved */\n element?: HTMLElement | ElementRef | string;\n\n /** The DOM element, ElementRef, or a selector string of an element which the element will be attached to */\n target?: HTMLElement | ElementRef | string;\n\n /**\n * A string of the form 'vert-attachment horiz-attachment' or 'placement'\n * - placement can be \"top\", \"bottom\", \"left\", \"right\"\n * not yet supported:\n * - vert-attachment can be any of 'top', 'middle', 'bottom'\n * - horiz-attachment can be any of 'left', 'center', 'right'\n */\n attachment?: string;\n\n /** A string similar to `attachment`. The one difference is that, if it's not provided,\n * `targetAttachment` will assume the mirror image of `attachment`.\n */\n targetAttachment?: string;\n\n /** A string of the form 'vert-offset horiz-offset'\n * - vert-offset and horiz-offset can be of the form \"20px\" or \"55%\"\n */\n offset?: string;\n\n /** A string similar to `offset`, but referring to the offset of the target */\n targetOffset?: string;\n\n /** If true component will be attached to body */\n appendToBody?: boolean;\n}\n\n\n@Injectable({providedIn: 'root'})\nexport class PositioningService {\n private options?: Options;\n private update$$ = new Subject<null>();\n private positionElements = new Map();\n private triggerEvent$?: Observable<number|Event|null>;\n private isDisabled = false;\n\n constructor(\n ngZone: NgZone,\n rendererFactory: RendererFactory2,\n @Inject(PLATFORM_ID) platformId: number\n ) {\n\n if (isPlatformBrowser(platformId)) {\n ngZone.runOutsideAngular(() => {\n this.triggerEvent$ = merge(\n fromEvent(window, 'scroll', { passive: true }),\n fromEvent(window, 'resize', { passive: true }),\n of(0, animationFrameScheduler),\n this.update$$\n );\n\n this.triggerEvent$.subscribe(() => {\n if (this.isDisabled) {\n return;\n }\n\n this.positionElements\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n .forEach((positionElement: any) => {\n positionElements(\n _getHtmlElement(positionElement.target),\n _getHtmlElement(positionElement.element),\n positionElement.attachment,\n