stimeo-ui 0.6.0 → 0.7.0
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/CHANGELOG.md +62 -0
- package/dist/controllers/alert_dialog_controller.d.ts +2 -0
- package/dist/controllers/alert_dialog_controller.js +75 -4
- package/dist/controllers/alert_dialog_controller.js.map +1 -1
- package/dist/controllers/auto_submit_controller.d.ts +2 -0
- package/dist/controllers/auto_submit_controller.js.map +1 -1
- package/dist/controllers/avatar_controller.js +47 -5
- package/dist/controllers/avatar_controller.js.map +1 -1
- package/dist/controllers/breadcrumb_controller.d.ts +2 -0
- package/dist/controllers/breadcrumb_controller.js.map +1 -1
- package/dist/controllers/bulk_select_controller.d.ts +2 -0
- package/dist/controllers/bulk_select_controller.js.map +1 -1
- package/dist/controllers/calendar_controller.d.ts +2 -0
- package/dist/controllers/calendar_controller.js.map +1 -1
- package/dist/controllers/character_counter_controller.d.ts +52 -20
- package/dist/controllers/character_counter_controller.js +338 -63
- package/dist/controllers/character_counter_controller.js.map +1 -1
- package/dist/controllers/checkbox_controller.d.ts +3 -0
- package/dist/controllers/checkbox_controller.js.map +1 -1
- package/dist/controllers/color_picker_controller.d.ts +3 -0
- package/dist/controllers/color_picker_controller.js.map +1 -1
- package/dist/controllers/combobox_controller.d.ts +2 -0
- package/dist/controllers/combobox_controller.js.map +1 -1
- package/dist/controllers/command_palette_controller.d.ts +2 -0
- package/dist/controllers/command_palette_controller.js +75 -4
- package/dist/controllers/command_palette_controller.js.map +1 -1
- package/dist/controllers/conditional_fields_controller.d.ts +42 -14
- package/dist/controllers/conditional_fields_controller.js +345 -51
- package/dist/controllers/conditional_fields_controller.js.map +1 -1
- package/dist/controllers/confirm_controller.d.ts +2 -0
- package/dist/controllers/confirm_controller.js +75 -4
- package/dist/controllers/confirm_controller.js.map +1 -1
- package/dist/controllers/count_up_controller.d.ts +2 -0
- package/dist/controllers/count_up_controller.js.map +1 -1
- package/dist/controllers/countdown_controller.d.ts +4 -0
- package/dist/controllers/countdown_controller.js.map +1 -1
- package/dist/controllers/currency_input_controller.d.ts +2 -0
- package/dist/controllers/currency_input_controller.js.map +1 -1
- package/dist/controllers/data_grid_controller.d.ts +3 -0
- package/dist/controllers/data_grid_controller.js.map +1 -1
- package/dist/controllers/dialog_controller.js +75 -4
- package/dist/controllers/dialog_controller.js.map +1 -1
- package/dist/controllers/direct_upload_controller.d.ts +56 -24
- package/dist/controllers/direct_upload_controller.js +201 -45
- package/dist/controllers/direct_upload_controller.js.map +1 -1
- package/dist/controllers/dirty_form_controller.d.ts +14 -6
- package/dist/controllers/dirty_form_controller.js +192 -29
- package/dist/controllers/dirty_form_controller.js.map +1 -1
- package/dist/controllers/dismissible_controller.d.ts +2 -0
- package/dist/controllers/dismissible_controller.js +83 -18
- package/dist/controllers/dismissible_controller.js.map +1 -1
- package/dist/controllers/drawer_controller.js +75 -4
- package/dist/controllers/drawer_controller.js.map +1 -1
- package/dist/controllers/empty_state_controller.d.ts +2 -0
- package/dist/controllers/empty_state_controller.js.map +1 -1
- package/dist/controllers/file_dropzone_controller.d.ts +2 -0
- package/dist/controllers/file_dropzone_controller.js.map +1 -1
- package/dist/controllers/filter_controller.d.ts +2 -0
- package/dist/controllers/filter_controller.js.map +1 -1
- package/dist/controllers/flash_controller.d.ts +4 -0
- package/dist/controllers/flash_controller.js.map +1 -1
- package/dist/controllers/focus_controller.d.ts +2 -0
- package/dist/controllers/focus_controller.js +75 -4
- package/dist/controllers/focus_controller.js.map +1 -1
- package/dist/controllers/form_field_controller.d.ts +50 -10
- package/dist/controllers/form_field_controller.js +280 -62
- package/dist/controllers/form_field_controller.js.map +1 -1
- package/dist/controllers/form_validation_controller.d.ts +10 -8
- package/dist/controllers/form_validation_controller.js +208 -83
- package/dist/controllers/form_validation_controller.js.map +1 -1
- package/dist/controllers/frame_loading_controller.d.ts +2 -0
- package/dist/controllers/frame_loading_controller.js.map +1 -1
- package/dist/controllers/highlight_controller.d.ts +2 -0
- package/dist/controllers/highlight_controller.js.map +1 -1
- package/dist/controllers/idle_controller.d.ts +2 -0
- package/dist/controllers/idle_controller.js.map +1 -1
- package/dist/controllers/input_mask_controller.d.ts +2 -0
- package/dist/controllers/input_mask_controller.js.map +1 -1
- package/dist/controllers/lazy_frame_controller.d.ts +2 -0
- package/dist/controllers/lazy_frame_controller.js.map +1 -1
- package/dist/controllers/listbox_controller.d.ts +2 -0
- package/dist/controllers/listbox_controller.js.map +1 -1
- package/dist/controllers/local_time_controller.d.ts +2 -0
- package/dist/controllers/local_time_controller.js.map +1 -1
- package/dist/controllers/masonry_controller.d.ts +2 -0
- package/dist/controllers/masonry_controller.js.map +1 -1
- package/dist/controllers/meter_controller.d.ts +2 -0
- package/dist/controllers/meter_controller.js.map +1 -1
- package/dist/controllers/multi_select_controller.d.ts +2 -0
- package/dist/controllers/multi_select_controller.js.map +1 -1
- package/dist/controllers/nested_form_controller.d.ts +2 -0
- package/dist/controllers/nested_form_controller.js.map +1 -1
- package/dist/controllers/network_status_controller.d.ts +2 -0
- package/dist/controllers/network_status_controller.js.map +1 -1
- package/dist/controllers/number_input_controller.d.ts +2 -0
- package/dist/controllers/number_input_controller.js +47 -5
- package/dist/controllers/number_input_controller.js.map +1 -1
- package/dist/controllers/otp_controller.d.ts +3 -0
- package/dist/controllers/otp_controller.js.map +1 -1
- package/dist/controllers/overflow_indicator_controller.d.ts +2 -0
- package/dist/controllers/overflow_indicator_controller.js.map +1 -1
- package/dist/controllers/overflow_menu_controller.d.ts +2 -0
- package/dist/controllers/overflow_menu_controller.js +2 -1
- package/dist/controllers/overflow_menu_controller.js.map +1 -1
- package/dist/controllers/pagination_controller.d.ts +2 -0
- package/dist/controllers/pagination_controller.js +2 -1
- package/dist/controllers/pagination_controller.js.map +1 -1
- package/dist/controllers/password_reveal_controller.d.ts +2 -0
- package/dist/controllers/password_reveal_controller.js.map +1 -1
- package/dist/controllers/password_strength_controller.d.ts +2 -0
- package/dist/controllers/password_strength_controller.js.map +1 -1
- package/dist/controllers/persist_controller.d.ts +30 -16
- package/dist/controllers/persist_controller.js +432 -122
- package/dist/controllers/persist_controller.js.map +1 -1
- package/dist/controllers/pointer_drag_controller.d.ts +3 -0
- package/dist/controllers/pointer_drag_controller.js.map +1 -1
- package/dist/controllers/popover_controller.js +77 -4
- package/dist/controllers/popover_controller.js.map +1 -1
- package/dist/controllers/portal_controller.d.ts +2 -0
- package/dist/controllers/portal_controller.js.map +1 -1
- package/dist/controllers/preview_guard_controller.d.ts +2 -0
- package/dist/controllers/preview_guard_controller.js.map +1 -1
- package/dist/controllers/progress_controller.d.ts +3 -0
- package/dist/controllers/progress_controller.js.map +1 -1
- package/dist/controllers/radio_group_controller.d.ts +3 -0
- package/dist/controllers/radio_group_controller.js.map +1 -1
- package/dist/controllers/rating_controller.d.ts +2 -0
- package/dist/controllers/rating_controller.js +9 -5
- package/dist/controllers/rating_controller.js.map +1 -1
- package/dist/controllers/reading_progress_controller.d.ts +2 -0
- package/dist/controllers/reading_progress_controller.js.map +1 -1
- package/dist/controllers/resizable_controller.d.ts +2 -0
- package/dist/controllers/resizable_controller.js.map +1 -1
- package/dist/controllers/roving_controller.d.ts +2 -0
- package/dist/controllers/roving_controller.js.map +1 -1
- package/dist/controllers/scroll_area_controller.d.ts +23 -15
- package/dist/controllers/scroll_area_controller.js +462 -162
- package/dist/controllers/scroll_area_controller.js.map +1 -1
- package/dist/controllers/scroll_visibility_controller.d.ts +2 -0
- package/dist/controllers/scroll_visibility_controller.js.map +1 -1
- package/dist/controllers/scrollspy_controller.d.ts +2 -0
- package/dist/controllers/scrollspy_controller.js.map +1 -1
- package/dist/controllers/separator_controller.d.ts +54 -11
- package/dist/controllers/separator_controller.js +354 -38
- package/dist/controllers/separator_controller.js.map +1 -1
- package/dist/controllers/sidebar_controller.js +83 -10
- package/dist/controllers/sidebar_controller.js.map +1 -1
- package/dist/controllers/skeleton_controller.d.ts +2 -0
- package/dist/controllers/skeleton_controller.js.map +1 -1
- package/dist/controllers/slider_controller.d.ts +2 -0
- package/dist/controllers/slider_controller.js.map +1 -1
- package/dist/controllers/smart_sticky_header_controller.d.ts +2 -0
- package/dist/controllers/smart_sticky_header_controller.js.map +1 -1
- package/dist/controllers/spinner_controller.d.ts +2 -0
- package/dist/controllers/spinner_controller.js.map +1 -1
- package/dist/controllers/step_indicator_controller.d.ts +2 -0
- package/dist/controllers/step_indicator_controller.js.map +1 -1
- package/dist/controllers/stepper_controller.d.ts +2 -0
- package/dist/controllers/stepper_controller.js.map +1 -1
- package/dist/controllers/stick_to_bottom_controller.d.ts +2 -0
- package/dist/controllers/stick_to_bottom_controller.js.map +1 -1
- package/dist/controllers/sticky_observer_controller.d.ts +2 -0
- package/dist/controllers/sticky_observer_controller.js.map +1 -1
- package/dist/controllers/submit_once_controller.d.ts +94 -38
- package/dist/controllers/submit_once_controller.js +399 -121
- package/dist/controllers/submit_once_controller.js.map +1 -1
- package/dist/controllers/switch_controller.d.ts +2 -0
- package/dist/controllers/switch_controller.js.map +1 -1
- package/dist/controllers/tags_input_controller.d.ts +2 -0
- package/dist/controllers/tags_input_controller.js.map +1 -1
- package/dist/controllers/textarea_autosize_controller.d.ts +2 -0
- package/dist/controllers/textarea_autosize_controller.js.map +1 -1
- package/dist/controllers/theme_controller.d.ts +2 -0
- package/dist/controllers/theme_controller.js +8 -6
- package/dist/controllers/theme_controller.js.map +1 -1
- package/dist/controllers/time_picker_controller.d.ts +2 -0
- package/dist/controllers/time_picker_controller.js.map +1 -1
- package/dist/controllers/toast_controller.d.ts +4 -0
- package/dist/controllers/toast_controller.js.map +1 -1
- package/dist/controllers/toggle_group_controller.d.ts +2 -0
- package/dist/controllers/toggle_group_controller.js.map +1 -1
- package/dist/controllers/toolbar_controller.js.map +1 -1
- package/dist/controllers/transition_controller.d.ts +2 -0
- package/dist/controllers/transition_controller.js.map +1 -1
- package/dist/controllers/tree_view_controller.d.ts +2 -0
- package/dist/controllers/tree_view_controller.js +2 -1
- package/dist/controllers/tree_view_controller.js.map +1 -1
- package/dist/index.js +2387 -861
- package/dist/index.js.map +1 -1
- package/dist/inspector/cli.d.ts +107 -3
- package/dist/inspector/cli.js +192 -14
- package/dist/inspector/cli.js.map +1 -1
- package/dist/inspector/cli_bin.js +254 -46
- package/dist/inspector/cli_bin.js.map +1 -1
- package/dist/inspector/examples.json +7 -7
- package/dist/inspector/manifest.json +434 -44
- package/dist/positioning/index.d.ts +2 -0
- package/dist/positioning/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/intersection_watcher.ts","../../src/utils/reduced_motion.ts","../../src/controllers/scrollspy_controller.ts"],"names":[],"mappings":";;;;;AAmDO,IAAM,sBAAN,MAA0B;AAAA,EACtB,UAAA;AAAA,EACT,SAAA,GAAyC,IAAA;AAAA,EACzC,OAAA,GAAU,KAAA;AAAA,EACV,sBAAA,GAAyB,KAAA;AAAA,EAEzB,YAAY,SAAA,EAA2D;AACrE,IAAA,IAAA,CAAK,UAAA,GAAa,SAAA;AAAA,EACpB;AAAA;AAAA,EAGA,IAAI,MAAA,GAAkB;AACpB,IAAA,OAAO,IAAA,CAAK,OAAA;AAAA,EACd;AAAA;AAAA,EAGA,IAAI,qBAAA,GAAiC;AACnC,IAAA,OAAO,IAAA,CAAK,sBAAA;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAeA,KAAA,CAAM,OAAA,EAAuC,OAAA,GAAoC,EAAC,EAAY;AAC5F,IAAA,IAAA,CAAK,IAAA,EAAK;AACV,IAAA,IAAI,OAAO,oBAAA,KAAyB,WAAA,EAAa,OAAO,KAAA;AACxD,IAAA,MAAM,OAAO,KAAA,CAAM,OAAA,CAAQ,OAAO,CAAA,GAAK,OAAA,GAAiC,CAAC,OAAkB,CAAA;AAC3F,IAAA,IAAI,IAAA,CAAK,MAAA,KAAW,CAAA,EAAG,OAAO,KA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,EAAa;AACnC,MAAA,IAAI,IAAA,CAAK,YAAA,CAAa,cAAc,CAAA,KAAM,UAAA,EAAY;AACtD,MAAA,MAAM,EAAA,GAAK,IAAA,CAAK,YAAA,CAAa,IAAI,CAAA;AACjC,MAAA,IAAI,IAAI,OAAO,EAAA;AAAA,IACjB;AACA,IAAA,OAAO,EAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBA,aAAa,IAAA,EAAkC;AAC7C,IAAA,OACE,IAAA,CAAK,WAAA,CAAY,IAAA,CAAK,YAAA,CAAa,MAAM,CAAC,CAAA,IAC1C,IAAA,CAAK,WAAA,CAAY,IAAA,CAAK,YAAA,CAAa,WAAW,CAAC,CAAA;AAAA,EAEnD;AAAA;AAAA,EAGA,YAAY,KAAA,EAAqC;AAC/C,IAAA,IAAI,CAAC,KAAA,EAAO,UAAA,CAAW,GAAG,GAAG,OAAO,IAAA;AACpC,IAAA,OAAO,KAAA,CAAM,SAAA,CAAU,CAAC,CAAA,IAAK,IAAA;AAAA,EAC/B;AACF","file":"scrollspy_controller.js","sourcesContent":["/**\n * Shared `IntersectionObserver` plumbing for Stimeo's scroll-triggered\n * controllers (`intersection`, `scrollspy`, `sticky-observer`, `lazy-frame`).\n *\n * It centralizes the `IntersectionObserver` support guard, root resolution from\n * a selector, observer creation/teardown, the **active guard** (the browser may\n * flush a final queued callback batch right after `disconnect()`, and a\n * detached controller must not mutate possibly-cached DOM), and the\n * unobserve→observe **re-arm** that re-delivers the current state even when the\n * target never leaves the viewport.\n *\n * Like {@link RovingTabindex} and `FocusTrap`, this is a policy-free internal\n * util: what an intersection *means* (a spied link, a stuck header, a lazy\n * load) stays in each controller. The public `stimeo--intersection` controller\n * is its thin declarative face.\n */\n/**\n * Whether `entry`'s target sits entirely before the root's **start (top)** edge —\n * the \"scrolled past the top\" half of a non-intersecting entry, as opposed to\n * \"not reached yet\" below the root.\n *\n * A target with no layout box (`display: none`, a `hidden` ancestor, a collapsed\n * `<details>`) is reported with an **empty rect**, whose `bottom` of `0` would\n * otherwise satisfy `bottom <= rootTop` for a viewport root and read as \"passed\"\n * even though the target was never scrolled anywhere. An empty rect carries no\n * position at all, so it is deliberately never \"before the edge\"; what a caller\n * publishes for that case is its own policy (both consumers treat it as the\n * neutral \"not passed\"/\"not stuck\", and the real rect that arrives once the\n * target is laid out re-establishes the true state).\n */\nexport function isBeforeRootStart(entry: IntersectionObserverEntry): boolean {\n const rect = entry.boundingClientRect;\n if (rect.width === 0 && rect.height === 0) return false;\n // rootBounds is null for a cross-origin/removed root; fall back to the\n // viewport origin.\n const rootTop = entry.rootBounds?.top ?? 0;\n return rect.bottom <= rootTop;\n}\n\nexport interface IntersectionWatchOptions {\n /**\n * The observation root. Pass an element (or `null` for the viewport) when\n * the caller already resolved it; omit to resolve from `rootSelector`.\n */\n root?: Element | null;\n /** Selector for the observation root; empty/omitted = viewport. */\n rootSelector?: string;\n rootMargin?: string;\n threshold?: number | number[];\n}\n\nexport class IntersectionWatcher {\n readonly #onEntries: (entries: IntersectionObserverEntry[]) => void;\n #observer: IntersectionObserver | null = null;\n #active = false;\n #usingPlatformDefaults = false;\n\n constructor(onEntries: (entries: IntersectionObserverEntry[]) => void) {\n this.#onEntries = onEntries;\n }\n\n /** Whether an observer is live (started, `IntersectionObserver` supported). */\n get active(): boolean {\n return this.#active;\n }\n\n /** Whether the live observer discarded configured options after construction failed. */\n get usingPlatformDefaults(): boolean {\n return this.#usingPlatformDefaults;\n }\n\n /**\n * (Re)creates the observer and observes `targets`. Returns `false` — leaving\n * the watcher inert — without `IntersectionObserver` support (very old\n * browsers; the caller's no-JS fallback stays in charge) or with no targets.\n * If initial construction with the configured options fails, the watcher\n * warns and retries once with the same root and platform defaults.\n *\n * @throws The fallback constructor error if both construction attempts fail,\n * or whatever the platform throws from `observe()`. The exception is passed\n * through unchanged, but the watcher rolls back first: every target observed\n * so far is released and `active` stays `false`, so a caller that retries\n * starts from a clean slate.\n */\n start(targets: Element | readonly Element[], options: IntersectionWatchOptions = {}): boolean {\n this.stop();\n if (typeof IntersectionObserver === \"undefined\") return false;\n const list = Array.isArray(targets) ? (targets as readonly Element[]) : [targets as Element];\n if (list.length === 0) return false;\n\n const root =\n \"root\" in options\n ? (options.root ?? null)\n : options.rootSelector\n ? document.querySelector(options.rootSelector)\n : null;\n\n let observer: IntersectionObserver | null = null;\n try {\n const onEntries = (entries: IntersectionObserverEntry[]): void => {\n // Identity matters across an immediate restart: the old observer can\n // flush a queued batch after the new observer has made `active` true.\n if (this.#active && this.#observer === observer) this.#onEntries(entries);\n };\n try {\n observer = new IntersectionObserver(onEntries, {\n root,\n rootMargin: options.rootMargin,\n threshold: options.threshold,\n });\n } catch (error) {\n console.warn(\n \"Stimeo UI: IntersectionObserver could not be constructed with the configured options; retrying with platform defaults.\",\n error,\n );\n observer = new IntersectionObserver(onEntries, { root });\n this.#usingPlatformDefaults = true;\n }\n for (const target of list) observer.observe(target);\n this.#observer = observer;\n this.#active = true;\n return true;\n } catch (error) {\n // A constructor or partial observe failure must not leave earlier targets\n // observed or report an active watcher. Preserve the platform exception.\n observer?.disconnect();\n this.#observer = null;\n this.#active = false;\n this.#usingPlatformDefaults = false;\n throw error;\n }\n }\n\n /**\n * Re-delivers `target`'s CURRENT intersection state: `IntersectionObserver`\n * only reports *changes*, but `observe()` always reports the present state,\n * so unobserve→observe turns \"still intersecting\" into a fresh callback.\n *\n * @throws Whatever `unobserve()`/`observe()` throws. The watcher is stopped\n * first, so it never stays live with a half-rearmed target.\n */\n rearm(target: Element): void {\n if (!this.#observer) return;\n try {\n this.#observer.unobserve(target);\n this.#observer.observe(target);\n } catch (error) {\n this.stop();\n throw error;\n }\n }\n\n /** Severs the observer; late queued callbacks become no-ops via the guard. */\n stop(): void {\n this.#active = false;\n this.#observer?.disconnect();\n this.#observer = null;\n this.#usingPlatformDefaults = false;\n }\n}\n","/**\n * Shared `prefers-reduced-motion` lookup for the motion-aware controllers\n * (count-up, highlight, overflow-indicator, scroll-visibility, stick-to-bottom,\n * transition).\n *\n * This one-liner keeps the media query string and the environment guard\n * single-sourced across them. The preference is intentionally re-read on every\n * call — the controllers check it at each animation/scroll start (WCAG 2.2\n * **2.3.3**), so flipping the OS setting takes effect immediately without any\n * listener or cache bookkeeping here.\n */\n\n/**\n * Whether the user currently requests reduced motion.\n *\n * @returns `true` when `(prefers-reduced-motion: reduce)` matches; `false`\n * otherwise, including environments without `window.matchMedia` (treated as\n * \"no preference\").\n */\nexport function prefersReducedMotion(): boolean {\n return (\n typeof window.matchMedia === \"function\" &&\n window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches\n );\n}\n","import { Controller } from \"@hotwired/stimulus\";\nimport { IntersectionWatcher } from \"../utils/intersection_watcher\";\nimport { prefersReducedMotion } from \"../utils/reduced_motion\";\n\n/**\n * The attributes a link may anchor its section with, and therefore the only\n * ones whose rewrite has to re-sync the observation set. `aria-current` — the\n * attribute this controller writes itself — is deliberately absent, so\n * publishing the current location cannot feed back into a rebuild.\n */\nconst ANCHOR_ATTRIBUTES = [\"href\", \"data-href\"];\n\n/**\n * Headless, accessible **Scrollspy**: keeps a table of contents in sync with the\n * section the reader is currently in, published as `aria-current=\"location\"`.\n * There is no dedicated APG widget; it follows the `aria-current`\n * current-location practice inside a `<nav>` landmark.\n *\n * Markup contract (identifier: `stimeo--scrollspy`):\n * <nav data-controller=\"stimeo--scrollspy\"\n * data-stimeo--scrollspy-offset-value=\"80\"\n * data-stimeo--scrollspy-root-selector-value=\".content\"\n * aria-label=\"Table of contents\">\n * <a href=\"#intro\" data-stimeo--scrollspy-target=\"link\"\n * data-action=\"click->stimeo--scrollspy#scrollTo\">Intro</a>\n * <a href=\"#usage\" data-stimeo--scrollspy-target=\"link\"\n * data-action=\"click->stimeo--scrollspy#scrollTo\">Usage</a>\n * </nav>\n * <div class=\"content\">\n * <section id=\"intro\">…</section>\n * <section id=\"usage\">…</section>\n * </div>\n *\n * The active section is the one whose top edge sits closest to the **trigger\n * line**: `offset` px below the top of the *scroll root* — the `rootSelector`\n * container, or the viewport when that value is empty. It is not the viewport\n * top whenever a nested container is spied on. Intersecting sections win; when\n * none intersects (between two sections, scrolled past the last one) the\n * closest tracked section keeps the highlight, so a table of contents never\n * goes blank.\n *\n * `data-action` on the links is optional and opts into {@link scrollTo}, which\n * scrolls the nested container instead of bouncing the whole window.\n *\n * @remarks\n * Behavior only — how a current link looks is the consumer's CSS\n * (`[aria-current=\"location\"] { … }`). `connect()` reads the current location\n * back from the DOM so a Turbo cache restore re-establishes it without a\n * redundant `change`, and `disconnect()` severs every resource acquired here:\n * the observers, the scroll listener, and any pending frame or queued rebuild.\n *\n * **What is followed automatically**, and what is not (the boundary a consumer\n * has to know, because everything outside it needs a re-`connect()`):\n *\n * - `link` targets added or removed — Stimulus's target callbacks.\n * - a `link` target's `href` / `data-href` rewritten in place — a Turbo 8 morph\n * keeps the element *and* its target marker, so no target callback fires;\n * {@link ANCHOR_ATTRIBUTES} is watched for exactly this case.\n * - the reader's scroll position, including inside a stretch where no section\n * crosses an observation threshold.\n *\n * Not followed: a *split* lifecycle in which the nav survives while the scroll\n * root or the sections are replaced underneath it. `rootSelector` is resolved\n * against the whole document and re-resolved once the cached container leaves\n * it, but section elements are looked up only while the observation set is\n * (re)built — swap those alone and nothing tells this controller to look again.\n */\nexport class ScrollspyController extends Controller<HTMLElement> {\n static override targets = [\"link\"];\n static override values = {\n offset: { type: Number, default: 0 },\n rootMargin: { type: String, default: \"\" },\n rootSelector: { type: String, default: \"\" },\n focusSection: { type: Boolean, default: false },\n };\n static actions = [\"scrollTo\"] as const;\n static events = [\"change\"] as const;\n\n declare readonly linkTargets: HTMLElement[];\n\n declare offsetValue: number;\n declare rootMarginValue: string;\n declare rootSelectorValue: string;\n declare focusSectionValue: boolean;\n\n /**\n * The one offset shared by observation, active-section selection, and\n * scrolling. Stimulus parses a malformed Number Value as `NaN`; degrading it\n * to the declared default keeps every path aligned instead of only repairing\n * the observer margin while selection and scrolling still receive `NaN`.\n */\n get #offset(): number {\n return Number.isFinite(this.offsetValue) ? this.offsetValue : 0;\n }\n\n /** Shared IO plumbing (support guard, active guard, teardown). */\n readonly #watcher = new IntersectionWatcher((entries) => this.#onIntersection(entries));\n #isConnected = false;\n\n /**\n * Sections currently tracked, by id. Only the *latest reported* intersection\n * flag is stored — never a coordinate. Positions are re-measured when the\n * active section is evaluated, so a section observed several batches ago is\n * never compared against a trigger line computed now.\n */\n #intersectionStates = new Map<string, { element: Element; isIntersecting: boolean }>();\n\n /** Current active section ID; comparing it suppresses duplicate `change` events. */\n #activeSectionId = \"\";\n\n /**\n * Scroll root resolved when the observer was (re)built; `null` = viewport.\n * Cached so a click and every intersection batch reuse the element the\n * observer is actually watching instead of re-querying the document.\n */\n #rootElement: HTMLElement | null = null;\n\n /**\n * The source the `scroll` listener is currently attached to — the resolved\n * root, or the window while the viewport is spied. `null` means \"nothing\n * attached\", so teardown always detaches from the source it attached to\n * rather than from whatever the selector resolves to now.\n */\n #scrollSource: HTMLElement | Window | null = null;\n\n /** Pending re-evaluation frame; coalesces a scroll burst into one measurement. */\n #frame: number | null = null;\n\n /** Watches the link targets' anchor attributes for an in-place morph rewrite. */\n #anchorObserver: MutationObserver | null = null;\n\n /** True while a coalesced observation rebuild is queued; see {@link #scheduleResync}. */\n #resyncQueued = false;\n\n override connect(): void {\n this.#isConnected = true;\n this.#observeAnchorAttributes();\n this.#initializeObserver();\n }\n\n override disconnect(): void {\n this.#isConnected = false;\n // Dropping the flag is what discards a rebuild queued moments ago: the\n // drain reads it, so the queued microtask becomes a no-op.\n this.#resyncQueued = false;\n this.#watcher.stop();\n this.#anchorObserver?.disconnect();\n this.#anchorObserver = null;\n this.#detachScrollListener();\n if (this.#frame !== null) {\n cancelAnimationFrame(this.#frame);\n this.#frame = null;\n }\n this.#intersectionStates.clear();\n this.#activeSectionId = \"\";\n this.#rootElement = null;\n }\n\n /**\n * Re-initializes the observer if the offset or rootMargin values change dynamically.\n */\n offsetValueChanged(): void {\n if (!this.#isConnected) return;\n this.#initializeObserver();\n }\n\n rootMarginValueChanged(): void {\n if (!this.#isConnected) return;\n this.#initializeObserver();\n }\n\n rootSelectorValueChanged(): void {\n if (!this.#isConnected) return;\n this.#initializeObserver();\n }\n\n /**\n * Re-syncs the observation set when a Turbo Stream/morph swaps the table of\n * contents. Stimulus fires these before `connect()` for the links already in\n * the markup, hence the guard: the initial observer is built exactly once, by\n * `connect()`.\n */\n linkTargetConnected(): void {\n if (this.#isConnected) this.#scheduleResync();\n }\n\n linkTargetDisconnected(): void {\n if (this.#isConnected) this.#scheduleResync();\n }\n\n /**\n * Queues **one** observation rebuild for the current mutation batch.\n *\n * A single Turbo morph can append one link, drop another, and rewrite a\n * third's `href`, and those arrive through two independent channels —\n * Stimulus's target callbacks and {@link #anchorObserver}. Each channel just\n * raises the flag and queues a drain; the first drain to run does the work and\n * clears it, so every later drain in the same batch finds nothing to do and\n * the set is rebuilt once instead of three times. `disconnect()` clears the\n * same flag, which is how a queued rebuild is dropped rather than run against\n * a detached controller.\n */\n #scheduleResync(): void {\n this.#resyncQueued = true;\n queueMicrotask(this.#drainResync);\n }\n\n readonly #drainResync = (): void => {\n if (!this.#resyncQueued) return;\n this.#resyncQueued = false;\n this.#initializeObserver();\n };\n\n /**\n * Watches the link targets' anchor attributes so an in-place rewrite re-syncs.\n *\n * A Turbo 8 morph keeps the element **and** its `data-*-target` marker and\n * only rewrites attributes, so Stimulus fires no target callback: without\n * this, a link re-pointed from `#intro` to `#faq` would keep the controller\n * observing `#intro` for the rest of the page's life. The filter is exactly\n * {@link ANCHOR_ATTRIBUTES}; guarding on `MutationObserver` keeps the\n * controller usable where the API is absent, matching `IntersectionWatcher`'s\n * own support guard.\n */\n #observeAnchorAttributes(): void {\n if (typeof MutationObserver !== \"undefined\") {\n this.#anchorObserver = new MutationObserver(this.#onAnchorMutation);\n this.#anchorObserver.observe(this.element, {\n subtree: true,\n attributes: true,\n attributeFilter: ANCHOR_ATTRIBUTES,\n });\n }\n }\n\n /**\n * Rebuilds only for a rewrite on a *current* link target. The observer is\n * scoped to this controller's element, but that subtree also holds links the\n * author never marked as targets (a \"back to top\" anchor, a nested nav), and\n * those anchor nothing here.\n */\n readonly #onAnchorMutation = (records: MutationRecord[]): void => {\n const links = this.linkTargets;\n for (const record of records) {\n if (!links.includes(record.target as HTMLElement)) continue;\n this.#scheduleResync();\n return;\n }\n };\n\n /**\n * Scrolls to the section the clicked link anchors, honoring `offset` and any\n * nested scroll container (a plain fragment jump would scroll the window).\n *\n * Honors `prefers-reduced-motion` (WCAG 2.2 **2.3.3**) by forcing an instant\n * jump independently of the consumer's CSS `scroll-behavior`. With\n * `focusSection` enabled it also moves the sequential focus starting point\n * into the destination; the URL fragment is deliberately not touched.\n */\n scrollTo(event: Event): void {\n const link = event.currentTarget as HTMLElement;\n const id = this.#getAnchorId(link);\n if (!id) return;\n\n event.preventDefault();\n\n const targetElement = document.getElementById(id);\n if (!targetElement) return;\n\n const behavior: ScrollBehavior = prefersReducedMotion() ? \"instant\" : \"smooth\";\n const rootElement = this.#scrollRoot();\n const targetRect = targetElement.getBoundingClientRect();\n const offset = this.#offset;\n\n if (rootElement) {\n const containerRect = rootElement.getBoundingClientRect();\n const scrollPosition = rootElement.scrollTop + (targetRect.top - containerRect.top) - offset;\n\n rootElement.scrollTo({ top: scrollPosition, behavior });\n } else {\n const scrollPosition = window.scrollY + targetRect.top - offset;\n\n window.scrollTo({ top: scrollPosition, behavior });\n }\n\n if (this.focusSectionValue) this.#focusSection(targetElement);\n }\n\n /**\n * Moves the sequential focus starting point into the section `scrollTo` just\n * jumped to, so the next Tab continues *inside* the destination instead of\n * resuming in the table of contents (`preventDefault()` alone would leave the\n * starting point on the link). Opt-in through `focusSection`, because moving\n * focus is a decision only the consuming page can make.\n *\n * `tabindex=\"-1\"` is established only when the section is not already\n * focusable and is never removed, so an author-owned tabindex is left alone.\n * `preventScroll` keeps the focus call from cancelling the smooth scroll\n * started just above.\n */\n #focusSection(section: HTMLElement): void {\n if (!section.hasAttribute(\"tabindex\")) section.setAttribute(\"tabindex\", \"-1\");\n section.focus({ preventScroll: true });\n }\n\n /**\n * The cached scroll root, re-resolved when the cached element has left the\n * document (a Turbo morph replaced the container) so `scrollTo` never\n * scrolls a detached node.\n */\n #scrollRoot(): HTMLElement | null {\n if (this.#rootElement && !this.#rootElement.isConnected) {\n this.#rootElement = this.#queryRootElement();\n }\n return this.#rootElement;\n }\n\n /**\n * Resolves `rootSelector` to a scrollable element.\n *\n * @returns The container, or `null` meaning \"spy the viewport\" when the value\n * is empty, matches nothing, matches a non-HTML element (an SVG node is not a\n * scroll container), or is not a valid selector — a typo in a data attribute\n * must degrade to viewport spying, not leave the controller inert.\n */\n #queryRootElement(): HTMLElement | null {\n if (!this.rootSelectorValue) return null;\n try {\n const root = document.querySelector(this.rootSelectorValue);\n return root instanceof HTMLElement ? root : null;\n } catch {\n return null;\n }\n }\n\n /**\n * Re-evaluates once per frame while the reader scrolls.\n *\n * `IntersectionObserver` reports **threshold crossings**, not positions, so a\n * reader moving inside one long section — or across a gap wider than the\n * observation band — produces no batch at all and the highlight would stay\n * frozen at whatever the last crossing decided. That would make the current\n * location depend on the *route* to a position instead of the position: a\n * stepwise scroll crosses thresholds an instant jump to the same offset never\n * does. Listening to the scroll source closes the gap, and because both paths\n * end in {@link #evaluateActiveSection} — which measures section rects and the\n * root's top edge at that instant — they converge on the same answer.\n */\n readonly #onScroll = (): void => {\n if (this.#frame !== null) return;\n this.#frame = requestAnimationFrame(() => {\n this.#frame = null;\n this.#evaluateActiveSection();\n });\n };\n\n /**\n * Points the `scroll` listener at whatever the reader actually scrolls: the\n * resolved root, or the window when the viewport is spied.\n *\n * The detach is unconditional, so rebuilding the observation set (a Value\n * change, a morph) **moves** the listener rather than stacking a second one on\n * a container the reader has stopped scrolling.\n */\n #syncScrollListener(): void {\n this.#detachScrollListener();\n this.#scrollSource = this.#rootElement ?? window;\n this.#scrollSource.addEventListener(\"scroll\", this.#onScroll, { passive: true });\n }\n\n #detachScrollListener(): void {\n this.#scrollSource?.removeEventListener(\"scroll\", this.#onScroll);\n this.#scrollSource = null;\n }\n\n #initializeObserver(): void {\n this.#watcher.stop();\n this.#intersectionStates.clear();\n // The DOM is the source of truth for the current location **only when this\n // controller has none of its own** — a fresh `connect()`, which is also the\n // Turbo cache-restore case, where the links still carry `aria-current` from\n // the snapshot. Adopting it there makes the observer's first batch a silent\n // confirmation instead of a duplicate `change`.\n //\n // On a *live* rebuild the memory wins, because the DOM has stopped meaning\n // what this controller wrote: an anchor rewritten underneath us leaves\n // `aria-current` on a link that now points somewhere else, so reading it\n // back would hand the current location to a section the reader never\n // scrolled to — and then announce the correction as a `change`, as if they\n // had travelled there and back.\n this.#activeSectionId = this.#activeSectionId || this.#activeIdFromDom();\n this.#rootElement = this.#queryRootElement();\n this.#syncScrollListener();\n\n if (this.linkTargets.length === 0) return;\n\n // Negate the numeric value so a valid negative offset becomes a positive margin.\n const margin = this.rootMarginValue || `${-this.#offset}px 0px -80% 0px`;\n\n // Observe each target section mapped by the href anchors.\n const sections: Element[] = [];\n for (const link of this.linkTargets) {\n const id = this.#getAnchorId(link);\n if (!id) continue;\n const section = document.getElementById(id);\n if (section && !sections.includes(section)) sections.push(section);\n }\n\n this.#watcher.start(sections, {\n root: this.#rootElement,\n rootMargin: margin,\n threshold: [0, 0.2, 0.4, 0.6, 0.8, 1], // Multiple thresholds handle large sections safely\n });\n\n // Republish the adopted location over the *current* link set. Evaluation\n // writes attributes only when the winning section changes, so a link added\n // — or re-anchored — while the reader stays put would otherwise never be\n // marked: a mobile table of contents rendered after the sidebar one would\n // stay blank until the reader happened to cross into another section.\n //\n // Unconditional, including when the adopted location is empty: a link whose\n // anchor was rewritten to something that resolves nowhere cannot be the\n // reader's location, and this controller is the one that published the\n // attribute saying it was, so it is the one that has to take it back.\n this.#syncActiveStates(false);\n }\n\n readonly #onIntersection = (entries: IntersectionObserverEntry[]): void => {\n // Defense in depth. `IntersectionWatcher` already drops a batch the browser\n // flushes after `stop()` (its active/identity guard), so this flag is the\n // second line that keeps a detached controller from mutating `aria-current`\n // on (possibly cached) links.\n const isDetached = !this.#isConnected;\n if (isDetached) return;\n\n for (const entry of entries) {\n const sectionId = entry.target.id;\n if (!sectionId) continue;\n\n this.#intersectionStates.set(sectionId, {\n element: entry.target,\n isIntersecting: entry.isIntersecting,\n });\n }\n\n this.#evaluateActiveSection();\n };\n\n /**\n * Picks the section closest to the trigger line and publishes it.\n *\n * Every coordinate is read **now**: the section rects *and* the root's top\n * edge share one measurement instant. Comparing an entry's recorded\n * `boundingClientRect.top` (captured whenever that section last crossed a\n * threshold) against a freshly computed trigger line mixes two moments in\n * time, which would make the result depend on how the reader arrived at a\n * position — a smooth scroll and an instant jump to the same offset disagree.\n */\n #evaluateActiveSection(): void {\n // The trigger line is `offset` px below the top of the scroll root. When a\n // nested `rootSelector` container is used it is not at the viewport top, so\n // the line must be measured from the container's current top — comparing the\n // viewport-based rect top against a bare `offset` would otherwise pick the\n // section nearest the viewport top, not the container's.\n const rootEl = this.#scrollRoot();\n const triggerLine = (rootEl ? rootEl.getBoundingClientRect().top : 0) + this.#offset;\n\n let intersectingId = \"\";\n let intersectingDistance = Number.POSITIVE_INFINITY;\n let trackedId = \"\";\n let trackedDistance = Number.POSITIVE_INFINITY;\n\n for (const [id, state] of this.#intersectionStates) {\n const rect = state.element.getBoundingClientRect();\n // A section with no layout box (`display: none`, a collapsed `<details>`,\n // an undisplayed Turbo Frame) is reported with an empty rect whose `top`\n // of 0 carries no position at all. Letting it compete would hand it the\n // fallback below; it re-enters the race once it is actually laid out.\n if (rect.width === 0 && rect.height === 0) continue;\n\n const distance = Math.abs(rect.top - triggerLine);\n if (distance < trackedDistance) {\n trackedDistance = distance;\n trackedId = id;\n }\n if (state.isIntersecting && distance < intersectingDistance) {\n intersectingDistance = distance;\n intersectingId = id;\n }\n }\n\n // Fallback: when no section currently intersects (e.g. scrolled past the\n // bottom, or between sections), keep the tracked section whose top is\n // closest to the trigger line so something stays highlighted.\n const bestId = intersectingId || trackedId;\n\n if (bestId && bestId !== this.#activeSectionId) {\n this.#activeSectionId = bestId;\n this.#syncActiveStates(true);\n }\n }\n\n /**\n * Writes `aria-current` across the current link set, optionally announcing.\n *\n * The two halves are separate because they answer different questions.\n * *Attributes* must be idempotently re-established whenever the link set\n * changes, even though the reader has not moved — otherwise a link that\n * appears (or is re-anchored) while its section is already current never gets\n * marked. *The `change` event* announces that the reader moved, so it fires\n * only from the evaluation path; re-publishing over a new link set is not\n * news, and dispatching there would make a rebuild look like navigation.\n *\n * @param announce Whether this sync represents a change of current section.\n */\n #syncActiveStates(announce: boolean): void {\n // Every link anchoring the active section is marked, not just the first:\n // a page may render the same table of contents twice (a sidebar and a\n // collapsed mobile menu) and both must show the current location.\n const activeLinks = this.linkTargets.filter(\n (link) => this.#getAnchorId(link) === this.#activeSectionId,\n );\n\n for (const link of this.linkTargets) {\n if (activeLinks.includes(link)) {\n link.setAttribute(\"aria-current\", \"location\");\n } else if (link.getAttribute(\"aria-current\") === \"location\") {\n // Reclaim only the value this controller publishes, so an author-owned\n // `aria-current=\"page\"` on a table-of-contents link survives.\n link.removeAttribute(\"aria-current\");\n }\n }\n\n if (!announce) return;\n\n const primaryLink = activeLinks[0];\n if (primaryLink) {\n this.dispatch(\"change\", { detail: { id: this.#activeSectionId, link: primaryLink } });\n }\n }\n\n /**\n * The current location already encoded in the DOM, i.e. the section anchored\n * by the first link carrying this controller's `aria-current=\"location\"`.\n * Empty when no link claims it (a genuinely fresh render).\n */\n #activeIdFromDom(): string {\n for (const link of this.linkTargets) {\n if (link.getAttribute(\"aria-current\") !== \"location\") continue;\n const id = this.#getAnchorId(link);\n if (id) return id;\n }\n return \"\";\n }\n\n /**\n * The section id a link anchors, resolved in a fixed order:\n *\n * 1. `href`, when it is a non-empty same-document fragment — the contract.\n * 2. otherwise `data-href`'s fragment — the fallback for a link whose `href`\n * must stay a real URL (a server-rendered permalink) or that is not an\n * `<a>` at all.\n * 3. otherwise `null`: the link anchors nothing here and is not observed.\n *\n * Step 2 is reached whenever `href` yields nothing usable — absent, `\"#\"`, or\n * a real URL — which is the whole point of the fallback: `href=\"/guide/usage\"`\n * with `data-href=\"#usage\"` is a permalink that also spies, and picking the\n * first *present* attribute instead of the first *usable* one would silently\n * exclude exactly that markup. When both are valid fragments `href` wins.\n */\n #getAnchorId(link: HTMLElement): string | null {\n return (\n this.#fragmentId(link.getAttribute(\"href\")) ??\n this.#fragmentId(link.getAttribute(\"data-href\"))\n );\n }\n\n /** The id in a `#fragment` value; `null` for absent, empty, or non-fragment. */\n #fragmentId(value: string | null): string | null {\n if (!value?.startsWith(\"#\")) return null;\n return value.substring(1) || null;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/intersection_watcher.ts","../../src/utils/reduced_motion.ts","../../src/controllers/scrollspy_controller.ts"],"names":[],"mappings":";;;;;AAmDO,IAAM,sBAAN,MAA0B;AAAA,EACtB,UAAA;AAAA,EACT,SAAA,GAAyC,IAAA;AAAA,EACzC,OAAA,GAAU,KAAA;AAAA,EACV,sBAAA,GAAyB,KAAA;AAAA,EAEzB,YAAY,SAAA,EAA2D;AACrE,IAAA,IAAA,CAAK,UAAA,GAAa,SAAA;AAAA,EACpB;AAAA;AAAA,EAGA,IAAI,MAAA,GAAkB;AACpB,IAAA,OAAO,IAAA,CAAK,OAAA;AAAA,EACd;AAAA;AAAA,EAGA,IAAI,qBAAA,GAAiC;AACnC,IAAA,OAAO,IAAA,CAAK,sBAAA;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAeA,KAAA,CAAM,OAAA,EAAuC,OAAA,GAAoC,EAAC,EAAY;AAC5F,IAAA,IAAA,CAAK,IAAA,EAAK;AACV,IAAA,IAAI,OAAO,oBAAA,KAAyB,WAAA,EAA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gBAAA,EAAkB,IAAA,EAAM,WAAA,EAAY,EAAG,CAAA;AAAA,IACtF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,gBAAA,GAA2B;AACzB,IAAA,KAAA,MAAW,IAAA,IAAQ,KAAK,WAAA,EAAa;AACnC,MAAA,IAAI,IAAA,CAAK,YAAA,CAAa,cAAc,CAAA,KAAM,UAAA,EAAY;AACtD,MAAA,MAAM,EAAA,GAAK,IAAA,CAAK,YAAA,CAAa,IAAI,CAAA;AACjC,MAAA,IAAI,IAAI,OAAO,EAAA;AAAA,IACjB;AACA,IAAA,OAAO,EAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBA,aAAa,IAAA,EAAkC;AAC7C,IAAA,OACE,IAAA,CAAK,WAAA,CAAY,IAAA,CAAK,YAAA,CAAa,MAAM,CAAC,CAAA,IAC1C,IAAA,CAAK,WAAA,CAAY,IAAA,CAAK,YAAA,CAAa,WAAW,CAAC,CAAA;AAAA,EAEnD;AAAA;AAAA,EAGA,YAAY,KAAA,EAAqC;AAC/C,IAAA,IAAI,CAAC,KAAA,EAAO,UAAA,CAAW,GAAG,GAAG,OAAO,IAAA;AACpC,IAAA,OAAO,KAAA,CAAM,SAAA,CAAU,CAAC,CAAA,IAAK,IAAA;AAAA,EAC/B;AACF","file":"scrollspy_controller.js","sourcesContent":["/**\n * Shared `IntersectionObserver` plumbing for Stimeo's scroll-triggered\n * controllers (`intersection`, `scrollspy`, `sticky-observer`, `lazy-frame`).\n *\n * It centralizes the `IntersectionObserver` support guard, root resolution from\n * a selector, observer creation/teardown, the **active guard** (the browser may\n * flush a final queued callback batch right after `disconnect()`, and a\n * detached controller must not mutate possibly-cached DOM), and the\n * unobserve→observe **re-arm** that re-delivers the current state even when the\n * target never leaves the viewport.\n *\n * Like {@link RovingTabindex} and `FocusTrap`, this is a policy-free internal\n * util: what an intersection *means* (a spied link, a stuck header, a lazy\n * load) stays in each controller. The public `stimeo--intersection` controller\n * is its thin declarative face.\n */\n/**\n * Whether `entry`'s target sits entirely before the root's **start (top)** edge —\n * the \"scrolled past the top\" half of a non-intersecting entry, as opposed to\n * \"not reached yet\" below the root.\n *\n * A target with no layout box (`display: none`, a `hidden` ancestor, a collapsed\n * `<details>`) is reported with an **empty rect**, whose `bottom` of `0` would\n * otherwise satisfy `bottom <= rootTop` for a viewport root and read as \"passed\"\n * even though the target was never scrolled anywhere. An empty rect carries no\n * position at all, so it is deliberately never \"before the edge\"; what a caller\n * publishes for that case is its own policy (both consumers treat it as the\n * neutral \"not passed\"/\"not stuck\", and the real rect that arrives once the\n * target is laid out re-establishes the true state).\n */\nexport function isBeforeRootStart(entry: IntersectionObserverEntry): boolean {\n const rect = entry.boundingClientRect;\n if (rect.width === 0 && rect.height === 0) return false;\n // rootBounds is null for a cross-origin/removed root; fall back to the\n // viewport origin.\n const rootTop = entry.rootBounds?.top ?? 0;\n return rect.bottom <= rootTop;\n}\n\nexport interface IntersectionWatchOptions {\n /**\n * The observation root. Pass an element (or `null` for the viewport) when\n * the caller already resolved it; omit to resolve from `rootSelector`.\n */\n root?: Element | null;\n /** Selector for the observation root; empty/omitted = viewport. */\n rootSelector?: string;\n rootMargin?: string;\n threshold?: number | number[];\n}\n\nexport class IntersectionWatcher {\n readonly #onEntries: (entries: IntersectionObserverEntry[]) => void;\n #observer: IntersectionObserver | null = null;\n #active = false;\n #usingPlatformDefaults = false;\n\n constructor(onEntries: (entries: IntersectionObserverEntry[]) => void) {\n this.#onEntries = onEntries;\n }\n\n /** Whether an observer is live (started, `IntersectionObserver` supported). */\n get active(): boolean {\n return this.#active;\n }\n\n /** Whether the live observer discarded configured options after construction failed. */\n get usingPlatformDefaults(): boolean {\n return this.#usingPlatformDefaults;\n }\n\n /**\n * (Re)creates the observer and observes `targets`. Returns `false` — leaving\n * the watcher inert — without `IntersectionObserver` support (very old\n * browsers; the caller's no-JS fallback stays in charge) or with no targets.\n * If initial construction with the configured options fails, the watcher\n * warns and retries once with the same root and platform defaults.\n *\n * @throws The fallback constructor error if both construction attempts fail,\n * or whatever the platform throws from `observe()`. The exception is passed\n * through unchanged, but the watcher rolls back first: every target observed\n * so far is released and `active` stays `false`, so a caller that retries\n * starts from a clean slate.\n */\n start(targets: Element | readonly Element[], options: IntersectionWatchOptions = {}): boolean {\n this.stop();\n if (typeof IntersectionObserver === \"undefined\") return false;\n const list = Array.isArray(targets) ? (targets as readonly Element[]) : [targets as Element];\n if (list.length === 0) return false;\n\n const root =\n \"root\" in options\n ? (options.root ?? null)\n : options.rootSelector\n ? document.querySelector(options.rootSelector)\n : null;\n\n let observer: IntersectionObserver | null = null;\n try {\n const onEntries = (entries: IntersectionObserverEntry[]): void => {\n // Identity matters across an immediate restart: the old observer can\n // flush a queued batch after the new observer has made `active` true.\n if (this.#active && this.#observer === observer) this.#onEntries(entries);\n };\n try {\n observer = new IntersectionObserver(onEntries, {\n root,\n rootMargin: options.rootMargin,\n threshold: options.threshold,\n });\n } catch (error) {\n console.warn(\n \"Stimeo UI: IntersectionObserver could not be constructed with the configured options; retrying with platform defaults.\",\n error,\n );\n observer = new IntersectionObserver(onEntries, { root });\n this.#usingPlatformDefaults = true;\n }\n for (const target of list) observer.observe(target);\n this.#observer = observer;\n this.#active = true;\n return true;\n } catch (error) {\n // A constructor or partial observe failure must not leave earlier targets\n // observed or report an active watcher. Preserve the platform exception.\n observer?.disconnect();\n this.#observer = null;\n this.#active = false;\n this.#usingPlatformDefaults = false;\n throw error;\n }\n }\n\n /**\n * Re-delivers `target`'s CURRENT intersection state: `IntersectionObserver`\n * only reports *changes*, but `observe()` always reports the present state,\n * so unobserve→observe turns \"still intersecting\" into a fresh callback.\n *\n * @throws Whatever `unobserve()`/`observe()` throws. The watcher is stopped\n * first, so it never stays live with a half-rearmed target.\n */\n rearm(target: Element): void {\n if (!this.#observer) return;\n try {\n this.#observer.unobserve(target);\n this.#observer.observe(target);\n } catch (error) {\n this.stop();\n throw error;\n }\n }\n\n /** Severs the observer; late queued callbacks become no-ops via the guard. */\n stop(): void {\n this.#active = false;\n this.#observer?.disconnect();\n this.#observer = null;\n this.#usingPlatformDefaults = false;\n }\n}\n","/**\n * Shared `prefers-reduced-motion` lookup for the motion-aware controllers\n * (count-up, highlight, overflow-indicator, scroll-visibility, stick-to-bottom,\n * transition).\n *\n * This one-liner keeps the media query string and the environment guard\n * single-sourced across them. The preference is intentionally re-read on every\n * call — the controllers check it at each animation/scroll start (WCAG 2.2\n * **2.3.3**), so flipping the OS setting takes effect immediately without any\n * listener or cache bookkeeping here.\n */\n\n/**\n * Whether the user currently requests reduced motion.\n *\n * @returns `true` when `(prefers-reduced-motion: reduce)` matches; `false`\n * otherwise, including environments without `window.matchMedia` (treated as\n * \"no preference\").\n */\nexport function prefersReducedMotion(): boolean {\n return (\n typeof window.matchMedia === \"function\" &&\n window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches\n );\n}\n","import { Controller } from \"@hotwired/stimulus\";\nimport { IntersectionWatcher } from \"../utils/intersection_watcher\";\nimport { prefersReducedMotion } from \"../utils/reduced_motion\";\n\n/**\n * The attributes a link may anchor its section with, and therefore the only\n * ones whose rewrite has to re-sync the observation set. `aria-current` — the\n * attribute this controller writes itself — is deliberately absent, so\n * publishing the current location cannot feed back into a rebuild.\n */\nconst ANCHOR_ATTRIBUTES = [\"href\", \"data-href\"];\n\n/**\n * Headless, accessible **Scrollspy**: keeps a table of contents in sync with the\n * section the reader is currently in, published as `aria-current=\"location\"`.\n * There is no dedicated APG widget; it follows the `aria-current`\n * current-location practice inside a `<nav>` landmark.\n *\n * Markup contract (identifier: `stimeo--scrollspy`):\n * <nav data-controller=\"stimeo--scrollspy\"\n * data-stimeo--scrollspy-offset-value=\"80\"\n * data-stimeo--scrollspy-root-selector-value=\".content\"\n * aria-label=\"Table of contents\">\n * <a href=\"#intro\" data-stimeo--scrollspy-target=\"link\"\n * data-action=\"click->stimeo--scrollspy#scrollTo\">Intro</a>\n * <a href=\"#usage\" data-stimeo--scrollspy-target=\"link\"\n * data-action=\"click->stimeo--scrollspy#scrollTo\">Usage</a>\n * </nav>\n * <div class=\"content\">\n * <section id=\"intro\">…</section>\n * <section id=\"usage\">…</section>\n * </div>\n *\n * The active section is the one whose top edge sits closest to the **trigger\n * line**: `offset` px below the top of the *scroll root* — the `rootSelector`\n * container, or the viewport when that value is empty. It is not the viewport\n * top whenever a nested container is spied on. Intersecting sections win; when\n * none intersects (between two sections, scrolled past the last one) the\n * closest tracked section keeps the highlight, so a table of contents never\n * goes blank.\n *\n * `data-action` on the links is optional and opts into {@link scrollTo}, which\n * scrolls the nested container instead of bouncing the whole window.\n *\n * `change` dispatches `{ id: string, link: HTMLElement }`.\n *\n * @remarks\n * Behavior only — how a current link looks is the consumer's CSS\n * (`[aria-current=\"location\"] { … }`). `connect()` reads the current location\n * back from the DOM so a Turbo cache restore re-establishes it without a\n * redundant `change`, and `disconnect()` severs every resource acquired here:\n * the observers, the scroll listener, and any pending frame or queued rebuild.\n *\n * **What is followed automatically**, and what is not (the boundary a consumer\n * has to know, because everything outside it needs a re-`connect()`):\n *\n * - `link` targets added or removed — Stimulus's target callbacks.\n * - a `link` target's `href` / `data-href` rewritten in place — a Turbo 8 morph\n * keeps the element *and* its target marker, so no target callback fires;\n * {@link ANCHOR_ATTRIBUTES} is watched for exactly this case.\n * - the reader's scroll position, including inside a stretch where no section\n * crosses an observation threshold.\n *\n * Not followed: a *split* lifecycle in which the nav survives while the scroll\n * root or the sections are replaced underneath it. `rootSelector` is resolved\n * against the whole document and re-resolved once the cached container leaves\n * it, but section elements are looked up only while the observation set is\n * (re)built — swap those alone and nothing tells this controller to look again.\n */\nexport class ScrollspyController extends Controller<HTMLElement> {\n static override targets = [\"link\"];\n static override values = {\n offset: { type: Number, default: 0 },\n rootMargin: { type: String, default: \"\" },\n rootSelector: { type: String, default: \"\" },\n focusSection: { type: Boolean, default: false },\n };\n static actions = [\"scrollTo\"] as const;\n static events = [\"change\"] as const;\n\n declare readonly linkTargets: HTMLElement[];\n\n declare offsetValue: number;\n declare rootMarginValue: string;\n declare rootSelectorValue: string;\n declare focusSectionValue: boolean;\n\n /**\n * The one offset shared by observation, active-section selection, and\n * scrolling. Stimulus parses a malformed Number Value as `NaN`; degrading it\n * to the declared default keeps every path aligned instead of only repairing\n * the observer margin while selection and scrolling still receive `NaN`.\n */\n get #offset(): number {\n return Number.isFinite(this.offsetValue) ? this.offsetValue : 0;\n }\n\n /** Shared IO plumbing (support guard, active guard, teardown). */\n readonly #watcher = new IntersectionWatcher((entries) => this.#onIntersection(entries));\n #isConnected = false;\n\n /**\n * Sections currently tracked, by id. Only the *latest reported* intersection\n * flag is stored — never a coordinate. Positions are re-measured when the\n * active section is evaluated, so a section observed several batches ago is\n * never compared against a trigger line computed now.\n */\n #intersectionStates = new Map<string, { element: Element; isIntersecting: boolean }>();\n\n /** Current active section ID; comparing it suppresses duplicate `change` events. */\n #activeSectionId = \"\";\n\n /**\n * Scroll root resolved when the observer was (re)built; `null` = viewport.\n * Cached so a click and every intersection batch reuse the element the\n * observer is actually watching instead of re-querying the document.\n */\n #rootElement: HTMLElement | null = null;\n\n /**\n * The source the `scroll` listener is currently attached to — the resolved\n * root, or the window while the viewport is spied. `null` means \"nothing\n * attached\", so teardown always detaches from the source it attached to\n * rather than from whatever the selector resolves to now.\n */\n #scrollSource: HTMLElement | Window | null = null;\n\n /** Pending re-evaluation frame; coalesces a scroll burst into one measurement. */\n #frame: number | null = null;\n\n /** Watches the link targets' anchor attributes for an in-place morph rewrite. */\n #anchorObserver: MutationObserver | null = null;\n\n /** True while a coalesced observation rebuild is queued; see {@link #scheduleResync}. */\n #resyncQueued = false;\n\n override connect(): void {\n this.#isConnected = true;\n this.#observeAnchorAttributes();\n this.#initializeObserver();\n }\n\n override disconnect(): void {\n this.#isConnected = false;\n // Dropping the flag is what discards a rebuild queued moments ago: the\n // drain reads it, so the queued microtask becomes a no-op.\n this.#resyncQueued = false;\n this.#watcher.stop();\n this.#anchorObserver?.disconnect();\n this.#anchorObserver = null;\n this.#detachScrollListener();\n if (this.#frame !== null) {\n cancelAnimationFrame(this.#frame);\n this.#frame = null;\n }\n this.#intersectionStates.clear();\n this.#activeSectionId = \"\";\n this.#rootElement = null;\n }\n\n /**\n * Re-initializes the observer if the offset or rootMargin values change dynamically.\n */\n offsetValueChanged(): void {\n if (!this.#isConnected) return;\n this.#initializeObserver();\n }\n\n rootMarginValueChanged(): void {\n if (!this.#isConnected) return;\n this.#initializeObserver();\n }\n\n rootSelectorValueChanged(): void {\n if (!this.#isConnected) return;\n this.#initializeObserver();\n }\n\n /**\n * Re-syncs the observation set when a Turbo Stream/morph swaps the table of\n * contents. Stimulus fires these before `connect()` for the links already in\n * the markup, hence the guard: the initial observer is built exactly once, by\n * `connect()`.\n */\n linkTargetConnected(): void {\n if (this.#isConnected) this.#scheduleResync();\n }\n\n linkTargetDisconnected(): void {\n if (this.#isConnected) this.#scheduleResync();\n }\n\n /**\n * Queues **one** observation rebuild for the current mutation batch.\n *\n * A single Turbo morph can append one link, drop another, and rewrite a\n * third's `href`, and those arrive through two independent channels —\n * Stimulus's target callbacks and {@link #anchorObserver}. Each channel just\n * raises the flag and queues a drain; the first drain to run does the work and\n * clears it, so every later drain in the same batch finds nothing to do and\n * the set is rebuilt once instead of three times. `disconnect()` clears the\n * same flag, which is how a queued rebuild is dropped rather than run against\n * a detached controller.\n */\n #scheduleResync(): void {\n this.#resyncQueued = true;\n queueMicrotask(this.#drainResync);\n }\n\n readonly #drainResync = (): void => {\n if (!this.#resyncQueued) return;\n this.#resyncQueued = false;\n this.#initializeObserver();\n };\n\n /**\n * Watches the link targets' anchor attributes so an in-place rewrite re-syncs.\n *\n * A Turbo 8 morph keeps the element **and** its `data-*-target` marker and\n * only rewrites attributes, so Stimulus fires no target callback: without\n * this, a link re-pointed from `#intro` to `#faq` would keep the controller\n * observing `#intro` for the rest of the page's life. The filter is exactly\n * {@link ANCHOR_ATTRIBUTES}; guarding on `MutationObserver` keeps the\n * controller usable where the API is absent, matching `IntersectionWatcher`'s\n * own support guard.\n */\n #observeAnchorAttributes(): void {\n if (typeof MutationObserver !== \"undefined\") {\n this.#anchorObserver = new MutationObserver(this.#onAnchorMutation);\n this.#anchorObserver.observe(this.element, {\n subtree: true,\n attributes: true,\n attributeFilter: ANCHOR_ATTRIBUTES,\n });\n }\n }\n\n /**\n * Rebuilds only for a rewrite on a *current* link target. The observer is\n * scoped to this controller's element, but that subtree also holds links the\n * author never marked as targets (a \"back to top\" anchor, a nested nav), and\n * those anchor nothing here.\n */\n readonly #onAnchorMutation = (records: MutationRecord[]): void => {\n const links = this.linkTargets;\n for (const record of records) {\n if (!links.includes(record.target as HTMLElement)) continue;\n this.#scheduleResync();\n return;\n }\n };\n\n /**\n * Scrolls to the section the clicked link anchors, honoring `offset` and any\n * nested scroll container (a plain fragment jump would scroll the window).\n *\n * Honors `prefers-reduced-motion` (WCAG 2.2 **2.3.3**) by forcing an instant\n * jump independently of the consumer's CSS `scroll-behavior`. With\n * `focusSection` enabled it also moves the sequential focus starting point\n * into the destination; the URL fragment is deliberately not touched.\n */\n scrollTo(event: Event): void {\n const link = event.currentTarget as HTMLElement;\n const id = this.#getAnchorId(link);\n if (!id) return;\n\n event.preventDefault();\n\n const targetElement = document.getElementById(id);\n if (!targetElement) return;\n\n const behavior: ScrollBehavior = prefersReducedMotion() ? \"instant\" : \"smooth\";\n const rootElement = this.#scrollRoot();\n const targetRect = targetElement.getBoundingClientRect();\n const offset = this.#offset;\n\n if (rootElement) {\n const containerRect = rootElement.getBoundingClientRect();\n const scrollPosition = rootElement.scrollTop + (targetRect.top - containerRect.top) - offset;\n\n rootElement.scrollTo({ top: scrollPosition, behavior });\n } else {\n const scrollPosition = window.scrollY + targetRect.top - offset;\n\n window.scrollTo({ top: scrollPosition, behavior });\n }\n\n if (this.focusSectionValue) this.#focusSection(targetElement);\n }\n\n /**\n * Moves the sequential focus starting point into the section `scrollTo` just\n * jumped to, so the next Tab continues *inside* the destination instead of\n * resuming in the table of contents (`preventDefault()` alone would leave the\n * starting point on the link). Opt-in through `focusSection`, because moving\n * focus is a decision only the consuming page can make.\n *\n * `tabindex=\"-1\"` is established only when the section is not already\n * focusable and is never removed, so an author-owned tabindex is left alone.\n * `preventScroll` keeps the focus call from cancelling the smooth scroll\n * started just above.\n */\n #focusSection(section: HTMLElement): void {\n if (!section.hasAttribute(\"tabindex\")) section.setAttribute(\"tabindex\", \"-1\");\n section.focus({ preventScroll: true });\n }\n\n /**\n * The cached scroll root, re-resolved when the cached element has left the\n * document (a Turbo morph replaced the container) so `scrollTo` never\n * scrolls a detached node.\n */\n #scrollRoot(): HTMLElement | null {\n if (this.#rootElement && !this.#rootElement.isConnected) {\n this.#rootElement = this.#queryRootElement();\n }\n return this.#rootElement;\n }\n\n /**\n * Resolves `rootSelector` to a scrollable element.\n *\n * @returns The container, or `null` meaning \"spy the viewport\" when the value\n * is empty, matches nothing, matches a non-HTML element (an SVG node is not a\n * scroll container), or is not a valid selector — a typo in a data attribute\n * must degrade to viewport spying, not leave the controller inert.\n */\n #queryRootElement(): HTMLElement | null {\n if (!this.rootSelectorValue) return null;\n try {\n const root = document.querySelector(this.rootSelectorValue);\n return root instanceof HTMLElement ? root : null;\n } catch {\n return null;\n }\n }\n\n /**\n * Re-evaluates once per frame while the reader scrolls.\n *\n * `IntersectionObserver` reports **threshold crossings**, not positions, so a\n * reader moving inside one long section — or across a gap wider than the\n * observation band — produces no batch at all and the highlight would stay\n * frozen at whatever the last crossing decided. That would make the current\n * location depend on the *route* to a position instead of the position: a\n * stepwise scroll crosses thresholds an instant jump to the same offset never\n * does. Listening to the scroll source closes the gap, and because both paths\n * end in {@link #evaluateActiveSection} — which measures section rects and the\n * root's top edge at that instant — they converge on the same answer.\n */\n readonly #onScroll = (): void => {\n if (this.#frame !== null) return;\n this.#frame = requestAnimationFrame(() => {\n this.#frame = null;\n this.#evaluateActiveSection();\n });\n };\n\n /**\n * Points the `scroll` listener at whatever the reader actually scrolls: the\n * resolved root, or the window when the viewport is spied.\n *\n * The detach is unconditional, so rebuilding the observation set (a Value\n * change, a morph) **moves** the listener rather than stacking a second one on\n * a container the reader has stopped scrolling.\n */\n #syncScrollListener(): void {\n this.#detachScrollListener();\n this.#scrollSource = this.#rootElement ?? window;\n this.#scrollSource.addEventListener(\"scroll\", this.#onScroll, { passive: true });\n }\n\n #detachScrollListener(): void {\n this.#scrollSource?.removeEventListener(\"scroll\", this.#onScroll);\n this.#scrollSource = null;\n }\n\n #initializeObserver(): void {\n this.#watcher.stop();\n this.#intersectionStates.clear();\n // The DOM is the source of truth for the current location **only when this\n // controller has none of its own** — a fresh `connect()`, which is also the\n // Turbo cache-restore case, where the links still carry `aria-current` from\n // the snapshot. Adopting it there makes the observer's first batch a silent\n // confirmation instead of a duplicate `change`.\n //\n // On a *live* rebuild the memory wins, because the DOM has stopped meaning\n // what this controller wrote: an anchor rewritten underneath us leaves\n // `aria-current` on a link that now points somewhere else, so reading it\n // back would hand the current location to a section the reader never\n // scrolled to — and then announce the correction as a `change`, as if they\n // had travelled there and back.\n this.#activeSectionId = this.#activeSectionId || this.#activeIdFromDom();\n this.#rootElement = this.#queryRootElement();\n this.#syncScrollListener();\n\n if (this.linkTargets.length === 0) return;\n\n // Negate the numeric value so a valid negative offset becomes a positive margin.\n const margin = this.rootMarginValue || `${-this.#offset}px 0px -80% 0px`;\n\n // Observe each target section mapped by the href anchors.\n const sections: Element[] = [];\n for (const link of this.linkTargets) {\n const id = this.#getAnchorId(link);\n if (!id) continue;\n const section = document.getElementById(id);\n if (section && !sections.includes(section)) sections.push(section);\n }\n\n this.#watcher.start(sections, {\n root: this.#rootElement,\n rootMargin: margin,\n threshold: [0, 0.2, 0.4, 0.6, 0.8, 1], // Multiple thresholds handle large sections safely\n });\n\n // Republish the adopted location over the *current* link set. Evaluation\n // writes attributes only when the winning section changes, so a link added\n // — or re-anchored — while the reader stays put would otherwise never be\n // marked: a mobile table of contents rendered after the sidebar one would\n // stay blank until the reader happened to cross into another section.\n //\n // Unconditional, including when the adopted location is empty: a link whose\n // anchor was rewritten to something that resolves nowhere cannot be the\n // reader's location, and this controller is the one that published the\n // attribute saying it was, so it is the one that has to take it back.\n this.#syncActiveStates(false);\n }\n\n readonly #onIntersection = (entries: IntersectionObserverEntry[]): void => {\n // Defense in depth. `IntersectionWatcher` already drops a batch the browser\n // flushes after `stop()` (its active/identity guard), so this flag is the\n // second line that keeps a detached controller from mutating `aria-current`\n // on (possibly cached) links.\n const isDetached = !this.#isConnected;\n if (isDetached) return;\n\n for (const entry of entries) {\n const sectionId = entry.target.id;\n if (!sectionId) continue;\n\n this.#intersectionStates.set(sectionId, {\n element: entry.target,\n isIntersecting: entry.isIntersecting,\n });\n }\n\n this.#evaluateActiveSection();\n };\n\n /**\n * Picks the section closest to the trigger line and publishes it.\n *\n * Every coordinate is read **now**: the section rects *and* the root's top\n * edge share one measurement instant. Comparing an entry's recorded\n * `boundingClientRect.top` (captured whenever that section last crossed a\n * threshold) against a freshly computed trigger line mixes two moments in\n * time, which would make the result depend on how the reader arrived at a\n * position — a smooth scroll and an instant jump to the same offset disagree.\n */\n #evaluateActiveSection(): void {\n // The trigger line is `offset` px below the top of the scroll root. When a\n // nested `rootSelector` container is used it is not at the viewport top, so\n // the line must be measured from the container's current top — comparing the\n // viewport-based rect top against a bare `offset` would otherwise pick the\n // section nearest the viewport top, not the container's.\n const rootEl = this.#scrollRoot();\n const triggerLine = (rootEl ? rootEl.getBoundingClientRect().top : 0) + this.#offset;\n\n let intersectingId = \"\";\n let intersectingDistance = Number.POSITIVE_INFINITY;\n let trackedId = \"\";\n let trackedDistance = Number.POSITIVE_INFINITY;\n\n for (const [id, state] of this.#intersectionStates) {\n const rect = state.element.getBoundingClientRect();\n // A section with no layout box (`display: none`, a collapsed `<details>`,\n // an undisplayed Turbo Frame) is reported with an empty rect whose `top`\n // of 0 carries no position at all. Letting it compete would hand it the\n // fallback below; it re-enters the race once it is actually laid out.\n if (rect.width === 0 && rect.height === 0) continue;\n\n const distance = Math.abs(rect.top - triggerLine);\n if (distance < trackedDistance) {\n trackedDistance = distance;\n trackedId = id;\n }\n if (state.isIntersecting && distance < intersectingDistance) {\n intersectingDistance = distance;\n intersectingId = id;\n }\n }\n\n // Fallback: when no section currently intersects (e.g. scrolled past the\n // bottom, or between sections), keep the tracked section whose top is\n // closest to the trigger line so something stays highlighted.\n const bestId = intersectingId || trackedId;\n\n if (bestId && bestId !== this.#activeSectionId) {\n this.#activeSectionId = bestId;\n this.#syncActiveStates(true);\n }\n }\n\n /**\n * Writes `aria-current` across the current link set, optionally announcing.\n *\n * The two halves are separate because they answer different questions.\n * *Attributes* must be idempotently re-established whenever the link set\n * changes, even though the reader has not moved — otherwise a link that\n * appears (or is re-anchored) while its section is already current never gets\n * marked. *The `change` event* announces that the reader moved, so it fires\n * only from the evaluation path; re-publishing over a new link set is not\n * news, and dispatching there would make a rebuild look like navigation.\n *\n * @param announce Whether this sync represents a change of current section.\n */\n #syncActiveStates(announce: boolean): void {\n // Every link anchoring the active section is marked, not just the first:\n // a page may render the same table of contents twice (a sidebar and a\n // collapsed mobile menu) and both must show the current location.\n const activeLinks = this.linkTargets.filter(\n (link) => this.#getAnchorId(link) === this.#activeSectionId,\n );\n\n for (const link of this.linkTargets) {\n if (activeLinks.includes(link)) {\n link.setAttribute(\"aria-current\", \"location\");\n } else if (link.getAttribute(\"aria-current\") === \"location\") {\n // Reclaim only the value this controller publishes, so an author-owned\n // `aria-current=\"page\"` on a table-of-contents link survives.\n link.removeAttribute(\"aria-current\");\n }\n }\n\n if (!announce) return;\n\n const primaryLink = activeLinks[0];\n if (primaryLink) {\n this.dispatch(\"change\", { detail: { id: this.#activeSectionId, link: primaryLink } });\n }\n }\n\n /**\n * The current location already encoded in the DOM, i.e. the section anchored\n * by the first link carrying this controller's `aria-current=\"location\"`.\n * Empty when no link claims it (a genuinely fresh render).\n */\n #activeIdFromDom(): string {\n for (const link of this.linkTargets) {\n if (link.getAttribute(\"aria-current\") !== \"location\") continue;\n const id = this.#getAnchorId(link);\n if (id) return id;\n }\n return \"\";\n }\n\n /**\n * The section id a link anchors, resolved in a fixed order:\n *\n * 1. `href`, when it is a non-empty same-document fragment — the contract.\n * 2. otherwise `data-href`'s fragment — the fallback for a link whose `href`\n * must stay a real URL (a server-rendered permalink) or that is not an\n * `<a>` at all.\n * 3. otherwise `null`: the link anchors nothing here and is not observed.\n *\n * Step 2 is reached whenever `href` yields nothing usable — absent, `\"#\"`, or\n * a real URL — which is the whole point of the fallback: `href=\"/guide/usage\"`\n * with `data-href=\"#usage\"` is a permalink that also spies, and picking the\n * first *present* attribute instead of the first *usable* one would silently\n * exclude exactly that markup. When both are valid fragments `href` wins.\n */\n #getAnchorId(link: HTMLElement): string | null {\n return (\n this.#fragmentId(link.getAttribute(\"href\")) ??\n this.#fragmentId(link.getAttribute(\"data-href\"))\n );\n }\n\n /** The id in a `#fragment` value; `null` for absent, empty, or non-fragment. */\n #fragmentId(value: string | null): string | null {\n if (!value?.startsWith(\"#\")) return null;\n return value.substring(1) || null;\n }\n}\n"]}
|
|
@@ -9,21 +9,28 @@ import { Controller } from '@hotwired/stimulus';
|
|
|
9
9
|
*
|
|
10
10
|
* Markup contract (identifier: `stimeo--separator`):
|
|
11
11
|
* <!-- decorative -->
|
|
12
|
-
* <div data-controller="stimeo--separator"
|
|
12
|
+
* <div data-controller="stimeo--separator"
|
|
13
13
|
* data-stimeo--separator-orientation-value="horizontal"></div>
|
|
14
14
|
*
|
|
15
15
|
* <!-- focusable, value-bearing -->
|
|
16
|
-
* <div data-controller="stimeo--separator"
|
|
16
|
+
* <div data-controller="stimeo--separator"
|
|
17
17
|
* aria-labelledby="sidebar-heading" aria-controls="sidebar"
|
|
18
|
-
*
|
|
19
|
-
* aria-valuemin="0" aria-valuemax="100" aria-valuenow="50"
|
|
18
|
+
* data-stimeo--separator-orientation-value="vertical"
|
|
20
19
|
* data-stimeo--separator-focusable-value="true"
|
|
20
|
+
* data-stimeo--separator-min-value="0"
|
|
21
|
+
* data-stimeo--separator-max-value="100"
|
|
22
|
+
* data-stimeo--separator-step-value="1"
|
|
23
|
+
* data-stimeo--separator-value-value="50"
|
|
21
24
|
* data-action="keydown->stimeo--separator#onKeydown"></div>
|
|
22
25
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
26
|
+
* The Stimulus Values are the live inputs. The controller reflects them as
|
|
27
|
+
* `role`, `tabindex`, `aria-orientation`, and the range ARIA while connected,
|
|
28
|
+
* then restores the attributes it displaced on disconnect and before Turbo
|
|
29
|
+
* caches the page. Existing finite range ARIA is hydrated into otherwise
|
|
30
|
+
* absent Values once, which preserves progressively enhanced server markup
|
|
31
|
+
* without leaving two live sources of truth.
|
|
32
|
+
*
|
|
33
|
+
* `change` dispatches `{ value: number }`.
|
|
27
34
|
*
|
|
28
35
|
* @remarks
|
|
29
36
|
* Behavior only — line drawing is the consumer's CSS. The axis follows Window
|
|
@@ -32,13 +39,19 @@ import { Controller } from '@hotwired/stimulus';
|
|
|
32
39
|
* there, so it follows the slider convention (ArrowRight/ArrowUp increase).
|
|
33
40
|
* Home/End are optional in the pattern and are implemented here; F6 is not.
|
|
34
41
|
*
|
|
42
|
+
* Runtime Value changes repaint silently. A maximum below the effective
|
|
43
|
+
* minimum collapses to that minimum; non-finite bounds use `0`/`100`, and an
|
|
44
|
+
* invalid or non-positive step uses `1`. Finite endpoints remain reachable even
|
|
45
|
+
* when they do not align to the step grid.
|
|
46
|
+
*
|
|
35
47
|
* Because no position is ever applied here, two Window Splitter requirements
|
|
36
48
|
* fall to the consumer: `aria-controls` naming the **primary** pane — the one
|
|
37
49
|
* whose size the value reports — and `Enter` to toggle collapse/restore, since
|
|
38
50
|
* collapsing applies a position — {@link ResizableController} implements that
|
|
39
|
-
* key for the same divider. Because the increment direction is fixed, the
|
|
40
|
-
* be the left one for a vertical splitter and the bottom
|
|
41
|
-
* splitter: those are the panes that grow as
|
|
51
|
+
* key for the same divider. Because the increment direction is fixed, the
|
|
52
|
+
* primary pane can only be the left one for a vertical splitter and the bottom
|
|
53
|
+
* one for a horizontal splitter: those are the panes that grow as
|
|
54
|
+
* ArrowRight/ArrowUp raise the value.
|
|
42
55
|
*/
|
|
43
56
|
declare class SeparatorController extends Controller<HTMLElement> {
|
|
44
57
|
#private;
|
|
@@ -51,17 +64,47 @@ declare class SeparatorController extends Controller<HTMLElement> {
|
|
|
51
64
|
type: BooleanConstructor;
|
|
52
65
|
default: boolean;
|
|
53
66
|
};
|
|
67
|
+
min: {
|
|
68
|
+
type: NumberConstructor;
|
|
69
|
+
default: number;
|
|
70
|
+
};
|
|
71
|
+
max: {
|
|
72
|
+
type: NumberConstructor;
|
|
73
|
+
default: number;
|
|
74
|
+
};
|
|
54
75
|
step: {
|
|
55
76
|
type: NumberConstructor;
|
|
56
77
|
default: number;
|
|
57
78
|
};
|
|
79
|
+
value: {
|
|
80
|
+
type: NumberConstructor;
|
|
81
|
+
default: number;
|
|
82
|
+
};
|
|
58
83
|
};
|
|
59
84
|
static actions: readonly ["onKeydown"];
|
|
60
85
|
static events: readonly ["change"];
|
|
61
86
|
orientationValue: string;
|
|
62
87
|
focusableValue: boolean;
|
|
88
|
+
minValue: number;
|
|
89
|
+
maxValue: number;
|
|
63
90
|
stepValue: number;
|
|
91
|
+
valueValue: number;
|
|
92
|
+
/** Hydrates legacy ARIA input once, normalizes the current Value, and renders. */
|
|
64
93
|
connect(): void;
|
|
94
|
+
/** Cancels repaint work and returns every semantic attribute this instance controlled. */
|
|
95
|
+
disconnect(): void;
|
|
96
|
+
/** Silently repaints an orientation changed by application code or a Turbo morph. */
|
|
97
|
+
orientationValueChanged(): void;
|
|
98
|
+
/** Silently adds or removes the focusable range semantics at runtime. */
|
|
99
|
+
focusableValueChanged(): void;
|
|
100
|
+
/** Silently repaints a minimum changed by application code or a Turbo morph. */
|
|
101
|
+
minValueChanged(): void;
|
|
102
|
+
/** Silently repaints a maximum changed by application code or a Turbo morph. */
|
|
103
|
+
maxValueChanged(): void;
|
|
104
|
+
/** Silently repaints a step changed by application code or a Turbo morph. */
|
|
105
|
+
stepValueChanged(): void;
|
|
106
|
+
/** Silently repaints a current value changed by application code or a Turbo morph. */
|
|
107
|
+
valueValueChanged(): void;
|
|
65
108
|
/** Adjusts the value on arrow / Home / End keys (focusable variant only). */
|
|
66
109
|
onKeydown(event: KeyboardEvent): void;
|
|
67
110
|
}
|