@eifi1/ui-kit 0.50.0 → 0.50.1
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.
- package/README.md +5 -5
- package/dist/components/autocomplete.js +13 -0
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/combobox.js +3 -1
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/inline-entity-combobox.js +12 -0
- package/dist/components/inline-entity-combobox.js.map +1 -1
- package/dist/eslint/index.js +1 -1
- package/dist/lib/quiet-focus.d.ts +4 -0
- package/dist/lib/quiet-focus.js +19 -0
- package/dist/lib/quiet-focus.js.map +1 -0
- package/dist/testing/index.d.ts +1 -0
- package/dist/testing/index.js +4 -0
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/tour.d.ts +31 -0
- package/dist/testing/tour.js +12 -0
- package/dist/testing/tour.js.map +1 -0
- package/dist/tour/tour-engine.d.ts +12 -0
- package/dist/tour/tour-engine.js +31 -0
- package/dist/tour/tour-engine.js.map +1 -0
- package/dist/tour/tour.d.ts +14 -3
- package/dist/tour/tour.js +60 -45
- package/dist/tour/tour.js.map +1 -1
- package/dist/tour/use-tour-url-sync.d.ts +5 -3
- package/dist/tour/use-tour-url-sync.js +21 -1
- package/dist/tour/use-tour-url-sync.js.map +1 -1
- package/package.json +1 -1
- package/src/components/autocomplete.tsx +18 -0
- package/src/components/combobox.tsx +5 -1
- package/src/components/inline-entity-combobox.tsx +17 -0
- package/src/lib/quiet-focus.ts +32 -0
- package/src/testing/index.ts +8 -0
- package/src/testing/tour.ts +41 -0
- package/src/tour/tour-engine.ts +41 -0
- package/src/tour/tour.tsx +64 -24
- package/src/tour/use-tour-url-sync.ts +33 -4
package/dist/tour/tour.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/tour/tour.tsx"],"sourcesContent":["import {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n} from \"react\";\nimport type { CSSProperties, ReactNode, RefObject } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { cn } from \"../lib/cn\";\nimport { useKitLabels, type LabelOverride } from \"../i18n/kit-labels\";\nimport { Button } from \"../components/button\";\nimport { useFocusTrap } from \"../hooks/use-focus-trap\";\nimport { useDismissLayer } from \"../hooks/use-dismiss\";\nimport { sameRect } from \"../hooks/use-anchored-rect\";\nimport { dirOf, horizontalStep } from \"../lib/direction\";\nimport { isComposing } from \"../lib/ime\";\nimport type { Direction } from \"../lib/direction\";\nimport { DEFAULT_TOUR_LABELS } from \"./tour-labels\";\nimport type { TourInfo } from \"./tour-info\";\nimport { completeStored, rememberAccount, rememberMigrate, type UseTourProgressOptions } from \"./use-tour-progress\";\nimport { createGateRegistry, devWarnings, TourInternalContext, type GateRegistry } from \"./tour-gates\";\nimport { DOCK_MAX_WIDTH, dockEdge, dockStyle, readBand, scrollIntoFreeHalf, type DockEdge } from \"./tour-dock\";\n\nexport { useTourGate, useTourGateRelease } from \"./tour-gates\";\nexport type { TourGateRelease } from \"./tour-gates\";\n\n/**\n * `start`/`end` follow the reading direction (`end` is the right side in LTR and the\n * left side in RTL) and are what a translated app wants. `left`/`right` stay physical\n * for the steps that genuinely mean a screen side.\n */\nexport type TourPlacement = \"top\" | \"right\" | \"bottom\" | \"left\" | \"start\" | \"end\" | \"center\" | \"dock\";\n\nexport interface TourStep {\n /** CSS selector for the element to spotlight. Omit for a centered step\n * (welcome/finish). If the target isn't found/visible, the step centers. */\n target?: string;\n title: string;\n body: ReactNode;\n /** Extra footer content, e.g. a \"load sample data\" shortcut. */\n action?: ReactNode;\n /** Spotlight padding around the target, px (default 8). On a field step the spot also\n * takes in the lines the field's `aria-describedby` names when they sit within the\n * ring's reach of it (a hint or warning line under the field, keksdose S1, §11.6). */\n padding?: number;\n /** Where the card sits relative to the target. Omit for auto placement\n * (below → above → centered). \"center\" ignores the target and centers on\n * screen. \"start\"/\"end\" are the logical sides and flip in RTL; \"left\"/\"right\"\n * are physical. An explicit side flips to the opposite side if it would\n * overflow, then clamps into the viewport.\n *\n * `\"dock\"` (0.50, §11.7): below `sm` (640 px) the card is pinned full-width to the top\n * or bottom edge of the usable band — the visual viewport less the keyboard and any\n * `[data-tour-obstruction]` (the number pad) — on the edge away from the field, and the\n * field's scroll container brings it into the other half. From `sm` up it is auto\n * placement. On a phone a field step (`interactive`, `awaitInput`, `gate`, `awaitGate`)\n * with a target and no `placement` docks by default (`TourProvider dockOnPhones`). */\n placement?: TourPlacement;\n /** Advance only when the user clicks the spotlighted target itself (not the\n * card's Next button). Requires `target`: the real control's own handler runs\n * first, then the tour steps forward on a microtask. The spotlight hole stays\n * click-through to the target; the rest of the page does not. */\n awaitClick?: boolean;\n /**\n * The spotlighted control is for USING, not only for looking at (0.46, keksdose live\n * #436): the layers it opens sit above the scrim and work. A plain step's overlay is\n * `z-[60]`, over every kit layer, so a field whose number pad (`NumberPadSheet`), a\n * select's menu or a popover opens at `z-50` opened UNDER the shields, where nothing\n * could be tapped. Here the overlay drops to `z-[45]`: still over the top bar and the\n * page (`z-40` and below, still dimmed and shielded), under every `z-50` layer the\n * target opens — so an app's own layer wants `z-50` or more to clear it. Keys pressed\n * in the target or in such a layer are theirs (Escape closes the pad, arrows walk a\n * list); from the card the tour's keys work as on any step. The overlay is not\n * `aria-modal` then, and carries `data-tour-interactive`.\n *\n * The card is in the same layer as the scrim, so an open pad or sheet may cover it\n * until it closes. Requires `target`. A `HoverMenu` (`z-40`, the top bar's menus) stays\n * under the scrim: point an `awaitClick` step at its trigger instead.\n */\n interactive?: boolean;\n /**\n * Advance once a value was ENTERED in the spotlighted control (0.46, keksdose live\n * #436) — `awaitClick` for a field. Implies `interactive`. Counted when focus leaves\n * the target (the number pad's Done, a Tab, a tap elsewhere), or Enter is pressed in\n * it, and one of its fields (`input`, `textarea`, `select`: the target itself or\n * inside it) then holds another value than when the step began; a native `change`\n * (a select, a checkbox) counts at once. The card swaps Next for `awaitInputHint`,\n * as for `awaitClick`. A picker whose value is not a field's (the kit's `Select`\n * button) has nothing to compare: call `useTour().next()` from its `onChange`.\n */\n awaitInput?: boolean;\n /**\n * 0.50 (docs/tours-harmonization.md §11.1): Next stays locked until the gate `key` is\n * satisfied — the form publishes it with `useTourGate(key, satisfied)` beside the field.\n * Implies `interactive`. The locked Next is `aria-disabled` with {@link gateHint} under\n * it; pressing it focuses the field. Once satisfied the tour does NOT advance by itself:\n * Next, Enter in the field, or focus leaving the field to nowhere or to the card (the\n * number pad's Done) moves on. A key nobody publishes is not enforced (the form closed\n * under the tour): Next opens. A step may have a `gate` and no `target`.\n */\n gate?: string;\n /** Overrides `labels.gateHint` for this step. */\n gateHint?: string;\n /**\n * 0.50 (§11.4): wait for the app to RELEASE this key — `useTourGateRelease().release(key)`\n * from the save's `onSuccess`. Implies `interactive`; usually it targets the Save button,\n * whose hole stays click-through. Next is replaced by {@link awaitGateHint}, and a click\n * does not advance: only `release` does. A release that arrives on an earlier step (Enter\n * in the last field submitted the form) jumps past the first later step awaiting the key.\n * `refuse(key, reason)` keeps the step and shows the reason, with a \"Back to …\" link to the\n * first earlier field whose gate is now unsatisfied; the kit never jumps there itself.\n * A viewer who cannot save gets `awaitGate: undefined`, so a plain Next.\n */\n awaitGate?: string;\n /** Overrides `labels.awaitGateHint` for this step. */\n awaitGateHint?: string;\n /**\n * 0.50 (§11.2): the field may stay empty. While the `gate` is unsatisfied the card\n * offers \"Leave empty\" beside the locked Next, which moves on without touching the field\n * (the kit never writes app values); the title carries an \"Optional\" chip. Not a skip:\n * the run continues and can complete. Without a `gate`, only the chip.\n */\n optional?: boolean;\n /**\n * 0.50 (§11.3): shown only if this returns true on ARRIVAL (evaluated before\n * `beforeStep`, so a skipped step never navigates). Next walks forward to the first step\n * shown, Back to the nearest earlier one shown now. Branch facts are gates:\n * `when: (c) => c.gate(\"txn.transfer\") === true`. Keep it pure and cheap: the counter\n * evaluates every step's `when` on each arrival. A throw counts as skipped.\n */\n when?: (ctx: TourStepContext) => boolean;\n /** Runs before the step is shown — e.g. navigate to a route, open a panel.\n * May be async; the step waits for it, then locates the target. Receives the\n * {@link TourStepContext} (0.50); a step entered by \"Guide me\" sees `via: \"at\"` and\n * should leave an open form alone. */\n beforeStep?: (ctx: TourStepContext) => void | Promise<void>;\n}\n\n/** What a step's `when` and `beforeStep` may ask on arrival (0.50, §11.3). */\nexport interface TourStepContext {\n /** The gate's current value: true/false, or undefined while nobody publishes it. */\n gate(key: string): boolean | undefined;\n /** How this step is being entered. */\n via: \"start\" | \"at\" | \"next\" | \"back\" | \"goto\";\n}\n\nexport interface TourLabels {\n next: string;\n back: string;\n skip: string;\n done: string;\n /** Shown in place of the Next button on an `awaitClick` step. */\n awaitClickHint: string;\n /** Shown in place of the Next button on an `awaitInput` step (0.46). */\n awaitInputHint: string;\n /** Step counter, e.g. (2, 7) => \"2 / 7\". Counts the steps the run shows (0.50). */\n step: (current: number, total: number) => string;\n /** 0.50: an `optional` gate step's button while the field is empty. */\n leaveEmpty: string;\n /** 0.50: the chip beside an `optional` step's title. */\n optional: string;\n /** 0.50: under a `gate` step's locked Next (`TourStep.gateHint` overrides it). */\n gateHint: string;\n /** 0.50: announced (screen readers only) when a gate step's field is filled. */\n gateReady: string;\n /** 0.50: in place of Next on an `awaitGate` step (`TourStep.awaitGateHint` overrides it). */\n awaitGateHint: string;\n /** 0.50: the warning when the app `refuse`s an `awaitGate` step without a reason. */\n awaitGateRefused: string;\n /** 0.50: the link to an earlier step whose field was emptied, after a refused save. */\n backToStep: (title: string) => string;\n}\n\n// Defined in ./tour-labels, which holds no component code (0.34, KS U8).\nexport { DEFAULT_TOUR_LABELS };\n\n/** 0.50 (§11.5): a step index, or the `data-tour` value of the step's anchor. */\nexport type TourAt = number | string;\n\n/** `useTour().start`, both forms: what `TourProvider` hands its `launch` as the third argument. */\nexport type TourStart = TourContextValue[\"start\"];\n\n/**\n * 0.50 (§11.5): the app's launcher — the shape `useTourUrlSync` already takes, plus `at`.\n * It builds the steps (`prepare()`, `build()`, `tour: tourInfo(def)`) and passes `at` on to\n * `start(steps, { …, at })`. Give the same function to `TourProvider launch` and to\n * `useTourUrlSync`.\n *\n * `start` is the provider's own `start` (keksdose N4), so the launcher needs no ref to a\n * component below the provider and may be defined above it. `useTourUrlSync` passes it too\n * (under a provider). A two-argument launcher that reaches `start` its own way still works.\n */\nexport type TourLauncher = (\n id: string,\n opts: { startIndex?: number; at?: TourAt },\n start: TourStart,\n) => void | Promise<unknown>;\n\ninterface StartOptions {\n /** Stable id of the tour, surfaced as `activeId` so the app can mirror it to\n * the URL (deep-link / evaluation tracking) and record completion. Defaults to\n * `tour.id`. */\n id?: string;\n /** The tour being started, as the app lists it (docs/tours-harmonization.md §9.6.1).\n * When its last step is finished, the provider records the completion in its\n * `progress` and hands this to `onComplete`. */\n tour?: TourInfo;\n /** Start at this step index instead of 0 (clamped) — for URL/deep-link resume. */\n startIndex?: number;\n /**\n * 0.50 (§11.5): start here AND make it the floor — earlier steps never run (nor their\n * `beforeStep`), Back stops here, `position`/`count` count from here, and the finish\n * records the completion as a full run does (Marcel, Q2). A number is a step index\n * (clamped); a string is the first step whose `target` contains `data-tour=\"<at>\"`\n * verbatim (unknown: 0, with a development warning). The `at` step is entered with\n * `via: \"at\"`. With `startIndex` too, `startIndex` picks the step and `at` the floor.\n */\n at?: TourAt;\n /** Fires synchronously when the tour starts (e.g. enable a mock interceptor). */\n onStart?: () => void;\n /** After the last step: runs after the provider's progress write and `onComplete`. */\n onFinish?: () => void;\n onSkip?: () => void;\n}\n\n/** What `TourProvider`'s `onComplete` learns besides the tour (§9.1, §9.6). */\nexport interface TourCompletion {\n /**\n * `true` when the completion counts anew (the first time, or the first time after the\n * tour's update, §8): the moment for the app's points toast. `false` for a replay, and\n * when the stored text is in an old shape no `migrate` reads: nothing is overwritten\n * then, and the error goes to `console.error` (keksdose B-1). `undefined` when the provider has no `progress` or the start carried no `tour`, so\n * nothing was recorded.\n */\n awarded: boolean | undefined;\n}\n\ninterface TourContextValue {\n active: boolean;\n /** Id of the running tour (from {@link StartOptions.id}), else null. */\n activeId: string | null;\n /**\n * Start a tour with the given steps — or, by id (0.50), through the provider's `launch`:\n * `start(\"create-transaction\", { at: \"txn-entry-mode\" })`. Without a `launch` the id form\n * does nothing (a development build warns).\n */\n start: {\n // The id form first: `Parameters<typeof start>` reads the LAST overload, which stays\n // the 0.49 one.\n (id: string, opts?: { at?: TourAt }): void;\n (steps: TourStep[], opts?: StartOptions): void;\n };\n /** End the current tour (no callbacks fire). */\n stop: () => void;\n /** Advance one step; past the last step it finishes the tour (fires onFinish). */\n next: () => void;\n /** Go back one step (no-op on the first). */\n prev: () => void;\n /** Jump to a step by index, clamped to range — e.g. for URL/deep-link resume. */\n goToStep: (index: number) => void;\n /** Current step (0-based; 0 while inactive). */\n index: number;\n /** Total steps (0 while inactive). */\n total: number;\n /** 0.50: 1-based position among the steps this run shows, for \"3 of 9\"; 0 while inactive. */\n position: number;\n /** 0.50: how many steps this run shows, from its first (the `at` floor) to the end; 0 while inactive. */\n count: number;\n}\n\nconst TourContext = createContext<TourContextValue | null>(null);\n\nexport function useTour(): TourContextValue {\n const ctx = useContext(TourContext);\n if (!ctx) throw new Error(\"useTour must be used within <TourProvider>\");\n return ctx;\n}\n\n/**\n * The tour engine if it is there, `null` if it is not — for a control that is a\n * DECORATION rather than a participant.\n *\n * {@link useTour}'s throw is correct and stays: a component that runs a tour cannot do\n * its job without the provider, and failing loudly is how that gets fixed. But the\n * throw's blast radius is whatever error boundary is above it, and for a launcher in\n * the app shell that is the whole app.\n *\n * Keksdose feedback dev#524 is what that costs: an `@hb/ui` module was edited while a\n * dev server was running, vite re-evaluated it, and the module's freshly created\n * context object was no longer the one the mounted provider was providing. React's\n * `useContext` then answers `null` for a provider that is, structurally, right there —\n * and the top bar's tour menu took the entire shell down with it. **Build-time module\n * graphs cannot produce that**, so it is a development-only failure; a menu that\n * disappears for a second is the proportionate response to it either way.\n *\n * Only for controls that can honestly render nothing. If a component would show a\n * broken half of itself without the tour, it wants {@link useTour}.\n */\nexport function useTourOptional(): TourContextValue | null {\n return useContext(TourContext);\n}\n\n/**\n * Provides the guided-tour engine: a dimmed spotlight overlay + step card driven\n * by a list of {@link TourStep}s. Domain-free — the app supplies the steps (copy,\n * selectors, per-step navigation, placement) and the translated {@link TourLabels}.\n * Mount once inside the router; start a tour from anywhere via {@link useTour},\n * which also exposes step control (`next`/`prev`/`goToStep`) and the current\n * `index`/`total` for URL mirroring, `awaitClick` and deep-link resume.\n *\n * **Completion in one place** (docs/tours-harmonization.md §9.6): give the provider the\n * app's `progress` (the same `{storageKey, migrate}` as `useTourProgress`) and start each\n * tour with `start(steps, {tour})`. When the last step is finished the provider writes the\n * completion ONCE, through the store every `useTourProgress` reader of the key shares\n * (never a second copy), then calls `onComplete(tour, {awarded})`, then the start's own\n * `onFinish`. A skip or `stop()` records nothing and calls neither. The app removes its\n * own `complete()` from `onFinish`, or that second write answers `false`.\n *\n * Both props are optional: without `progress` or a `tour` on the start, `onComplete`\n * still fires, with `awarded: undefined` (and `tour` as given, possibly `undefined`). A\n * new `storageKey` (an account switch on a shared PC) is followed on the next\n * completion, without a remount.\n */\nexport function TourProvider({\n children,\n labels,\n progress,\n onComplete,\n launch,\n dockOnPhones = true,\n}: {\n children: ReactNode;\n labels?: LabelOverride<TourLabels>;\n /**\n * 0.50 (§11.5): lets `start(id)` and `<TourGuideButton>` start a tour by id. Usually the\n * same function the app gives `useTourUrlSync`.\n */\n launch?: TourLauncher;\n /** The app's tour progress: the same options its `useTourProgress` readers use. */\n progress?: UseTourProgressOptions;\n /** A tour's last step was finished; see {@link TourCompletion}. */\n onComplete?: (tour: TourInfo | undefined, completion: TourCompletion) => void;\n /**\n * 0.50 (§11.7, Marcel's Q1): below `sm`, a field step with a target and no `placement`\n * docks. Default `true`; `false` makes docking strictly opt-in (`placement: \"dock\"`).\n */\n dockOnPhones?: boolean;\n}) {\n // `labels` over the provider's `tour` over English. Resolved once here and handed\n // down: the step card is portalled, but context crosses portals anyway — this is\n // simply the one place that already owned the merge.\n const merged = useKitLabels(\"tour\", DEFAULT_TOUR_LABELS, labels);\n const [steps, setSteps] = useState<TourStep[] | null>(null);\n // Where the run is: the raw index (what `?tourStep=` mirrors), how it got there, and\n // its place among the steps shown (§11.3), computed once on arrival.\n const [nav, setNav] = useState<Nav>(NO_NAV);\n const index = nav.index;\n // The app's last `refuse` on the step awaiting its key; any arrival clears it.\n const [refusal, setRefusal] = useState<Refusal | null>(null);\n const [activeId, setActiveId] = useState<string | null>(null);\n const optsRef = useRef<StartOptions>({});\n // The latest props, read at the finish: a new `storageKey` or callback needs no remount.\n const progressRef = useRef(progress);\n const onCompleteRef = useRef(onComplete);\n const launchRef = useRef(launch);\n useLayoutEffect(() => {\n progressRef.current = progress;\n onCompleteRef.current = onComplete;\n launchRef.current = launch;\n });\n // The provider's migrate becomes the key's, for readers that pass none (keksdose B-2).\n const storageKey = progress?.storageKey;\n const migrate = progress?.migrate;\n // 0.45: and its `account` (§10.3), so a finish on an account key is sent as readers' are.\n const account = progress?.account;\n useLayoutEffect(() => {\n if (storageKey !== undefined) rememberMigrate(storageKey, migrate);\n if (storageKey !== undefined) rememberAccount(storageKey, account);\n }, [storageKey, migrate, account]);\n const warnedNoTourRef = useRef(false);\n // Live mirrors so the step-control callbacks can stay stable (identity-safe for\n // consumers) while still reading the current steps/index. Synced in a layout\n // effect — after the commit, before paint and before any passive effect or event\n // can call them — rather than written during render.\n const stepsRef = useRef<TourStep[] | null>(null);\n const indexRef = useRef(0);\n useLayoutEffect(() => {\n stepsRef.current = steps;\n indexRef.current = index;\n }, [steps, index]);\n /** The run's first step: earlier steps never run, Back stops here (the `at` floor). */\n const floorRef = useRef(0);\n const active = !!steps && steps.length > 0;\n const total = steps?.length ?? 0;\n // The gate registry (§11.1): one per provider, read by the overlay while a tour runs.\n const [gates] = useState(createGateRegistry);\n useLayoutEffect(() => {\n gates.setActive(active);\n }, [gates, active]);\n const canLaunch = !!launch;\n const internals = useMemo(() => ({ gates, canLaunch }), [gates, canLaunch]);\n\n /** Is step `i` shown, asked now (§11.3)? */\n const shown = useCallback(\n (s: TourStep[], i: number, via: TourStepContext[\"via\"]) => isShown(s[i], stepContext(gates, via)),\n [gates],\n );\n /** Arrive at `i`: the counter is recomputed from every step's `when`, against the gates now. */\n const arrive = useCallback(\n (s: TourStep[], i: number, via: TourStepContext[\"via\"]) => {\n const ctx = stepContext(gates, via);\n let position = 0;\n let count = 0;\n for (let j = floorRef.current; j < s.length; j++) {\n if (j !== i && !isShown(s[j], ctx)) continue;\n count++;\n if (j <= i) position++;\n }\n indexRef.current = i;\n setRefusal(null);\n setNav({ index: i, floor: floorRef.current, via, position, count });\n },\n [gates],\n );\n /** The first step shown at or after `from`, or -1. */\n const forward = useCallback(\n (s: TourStep[], from: number, via: TourStepContext[\"via\"]) => {\n for (let j = Math.max(from, floorRef.current); j < s.length; j++) if (shown(s, j, via)) return j;\n return -1;\n },\n [shown],\n );\n /** The nearest step shown at or before `from`, not below the floor, or -1. */\n const backward = useCallback(\n (s: TourStep[], from: number, via: TourStepContext[\"via\"]) => {\n for (let j = Math.min(from, s.length - 1); j >= floorRef.current; j--) if (shown(s, j, via)) return j;\n return -1;\n },\n [shown],\n );\n\n const startSteps = useCallback(\n (s: TourStep[], opts?: StartOptions) => {\n optsRef.current = opts ?? {};\n optsRef.current.onStart?.();\n const last = Math.max(0, s.length - 1);\n floorRef.current = opts?.at === undefined ? 0 : resolveAt(s, opts.at);\n const via: TourStepContext[\"via\"] = opts?.at === undefined ? \"start\" : \"at\";\n const wanted = Math.min(Math.max(floorRef.current, opts?.startIndex ?? floorRef.current), last);\n let to = forward(s, wanted, via);\n if (to < 0) to = backward(s, wanted, via);\n // Not one step of the run is shown: there is nothing to tour.\n if (to < 0) return;\n arrive(s, to, via);\n setActiveId(opts?.id ?? opts?.tour?.id ?? null);\n setSteps(s);\n },\n [arrive, forward, backward],\n );\n // The provider's own `start`, handed to `launch` as its third argument (keksdose N4).\n const ownStartRef = useRef<TourContextValue[\"start\"] | null>(null);\n const start = useCallback(\n (what: TourStep[] | string, opts?: StartOptions | { at?: TourAt }) => {\n if (typeof what !== \"string\") {\n startSteps(what, opts as StartOptions | undefined);\n return;\n }\n const run = launchRef.current;\n if (!run) {\n if (devWarnings()) console.warn(`[ui-kit] start(\"${what}\") needs TourProvider's \\`launch\\` prop.`);\n return;\n }\n void Promise.resolve(run(what, { at: opts?.at }, ownStartRef.current!)).catch((error: unknown) =>\n console.error(error),\n );\n },\n [startSteps],\n ) as TourContextValue[\"start\"];\n useLayoutEffect(() => {\n ownStartRef.current = start;\n }, [start]);\n const stop = useCallback(() => {\n setSteps(null);\n setActiveId(null);\n }, []);\n const finish = useCallback(() => {\n // Once per tour: a second \"Done\" before the overlay unmounts records nothing more.\n if (!stepsRef.current) return;\n stepsRef.current = null;\n const { tour, onFinish } = optsRef.current;\n const store = progressRef.current;\n // Exactly one write per completion (§9.6.2), so `awarded` is what `complete(tour)` answered.\n let awarded: boolean | undefined;\n if (store && tour) {\n try {\n awarded = completeStored(store.storageKey, store.migrate, tour);\n } catch (error) {\n // A stored text no migrate reads is left as it is (keksdose B-1); the tour still ends.\n console.error(error);\n awarded = false;\n }\n } else if (store && !tour && devWarnings() && !warnedNoTourRef.current) {\n warnedNoTourRef.current = true;\n console.warn(\n \"[ui-kit] TourProvider has `progress`, but a finished tour's start carried no `tour`: \" +\n \"nothing was recorded and `awarded` is undefined. Start it with `start(steps, { tour })`.\",\n );\n }\n onCompleteRef.current?.(tour, { awarded });\n onFinish?.();\n setSteps(null);\n setActiveId(null);\n }, []);\n const skip = useCallback(() => {\n optsRef.current.onSkip?.();\n setSteps(null);\n setActiveId(null);\n }, []);\n\n // A step whose `when` is false is passed over: `goToStep` lands on the next step shown\n // after it, failing that the previous one; Next past the last shown step finishes.\n const goToStep = useCallback(\n (i: number) => {\n const s = stepsRef.current;\n if (!s || s.length === 0) return;\n const wanted = Math.min(Math.max(floorRef.current, i), s.length - 1);\n let to = forward(s, wanted, \"goto\");\n if (to < 0) to = backward(s, wanted, \"goto\");\n if (to >= 0) arrive(s, to, \"goto\");\n },\n [arrive, forward, backward],\n );\n const next = useCallback(() => {\n const s = stepsRef.current;\n if (!s || s.length === 0) return;\n const to = forward(s, indexRef.current + 1, \"next\");\n if (to < 0) finish();\n else arrive(s, to, \"next\");\n }, [arrive, forward, finish]);\n const prev = useCallback(() => {\n const s = stepsRef.current;\n if (!s) return;\n const to = backward(s, indexRef.current - 1, \"back\");\n if (to >= 0) arrive(s, to, \"back\");\n }, [arrive, backward]);\n\n // awaitGate (§11.4): `release` and `refuse` are events, heard only while a tour runs.\n useEffect(() => {\n if (!active) return;\n let seq = 0;\n return gates.listen((signal) => {\n const s = stepsRef.current;\n if (!s) return;\n const i = indexRef.current;\n if (signal.kind === \"refuse\") {\n // On any other step the form's own errors speak.\n if (s[i]?.awaitGate === signal.key) setRefusal({ step: s[i], reason: signal.reason, seq: ++seq });\n return;\n }\n // The step awaiting it, or the first later one: the record is saved, so the fields\n // between are passed over.\n const awaiting = s[i]?.awaitGate === signal.key ? i : s.findIndex((st, k) => k > i && st.awaitGate === signal.key);\n if (awaiting < 0) return;\n const to = forward(s, awaiting + 1, \"next\");\n if (to < 0) finish();\n else arrive(s, to, \"next\");\n });\n }, [active, gates, arrive, forward, finish]);\n\n return (\n <TourInternalContext.Provider value={internals}>\n <TourContext.Provider\n value={{\n active,\n activeId,\n start,\n stop,\n next,\n prev,\n goToStep,\n index,\n total,\n position: active ? nav.position : 0,\n count: active ? nav.count : 0,\n }}\n >\n {children}\n {active && (\n <TourOverlay\n steps={steps!}\n index={index}\n via={nav.via}\n floor={nav.floor}\n position={nav.position}\n count={nav.count}\n refusal={refusal?.step === steps![index] ? refusal : null}\n onGoTo={goToStep}\n labels={merged}\n gates={gates}\n dockOnPhones={dockOnPhones}\n onNext={next}\n onPrev={prev}\n onSkip={skip}\n />\n )}\n </TourContext.Provider>\n </TourInternalContext.Provider>\n );\n}\n\ninterface Nav {\n index: number;\n /** The run's first step (the `at` floor). */\n floor: number;\n via: TourStepContext[\"via\"];\n position: number;\n count: number;\n}\n\nconst NO_NAV: Nav = { index: 0, floor: 0, via: \"start\", position: 0, count: 0 };\n\n/** The app's `refuse` on the step that awaits its key (§11.4). */\ninterface Refusal {\n step: TourStep;\n reason?: string;\n /** Bumped per refusal, so the same words are announced again. */\n seq: number;\n}\n\nconst NOOP = () => {};\n\nfunction stepContext(gates: GateRegistry, via: TourStepContext[\"via\"]): TourStepContext {\n return { gate: (key) => gates.get(key), via };\n}\n\n/** `StartOptions.at` as a step index: a number clamped, an anchor's first step, else 0. */\nfunction resolveAt(steps: TourStep[], at: TourAt): number {\n if (typeof at === \"number\") return Math.min(Math.max(0, Math.floor(at)), Math.max(0, steps.length - 1));\n const anchor = `data-tour=\"${at}\"`;\n const found = steps.findIndex((step) => step.target?.includes(anchor));\n if (found >= 0) return found;\n if (devWarnings()) console.warn(`[ui-kit] A tour was started at \"${at}\", but no step targets [${anchor}]: it starts at 0.`);\n return 0;\n}\n\n/** The first step in [floor, index) shown now whose gate is published and unsatisfied, or -1. */\nfunction firstEmptied(steps: TourStep[], floor: number, index: number, gates: GateRegistry): number {\n const ctx = stepContext(gates, \"goto\");\n for (let j = floor; j < index; j++) {\n const key = steps[j].gate;\n if (key && gates.get(key) === false && isShown(steps[j], ctx)) return j;\n }\n return -1;\n}\n\n/** A step's `when`, asked now; a throw is a skip, and the error goes to the console. */\nfunction isShown(step: TourStep, ctx: TourStepContext): boolean {\n if (!step.when) return true;\n try {\n return step.when(ctx) === true;\n } catch (error) {\n console.error(error);\n return false;\n }\n}\n\ninterface Rect {\n top: number;\n left: number;\n width: number;\n height: number;\n}\n\nfunction isVisible(el: Element): boolean {\n // A non-zero box already rules out display:none on the element or any ancestor\n // (an unrendered element measures 0x0). We deliberately do NOT test\n // offsetParent: it is null for position:fixed elements even when fully visible,\n // which made the mobile bottom-nav bar (fixed) un-highlightable on mobile\n // (feedback #313). visibility:hidden keeps a box, so check it explicitly.\n const r = el.getBoundingClientRect();\n if (r.width <= 0 || r.height <= 0) return false;\n const style = getComputedStyle(el);\n return style.visibility !== \"hidden\" && style.display !== \"none\";\n}\n\n// The first VISIBLE element matching the selector, not merely the first in DOM\n// order. This lets a step target the same control across layouts with one\n// combined selector — e.g. the desktop sidebar link AND the mobile bottom-bar\n// link — where the off-layout copy is present but `display:none` (feedback\n// #313). Returns null while none is visible so the finder keeps retrying.\nfunction queryVisibleTarget(selector: string): Element | null {\n const els = document.querySelectorAll(selector);\n for (const el of els) {\n if (isVisible(el)) return el;\n }\n return null;\n}\n\nfunction rectOf(el: Element): Rect {\n const r = el.getBoundingClientRect();\n return { top: r.top, left: r.left, width: r.width, height: r.height };\n}\n\n/** The two-tone frame's width outside the spot (3px white, 2px keyline), plus a pixel. */\nconst RING_BAND = 6;\n\n/**\n * What a step's ring frames (keksdose S1, §11.6): the target, and on a FIELD step also the\n * lines that describe the field from outside it — the elements its `aria-describedby`\n * (on the target or a control inside) names that lie within the ring's reach of it (a\n * caption, a hint or warning line, an error drawn under or above the field). Without\n * them the ring's frame ran through such a line; with them it frames field and line, and\n * the line is lit, not under the scrim. A kit field's own caption and error are inside\n * its root already. A line far away (a tooltip, another part of the page) is not taken.\n */\nfunction spotRectOf(el: Element, step: TourStep): Rect {\n const own = rectOf(el);\n if (!isFieldStep(step)) return own;\n const ids = new Set<string>();\n const holders = [el, ...Array.from(el.querySelectorAll(\"[aria-describedby]\"))];\n for (const holder of holders) {\n for (const id of (holder.getAttribute(\"aria-describedby\") ?? \"\").split(/\\s+/)) if (id) ids.add(id);\n }\n if (ids.size === 0) return own;\n const lines: DOMRect[] = [];\n for (const id of ids) {\n const line = document.getElementById(id);\n if (!line || el.contains(line) || line.closest('[role=\"tooltip\"]') || !isVisible(line)) continue;\n const r = line.getBoundingClientRect();\n // An `sr-only` description measures 1×1: nothing to frame.\n if (r.width > 1 && r.height > 1) lines.push(r);\n }\n let top = own.top;\n let left = own.left;\n let right = own.left + own.width;\n let bottom = own.top + own.height;\n const reach = (step.padding ?? 8) + RING_BAND;\n // Grow until nothing more is in reach: a hint under the field, then an error under it.\n for (let grew = true; grew; ) {\n grew = false;\n for (let i = lines.length - 1; i >= 0; i--) {\n const r = lines[i];\n const across = r.left < right && r.right > left;\n const gap = Math.max(r.top - bottom, top - r.bottom);\n if (!across || gap > reach) continue;\n top = Math.min(top, r.top);\n left = Math.min(left, r.left);\n right = Math.max(right, r.right);\n bottom = Math.max(bottom, r.bottom);\n lines.splice(i, 1);\n grew = true;\n }\n }\n return { top, left, width: right - left, height: bottom - top };\n}\n\n/**\n * What the finder established for ONE step: where its target is (`null` = no target,\n * or not on the page), and the reading direction the card takes from it.\n *\n * It carries the step it was found for, and the overlay only believes it for that\n * step — which is the whole fix for keksdose's tours audit 2026-10-02, §1.0 A (\"stale\n * spotlight on the step after a spotlighted one\", 15 steps in 16 tours, desktop and\n * phone, mouse and keyboard). When step N spotlit a target and step N+1 had none (or\n * its anchor was missing), N+1 kept N's hole and parked its card beside it, so a\n * centred \"You're all set\" read as pointing at the Import & Export link; Back→Next kept\n * it for as long as anyone watched.\n *\n * The overlay used to hold `rect` and `ready` as separate states and reset them\n * DURING RENDER when the step changed. React 19 does not keep a render-phase update\n * while an earlier, lower-priority update to the same hook is still queued — it only\n * writes the result to the base state \"unless the queue is empty\" — and the follow\n * interval below queues exactly such an update every 250 ms (eagerly bailed out because\n * the rect had not moved, but left in the queue for rebasing). So the click's render\n * showed the reset, and the very next render (the finder saying \"ready\") re-based on\n * the old rect. A deep link was fine because nothing had queued anything yet.\n *\n * Keying the result to its step does not depend on any of that ordering: a rect found\n * for another step is not this step's rect, whatever the queue does with it, and a\n * missing anchor reads as \"no target\" instead of as the last thing that was lit.\n */\ninterface Located {\n index: number;\n step: TourStep;\n rect: Rect | null;\n dir: Direction;\n /**\n * A field step's own container (§11.6): inserted right after the kit layer holding the\n * target (`host.after`), or at the end of <body> on the page. `null` on a plain step,\n * which is portalled to <body> at z-[60] as ever.\n */\n layer: HTMLElement | null;\n /** The host fills the visual viewport (a phone's FullBleedDialog): no scrim, no shields. */\n fullScreen: boolean;\n}\n\n/** The kit layer (`data-kit-layer`) holding `el`, if any. */\nfunction layerHost(el: Element): HTMLElement | null {\n return el.closest<HTMLElement>(\"[data-kit-layer]\");\n}\n\n/**\n * Does the host fill the visual viewport? A backdrop host (`data-kit-layer=\"backdrop\"`:\n * Modal, FullBleedDialog) is judged by its panel, the child holding the target.\n */\nfunction coversViewport(host: HTMLElement, el: Element): boolean {\n let surface: Element = host;\n if (host.getAttribute(\"data-kit-layer\") === \"backdrop\") {\n for (const child of Array.from(host.children)) {\n if (child.contains(el)) {\n surface = child;\n break;\n }\n }\n }\n const r = surface.getBoundingClientRect();\n const vv = window.visualViewport;\n const top = vv?.offsetTop ?? 0;\n const bottom = top + (vv?.height ?? window.innerHeight);\n const width = vv?.width ?? window.innerWidth;\n return r.width > 0 && r.left <= 1 && r.top <= top + 1 && r.right >= width - 1 && r.bottom >= bottom - 1;\n}\n\n/** Does this step's card dock now (§11.7)? A phone-width viewport, and `\"dock\"` or a field\n * step with no placement while the provider docks on phones. */\nfunction docks(step: TourStep, dockOnPhones: boolean): boolean {\n if (typeof window === \"undefined\" || window.innerWidth >= DOCK_MAX_WIDTH || !step.target) return false;\n return step.placement === \"dock\" || (step.placement === undefined && dockOnPhones && isFieldStep(step));\n}\n\n/** A step whose control is for using: its card joins the layer stack above the field (§11.6). */\nfunction isFieldStep(step: TourStep): boolean {\n return !!(step.interactive || step.awaitInput || step.gate || step.awaitGate);\n}\n\n/** The first control in `el` (or `el` itself) a person would type into or press. */\nfunction firstFocusable(el: Element): HTMLElement | null {\n if (el instanceof HTMLElement && el.matches(FOCUSABLE_CONTROL)) return el;\n return el.querySelector<HTMLElement>(FOCUSABLE_CONTROL);\n}\n\n/** The tab stops inside `el`, in DOM order (the focus trap's selector). */\nfunction tabStops(el: Element): HTMLElement[] {\n const all = el.matches(FOCUSABLE_CONTROL) ? [el as HTMLElement] : [];\n return all.concat(\n Array.from(el.querySelectorAll<HTMLElement>(FOCUSABLE_CONTROL)).filter(\n (x) => x.tabIndex >= 0 && !x.closest(\"[hidden],[inert]\"),\n ),\n );\n}\n\nconst FOCUSABLE_CONTROL =\n 'a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex=\"-1\"])';\n\n/** A touch screen: the card takes focus, so no keyboard or pad opens before the step is read (§11.8). */\nfunction coarsePointer(): boolean {\n return typeof window !== \"undefined\" && typeof window.matchMedia === \"function\"\n ? window.matchMedia(\"(pointer: coarse)\").matches\n : false;\n}\n\nfunction TourOverlay({\n steps,\n index,\n via,\n floor,\n position,\n count,\n refusal,\n onGoTo,\n labels,\n gates,\n dockOnPhones,\n onNext,\n onPrev,\n onSkip,\n}: {\n steps: TourStep[];\n index: number;\n via: TourStepContext[\"via\"];\n floor: number;\n /** The app refused this step's save (§11.4). */\n refusal: Refusal | null;\n onGoTo: (index: number) => void;\n /** 1-based among the steps shown; Back is hidden on the first, Done on the last. */\n position: number;\n count: number;\n labels: TourLabels;\n gates: GateRegistry;\n dockOnPhones: boolean;\n onNext: () => void;\n onPrev: () => void;\n onSkip: () => void;\n}) {\n const step = steps[index];\n const isFirst = position <= 1;\n const isLast = position >= count;\n // A new step starts unlocated: whatever was found for another step (see `Located`)\n // is ignored, so the overlay renders nothing until the effect below has located THIS\n // step, and never the previous step's spotlight.\n const [located, setLocated] = useState<Located | null>(null);\n const current = located !== null && located.index === index && located.step === step ? located : null;\n const ready = current !== null;\n const rect = current?.rect ?? null;\n // The overlay is portalled to <body>, out of whatever `dir` subtree the app set, so it\n // takes the direction of the element it spotlights (the document's for a centered\n // step). Arrow keys and start/end placement read it.\n const dir: Direction = current?.dir ?? \"ltr\";\n const rootRef = useRef<HTMLDivElement>(null);\n const cardRef = useRef<HTMLDivElement>(null);\n const bodyId = useId();\n const hintId = useId();\n\n // The gate (§11.1). Re-rendered on every registry change while the tour runs.\n const gateVersion = useSyncExternalStore(gates.subscribe, gates.version, gates.version);\n const gateKey = step.gate;\n const enforced = !!gateKey && gates.has(gateKey);\n const locked = enforced && gates.get(gateKey) !== true;\n\n // The polite live region (§11.8): `gateReady` once a gate opens, the hint on a locked\n // Next. A repeat of the same words gets a trailing zero-width space so it is read again.\n const [polite, setPolite] = useState(\"\");\n const announce = useCallback((text: string) => {\n setPolite((prev) => (prev === text ? `${text}\\u200b` : text));\n }, []);\n\n // Run beforeStep, then locate the target (retrying across route/render lag).\n useEffect(() => {\n let cancelled = false;\n let raf = 0;\n // `null` = untargeted, or the finder gave up → the card centres, with no hole.\n const settle = (el: Element | null) => {\n let layer: HTMLElement | null = null;\n let fullScreen = false;\n if (el && isFieldStep(step)) {\n // §11.6: directly above the layer holding the field — DOM order decides between\n // the kit's z-50 body children, so this paints over the host and everything opened\n // before it, and under whatever the field opens next (a list, the number pad).\n const host = layerHost(el);\n layer = document.createElement(\"div\");\n layer.setAttribute(\"data-tour-layer\", \"\");\n if (host) host.after(layer);\n else document.body.appendChild(layer);\n fullScreen = !!host && coversViewport(host, el);\n }\n setLocated({ index, step, rect: el ? spotRectOf(el, step) : null, dir: dirOf(el), layer, fullScreen });\n };\n void (async () => {\n await step.beforeStep?.(stepContext(gates, via));\n if (cancelled) return;\n if (!step.target) {\n settle(null);\n return;\n }\n let tries = 0;\n const find = () => {\n if (cancelled) return;\n const el = queryVisibleTarget(step.target!);\n if (el) {\n // A docked step scrolls the field into the half the card leaves free, through\n // the field's own scroll container (§11.7); any other centres it, as ever.\n if (docks(step, dockOnPhones)) scrollIntoFreeHalf(el, null, null);\n else el.scrollIntoView({ block: \"center\", behavior: \"smooth\" });\n settle(el);\n return;\n }\n if (tries++ < 45) raf = requestAnimationFrame(find);\n else settle(null); // give up → render centered\n };\n find();\n })();\n return () => {\n cancelled = true;\n cancelAnimationFrame(raf);\n };\n // `via` and the gates are read at arrival, not followed.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [index, step]);\n\n // Follow the target as the page scrolls / reflows — only once THIS step is located,\n // and only into this step's result.\n useEffect(() => {\n if (!step.target) return;\n const update = () => {\n const el = queryVisibleTarget(step.target!);\n if (el) {\n const next = spotRectOf(el, step);\n // A sheet that grows to full screen (or shrinks from it) takes or drops the scrim.\n const host = layerHost(el);\n const full = !!host && coversViewport(host, el);\n setLocated((prev) => {\n if (!prev || prev.index !== index || prev.step !== step) return prev;\n const fullScreen = prev.layer ? full : prev.fullScreen;\n if (sameRect(prev.rect, next) && fullScreen === prev.fullScreen) return prev;\n return { ...prev, rect: next, fullScreen };\n });\n }\n };\n window.addEventListener(\"scroll\", update, true);\n window.addEventListener(\"resize\", update);\n const id = window.setInterval(update, 250);\n return () => {\n window.removeEventListener(\"scroll\", update, true);\n window.removeEventListener(\"resize\", update);\n clearInterval(id);\n };\n }, [index, step]);\n\n // A field step's container goes with the step (and with the tour).\n const layer = located?.layer ?? null;\n useEffect(() => {\n if (!layer) return;\n return () => layer.remove();\n }, [layer]);\n\n // Escape (§11.6.4): the tour is a layer on the kit's Escape stack, pushed on each\n // arrival, so it sits above the sheet holding the form. Escape from the card skips the\n // tour and no longer also closes that sheet; a layer the field opens afterwards (a\n // list, the pad) is above the tour and takes Escape first. An Escape pressed in the\n // field itself belongs to the field: the tour lets it pass by doing nothing.\n useDismissLayer(\n ready,\n (e) => {\n if (fieldStepNow && step.target && e.target instanceof Node) {\n const el = queryVisibleTarget(step.target);\n if (el?.contains(e.target)) return;\n }\n onSkip();\n },\n // Not an overlay to `useOverlayOpen`: a floating launcher a tour spotlights stays.\n { overlay: false },\n );\n\n // awaitClick: advance when the *real* target is clicked. The spotlight hole is\n // click-through (see the shields in the render below) so the element's own\n // handler runs first; we step forward on the next macrotask.\n //\n // Re-armed when the target turns up after the finder gave up (the follow effect\n // lights it late): the card swaps Next for the \"click the highlighted element\" hint\n // as soon as there is a rect, so the click must work from that moment too.\n const spotted = rect !== null;\n useEffect(() => {\n if (!ready || !spotted || !step.awaitClick || !step.target) return;\n const el = queryVisibleTarget(step.target);\n if (!el) return;\n const onClick = () => window.setTimeout(() => onNext(), 0);\n el.addEventListener(\"click\", onClick, { once: true });\n return () => el.removeEventListener(\"click\", onClick);\n }, [ready, spotted, index, step, onNext]);\n\n // A field step (see `TourStep.interactive`): only while the target is lit — a step\n // whose target is missing centres its card over a full scrim, modal as ever.\n const interactive =\n spotted && !!step.target && !!(step.interactive || step.awaitInput || step.gate || step.awaitGate);\n // A GUIDED field step (§11.8): focus goes to the field on a fine pointer, and Tab\n // cycles field + card. A plain `interactive` step keeps the card's own trap.\n const guided = interactive && !!(step.gate || step.awaitInput || step.awaitGate);\n const fieldStepNow = interactive;\n // An awaitGate step whose target is lit: only `release` moves it (a missing Save\n // button would otherwise be a dead end, as for awaitClick).\n const awaitsRelease = spotted && !!step.target && !!step.awaitGate;\n\n // A gate nobody publishes is not enforced: Next opens, and a development build says why\n // (on arrival, or when its publisher unmounts under the step), once per step.\n const warnedGateRef = useRef<TourStep | null>(null);\n useEffect(() => {\n if (!ready || !gateKey || gates.has(gateKey) || !devWarnings() || warnedGateRef.current === step) return;\n warnedGateRef.current = step;\n console.warn(\n `[ui-kit] Tour step \"${step.title}\" waits for the gate \"${gateKey}\", which nothing publishes: its Next is open. ` +\n \"Publish it with useTourGate beside the field, or the form has closed under the tour.\",\n );\n }, [ready, gateKey, gates, step, gateVersion]);\n\n // `optional` means \"may stay EMPTY\": without a gate there is no value to compare.\n useEffect(() => {\n if (!ready || !step.optional || step.gate || !devWarnings()) return;\n console.warn(\n `[ui-kit] Tour step \"${step.title}\" is \\`optional\\` without a \\`gate\\`: it shows the Optional chip ` +\n \"and a plain Next. \\\"Leave empty\\\" needs a gate to compare.\",\n );\n }, [ready, step]);\n\n // \"Ready\" once, when this step's gate turns satisfied (not when it arrives satisfied).\n const wasLockedRef = useRef<{ step: TourStep; locked: boolean } | null>(null);\n useEffect(() => {\n if (!ready || !gateKey) return;\n const before = wasLockedRef.current;\n if (before && before.step === step && before.locked && !locked && enforced) announce(labels.gateReady);\n wasLockedRef.current = { step, locked };\n }, [ready, gateKey, step, locked, enforced, announce, labels.gateReady]);\n\n // Arrival on a guided step: the field takes focus on a fine pointer, the card on a\n // coarse one; the field is described by the card's body while the step lasts.\n // Declared BEFORE the advance listeners below, so the focus it moves is not mistaken\n // for the person leaving the field.\n useEffect(() => {\n if (!ready || !guided || !step.target) return;\n const el = queryVisibleTarget(step.target);\n const control = el ? firstFocusable(el) : null;\n if (coarsePointer() || !control) cardRef.current?.focus();\n else if (!el!.contains(document.activeElement)) control.focus();\n if (!control) return;\n const previous = control.getAttribute(\"aria-describedby\");\n control.setAttribute(\"aria-describedby\", previous ? `${previous} ${bodyId}` : bodyId);\n return () => {\n if (previous === null) control.removeAttribute(\"aria-describedby\");\n else control.setAttribute(\"aria-describedby\", previous);\n };\n }, [ready, guided, index, step, bodyId]);\n\n // Tab on a guided step cycles field + card as one ring (§11.8): from the field's last\n // stop to the card's first, from the card's last back to the field. Captured on the\n // document, ahead of a sheet's own trap, which would wrap inside the sheet.\n useEffect(() => {\n if (!ready || !guided || !step.target) return;\n const onTab = (e: KeyboardEvent) => {\n if (e.key !== \"Tab\") return;\n const el = queryVisibleTarget(step.target!);\n const card = cardRef.current;\n if (!el || !card) return;\n const active = document.activeElement;\n const fieldStops = tabStops(el);\n const cardStops = tabStops(card);\n if (fieldStops.length === 0 || cardStops.length === 0) return;\n let to: HTMLElement | null = null;\n if (active instanceof Node && el.contains(active)) {\n if (!e.shiftKey && active === fieldStops[fieldStops.length - 1]) to = cardStops[0];\n else if (e.shiftKey && active === fieldStops[0]) to = cardStops[cardStops.length - 1];\n } else if (active instanceof Node && card.contains(active)) {\n if (!e.shiftKey && active === cardStops[cardStops.length - 1]) to = fieldStops[0];\n else if (e.shiftKey && (active === cardStops[0] || active === card)) to = fieldStops[fieldStops.length - 1];\n }\n if (!to) return;\n e.preventDefault();\n e.stopPropagation();\n to.focus();\n };\n document.addEventListener(\"keydown\", onTab, true);\n return () => document.removeEventListener(\"keydown\", onTab, true);\n }, [ready, guided, index, step]);\n\n // gate: once satisfied, advance on Enter in the field (unless the control took it, or\n // a textarea without Ctrl/Cmd) or on focus leaving the field to nowhere or to the card.\n // Checked on the next macrotask, after the field's own blur/Enter commit has rendered.\n useEffect(() => {\n if (!ready || !spotted || !gateKey || !step.target) return;\n const el = queryVisibleTarget(step.target) as HTMLElement | null;\n if (!el) return;\n const satisfied = () => !gates.has(gateKey) || gates.get(gateKey) === true;\n let timer = 0;\n // Focus that was in the field when the step settled, or went there since. A focus\n // move the tour made itself (the card taking it on a phone) is not a leave.\n let armed = el.contains(document.activeElement);\n const check = () => {\n window.clearTimeout(timer);\n timer = window.setTimeout(() => {\n if (satisfied()) onNext();\n }, 0);\n };\n const onFocusIn = () => {\n armed = true;\n };\n const onFocusOut = (e: FocusEvent) => {\n const to = e.relatedTarget;\n if (to instanceof Node && el.contains(to)) return;\n const wasArmed = armed;\n armed = false;\n if (!wasArmed) return;\n if (to === null || (to instanceof Node && rootRef.current?.contains(to))) check();\n };\n const onKeyDown = (e: KeyboardEvent) => {\n if (e.key !== \"Enter\" || !(e.target instanceof Node) || !el.contains(e.target)) return;\n // Heard at the document, after React's handlers: a combobox picking an option has\n // called preventDefault by now.\n if (e.defaultPrevented || isComposing(e)) return;\n if (e.target instanceof HTMLTextAreaElement && !(e.ctrlKey || e.metaKey)) return;\n check();\n };\n el.addEventListener(\"focusin\", onFocusIn);\n el.addEventListener(\"focusout\", onFocusOut);\n document.addEventListener(\"keydown\", onKeyDown);\n return () => {\n window.clearTimeout(timer);\n el.removeEventListener(\"focusin\", onFocusIn);\n el.removeEventListener(\"focusout\", onFocusOut);\n document.removeEventListener(\"keydown\", onKeyDown);\n };\n }, [ready, spotted, gateKey, gates, index, step, onNext]);\n\n // awaitInput: advance once the target's fields hold another value than when the step\n // was armed, checked when focus leaves the target or Enter is pressed in it — on the\n // next macrotask, after the field's own blur/Enter commit has rendered. A value the\n // number pad typed fires no native `change`, so comparing is what catches it.\n useEffect(() => {\n if (!ready || !spotted || !step.awaitInput || !step.target) return;\n const el = queryVisibleTarget(step.target) as HTMLElement | null;\n if (!el) return;\n const read = () => fieldValues(el);\n const before = read();\n let timer = 0;\n let done = false;\n const check = () => {\n window.clearTimeout(timer);\n timer = window.setTimeout(() => {\n if (done || read() === before) return;\n done = true;\n onNext();\n }, 0);\n };\n const onFocusOut = (e: FocusEvent) => {\n if (e.relatedTarget instanceof Node && el.contains(e.relatedTarget)) return;\n check();\n };\n const onKeyDown = (e: KeyboardEvent) => {\n if (e.key === \"Enter\") check();\n };\n el.addEventListener(\"focusout\", onFocusOut);\n el.addEventListener(\"keydown\", onKeyDown);\n el.addEventListener(\"change\", check);\n return () => {\n window.clearTimeout(timer);\n el.removeEventListener(\"focusout\", onFocusOut);\n el.removeEventListener(\"keydown\", onKeyDown);\n el.removeEventListener(\"change\", check);\n };\n }, [ready, spotted, index, step, onNext]);\n\n /** A press on the locked Next (or Enter / → from the card): no move; the field takes\n * focus and the hint is read again. */\n const gateHint = step.gateHint ?? labels.gateHint;\n const lockedNext = useCallback(() => {\n const el = step.target ? queryVisibleTarget(step.target) : null;\n const control = el ? firstFocusable(el) : null;\n control?.focus();\n announce(gateHint);\n }, [step.target, announce, gateHint]);\n const tryNext = awaitsRelease ? NOOP : locked ? lockedNext : onNext;\n\n // After a refused save: the first earlier step shown whose field is now empty (§11.4).\n // Computed each render, which the gate subscription above triggers: a field filled\n // again drops the link.\n const backTo = refusal ? firstEmptied(steps, floor, index, gates) : -1;\n\n // Keyboard: Esc skips, Enter and the reading-direction arrow advance (→ in LTR,\n // ← in RTL), the other arrow goes back. On awaitClick steps Enter is ignored (it\n // would fire the target's click AND advance) — the forward arrow stays as an escape\n // hatch. On a locked gate step both are the locked Next.\n //\n // Enter on a focused control belongs to that control. This used to advance from\n // anywhere, so Enter on a focused Skip or Back ran the button's own click AND stepped\n // forward: Back moved nowhere, Skip skipped and then called `next` on a dead tour.\n // The same goes for arrows in a text field a step's `action` might contain.\n useEffect(() => {\n const onKey = (e: KeyboardEvent) => {\n // On an interactive step a key pressed in the target, or in a layer it opened (the\n // number pad's Escape, a menu's arrows), is the page's. The card's and the bare\n // page's (focus on <body>) stay the tour's.\n if (interactive && e.target instanceof Node && e.target !== document.body && !rootRef.current?.contains(e.target)) {\n return;\n }\n // Escape is the tour's Escape layer's (above) once the step is shown; while it is\n // still being located there is no layer yet, and the tour takes it here as in 0.49.\n if (e.key === \"Escape\") {\n if (!ready) onSkip();\n return;\n }\n if (e.key === \"Enter\") {\n if (step.awaitClick || step.awaitInput || ownsKey(e.target, \"Enter\")) return;\n e.preventDefault();\n tryNext();\n return;\n }\n if (ownsKey(e.target, e.key)) return;\n // The overlay root carries `dir`; before it paints, the document's answers.\n const delta = horizontalStep(e.key, rootRef.current);\n if (delta === 1) {\n e.preventDefault();\n tryNext();\n } else if (delta === -1) {\n if (!isFirst) onPrev();\n }\n };\n document.addEventListener(\"keydown\", onKey);\n return () => document.removeEventListener(\"keydown\", onKey);\n }, [isFirst, step, interactive, tryNext, onPrev, onSkip, ready]);\n\n if (!ready) return null;\n\n // No scrim, no shields: a field step inside a layer that fills the screen (§11.6.3).\n const bare = interactive && !!current?.fullScreen;\n const pad = step.padding ?? 8;\n const spot: Rect | null = rect\n ? { top: rect.top - pad, left: rect.left - pad, width: rect.width + pad * 2, height: rect.height + pad * 2 }\n : null;\n\n // `aria-modal` promises the page behind is out of reach, and the card's focus trap\n // keeps that promise for the keyboard. The pointer used to get no such treatment: the\n // root is `pointer-events-none` so that the spotlight hole can stay live for\n // `awaitClick`, and the scrim is a box-shadow, which takes no clicks — so every\n // control on the dimmed page stayed clickable. Four shields now tile the viewport\n // around the hole: the page is blocked, the card and the spotlighted target are not.\n // Keeping `aria-modal` (rather than dropping it) is the coherent half: the tour\n // really is modal — focus is trapped and Esc/Skip is the way out.\n return createPortal(\n <div\n ref={rootRef}\n // z-50 on a field step, in its own container right after the layer holding the field\n // (or at the end of <body>): over that layer and the page, under the z-50 layers the\n // field opens next (§11.6). z-[60] on a plain step, over everything.\n className={cn(\"pointer-events-none fixed inset-0\", interactive ? \"z-50\" : \"z-[60]\")}\n role=\"dialog\"\n aria-modal={interactive ? undefined : \"true\"}\n // A stable marker for the overlay, on every step (0.48, keksdose dev#611–613): an\n // app that hides its floating help launcher while a modal is open excepts the\n // tour, which may spotlight that launcher — `[aria-modal=\"true\"]:not([data-tour-overlay])`.\n // keksdose matched the `pointer-events-none` class until now, which is the kit's to change.\n data-tour-overlay=\"\"\n data-tour-interactive={interactive ? \"\" : undefined}\n data-tour-bare={bare ? \"\" : undefined}\n aria-label={step.title}\n dir={dir}\n >\n {/* In a full-screen layer (a phone's form sheet) no scrim and no shields: the rest of\n the form stays usable and scrollable, and the ring alone marks the field. */}\n {spot && !bare && <SpotlightShields spot={spot} />}\n {spot ? (\n <div\n className=\"pointer-events-none fixed rounded-lg transition-all duration-200 ease-out\"\n style={{\n top: spot.top,\n left: spot.left,\n width: spot.width,\n height: spot.height,\n // A two-tone frame, not a single translucent ring.\n //\n // The old treatment was `ring-2 ring-white/80` over a 55% scrim, and it\n // \"was barely visible\" on the app's blue-tinted surfaces. Two reasons,\n // and a single ring can't fix either: at 55% the surround stays bright\n // enough that the un-dimmed hole barely reads AS a hole, and a 80%-white\n // ring sitting on the edge of a light card is white-on-near-white.\n //\n // So: an opaque white band immediately around the target, a dark keyline\n // outside it, then the scrim. Whatever the target's own colour is, one of\n // the two bands is always in contrast with it and the other is always in\n // contrast with the dimmed surround — there is no background that can\n // swallow both. The blurred layer between them softens the step so the\n // frame reads as lighting rather than as a pasted-on rectangle.\n boxShadow: [\n \"0 0 0 3px rgba(255,255,255,0.98)\",\n \"0 0 0 5px rgba(15,23,42,0.92)\",\n \"0 0 18px 6px rgba(15,23,42,0.45)\",\n ...(bare ? [] : [\"0 0 0 9999px rgba(15,23,42,0.70)\"]),\n ].join(\", \"),\n }}\n />\n ) : (\n <div className=\"pointer-events-auto fixed inset-0 bg-black/70\" />\n )}\n <TourCard\n cardRef={cardRef}\n step={step}\n index={index}\n position={position}\n total={count}\n labels={labels}\n isFirst={isFirst}\n isLast={isLast}\n rect={spot}\n dir={dir}\n trap={!guided}\n bodyId={bodyId}\n hintId={hintId}\n locked={locked}\n gateHint={gateHint}\n onBack={onPrev}\n onNext={tryNext}\n onLeaveEmpty={onNext}\n onSkip={onSkip}\n awaitsRelease={awaitsRelease}\n docked={spot !== null && docks(step, dockOnPhones)}\n refusal={refusal}\n backTo={backTo >= 0 ? { title: steps[backTo].title, go: () => onGoTo(backTo) } : null}\n />\n <div className=\"sr-only\" aria-live=\"polite\" aria-atomic=\"true\">\n {polite}\n </div>\n </div>,\n (interactive && current?.layer) || document.body,\n );\n}\n\n/** The values of the fields at or inside `el`, as one string to compare (`awaitInput`). */\nfunction fieldValues(el: Element): string {\n const fields = el.matches(\"input,textarea,select\") ? [el] : Array.from(el.querySelectorAll(\"input,textarea,select\"));\n return fields\n .map((f) =>\n f instanceof HTMLInputElement && (f.type === \"checkbox\" || f.type === \"radio\")\n ? String(f.checked)\n : (f as HTMLInputElement).value,\n )\n .join(\"\\u0000\");\n}\n\n/** Does the focused element handle `key` itself? Enter on a button or link, and any\n * editing key in a text field or select, is the control's — not the tour's. */\nfunction ownsKey(target: EventTarget | null, key: string): boolean {\n if (!(target instanceof HTMLElement)) return false;\n if (target.isContentEditable) return true;\n const tag = target.tagName;\n if (tag === \"TEXTAREA\" || tag === \"SELECT\") return true;\n if (tag === \"INPUT\") {\n const type = (target as HTMLInputElement).type;\n // Enter on a checkbox does nothing natively, but ←/→ on a radio moves it.\n return key !== \"Enter\" || type !== \"checkbox\";\n }\n if (key !== \"Enter\") return false;\n return (\n tag === \"BUTTON\" ||\n (tag === \"A\" && target.hasAttribute(\"href\")) ||\n target.getAttribute(\"role\") === \"button\" ||\n target.getAttribute(\"role\") === \"link\"\n );\n}\n\n/**\n * Transparent pointer blockers tiling the viewport around the spotlight hole: one\n * full-width band above and below, one on each side at the hole's own height. The hole\n * itself stays uncovered, so the target keeps its clicks.\n */\nfunction SpotlightShields({ spot }: { spot: Rect }) {\n const shield = \"pointer-events-auto fixed\";\n const bottom = spot.top + spot.height;\n return (\n <>\n <div data-tour-shield=\"\" className={shield} style={{ top: 0, left: 0, right: 0, height: Math.max(0, spot.top) }} />\n <div data-tour-shield=\"\" className={shield} style={{ top: bottom, left: 0, right: 0, bottom: 0 }} />\n <div\n data-tour-shield=\"\"\n className={shield}\n style={{ top: spot.top, left: 0, width: Math.max(0, spot.left), height: spot.height }}\n />\n <div\n data-tour-shield=\"\"\n className={shield}\n style={{ top: spot.top, left: spot.left + spot.width, right: 0, height: spot.height }}\n />\n </>\n );\n}\n\n/**\n * Card position (viewport px) for the given placement relative to the padded\n * spotlight `rect`. Omitted placement keeps the original auto behavior\n * (below → above → vertically centered); an explicit side flips to its opposite\n * if it would overflow, then clamps into the viewport. \"center\" (or no rect)\n * centers on screen.\n */\nfunction placeCard(\n rect: Rect | null,\n cw: number,\n ch: number,\n vw: number,\n vh: number,\n m: number,\n placement?: TourPlacement,\n dir: Direction = \"ltr\",\n): { top: number; left: number } {\n // The logical sides resolve to a physical one here, and only here.\n if (placement === \"start\") placement = dir === \"rtl\" ? \"right\" : \"left\";\n else if (placement === \"end\") placement = dir === \"rtl\" ? \"left\" : \"right\";\n if (!rect || placement === \"center\") {\n return { top: Math.max(m, (vh - ch) / 2), left: Math.max(m, (vw - cw) / 2) };\n }\n const clampX = (x: number) => Math.min(Math.max(m, x), Math.max(m, vw - cw - m));\n const clampY = (y: number) => Math.min(Math.max(m, y), Math.max(m, vh - ch - m));\n const centerX = clampX(rect.left + rect.width / 2 - cw / 2);\n const centerY = clampY(rect.top + rect.height / 2 - ch / 2);\n const belowTop = rect.top + rect.height + m;\n const aboveTop = rect.top - ch - m;\n const rightLeft = rect.left + rect.width + m;\n const leftLeft = rect.left - cw - m;\n const fitsBelow = belowTop + ch <= vh;\n const fitsAbove = aboveTop >= 0;\n const fitsRight = rightLeft + cw <= vw;\n const fitsLeft = leftLeft >= 0;\n\n switch (placement) {\n case \"top\":\n return { top: fitsAbove ? aboveTop : fitsBelow ? belowTop : clampY(aboveTop), left: centerX };\n case \"bottom\":\n return { top: fitsBelow ? belowTop : fitsAbove ? aboveTop : clampY(belowTop), left: centerX };\n case \"right\":\n return { top: centerY, left: fitsRight ? rightLeft : fitsLeft ? leftLeft : clampX(rightLeft) };\n case \"left\":\n return { top: centerY, left: fitsLeft ? leftLeft : fitsRight ? rightLeft : clampX(leftLeft) };\n default:\n if (fitsBelow) return { top: belowTop, left: centerX };\n if (fitsAbove) return { top: aboveTop, left: centerX };\n return { top: Math.max(m, (vh - ch) / 2), left: centerX };\n }\n}\n\nfunction TourCard({\n cardRef: ref,\n step,\n index,\n position,\n total,\n labels,\n isFirst,\n isLast,\n rect,\n dir,\n trap,\n bodyId,\n hintId,\n locked,\n gateHint,\n onBack,\n onNext,\n onLeaveEmpty,\n onSkip,\n awaitsRelease,\n docked,\n refusal,\n backTo,\n}: {\n cardRef: RefObject<HTMLDivElement | null>;\n step: TourStep;\n index: number;\n /** 1-based among the steps shown (§11.3). */\n position: number;\n /** How many steps the run shows. */\n total: number;\n labels: TourLabels;\n isFirst: boolean;\n isLast: boolean;\n rect: Rect | null;\n dir: Direction;\n /** The card's own focus trap; off on a guided step, where field + card are one ring. */\n trap: boolean;\n bodyId: string;\n hintId: string;\n /** A gate step whose field is not filled yet (§11.1). */\n locked: boolean;\n gateHint: string;\n onBack: () => void;\n onNext: () => void;\n /** Moves on past an `optional` field left empty. */\n onLeaveEmpty: () => void;\n onSkip: () => void;\n /** An awaitGate step with its target lit: the hint in place of Next. */\n awaitsRelease: boolean;\n /** Pinned to the band's edge away from the field (§11.7). */\n docked: boolean;\n refusal: Refusal | null;\n /** The \"Back to …\" link after a refused save. */\n backTo: { title: string; go: () => void } | null;\n}) {\n const [style, setStyle] = useState<CSSProperties>({ opacity: 0 });\n\n /**\n * The card holds the focus, because the card is what the tour IS.\n *\n * The overlay above declares `role=\"dialog\" aria-modal=\"true\"` — it always has — and\n * then left focus wherever the page had put it. For a tour that is the most pointed\n * version of the audit's *\"Only Modal manages focus\"*: the whole component exists to\n * say \"look here\", and for a keyboard user \"here\" is the focus ring. They were told\n * the page was hidden, given no way to reach the Next button without Tabbing through\n * it, and left on a control the screen reader would no longer describe.\n *\n * It re-engages on every step, without any bookkeeping here, because `TourOverlay`\n * returns null while it re-locates the next target: the card genuinely unmounts and\n * remounts between steps. That is what keeps focus honest when the BUTTONS change —\n * \"Back\" does not exist on the first step, so stepping back onto it destroys the\n * control the press came from, and focus would otherwise fall to `<body>`, outside\n * this trap's own listener, where Tab walks straight into the page the overlay claims\n * to have hidden.\n *\n * **The cost, written down:** on an `awaitClick` step the user is asked to click the\n * spotlighted element, and they can no longer Tab to it. ArrowRight still advances\n * (the key handler in `TourOverlay` is on the document and does not care where focus\n * is), which is the escape hatch that step already documents for the case where the\n * target cannot be found. Containment is worth that: an `awaitClick` step is a\n * minority of steps, while focus stranded behind `aria-modal` is every step.\n *\n * A guided field step (`gate`, `awaitInput`, 0.50) is the exception: the field is\n * what the step is about, so the overlay focuses it (or the card, on a touch screen)\n * and runs one Tab ring over field + card itself.\n */\n useFocusTrap(ref, { active: trap });\n\n // Docked (§11.7): the edge it last took, for the hysteresis, and a tick bumped when the\n // band moves under an unmoved field (a pad or keyboard opening).\n const edgeRef = useRef<DockEdge | null>(null);\n const [bandTick, setBandTick] = useState(0);\n const [edge, setEdge] = useState<DockEdge | null>(null);\n useEffect(() => {\n if (!docked) return;\n let last = \"\";\n const look = () => {\n const target = step.target ? queryVisibleTarget(step.target) : null;\n const band = readBand(target, ref.current);\n const key = `${band.top}:${band.bottom}`;\n if (key === last) return;\n last = key;\n // A field the pad or keyboard now covers is brought back into the free half.\n if (target) {\n const r = target.getBoundingClientRect();\n if (r.top < band.top || r.bottom > band.bottom) {\n edgeRef.current = scrollIntoFreeHalf(target, ref.current, edgeRef.current);\n }\n }\n setBandTick((t) => t + 1);\n };\n const vv = window.visualViewport;\n vv?.addEventListener(\"resize\", look);\n vv?.addEventListener(\"scroll\", look);\n window.addEventListener(\"resize\", look);\n // The follow tick's cadence: it catches a pad opening, which moves nothing.\n const id = window.setInterval(look, 250);\n return () => {\n vv?.removeEventListener(\"resize\", look);\n vv?.removeEventListener(\"scroll\", look);\n window.removeEventListener(\"resize\", look);\n clearInterval(id);\n };\n }, [docked, step.target, ref]);\n\n useLayoutEffect(() => {\n const card = ref.current;\n if (!card) return;\n if (docked) {\n const target = step.target ? queryVisibleTarget(step.target) : null;\n const band = readBand(target, card);\n const next = rect ? dockEdge(rect, band, edgeRef.current, card.offsetHeight) : \"bottom\";\n edgeRef.current = next;\n setEdge(next);\n setStyle(dockStyle(next, rect, band));\n return;\n }\n setEdge(null);\n setStyle(\n placeCard(rect, card.offsetWidth, card.offsetHeight, window.innerWidth, window.innerHeight, 12, step.placement, dir),\n );\n }, [ref, rect, index, step.placement, step.target, dir, docked, bandTick]);\n\n const awaitsTarget = ((step.awaitClick || step.awaitInput) && step.target && rect) || awaitsRelease;\n\n return (\n <div\n ref={ref}\n // Focusable but not tabbable: the trap above focuses the card itself rather than\n // its first button, so a screen reader reads the step's title and body before it\n // reads \"Next\" — and without this the container cannot take focus at all and the\n // trap silently does nothing.\n tabIndex={-1}\n style={style}\n data-tour-card=\"\"\n data-tour-docked={edge ?? undefined}\n className={cn(\n \"pointer-events-auto fixed z-[61] w-80 max-w-[calc(100vw-1.5rem)] rounded-lg border border-subtle bg-surface p-4 shadow-xl outline-none transition-all duration-200 ease-out\",\n // Docked, the height is capped: the body scrolls, the title and buttons stay.\n docked && \"flex flex-col\",\n )}\n >\n <div className=\"flex flex-wrap items-center gap-x-2 gap-y-1 text-sm font-semibold text-primary\">\n <span>{step.title}</span>\n {step.optional && (\n <span className=\"rounded-full border border-subtle px-1.5 py-px text-xs font-normal text-muted\">\n {labels.optional}\n </span>\n )}\n </div>\n <div\n id={bodyId}\n className={cn(\"mt-1 text-sm leading-relaxed text-secondary\", docked && \"min-h-0 shrink overflow-y-auto\")}\n >\n {step.body}\n </div>\n {step.action && <div className=\"mt-3\">{step.action}</div>}\n <div className=\"mt-4 space-y-2\">\n <div className=\"flex items-center justify-between gap-2\">\n <button\n type=\"button\"\n onClick={onSkip}\n className=\"text-xs text-placeholder hover:text-secondary\"\n >\n {labels.skip}\n </button>\n <div className=\"flex items-center gap-2\">\n <span className=\"whitespace-nowrap text-xs tabular-nums text-placeholder\">\n {labels.step(position, total)}\n </span>\n {!isFirst && (\n <Button variant=\"secondary\" onClick={onBack} className=\"px-2.5 py-1 text-xs\">\n {labels.back}\n </Button>\n )}\n {/* On an awaitClick step the Next button is replaced by a hint on its\n own row below, so it doesn't cram the counter + buttons and wrap.\n Only when the target was actually FOUND, though — `rect` is null\n when the finder gave up, and the click listener early-returns on\n the same absence. Keyed on `step.target` alone this hid the only\n way forward on any step whose anchor happens not to be rendered\n for this user (a guest sees no \"add account\" button), leaving the\n undocumented ArrowRight key as the sole escape. */}\n {/* \"Leave empty\" (§11.2): an optional field may stay empty, so the step can\n move on without it. Gone once the field is filled. */}\n {step.optional && locked && !awaitsTarget && (\n <Button variant=\"secondary\" onClick={onLeaveEmpty} className=\"px-2.5 py-1 text-xs\">\n {labels.leaveEmpty}\n </Button>\n )}\n {!awaitsTarget && (\n <Button\n variant=\"accent\"\n onClick={onNext}\n // Locked, not disabled (§11.1): it stays focusable, and a press focuses the\n // field and reads the hint again.\n aria-disabled={locked || undefined}\n aria-describedby={locked ? hintId : undefined}\n className={cn(\"px-2.5 py-1 text-xs\", locked && \"opacity-60\")}\n >\n {isLast ? labels.done : labels.next}\n </Button>\n )}\n </div>\n </div>\n {awaitsTarget && (\n <div className=\"text-center text-xs italic text-placeholder\">\n {awaitsRelease\n ? (step.awaitGateHint ?? labels.awaitGateHint)\n : step.awaitInput && !step.awaitClick\n ? labels.awaitInputHint\n : labels.awaitClickHint}\n </div>\n )}\n {/* Always mounted on an awaitGate step, so a refusal is read out (assertively)\n the moment it lands. */}\n {awaitsRelease && (\n <div aria-live=\"assertive\" aria-atomic=\"true\" className=\"space-y-1\">\n {refusal && (\n <p data-tour-refused=\"\" className=\"text-xs text-danger\">\n {refusal.reason ?? labels.awaitGateRefused}\n {refusal.seq % 2 === 0 ? \"\\u200b\" : \"\"}\n </p>\n )}\n {refusal && backTo && (\n <Button variant=\"link\" onClick={backTo.go} className=\"text-xs\">\n {labels.backToStep(backTo.title)}\n </Button>\n )}\n </div>\n )}\n {locked && !awaitsTarget && (\n <div id={hintId} className=\"text-center text-xs italic text-placeholder\">\n {gateHint}\n </div>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";AAikBM,SA+1BF,UA90BM,KAjBJ;AAjkBN;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,oBAAoB;AAC7B,SAAS,UAAU;AACnB,SAAS,oBAAwC;AACjD,SAAS,cAAc;AACvB,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB;AAChC,SAAS,gBAAgB;AACzB,SAAS,OAAO,sBAAsB;AACtC,SAAS,mBAAmB;AAE5B,SAAS,2BAA2B;AAEpC,SAAS,gBAAgB,iBAAiB,uBAAoD;AAC9F,SAAS,oBAAoB,aAAa,2BAA8C;AACxF,SAAS,gBAAgB,UAAU,WAAW,UAAU,0BAAyC;AAEjG,SAAS,aAAa,0BAA0B;AAuPhD,MAAM,cAAc,cAAuC,IAAI;AAExD,SAAS,UAA4B;AAC1C,QAAM,MAAM,WAAW,WAAW;AAClC,MAAI,CAAC,IAAK,OAAM,IAAI,MAAM,4CAA4C;AACtE,SAAO;AACT;AAsBO,SAAS,kBAA2C;AACzD,SAAO,WAAW,WAAW;AAC/B;AAuBO,SAAS,aAAa;AAAA,EAC3B;AAAA,EACA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aAEJ;AAAA,UAED,UAAU,CAAC,gBACV,oBAAC,SAAI,IAAI,QAAQ,WAAU,+CACxB,oBACH;AAAA,WAEJ;AAAA;AAAA;AAAA,EACF;AAEJ;","names":["layer"]}
|
|
1
|
+
{"version":3,"sources":["../../src/tour/tour.tsx"],"sourcesContent":["import {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n} from \"react\";\nimport type { CSSProperties, ReactNode, RefObject } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { cn } from \"../lib/cn\";\nimport { useKitLabels, type LabelOverride } from \"../i18n/kit-labels\";\nimport { Button } from \"../components/button\";\nimport { useFocusTrap } from \"../hooks/use-focus-trap\";\nimport { useDismissLayer } from \"../hooks/use-dismiss\";\nimport { sameRect } from \"../hooks/use-anchored-rect\";\nimport { dirOf, horizontalStep } from \"../lib/direction\";\nimport { isComposing } from \"../lib/ime\";\nimport { focusQuietly } from \"../lib/quiet-focus\";\nimport type { Direction } from \"../lib/direction\";\nimport { DEFAULT_TOUR_LABELS } from \"./tour-labels\";\nimport type { TourInfo } from \"./tour-info\";\nimport { completeStored, rememberAccount, rememberMigrate, type UseTourProgressOptions } from \"./use-tour-progress\";\nimport { createGateRegistry, devWarnings, TourInternalContext, type GateRegistry } from \"./tour-gates\";\nimport { liveEngine } from \"./tour-engine\";\nimport { DOCK_MAX_WIDTH, dockEdge, dockStyle, readBand, scrollIntoFreeHalf, type DockEdge } from \"./tour-dock\";\n\nexport { useTourGate, useTourGateRelease } from \"./tour-gates\";\nexport type { TourGateRelease } from \"./tour-gates\";\n\n/**\n * `start`/`end` follow the reading direction (`end` is the right side in LTR and the\n * left side in RTL) and are what a translated app wants. `left`/`right` stay physical\n * for the steps that genuinely mean a screen side.\n */\nexport type TourPlacement = \"top\" | \"right\" | \"bottom\" | \"left\" | \"start\" | \"end\" | \"center\" | \"dock\";\n\nexport interface TourStep {\n /** CSS selector for the element to spotlight. Omit for a centered step\n * (welcome/finish). If the target isn't found/visible, the step centers. */\n target?: string;\n title: string;\n body: ReactNode;\n /** Extra footer content, e.g. a \"load sample data\" shortcut. */\n action?: ReactNode;\n /** Spotlight padding around the target, px (default 8). On a field step the spot also\n * takes in the lines the field's `aria-describedby` names when they sit within the\n * ring's reach of it (a hint or warning line under the field, keksdose S1, §11.6). */\n padding?: number;\n /** Where the card sits relative to the target. Omit for auto placement\n * (below → above → centered). \"center\" ignores the target and centers on\n * screen. \"start\"/\"end\" are the logical sides and flip in RTL; \"left\"/\"right\"\n * are physical. An explicit side flips to the opposite side if it would\n * overflow, then clamps into the viewport.\n *\n * `\"dock\"` (0.50, §11.7): below `sm` (640 px) the card is pinned full-width to the top\n * or bottom edge of the usable band — the visual viewport less the keyboard and any\n * `[data-tour-obstruction]` (the number pad) — on the edge away from the field, and the\n * field's scroll container brings it into the other half. From `sm` up it is auto\n * placement. On a phone a field step (`interactive`, `awaitInput`, `gate`, `awaitGate`)\n * with a target and no `placement` docks by default (`TourProvider dockOnPhones`). */\n placement?: TourPlacement;\n /** Advance only when the user clicks the spotlighted target itself (not the\n * card's Next button). Requires `target`: the real control's own handler runs\n * first, then the tour steps forward on a microtask. The spotlight hole stays\n * click-through to the target; the rest of the page does not. */\n awaitClick?: boolean;\n /**\n * The spotlighted control is for USING, not only for looking at (0.46, keksdose live\n * #436): the layers it opens sit above the scrim and work. A plain step's overlay is\n * `z-[60]`, over every kit layer, so a field whose number pad (`NumberPadSheet`), a\n * select's menu or a popover opens at `z-50` opened UNDER the shields, where nothing\n * could be tapped. Here the overlay drops to `z-[45]`: still over the top bar and the\n * page (`z-40` and below, still dimmed and shielded), under every `z-50` layer the\n * target opens — so an app's own layer wants `z-50` or more to clear it. Keys pressed\n * in the target or in such a layer are theirs (Escape closes the pad, arrows walk a\n * list); from the card the tour's keys work as on any step. The overlay is not\n * `aria-modal` then, and carries `data-tour-interactive`.\n *\n * The card is in the same layer as the scrim, so an open pad or sheet may cover it\n * until it closes. Requires `target`. A `HoverMenu` (`z-40`, the top bar's menus) stays\n * under the scrim: point an `awaitClick` step at its trigger instead.\n */\n interactive?: boolean;\n /**\n * Advance once a value was ENTERED in the spotlighted control (0.46, keksdose live\n * #436) — `awaitClick` for a field. Implies `interactive`. Counted when focus leaves\n * the target (the number pad's Done, a Tab, a tap elsewhere), or Enter is pressed in\n * it, and one of its fields (`input`, `textarea`, `select`: the target itself or\n * inside it) then holds another value than when the step began; a native `change`\n * (a select, a checkbox) counts at once. The card swaps Next for `awaitInputHint`,\n * as for `awaitClick`. A picker whose value is not a field's (the kit's `Select`\n * button) has nothing to compare: call `useTour().next()` from its `onChange`.\n */\n awaitInput?: boolean;\n /**\n * 0.50 (docs/tours-harmonization.md §11.1): Next stays locked until the gate `key` is\n * satisfied — the form publishes it with `useTourGate(key, satisfied)` beside the field.\n * Implies `interactive`. The locked Next is `aria-disabled` with {@link gateHint} under\n * it; pressing it focuses the field. Once satisfied the tour does NOT advance by itself:\n * Next, Enter in the field, or focus leaving the field to nowhere or to the card (the\n * number pad's Done) moves on. A key nobody publishes is not enforced (the form closed\n * under the tour): Next opens. A step may have a `gate` and no `target`.\n */\n gate?: string;\n /** Overrides `labels.gateHint` for this step. */\n gateHint?: string;\n /**\n * 0.50 (§11.4): wait for the app to RELEASE this key — `useTourGateRelease().release(key)`\n * from the save's `onSuccess`. Implies `interactive`; usually it targets the Save button,\n * whose hole stays click-through. Next is replaced by {@link awaitGateHint}, and a click\n * does not advance: only `release` does. A release that arrives on an earlier step (Enter\n * in the last field submitted the form) jumps past the first later step awaiting the key.\n * `refuse(key, reason)` keeps the step and shows the reason, with a \"Back to …\" link to the\n * first earlier field whose gate is now unsatisfied; the kit never jumps there itself.\n * A viewer who cannot save gets `awaitGate: undefined`, so a plain Next.\n */\n awaitGate?: string;\n /** Overrides `labels.awaitGateHint` for this step. */\n awaitGateHint?: string;\n /**\n * 0.50 (§11.2): the field may stay empty. While the `gate` is unsatisfied the card\n * offers \"Leave empty\" beside the locked Next, which moves on without touching the field\n * (the kit never writes app values); the title carries an \"Optional\" chip. Not a skip:\n * the run continues and can complete. Without a `gate`, only the chip.\n */\n optional?: boolean;\n /**\n * 0.50 (§11.3): shown only if this returns true on ARRIVAL (evaluated before\n * `beforeStep`, so a skipped step never navigates). Next walks forward to the first step\n * shown, Back to the nearest earlier one shown now. Branch facts are gates:\n * `when: (c) => c.gate(\"txn.transfer\") === true`. Keep it pure and cheap: the counter\n * evaluates every step's `when` on each arrival. A throw counts as skipped.\n */\n when?: (ctx: TourStepContext) => boolean;\n /** Runs before the step is shown — e.g. navigate to a route, open a panel.\n * May be async; the step waits for it, then locates the target. Receives the\n * {@link TourStepContext} (0.50); a step entered by \"Guide me\" sees `via: \"at\"` and\n * should leave an open form alone. */\n beforeStep?: (ctx: TourStepContext) => void | Promise<void>;\n}\n\n/** What a step's `when` and `beforeStep` may ask on arrival (0.50, §11.3). */\nexport interface TourStepContext {\n /** The gate's current value: true/false, or undefined while nobody publishes it. */\n gate(key: string): boolean | undefined;\n /** How this step is being entered. */\n via: \"start\" | \"at\" | \"next\" | \"back\" | \"goto\";\n}\n\nexport interface TourLabels {\n next: string;\n back: string;\n skip: string;\n done: string;\n /** Shown in place of the Next button on an `awaitClick` step. */\n awaitClickHint: string;\n /** Shown in place of the Next button on an `awaitInput` step (0.46). */\n awaitInputHint: string;\n /** Step counter, e.g. (2, 7) => \"2 / 7\". Counts the steps the run shows (0.50). */\n step: (current: number, total: number) => string;\n /** 0.50: an `optional` gate step's button while the field is empty. */\n leaveEmpty: string;\n /** 0.50: the chip beside an `optional` step's title. */\n optional: string;\n /** 0.50: under a `gate` step's locked Next (`TourStep.gateHint` overrides it). */\n gateHint: string;\n /** 0.50: announced (screen readers only) when a gate step's field is filled. */\n gateReady: string;\n /** 0.50: in place of Next on an `awaitGate` step (`TourStep.awaitGateHint` overrides it). */\n awaitGateHint: string;\n /** 0.50: the warning when the app `refuse`s an `awaitGate` step without a reason. */\n awaitGateRefused: string;\n /** 0.50: the link to an earlier step whose field was emptied, after a refused save. */\n backToStep: (title: string) => string;\n}\n\n// Defined in ./tour-labels, which holds no component code (0.34, KS U8).\nexport { DEFAULT_TOUR_LABELS };\n\n/** 0.50 (§11.5): a step index, or the `data-tour` value of the step's anchor. */\nexport type TourAt = number | string;\n\n/** `useTour().start`, both forms: what `TourProvider` hands its `launch` as the third argument. */\nexport type TourStart = TourContextValue[\"start\"];\n\n/**\n * 0.50 (§11.5): the app's launcher — the shape `useTourUrlSync` already takes, plus `at`.\n * It builds the steps (`prepare()`, `build()`, `tour: tourInfo(def)`) and passes `at` on to\n * `start(steps, { …, at })`. Give the same function to `TourProvider launch` and to\n * `useTourUrlSync`.\n *\n * `start` is the provider's own `start` (keksdose N4), so the launcher needs no ref to a\n * component below the provider and may be defined above it. `engine` (0.50.1, keksdose N1)\n * is the rest of the engine — `stop`, `next`, `active`, … — read live, see {@link TourEngine}.\n * `useTourUrlSync` passes both (under a provider). A launcher taking fewer arguments still\n * works.\n */\nexport type TourLauncher = (\n id: string,\n opts: { startIndex?: number; at?: TourAt },\n start: TourStart,\n engine: TourEngine,\n) => void | Promise<unknown>;\n\n/**\n * 0.50.1 (keksdose N1): the whole engine `useTour()` returns, handed to a launcher as its\n * FOURTH argument by `TourProvider` and `useTourUrlSync`, so a tour built above the provider\n * can also `stop`, `next` or read `active` with no `useTour()` registered from below. One\n * object per provider whose fields read the latest render (`engine.active` after an\n * `await` is current); its methods are the provider's own. `start` (the third argument) is\n * `engine.start`.\n */\nexport type TourEngine = TourContextValue;\n\nconst ENGINE_KEYS = [\n \"active\",\n \"activeId\",\n \"start\",\n \"stop\",\n \"next\",\n \"prev\",\n \"goToStep\",\n \"index\",\n \"total\",\n \"position\",\n \"count\",\n] as const satisfies readonly (keyof TourContextValue)[];\n\ninterface StartOptions {\n /** Stable id of the tour, surfaced as `activeId` so the app can mirror it to\n * the URL (deep-link / evaluation tracking) and record completion. Defaults to\n * `tour.id`. */\n id?: string;\n /** The tour being started, as the app lists it (docs/tours-harmonization.md §9.6.1).\n * When its last step is finished, the provider records the completion in its\n * `progress` and hands this to `onComplete`. */\n tour?: TourInfo;\n /** Start at this step index instead of 0 (clamped) — for URL/deep-link resume. */\n startIndex?: number;\n /**\n * 0.50 (§11.5): start here AND make it the floor — earlier steps never run (nor their\n * `beforeStep`), Back stops here, `position`/`count` count from here, and the finish\n * records the completion as a full run does (Marcel, Q2). A number is a step index\n * (clamped); a string is the first step whose `target` contains `data-tour=\"<at>\"`\n * verbatim (unknown: 0, with a development warning). The `at` step is entered with\n * `via: \"at\"`. With `startIndex` too, `startIndex` picks the step and `at` the floor.\n */\n at?: TourAt;\n /** Fires synchronously when the tour starts (e.g. enable a mock interceptor). */\n onStart?: () => void;\n /** After the last step: runs after the provider's progress write and `onComplete`. */\n onFinish?: () => void;\n onSkip?: () => void;\n}\n\n/** What `TourProvider`'s `onComplete` learns besides the tour (§9.1, §9.6). */\nexport interface TourCompletion {\n /**\n * `true` when the completion counts anew (the first time, or the first time after the\n * tour's update, §8): the moment for the app's points toast. `false` for a replay, and\n * when the stored text is in an old shape no `migrate` reads: nothing is overwritten\n * then, and the error goes to `console.error` (keksdose B-1). `undefined` when the provider has no `progress` or the start carried no `tour`, so\n * nothing was recorded.\n */\n awarded: boolean | undefined;\n}\n\ninterface TourContextValue {\n active: boolean;\n /** Id of the running tour (from {@link StartOptions.id}), else null. */\n activeId: string | null;\n /**\n * Start a tour with the given steps — or, by id (0.50), through the provider's `launch`:\n * `start(\"create-transaction\", { at: \"txn-entry-mode\" })`. Without a `launch` the id form\n * does nothing (a development build warns).\n */\n start: {\n // The id form first: `Parameters<typeof start>` reads the LAST overload, which stays\n // the 0.49 one.\n (id: string, opts?: { at?: TourAt }): void;\n (steps: TourStep[], opts?: StartOptions): void;\n };\n /** End the current tour (no callbacks fire). */\n stop: () => void;\n /** Advance one step; past the last step it finishes the tour (fires onFinish). */\n next: () => void;\n /** Go back one step (no-op on the first). */\n prev: () => void;\n /** Jump to a step by index, clamped to range — e.g. for URL/deep-link resume. */\n goToStep: (index: number) => void;\n /** Current step (0-based; 0 while inactive). */\n index: number;\n /** Total steps (0 while inactive). */\n total: number;\n /** 0.50: 1-based position among the steps this run shows, for \"3 of 9\"; 0 while inactive. */\n position: number;\n /** 0.50: how many steps this run shows, from its first (the `at` floor) to the end; 0 while inactive. */\n count: number;\n}\n\nconst TourContext = createContext<TourContextValue | null>(null);\n\nexport function useTour(): TourContextValue {\n const ctx = useContext(TourContext);\n if (!ctx) throw new Error(\"useTour must be used within <TourProvider>\");\n return ctx;\n}\n\n/**\n * The tour engine if it is there, `null` if it is not — for a control that is a\n * DECORATION rather than a participant.\n *\n * {@link useTour}'s throw is correct and stays: a component that runs a tour cannot do\n * its job without the provider, and failing loudly is how that gets fixed. But the\n * throw's blast radius is whatever error boundary is above it, and for a launcher in\n * the app shell that is the whole app.\n *\n * Keksdose feedback dev#524 is what that costs: an `@hb/ui` module was edited while a\n * dev server was running, vite re-evaluated it, and the module's freshly created\n * context object was no longer the one the mounted provider was providing. React's\n * `useContext` then answers `null` for a provider that is, structurally, right there —\n * and the top bar's tour menu took the entire shell down with it. **Build-time module\n * graphs cannot produce that**, so it is a development-only failure; a menu that\n * disappears for a second is the proportionate response to it either way.\n *\n * Only for controls that can honestly render nothing. If a component would show a\n * broken half of itself without the tour, it wants {@link useTour}.\n */\nexport function useTourOptional(): TourContextValue | null {\n return useContext(TourContext);\n}\n\n/**\n * Provides the guided-tour engine: a dimmed spotlight overlay + step card driven\n * by a list of {@link TourStep}s. Domain-free — the app supplies the steps (copy,\n * selectors, per-step navigation, placement) and the translated {@link TourLabels}.\n * Mount once inside the router; start a tour from anywhere via {@link useTour},\n * which also exposes step control (`next`/`prev`/`goToStep`) and the current\n * `index`/`total` for URL mirroring, `awaitClick` and deep-link resume.\n *\n * **Completion in one place** (docs/tours-harmonization.md §9.6): give the provider the\n * app's `progress` (the same `{storageKey, migrate}` as `useTourProgress`) and start each\n * tour with `start(steps, {tour})`. When the last step is finished the provider writes the\n * completion ONCE, through the store every `useTourProgress` reader of the key shares\n * (never a second copy), then calls `onComplete(tour, {awarded})`, then the start's own\n * `onFinish`. A skip or `stop()` records nothing and calls neither. The app removes its\n * own `complete()` from `onFinish`, or that second write answers `false`.\n *\n * Both props are optional: without `progress` or a `tour` on the start, `onComplete`\n * still fires, with `awarded: undefined` (and `tour` as given, possibly `undefined`). A\n * new `storageKey` (an account switch on a shared PC) is followed on the next\n * completion, without a remount.\n */\nexport function TourProvider({\n children,\n labels,\n progress,\n onComplete,\n launch,\n dockOnPhones = true,\n}: {\n children: ReactNode;\n labels?: LabelOverride<TourLabels>;\n /**\n * 0.50 (§11.5): lets `start(id)` and `<TourGuideButton>` start a tour by id. Usually the\n * same function the app gives `useTourUrlSync`.\n */\n launch?: TourLauncher;\n /** The app's tour progress: the same options its `useTourProgress` readers use. */\n progress?: UseTourProgressOptions;\n /** A tour's last step was finished; see {@link TourCompletion}. */\n onComplete?: (tour: TourInfo | undefined, completion: TourCompletion) => void;\n /**\n * 0.50 (§11.7, Marcel's Q1): below `sm`, a field step with a target and no `placement`\n * docks. Default `true`; `false` makes docking strictly opt-in (`placement: \"dock\"`).\n */\n dockOnPhones?: boolean;\n}) {\n // `labels` over the provider's `tour` over English. Resolved once here and handed\n // down: the step card is portalled, but context crosses portals anyway — this is\n // simply the one place that already owned the merge.\n const merged = useKitLabels(\"tour\", DEFAULT_TOUR_LABELS, labels);\n const [steps, setSteps] = useState<TourStep[] | null>(null);\n // Where the run is: the raw index (what `?tourStep=` mirrors), how it got there, and\n // its place among the steps shown (§11.3), computed once on arrival.\n const [nav, setNav] = useState<Nav>(NO_NAV);\n const index = nav.index;\n // The app's last `refuse` on the step awaiting its key; any arrival clears it.\n const [refusal, setRefusal] = useState<Refusal | null>(null);\n const [activeId, setActiveId] = useState<string | null>(null);\n const optsRef = useRef<StartOptions>({});\n // The latest props, read at the finish: a new `storageKey` or callback needs no remount.\n const progressRef = useRef(progress);\n const onCompleteRef = useRef(onComplete);\n const launchRef = useRef(launch);\n useLayoutEffect(() => {\n progressRef.current = progress;\n onCompleteRef.current = onComplete;\n launchRef.current = launch;\n });\n // The provider's migrate becomes the key's, for readers that pass none (keksdose B-2).\n const storageKey = progress?.storageKey;\n const migrate = progress?.migrate;\n // 0.45: and its `account` (§10.3), so a finish on an account key is sent as readers' are.\n const account = progress?.account;\n useLayoutEffect(() => {\n if (storageKey !== undefined) rememberMigrate(storageKey, migrate);\n if (storageKey !== undefined) rememberAccount(storageKey, account);\n }, [storageKey, migrate, account]);\n const warnedNoTourRef = useRef(false);\n // Live mirrors so the step-control callbacks can stay stable (identity-safe for\n // consumers) while still reading the current steps/index. Synced in a layout\n // effect — after the commit, before paint and before any passive effect or event\n // can call them — rather than written during render.\n const stepsRef = useRef<TourStep[] | null>(null);\n const indexRef = useRef(0);\n useLayoutEffect(() => {\n stepsRef.current = steps;\n indexRef.current = index;\n }, [steps, index]);\n /** The run's first step: earlier steps never run, Back stops here (the `at` floor). */\n const floorRef = useRef(0);\n const active = !!steps && steps.length > 0;\n const total = steps?.length ?? 0;\n // The gate registry (§11.1): one per provider, read by the overlay while a tour runs.\n const [gates] = useState(createGateRegistry);\n useLayoutEffect(() => {\n gates.setActive(active);\n }, [gates, active]);\n const canLaunch = !!launch;\n const internals = useMemo(() => ({ gates, canLaunch }), [gates, canLaunch]);\n\n /** Is step `i` shown, asked now (§11.3)? */\n const shown = useCallback(\n (s: TourStep[], i: number, via: TourStepContext[\"via\"]) => isShown(s[i], stepContext(gates, via)),\n [gates],\n );\n /** Arrive at `i`: the counter is recomputed from every step's `when`, against the gates now. */\n const arrive = useCallback(\n (s: TourStep[], i: number, via: TourStepContext[\"via\"]) => {\n const ctx = stepContext(gates, via);\n let position = 0;\n let count = 0;\n for (let j = floorRef.current; j < s.length; j++) {\n if (j !== i && !isShown(s[j], ctx)) continue;\n count++;\n if (j <= i) position++;\n }\n indexRef.current = i;\n setRefusal(null);\n setNav({ index: i, floor: floorRef.current, via, position, count });\n },\n [gates],\n );\n /** The first step shown at or after `from`, or -1. */\n const forward = useCallback(\n (s: TourStep[], from: number, via: TourStepContext[\"via\"]) => {\n for (let j = Math.max(from, floorRef.current); j < s.length; j++) if (shown(s, j, via)) return j;\n return -1;\n },\n [shown],\n );\n /** The nearest step shown at or before `from`, not below the floor, or -1. */\n const backward = useCallback(\n (s: TourStep[], from: number, via: TourStepContext[\"via\"]) => {\n for (let j = Math.min(from, s.length - 1); j >= floorRef.current; j--) if (shown(s, j, via)) return j;\n return -1;\n },\n [shown],\n );\n\n const startSteps = useCallback(\n (s: TourStep[], opts?: StartOptions) => {\n optsRef.current = opts ?? {};\n optsRef.current.onStart?.();\n const last = Math.max(0, s.length - 1);\n floorRef.current = opts?.at === undefined ? 0 : resolveAt(s, opts.at);\n const via: TourStepContext[\"via\"] = opts?.at === undefined ? \"start\" : \"at\";\n const wanted = Math.min(Math.max(floorRef.current, opts?.startIndex ?? floorRef.current), last);\n let to = forward(s, wanted, via);\n if (to < 0) to = backward(s, wanted, via);\n // Not one step of the run is shown: there is nothing to tour.\n if (to < 0) return;\n arrive(s, to, via);\n setActiveId(opts?.id ?? opts?.tour?.id ?? null);\n setSteps(s);\n },\n [arrive, forward, backward],\n );\n // The provider's own `start` and the live engine, handed to `launch` as its third and\n // fourth arguments (keksdose N4, N1).\n const ownStartRef = useRef<TourContextValue[\"start\"] | null>(null);\n const [live] = useState(() => liveEngine<TourEngine>(ENGINE_KEYS));\n const engine = live.engine;\n const start = useCallback(\n (what: TourStep[] | string, opts?: StartOptions | { at?: TourAt }) => {\n if (typeof what !== \"string\") {\n startSteps(what, opts as StartOptions | undefined);\n return;\n }\n const run = launchRef.current;\n if (!run) {\n if (devWarnings()) console.warn(`[ui-kit] start(\"${what}\") needs TourProvider's \\`launch\\` prop.`);\n return;\n }\n void Promise.resolve(run(what, { at: opts?.at }, ownStartRef.current!, engine)).catch((error: unknown) =>\n console.error(error),\n );\n },\n [startSteps, engine],\n ) as TourContextValue[\"start\"];\n useLayoutEffect(() => {\n ownStartRef.current = start;\n }, [start]);\n const stop = useCallback(() => {\n setSteps(null);\n setActiveId(null);\n }, []);\n const finish = useCallback(() => {\n // Once per tour: a second \"Done\" before the overlay unmounts records nothing more.\n if (!stepsRef.current) return;\n stepsRef.current = null;\n const { tour, onFinish } = optsRef.current;\n const store = progressRef.current;\n // Exactly one write per completion (§9.6.2), so `awarded` is what `complete(tour)` answered.\n let awarded: boolean | undefined;\n if (store && tour) {\n try {\n awarded = completeStored(store.storageKey, store.migrate, tour);\n } catch (error) {\n // A stored text no migrate reads is left as it is (keksdose B-1); the tour still ends.\n console.error(error);\n awarded = false;\n }\n } else if (store && !tour && devWarnings() && !warnedNoTourRef.current) {\n warnedNoTourRef.current = true;\n console.warn(\n \"[ui-kit] TourProvider has `progress`, but a finished tour's start carried no `tour`: \" +\n \"nothing was recorded and `awarded` is undefined. Start it with `start(steps, { tour })`.\",\n );\n }\n onCompleteRef.current?.(tour, { awarded });\n onFinish?.();\n setSteps(null);\n setActiveId(null);\n }, []);\n const skip = useCallback(() => {\n optsRef.current.onSkip?.();\n setSteps(null);\n setActiveId(null);\n }, []);\n\n // A step whose `when` is false is passed over: `goToStep` lands on the next step shown\n // after it, failing that the previous one; Next past the last shown step finishes.\n const goToStep = useCallback(\n (i: number) => {\n const s = stepsRef.current;\n if (!s || s.length === 0) return;\n const wanted = Math.min(Math.max(floorRef.current, i), s.length - 1);\n let to = forward(s, wanted, \"goto\");\n if (to < 0) to = backward(s, wanted, \"goto\");\n if (to >= 0) arrive(s, to, \"goto\");\n },\n [arrive, forward, backward],\n );\n const next = useCallback(() => {\n const s = stepsRef.current;\n if (!s || s.length === 0) return;\n const to = forward(s, indexRef.current + 1, \"next\");\n if (to < 0) finish();\n else arrive(s, to, \"next\");\n }, [arrive, forward, finish]);\n const prev = useCallback(() => {\n const s = stepsRef.current;\n if (!s) return;\n const to = backward(s, indexRef.current - 1, \"back\");\n if (to >= 0) arrive(s, to, \"back\");\n }, [arrive, backward]);\n\n // awaitGate (§11.4): `release` and `refuse` are events, heard only while a tour runs.\n useEffect(() => {\n if (!active) return;\n let seq = 0;\n return gates.listen((signal) => {\n const s = stepsRef.current;\n if (!s) return;\n const i = indexRef.current;\n if (signal.kind === \"refuse\") {\n // On any other step the form's own errors speak.\n if (s[i]?.awaitGate === signal.key) setRefusal({ step: s[i], reason: signal.reason, seq: ++seq });\n return;\n }\n // The step awaiting it, or the first later one: the record is saved, so the fields\n // between are passed over.\n const awaiting = s[i]?.awaitGate === signal.key ? i : s.findIndex((st, k) => k > i && st.awaitGate === signal.key);\n if (awaiting < 0) return;\n const to = forward(s, awaiting + 1, \"next\");\n if (to < 0) finish();\n else arrive(s, to, \"next\");\n });\n }, [active, gates, arrive, forward, finish]);\n\n const value: TourContextValue = {\n active,\n activeId,\n start,\n stop,\n next,\n prev,\n goToStep,\n index,\n total,\n position: active ? nav.position : 0,\n count: active ? nav.count : 0,\n };\n // Read by the live engine (`launch`'s fourth argument) after this render commits.\n useLayoutEffect(() => {\n live.set(value);\n });\n\n return (\n <TourInternalContext.Provider value={internals}>\n <TourContext.Provider value={value}>\n {children}\n {active && (\n <TourOverlay\n steps={steps!}\n index={index}\n via={nav.via}\n floor={nav.floor}\n position={nav.position}\n count={nav.count}\n refusal={refusal?.step === steps![index] ? refusal : null}\n onGoTo={goToStep}\n labels={merged}\n gates={gates}\n dockOnPhones={dockOnPhones}\n onNext={next}\n onPrev={prev}\n onSkip={skip}\n />\n )}\n </TourContext.Provider>\n </TourInternalContext.Provider>\n );\n}\n\ninterface Nav {\n index: number;\n /** The run's first step (the `at` floor). */\n floor: number;\n via: TourStepContext[\"via\"];\n position: number;\n count: number;\n}\n\nconst NO_NAV: Nav = { index: 0, floor: 0, via: \"start\", position: 0, count: 0 };\n\n/** The app's `refuse` on the step that awaits its key (§11.4). */\ninterface Refusal {\n step: TourStep;\n reason?: string;\n /** Bumped per refusal, so the same words are announced again. */\n seq: number;\n}\n\nconst NOOP = () => {};\n\nfunction stepContext(gates: GateRegistry, via: TourStepContext[\"via\"]): TourStepContext {\n return { gate: (key) => gates.get(key), via };\n}\n\n/** `StartOptions.at` as a step index: a number clamped, an anchor's first step, else 0. */\nfunction resolveAt(steps: TourStep[], at: TourAt): number {\n if (typeof at === \"number\") return Math.min(Math.max(0, Math.floor(at)), Math.max(0, steps.length - 1));\n const anchor = `data-tour=\"${at}\"`;\n const found = steps.findIndex((step) => step.target?.includes(anchor));\n if (found >= 0) return found;\n if (devWarnings()) console.warn(`[ui-kit] A tour was started at \"${at}\", but no step targets [${anchor}]: it starts at 0.`);\n return 0;\n}\n\n/** The first step in [floor, index) shown now whose gate is published and unsatisfied, or -1. */\nfunction firstEmptied(steps: TourStep[], floor: number, index: number, gates: GateRegistry): number {\n const ctx = stepContext(gates, \"goto\");\n for (let j = floor; j < index; j++) {\n const key = steps[j].gate;\n if (key && gates.get(key) === false && isShown(steps[j], ctx)) return j;\n }\n return -1;\n}\n\n/** A step's `when`, asked now; a throw is a skip, and the error goes to the console. */\nfunction isShown(step: TourStep, ctx: TourStepContext): boolean {\n if (!step.when) return true;\n try {\n return step.when(ctx) === true;\n } catch (error) {\n console.error(error);\n return false;\n }\n}\n\ninterface Rect {\n top: number;\n left: number;\n width: number;\n height: number;\n}\n\nfunction isVisible(el: Element): boolean {\n // A non-zero box already rules out display:none on the element or any ancestor\n // (an unrendered element measures 0x0). We deliberately do NOT test\n // offsetParent: it is null for position:fixed elements even when fully visible,\n // which made the mobile bottom-nav bar (fixed) un-highlightable on mobile\n // (feedback #313). visibility:hidden keeps a box, so check it explicitly.\n const r = el.getBoundingClientRect();\n if (r.width <= 0 || r.height <= 0) return false;\n const style = getComputedStyle(el);\n return style.visibility !== \"hidden\" && style.display !== \"none\";\n}\n\n// The first VISIBLE element matching the selector, not merely the first in DOM\n// order. This lets a step target the same control across layouts with one\n// combined selector — e.g. the desktop sidebar link AND the mobile bottom-bar\n// link — where the off-layout copy is present but `display:none` (feedback\n// #313). Returns null while none is visible so the finder keeps retrying.\nfunction queryVisibleTarget(selector: string): Element | null {\n const els = document.querySelectorAll(selector);\n for (const el of els) {\n if (isVisible(el)) return el;\n }\n return null;\n}\n\nfunction rectOf(el: Element): Rect {\n const r = el.getBoundingClientRect();\n return { top: r.top, left: r.left, width: r.width, height: r.height };\n}\n\n/** The two-tone frame's width outside the spot (3px white, 2px keyline), plus a pixel. */\nconst RING_BAND = 6;\n\n/**\n * What a step's ring frames (keksdose S1, §11.6): the target, and on a FIELD step also the\n * lines that describe the field from outside it — the elements its `aria-describedby`\n * (on the target or a control inside) names that lie within the ring's reach of it (a\n * caption, a hint or warning line, an error drawn under or above the field). Without\n * them the ring's frame ran through such a line; with them it frames field and line, and\n * the line is lit, not under the scrim. A kit field's own caption and error are inside\n * its root already. A line far away (a tooltip, another part of the page) is not taken.\n */\nfunction spotRectOf(el: Element, step: TourStep): Rect {\n const own = rectOf(el);\n if (!isFieldStep(step)) return own;\n const ids = new Set<string>();\n const holders = [el, ...Array.from(el.querySelectorAll(\"[aria-describedby]\"))];\n for (const holder of holders) {\n for (const id of (holder.getAttribute(\"aria-describedby\") ?? \"\").split(/\\s+/)) if (id) ids.add(id);\n }\n if (ids.size === 0) return own;\n const lines: DOMRect[] = [];\n for (const id of ids) {\n const line = document.getElementById(id);\n if (!line || el.contains(line) || line.closest('[role=\"tooltip\"]') || !isVisible(line)) continue;\n const r = line.getBoundingClientRect();\n // An `sr-only` description measures 1×1: nothing to frame.\n if (r.width > 1 && r.height > 1) lines.push(r);\n }\n let top = own.top;\n let left = own.left;\n let right = own.left + own.width;\n let bottom = own.top + own.height;\n const reach = (step.padding ?? 8) + RING_BAND;\n // Grow until nothing more is in reach: a hint under the field, then an error under it.\n for (let grew = true; grew; ) {\n grew = false;\n for (let i = lines.length - 1; i >= 0; i--) {\n const r = lines[i];\n const across = r.left < right && r.right > left;\n const gap = Math.max(r.top - bottom, top - r.bottom);\n if (!across || gap > reach) continue;\n top = Math.min(top, r.top);\n left = Math.min(left, r.left);\n right = Math.max(right, r.right);\n bottom = Math.max(bottom, r.bottom);\n lines.splice(i, 1);\n grew = true;\n }\n }\n return { top, left, width: right - left, height: bottom - top };\n}\n\n/**\n * What the finder established for ONE step: where its target is (`null` = no target,\n * or not on the page), and the reading direction the card takes from it.\n *\n * It carries the step it was found for, and the overlay only believes it for that\n * step — which is the whole fix for keksdose's tours audit 2026-10-02, §1.0 A (\"stale\n * spotlight on the step after a spotlighted one\", 15 steps in 16 tours, desktop and\n * phone, mouse and keyboard). When step N spotlit a target and step N+1 had none (or\n * its anchor was missing), N+1 kept N's hole and parked its card beside it, so a\n * centred \"You're all set\" read as pointing at the Import & Export link; Back→Next kept\n * it for as long as anyone watched.\n *\n * The overlay used to hold `rect` and `ready` as separate states and reset them\n * DURING RENDER when the step changed. React 19 does not keep a render-phase update\n * while an earlier, lower-priority update to the same hook is still queued — it only\n * writes the result to the base state \"unless the queue is empty\" — and the follow\n * interval below queues exactly such an update every 250 ms (eagerly bailed out because\n * the rect had not moved, but left in the queue for rebasing). So the click's render\n * showed the reset, and the very next render (the finder saying \"ready\") re-based on\n * the old rect. A deep link was fine because nothing had queued anything yet.\n *\n * Keying the result to its step does not depend on any of that ordering: a rect found\n * for another step is not this step's rect, whatever the queue does with it, and a\n * missing anchor reads as \"no target\" instead of as the last thing that was lit.\n */\ninterface Located {\n index: number;\n step: TourStep;\n rect: Rect | null;\n dir: Direction;\n /**\n * A field step's own container (§11.6): inserted right after the kit layer holding the\n * target (`host.after`), or at the end of <body> on the page. `null` on a plain step,\n * which is portalled to <body> at z-[60] as ever.\n */\n layer: HTMLElement | null;\n /** The host fills the visual viewport (a phone's FullBleedDialog): no scrim, no shields. */\n fullScreen: boolean;\n}\n\n/** The kit layer (`data-kit-layer`) holding `el`, if any. */\nfunction layerHost(el: Element): HTMLElement | null {\n return el.closest<HTMLElement>(\"[data-kit-layer]\");\n}\n\n/**\n * Does the host fill the visual viewport? A backdrop host (`data-kit-layer=\"backdrop\"`:\n * Modal, FullBleedDialog) is judged by its panel, the child holding the target.\n */\nfunction coversViewport(host: HTMLElement, el: Element): boolean {\n let surface: Element = host;\n if (host.getAttribute(\"data-kit-layer\") === \"backdrop\") {\n for (const child of Array.from(host.children)) {\n if (child.contains(el)) {\n surface = child;\n break;\n }\n }\n }\n const r = surface.getBoundingClientRect();\n const vv = window.visualViewport;\n const top = vv?.offsetTop ?? 0;\n const bottom = top + (vv?.height ?? window.innerHeight);\n const width = vv?.width ?? window.innerWidth;\n return r.width > 0 && r.left <= 1 && r.top <= top + 1 && r.right >= width - 1 && r.bottom >= bottom - 1;\n}\n\n/** Does this step's card dock now (§11.7)? A phone-width viewport, and `\"dock\"` or a field\n * step with no placement while the provider docks on phones. */\nfunction docks(step: TourStep, dockOnPhones: boolean): boolean {\n if (typeof window === \"undefined\" || window.innerWidth >= DOCK_MAX_WIDTH || !step.target) return false;\n return step.placement === \"dock\" || (step.placement === undefined && dockOnPhones && isFieldStep(step));\n}\n\n/** A step whose control is for using: its card joins the layer stack above the field (§11.6). */\nfunction isFieldStep(step: TourStep): boolean {\n return !!(step.interactive || step.awaitInput || step.gate || step.awaitGate);\n}\n\n/** The first control in `el` (or `el` itself) a person would type into or press. */\nfunction firstFocusable(el: Element): HTMLElement | null {\n if (el instanceof HTMLElement && el.matches(FOCUSABLE_CONTROL)) return el;\n return el.querySelector<HTMLElement>(FOCUSABLE_CONTROL);\n}\n\n/** The tab stops inside `el`, in DOM order (the focus trap's selector). */\nfunction tabStops(el: Element): HTMLElement[] {\n const all = el.matches(FOCUSABLE_CONTROL) ? [el as HTMLElement] : [];\n return all.concat(\n Array.from(el.querySelectorAll<HTMLElement>(FOCUSABLE_CONTROL)).filter(\n (x) => x.tabIndex >= 0 && !x.closest(\"[hidden],[inert]\"),\n ),\n );\n}\n\nconst FOCUSABLE_CONTROL =\n 'a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex=\"-1\"])';\n\n/** A touch screen: the card takes focus, so no keyboard or pad opens before the step is read (§11.8). */\nfunction coarsePointer(): boolean {\n return typeof window !== \"undefined\" && typeof window.matchMedia === \"function\"\n ? window.matchMedia(\"(pointer: coarse)\").matches\n : false;\n}\n\nfunction TourOverlay({\n steps,\n index,\n via,\n floor,\n position,\n count,\n refusal,\n onGoTo,\n labels,\n gates,\n dockOnPhones,\n onNext,\n onPrev,\n onSkip,\n}: {\n steps: TourStep[];\n index: number;\n via: TourStepContext[\"via\"];\n floor: number;\n /** The app refused this step's save (§11.4). */\n refusal: Refusal | null;\n onGoTo: (index: number) => void;\n /** 1-based among the steps shown; Back is hidden on the first, Done on the last. */\n position: number;\n count: number;\n labels: TourLabels;\n gates: GateRegistry;\n dockOnPhones: boolean;\n onNext: () => void;\n onPrev: () => void;\n onSkip: () => void;\n}) {\n const step = steps[index];\n const isFirst = position <= 1;\n const isLast = position >= count;\n // A new step starts unlocated: whatever was found for another step (see `Located`)\n // is ignored, so the overlay renders nothing until the effect below has located THIS\n // step, and never the previous step's spotlight.\n const [located, setLocated] = useState<Located | null>(null);\n const current = located !== null && located.index === index && located.step === step ? located : null;\n const ready = current !== null;\n const rect = current?.rect ?? null;\n // The overlay is portalled to <body>, out of whatever `dir` subtree the app set, so it\n // takes the direction of the element it spotlights (the document's for a centered\n // step). Arrow keys and start/end placement read it.\n const dir: Direction = current?.dir ?? \"ltr\";\n const rootRef = useRef<HTMLDivElement>(null);\n const cardRef = useRef<HTMLDivElement>(null);\n const bodyId = useId();\n const hintId = useId();\n\n // The gate (§11.1). Re-rendered on every registry change while the tour runs.\n const gateVersion = useSyncExternalStore(gates.subscribe, gates.version, gates.version);\n const gateKey = step.gate;\n const enforced = !!gateKey && gates.has(gateKey);\n const locked = enforced && gates.get(gateKey) !== true;\n\n // The polite live region (§11.8): `gateReady` once a gate opens, the hint on a locked\n // Next. A repeat of the same words gets a trailing zero-width space so it is read again.\n const [polite, setPolite] = useState(\"\");\n const announce = useCallback((text: string) => {\n setPolite((prev) => (prev === text ? `${text}\\u200b` : text));\n }, []);\n\n // Run beforeStep, then locate the target (retrying across route/render lag).\n useEffect(() => {\n let cancelled = false;\n let raf = 0;\n // `null` = untargeted, or the finder gave up → the card centres, with no hole.\n const settle = (el: Element | null) => {\n let layer: HTMLElement | null = null;\n let fullScreen = false;\n if (el && isFieldStep(step)) {\n // §11.6: directly above the layer holding the field — DOM order decides between\n // the kit's z-50 body children, so this paints over the host and everything opened\n // before it, and under whatever the field opens next (a list, the number pad).\n const host = layerHost(el);\n layer = document.createElement(\"div\");\n layer.setAttribute(\"data-tour-layer\", \"\");\n if (host) host.after(layer);\n else document.body.appendChild(layer);\n fullScreen = !!host && coversViewport(host, el);\n }\n setLocated({ index, step, rect: el ? spotRectOf(el, step) : null, dir: dirOf(el), layer, fullScreen });\n };\n void (async () => {\n await step.beforeStep?.(stepContext(gates, via));\n if (cancelled) return;\n if (!step.target) {\n settle(null);\n return;\n }\n let tries = 0;\n const find = () => {\n if (cancelled) return;\n const el = queryVisibleTarget(step.target!);\n if (el) {\n // A docked step scrolls the field into the half the card leaves free, through\n // the field's own scroll container (§11.7); any other centres it, as ever.\n if (docks(step, dockOnPhones)) scrollIntoFreeHalf(el, null, null);\n else el.scrollIntoView({ block: \"center\", behavior: \"smooth\" });\n settle(el);\n return;\n }\n if (tries++ < 45) raf = requestAnimationFrame(find);\n else settle(null); // give up → render centered\n };\n find();\n })();\n return () => {\n cancelled = true;\n cancelAnimationFrame(raf);\n };\n // `via` and the gates are read at arrival, not followed.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [index, step]);\n\n // Follow the target as the page scrolls / reflows — only once THIS step is located,\n // and only into this step's result.\n useEffect(() => {\n if (!step.target) return;\n const update = () => {\n const el = queryVisibleTarget(step.target!);\n if (el) {\n const next = spotRectOf(el, step);\n // A sheet that grows to full screen (or shrinks from it) takes or drops the scrim.\n const host = layerHost(el);\n const full = !!host && coversViewport(host, el);\n setLocated((prev) => {\n if (!prev || prev.index !== index || prev.step !== step) return prev;\n const fullScreen = prev.layer ? full : prev.fullScreen;\n if (sameRect(prev.rect, next) && fullScreen === prev.fullScreen) return prev;\n return { ...prev, rect: next, fullScreen };\n });\n }\n };\n window.addEventListener(\"scroll\", update, true);\n window.addEventListener(\"resize\", update);\n const id = window.setInterval(update, 250);\n return () => {\n window.removeEventListener(\"scroll\", update, true);\n window.removeEventListener(\"resize\", update);\n clearInterval(id);\n };\n }, [index, step]);\n\n // A field step's container goes with the step (and with the tour).\n const layer = located?.layer ?? null;\n useEffect(() => {\n if (!layer) return;\n return () => layer.remove();\n }, [layer]);\n\n // Escape (§11.6.4): the tour is a layer on the kit's Escape stack, pushed on each\n // arrival, so it sits above the sheet holding the form. Escape from the card skips the\n // tour and no longer also closes that sheet; a layer the field opens afterwards (a\n // list, the pad) is above the tour and takes Escape first. An Escape pressed in the\n // field itself belongs to the field: the tour lets it pass by doing nothing.\n useDismissLayer(\n ready,\n (e) => {\n if (fieldStepNow && step.target && e.target instanceof Node) {\n const el = queryVisibleTarget(step.target);\n if (el?.contains(e.target)) return;\n }\n onSkip();\n },\n // Not an overlay to `useOverlayOpen`: a floating launcher a tour spotlights stays.\n { overlay: false },\n );\n\n // awaitClick: advance when the *real* target is clicked. The spotlight hole is\n // click-through (see the shields in the render below) so the element's own\n // handler runs first; we step forward on the next macrotask.\n //\n // Re-armed when the target turns up after the finder gave up (the follow effect\n // lights it late): the card swaps Next for the \"click the highlighted element\" hint\n // as soon as there is a rect, so the click must work from that moment too.\n const spotted = rect !== null;\n useEffect(() => {\n if (!ready || !spotted || !step.awaitClick || !step.target) return;\n const el = queryVisibleTarget(step.target);\n if (!el) return;\n const onClick = () => window.setTimeout(() => onNext(), 0);\n el.addEventListener(\"click\", onClick, { once: true });\n return () => el.removeEventListener(\"click\", onClick);\n }, [ready, spotted, index, step, onNext]);\n\n // A field step (see `TourStep.interactive`): only while the target is lit — a step\n // whose target is missing centres its card over a full scrim, modal as ever.\n const interactive =\n spotted && !!step.target && !!(step.interactive || step.awaitInput || step.gate || step.awaitGate);\n // A GUIDED field step (§11.8): focus goes to the field on a fine pointer, and Tab\n // cycles field + card. A plain `interactive` step keeps the card's own trap.\n const guided = interactive && !!(step.gate || step.awaitInput || step.awaitGate);\n const fieldStepNow = interactive;\n // An awaitGate step whose target is lit: only `release` moves it (a missing Save\n // button would otherwise be a dead end, as for awaitClick).\n const awaitsRelease = spotted && !!step.target && !!step.awaitGate;\n\n // A gate nobody publishes is not enforced: Next opens, and a development build says why\n // (on arrival, or when its publisher unmounts under the step), once per step.\n const warnedGateRef = useRef<TourStep | null>(null);\n useEffect(() => {\n if (!ready || !gateKey || gates.has(gateKey) || !devWarnings() || warnedGateRef.current === step) return;\n warnedGateRef.current = step;\n console.warn(\n `[ui-kit] Tour step \"${step.title}\" waits for the gate \"${gateKey}\", which nothing publishes: its Next is open. ` +\n \"Publish it with useTourGate beside the field, or the form has closed under the tour.\",\n );\n }, [ready, gateKey, gates, step, gateVersion]);\n\n // `optional` means \"may stay EMPTY\": without a gate there is no value to compare.\n useEffect(() => {\n if (!ready || !step.optional || step.gate || !devWarnings()) return;\n console.warn(\n `[ui-kit] Tour step \"${step.title}\" is \\`optional\\` without a \\`gate\\`: it shows the Optional chip ` +\n \"and a plain Next. \\\"Leave empty\\\" needs a gate to compare.\",\n );\n }, [ready, step]);\n\n // \"Ready\" once, when this step's gate turns satisfied (not when it arrives satisfied).\n const wasLockedRef = useRef<{ step: TourStep; locked: boolean } | null>(null);\n useEffect(() => {\n if (!ready || !gateKey) return;\n const before = wasLockedRef.current;\n if (before && before.step === step && before.locked && !locked && enforced) announce(labels.gateReady);\n wasLockedRef.current = { step, locked };\n }, [ready, gateKey, step, locked, enforced, announce, labels.gateReady]);\n\n // Arrival on a guided step: the field takes focus on a fine pointer, the card on a\n // coarse one; the field is described by the card's body while the step lasts.\n // Declared BEFORE the advance listeners below, so the focus it moves is not mistaken\n // for the person leaving the field.\n useEffect(() => {\n if (!ready || !guided || !step.target) return;\n const el = queryVisibleTarget(step.target);\n const control = el ? firstFocusable(el) : null;\n // Described BEFORE it is focused, so a screen reader reads the step with the field's\n // name. Focused quietly (0.50.1, keksdose B1): a picker that opens on focus stays\n // closed, or its list would cover the card; ArrowDown, typing or a click opens it.\n const previous = control ? control.getAttribute(\"aria-describedby\") : null;\n if (control) control.setAttribute(\"aria-describedby\", previous ? `${previous} ${bodyId}` : bodyId);\n if (coarsePointer() || !control) cardRef.current?.focus();\n else if (!el!.contains(document.activeElement)) focusQuietly(control);\n if (!control) return;\n return () => {\n if (previous === null) control.removeAttribute(\"aria-describedby\");\n else control.setAttribute(\"aria-describedby\", previous);\n };\n }, [ready, guided, index, step, bodyId]);\n\n // Tab on a guided step cycles field + card as one ring (§11.8): from the field's last\n // stop to the card's first, from the card's last back to the field. Captured on the\n // document, ahead of a sheet's own trap, which would wrap inside the sheet.\n useEffect(() => {\n if (!ready || !guided || !step.target) return;\n const onTab = (e: KeyboardEvent) => {\n if (e.key !== \"Tab\") return;\n const el = queryVisibleTarget(step.target!);\n const card = cardRef.current;\n if (!el || !card) return;\n const active = document.activeElement;\n const fieldStops = tabStops(el);\n const cardStops = tabStops(card);\n if (fieldStops.length === 0 || cardStops.length === 0) return;\n let to: HTMLElement | null = null;\n if (active instanceof Node && el.contains(active)) {\n if (!e.shiftKey && active === fieldStops[fieldStops.length - 1]) to = cardStops[0];\n else if (e.shiftKey && active === fieldStops[0]) to = cardStops[cardStops.length - 1];\n } else if (active instanceof Node && card.contains(active)) {\n if (!e.shiftKey && active === cardStops[cardStops.length - 1]) to = fieldStops[0];\n else if (e.shiftKey && (active === cardStops[0] || active === card)) to = fieldStops[fieldStops.length - 1];\n }\n if (!to) return;\n e.preventDefault();\n e.stopPropagation();\n to.focus();\n };\n document.addEventListener(\"keydown\", onTab, true);\n return () => document.removeEventListener(\"keydown\", onTab, true);\n }, [ready, guided, index, step]);\n\n // gate: once satisfied, advance on Enter in the field (unless the control took it, or\n // a textarea without Ctrl/Cmd) or on focus leaving the field to nowhere or to the card.\n // Checked on the next macrotask, after the field's own blur/Enter commit has rendered.\n useEffect(() => {\n if (!ready || !spotted || !gateKey || !step.target) return;\n const el = queryVisibleTarget(step.target) as HTMLElement | null;\n if (!el) return;\n const satisfied = () => !gates.has(gateKey) || gates.get(gateKey) === true;\n let timer = 0;\n // Focus that was in the field when the step settled, or went there since. A focus\n // move the tour made itself (the card taking it on a phone) is not a leave.\n let armed = el.contains(document.activeElement);\n const check = () => {\n window.clearTimeout(timer);\n timer = window.setTimeout(() => {\n if (satisfied()) onNext();\n }, 0);\n };\n const onFocusIn = () => {\n armed = true;\n };\n const onFocusOut = (e: FocusEvent) => {\n const to = e.relatedTarget;\n if (to instanceof Node && el.contains(to)) return;\n const wasArmed = armed;\n armed = false;\n if (!wasArmed) return;\n if (to === null || (to instanceof Node && rootRef.current?.contains(to))) check();\n };\n const onKeyDown = (e: KeyboardEvent) => {\n if (e.key !== \"Enter\" || !(e.target instanceof Node) || !el.contains(e.target)) return;\n // Heard at the document, after React's handlers: a combobox picking an option has\n // called preventDefault by now.\n if (e.defaultPrevented || isComposing(e)) return;\n if (e.target instanceof HTMLTextAreaElement && !(e.ctrlKey || e.metaKey)) return;\n check();\n };\n el.addEventListener(\"focusin\", onFocusIn);\n el.addEventListener(\"focusout\", onFocusOut);\n document.addEventListener(\"keydown\", onKeyDown);\n return () => {\n window.clearTimeout(timer);\n el.removeEventListener(\"focusin\", onFocusIn);\n el.removeEventListener(\"focusout\", onFocusOut);\n document.removeEventListener(\"keydown\", onKeyDown);\n };\n }, [ready, spotted, gateKey, gates, index, step, onNext]);\n\n // awaitInput: advance once the target's fields hold another value than when the step\n // was armed, checked when focus leaves the target or Enter is pressed in it — on the\n // next macrotask, after the field's own blur/Enter commit has rendered. A value the\n // number pad typed fires no native `change`, so comparing is what catches it.\n useEffect(() => {\n if (!ready || !spotted || !step.awaitInput || !step.target) return;\n const el = queryVisibleTarget(step.target) as HTMLElement | null;\n if (!el) return;\n const read = () => fieldValues(el);\n const before = read();\n let timer = 0;\n let done = false;\n const check = () => {\n window.clearTimeout(timer);\n timer = window.setTimeout(() => {\n if (done || read() === before) return;\n done = true;\n onNext();\n }, 0);\n };\n const onFocusOut = (e: FocusEvent) => {\n if (e.relatedTarget instanceof Node && el.contains(e.relatedTarget)) return;\n check();\n };\n const onKeyDown = (e: KeyboardEvent) => {\n if (e.key === \"Enter\") check();\n };\n el.addEventListener(\"focusout\", onFocusOut);\n el.addEventListener(\"keydown\", onKeyDown);\n el.addEventListener(\"change\", check);\n return () => {\n window.clearTimeout(timer);\n el.removeEventListener(\"focusout\", onFocusOut);\n el.removeEventListener(\"keydown\", onKeyDown);\n el.removeEventListener(\"change\", check);\n };\n }, [ready, spotted, index, step, onNext]);\n\n /** A press on the locked Next (or Enter / → from the card): no move; the field takes\n * focus and the hint is read again. */\n const gateHint = step.gateHint ?? labels.gateHint;\n const lockedNext = useCallback(() => {\n const el = step.target ? queryVisibleTarget(step.target) : null;\n const control = el ? firstFocusable(el) : null;\n // Quietly, as on arrival: the hint is read with the card in view, not under a list.\n if (control) focusQuietly(control);\n announce(gateHint);\n }, [step.target, announce, gateHint]);\n const tryNext = awaitsRelease ? NOOP : locked ? lockedNext : onNext;\n\n // After a refused save: the first earlier step shown whose field is now empty (§11.4).\n // Computed each render, which the gate subscription above triggers: a field filled\n // again drops the link.\n const backTo = refusal ? firstEmptied(steps, floor, index, gates) : -1;\n\n // Keyboard: Esc skips, Enter and the reading-direction arrow advance (→ in LTR,\n // ← in RTL), the other arrow goes back. On awaitClick steps Enter is ignored (it\n // would fire the target's click AND advance) — the forward arrow stays as an escape\n // hatch. On a locked gate step both are the locked Next.\n //\n // Enter on a focused control belongs to that control. This used to advance from\n // anywhere, so Enter on a focused Skip or Back ran the button's own click AND stepped\n // forward: Back moved nowhere, Skip skipped and then called `next` on a dead tour.\n // The same goes for arrows in a text field a step's `action` might contain.\n useEffect(() => {\n const onKey = (e: KeyboardEvent) => {\n // On an interactive step a key pressed in the target, or in a layer it opened (the\n // number pad's Escape, a menu's arrows), is the page's. The card's and the bare\n // page's (focus on <body>) stay the tour's.\n if (interactive && e.target instanceof Node && e.target !== document.body && !rootRef.current?.contains(e.target)) {\n return;\n }\n // Escape is the tour's Escape layer's (above) once the step is shown; while it is\n // still being located there is no layer yet, and the tour takes it here as in 0.49.\n if (e.key === \"Escape\") {\n if (!ready) onSkip();\n return;\n }\n if (e.key === \"Enter\") {\n if (step.awaitClick || step.awaitInput || ownsKey(e.target, \"Enter\")) return;\n e.preventDefault();\n tryNext();\n return;\n }\n if (ownsKey(e.target, e.key)) return;\n // The overlay root carries `dir`; before it paints, the document's answers.\n const delta = horizontalStep(e.key, rootRef.current);\n if (delta === 1) {\n e.preventDefault();\n tryNext();\n } else if (delta === -1) {\n if (!isFirst) onPrev();\n }\n };\n document.addEventListener(\"keydown\", onKey);\n return () => document.removeEventListener(\"keydown\", onKey);\n }, [isFirst, step, interactive, tryNext, onPrev, onSkip, ready]);\n\n if (!ready) return null;\n\n // No scrim, no shields: a field step inside a layer that fills the screen (§11.6.3).\n const bare = interactive && !!current?.fullScreen;\n const pad = step.padding ?? 8;\n const spot: Rect | null = rect\n ? { top: rect.top - pad, left: rect.left - pad, width: rect.width + pad * 2, height: rect.height + pad * 2 }\n : null;\n\n // `aria-modal` promises the page behind is out of reach, and the card's focus trap\n // keeps that promise for the keyboard. The pointer used to get no such treatment: the\n // root is `pointer-events-none` so that the spotlight hole can stay live for\n // `awaitClick`, and the scrim is a box-shadow, which takes no clicks — so every\n // control on the dimmed page stayed clickable. Four shields now tile the viewport\n // around the hole: the page is blocked, the card and the spotlighted target are not.\n // Keeping `aria-modal` (rather than dropping it) is the coherent half: the tour\n // really is modal — focus is trapped and Esc/Skip is the way out.\n return createPortal(\n <div\n ref={rootRef}\n // z-50 on a field step, in its own container right after the layer holding the field\n // (or at the end of <body>): over that layer and the page, under the z-50 layers the\n // field opens next (§11.6). z-[60] on a plain step, over everything.\n className={cn(\"pointer-events-none fixed inset-0\", interactive ? \"z-50\" : \"z-[60]\")}\n role=\"dialog\"\n aria-modal={interactive ? undefined : \"true\"}\n // A stable marker for the overlay, on every step (0.48, keksdose dev#611–613): an\n // app that hides its floating help launcher while a modal is open excepts the\n // tour, which may spotlight that launcher — `[aria-modal=\"true\"]:not([data-tour-overlay])`.\n // keksdose matched the `pointer-events-none` class until now, which is the kit's to change.\n data-tour-overlay=\"\"\n data-tour-interactive={interactive ? \"\" : undefined}\n data-tour-bare={bare ? \"\" : undefined}\n aria-label={step.title}\n dir={dir}\n >\n {/* In a full-screen layer (a phone's form sheet) no scrim and no shields: the rest of\n the form stays usable and scrollable, and the ring alone marks the field. */}\n {spot && !bare && <SpotlightShields spot={spot} />}\n {spot ? (\n <div\n className=\"pointer-events-none fixed rounded-lg transition-all duration-200 ease-out\"\n style={{\n top: spot.top,\n left: spot.left,\n width: spot.width,\n height: spot.height,\n // A two-tone frame, not a single translucent ring.\n //\n // The old treatment was `ring-2 ring-white/80` over a 55% scrim, and it\n // \"was barely visible\" on the app's blue-tinted surfaces. Two reasons,\n // and a single ring can't fix either: at 55% the surround stays bright\n // enough that the un-dimmed hole barely reads AS a hole, and a 80%-white\n // ring sitting on the edge of a light card is white-on-near-white.\n //\n // So: an opaque white band immediately around the target, a dark keyline\n // outside it, then the scrim. Whatever the target's own colour is, one of\n // the two bands is always in contrast with it and the other is always in\n // contrast with the dimmed surround — there is no background that can\n // swallow both. The blurred layer between them softens the step so the\n // frame reads as lighting rather than as a pasted-on rectangle.\n boxShadow: [\n \"0 0 0 3px rgba(255,255,255,0.98)\",\n \"0 0 0 5px rgba(15,23,42,0.92)\",\n \"0 0 18px 6px rgba(15,23,42,0.45)\",\n ...(bare ? [] : [\"0 0 0 9999px rgba(15,23,42,0.70)\"]),\n ].join(\", \"),\n }}\n />\n ) : (\n <div className=\"pointer-events-auto fixed inset-0 bg-black/70\" />\n )}\n <TourCard\n cardRef={cardRef}\n step={step}\n index={index}\n position={position}\n total={count}\n labels={labels}\n isFirst={isFirst}\n isLast={isLast}\n rect={spot}\n dir={dir}\n trap={!guided}\n bodyId={bodyId}\n hintId={hintId}\n locked={locked}\n gateHint={gateHint}\n onBack={onPrev}\n onNext={tryNext}\n onLeaveEmpty={onNext}\n onSkip={onSkip}\n awaitsRelease={awaitsRelease}\n docked={spot !== null && docks(step, dockOnPhones)}\n refusal={refusal}\n backTo={backTo >= 0 ? { title: steps[backTo].title, go: () => onGoTo(backTo) } : null}\n />\n <div className=\"sr-only\" aria-live=\"polite\" aria-atomic=\"true\">\n {polite}\n </div>\n </div>,\n (interactive && current?.layer) || document.body,\n );\n}\n\n/** The values of the fields at or inside `el`, as one string to compare (`awaitInput`). */\nfunction fieldValues(el: Element): string {\n const fields = el.matches(\"input,textarea,select\") ? [el] : Array.from(el.querySelectorAll(\"input,textarea,select\"));\n return fields\n .map((f) =>\n f instanceof HTMLInputElement && (f.type === \"checkbox\" || f.type === \"radio\")\n ? String(f.checked)\n : (f as HTMLInputElement).value,\n )\n .join(\"\\u0000\");\n}\n\n/** Does the focused element handle `key` itself? Enter on a button or link, and any\n * editing key in a text field or select, is the control's — not the tour's. */\nfunction ownsKey(target: EventTarget | null, key: string): boolean {\n if (!(target instanceof HTMLElement)) return false;\n if (target.isContentEditable) return true;\n const tag = target.tagName;\n if (tag === \"TEXTAREA\" || tag === \"SELECT\") return true;\n if (tag === \"INPUT\") {\n const type = (target as HTMLInputElement).type;\n // Enter on a checkbox does nothing natively, but ←/→ on a radio moves it.\n return key !== \"Enter\" || type !== \"checkbox\";\n }\n if (key !== \"Enter\") return false;\n return (\n tag === \"BUTTON\" ||\n (tag === \"A\" && target.hasAttribute(\"href\")) ||\n target.getAttribute(\"role\") === \"button\" ||\n target.getAttribute(\"role\") === \"link\"\n );\n}\n\n/**\n * Transparent pointer blockers tiling the viewport around the spotlight hole: one\n * full-width band above and below, one on each side at the hole's own height. The hole\n * itself stays uncovered, so the target keeps its clicks.\n */\nfunction SpotlightShields({ spot }: { spot: Rect }) {\n const shield = \"pointer-events-auto fixed\";\n const bottom = spot.top + spot.height;\n return (\n <>\n <div data-tour-shield=\"\" className={shield} style={{ top: 0, left: 0, right: 0, height: Math.max(0, spot.top) }} />\n <div data-tour-shield=\"\" className={shield} style={{ top: bottom, left: 0, right: 0, bottom: 0 }} />\n <div\n data-tour-shield=\"\"\n className={shield}\n style={{ top: spot.top, left: 0, width: Math.max(0, spot.left), height: spot.height }}\n />\n <div\n data-tour-shield=\"\"\n className={shield}\n style={{ top: spot.top, left: spot.left + spot.width, right: 0, height: spot.height }}\n />\n </>\n );\n}\n\n/**\n * Card position (viewport px) for the given placement relative to the padded\n * spotlight `rect`. Omitted placement keeps the original auto behavior\n * (below → above → vertically centered); an explicit side flips to its opposite\n * if it would overflow, then clamps into the viewport. \"center\" (or no rect)\n * centers on screen.\n */\nfunction placeCard(\n rect: Rect | null,\n cw: number,\n ch: number,\n vw: number,\n vh: number,\n m: number,\n placement?: TourPlacement,\n dir: Direction = \"ltr\",\n): { top: number; left: number } {\n // The logical sides resolve to a physical one here, and only here.\n if (placement === \"start\") placement = dir === \"rtl\" ? \"right\" : \"left\";\n else if (placement === \"end\") placement = dir === \"rtl\" ? \"left\" : \"right\";\n if (!rect || placement === \"center\") {\n return { top: Math.max(m, (vh - ch) / 2), left: Math.max(m, (vw - cw) / 2) };\n }\n const clampX = (x: number) => Math.min(Math.max(m, x), Math.max(m, vw - cw - m));\n const clampY = (y: number) => Math.min(Math.max(m, y), Math.max(m, vh - ch - m));\n const centerX = clampX(rect.left + rect.width / 2 - cw / 2);\n const centerY = clampY(rect.top + rect.height / 2 - ch / 2);\n const belowTop = rect.top + rect.height + m;\n const aboveTop = rect.top - ch - m;\n const rightLeft = rect.left + rect.width + m;\n const leftLeft = rect.left - cw - m;\n const fitsBelow = belowTop + ch <= vh;\n const fitsAbove = aboveTop >= 0;\n const fitsRight = rightLeft + cw <= vw;\n const fitsLeft = leftLeft >= 0;\n\n switch (placement) {\n case \"top\":\n return { top: fitsAbove ? aboveTop : fitsBelow ? belowTop : clampY(aboveTop), left: centerX };\n case \"bottom\":\n return { top: fitsBelow ? belowTop : fitsAbove ? aboveTop : clampY(belowTop), left: centerX };\n case \"right\":\n return { top: centerY, left: fitsRight ? rightLeft : fitsLeft ? leftLeft : clampX(rightLeft) };\n case \"left\":\n return { top: centerY, left: fitsLeft ? leftLeft : fitsRight ? rightLeft : clampX(leftLeft) };\n default:\n if (fitsBelow) return { top: belowTop, left: centerX };\n if (fitsAbove) return { top: aboveTop, left: centerX };\n return { top: Math.max(m, (vh - ch) / 2), left: centerX };\n }\n}\n\nfunction TourCard({\n cardRef: ref,\n step,\n index,\n position,\n total,\n labels,\n isFirst,\n isLast,\n rect,\n dir,\n trap,\n bodyId,\n hintId,\n locked,\n gateHint,\n onBack,\n onNext,\n onLeaveEmpty,\n onSkip,\n awaitsRelease,\n docked,\n refusal,\n backTo,\n}: {\n cardRef: RefObject<HTMLDivElement | null>;\n step: TourStep;\n index: number;\n /** 1-based among the steps shown (§11.3). */\n position: number;\n /** How many steps the run shows. */\n total: number;\n labels: TourLabels;\n isFirst: boolean;\n isLast: boolean;\n rect: Rect | null;\n dir: Direction;\n /** The card's own focus trap; off on a guided step, where field + card are one ring. */\n trap: boolean;\n bodyId: string;\n hintId: string;\n /** A gate step whose field is not filled yet (§11.1). */\n locked: boolean;\n gateHint: string;\n onBack: () => void;\n onNext: () => void;\n /** Moves on past an `optional` field left empty. */\n onLeaveEmpty: () => void;\n onSkip: () => void;\n /** An awaitGate step with its target lit: the hint in place of Next. */\n awaitsRelease: boolean;\n /** Pinned to the band's edge away from the field (§11.7). */\n docked: boolean;\n refusal: Refusal | null;\n /** The \"Back to …\" link after a refused save. */\n backTo: { title: string; go: () => void } | null;\n}) {\n const [style, setStyle] = useState<CSSProperties>({ opacity: 0 });\n\n /**\n * The card holds the focus, because the card is what the tour IS.\n *\n * The overlay above declares `role=\"dialog\" aria-modal=\"true\"` — it always has — and\n * then left focus wherever the page had put it. For a tour that is the most pointed\n * version of the audit's *\"Only Modal manages focus\"*: the whole component exists to\n * say \"look here\", and for a keyboard user \"here\" is the focus ring. They were told\n * the page was hidden, given no way to reach the Next button without Tabbing through\n * it, and left on a control the screen reader would no longer describe.\n *\n * It re-engages on every step, without any bookkeeping here, because `TourOverlay`\n * returns null while it re-locates the next target: the card genuinely unmounts and\n * remounts between steps. That is what keeps focus honest when the BUTTONS change —\n * \"Back\" does not exist on the first step, so stepping back onto it destroys the\n * control the press came from, and focus would otherwise fall to `<body>`, outside\n * this trap's own listener, where Tab walks straight into the page the overlay claims\n * to have hidden.\n *\n * **The cost, written down:** on an `awaitClick` step the user is asked to click the\n * spotlighted element, and they can no longer Tab to it. ArrowRight still advances\n * (the key handler in `TourOverlay` is on the document and does not care where focus\n * is), which is the escape hatch that step already documents for the case where the\n * target cannot be found. Containment is worth that: an `awaitClick` step is a\n * minority of steps, while focus stranded behind `aria-modal` is every step.\n *\n * A guided field step (`gate`, `awaitInput`, 0.50) is the exception: the field is\n * what the step is about, so the overlay focuses it (or the card, on a touch screen)\n * and runs one Tab ring over field + card itself.\n */\n useFocusTrap(ref, { active: trap });\n\n // Docked (§11.7): the edge it last took, for the hysteresis, and a tick bumped when the\n // band moves under an unmoved field (a pad or keyboard opening).\n const edgeRef = useRef<DockEdge | null>(null);\n const [bandTick, setBandTick] = useState(0);\n const [edge, setEdge] = useState<DockEdge | null>(null);\n useEffect(() => {\n if (!docked) return;\n let last = \"\";\n const look = () => {\n const target = step.target ? queryVisibleTarget(step.target) : null;\n const band = readBand(target, ref.current);\n const key = `${band.top}:${band.bottom}`;\n if (key === last) return;\n last = key;\n // A field the pad or keyboard now covers is brought back into the free half.\n if (target) {\n const r = target.getBoundingClientRect();\n if (r.top < band.top || r.bottom > band.bottom) {\n edgeRef.current = scrollIntoFreeHalf(target, ref.current, edgeRef.current);\n }\n }\n setBandTick((t) => t + 1);\n };\n const vv = window.visualViewport;\n vv?.addEventListener(\"resize\", look);\n vv?.addEventListener(\"scroll\", look);\n window.addEventListener(\"resize\", look);\n // The follow tick's cadence: it catches a pad opening, which moves nothing.\n const id = window.setInterval(look, 250);\n return () => {\n vv?.removeEventListener(\"resize\", look);\n vv?.removeEventListener(\"scroll\", look);\n window.removeEventListener(\"resize\", look);\n clearInterval(id);\n };\n }, [docked, step.target, ref]);\n\n useLayoutEffect(() => {\n const card = ref.current;\n if (!card) return;\n if (docked) {\n const target = step.target ? queryVisibleTarget(step.target) : null;\n const band = readBand(target, card);\n const next = rect ? dockEdge(rect, band, edgeRef.current, card.offsetHeight) : \"bottom\";\n edgeRef.current = next;\n setEdge(next);\n setStyle(dockStyle(next, rect, band));\n return;\n }\n setEdge(null);\n setStyle(\n placeCard(rect, card.offsetWidth, card.offsetHeight, window.innerWidth, window.innerHeight, 12, step.placement, dir),\n );\n }, [ref, rect, index, step.placement, step.target, dir, docked, bandTick]);\n\n const awaitsTarget = ((step.awaitClick || step.awaitInput) && step.target && rect) || awaitsRelease;\n\n return (\n <div\n ref={ref}\n // Focusable but not tabbable: the trap above focuses the card itself rather than\n // its first button, so a screen reader reads the step's title and body before it\n // reads \"Next\" — and without this the container cannot take focus at all and the\n // trap silently does nothing.\n tabIndex={-1}\n style={style}\n data-tour-card=\"\"\n data-tour-docked={edge ?? undefined}\n className={cn(\n \"pointer-events-auto fixed z-[61] w-80 max-w-[calc(100vw-1.5rem)] rounded-lg border border-subtle bg-surface p-4 shadow-xl outline-none transition-all duration-200 ease-out\",\n // Docked, the height is capped: the body scrolls, the title and buttons stay.\n docked && \"flex flex-col\",\n )}\n >\n <div className=\"flex flex-wrap items-center gap-x-2 gap-y-1 text-sm font-semibold text-primary\">\n <span>{step.title}</span>\n {step.optional && (\n <span className=\"rounded-full border border-subtle px-1.5 py-px text-xs font-normal text-muted\">\n {labels.optional}\n </span>\n )}\n </div>\n <div\n id={bodyId}\n className={cn(\"mt-1 text-sm leading-relaxed text-secondary\", docked && \"min-h-0 shrink overflow-y-auto\")}\n >\n {step.body}\n </div>\n {step.action && <div className=\"mt-3\">{step.action}</div>}\n <div className=\"mt-4 space-y-2\">\n <div className=\"flex items-center justify-between gap-2\">\n <button\n type=\"button\"\n onClick={onSkip}\n className=\"text-xs text-placeholder hover:text-secondary\"\n >\n {labels.skip}\n </button>\n <div className=\"flex items-center gap-2\">\n <span className=\"whitespace-nowrap text-xs tabular-nums text-placeholder\">\n {labels.step(position, total)}\n </span>\n {!isFirst && (\n <Button variant=\"secondary\" onClick={onBack} className=\"px-2.5 py-1 text-xs\">\n {labels.back}\n </Button>\n )}\n {/* On an awaitClick step the Next button is replaced by a hint on its\n own row below, so it doesn't cram the counter + buttons and wrap.\n Only when the target was actually FOUND, though — `rect` is null\n when the finder gave up, and the click listener early-returns on\n the same absence. Keyed on `step.target` alone this hid the only\n way forward on any step whose anchor happens not to be rendered\n for this user (a guest sees no \"add account\" button), leaving the\n undocumented ArrowRight key as the sole escape. */}\n {/* \"Leave empty\" (§11.2): an optional field may stay empty, so the step can\n move on without it. Gone once the field is filled. */}\n {step.optional && locked && !awaitsTarget && (\n <Button variant=\"secondary\" onClick={onLeaveEmpty} className=\"px-2.5 py-1 text-xs\">\n {labels.leaveEmpty}\n </Button>\n )}\n {!awaitsTarget && (\n <Button\n variant=\"accent\"\n onClick={onNext}\n // Locked, not disabled (§11.1): it stays focusable, and a press focuses the\n // field and reads the hint again.\n aria-disabled={locked || undefined}\n aria-describedby={locked ? hintId : undefined}\n className={cn(\"px-2.5 py-1 text-xs\", locked && \"opacity-60\")}\n >\n {isLast ? labels.done : labels.next}\n </Button>\n )}\n </div>\n </div>\n {awaitsTarget && (\n <div className=\"text-center text-xs italic text-placeholder\">\n {awaitsRelease\n ? (step.awaitGateHint ?? labels.awaitGateHint)\n : step.awaitInput && !step.awaitClick\n ? labels.awaitInputHint\n : labels.awaitClickHint}\n </div>\n )}\n {/* Always mounted on an awaitGate step, so a refusal is read out (assertively)\n the moment it lands. */}\n {awaitsRelease && (\n <div aria-live=\"assertive\" aria-atomic=\"true\" className=\"space-y-1\">\n {refusal && (\n <p data-tour-refused=\"\" className=\"text-xs text-danger\">\n {refusal.reason ?? labels.awaitGateRefused}\n {refusal.seq % 2 === 0 ? \"\\u200b\" : \"\"}\n </p>\n )}\n {refusal && backTo && (\n <Button variant=\"link\" onClick={backTo.go} className=\"text-xs\">\n {labels.backToStep(backTo.title)}\n </Button>\n )}\n </div>\n )}\n {locked && !awaitsTarget && (\n <div id={hintId} className=\"text-center text-xs italic text-placeholder\">\n {gateHint}\n </div>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";AAmnBM,SAq1BF,UAl1BM,KAHJ;AAnnBN;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,oBAAoB;AAC7B,SAAS,UAAU;AACnB,SAAS,oBAAwC;AACjD,SAAS,cAAc;AACvB,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB;AAChC,SAAS,gBAAgB;AACzB,SAAS,OAAO,sBAAsB;AACtC,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAE7B,SAAS,2BAA2B;AAEpC,SAAS,gBAAgB,iBAAiB,uBAAoD;AAC9F,SAAS,oBAAoB,aAAa,2BAA8C;AACxF,SAAS,kBAAkB;AAC3B,SAAS,gBAAgB,UAAU,WAAW,UAAU,0BAAyC;AAEjG,SAAS,aAAa,0BAA0B;AA4LhD,MAAM,cAAc;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AA0EA,MAAM,cAAc,cAAuC,IAAI;AAExD,SAAS,UAA4B;AAC1C,QAAM,MAAM,WAAW,WAAW;AAClC,MAAI,CAAC,IAAK,OAAM,IAAI,MAAM,4CAA4C;AACtE,SAAO;AACT;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,QAAO,WAAU,aACrD;AAAA,uBACC,qBAAC,OAAE,qBAAkB,IAAG,WAAU,uBAC/B;AAAA,sBAAQ,UAAU,OAAO;AAAA,cACzB,QAAQ,MAAM,MAAM,IAAI,WAAW;AAAA,eACtC;AAAA,YAED,WAAW,UACV,oBAAC,UAAO,SAAQ,QAAO,SAAS,OAAO,IAAI,WAAU,WAClD,iBAAO,WAAW,OAAO,KAAK,GACjC;AAAA,aAEJ;AAAA,UAED,UAAU,CAAC,gBACV,oBAAC,SAAI,IAAI,QAAQ,WAAU,+CACxB,oBACH;AAAA,WAEJ;AAAA;AAAA;AAAA,EACF;AAEJ;","names":["layer"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type TourStart } from "./tour.js";
|
|
1
|
+
import { type TourEngine, type TourStart } from "./tour.js";
|
|
2
2
|
export interface UseTourUrlSyncOptions {
|
|
3
3
|
/**
|
|
4
4
|
* Start the tour `id` at `startIndex` (0-based) — the app's launcher, which builds the
|
|
@@ -6,11 +6,13 @@ export interface UseTourUrlSyncOptions {
|
|
|
6
6
|
* toast) to `useTour().start`. An unknown id should do nothing. May return a promise:
|
|
7
7
|
* the parameters are kept until it settles. Under a `TourProvider` the third argument is
|
|
8
8
|
* that provider's `start` (0.50, as `TourProvider launch` gets it), so one launcher serves
|
|
9
|
-
* both
|
|
9
|
+
* both; the fourth is its whole engine, read live (0.50.1, `TourEngine`: `stop`, `next`,
|
|
10
|
+
* `active`, …). Without a provider `start` and the engine's methods do nothing (a
|
|
11
|
+
* development build warns) and the engine reads as idle.
|
|
10
12
|
*/
|
|
11
13
|
launch: (id: string, options: {
|
|
12
14
|
startIndex: number;
|
|
13
|
-
}, start: TourStart) => void | Promise<unknown>;
|
|
15
|
+
}, start: TourStart, engine: TourEngine) => void | Promise<unknown>;
|
|
14
16
|
/**
|
|
15
17
|
* Are the facts a tour's steps are built from loaded yet (keksdose's `ready`: the
|
|
16
18
|
* caches a branching tour reads)? A deep link waits for it, keeping its parameters, so
|