@spectrum-web-components/overlay 1.12.0-testing.20260223092154 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["Overlay.ts"],
4
- "sourcesContent": ["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nimport {\n html,\n nothing,\n PropertyValues,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n property,\n query,\n queryAssignedElements,\n state,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport {\n ifDefined,\n StyleInfo,\n styleMap,\n} from '@spectrum-web-components/base/src/directives.js';\nimport {\n ElementResolutionController,\n elementResolverUpdatedSymbol,\n} from '@spectrum-web-components/reactive-controllers/src/ElementResolution.js';\nimport { randomID } from '@spectrum-web-components/shared/src/random-id.js';\n\nimport { AbstractOverlay, nextFrame } from './AbstractOverlay.js';\nimport type { ClickController } from './ClickController.js';\nimport type { HoverController } from './HoverController.js';\nimport type { LongpressController } from './LongpressController.js';\nimport type {\n OpenableElement,\n OverlayState,\n OverlayTypes,\n Placement,\n TriggerInteraction,\n} from './overlay-types.js';\nimport { OverlayNoPopover } from './OverlayNoPopover.js';\nimport { OverlayPopover } from './OverlayPopover.js';\nimport { overlayStack } from './OverlayStack.js';\nimport { PlacementController } from './PlacementController.js';\nimport { VirtualTrigger } from './VirtualTrigger.js';\nexport { LONGPRESS_INSTRUCTIONS } from './LongpressController.js';\nimport { FocusTrap } from 'focus-trap';\n\nimport styles from './overlay.css.js';\nimport {\n removeSlottableRequest,\n SlottableRequestEvent,\n} from './slottable-request-event.js';\nimport { strategies } from './strategies.js';\n\nconst browserSupportsPopover = 'showPopover' in document.createElement('div');\n\n// Start the base class and add the popover or no-popover functionality\nlet ComputedOverlayBase = OverlayPopover(AbstractOverlay);\nif (!browserSupportsPopover) {\n ComputedOverlayBase = OverlayNoPopover(AbstractOverlay);\n}\n\n/**\n * @element sp-overlay\n *\n * @slot default - The content that will be displayed in the overlay\n *\n * @fires sp-opened - announces that an overlay has completed any entry animations\n * @fires sp-closed - announce that an overlay has completed any exit animations\n * @fires slottable-request - requests to add or remove slottable content\n *\n * @attr {string} placement - The placement of the overlay relative to the trigger\n * @attr {number} offset - The distance between the overlay and the trigger\n * @attr {boolean} disabled - Whether the overlay trigger is disabled\n * @attr {string} receives-focus - How focus should be handled ('true'|'false'|'auto')\n * @attr {boolean} delayed - Whether the overlay should wait for a warm-up period before opening\n * @attr {boolean} open - Whether the overlay is currently open\n * @attr {boolean} allow-outside-click - DEPRECATED: Whether clicks outside the overlay should close it (not recommended for accessibility)\n */\nexport class Overlay extends ComputedOverlayBase {\n static override styles = [styles];\n\n /**\n * An Overlay that is `delayed` will wait until a warm-up period of 1000ms\n * has completed before opening. Once the warm-up period has completed, all\n * subsequent Overlays will open immediately. When no Overlays are opened,\n * a cool-down period of 1000ms will begin. Once the cool-down has completed,\n * the next Overlay to be opened will be subject to the warm-up period if\n * provided that option.\n *\n * This behavior helps to manage the performance and user experience by\n * preventing multiple overlays from opening simultaneously and ensuring\n * a smooth transition between opening and closing overlays.\n *\n * @type {boolean}\n * @default false\n */\n @property({ type: Boolean })\n override get delayed(): boolean {\n return this.elements.at(-1)?.hasAttribute('delayed') || this._delayed;\n }\n\n override set delayed(delayed: boolean) {\n this._delayed = delayed;\n }\n\n private _delayed = false;\n\n /**\n * A reference to the dialog element within the overlay.\n * This element is expected to have `showPopover` and `hidePopover` methods.\n */\n @query('.dialog')\n override dialogEl!: HTMLDialogElement & {\n showPopover(): void;\n hidePopover(): void;\n };\n\n /**\n * Indicates whether the overlay is currently functional or not.\n *\n * When set to `true`, the overlay is disabled, and any active strategy is aborted.\n * The overlay will also close if it is currently open. When set to `false`, the\n * overlay will re-bind events and re-open if it was previously open.\n *\n * @type {boolean}\n * @default false\n */\n @property({ type: Boolean })\n override get disabled(): boolean {\n return this._disabled;\n }\n\n override set disabled(disabled: boolean) {\n this._disabled = disabled;\n if (disabled) {\n // Abort any active strategy and close the overlay if it is currently open\n this.strategy?.abort();\n this.wasOpen = this.open;\n this.open = false;\n } else {\n // Re-bind events and re-open the overlay if it was previously open\n this.bindEvents();\n this.open = this.open || this.wasOpen;\n this.wasOpen = false;\n }\n }\n\n private _disabled = false;\n\n /**\n * A query to gather all elements slotted into the default slot, excluding elements\n * with the slot name \"longpress-describedby-descriptor\".\n */\n @queryAssignedElements({\n flatten: true,\n selector: ':not([slot=\"longpress-describedby-descriptor\"], slot)',\n })\n override elements!: OpenableElement[];\n\n /**\n * A reference to the parent overlay that should be force-closed, if any.\n */\n public parentOverlayToForceClose?: Overlay;\n\n /**\n * Determines if the overlay has a non-virtual trigger element.\n *\n * @returns {boolean} `true` if the trigger element is not a virtual trigger, otherwise `false`.\n */\n private get hasNonVirtualTrigger(): boolean {\n return (\n !!this.triggerElement && !(this.triggerElement instanceof VirtualTrigger)\n );\n }\n\n /**\n * The `offset` property accepts either a single number to define the offset of the\n * Overlay along the main axis from the trigger, or a 2-tuple to define the offset\n * along both the main axis and the cross axis. This option has no effect when there\n * is no trigger element.\n *\n * @type {number | [number, number]}\n * @default 0\n */\n @property({ type: Number })\n override offset: number | [number, number] = 0;\n\n /**\n * Provides an instance of the `PlacementController` for managing the positioning\n * of the overlay relative to its trigger element.\n *\n * If the `PlacementController` instance does not already exist, it is created and\n * assigned to the `_placementController` property.\n *\n * @protected\n * @returns {PlacementController} The `PlacementController` instance.\n */\n protected override get placementController(): PlacementController {\n if (!this._placementController) {\n this._placementController = new PlacementController(this);\n }\n return this._placementController;\n }\n\n /**\n * Indicates whether the Overlay is projected onto the \"top layer\" or not.\n *\n * When set to `true`, the overlay is open and visible. When set to `false`, the overlay is closed and hidden.\n *\n * @type {boolean}\n * @default false\n */\n @property({ type: Boolean, reflect: true })\n override get open(): boolean {\n return this._open;\n }\n\n override set open(open: boolean) {\n // Don't respond if the overlay is disabled.\n if (open && this.disabled) {\n return;\n }\n\n // Don't respond if the state is not changing.\n if (open === this.open) {\n return;\n }\n\n // Don't respond if the overlay is in the shadow state during a longpress.\n // The shadow state occurs when the first \"click\" would normally close the popover.\n if (this.strategy?.activelyOpening && !open) {\n return;\n }\n\n // Update the internal _open property.\n this._open = open;\n\n // Increment the open count if the overlay is opening.\n if (this.open) {\n Overlay.openCount += 1;\n }\n\n // Request an update to re-render the component if necessary.\n this.requestUpdate('open', !this.open);\n\n // Request slottable content if the overlay is opening.\n if (this.open) {\n this.requestSlottable();\n }\n }\n\n private _open = false;\n\n /**\n * Tracks the number of overlays that have been opened.\n *\n * This static property is used to manage the stacking context of multiple overlays.\n *\n * @type {number}\n * @default 1\n */\n static openCount = 1;\n\n /**\n * Instruct the Overlay where to place itself in relationship to the trigger element.\n *\n * @type {\"top\" | \"top-start\" | \"top-end\" | \"right\" | \"right-start\" | \"right-end\" | \"bottom\" | \"bottom-start\" | \"bottom-end\" | \"left\" | \"left-start\" | \"left-end\"}\n */\n @property()\n override placement?: Placement;\n\n /**\n * The state in which the last `request-slottable` event was dispatched.\n *\n * This property ensures that overlays do not dispatch the same state twice in a row.\n *\n * @type {boolean}\n * @default false\n */\n private lastRequestSlottableState = false;\n\n /**\n * Whether to pass focus to the overlay once opened, or\n * to the appropriate value based on the \"type\" of the overlay\n * when set to `\"auto\"`.\n *\n * @type {'true' | 'false' | 'auto'}\n * @default 'auto'\n */\n @property({ attribute: 'receives-focus' })\n override receivesFocus: 'true' | 'false' | 'auto' = 'auto';\n\n /**\n * @deprecated This property will be removed in a future version.\n * We do not recommend using this property for accessibility reasons.\n * It allows clicks outside the overlay to close it, which can cause\n * unexpected behavior and accessibility issues.\n *\n * @type {boolean}\n * @default false\n */\n @property({ type: Boolean, attribute: 'allow-outside-click' })\n allowOutsideClick = false;\n\n /**\n * A reference to the slot element within the overlay.\n *\n * This element is used to manage the content slotted into the overlay.\n *\n * @type {HTMLSlotElement}\n */\n @query('slot')\n slotEl!: HTMLSlotElement;\n\n /**\n * The current state of the overlay.\n *\n * This property reflects the current state of the overlay, such as 'opened' or 'closed'.\n * When the state changes, it triggers the appropriate actions and updates the component.\n *\n * @type {OverlayState}\n * @default 'closed'\n */\n @state()\n override get state(): OverlayState {\n return this._state;\n }\n\n override set state(state) {\n // Do not respond if the state is not changing.\n if (state === this.state) {\n return;\n }\n\n const oldState = this.state;\n\n this._state = state;\n\n // Complete the opening strategy if the state is 'opened' or 'closed'.\n if (this.state === 'opened' || this.state === 'closed') {\n this.strategy?.shouldCompleteOpen();\n }\n\n // Request an update to re-render the component if necessary.\n this.requestUpdate('state', oldState);\n }\n\n override _state: OverlayState = 'closed';\n\n /**\n * The interaction strategy for opening the overlay.\n * This can be a ClickController, HoverController, or LongpressController.\n */\n public strategy?: ClickController | HoverController | LongpressController;\n\n /**\n * The padding around the tip of the overlay.\n * This property defines the padding around the tip of the overlay, which can be used to adjust its positioning.\n *\n * @type {number}\n */\n @property({ type: Number, attribute: 'tip-padding' })\n tipPadding?: number;\n\n /**\n * An optional ID reference for the trigger element combined with the optional\n * interaction (click | hover | longpress) by which the overlay should open.\n * The format is `trigger@interaction`, e.g., `trigger@click` opens the overlay\n * when an element with the ID \"trigger\" is clicked.\n *\n * @type {string}\n */\n @property()\n trigger?: string;\n\n /**\n * An element reference for the trigger element that the overlay should relate to.\n * This property is not reflected as an attribute.\n *\n * @type {HTMLElement | VirtualTrigger | null}\n */\n @property({ attribute: false })\n override triggerElement: HTMLElement | VirtualTrigger | null = null;\n\n /**\n * The specific interaction to listen for on the `triggerElement` to open the overlay.\n * This property is not reflected as an attribute.\n *\n * @type {TriggerInteraction}\n */\n @property({ attribute: false })\n triggerInteraction?: TriggerInteraction;\n\n /**\n * Configures the open/close heuristics of the Overlay.\n *\n * @type {\"auto\" | \"hint\" | \"manual\" | \"modal\" | \"page\"}\n * @default \"auto\"\n */\n @property()\n override type: OverlayTypes = 'auto';\n\n /**\n * Tracks whether the overlay was previously open.\n * This is used to restore the open state when re-enabling the overlay.\n *\n * @type {boolean}\n * @default false\n */\n protected wasOpen = false;\n\n /**\n * Focus trap to keep focus within the dialog\n *\n * @private\n */\n private _focusTrap: FocusTrap | null = null;\n\n /**\n * Provides an instance of the `ElementResolutionController` for managing the element\n * that the overlay should be associated with. If the instance does not already exist,\n * it is created and assigned to the `_elementResolver` property.\n *\n * @protected\n * @returns {ElementResolutionController} The `ElementResolutionController` instance.\n */\n protected override get elementResolver(): ElementResolutionController {\n if (!this._elementResolver) {\n this._elementResolver = new ElementResolutionController(this);\n }\n\n return this._elementResolver;\n }\n\n /**\n * Determines the value for the popover attribute based on the overlay type.\n *\n * @private\n * @returns {'auto' | 'manual' | undefined} The popover value or undefined if not applicable.\n */\n private get popoverValue(): 'auto' | 'manual' | undefined {\n const hasPopoverAttribute = 'popover' in this;\n\n if (!hasPopoverAttribute) {\n return undefined;\n }\n\n switch (this.type) {\n case 'modal':\n // Use 'manual' to allow multiple modal overlays to be visible simultaneously.\n // The browser's 'auto' popover only allows one at a time (light dismiss closes others).\n // This restores the stacking behavior that existed when using showModal().\n // The OverlayStack handles Escape key closing for modal overlays.\n return 'manual';\n case 'page':\n return 'manual';\n case 'hint':\n return 'manual';\n default:\n return this.type;\n }\n }\n\n /**\n * Determines if the overlay requires positioning based on its type and state.\n *\n * @protected\n * @returns {boolean} True if the overlay requires positioning, otherwise false.\n */\n protected get requiresPositioning(): boolean {\n // Do not position \"page\" overlays as they should block the entire UI.\n if (this.type === 'page' || !this.open) {\n return false;\n }\n\n // Do not position content without a trigger element, as there is nothing to position it relative to.\n // Do not automatically position content unless it is a \"hint\".\n if (!this.triggerElement || (!this.placement && this.type !== 'hint')) {\n return false;\n }\n\n return true;\n }\n\n /**\n * Determines if the overlay needs a modal backdrop to block external clicks.\n * Only page overlays need the backdrop since they don't have light dismiss.\n * Modal overlays use popover=\"manual\" for stacking and handle light dismiss\n * via handlePointerup in OverlayStack.\n */\n protected get needsModalBackdrop(): boolean {\n return this.open && (this.type === 'modal' || this.type === 'page');\n }\n\n /**\n * Manages the positioning of the overlay relative to its trigger element.\n *\n * This method calculates the necessary parameters for positioning the overlay,\n * such as offset, placement, and tip padding, and then delegates the actual\n * positioning to the `PlacementController`.\n *\n * @protected\n * @override\n */\n protected override managePosition(): void {\n // Do not proceed if positioning is not required or the overlay is not open.\n if (!this.requiresPositioning || !this.open) {\n return;\n }\n\n const offset = this.offset || 0;\n\n const trigger = this.triggerElement as HTMLElement;\n\n const placement = (this.placement as Placement) || 'right';\n\n const tipPadding = this.tipPadding;\n\n this.placementController.placeOverlay(this.dialogEl, {\n offset,\n placement,\n tipPadding,\n trigger,\n type: this.type,\n });\n }\n\n /**\n * Manages the process of opening the popover.\n *\n * This method handles the necessary steps to open the popover, including managing delays,\n * ensuring the popover is in the DOM, making transitions, and applying focus.\n *\n * @protected\n * @override\n * @returns {Promise<void>} A promise that resolves when the popover has been fully opened.\n */\n protected override async managePopoverOpen(): Promise<void> {\n // Call the base class method to handle any initial setup.\n super.managePopoverOpen();\n\n const targetOpenState = this.open;\n\n // Ensure the open state has not changed before proceeding.\n if (this.open !== targetOpenState) {\n return;\n }\n\n // Manage any delays before opening the popover.\n await this.manageDelay(targetOpenState);\n\n if (this.open !== targetOpenState) {\n return;\n }\n\n // Only wait for next frame if `longpress` is the trigger.\n // In Safari, awaiting nextFrame here causes layout issues\n // when rendering trays inside modals, so we skip it otherwise.\n if (this.triggerInteraction === 'longpress') {\n await nextFrame();\n }\n\n // Ensure the popover is in the DOM before proceeding.\n await this.ensureOnDOM(targetOpenState);\n\n if (this.open !== targetOpenState) {\n return;\n }\n\n // Make any necessary transitions for opening the popover.\n const focusEl = await this.makeTransition(targetOpenState);\n\n if (this.open !== targetOpenState) {\n return;\n }\n if (targetOpenState) {\n const focusTrap = await import('focus-trap');\n this._focusTrap = focusTrap.createFocusTrap(this.dialogEl, {\n initialFocus: focusEl || undefined,\n tabbableOptions: {\n getShadowRoot: true,\n },\n fallbackFocus: () => {\n // set tabIndex to -1 allow the focus-trap to still be applied\n this.dialogEl.setAttribute('tabIndex', '-1');\n return this.dialogEl;\n },\n // disable escape key capture to close the overlay, the focus-trap library captures it otherwise\n escapeDeactivates: false,\n allowOutsideClick: this.allowOutsideClick,\n });\n\n if (this.type === 'modal' || this.type === 'page') {\n this._focusTrap.activate();\n }\n }\n // Apply focus to the appropriate element after opening the popover.\n await this.applyFocus(targetOpenState, focusEl);\n }\n\n /**\n * Applies focus to the appropriate element after the popover has been opened.\n *\n * This method handles the focus management for the overlay, ensuring that the correct\n * element receives focus based on the overlay's type and state.\n *\n * @protected\n * @override\n * @param {boolean} targetOpenState - The target open state of the overlay.\n * @param {HTMLElement | null} focusEl - The element to focus after opening the popover.\n * @returns {Promise<void>} A promise that resolves when the focus has been applied.\n */\n protected override async applyFocus(\n targetOpenState: boolean,\n focusEl: HTMLElement | null\n ): Promise<void> {\n // Do not move focus when explicitly told not to or when the overlay is a \"hint\".\n if (this.receivesFocus === 'false' || this.type === 'hint') {\n return;\n }\n\n // Wait for the next two animation frames to ensure the DOM is updated.\n await nextFrame();\n await nextFrame();\n\n // If the open state has changed during the delay, do not proceed.\n if (targetOpenState === this.open && !this.open) {\n // If the overlay is closing and the trigger element is still focused, return focus to the trigger element.\n if (\n this.hasNonVirtualTrigger &&\n this.contains((this.getRootNode() as Document).activeElement)\n ) {\n (this.triggerElement as HTMLElement).focus();\n }\n return;\n }\n\n // Apply focus to the specified focus element.\n focusEl?.focus();\n }\n\n /**\n * Returns focus to the trigger element if the overlay is closed.\n *\n * This method ensures that focus is returned to the trigger element when the overlay is closed,\n * unless the overlay is of type \"hint\" or the focus is already outside the overlay.\n *\n * @protected\n * @override\n */\n protected override returnFocus(): void {\n // Do not proceed if the overlay is open or if the overlay type is \"hint\".\n if (this.open || this.type === 'hint') {\n return;\n }\n\n /**\n * Retrieves the ancestors of the currently focused element.\n *\n * @returns {HTMLElement[]} An array of ancestor elements.\n */\n const getAncestors = (): HTMLElement[] => {\n const ancestors: HTMLElement[] = [];\n\n // eslint-disable-next-line swc/document-active-element\n let currentNode = document.activeElement;\n\n // Traverse the shadow DOM to find the active element.\n while (currentNode?.shadowRoot?.activeElement) {\n currentNode = currentNode.shadowRoot.activeElement;\n }\n\n // Traverse the DOM tree to collect ancestor elements.\n while (currentNode) {\n const ancestor =\n currentNode.assignedSlot ||\n currentNode.parentElement ||\n (currentNode.getRootNode() as ShadowRoot)?.host;\n if (ancestor) {\n ancestors.push(ancestor as HTMLElement);\n }\n currentNode = ancestor;\n }\n return ancestors;\n };\n\n // Check if focus should be returned to the trigger element.\n if (\n this.receivesFocus !== 'false' &&\n !!(this.triggerElement as HTMLElement)?.focus &&\n (this.contains((this.getRootNode() as Document).activeElement) ||\n getAncestors().includes(this) ||\n // eslint-disable-next-line swc/document-active-element\n document.activeElement === document.body)\n ) {\n // Return focus to the trigger element.\n (this.triggerElement as HTMLElement).focus();\n }\n }\n\n /**\n * Handles the focus out event to close the overlay if the focus moves outside of it.\n *\n * This method ensures that the overlay is closed when the focus moves to an element\n * outside of the overlay, unless the focus is moved to a related element.\n *\n * @private\n * @param {FocusEvent} event - The focus out event.\n */\n private closeOnFocusOut = (event: FocusEvent): void => {\n // If the related target (newly focused element) is not known, do nothing.\n if (!event.relatedTarget) {\n return;\n }\n\n // Create a custom event to query the relationship of the newly focused element.\n const relationEvent = new Event('overlay-relation-query', {\n bubbles: true,\n composed: true,\n });\n\n // Add an event listener to the related target to handle the custom event.\n event.relatedTarget.addEventListener(relationEvent.type, (event: Event) => {\n // Check if the newly focused element is within the overlay or its children\n const path = event.composedPath();\n const isWithinOverlay = path.some((el) => el === this);\n\n // Only close if focus moves outside the overlay and its children\n if (!isWithinOverlay) {\n this.open = false;\n }\n });\n\n // Dispatch the custom event to the related target.\n event.relatedTarget.dispatchEvent(relationEvent);\n };\n\n private closeOnCancelEvent = (): void => {\n this.open = false;\n };\n\n /**\n * Manages the process of opening or closing the overlay.\n *\n * This method handles the necessary steps to open or close the overlay, including updating the state,\n * managing the overlay stack, and handling focus events.\n *\n * @protected\n * @param {boolean} oldOpen - The previous open state of the overlay.\n * @returns {Promise<void>} A promise that resolves when the overlay has been fully managed.\n */\n protected async manageOpen(oldOpen: boolean): Promise<void> {\n // Prevent entering the manage workflow if the overlay is not connected to the DOM.\n // The `.showPopover()` event will error on content that is not connected to the DOM.\n if (!this.isConnected && this.open) {\n return;\n }\n\n // Wait for the component to finish updating if it has not already done so.\n if (!this.hasUpdated) {\n await this.updateComplete;\n }\n\n if (this.open) {\n // Add the overlay to the overlay stack.\n overlayStack.add(this);\n\n if (this.willPreventClose) {\n // Add an event listener to handle the pointerup event and toggle the 'not-immediately-closable' class.\n document.addEventListener(\n 'pointerup',\n () => {\n this.dialogEl.classList.toggle('not-immediately-closable', false);\n this.willPreventClose = false;\n },\n { once: true }\n );\n this.dialogEl.classList.toggle('not-immediately-closable', true);\n }\n } else {\n if (oldOpen) {\n this._focusTrap?.deactivate();\n this._focusTrap = null;\n // Dispose of the overlay if it was previously open.\n this.dispose();\n }\n\n // Remove the overlay from the overlay stack.\n overlayStack.remove(this);\n }\n\n // Update the state of the overlay based on the open property.\n if (this.open && this.state !== 'opened') {\n this.state = 'opening';\n } else if (!this.open && this.state !== 'closed') {\n this.state = 'closing';\n }\n\n this.managePopoverOpen();\n\n const listenerRoot = this.getRootNode() as Document;\n // Handle focus events for auto type overlays.\n if (this.type === 'auto') {\n if (this.open) {\n listenerRoot.addEventListener('focusout', this.closeOnFocusOut, {\n capture: true,\n });\n } else {\n listenerRoot.removeEventListener('focusout', this.closeOnFocusOut, {\n capture: true,\n });\n }\n }\n\n // Handle cancel events for modal and page type overlays.\n if (this.type === 'modal' || this.type === 'page') {\n if (this.open) {\n listenerRoot.addEventListener('cancel', this.closeOnCancelEvent, {\n capture: true,\n });\n } else {\n listenerRoot.removeEventListener('cancel', this.closeOnCancelEvent, {\n capture: true,\n });\n }\n }\n }\n\n /**\n * Binds event handling strategies to the overlay based on the specified trigger interaction.\n *\n * This method sets up the appropriate event handling strategy for the overlay, ensuring that\n * it responds correctly to user interactions such as clicks, hovers, or long presses.\n *\n * @protected\n */\n protected bindEvents(): void {\n // Abort any existing strategy to ensure a clean setup.\n this.strategy?.abort();\n this.strategy = undefined;\n\n // Return early if there is no non-virtual trigger element.\n if (!this.hasNonVirtualTrigger) {\n return;\n }\n\n // Return early if no trigger interaction is specified.\n if (!this.triggerInteraction) {\n return;\n }\n\n // Set up a new event handling strategy based on the specified trigger interaction.\n this.strategy = new strategies[this.triggerInteraction](\n this.triggerElement as HTMLElement,\n {\n overlay: this,\n }\n );\n }\n\n /**\n * Handles the `beforetoggle` event to manage the overlay's state.\n *\n * This method checks the new state of the event and calls `handleBrowserClose`\n * if the new state is not 'open'.\n *\n * @protected\n * @param {Event & { newState: string }} event - The `beforetoggle` event with the new state.\n */\n protected handleBeforetoggle(event: Event & { newState: string }): void {\n if (event.newState !== 'open') {\n this.handleBrowserClose(event);\n }\n }\n\n /**\n * Handles the browser's close event to manage the overlay's state.\n *\n * This method stops the propagation of the event and closes the overlay if it is not\n * actively opening. If the overlay is actively opening, it calls `manuallyKeepOpen`.\n *\n * @protected\n * @param {Event} event - The browser's close event.\n */\n protected handleBrowserClose(event: Event): void {\n event.stopPropagation();\n if (!this.strategy?.activelyOpening) {\n this.open = false;\n return;\n }\n this.manuallyKeepOpen();\n }\n\n /**\n * Manually keeps the overlay open.\n *\n * This method sets the overlay to open, allows placement updates, and manages the open state.\n *\n * @public\n * @override\n */\n public override manuallyKeepOpen(): void {\n this.open = true;\n this.placementController.allowPlacementUpdate = true;\n this.manageOpen(false);\n }\n\n /**\n * Handles the `slotchange` event to manage the overlay's state.\n *\n * This method checks if there are any elements in the slot. If there are no elements,\n * it releases the description from the strategy. If there are elements and the trigger\n * is non-virtual, it prepares the description for the trigger element.\n *\n * @protected\n */\n protected handleSlotchange(): void {\n if (!this.elements.length) {\n // Release the description if there are no elements in the slot.\n this.strategy?.releaseDescription();\n } else if (this.hasNonVirtualTrigger) {\n // Prepare the description for the trigger element if it is non-virtual.\n this.strategy?.prepareDescription(this.triggerElement as HTMLElement);\n }\n }\n\n /**\n * Handles the 'close' event to update the 'open' property.\n *\n * @private\n */\n private handleClose(): void {\n this.open = false;\n }\n\n /**\n * Determines whether the overlay should prevent closing.\n *\n * This method checks the `willPreventClose` flag and resets it to `false`.\n * It returns the value of the `willPreventClose` flag.\n *\n * @public\n * @returns {boolean} `true` if the overlay should prevent closing, otherwise `false`.\n */\n public shouldPreventClose(): boolean {\n const shouldPreventClose = this.willPreventClose;\n this.willPreventClose = false;\n return shouldPreventClose;\n }\n\n /**\n * Requests slottable content for the overlay.\n *\n * This method dispatches a `SlottableRequestEvent` to request or remove slottable content\n * based on the current open state of the overlay. It ensures that the same state is not\n * dispatched twice in a row.\n *\n * @protected\n * @override\n */\n protected override requestSlottable(): void {\n // Do not dispatch the same state twice in a row.\n if (this.lastRequestSlottableState === this.open) {\n return;\n }\n\n // Force the browser to paint if the overlay is closing.\n if (!this.open) {\n /** @todo investigate why this is needed and if there is a better way to do this or remove it entirely */\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n document.body.offsetHeight;\n }\n\n /**\n * @ignore\n */\n // Dispatch a custom event to request or remove slottable content based on the open state.\n this.dispatchEvent(\n new SlottableRequestEvent(\n 'overlay-content',\n this.open ? {} : removeSlottableRequest\n )\n );\n\n // Update the last request slottable state.\n this.lastRequestSlottableState = this.open;\n }\n\n /**\n * Lifecycle method called before the component updates.\n *\n * This method handles various tasks before the component updates, such as setting an ID,\n * managing the open state, resolving the trigger element, and binding events.\n *\n * @override\n * @param {PropertyValues} changes - The properties that have changed.\n */\n override willUpdate(changes: PropertyValues): void {\n // Ensure the component has an ID attribute.\n if (!this.hasAttribute('id')) {\n this.setAttribute('id', `${this.tagName.toLowerCase()}-${randomID()}`);\n }\n\n // Warn about deprecated allowOutsideClick property\n if (changes.has('allowOutsideClick') && this.allowOutsideClick) {\n if (window.__swc?.DEBUG) {\n window.__swc.warn(\n this,\n `The \"allow-outside-click\" attribute on <${this.localName}> has been deprecated and will be removed in a future release. We do not recommend using this attribute for accessibility reasons. It allows clicks outside the overlay to close it, which can cause unexpected behavior and accessibility issues.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/overlay/',\n { level: 'deprecation' }\n );\n } else {\n // Fallback for testing environments or when SWC is not available\n console.warn(\n `[${this.localName}] The \"allow-outside-click\" attribute has been deprecated and will be removed in a future release. We do not recommend using this attribute for accessibility reasons. It allows clicks outside the overlay to close it, which can cause unexpected behavior and accessibility issues.`\n );\n }\n }\n\n // Manage the open state if the 'open' property has changed.\n if (changes.has('open') && (this.hasUpdated || this.open)) {\n this.manageOpen(changes.get('open'));\n }\n\n // Resolve the trigger element if the 'trigger' property has changed.\n if (changes.has('trigger')) {\n const [id, interaction] = this.trigger?.split('@') || [];\n this.elementResolver.selector = id ? `#${id}` : '';\n this.triggerInteraction = interaction as\n | 'click'\n | 'longpress'\n | 'hover'\n | undefined;\n }\n\n // Initialize oldTrigger to track the previous trigger element.\n let oldTrigger: HTMLElement | false | undefined = false;\n\n // Check if the element resolver has been updated.\n if (changes.has(elementResolverUpdatedSymbol)) {\n // Store the current trigger element.\n oldTrigger = this.triggerElement as HTMLElement;\n // Update the trigger element from the element resolver.\n this.triggerElement = this.elementResolver.element;\n }\n\n // Check if the 'triggerElement' property has changed.\n if (changes.has('triggerElement')) {\n // Store the old trigger element.\n oldTrigger = changes.get('triggerElement');\n }\n\n // If the trigger element has changed, bind the new events.\n if (oldTrigger !== false) {\n this.bindEvents();\n }\n }\n\n /**\n * Lifecycle method called after the component updates.\n *\n * This method handles various tasks after the component updates, such as updating the placement\n * attribute, resetting the overlay position, and clearing the overlay position based on the state.\n *\n * @override\n * @param {PropertyValues} changes - The properties that have changed.\n */\n protected override updated(changes: PropertyValues): void {\n // Call the base class method to handle any initial setup.\n super.updated(changes);\n\n // Check if the 'placement' property has changed.\n if (changes.has('placement')) {\n if (this.placement) {\n // Set the 'actual-placement' attribute on the dialog element.\n this.dialogEl.setAttribute('actual-placement', this.placement);\n } else {\n // Remove the 'actual-placement' attribute from the dialog element.\n this.dialogEl.removeAttribute('actual-placement');\n }\n\n // If the overlay is open and the 'placement' property has changed, reset the overlay position.\n if (this.open && typeof changes.get('placement') !== 'undefined') {\n this.placementController.resetOverlayPosition();\n }\n }\n\n // Check if the 'state' property has changed and the overlay is closed.\n if (\n changes.has('state') &&\n this.state === 'closed' &&\n typeof changes.get('state') !== 'undefined'\n ) {\n // Clear the overlay position.\n this.placementController.clearOverlayPosition();\n }\n }\n\n /**\n * Renders the content of the overlay.\n *\n * This method returns a template result containing a slot element. The slot element\n * listens for the `slotchange` event to manage the overlay's state.\n *\n * @protected\n * @returns {TemplateResult} The template result containing the slot element.\n */\n protected renderContent(): TemplateResult {\n return html`\n <slot @slotchange=${this.handleSlotchange}></slot>\n `;\n }\n\n /**\n * Generates a style map for the dialog element.\n *\n * This method returns an object containing CSS custom properties for the dialog element.\n * The `--swc-overlay-open-count` custom property is set to the current open count of overlays.\n *\n * @private\n * @returns {StyleInfo} The style map for the dialog element.\n */\n private get dialogStyleMap(): StyleInfo {\n return {\n '--swc-overlay-open-count': Overlay.openCount.toString(),\n };\n }\n\n /**\n * Renders the popover element for the overlay.\n *\n * This method returns a template result containing a div element styled as a popover.\n * The popover element includes various attributes and event listeners to manage the overlay's state and behavior.\n *\n * @protected\n * @returns {TemplateResult} The template result containing the popover element.\n */\n protected renderPopover(): TemplateResult {\n /**\n * The `--swc-overlay-open-count` custom property is applied to mimic the single stack\n * nature of the top layer in browsers that do not yet support it.\n *\n * The value should always represent the total number of overlays that have ever been opened.\n * This value will be added to the `--swc-overlay-z-index-base` custom property, which can be\n * provided by a consuming developer. By default, `--swc-overlay-z-index-base` is set to 1000\n * to ensure that the overlay stacks above most other elements during fallback delivery.\n */\n return html`\n ${this.needsModalBackdrop\n ? html`\n <div class=\"modal-backdrop\"></div>\n `\n : nothing}\n <div\n class=\"dialog\"\n part=\"dialog\"\n role=${ifDefined(\n this.type === 'modal' || this.type === 'page' ? 'dialog' : undefined\n )}\n aria-modal=${ifDefined(\n this.type === 'modal' || this.type === 'page' ? 'true' : undefined\n )}\n placement=${ifDefined(\n this.requiresPositioning ? this.placement || 'right' : undefined\n )}\n popover=${ifDefined(this.popoverValue)}\n style=${styleMap(this.dialogStyleMap)}\n @beforetoggle=${this.handleBeforetoggle}\n @close=${this.handleBrowserClose}\n ?is-visible=${this.state !== 'closed'}\n >\n ${this.renderContent()}\n </div>\n `;\n }\n\n /**\n * Renders the overlay component.\n *\n * This method returns a template result containing either a dialog or popover element\n * based on the overlay type. It also includes a slot for longpress descriptors.\n *\n * @override\n * @returns {TemplateResult} The template result containing the overlay content.\n */\n public override render(): TemplateResult {\n return html`\n ${this.renderPopover()}\n <slot name=\"longpress-describedby-descriptor\"></slot>\n `;\n }\n\n /**\n * Lifecycle method called when the component is added to the DOM.\n *\n * This method sets up event listeners and binds events if the component has already updated.\n *\n * @override\n */\n override connectedCallback(): void {\n super.connectedCallback();\n\n // Add an event listener to handle the 'close' event and update the 'open' property.\n this.addEventListener('close', this.handleClose);\n\n // Bind events if the component has already updated.\n if (this.hasUpdated) {\n this.bindEvents();\n }\n }\n\n /**\n * Lifecycle method called when the component is removed from the DOM.\n *\n * This method releases the description from the strategy and updates the 'open' property.\n *\n * @override\n */\n override disconnectedCallback(): void {\n // Release the description from the strategy.\n this.strategy?.releaseDescription();\n // Update the 'open' property to false.\n this.open = false;\n this.removeEventListener('close', this.handleClose);\n super.disconnectedCallback();\n }\n}\n"],
5
- "mappings": "qNAWA,OACE,QAAAA,EACA,WAAAC,MAGK,gCACP,OACE,Y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,GA3RzCsB,EA4RX,0BAWA4B,EAAA,CADClD,EAAS,GAtSCsB,EAuSX,uBASS4B,EAAA,CADRlD,EAAS,CAAE,UAAW,EAAM,CAAC,GA/SnBsB,EAgTF,8BAST4B,EAAA,CADClD,EAAS,CAAE,UAAW,EAAM,CAAC,GAxTnBsB,EAyTX,kCASS4B,EAAA,CADRlD,EAAS,GAjUCsB,EAkUF,oBAlUJ,WAAM,QAANA",
6
- "names": ["html", "nothing", "property", "query", "queryAssignedElements", "state", "ifDefined", "styleMap", "ElementResolutionController", "elementResolverUpdatedSymbol", "randomID", "AbstractOverlay", "nextFrame", "OverlayNoPopover", "OverlayPopover", "overlayStack", "PlacementController", "VirtualTrigger", "styles", "removeSlottableRequest", "SlottableRequestEvent", "strategies", "browserSupportsPopover", "ComputedOverlayBase", "_Overlay", "event", "relationEvent", "el", "_a", "delayed", "disabled", "open", "oldState", "offset", "trigger", "placement", "tipPadding", "targetOpenState", "focusEl", "focusTrap", "getAncestors", "_b", "ancestors", "currentNode", "ancestor", "oldOpen", "listenerRoot", "shouldPreventClose", "changes", "id", "interaction", "oldTrigger", "__decorateClass"]
4
+ "sourcesContent": ["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nimport {\n html,\n nothing,\n PropertyValues,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n property,\n query,\n queryAssignedElements,\n state,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport {\n ifDefined,\n StyleInfo,\n styleMap,\n} from '@spectrum-web-components/base/src/directives.js';\nimport {\n ElementResolutionController,\n elementResolverUpdatedSymbol,\n} from '@spectrum-web-components/reactive-controllers/src/ElementResolution.js';\nimport { randomID } from '@spectrum-web-components/shared/src/random-id.js';\n\nimport { AbstractOverlay, nextFrame } from './AbstractOverlay.js';\nimport type { ClickController } from './ClickController.js';\nimport type { HoverController } from './HoverController.js';\nimport type { LongpressController } from './LongpressController.js';\nimport type {\n OpenableElement,\n OverlayState,\n OverlayTypes,\n Placement,\n TriggerInteraction,\n} from './overlay-types.js';\nimport { OverlayNoPopover } from './OverlayNoPopover.js';\nimport { OverlayPopover } from './OverlayPopover.js';\nimport { overlayStack } from './OverlayStack.js';\nimport { PlacementController } from './PlacementController.js';\nimport { VirtualTrigger } from './VirtualTrigger.js';\nexport { LONGPRESS_INSTRUCTIONS } from './LongpressController.js';\nimport { FocusTrap } from 'focus-trap';\n\nimport styles from './overlay.css.js';\nimport {\n removeSlottableRequest,\n SlottableRequestEvent,\n} from './slottable-request-event.js';\nimport { strategies } from './strategies.js';\n\nconst browserSupportsPopover = 'showPopover' in document.createElement('div');\n\n// Start the base class and add the popover or no-popover functionality\nlet ComputedOverlayBase = OverlayPopover(AbstractOverlay);\nif (!browserSupportsPopover) {\n ComputedOverlayBase = OverlayNoPopover(AbstractOverlay);\n}\n\n/**\n * @element sp-overlay\n *\n * @slot default - The content that will be displayed in the overlay\n *\n * @fires sp-opened - announces that an overlay has completed any entry animations\n * @fires sp-closed - announce that an overlay has completed any exit animations\n * @fires slottable-request - requests to add or remove slottable content\n *\n * @attr {string} placement - The placement of the overlay relative to the trigger\n * @attr {number} offset - The distance between the overlay and the trigger\n * @attr {boolean} disabled - Whether the overlay trigger is disabled\n * @attr {string} receives-focus - How focus should be handled ('true'|'false'|'auto')\n * @attr {boolean} delayed - Whether the overlay should wait for a warm-up period before opening\n * @attr {boolean} open - Whether the overlay is currently open\n * @attr {boolean} allow-outside-click - DEPRECATED: Whether clicks outside the overlay should close it (not recommended for accessibility)\n */\nexport class Overlay extends ComputedOverlayBase {\n static override styles = [styles];\n\n /**\n * An Overlay that is `delayed` will wait until a warm-up period of 1000ms\n * has completed before opening. Once the warm-up period has completed, all\n * subsequent Overlays will open immediately. When no Overlays are opened,\n * a cool-down period of 1000ms will begin. Once the cool-down has completed,\n * the next Overlay to be opened will be subject to the warm-up period if\n * provided that option.\n *\n * This behavior helps to manage the performance and user experience by\n * preventing multiple overlays from opening simultaneously and ensuring\n * a smooth transition between opening and closing overlays.\n *\n * @type {boolean}\n * @default false\n */\n @property({ type: Boolean })\n override get delayed(): boolean {\n const lastElement = this.elements[this.elements.length - 1];\n return lastElement?.hasAttribute('delayed') || this._delayed;\n }\n\n override set delayed(delayed: boolean) {\n this._delayed = delayed;\n }\n\n private _delayed = false;\n\n /**\n * A reference to the dialog element within the overlay.\n * This element is expected to have `showPopover` and `hidePopover` methods.\n */\n @query('.dialog')\n override dialogEl!: HTMLDialogElement & {\n showPopover(): void;\n hidePopover(): void;\n };\n\n /**\n * Indicates whether the overlay is currently functional or not.\n *\n * When set to `true`, the overlay is disabled, and any active strategy is aborted.\n * The overlay will also close if it is currently open. When set to `false`, the\n * overlay will re-bind events and re-open if it was previously open.\n *\n * @type {boolean}\n * @default false\n */\n @property({ type: Boolean })\n override get disabled(): boolean {\n return this._disabled;\n }\n\n override set disabled(disabled: boolean) {\n this._disabled = disabled;\n if (disabled) {\n // Abort any active strategy and close the overlay if it is currently open\n this.strategy?.abort();\n this.wasOpen = this.open;\n this.open = false;\n } else {\n // Re-bind events and re-open the overlay if it was previously open\n this.bindEvents();\n this.open = this.open || this.wasOpen;\n this.wasOpen = false;\n }\n }\n\n private _disabled = false;\n\n /**\n * A query to gather all elements slotted into the default slot, excluding elements\n * with the slot name \"longpress-describedby-descriptor\".\n */\n @queryAssignedElements({\n flatten: true,\n selector: ':not([slot=\"longpress-describedby-descriptor\"], slot)',\n })\n override elements!: OpenableElement[];\n\n /**\n * A reference to the parent overlay that should be force-closed, if any.\n */\n public parentOverlayToForceClose?: Overlay;\n\n /**\n * Determines if the overlay has a non-virtual trigger element.\n *\n * @returns {boolean} `true` if the trigger element is not a virtual trigger, otherwise `false`.\n */\n private get hasNonVirtualTrigger(): boolean {\n return (\n !!this.triggerElement && !(this.triggerElement instanceof VirtualTrigger)\n );\n }\n\n /**\n * The `offset` property accepts either a single number to define the offset of the\n * Overlay along the main axis from the trigger, or a 2-tuple to define the offset\n * along both the main axis and the cross axis. This option has no effect when there\n * is no trigger element.\n *\n * @type {number | [number, number]}\n * @default 0\n */\n @property({ type: Number })\n override offset: number | [number, number] = 0;\n\n /**\n * Provides an instance of the `PlacementController` for managing the positioning\n * of the overlay relative to its trigger element.\n *\n * If the `PlacementController` instance does not already exist, it is created and\n * assigned to the `_placementController` property.\n *\n * @protected\n * @returns {PlacementController} The `PlacementController` instance.\n */\n protected override get placementController(): PlacementController {\n if (!this._placementController) {\n this._placementController = new PlacementController(this);\n }\n return this._placementController;\n }\n\n /**\n * Indicates whether the Overlay is projected onto the \"top layer\" or not.\n *\n * When set to `true`, the overlay is open and visible. When set to `false`, the overlay is closed and hidden.\n *\n * @type {boolean}\n * @default false\n */\n @property({ type: Boolean, reflect: true })\n override get open(): boolean {\n return this._open;\n }\n\n override set open(open: boolean) {\n // Don't respond if the overlay is disabled.\n if (open && this.disabled) {\n return;\n }\n\n // Don't respond if the state is not changing.\n if (open === this.open) {\n return;\n }\n\n // Don't respond if the overlay is in the shadow state during a longpress.\n // The shadow state occurs when the first \"click\" would normally close the popover.\n if (this.strategy?.activelyOpening && !open) {\n return;\n }\n\n // Update the internal _open property.\n this._open = open;\n\n // Increment the open count if the overlay is opening.\n if (this.open) {\n Overlay.openCount += 1;\n }\n\n // Request an update to re-render the component if necessary.\n this.requestUpdate('open', !this.open);\n\n // Request slottable content if the overlay is opening.\n if (this.open) {\n this.requestSlottable();\n }\n }\n\n private _open = false;\n\n /**\n * Tracks the number of overlays that have been opened.\n *\n * This static property is used to manage the stacking context of multiple overlays.\n *\n * @type {number}\n * @default 1\n */\n static openCount = 1;\n\n /**\n * Instruct the Overlay where to place itself in relationship to the trigger element.\n *\n * @type {\"top\" | \"top-start\" | \"top-end\" | \"right\" | \"right-start\" | \"right-end\" | \"bottom\" | \"bottom-start\" | \"bottom-end\" | \"left\" | \"left-start\" | \"left-end\"}\n */\n @property()\n override placement?: Placement;\n\n /**\n * The state in which the last `request-slottable` event was dispatched.\n *\n * This property ensures that overlays do not dispatch the same state twice in a row.\n *\n * @type {boolean}\n * @default false\n */\n private lastRequestSlottableState = false;\n\n /**\n * Whether to pass focus to the overlay once opened, or\n * to the appropriate value based on the \"type\" of the overlay\n * when set to `\"auto\"`.\n *\n * @type {'true' | 'false' | 'auto'}\n * @default 'auto'\n */\n @property({ attribute: 'receives-focus' })\n override receivesFocus: 'true' | 'false' | 'auto' = 'auto';\n\n /**\n * @deprecated This property will be removed in a future version.\n * We do not recommend using this property for accessibility reasons.\n * It allows clicks outside the overlay to close it, which can cause\n * unexpected behavior and accessibility issues.\n *\n * @type {boolean}\n * @default false\n */\n @property({ type: Boolean, attribute: 'allow-outside-click' })\n allowOutsideClick = false;\n\n /**\n * A reference to the slot element within the overlay.\n *\n * This element is used to manage the content slotted into the overlay.\n *\n * @type {HTMLSlotElement}\n */\n @query('slot')\n slotEl!: HTMLSlotElement;\n\n /**\n * The current state of the overlay.\n *\n * This property reflects the current state of the overlay, such as 'opened' or 'closed'.\n * When the state changes, it triggers the appropriate actions and updates the component.\n *\n * @type {OverlayState}\n * @default 'closed'\n */\n @state()\n override get state(): OverlayState {\n return this._state;\n }\n\n override set state(state) {\n // Do not respond if the state is not changing.\n if (state === this.state) {\n return;\n }\n\n const oldState = this.state;\n\n this._state = state;\n\n // Complete the opening strategy if the state is 'opened' or 'closed'.\n if (this.state === 'opened' || this.state === 'closed') {\n this.strategy?.shouldCompleteOpen();\n }\n\n // Request an update to re-render the component if necessary.\n this.requestUpdate('state', oldState);\n }\n\n override _state: OverlayState = 'closed';\n\n /**\n * The interaction strategy for opening the overlay.\n * This can be a ClickController, HoverController, or LongpressController.\n */\n public strategy?: ClickController | HoverController | LongpressController;\n\n /**\n * The padding around the tip of the overlay.\n * This property defines the padding around the tip of the overlay, which can be used to adjust its positioning.\n *\n * @type {number}\n */\n @property({ type: Number, attribute: 'tip-padding' })\n tipPadding?: number;\n\n /**\n * An optional ID reference for the trigger element combined with the optional\n * interaction (click | hover | longpress) by which the overlay should open.\n * The format is `trigger@interaction`, e.g., `trigger@click` opens the overlay\n * when an element with the ID \"trigger\" is clicked.\n *\n * @type {string}\n */\n @property()\n trigger?: string;\n\n /**\n * An element reference for the trigger element that the overlay should relate to.\n * This property is not reflected as an attribute.\n *\n * @type {HTMLElement | VirtualTrigger | null}\n */\n @property({ attribute: false })\n override triggerElement: HTMLElement | VirtualTrigger | null = null;\n\n /**\n * The specific interaction to listen for on the `triggerElement` to open the overlay.\n * This property is not reflected as an attribute.\n *\n * @type {TriggerInteraction}\n */\n @property({ attribute: false })\n triggerInteraction?: TriggerInteraction;\n\n /**\n * When set to `'none'`, the overlay will not set `aria-describedby` on the\n * trigger when open, so the trigger is not described by the overlay content.\n * Use for hint overlays whose content duplicates the trigger (e.g. truncated\n * value tooltips) to avoid double announcement by screen readers.\n *\n * @internal\n * @type {\"auto\" | \"none\"}\n * @default \"auto\"\n */\n @property({ attribute: false })\n describeTrigger: 'auto' | 'none' = 'auto';\n\n /**\n * Configures the open/close heuristics of the Overlay.\n *\n * @type {\"auto\" | \"hint\" | \"manual\" | \"modal\" | \"page\"}\n * @default \"auto\"\n */\n @property()\n override type: OverlayTypes = 'auto';\n\n /**\n * Tracks whether the overlay was previously open.\n * This is used to restore the open state when re-enabling the overlay.\n *\n * @type {boolean}\n * @default false\n */\n protected wasOpen = false;\n\n /**\n * Focus trap to keep focus within the dialog\n *\n * @private\n */\n private _focusTrap: FocusTrap | null = null;\n\n /**\n * Provides an instance of the `ElementResolutionController` for managing the element\n * that the overlay should be associated with. If the instance does not already exist,\n * it is created and assigned to the `_elementResolver` property.\n *\n * @protected\n * @returns {ElementResolutionController} The `ElementResolutionController` instance.\n */\n protected override get elementResolver(): ElementResolutionController {\n if (!this._elementResolver) {\n this._elementResolver = new ElementResolutionController(this);\n }\n\n return this._elementResolver;\n }\n\n /**\n * Determines the value for the popover attribute based on the overlay type.\n *\n * @private\n * @returns {'auto' | 'manual' | undefined} The popover value or undefined if not applicable.\n */\n private get popoverValue(): 'auto' | 'manual' | undefined {\n const hasPopoverAttribute = 'popover' in this;\n\n if (!hasPopoverAttribute) {\n return undefined;\n }\n\n switch (this.type) {\n case 'modal':\n // Use 'manual' to allow multiple modal overlays to be visible simultaneously.\n // The browser's 'auto' popover only allows one at a time (light dismiss closes others).\n // This restores the stacking behavior that existed when using showModal().\n // The OverlayStack handles Escape key closing for modal overlays.\n return 'manual';\n case 'page':\n return 'manual';\n case 'hint':\n return 'manual';\n default:\n return this.type;\n }\n }\n\n /**\n * Determines if the overlay requires positioning based on its type and state.\n *\n * @protected\n * @returns {boolean} True if the overlay requires positioning, otherwise false.\n */\n protected get requiresPositioning(): boolean {\n // Do not position \"page\" overlays as they should block the entire UI.\n if (this.type === 'page' || !this.open) {\n return false;\n }\n\n // Do not position content without a trigger element, as there is nothing to position it relative to.\n // Do not automatically position content unless it is a \"hint\".\n if (!this.triggerElement || (!this.placement && this.type !== 'hint')) {\n return false;\n }\n\n return true;\n }\n\n /**\n * Determines if the overlay needs a modal backdrop to block external clicks.\n * Only page overlays need the backdrop since they don't have light dismiss.\n * Modal overlays use popover=\"manual\" for stacking and handle light dismiss\n * via handlePointerup in OverlayStack.\n */\n protected get needsModalBackdrop(): boolean {\n return this.open && (this.type === 'modal' || this.type === 'page');\n }\n\n /**\n * Manages the positioning of the overlay relative to its trigger element.\n *\n * This method calculates the necessary parameters for positioning the overlay,\n * such as offset, placement, and tip padding, and then delegates the actual\n * positioning to the `PlacementController`.\n *\n * @protected\n * @override\n */\n protected override managePosition(): void {\n // Do not proceed if positioning is not required or the overlay is not open.\n if (!this.requiresPositioning || !this.open) {\n return;\n }\n\n const offset = this.offset || 0;\n\n const trigger = this.triggerElement as HTMLElement;\n\n const placement = (this.placement as Placement) || 'right';\n\n const tipPadding = this.tipPadding;\n\n this.placementController.placeOverlay(this.dialogEl, {\n offset,\n placement,\n tipPadding,\n trigger,\n type: this.type,\n });\n }\n\n /**\n * Manages the process of opening the popover.\n *\n * This method handles the necessary steps to open the popover, including managing delays,\n * ensuring the popover is in the DOM, making transitions, and applying focus.\n *\n * @protected\n * @override\n * @returns {Promise<void>} A promise that resolves when the popover has been fully opened.\n */\n protected override async managePopoverOpen(): Promise<void> {\n // Call the base class method to handle any initial setup.\n super.managePopoverOpen();\n\n const targetOpenState = this.open;\n\n // Ensure the open state has not changed before proceeding.\n if (this.open !== targetOpenState) {\n return;\n }\n\n // Manage any delays before opening the popover.\n await this.manageDelay(targetOpenState);\n\n if (this.open !== targetOpenState) {\n return;\n }\n\n // Only wait for next frame if `longpress` is the trigger.\n // In Safari, awaiting nextFrame here causes layout issues\n // when rendering trays inside modals, so we skip it otherwise.\n if (this.triggerInteraction === 'longpress') {\n await nextFrame();\n }\n\n // Ensure the popover is in the DOM before proceeding.\n await this.ensureOnDOM(targetOpenState);\n\n if (this.open !== targetOpenState) {\n return;\n }\n\n // Make any necessary transitions for opening the popover.\n const focusEl = await this.makeTransition(targetOpenState);\n\n if (this.open !== targetOpenState) {\n return;\n }\n if (targetOpenState) {\n const focusTrap = await import('focus-trap');\n // When `receives-focus=\"false\"`, pass `initialFocus: false` so the trap\n // still captures Tab but does not move focus on activation. Without this,\n // focus-trap would move focus before `applyFocus` runs, bypassing the\n // `receivesFocus === 'false'` guard there.\n const initialFocus =\n this.receivesFocus === 'false' ? false : focusEl || undefined;\n this._focusTrap = focusTrap.createFocusTrap(this.dialogEl, {\n initialFocus,\n tabbableOptions: {\n getShadowRoot: true,\n },\n fallbackFocus: () => {\n // set tabIndex to -1 allow the focus-trap to still be applied\n this.dialogEl.setAttribute('tabIndex', '-1');\n return this.dialogEl;\n },\n // disable escape key capture to close the overlay, the focus-trap library captures it otherwise\n escapeDeactivates: false,\n allowOutsideClick: this.allowOutsideClick,\n });\n\n if (this.type === 'modal' || this.type === 'page') {\n this._focusTrap.activate();\n }\n }\n // Apply focus to the appropriate element after opening the popover.\n await this.applyFocus(targetOpenState, focusEl);\n }\n\n /**\n * Applies focus to the appropriate element after the popover has been opened.\n *\n * This method handles the focus management for the overlay, ensuring that the correct\n * element receives focus based on the overlay's type and state.\n *\n * @protected\n * @override\n * @param {boolean} targetOpenState - The target open state of the overlay.\n * @param {HTMLElement | null} focusEl - The element to focus after opening the popover.\n * @returns {Promise<void>} A promise that resolves when the focus has been applied.\n */\n protected override async applyFocus(\n targetOpenState: boolean,\n focusEl: HTMLElement | null\n ): Promise<void> {\n // Do not move focus when explicitly told not to or when the overlay is a \"hint\".\n if (this.receivesFocus === 'false' || this.type === 'hint') {\n return;\n }\n\n // Wait for the next two animation frames to ensure the DOM is updated.\n await nextFrame();\n await nextFrame();\n\n // If the open state has changed during the delay, do not proceed.\n if (targetOpenState === this.open && !this.open) {\n // If the overlay is closing and the trigger element is still focused, return focus to the trigger element.\n if (\n this.hasNonVirtualTrigger &&\n this.contains((this.getRootNode() as Document).activeElement)\n ) {\n (this.triggerElement as HTMLElement).focus();\n }\n return;\n }\n\n // Apply focus to the specified focus element.\n focusEl?.focus();\n }\n\n /**\n * Returns focus to the trigger element if the overlay is closed.\n *\n * This method ensures that focus is returned to the trigger element when the overlay is closed,\n * unless the overlay is of type \"hint\" or the focus is already outside the overlay.\n *\n * @protected\n * @override\n */\n protected override returnFocus(): void {\n // Do not proceed if the overlay is open or if the overlay type is \"hint\".\n if (this.open || this.type === 'hint') {\n return;\n }\n\n /**\n * Retrieves the ancestors of the currently focused element.\n *\n * @returns {HTMLElement[]} An array of ancestor elements.\n */\n const getAncestors = (): HTMLElement[] => {\n const ancestors: HTMLElement[] = [];\n\n // eslint-disable-next-line swc/document-active-element\n let currentNode = document.activeElement;\n\n // Traverse the shadow DOM to find the active element.\n while (currentNode?.shadowRoot?.activeElement) {\n currentNode = currentNode.shadowRoot.activeElement;\n }\n\n // Traverse the DOM tree to collect ancestor elements.\n while (currentNode) {\n const ancestor =\n currentNode.assignedSlot ||\n currentNode.parentElement ||\n (currentNode.getRootNode() as ShadowRoot)?.host;\n if (ancestor) {\n ancestors.push(ancestor as HTMLElement);\n }\n currentNode = ancestor;\n }\n return ancestors;\n };\n\n // Check if focus should be returned to the trigger element.\n if (\n this.receivesFocus !== 'false' &&\n !!(this.triggerElement as HTMLElement)?.focus &&\n (this.contains((this.getRootNode() as Document).activeElement) ||\n getAncestors().includes(this) ||\n // eslint-disable-next-line swc/document-active-element\n document.activeElement === document.body)\n ) {\n // Return focus to the trigger element.\n (this.triggerElement as HTMLElement).focus();\n }\n }\n\n /**\n * Handles the focus out event to close the overlay if the focus moves outside of it.\n *\n * This method ensures that the overlay is closed when the focus moves to an element\n * outside of the overlay, unless the focus is moved to a related element.\n *\n * @private\n * @param {FocusEvent} event - The focus out event.\n */\n private closeOnFocusOut = (event: FocusEvent): void => {\n // If the related target (newly focused element) is not known, do nothing.\n if (!event.relatedTarget) {\n return;\n }\n\n // Create a custom event to query the relationship of the newly focused element.\n const relationEvent = new Event('overlay-relation-query', {\n bubbles: true,\n composed: true,\n });\n\n // Add an event listener to the related target to handle the custom event.\n event.relatedTarget.addEventListener(relationEvent.type, (event: Event) => {\n // Check if the newly focused element is within the overlay or its children\n const path = event.composedPath();\n const isWithinOverlay = path.some((el) => el === this);\n\n // Only close if focus moves outside the overlay and its children\n if (!isWithinOverlay) {\n this.open = false;\n }\n });\n\n // Dispatch the custom event to the related target.\n event.relatedTarget.dispatchEvent(relationEvent);\n };\n\n private closeOnCancelEvent = (): void => {\n this.open = false;\n };\n\n /**\n * Manages the process of opening or closing the overlay.\n *\n * This method handles the necessary steps to open or close the overlay, including updating the state,\n * managing the overlay stack, and handling focus events.\n *\n * @protected\n * @param {boolean} oldOpen - The previous open state of the overlay.\n * @returns {Promise<void>} A promise that resolves when the overlay has been fully managed.\n */\n protected async manageOpen(oldOpen: boolean): Promise<void> {\n // Prevent entering the manage workflow if the overlay is not connected to the DOM.\n // The `.showPopover()` event will error on content that is not connected to the DOM.\n if (!this.isConnected && this.open) {\n return;\n }\n\n // Wait for the component to finish updating if it has not already done so.\n if (!this.hasUpdated) {\n await this.updateComplete;\n }\n\n if (this.open) {\n // Add the overlay to the overlay stack.\n overlayStack.add(this);\n\n if (this.willPreventClose) {\n // Add an event listener to handle the pointerup event and toggle the 'not-immediately-closable' class.\n document.addEventListener(\n 'pointerup',\n () => {\n this.dialogEl.classList.toggle('not-immediately-closable', false);\n this.willPreventClose = false;\n },\n { once: true }\n );\n this.dialogEl.classList.toggle('not-immediately-closable', true);\n }\n } else {\n if (oldOpen) {\n this._focusTrap?.deactivate();\n this._focusTrap = null;\n // Dispose of the overlay if it was previously open.\n this.dispose();\n }\n\n // Remove the overlay from the overlay stack.\n overlayStack.remove(this);\n }\n\n // Update the state of the overlay based on the open property.\n if (this.open && this.state !== 'opened') {\n this.state = 'opening';\n } else if (!this.open && this.state !== 'closed') {\n this.state = 'closing';\n }\n\n this.managePopoverOpen();\n\n const listenerRoot = this.getRootNode() as Document;\n // Handle focus events for auto type overlays.\n if (this.type === 'auto') {\n if (this.open) {\n listenerRoot.addEventListener('focusout', this.closeOnFocusOut, {\n capture: true,\n });\n } else {\n listenerRoot.removeEventListener('focusout', this.closeOnFocusOut, {\n capture: true,\n });\n }\n }\n\n // Handle cancel events for modal and page type overlays.\n if (this.type === 'modal' || this.type === 'page') {\n if (this.open) {\n listenerRoot.addEventListener('cancel', this.closeOnCancelEvent, {\n capture: true,\n });\n } else {\n listenerRoot.removeEventListener('cancel', this.closeOnCancelEvent, {\n capture: true,\n });\n }\n }\n }\n\n /**\n * Binds event handling strategies to the overlay based on the specified trigger interaction.\n *\n * This method sets up the appropriate event handling strategy for the overlay, ensuring that\n * it responds correctly to user interactions such as clicks, hovers, or long presses.\n *\n * @protected\n */\n protected bindEvents(): void {\n // Abort any existing strategy to ensure a clean setup.\n this.strategy?.abort();\n this.strategy = undefined;\n\n // Return early if there is no non-virtual trigger element.\n if (!this.hasNonVirtualTrigger) {\n return;\n }\n\n // Return early if no trigger interaction is specified.\n if (!this.triggerInteraction) {\n return;\n }\n\n // Set up a new event handling strategy based on the specified trigger interaction.\n this.strategy = new strategies[this.triggerInteraction](\n this.triggerElement as HTMLElement,\n {\n overlay: this,\n }\n );\n }\n\n /**\n * Handles the `beforetoggle` event to manage the overlay's state.\n *\n * This method checks the new state of the event and calls `handleBrowserClose`\n * if the new state is not 'open'.\n *\n * @protected\n * @param {Event & { newState: string }} event - The `beforetoggle` event with the new state.\n */\n protected handleBeforetoggle(event: Event & { newState: string }): void {\n if (event.newState !== 'open') {\n this.handleBrowserClose(event);\n }\n }\n\n /**\n * Handles the browser's close event to manage the overlay's state.\n *\n * This method stops the propagation of the event and closes the overlay if it is not\n * actively opening. If the overlay is actively opening, it calls `manuallyKeepOpen`.\n *\n * @protected\n * @param {Event} event - The browser's close event.\n */\n protected handleBrowserClose(event: Event): void {\n event.stopPropagation();\n if (!this.strategy?.activelyOpening) {\n this.open = false;\n return;\n }\n this.manuallyKeepOpen();\n }\n\n /**\n * Manually keeps the overlay open.\n *\n * This method sets the overlay to open, allows placement updates, and manages the open state.\n *\n * @public\n * @override\n */\n public override manuallyKeepOpen(): void {\n this.open = true;\n this.placementController.allowPlacementUpdate = true;\n this.manageOpen(false);\n }\n\n /**\n * Handles the `slotchange` event to manage the overlay's state.\n *\n * This method checks if there are any elements in the slot. If there are no elements,\n * it releases the description from the strategy. If there are elements and the trigger\n * is non-virtual, it prepares the description for the trigger element.\n *\n * @protected\n */\n protected handleSlotchange(): void {\n if (!this.elements.length) {\n // Release the description if there are no elements in the slot.\n this.strategy?.releaseDescription();\n } else if (this.hasNonVirtualTrigger) {\n // Prepare the description for the trigger element if it is non-virtual.\n this.strategy?.prepareDescription(this.triggerElement as HTMLElement);\n }\n }\n\n /**\n * Handles the 'close' event to update the 'open' property.\n *\n * @private\n */\n private handleClose(): void {\n this.open = false;\n }\n\n /**\n * Determines whether the overlay should prevent closing.\n *\n * This method checks the `willPreventClose` flag and resets it to `false`.\n * It returns the value of the `willPreventClose` flag.\n *\n * @public\n * @returns {boolean} `true` if the overlay should prevent closing, otherwise `false`.\n */\n public shouldPreventClose(): boolean {\n const shouldPreventClose = this.willPreventClose;\n this.willPreventClose = false;\n return shouldPreventClose;\n }\n\n /**\n * Requests slottable content for the overlay.\n *\n * This method dispatches a `SlottableRequestEvent` to request or remove slottable content\n * based on the current open state of the overlay. It ensures that the same state is not\n * dispatched twice in a row.\n *\n * @protected\n * @override\n */\n protected override requestSlottable(): void {\n // Do not dispatch the same state twice in a row.\n if (this.lastRequestSlottableState === this.open) {\n return;\n }\n\n // Force the browser to paint if the overlay is closing.\n if (!this.open) {\n /** @todo investigate why this is needed and if there is a better way to do this or remove it entirely */\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n document.body.offsetHeight;\n }\n\n /**\n * @ignore\n */\n // Dispatch a custom event to request or remove slottable content based on the open state.\n this.dispatchEvent(\n new SlottableRequestEvent(\n 'overlay-content',\n this.open ? {} : removeSlottableRequest\n )\n );\n\n // Update the last request slottable state.\n this.lastRequestSlottableState = this.open;\n }\n\n /**\n * Lifecycle method called before the component updates.\n *\n * This method handles various tasks before the component updates, such as setting an ID,\n * managing the open state, resolving the trigger element, and binding events.\n *\n * @override\n * @param {PropertyValues} changes - The properties that have changed.\n */\n override willUpdate(changes: PropertyValues): void {\n // Ensure the component has an ID attribute.\n if (!this.hasAttribute('id')) {\n this.setAttribute('id', `${this.tagName.toLowerCase()}-${randomID()}`);\n }\n\n // Warn about deprecated allowOutsideClick property\n if (changes.has('allowOutsideClick') && this.allowOutsideClick) {\n if (window.__swc?.DEBUG) {\n window.__swc.warn(\n this,\n `The \"allow-outside-click\" attribute on <${this.localName}> has been deprecated and will be removed in a future release. We do not recommend using this attribute for accessibility reasons. It allows clicks outside the overlay to close it, which can cause unexpected behavior and accessibility issues.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/overlay/',\n { level: 'deprecation' }\n );\n } else {\n // Fallback for testing environments or when SWC is not available\n console.warn(\n `[${this.localName}] The \"allow-outside-click\" attribute has been deprecated and will be removed in a future release. We do not recommend using this attribute for accessibility reasons. It allows clicks outside the overlay to close it, which can cause unexpected behavior and accessibility issues.`\n );\n }\n }\n\n // Manage the open state if the 'open' property has changed.\n if (changes.has('open') && (this.hasUpdated || this.open)) {\n this.manageOpen(changes.get('open'));\n }\n\n // Resolve the trigger element if the 'trigger' property has changed.\n if (changes.has('trigger')) {\n const [id, interaction] = this.trigger?.split('@') || [];\n this.elementResolver.selector = id ? `#${id}` : '';\n this.triggerInteraction = interaction as\n | 'click'\n | 'longpress'\n | 'hover'\n | undefined;\n }\n\n // Initialize oldTrigger to track the previous trigger element.\n let oldTrigger: HTMLElement | false | undefined = false;\n\n // Check if the element resolver has been updated.\n if (changes.has(elementResolverUpdatedSymbol)) {\n // Store the current trigger element.\n oldTrigger = this.triggerElement as HTMLElement;\n // Update the trigger element from the element resolver.\n this.triggerElement = this.elementResolver.element;\n }\n\n // Check if the 'triggerElement' property has changed.\n if (changes.has('triggerElement')) {\n // Store the old trigger element.\n oldTrigger = changes.get('triggerElement');\n }\n\n // If the trigger element has changed, bind the new events.\n if (oldTrigger !== false) {\n this.bindEvents();\n }\n }\n\n /**\n * Lifecycle method called after the component updates.\n *\n * This method handles various tasks after the component updates, such as updating the placement\n * attribute, resetting the overlay position, and clearing the overlay position based on the state.\n *\n * @override\n * @param {PropertyValues} changes - The properties that have changed.\n */\n protected override updated(changes: PropertyValues): void {\n // Call the base class method to handle any initial setup.\n super.updated(changes);\n\n // Check if the 'placement' property has changed.\n if (changes.has('placement')) {\n if (this.placement) {\n // Set the 'actual-placement' attribute on the dialog element.\n this.dialogEl.setAttribute('actual-placement', this.placement);\n } else {\n // Remove the 'actual-placement' attribute from the dialog element.\n this.dialogEl.removeAttribute('actual-placement');\n }\n\n // If the overlay is open and the 'placement' property has changed, reset the overlay position.\n if (this.open && typeof changes.get('placement') !== 'undefined') {\n this.placementController.resetOverlayPosition();\n }\n }\n\n // Check if the 'state' property has changed and the overlay is closed.\n if (\n changes.has('state') &&\n this.state === 'closed' &&\n typeof changes.get('state') !== 'undefined'\n ) {\n // Clear the overlay position.\n this.placementController.clearOverlayPosition();\n }\n }\n\n /**\n * Renders the content of the overlay.\n *\n * This method returns a template result containing a slot element. The slot element\n * listens for the `slotchange` event to manage the overlay's state.\n *\n * @protected\n * @returns {TemplateResult} The template result containing the slot element.\n */\n protected renderContent(): TemplateResult {\n return html`\n <slot @slotchange=${this.handleSlotchange}></slot>\n `;\n }\n\n /**\n * Generates a style map for the dialog element.\n *\n * This method returns an object containing CSS custom properties for the dialog element.\n * The `--swc-overlay-open-count` custom property is set to the current open count of overlays.\n *\n * @private\n * @returns {StyleInfo} The style map for the dialog element.\n */\n private get dialogStyleMap(): StyleInfo {\n return {\n '--swc-overlay-open-count': Overlay.openCount.toString(),\n };\n }\n\n /**\n * Renders the popover element for the overlay.\n *\n * This method returns a template result containing a div element styled as a popover.\n * The popover element includes various attributes and event listeners to manage the overlay's state and behavior.\n *\n * @protected\n * @returns {TemplateResult} The template result containing the popover element.\n */\n protected renderPopover(): TemplateResult {\n /**\n * The `--swc-overlay-open-count` custom property is applied to mimic the single stack\n * nature of the top layer in browsers that do not yet support it.\n *\n * The value should always represent the total number of overlays that have ever been opened.\n * This value will be added to the `--swc-overlay-z-index-base` custom property, which can be\n * provided by a consuming developer. By default, `--swc-overlay-z-index-base` is set to 1000\n * to ensure that the overlay stacks above most other elements during fallback delivery.\n */\n return html`\n ${this.needsModalBackdrop\n ? html`\n <div class=\"modal-backdrop\"></div>\n `\n : nothing}\n <div\n class=\"dialog\"\n part=\"dialog\"\n role=${ifDefined(\n this.type === 'modal' || this.type === 'page' ? 'dialog' : undefined\n )}\n aria-modal=${ifDefined(\n this.type === 'modal' || this.type === 'page' ? 'true' : undefined\n )}\n placement=${ifDefined(\n this.requiresPositioning ? this.placement || 'right' : undefined\n )}\n popover=${ifDefined(this.popoverValue)}\n style=${styleMap(this.dialogStyleMap)}\n @beforetoggle=${this.handleBeforetoggle}\n @close=${this.handleBrowserClose}\n ?is-visible=${this.state !== 'closed'}\n >\n ${this.renderContent()}\n </div>\n `;\n }\n\n /**\n * Renders the overlay component.\n *\n * This method returns a template result containing either a dialog or popover element\n * based on the overlay type. It also includes a slot for longpress descriptors.\n *\n * @override\n * @returns {TemplateResult} The template result containing the overlay content.\n */\n public override render(): TemplateResult {\n return html`\n ${this.renderPopover()}\n <slot name=\"longpress-describedby-descriptor\"></slot>\n `;\n }\n\n /**\n * Lifecycle method called when the component is added to the DOM.\n *\n * This method sets up event listeners and binds events if the component has already updated.\n *\n * @override\n */\n override connectedCallback(): void {\n super.connectedCallback();\n\n // Add an event listener to handle the 'close' event and update the 'open' property.\n this.addEventListener('close', this.handleClose);\n\n // Bind events if the component has already updated.\n if (this.hasUpdated) {\n this.bindEvents();\n }\n }\n\n /**\n * Lifecycle method called when the component is removed from the DOM.\n *\n * This method releases the description from the strategy and updates the 'open' property.\n *\n * @override\n */\n override disconnectedCallback(): void {\n // Release the description from the strategy.\n this.strategy?.releaseDescription();\n // Update the 'open' property to false.\n this.open = false;\n this.removeEventListener('close', this.handleClose);\n super.disconnectedCallback();\n }\n}\n"],
5
+ "mappings": "qNAWA,OACE,QAAAA,EACA,WAAAC,MAGK,gCACP,OACE,YAAAC,EACA,SAAAC,EACA,yBAAAC,EACA,SAAAC,MACK,kDACP,OACE,aAAAC,EAEA,YAAAC,MACK,kDACP,OACE,+BAAAC,EACA,gCAAAC,MACK,yEACP,OAAS,YAAAC,MAAgB,mDAEzB,OAAS,mBAAAC,EAAiB,aAAAC,MAAiB,uBAW3C,OAAS,oBAAAC,MAAwB,wBACjC,OAAS,kBAAAC,MAAsB,sBAC/B,OAAS,gBAAAC,MAAoB,oBAC7B,OAAS,uBAAAC,MAA2B,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AAE,UAAW,EAAM,CAAC,GAtUnBsB,EAuUX,+BASS8B,EAAA,CADRpD,EAAS,GA/UCsB,EAgVF,oBAhVJ,WAAM,QAANA",
6
+ "names": ["html", "nothing", "property", "query", "queryAssignedElements", "state", "ifDefined", "styleMap", "ElementResolutionController", "elementResolverUpdatedSymbol", "randomID", "AbstractOverlay", "nextFrame", "OverlayNoPopover", "OverlayPopover", "overlayStack", "PlacementController", "VirtualTrigger", "styles", "removeSlottableRequest", "SlottableRequestEvent", "strategies", "browserSupportsPopover", "ComputedOverlayBase", "_Overlay", "event", "relationEvent", "el", "lastElement", "delayed", "disabled", "_a", "open", "oldState", "offset", "trigger", "placement", "tipPadding", "targetOpenState", "focusEl", "focusTrap", "initialFocus", "getAncestors", "_b", "ancestors", "currentNode", "ancestor", "oldOpen", "listenerRoot", "shouldPreventClose", "changes", "id", "interaction", "oldTrigger", "__decorateClass"]
7
7
  }
@@ -74,10 +74,21 @@ export declare class OverlayTrigger extends SpectrumElement {
74
74
  clickOverlayElement: Overlay;
75
75
  longpressOverlayElement: Overlay;
76
76
  hoverOverlayElement: Overlay;
77
+ /**
78
+ * Tracks elements where this component has taken ownership
79
+ * of ARIA attributes, so consumer-set values are never removed.
80
+ */
81
+ private ariaManagedElements;
82
+ private previousTriggerElement?;
77
83
  private getAssignedElementsFromSlot;
78
84
  private handleTriggerContent;
79
85
  private handleSlotContent;
80
86
  private handleBeforetoggle;
87
+ private static readonly VALID_HASPOPUP_ROLES;
88
+ private resolveHaspopupValue;
89
+ private removeAriaFromTrigger;
90
+ private manageAriaOnTrigger;
91
+ disconnectedCallback(): void;
81
92
  protected update(changes: PropertyValues): void;
82
93
  protected renderSlot(name: string): TemplateResult;
83
94
  protected renderClickOverlay(): TemplateResult;
@@ -18,9 +18,10 @@ import {
18
18
  query,
19
19
  state
20
20
  } from "@spectrum-web-components/base/src/decorators.js";
21
+ import { randomID } from "@spectrum-web-components/shared/src/random-id.js";
21
22
  import "@spectrum-web-components/overlay/sp-overlay.js";
22
23
  import overlayTriggerStyles from "./overlay-trigger.css.js";
23
- export class OverlayTrigger extends SpectrumElement {
24
+ const _OverlayTrigger = class _OverlayTrigger extends SpectrumElement {
24
25
  constructor() {
25
26
  super(...arguments);
26
27
  this.offset = 6;
@@ -30,6 +31,11 @@ export class OverlayTrigger extends SpectrumElement {
30
31
  this.longpressContent = [];
31
32
  this.hoverContent = [];
32
33
  this.targetContent = [];
34
+ /**
35
+ * Tracks elements where this component has taken ownership
36
+ * of ARIA attributes, so consumer-set values are never removed.
37
+ */
38
+ this.ariaManagedElements = /* @__PURE__ */ new WeakSet();
33
39
  }
34
40
  static get styles() {
35
41
  return [overlayTriggerStyles];
@@ -71,6 +77,68 @@ export class OverlayTrigger extends SpectrumElement {
71
77
  this.open = void 0;
72
78
  }
73
79
  }
80
+ resolveHaspopupValue() {
81
+ const content = this.clickContent[0] || this.longpressContent[0];
82
+ if (!content) {
83
+ return "dialog";
84
+ }
85
+ const role = content.getAttribute("role");
86
+ if (role && _OverlayTrigger.VALID_HASPOPUP_ROLES.has(role)) {
87
+ return role;
88
+ }
89
+ const firstChild = content.querySelector("[role]");
90
+ if (firstChild && _OverlayTrigger.VALID_HASPOPUP_ROLES.has(firstChild.getAttribute("role"))) {
91
+ return firstChild.getAttribute("role");
92
+ }
93
+ return "dialog";
94
+ }
95
+ removeAriaFromTrigger(element) {
96
+ if (!this.ariaManagedElements.has(element)) {
97
+ return;
98
+ }
99
+ element.removeAttribute("aria-expanded");
100
+ element.removeAttribute("aria-controls");
101
+ element.removeAttribute("aria-haspopup");
102
+ this.ariaManagedElements.delete(element);
103
+ }
104
+ manageAriaOnTrigger() {
105
+ const triggerElement = this.targetContent[0];
106
+ if (this.previousTriggerElement && this.previousTriggerElement !== triggerElement) {
107
+ this.removeAriaFromTrigger(this.previousTriggerElement);
108
+ }
109
+ this.previousTriggerElement = triggerElement;
110
+ if (!triggerElement) {
111
+ return;
112
+ }
113
+ const hasClickContent = this.clickContent.length > 0;
114
+ const hasLongpressContent = this.longpressContent.length > 0;
115
+ if (!hasClickContent && !hasLongpressContent) {
116
+ this.removeAriaFromTrigger(triggerElement);
117
+ return;
118
+ }
119
+ const isExpanded = this.open === "click" || this.open === "longpress";
120
+ triggerElement.setAttribute("aria-expanded", String(isExpanded));
121
+ if (this.ariaManagedElements.has(triggerElement) || !triggerElement.hasAttribute("aria-haspopup")) {
122
+ triggerElement.setAttribute("aria-haspopup", this.resolveHaspopupValue());
123
+ }
124
+ this.ariaManagedElements.add(triggerElement);
125
+ const content = this.open === "longpress" ? this.longpressContent[0] : this.open === "click" ? this.clickContent[0] : this.clickContent[0] || this.longpressContent[0];
126
+ if (content) {
127
+ if (!content.id) {
128
+ content.id = `sp-overlay-content-${randomID()}`;
129
+ }
130
+ triggerElement.setAttribute("aria-controls", content.id);
131
+ } else {
132
+ triggerElement.removeAttribute("aria-controls");
133
+ }
134
+ }
135
+ disconnectedCallback() {
136
+ if (this.previousTriggerElement) {
137
+ this.removeAriaFromTrigger(this.previousTriggerElement);
138
+ this.previousTriggerElement = void 0;
139
+ }
140
+ super.disconnectedCallback();
141
+ }
74
142
  update(changes) {
75
143
  var _a, _b, _c, _d, _e, _f;
76
144
  if (changes.has("clickContent")) {
@@ -207,52 +275,63 @@ export class OverlayTrigger extends SpectrumElement {
207
275
  this.open = void 0;
208
276
  return;
209
277
  }
278
+ if (changedProperties.has("open") || changedProperties.has("type") || changedProperties.has("targetContent") || changedProperties.has("clickContent") || changedProperties.has("longpressContent")) {
279
+ this.manageAriaOnTrigger();
280
+ }
210
281
  }
211
282
  async getUpdateComplete() {
212
283
  const complete = await super.getUpdateComplete();
213
284
  return complete;
214
285
  }
215
- }
286
+ };
287
+ _OverlayTrigger.VALID_HASPOPUP_ROLES = /* @__PURE__ */ new Set([
288
+ "menu",
289
+ "listbox",
290
+ "tree",
291
+ "grid",
292
+ "dialog"
293
+ ]);
216
294
  __decorateClass([
217
295
  property({ attribute: "triggered-by" })
218
- ], OverlayTrigger.prototype, "triggeredBy", 2);
296
+ ], _OverlayTrigger.prototype, "triggeredBy", 2);
219
297
  __decorateClass([
220
298
  property({ reflect: true })
221
- ], OverlayTrigger.prototype, "placement", 2);
299
+ ], _OverlayTrigger.prototype, "placement", 2);
222
300
  __decorateClass([
223
301
  property()
224
- ], OverlayTrigger.prototype, "type", 2);
302
+ ], _OverlayTrigger.prototype, "type", 2);
225
303
  __decorateClass([
226
304
  property({ type: Number })
227
- ], OverlayTrigger.prototype, "offset", 2);
305
+ ], _OverlayTrigger.prototype, "offset", 2);
228
306
  __decorateClass([
229
307
  property({ reflect: true })
230
- ], OverlayTrigger.prototype, "open", 2);
308
+ ], _OverlayTrigger.prototype, "open", 2);
231
309
  __decorateClass([
232
310
  property({ type: Boolean, reflect: true })
233
- ], OverlayTrigger.prototype, "disabled", 2);
311
+ ], _OverlayTrigger.prototype, "disabled", 2);
234
312
  __decorateClass([
235
313
  property({ attribute: "receives-focus" })
236
- ], OverlayTrigger.prototype, "receivesFocus", 2);
314
+ ], _OverlayTrigger.prototype, "receivesFocus", 2);
237
315
  __decorateClass([
238
316
  state()
239
- ], OverlayTrigger.prototype, "clickContent", 2);
317
+ ], _OverlayTrigger.prototype, "clickContent", 2);
240
318
  __decorateClass([
241
319
  state()
242
- ], OverlayTrigger.prototype, "longpressContent", 2);
320
+ ], _OverlayTrigger.prototype, "longpressContent", 2);
243
321
  __decorateClass([
244
322
  state()
245
- ], OverlayTrigger.prototype, "hoverContent", 2);
323
+ ], _OverlayTrigger.prototype, "hoverContent", 2);
246
324
  __decorateClass([
247
325
  state()
248
- ], OverlayTrigger.prototype, "targetContent", 2);
326
+ ], _OverlayTrigger.prototype, "targetContent", 2);
249
327
  __decorateClass([
250
328
  query("#click-overlay", true)
251
- ], OverlayTrigger.prototype, "clickOverlayElement", 2);
329
+ ], _OverlayTrigger.prototype, "clickOverlayElement", 2);
252
330
  __decorateClass([
253
331
  query("#longpress-overlay", true)
254
- ], OverlayTrigger.prototype, "longpressOverlayElement", 2);
332
+ ], _OverlayTrigger.prototype, "longpressOverlayElement", 2);
255
333
  __decorateClass([
256
334
  query("#hover-overlay", true)
257
- ], OverlayTrigger.prototype, "hoverOverlayElement", 2);
335
+ ], _OverlayTrigger.prototype, "hoverOverlayElement", 2);
336
+ export let OverlayTrigger = _OverlayTrigger;
258
337
  //# sourceMappingURL=OverlayTrigger.dev.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["OverlayTrigger.ts"],
4
- "sourcesContent": ["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport type { Placement } from '@floating-ui/dom';\n\nimport {\n CSSResultArray,\n html,\n PropertyValues,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n property,\n query,\n state,\n} from '@spectrum-web-components/base/src/decorators.js';\n\n/* eslint-disable import/no-extraneous-dependencies */\nimport '@spectrum-web-components/overlay/sp-overlay.js';\n\nimport type { BeforetoggleOpenEvent } from './events.dev.js'\nimport type { Overlay } from './Overlay.dev.js'\nimport overlayTriggerStyles from './overlay-trigger.css.js';\nimport type { OverlayTypes } from './overlay-types.dev.js'\n\nexport type OverlayContentTypes = 'click' | 'hover' | 'longpress';\n\n// Helper type to create all unique combinations of OverlayContentTypes\ntype Combinations<T extends string, U extends string = T> = T extends string\n ? T | `${T} ${Combinations<Exclude<U, T>>}`\n : never;\n\nexport type TriggeredByType = Combinations<OverlayContentTypes>;\n\n/**\n * @element overlay-trigger\n *\n * A component that manages overlay content triggered by different interactions.\n * Supports click, hover, and longpress triggered overlays with configurable\n * placement and behavior.\n *\n * @slot trigger - The content that will trigger the various overlays\n * @slot hover-content - The content that will be displayed on hover\n * @slot click-content - The content that will be displayed on click\n * @slot longpress-content - The content that will be displayed on longpress\n * @slot longpress-describedby-descriptor - Description for longpress content\n *\n * @fires sp-opened - Announces that the overlay has been opened\n * @fires sp-closed - Announces that the overlay has been closed\n *\n * @attr {string} placement - The placement of the overlay relative to the trigger\n * @attr {number} offset - The distance between the overlay and the trigger\n * @attr {boolean} disabled - Whether the overlay trigger is disabled\n * @attr {string} receives-focus - How focus should be handled ('true'|'false'|'auto')\n * @attr {string} triggered-by - The type of interaction that will trigger the overlay ('click'|'hover'|'longpress')\n */\nexport class OverlayTrigger extends SpectrumElement {\n public static override get styles(): CSSResultArray {\n return [overlayTriggerStyles];\n }\n\n /**\n * Optional property to optimize performance and prevent race conditions.\n *\n * By explicitly declaring which content types are used (e.g. \"click\", \"longpress hover\"),\n * we can avoid:\n * 1. Extra renders from unnecessary slot reparenting\n * 2. Potential infinite render loops during content detection\n * 3. Race conditions during slot assignment\n *\n * By only returning overlay wrappers for explicitly declared content types,\n * we minimize unecessary DOM nodes, operations and ensure a more stable rendering behavior.\n */\n @property({ attribute: 'triggered-by' })\n public triggeredBy?: TriggeredByType;\n\n /**\n * @type {\"top\" | \"top-start\" | \"top-end\" | \"right\" | \"right-start\" | \"right-end\" | \"bottom\" | \"bottom-start\" | \"bottom-end\" | \"left\" | \"left-start\" | \"left-end\"}\n * @attr\n */\n @property({ reflect: true })\n public placement?: Placement;\n\n @property()\n public type?: OverlayTypes;\n\n @property({ type: Number })\n public offset = 6;\n\n @property({ reflect: true })\n public open?: OverlayContentTypes;\n\n @property({ type: Boolean, reflect: true })\n public disabled = false;\n\n @property({ attribute: 'receives-focus' })\n public receivesFocus: 'true' | 'false' | 'auto' = 'auto';\n\n @state()\n private clickContent: HTMLElement[] = [];\n\n private clickPlacement?: Placement;\n\n @state()\n private longpressContent: HTMLElement[] = [];\n\n private longpressPlacement?: Placement;\n\n @state()\n private hoverContent: HTMLElement[] = [];\n\n private hoverPlacement?: Placement;\n\n @state()\n private targetContent: HTMLElement[] = [];\n\n @query('#click-overlay', true)\n clickOverlayElement!: Overlay;\n\n @query('#longpress-overlay', true)\n longpressOverlayElement!: Overlay;\n\n @query('#hover-overlay', true)\n hoverOverlayElement!: Overlay;\n\n private getAssignedElementsFromSlot(slot: HTMLSlotElement): HTMLElement[] {\n return slot.assignedElements({ flatten: true }) as HTMLElement[];\n }\n\n private handleTriggerContent(\n event: Event & { target: HTMLSlotElement }\n ): void {\n this.targetContent = this.getAssignedElementsFromSlot(event.target);\n }\n\n private handleSlotContent(event: Event & { target: HTMLSlotElement }): void {\n switch (event.target.name) {\n case 'click-content':\n this.clickContent = this.getAssignedElementsFromSlot(event.target);\n break;\n case 'longpress-content':\n this.longpressContent = this.getAssignedElementsFromSlot(event.target);\n break;\n case 'hover-content':\n this.hoverContent = this.getAssignedElementsFromSlot(event.target);\n break;\n }\n }\n\n private handleBeforetoggle(event: BeforetoggleOpenEvent): void {\n const { target } = event;\n let type: OverlayContentTypes;\n if (target === this.clickOverlayElement) {\n type = 'click';\n } else if (target === this.longpressOverlayElement) {\n type = 'longpress';\n } else if (target === this.hoverOverlayElement) {\n type = 'hover';\n /* c8 ignore next 3 */\n } else {\n return;\n }\n if (event.newState === 'open') {\n this.open = type;\n } else if (this.open === type) {\n this.open = undefined;\n }\n }\n\n protected override update(changes: PropertyValues): void {\n if (changes.has('clickContent')) {\n this.clickPlacement =\n ((this.clickContent[0]?.getAttribute('placement') ||\n this.clickContent[0]?.getAttribute('direction')) as Placement) ||\n undefined;\n }\n if (changes.has('hoverContent')) {\n this.hoverPlacement =\n ((this.hoverContent[0]?.getAttribute('placement') ||\n this.hoverContent[0]?.getAttribute('direction')) as Placement) ||\n undefined;\n }\n if (changes.has('longpressContent')) {\n this.longpressPlacement =\n ((this.longpressContent[0]?.getAttribute('placement') ||\n this.longpressContent[0]?.getAttribute('direction')) as Placement) ||\n undefined;\n }\n super.update(changes);\n }\n\n protected renderSlot(name: string): TemplateResult {\n return html`\n <slot name=${name} @slotchange=${this.handleSlotContent}></slot>\n `;\n }\n\n protected renderClickOverlay(): TemplateResult {\n const slot = this.renderSlot('click-content');\n const clickOverlay = html`\n <sp-overlay\n id=\"click-overlay\"\n ?disabled=${this.disabled || !this.clickContent.length}\n ?open=${this.open === 'click' && !!this.clickContent.length}\n .offset=${this.offset}\n .placement=${this.clickPlacement || this.placement}\n .triggerElement=${this.targetContent[0]}\n .triggerInteraction=${'click'}\n .type=${this.type || 'auto'}\n @beforetoggle=${this.handleBeforetoggle}\n .receivesFocus=${this.receivesFocus}\n >\n ${slot}\n </sp-overlay>\n `;\n\n // If click interactions are explicitly enabled by customers, always return the overlay\n if (this.triggeredBy?.includes('click')) {\n return clickOverlay;\n }\n\n if (!this.clickContent.length) {\n return slot;\n } else {\n return clickOverlay;\n }\n }\n\n protected renderHoverOverlay(): TemplateResult {\n const slot = this.renderSlot('hover-content');\n const hoverOverlay = html`\n <sp-overlay\n id=\"hover-overlay\"\n ?open=${this.open === 'hover' && !!this.hoverContent.length}\n ?disabled=${this.disabled ||\n !this.hoverContent.length ||\n (!!this.open && this.open !== 'hover')}\n .offset=${this.offset}\n .placement=${this.hoverPlacement || this.placement}\n .triggerElement=${this.targetContent[0]}\n .triggerInteraction=${'hover'}\n .type=${'hint'}\n @beforetoggle=${this.handleBeforetoggle}\n .receivesFocus=${this.receivesFocus}\n >\n ${slot}\n </sp-overlay>\n `;\n\n // If hover interactions are explicitly enabled by customers, always return the overlay\n if (this.triggeredBy?.includes('hover')) {\n return hoverOverlay;\n }\n\n if (!this.hoverContent.length) {\n return slot;\n } else {\n return hoverOverlay;\n }\n }\n\n protected renderLongpressOverlay(): TemplateResult {\n const slot = this.renderSlot('longpress-content');\n const longpressOverlay = html`\n <sp-overlay\n id=\"longpress-overlay\"\n ?disabled=${this.disabled || !this.longpressContent.length}\n ?open=${this.open === 'longpress' && !!this.longpressContent.length}\n .offset=${this.offset}\n .placement=${this.longpressPlacement || this.placement}\n .triggerElement=${this.targetContent[0]}\n .triggerInteraction=${'longpress'}\n .type=${'auto'}\n @beforetoggle=${this.handleBeforetoggle}\n .receivesFocus=${this.receivesFocus}\n >\n ${slot}\n </sp-overlay>\n <slot name=\"longpress-describedby-descriptor\"></slot>\n `;\n\n // If click interactions are explicitly enabled by customers, always return the overlay\n if (this.triggeredBy?.includes('longpress')) {\n return longpressOverlay;\n }\n\n if (!this.longpressContent.length) {\n return slot;\n } else {\n return longpressOverlay;\n }\n }\n\n protected override render(): TemplateResult {\n // Keyboard event availability documented in README.md\n return html`\n <slot\n id=\"trigger\"\n name=\"trigger\"\n @slotchange=${this.handleTriggerContent}\n ></slot>\n ${[\n this.renderClickOverlay(),\n this.renderHoverOverlay(),\n this.renderLongpressOverlay(),\n ]}\n `;\n }\n\n protected override updated(changedProperties: PropertyValues): void {\n super.updated(changedProperties);\n\n if (window.__swc?.DEBUG && !this.triggeredBy) {\n const issues = [\n 'You have not specified the `triggeredBy` property. For optimal performance, consider explicitly declaring which overlay types you plan to use.',\n 'Example: triggered-by=\"click hover\"',\n 'This helps avoid unnecessary DOM operations and potential race conditions.',\n ];\n\n window.__swc.warn(\n this,\n 'Performance optimization available for <overlay-trigger>:',\n 'https://opensource.adobe.com/spectrum-web-components/components/overlay-trigger/#performance-optimization',\n { issues }\n );\n }\n\n if (this.disabled && changedProperties.has('disabled')) {\n this.open = undefined;\n return;\n }\n }\n\n protected override async getUpdateComplete(): Promise<boolean> {\n const complete = (await super.getUpdateComplete()) as boolean;\n return complete;\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;AAcA;AAAA,EAEE;AAAA,EAEA;AAAA,OAEK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,OAAO;AAIP,OAAO,0BAA0B;AAkC1B,aAAM,uBAAuB,gBAAgB;AAAA,EAA7C;AAAA;AA+BL,SAAO,SAAS;AAMhB,SAAO,WAAW;A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,IAAI;AAAA,GA5DlB,eA6DX;AAGA;AAAA,EADC,MAAM,sBAAsB,IAAI;AAAA,GA/DtB,eAgEX;AAGA;AAAA,EADC,MAAM,kBAAkB,IAAI;AAAA,GAlElB,eAmEX;",
4
+ "sourcesContent": ["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport type { Placement } from '@floating-ui/dom';\n\nimport {\n CSSResultArray,\n html,\n PropertyValues,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n property,\n query,\n state,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { randomID } from '@spectrum-web-components/shared/src/random-id.js';\n\n/* eslint-disable import/no-extraneous-dependencies */\nimport '@spectrum-web-components/overlay/sp-overlay.js';\n\nimport type { BeforetoggleOpenEvent } from './events.dev.js'\nimport type { Overlay } from './Overlay.dev.js'\nimport overlayTriggerStyles from './overlay-trigger.css.js';\nimport type { OverlayTypes } from './overlay-types.dev.js'\n\nexport type OverlayContentTypes = 'click' | 'hover' | 'longpress';\n\n// Helper type to create all unique combinations of OverlayContentTypes\ntype Combinations<T extends string, U extends string = T> = T extends string\n ? T | `${T} ${Combinations<Exclude<U, T>>}`\n : never;\n\nexport type TriggeredByType = Combinations<OverlayContentTypes>;\n\n/**\n * @element overlay-trigger\n *\n * A component that manages overlay content triggered by different interactions.\n * Supports click, hover, and longpress triggered overlays with configurable\n * placement and behavior.\n *\n * @slot trigger - The content that will trigger the various overlays\n * @slot hover-content - The content that will be displayed on hover\n * @slot click-content - The content that will be displayed on click\n * @slot longpress-content - The content that will be displayed on longpress\n * @slot longpress-describedby-descriptor - Description for longpress content\n *\n * @fires sp-opened - Announces that the overlay has been opened\n * @fires sp-closed - Announces that the overlay has been closed\n *\n * @attr {string} placement - The placement of the overlay relative to the trigger\n * @attr {number} offset - The distance between the overlay and the trigger\n * @attr {boolean} disabled - Whether the overlay trigger is disabled\n * @attr {string} receives-focus - How focus should be handled ('true'|'false'|'auto')\n * @attr {string} triggered-by - The type of interaction that will trigger the overlay ('click'|'hover'|'longpress')\n */\nexport class OverlayTrigger extends SpectrumElement {\n public static override get styles(): CSSResultArray {\n return [overlayTriggerStyles];\n }\n\n /**\n * Optional property to optimize performance and prevent race conditions.\n *\n * By explicitly declaring which content types are used (e.g. \"click\", \"longpress hover\"),\n * we can avoid:\n * 1. Extra renders from unnecessary slot reparenting\n * 2. Potential infinite render loops during content detection\n * 3. Race conditions during slot assignment\n *\n * By only returning overlay wrappers for explicitly declared content types,\n * we minimize unecessary DOM nodes, operations and ensure a more stable rendering behavior.\n */\n @property({ attribute: 'triggered-by' })\n public triggeredBy?: TriggeredByType;\n\n /**\n * @type {\"top\" | \"top-start\" | \"top-end\" | \"right\" | \"right-start\" | \"right-end\" | \"bottom\" | \"bottom-start\" | \"bottom-end\" | \"left\" | \"left-start\" | \"left-end\"}\n * @attr\n */\n @property({ reflect: true })\n public placement?: Placement;\n\n @property()\n public type?: OverlayTypes;\n\n @property({ type: Number })\n public offset = 6;\n\n @property({ reflect: true })\n public open?: OverlayContentTypes;\n\n @property({ type: Boolean, reflect: true })\n public disabled = false;\n\n @property({ attribute: 'receives-focus' })\n public receivesFocus: 'true' | 'false' | 'auto' = 'auto';\n\n @state()\n private clickContent: HTMLElement[] = [];\n\n private clickPlacement?: Placement;\n\n @state()\n private longpressContent: HTMLElement[] = [];\n\n private longpressPlacement?: Placement;\n\n @state()\n private hoverContent: HTMLElement[] = [];\n\n private hoverPlacement?: Placement;\n\n @state()\n private targetContent: HTMLElement[] = [];\n\n @query('#click-overlay', true)\n clickOverlayElement!: Overlay;\n\n @query('#longpress-overlay', true)\n longpressOverlayElement!: Overlay;\n\n @query('#hover-overlay', true)\n hoverOverlayElement!: Overlay;\n\n /**\n * Tracks elements where this component has taken ownership\n * of ARIA attributes, so consumer-set values are never removed.\n */\n private ariaManagedElements = new WeakSet<HTMLElement>();\n\n private previousTriggerElement?: HTMLElement;\n\n private getAssignedElementsFromSlot(slot: HTMLSlotElement): HTMLElement[] {\n return slot.assignedElements({ flatten: true }) as HTMLElement[];\n }\n\n private handleTriggerContent(\n event: Event & { target: HTMLSlotElement }\n ): void {\n this.targetContent = this.getAssignedElementsFromSlot(event.target);\n }\n\n private handleSlotContent(event: Event & { target: HTMLSlotElement }): void {\n switch (event.target.name) {\n case 'click-content':\n this.clickContent = this.getAssignedElementsFromSlot(event.target);\n break;\n case 'longpress-content':\n this.longpressContent = this.getAssignedElementsFromSlot(event.target);\n break;\n case 'hover-content':\n this.hoverContent = this.getAssignedElementsFromSlot(event.target);\n break;\n }\n }\n\n private handleBeforetoggle(event: BeforetoggleOpenEvent): void {\n const { target } = event;\n let type: OverlayContentTypes;\n if (target === this.clickOverlayElement) {\n type = 'click';\n } else if (target === this.longpressOverlayElement) {\n type = 'longpress';\n } else if (target === this.hoverOverlayElement) {\n type = 'hover';\n /* c8 ignore next 3 */\n } else {\n return;\n }\n if (event.newState === 'open') {\n this.open = type;\n } else if (this.open === type) {\n this.open = undefined;\n }\n }\n\n private static readonly VALID_HASPOPUP_ROLES = new Set([\n 'menu',\n 'listbox',\n 'tree',\n 'grid',\n 'dialog',\n ]);\n\n private resolveHaspopupValue(): string {\n const content = this.clickContent[0] || this.longpressContent[0];\n if (!content) {\n return 'dialog';\n }\n const role = content.getAttribute('role');\n if (role && OverlayTrigger.VALID_HASPOPUP_ROLES.has(role)) {\n return role;\n }\n const firstChild = content.querySelector('[role]') as HTMLElement | null;\n if (\n firstChild &&\n OverlayTrigger.VALID_HASPOPUP_ROLES.has(firstChild.getAttribute('role')!)\n ) {\n return firstChild.getAttribute('role')!;\n }\n return 'dialog';\n }\n\n private removeAriaFromTrigger(element: HTMLElement): void {\n if (!this.ariaManagedElements.has(element)) {\n return;\n }\n element.removeAttribute('aria-expanded');\n element.removeAttribute('aria-controls');\n element.removeAttribute('aria-haspopup');\n this.ariaManagedElements.delete(element);\n }\n\n private manageAriaOnTrigger(): void {\n const triggerElement = this.targetContent[0];\n\n if (\n this.previousTriggerElement &&\n this.previousTriggerElement !== triggerElement\n ) {\n this.removeAriaFromTrigger(this.previousTriggerElement);\n }\n this.previousTriggerElement = triggerElement;\n\n if (!triggerElement) {\n return;\n }\n\n const hasClickContent = this.clickContent.length > 0;\n const hasLongpressContent = this.longpressContent.length > 0;\n\n if (!hasClickContent && !hasLongpressContent) {\n this.removeAriaFromTrigger(triggerElement);\n return;\n }\n\n const isExpanded = this.open === 'click' || this.open === 'longpress';\n triggerElement.setAttribute('aria-expanded', String(isExpanded));\n\n if (\n this.ariaManagedElements.has(triggerElement) ||\n !triggerElement.hasAttribute('aria-haspopup')\n ) {\n triggerElement.setAttribute('aria-haspopup', this.resolveHaspopupValue());\n }\n this.ariaManagedElements.add(triggerElement);\n\n const content =\n this.open === 'longpress'\n ? this.longpressContent[0]\n : this.open === 'click'\n ? this.clickContent[0]\n : this.clickContent[0] || this.longpressContent[0];\n if (content) {\n if (!content.id) {\n content.id = `sp-overlay-content-${randomID()}`;\n }\n triggerElement.setAttribute('aria-controls', content.id);\n } else {\n triggerElement.removeAttribute('aria-controls');\n }\n }\n\n override disconnectedCallback(): void {\n if (this.previousTriggerElement) {\n this.removeAriaFromTrigger(this.previousTriggerElement);\n this.previousTriggerElement = undefined;\n }\n super.disconnectedCallback();\n }\n\n protected override update(changes: PropertyValues): void {\n if (changes.has('clickContent')) {\n this.clickPlacement =\n ((this.clickContent[0]?.getAttribute('placement') ||\n this.clickContent[0]?.getAttribute('direction')) as Placement) ||\n undefined;\n }\n if (changes.has('hoverContent')) {\n this.hoverPlacement =\n ((this.hoverContent[0]?.getAttribute('placement') ||\n this.hoverContent[0]?.getAttribute('direction')) as Placement) ||\n undefined;\n }\n if (changes.has('longpressContent')) {\n this.longpressPlacement =\n ((this.longpressContent[0]?.getAttribute('placement') ||\n this.longpressContent[0]?.getAttribute('direction')) as Placement) ||\n undefined;\n }\n super.update(changes);\n }\n\n protected renderSlot(name: string): TemplateResult {\n return html`\n <slot name=${name} @slotchange=${this.handleSlotContent}></slot>\n `;\n }\n\n protected renderClickOverlay(): TemplateResult {\n const slot = this.renderSlot('click-content');\n const clickOverlay = html`\n <sp-overlay\n id=\"click-overlay\"\n ?disabled=${this.disabled || !this.clickContent.length}\n ?open=${this.open === 'click' && !!this.clickContent.length}\n .offset=${this.offset}\n .placement=${this.clickPlacement || this.placement}\n .triggerElement=${this.targetContent[0]}\n .triggerInteraction=${'click'}\n .type=${this.type || 'auto'}\n @beforetoggle=${this.handleBeforetoggle}\n .receivesFocus=${this.receivesFocus}\n >\n ${slot}\n </sp-overlay>\n `;\n\n // If click interactions are explicitly enabled by customers, always return the overlay\n if (this.triggeredBy?.includes('click')) {\n return clickOverlay;\n }\n\n if (!this.clickContent.length) {\n return slot;\n } else {\n return clickOverlay;\n }\n }\n\n protected renderHoverOverlay(): TemplateResult {\n const slot = this.renderSlot('hover-content');\n const hoverOverlay = html`\n <sp-overlay\n id=\"hover-overlay\"\n ?open=${this.open === 'hover' && !!this.hoverContent.length}\n ?disabled=${this.disabled ||\n !this.hoverContent.length ||\n (!!this.open && this.open !== 'hover')}\n .offset=${this.offset}\n .placement=${this.hoverPlacement || this.placement}\n .triggerElement=${this.targetContent[0]}\n .triggerInteraction=${'hover'}\n .type=${'hint'}\n @beforetoggle=${this.handleBeforetoggle}\n .receivesFocus=${this.receivesFocus}\n >\n ${slot}\n </sp-overlay>\n `;\n\n // If hover interactions are explicitly enabled by customers, always return the overlay\n if (this.triggeredBy?.includes('hover')) {\n return hoverOverlay;\n }\n\n if (!this.hoverContent.length) {\n return slot;\n } else {\n return hoverOverlay;\n }\n }\n\n protected renderLongpressOverlay(): TemplateResult {\n const slot = this.renderSlot('longpress-content');\n const longpressOverlay = html`\n <sp-overlay\n id=\"longpress-overlay\"\n ?disabled=${this.disabled || !this.longpressContent.length}\n ?open=${this.open === 'longpress' && !!this.longpressContent.length}\n .offset=${this.offset}\n .placement=${this.longpressPlacement || this.placement}\n .triggerElement=${this.targetContent[0]}\n .triggerInteraction=${'longpress'}\n .type=${'auto'}\n @beforetoggle=${this.handleBeforetoggle}\n .receivesFocus=${this.receivesFocus}\n >\n ${slot}\n </sp-overlay>\n <slot name=\"longpress-describedby-descriptor\"></slot>\n `;\n\n // If click interactions are explicitly enabled by customers, always return the overlay\n if (this.triggeredBy?.includes('longpress')) {\n return longpressOverlay;\n }\n\n if (!this.longpressContent.length) {\n return slot;\n } else {\n return longpressOverlay;\n }\n }\n\n protected override render(): TemplateResult {\n // Keyboard event availability documented in README.md\n return html`\n <slot\n id=\"trigger\"\n name=\"trigger\"\n @slotchange=${this.handleTriggerContent}\n ></slot>\n ${[\n this.renderClickOverlay(),\n this.renderHoverOverlay(),\n this.renderLongpressOverlay(),\n ]}\n `;\n }\n\n protected override updated(changedProperties: PropertyValues): void {\n super.updated(changedProperties);\n\n if (window.__swc?.DEBUG && !this.triggeredBy) {\n const issues = [\n 'You have not specified the `triggeredBy` property. For optimal performance, consider explicitly declaring which overlay types you plan to use.',\n 'Example: triggered-by=\"click hover\"',\n 'This helps avoid unnecessary DOM operations and potential race conditions.',\n ];\n\n window.__swc.warn(\n this,\n 'Performance optimization available for <overlay-trigger>:',\n 'https://opensource.adobe.com/spectrum-web-components/components/overlay-trigger/#performance-optimization',\n { issues }\n );\n }\n\n if (this.disabled && changedProperties.has('disabled')) {\n this.open = undefined;\n return;\n }\n\n if (\n changedProperties.has('open') ||\n changedProperties.has('type') ||\n changedProperties.has('targetContent') ||\n changedProperties.has('clickContent') ||\n changedProperties.has('longpressContent')\n ) {\n this.manageAriaOnTrigger();\n }\n }\n\n protected override async getUpdateComplete(): Promise<boolean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