import type { WorkflowBuilder } from "../builder"; import type { ReadonlyStepProps, WorkflowDefinition } from "../definition"; export type { ReadonlyStartOptions, ReadonlyStepProps, WorkflowDefinition, WorkflowStepDefinition, } from "../definition"; /** A primitive value that can be stored in step data or passed to callbacks. */ export type PrimitiveValue = string | number | boolean | null; /** * Resolves the target element for a tour step. * * Can be a CSS selector string, an HTMLElement directly, or a function that resolves the target asynchronously. */ export type TargetResolver = string | HTMLElement | ((context: TargetResolverContext) => HTMLElement | null | Promise); /** Context passed to a target resolver function. */ export interface TargetResolverContext { /** Signal that aborts when the tour is cancelled or disposed. */ signal: AbortSignal; } /** Configures step-level interaction behavior and error handling. */ export interface StepBehavior { /** Allow user interaction with the target: the page is no longer inert and pointer events reach the target through the cutout, while the dimmed area still catches clicks. Change it during the step with `context.props.update({ behavior: { allowInteraction } })`. @default false */ allowInteraction?: boolean; /** Leave the page scrollable while the step is shown; set `false` to lock it. Change it during the step with `context.props.update({ behavior: { allowScroll } })`. @default true */ allowScroll?: boolean; /** * Focus the popover's Advance control (Back when going back) when the step is shown. Set `false` * to never move focus during the step: it stays where it is, on the body when a modal step * makes the page inert, and placing it is up to you. Focus that leaves the popover and target * is still pulled back, and focus returns to where it was when the tour ends. @default true */ autoFocus?: boolean; /** Scroll the target into view when the step is entered. @default true */ autoScroll?: boolean; /** What the step does when its target cannot be found. */ missingTarget?: MissingTargetOptions; /** Scroll behavior options. */ scroll?: ScrollOptions; /** * Behavior when the dimmed overlay backdrop (outside the cutout around the * target) is clicked: `"advance"` moves to the next step, `"cancel"` ends * the tour, `"none"` ignores the click. Has no effect when * `allowInteraction` is `true`: clicks on the dimmed area are then ignored. * @default "none" */ overlayClick?: "none" | "advance" | "cancel"; } /** How a step handles a target that cannot be found. */ export interface MissingTargetOptions { /** * `"wait"` retries until `timeout`, `"skip"` moves past the step, `"error"` fails the tour, * `"detached"` shows the popover centered in the viewport over a backdrop that covers the whole * screen. A detached step has no pointer and no cutout, does not scroll, keeps the page blocked * even when `allowInteraction` is `true`, and binds no `targetEvents`; its `context.target` is the * document's ``. * @default "error" */ strategy?: "wait" | "skip" | "error" | "detached"; /** How long to look for the target with the `"wait"` strategy, in milliseconds. @default 3000 */ timeout?: number; } /** Placement directions for positioning the pointer or popover around the target. */ export type TryOrderOptions = "top" | "bottom" | "left" | "right"; /** A resolved placement direction, including `"center"` for centered positioning. */ export type ResolvedPlacement = TryOrderOptions | "center"; /** One CSS class, or several. A string may hold several space-separated classes. */ export type ClassValue = string | readonly string[]; /** * Classes added to the tour components while a step is shown, one entry per component. * * They are added to the classes passed to the component itself, never replacing them. A step's entry * overrides the workflow's entry for the same component; the components the step leaves out keep the * workflow's classes. */ export interface TourClassNames { overlay?: ClassValue; popover?: ClassValue; pointer?: ClassValue; header?: ClassValue; content?: ClassValue; footer?: ClassValue; advance?: ClassValue; previous?: ClassValue; cancel?: ClassValue; } /** Base configuration for animated elements. */ export interface BaseOptions { /** Enable or disable animations. */ animated?: boolean; /** Animation duration and easing options. */ animation?: AnimationOptions; } /** Configures the pointer indicator that highlights the target element. */ export interface IndicatorOptions extends BaseOptions { /** Hide the indicator. It only shows on steps that allow interaction. @default false */ hidden?: boolean; /** Gap between the target and the indicator in pixels. */ gap?: number; /** Placement preference order when positioning the indicator. @default ["left", "right", "top", "bottom"] */ placementTryOrder?: readonly TryOrderOptions[]; } /** Configures the darkened overlay backdrop that highlights the target. */ export interface OverlayOptions extends BaseOptions { /** Color of the overlay backdrop (CSS color). Falls back to the `--glow-tour-overlay-color` theme variable when unset. */ color?: string; /** Opacity of the overlay (0-1). @default 0.7 */ opacity?: number; /** Padding around the target cutout in pixels. @default 8 */ padding?: number; /** Border radius of the target cutout in pixels. @default 8 */ radius?: number; } /** Configures the arrow that points from the popover to the target. */ export interface PopoverArrowOptions { /** Hide the arrow. @default false */ hidden?: boolean; /** Color of the arrow (CSS color). */ color?: string; /** Size of the arrow in pixels. @default 12 */ size?: number; /** Border width of the arrow in pixels. Falls back to the `--glow-tour-arrow-border-width` theme variable (`1px`) when unset. */ borderWidth?: number; /** Border radius of the arrow in pixels. @default 0 */ borderRadius?: number; /** Minimum gap the arrow keeps from the popover edges, in pixels. A placement whose arrow would fall inside this margin is rejected in favour of the next one. @default 16 */ edgePadding?: number; /** * CSP nonce applied to the `