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AAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE;MAC7B,cAAc,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC;KAC5C;SAAM;MACL,cAAc,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC;KACjC;IAED,QACE,EAAC,IAAI,IAAC,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAChC,WAAK,KAAK,EAAC,WAAW,IACpB,WAAK,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,GAAG,EAAE,EAAE,KAAK,IAAI,CAAC,gBAAgB,GAAG,EAAoB,CAAC,EAAE,KAAK,EAAC,MAAM,IAClI,YAAM,IAAI,EAAC,SAAS,GAAQ,CACxB,EAEN,WACE,KAAK,EAAC,UAAU,EAChB,OAAO,EAAE,IAAI,CAAC,eAAe,EAC7B,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,MAAM,IAAI,SAAS,IAAI,IAAI,CAAC,UAAU,GAAG,OAAO,GAAG,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,UAAU,GAAG,OAAO,GAAG,UAAU,EAAE,GAC/H,EACP,WAAK,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,GAAG,EAAE,EAAE,KAAK,IAAI,CAAC,iBAAiB,GAAG,EAAoB,CAAC,IAC/G,YAAM,IAAI,EAAC,SAAS,GAAQ,CACxB,CACF,CACD,EACP;GACH;;;;;;;;;;","names":["LhMath.angleBetweenVec2","LhMath.getAlignmentPosition"],"sources":["./src/utils/math.ts","./src/components/patternlib-overlay-container/patternlib-overlay-container.scss?tag=patternlib-overlay-container&encapsulation=shadow","./src/components/patternlib-overlay-container/patternlib-overlay-container.tsx"],"sourcesContent":["/**\n * @internal\n */\nexport type Vec2 = {\n x: number;\n y: number;\n};\n\n/**\n * Calculates the angle between two vec2.\n * Ranges from -1 to -180 (top quadrant) and 0 to 180 (bottom quadrant).\n * The 0 angles start at the right side with 180 beeing on the left.\n *\n * @internal\n */\nexport function angleBetweenVec2(c: Vec2, e: Vec2): number {\n /** Calculate direction (difference) vector */\n const dy = e.y - c.y;\n const dx = e.x - c.x;\n\n /** Use arctan2 to get the angle of the direction vector in radians */\n let theta = Math.atan2(dy, dx);\n\n /** Calculate to degrees (-1 to -180 and 0 to 180) */\n theta *= 180 / Math.PI;\n\n return theta;\n}\n\n/**\n * @internal\n */\nexport type AlignmentPosition = 'right' | 'center' | 'left';\n\n/**\n * Calculates the alignment sector based on the angle to the center.\n *\n * @internal\n */\nexport function getAlignmentPosition(angle: number): AlignmentPosition {\n // 0 - 34 = left, 35 - 145 center, 146 to 180 = right\n const absAngle = Math.abs(angle);\n if (absAngle < 35) {\n return 'right';\n } else if (absAngle <= 145) {\n return 'center';\n } else {\n return 'left';\n }\n}\n","$flyout-arrow-size: 12px;\n\n:host {\n display: inline-block;\n --arrow-offset: #{$flyout-arrow-size};\n --arrow-from-left: calc(50% - #{$flyout-arrow-size});\n}\n\n.content {\n @apply relative;\n box-shadow: var(--shadow-elevation-middle);\n text-align: left;\n transition: opacity 0.15s linear;\n z-index: var(--layer-1500);\n max-height: 90vh;\n box-sizing: border-box;\n\n &.arrow {\n &:before {\n content: '';\n @apply absolute;\n background-color: transparent;\n width: 0;\n height: 0;\n left: var(--arrow-from-left);\n }\n\n &.top {\n &:before {\n bottom: -#{$flyout-arrow-size};\n border-left: #{$flyout-arrow-size} solid transparent;\n border-right: #{$flyout-arrow-size} solid transparent;\n }\n }\n\n &.right {\n &:before {\n left: -#{$flyout-arrow-size};\n top: calc(#{$flyout-arrow-size}/ 2);\n border-top: #{$flyout-arrow-size} solid transparent;\n border-bottom: #{$flyout-arrow-size} solid transparent;\n }\n }\n\n &.bottom {\n &:before {\n top: -#{$flyout-arrow-size};\n border-left: #{$flyout-arrow-size} solid transparent;\n border-right: #{$flyout-arrow-size} solid transparent;\n }\n }\n\n &.left {\n &:before {\n left: 100%;\n top: calc(#{$flyout-arrow-size}/ 2);\n border-top: #{$flyout-arrow-size} solid transparent;\n border-bottom: #{$flyout-arrow-size} solid transparent;\n }\n }\n }\n\n &.dark {\n @apply bg-gray-900 text-white;\n\n &.top {\n &:before {\n border-top: #{$flyout-arrow-size} solid var(--color-steel-900);\n }\n }\n\n &.right {\n &:before {\n border-right: #{$flyout-arrow-size} solid var(--color-steel-900);\n }\n }\n\n &.bottom {\n &:before {\n border-bottom: #{$flyout-arrow-size} solid var(--color-steel-900);\n }\n }\n\n &.left {\n &:before {\n border-left: #{$flyout-arrow-size} solid var(--color-steel-900);\n }\n }\n }\n\n &.light {\n @apply bg-white;\n &.top {\n &:before {\n border-top: #{$flyout-arrow-size} solid white;\n }\n }\n\n &.right {\n &:before {\n border-right: #{$flyout-arrow-size} solid white;\n }\n }\n\n &.bottom {\n &:before {\n border-bottom: #{$flyout-arrow-size} solid white;\n }\n }\n\n &.left {\n &:before {\n border-left: #{$flyout-arrow-size} solid white;\n }\n }\n }\n}\n\n.backdrop {\n @apply w-full h-full;\n top: 0;\n left: 0;\n background: rgba(58, 64, 70, 0.2);\n z-index: var(--layer-1500);\n}\n","import { Component, Element, Event, EventEmitter, h, Host, Method, Prop, State, Watch } from '@stencil/core';\n\nimport { PatternlibService } from '../../global/runtime';\nimport { ClassNames, LhClose, LhOpen } from '../../utils/interfaces';\nimport * as LhMath from '../../utils/math';\nimport { returnScreenSize, ScreenSize } from '../../utils/screen';\n\nexport type Position = 'top' | 'bottom' | 'right' | 'left' | 'auto';\nexport type ResolvedPosition = Exclude;\n\n@Component({\n tag: 'patternlib-overlay-container',\n styleUrl: 'patternlib-overlay-container.scss',\n shadow: true,\n})\nexport class PatternlibOverlayContainer {\n /**\n * If target is 'element', the flyout is positioned around the 'element' slot.\n * If target is 'center', the flyout is positioned at the center of the window.\n */\n @Prop() target: 'element' | 'center' = 'center';\n\n /**\n * If an arrow is shown between element and flyout.\n * Only works if target is 'element'.\n */\n @Prop() showArrow = false;\n\n /**\n * Set the variant.\n */\n @Prop() variant: 'dark' | 'light' = 'light';\n\n /**\n * Fit content width. Sets the width of the content. If 'element' is set, the width of the slot='element' is used.\n * This logic is overridden if contentWidth is set.\n */\n @Prop() fit: 'auto' | 'element' = 'auto';\n\n /**\n * Show flyout property. Changes are watched.\n */\n @Prop() show: boolean | string = false;\n\n /**\n * Close flyout if a window scroll event was received. Only works with `target='element'`.\n */\n @Prop() closeOnScroll = true;\n\n /**\n * Disables the button and click functionality.\n */\n @Prop() disabled = false;\n\n /**\n * If true, the `overlay-container` does not attach any click event handlers to open the flyout on `element` click.\n * This allows the implementation side to handle any open or close logic themselves.\n */\n @Prop() disableClickHandlers = false;\n\n /**\n * Host width.\n */\n @Prop() width = 'auto';\n\n /**\n * Content width basing on external retrieved width, e.g. a parent object\n */\n @Prop() contentWidth?: number;\n\n /**\n * Set the position of the flyout.\n */\n @Prop() position: Position | [mobile: Position, tablet: Position, desktop: Position] = 'auto';\n\n /**\n * Fix the alignment of the flyout.\n */\n @Prop() alignment?: 'right' | 'center' | 'left' | 'auto' = 'auto';\n\n /**\n * Additional offset added to the y axis if the flyout position is top.\n */\n @Prop() offsetTopY = 0;\n\n /**\n * Additional offset added to the y axis if the flyout position is bottom.\n */\n @Prop() offsetBottomY = 0;\n\n /**\n * Additional offset added to the X axis if the flyout position is right.\n */\n @Prop() offsetLeftX = 0;\n\n /**\n * Additional offset added to the X axis if the flyout position is left.\n */\n @Prop() offsetRightX = 0;\n\n /**\n * Wether the component is registered at the FlyoutGroups handler or not.\n */\n @Prop() useFlyoutGroups = false;\n\n /**\n * Flyout group name. Only works if useFlyoutGroups is true.\n */\n @Prop() groupName?: string;\n\n /**\n * Only updates to the styles triggers a re-rendering.\n */\n @State() contentStyles = this.getDefaultStyles();\n\n /**\n * Host element ref.\n */\n @Element() hostElement: HTMLElement;\n\n /**\n * Triggers when the flyout is opened.\n * Set bubbles to false to prevent other components to receive that lhOpen-Event (unwanted side-effects).\n */\n @Event({ eventName: 'lhOpen', bubbles: false }) open: EventEmitter;\n\n /**\n * Triggers when the flyout is closed.\n */\n @Event({ eventName: 'lhClose' }) close: EventEmitter;\n\n /** Size/offset of the arrow between container and element */\n private arrowOffset = 15;\n\n private flyoutPosition: ResolvedPosition = 'bottom';\n private flyoutAlignment: 'right' | 'center' | 'left' = 'center';\n\n private elementTargetRef: HTMLDivElement | null = null;\n private contentElementRef: HTMLDivElement | null = null;\n\n private showFlyout = false;\n private isOpening = false;\n private initialConnect = false;\n\n connectedCallback() {\n if (this.useFlyoutGroups && this.initialConnect) {\n PatternlibService.registerFlyout(this, this.groupName);\n }\n this.initialConnect = true;\n }\n\n componentWillLoad() {\n this.showFlyout = this.show === 'true' || this.show === true;\n\n if (this.showFlyout) {\n setTimeout(() => this.calculateContentStyles(), 0); // Next tick, to get correct references and values.\n } else {\n this.calculateContentStyles();\n }\n }\n\n componentDidLoad() {\n window.addEventListener(\n 'scroll',\n () => {\n if (this.showFlyout && this.target === 'element') {\n if (this.closeOnScroll) {\n this.internalCloseSync();\n } else {\n this.calculateContentStyles();\n }\n }\n },\n true, // capture\n );\n\n window.addEventListener('resize', () => {\n if (this.showFlyout) {\n this.calculateContentStyles();\n }\n });\n\n // Close on outside click. Also only if the flyout was not opened in the same lifecycle.\n window.addEventListener(\n 'click',\n (e: Event) => {\n if (!this.disableClickHandlers && this.showFlyout && !this.isOpening) {\n const target = e.target as HTMLElement;\n if (!this.hostElement.contains(target)) {\n this.internalCloseSync();\n }\n }\n },\n false,\n );\n if (this.useFlyoutGroups) {\n PatternlibService.registerFlyout(this, this.groupName);\n }\n }\n\n componentDidRender() {\n this.isOpening = false;\n }\n\n disconnectedCallback() {\n if (this.useFlyoutGroups) {\n PatternlibService.unregisterFlyout(this, this.groupName);\n }\n }\n\n @Watch('show')\n async showWatcher(newValue: boolean | string, _oldValue: boolean | string): Promise {\n if ((_oldValue === false || _oldValue === 'false') && (newValue === true || newValue === 'true')) {\n await this.openFlyout();\n }\n\n if ((_oldValue === true || _oldValue === 'true') && (newValue === false || newValue === 'false')) {\n await this.closeFlyout();\n }\n }\n\n /**\n * Programmatically open the flyout.\n */\n @Method()\n async openFlyout(): Promise {\n this.internalOpenSync(false);\n }\n\n /**\n * Programmatically close the flyout.\n */\n @Method()\n async closeFlyout(): Promise {\n this.internalCloseSync();\n }\n\n /**\n * Programmatically trigger a recalculation of the flyout position and alignment.\n */\n @Method()\n async updateFlyout(): Promise {\n this.calculateContentStyles();\n }\n\n /**\n * Programmatically cloes all other flyout menus in registered group.\n */\n\n @Method()\n async closeFlyoutmenu(): Promise {\n this.internalCloseSync();\n }\n\n private internalOpenSync = (toggle: boolean): void => {\n if (!this.disabled) {\n if (toggle) {\n this.showFlyout = !this.showFlyout;\n } else {\n this.showFlyout = true;\n }\n\n this.isOpening = this.showFlyout;\n this.calculateContentStyles();\n\n if (this.showFlyout === true) {\n this.open.emit();\n } else {\n this.close.emit();\n }\n if (this.useFlyoutGroups && this.showFlyout) {\n PatternlibService.closeAllOtherFlyouts(this, this.groupName);\n }\n }\n };\n\n private internalCloseSync = (): void => {\n this.showFlyout = false;\n this.calculateContentStyles();\n\n this.close.emit();\n };\n\n private onTargetClick = e => {\n if (!this.disableClickHandlers) {\n e.stopPropagation();\n this.internalOpenSync(true);\n }\n };\n\n /** Prevent space triggering onclick */\n private handleKeyUp = e => {\n if (e.code == 'Space') {\n e.preventDefault();\n }\n };\n\n private onBackdropClick = e => {\n if (!this.disableClickHandlers) {\n e.stopPropagation();\n this.internalCloseSync();\n }\n };\n\n private calculateContentStyles(): void {\n let styles: { [key: string]: string } = {\n opacity: '0.0',\n visibility: 'hidden',\n position: 'absolute',\n left: '-99999px',\n top: '-99999px',\n };\n\n if (this.contentElementRef != null) {\n this.calculatePositionAndAlignment();\n\n switch (this.target) {\n case 'element':\n styles = this.getElementTargetContentStyles();\n break;\n\n case 'center':\n styles = this.getPositionalTargetContentStyles();\n }\n }\n\n this.contentStyles = styles;\n }\n\n /**\n * Calculates the styles if target is positional (like 'center').\n */\n private getPositionalTargetContentStyles(): { [key: string]: string } {\n let style = this.getDefaultStyles();\n const contentRect = this.contentElementRef.getBoundingClientRect();\n\n if (this.target === 'center') {\n style = {\n ...style,\n left: `${(window.innerWidth - contentRect.width) / 2}px`,\n top: `${(window.innerHeight - contentRect.height) / 2}px`,\n };\n }\n\n return style;\n }\n\n private getDefaultStyles(): { [key: string]: string } {\n return {\n visibility: this.showFlyout ? 'visible' : 'hidden',\n position: this.showFlyout ? 'fixed' : 'absolute',\n opacity: this.showFlyout ? '1.0' : '0.0',\n left: '-9999px',\n top: '-99999px',\n };\n }\n\n /**\n * Calculates the styles if target is 'element'.\n */\n private getElementTargetContentStyles() {\n let styles = this.getDefaultStyles();\n\n if (this.elementTargetRef != null && this.showFlyout === true) {\n const targetRect = this.elementTargetRef.getBoundingClientRect();\n const contentRect = this.contentElementRef.getBoundingClientRect();\n\n if (this.fit === 'element') {\n contentRect.width = targetRect.width;\n }\n\n const availableWidth = window.innerWidth;\n\n let flyoutContentWidth = this.contentWidth != null ? this.contentWidth : contentRect.width;\n flyoutContentWidth = Math.min(flyoutContentWidth, availableWidth);\n\n let top: number | 'auto' = targetRect.top;\n let bottom: number | 'auto' = targetRect.bottom;\n let left = targetRect.left;\n\n if (this.flyoutPosition === 'bottom') {\n bottom = 'auto';\n top = top + targetRect.height + (this.showArrow ? this.arrowOffset : 0) + this.offsetBottomY;\n } else if (this.flyoutPosition === 'right') {\n left = left + targetRect.width + (this.showArrow ? this.arrowOffset : 0) + this.offsetLeftX;\n bottom = 'auto';\n } else if (this.flyoutPosition === 'left') {\n left = left - flyoutContentWidth - (this.showArrow ? this.arrowOffset : 0) - this.offsetRightX;\n bottom = 'auto';\n } else {\n top = 'auto';\n bottom = window.innerHeight - targetRect.top + (this.showArrow ? this.arrowOffset : 0) - this.offsetTopY;\n }\n\n // align them horizontal only when position is not right or left beneath the content (it doesn't make sense in\n // those cases to align them horizontal and may lead to overlapping the origin element).\n if (this.flyoutPosition !== 'right' && this.flyoutPosition !== 'left') {\n // adjust alignment offsets.\n if (this.flyoutAlignment === 'center') {\n const center = targetRect.left + targetRect.width / 2;\n left = center - flyoutContentWidth / 2;\n } else if (this.flyoutAlignment === 'right') {\n const right = targetRect.left + targetRect.width;\n left = right - flyoutContentWidth;\n }\n }\n\n // Cleanup position and content width based on if we are too close to screen borders.\n if (flyoutContentWidth >= availableWidth - 5) {\n left = 5;\n flyoutContentWidth = availableWidth - 5;\n } else if (left + flyoutContentWidth >= availableWidth - 5) {\n left = availableWidth - flyoutContentWidth - 22.5;\n }\n\n // Constrain within a 5px padding to the left and right.\n left = Math.max(left, 5);\n left = Math.min(left, availableWidth - flyoutContentWidth - 10);\n\n // Offset in px from the left of the flyout content to the target center.\n this.hostElement.style.setProperty('--arrow-from-left', `${targetRect.left - left + targetRect.width / 2 - 12}px`);\n this.hostElement.style.setProperty('--arrow-offset', `${targetRect.width / 2}px`);\n\n styles = {\n ...styles,\n position: 'fixed',\n top: top === 'auto' ? top : `${top}px`,\n bottom: bottom === 'auto' ? bottom : `${bottom}px`,\n left: `${left}px`,\n width: `${flyoutContentWidth}px`,\n };\n }\n\n return styles;\n }\n\n /**\n * Calculates the Flyout position (vertical) and alignment (horizontal).\n */\n private calculatePositionAndAlignment(): void {\n const viewportCenter = {\n x: window.innerWidth / 2,\n y: window.innerHeight / 2,\n };\n\n const rect = this.elementTargetRef.getBoundingClientRect();\n const targetCenter = {\n x: rect.left + rect.width / 2,\n y: rect.top + rect.height / 2,\n };\n\n const angle = LhMath.angleBetweenVec2(viewportCenter, targetCenter);\n const screenSize = returnScreenSize();\n\n const breakpointPosition = this.getFinalPosition(screenSize);\n this.flyoutPosition = this.resolvePosition(breakpointPosition, angle);\n\n this.flyoutAlignment = this.alignment == null || this.alignment == 'auto' ? LhMath.getAlignmentPosition(angle) : this.alignment;\n\n // Adjust alignment based on position to the left and right borders.\n // TODO: Would be better to get the size of the content slot so \"slotWidth / 2\" would be the correct value here.\n if (targetCenter.x < 100) {\n this.flyoutAlignment = 'left';\n } else if (window.innerWidth - targetCenter.x < 100) {\n this.flyoutAlignment = 'right';\n }\n }\n\n /**\n * Extracts the position, even if position is a breakpoint specific array.\n */\n private getFinalPosition(screenSize: ScreenSize): Position {\n if (Array.isArray(this.position)) {\n switch (screenSize) {\n case 'isMobile':\n return this.position[0];\n case 'isTablet':\n return this.position[1];\n case 'isDesktop':\n return this.position[2];\n }\n }\n\n return this.position;\n }\n\n private resolvePosition(pos: Position, angle: number): ResolvedPosition {\n if (pos == 'auto') {\n return angle >= 0 ? 'top' : 'bottom';\n }\n\n return pos;\n }\n\n render() {\n const contentClasses: ClassNames = {\n 'content': true,\n 'arrow': this.showArrow && this.target === 'element' && this.showFlyout,\n 'z-10': true,\n [this.variant]: true,\n };\n\n if (this.target === 'element') {\n contentClasses[this.flyoutPosition] = true;\n } else {\n contentClasses['window'] = true;\n }\n\n return (\n \n
\n
(this.elementTargetRef = el as HTMLDivElement)} class=\"flex\">\n \n
\n\n
\n
(this.contentElementRef = el as HTMLDivElement)}>\n \n
\n \n
\n );\n }\n}\n"],"version":3}