import { ID } from "../../types/index.mjs"; import { ContextTrinity } from "../createTrinity/index.mjs"; import { RegistryContext, RegistryTicket, RegistryTicketInput } from "../createRegistry/index.mjs"; import { StepContext, StepTicket, StepTicketInput } from "../createStep/index.mjs"; import { MaybeElementRef } from "../toElement/index.mjs"; import { Plugin } from "../createPlugin/index.mjs"; import { FormContext } from "../createForm/index.mjs"; import { Ref, ShallowRef } from "vue"; //#region src/composables/useTour/index.d.ts type TourDirection = 'forward' | 'back' | 'resume' | 'jump'; /** Placement `Tour.Content` honors. Any other string is ignored at runtime. */ type TourPlacement = 'top' | 'bottom' | 'left' | 'right' | 'center'; /** * Context passed to a step `enter` handler. * * @example * ```ts * import { createTour } from '@vuetify/v0' * * const tour = createTour() * * tour.steps.register({ * id: 'search', * enter: ({ done, activate, direction }) => { * const el = document.querySelector('[data-tour="search"]') * if (el) activate(el) * if (direction === 'back') done() * }, * }) * ``` */ interface TourEnterContext { done: () => void; /** * Token for this entry. Pass it to `tour.ready(stepId, visit)` when the work * outlives the handler. A number copy, captured when `enter` starts. */ visit: number; next: () => Promise; direction: TourDirection; activate: (target: MaybeElementRef, options?: TourActivateOptions) => void; deactivate: () => void; } /** * Options for programmatic `activate()`. * * @example * ```ts * import { createTour } from '@vuetify/v0' * * const tour = createTour() * const el = document.querySelector('[data-tour="search"]') * * if (el) tour.activate(el, { padding: 8, scroll: false }) * ``` */ interface TourActivateOptions { padding?: number; /** @default true */ scroll?: boolean; } /** * Input type for tour step tickets. Extra fields survive `onboard` / `register`. * * @example * ```ts * import { createTour } from '@vuetify/v0' * * const tour = createTour() * * tour.steps.onboard([ * { id: 'intro', placement: 'bottom', enter: ({ done }) => done() }, * { id: 'done', leave: () => {}, completed: () => {} }, * ]) * ``` */ interface TourTicketInput extends StepTicketInput { /** Honored by Tour.Content. Ignored here. */ placement?: TourPlacement; /** * No target element. Content centers immediately and Highlight paints a full scrim. */ noActivator?: boolean; enter?: (ctx: TourEnterContext) => void | Promise; leave?: () => void; completed?: () => void; } /** * Output type for tour step tickets. */ type TourTicket = StepTicket; /** * Input type for activator tickets, keyed by step id. * * @example * ```ts * import { createTour } from '@vuetify/v0' * * const tour = createTour() * const buttonEl = document.querySelector('button') * * if (buttonEl) tour.activators.register({ id: 'search', element: buttonEl, padding: 8 }) * ``` */ interface TourActivatorTicketInput extends RegistryTicketInput { element: MaybeElementRef; padding?: number; } /** * Output type for activator tickets. */ type TourActivatorTicket = RegistryTicket & Z; interface TourOptions {} interface TourContextOptions extends TourOptions { /** Namespace for dependency injection. @default 'v0:tour' */ namespace?: string; } interface TourPluginOptions extends TourContextOptions { /** Show this tour in the Vue DevTools v0 inspector. @default false */ devtools?: boolean; } /** * Context returned by createTour. */ interface TourContext = TourTicket> { steps: StepContext; activators: RegistryContext; form: FormContext; isActive: Readonly>; isComplete: Readonly>; isReady: Readonly>; isFirst: Readonly>; isLast: Readonly>; canGoBack: Readonly>; canGoNext: Readonly>; selectedId: Readonly>; readonly total: number; /** * Begin the tour. No-op when `!IN_BROWSER`. * * @example * ```ts * import { createTour } from '@vuetify/v0' * * const tour = createTour() * * tour.start() * tour.start({ stepId: 'search' }) * ``` */ start: (options?: { stepId?: ID; }) => void; /** * Dismiss without marking complete. * * @example * ```ts * import { createTour } from '@vuetify/v0' * * const tour = createTour() * * tour.stop() * ``` */ stop: () => void; /** * Dismiss and mark complete. Emits `completed` for the current step. * Resolves after an in-flight `next()` or `step()` finishes that completion, * or after its gate drops it. From inside the submit that gate is already * awaiting, it requests completion and resolves so that submit can finish. * * @example * ```ts * import { createTour } from '@vuetify/v0' * * const tour = createTour() * * await tour.complete() * ``` */ complete: () => Promise; /** * Stop, reset the form, and clear steps and activators. * * @example * ```ts * import { createTour } from '@vuetify/v0' * * const tour = createTour() * * tour.reset() * ``` */ reset: () => void; /** * Advance one step. No-op while inactive, unready, or on the last step. * Validates the current form field when one is registered under this step id. * * @example * ```ts * import { createTour } from '@vuetify/v0' * * const tour = createTour() * * await tour.next() * ``` */ next: () => Promise; /** * Move back one step. No-op while inactive, unready, or on the first step. * Does not validate and does not emit `completed`. * * @example * ```ts * import { createTour } from '@vuetify/v0' * * const tour = createTour() * * await tour.prev() * ``` */ prev: () => Promise; /** * Jump to a 1-based step index. Validates when leaving a form step. * * @example * ```ts * import { createTour } from '@vuetify/v0' * * const tour = createTour() * * await tour.step(3) * ``` */ step: (index: number) => Promise; /** * Register a programmatic activator for the current step. * * @example * ```ts * import { createTour } from '@vuetify/v0' * * const tour = createTour() * const el = document.querySelector('[data-tour="search"]') * * if (el) tour.activate(el, { scroll: false }) * ``` */ activate: (target: MaybeElementRef, options?: TourActivateOptions) => void; /** * Unregister the programmatic activator and restore `anchor-name`. * * @example * ```ts * import { createTour } from '@vuetify/v0' * * const tour = createTour() * * tour.deactivate() * ``` */ deactivate: () => void; /** * Mark this entry ready from outside the handler. No-op unless the tour is * active, `stepId` is still selected, and `visit` is the token from that * entry's context. * * @example * ```ts * import { createTour } from '@vuetify/v0' * * const tour = createTour() * * tour.steps.register({ * id: 'search', * enter: ({ visit }) => { * void fetch('/ready').then(() => tour.ready('search', visit)) * }, * }) * ``` */ ready: (stepId: ID, visit: number) => void; } /** * Creates a new tour instance. * * @param options Factory options. Collection membership is `steps.onboard` / `steps.register`. * @returns A tour context with steps, activators, form, and navigation. * * @example * ```ts * import { createTour } from '@vuetify/v0' * * const tour = createTour() * * tour.steps.onboard([{ id: 'intro' }, { id: 'done' }]) * tour.start() * ``` */ declare function createTour = TourTicket>(_options?: TourOptions): TourContext; /** * Creates a tour context with dependency injection support. * * @param options Configuration options including namespace * @returns Trinity tuple: [useTour, provideTour, defaultTour] * * @example * ```ts * import { createTourContext } from '@vuetify/v0' * * const [useTour, provideTour, tour] = createTourContext({ * namespace: 'v0:tour', * }) * * provideTour() * ``` */ declare function createTourContext = TourTicket>(_options?: TourContextOptions): ContextTrinity>; /** * Installs one tour on the app. `useTour()` reads it during component setup. * A local `provide` from `createTourContext` shadows it for that subtree. * * The plugin does not store a catalog. Stop the running tour, clear its * steps, and onboard the next tour's steps. Leave activators registered. * `reset()` clears those too. * * @example * ```ts * import { createTourPlugin } from '@vuetify/v0' * * app.use(createTourPlugin()) * ``` */ declare function createTourPlugin(_options?: TourPluginOptions): Plugin; /** * Returns the current tour context from dependency injection. * * @param namespace The namespace for the tour context. Defaults to `v0:tour`. * @returns The current tour context. * * @throws An error if the tour context is not found and no default is provided. * * @example * ```ts * import { useTour } from '@vuetify/v0' * * const tour = useTour() * * await tour.next() * ``` */ declare function useTour = TourTicket>(namespace?: string): TourContext; //#endregion export { TourActivateOptions, TourActivatorTicket, TourActivatorTicketInput, TourContext, TourContextOptions, TourDirection, TourEnterContext, TourOptions, TourPlacement, TourPluginOptions, TourTicket, TourTicketInput, createTour, createTourContext, createTourPlugin, useTour };