import CwElement from '../../internal/cw-element.js'; import type { CSSResultGroup } from 'lit'; /** * @summary Popovers display rich content anchored to a trigger, positioned with floating-ui and rendered via the * native Popover API's top layer — a good fit for content that doesn't belong in a tooltip (hover-only) or a * dropdown (menu-focused). * @documentation https://cordwainer.dev/components/popover * @status experimental * @since 1.5 * * @slot - The popover's content. * @slot trigger - The element that anchors and toggles the popover, usually a ``. * * @event cw-show - Emitted when the popover opens. * @event cw-after-show - Emitted after the popover opens and all animations are complete. * @event cw-hide - Emitted when the popover closes, whether via `hide()`/toggling `open`, or dismissed natively * (clicking outside, pressing Escape). * @event cw-after-hide - Emitted after the popover closes and all animations are complete. * * @csspart trigger - The container that wraps the trigger. * @csspart popup - The outer popup container, the element the native Popover API and floating-ui both act on. Has * no visible styling of its own — see `body` for the visible box. * @csspart body - The popup's visible box (background, border, padding) wrapping its content. * @csspart arrow - The arrow's container, present only when the `arrow` attribute is set. * * @cssproperty [--arrow-size=6px] - The size of the arrow. Note that an arrow won't be shown unless the `arrow` * attribute is used. * @cssproperty [--arrow-color=var(--cw-color-neutral-0)] - The color of the arrow. * * @animation popover.show - The animation to use when showing the popover. * @animation popover.hide - The animation to use when hiding the popover. */ export default class CwPopover extends CwElement { static styles: CSSResultGroup; private readonly localize; private cleanup; private closeWatcher; trigger: HTMLSlotElement; popup: HTMLElement; private arrowEl; /** * Indicates whether or not the popover is open. You can toggle this attribute to show and hide the popover, or you * can use the `show()` and `hide()` methods. Clicking outside the popover or pressing Escape closes it too. */ open: boolean; /** * The preferred placement of the popover. Note that the actual placement may vary as needed to keep the popover * inside of the viewport. */ placement: 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'right' | 'right-start' | 'right-end' | 'left' | 'left-start' | 'left-end'; /** Disables the popover so it can't be opened. */ disabled: boolean; /** The distance in pixels from which to offset the popover away from its trigger. */ distance: number; /** The distance in pixels from which to offset the popover along its trigger. */ skidding: number; /** * Attaches an arrow to the popover, pointing at the trigger. The arrow's size and color can be customized using * the `--arrow-size` and `--arrow-color` custom properties, or via `::part(arrow)`. */ arrow: boolean; firstUpdated(): void; private syncTriggerDisabledState; private handleTriggerSlotChange; handleDisabledChange(): void; disconnectedCallback(): void; /** Shows the popover. */ show(): Promise; /** Hides the popover. */ hide(): Promise; /** Instructs the popover to recalculate and update its position. Useful if the trigger's size or position changes. */ reposition(): void; private getAnchor; private handleTriggerClick; private handleDocumentMouseDown; private handleDocumentKeyDown; private addOpenListeners; private removeOpenListeners; handleOpenChange(): Promise; render(): import("lit-html").TemplateResult<1>; }