import { SwishApp } from "../swish"; import { CreateElementLocatorArgs } from "./dom-utils"; export declare function createPlacement(swish: SwishApp, spec: PlacementSpec): { mount(): void; unmount(): void; }; /** -------------------------------------------- * Types * -------------------------------------------- */ export type BreakpointsSpec = { sm?: number; lg?: number; } | Record; export type ResponsiveValue = T | { base?: T; [breakpoint: string]: T | undefined; }; type ElementName = "save-button" | "home-button"; export type SaveButtonDesignSpec = { background?: ResponsiveValue; savedBackground?: ResponsiveValue; color?: ResponsiveValue; savedColor?: ResponsiveValue; height?: ResponsiveValue; radius?: ResponsiveValue; }; export type HomeButtonDesignSpec = { background?: ResponsiveValue; color?: ResponsiveValue; height?: ResponsiveValue; radius?: ResponsiveValue; }; type DesignSpecMap = { "save-button": SaveButtonDesignSpec; "home-button": HomeButtonDesignSpec; }; export type DesignSpecForElementName = TName extends keyof DesignSpecMap ? DesignSpecMap[TName] : never; export type MountMode = "before" | "after" | "append" | "prepend" | "replace"; export type MountAt = "target" | { closest: string; } | { query: string; } | { withinClosest: { root: string; selector: string; }; }; export type ContainerSpec = { tag?: keyof HTMLElementTagNameMap; classNames?: string[]; }; export type OverlayAnchor = "top-left" | "top-right" | "bottom-left" | "bottom-right"; export type ElementSpec = { name: TName; props?: Record; classNames?: string[]; }; export type OffsetSpec = { x?: number; y?: number; }; export type OverlayLayoutSpec = { type: "overlay"; anchor?: OverlayAnchor; zIndex?: number | string; offset?: OffsetSpec | ResponsiveValue; }; export type InlineLayoutSpec = { type: "inline"; rowSelector?: string; }; export type PlacementLayoutSpec = OverlayLayoutSpec | InlineLayoutSpec; export type PlacementSpec = { id: string; target: Omit; mount: { at?: MountAt; mode: MountMode; }; layout?: PlacementLayoutSpec; breakpoints?: BreakpointsSpec; container?: ContainerSpec; element?: ElementSpec | RenderFn; /** Design tokens (typed when element name is known). */ design?: DesignSpecForElementName; /** Custom CSS appended after defaults (one stylesheet per placement). */ css?: string; onMount?: (ctx: MountContext) => void; onUnmount?: (ctx: UnmountContext) => void; }; export type MountContext = { id: string; targetEl: Element; renderTargetEl: Element; mountEl: T; containerEl?: HTMLElement; rowEl?: HTMLElement; cleanup: (fn: () => void) => void; }; export type UnmountContext = Omit, "cleanup">; export type MountedElement = { targetEl: HTMLElement; renderTargetEl: HTMLElement; mountEl: T; containerEl?: HTMLElement; rowEl?: HTMLElement; rowWasCreated?: boolean; rowInlineAttrPrevValue?: string | null; cleanupFns: Array<() => void>; ownsNode: boolean; }; export type RenderFn = (spec: PlacementSpec) => HTMLElement | Promise; export {};