stimeo-ui 0.7.0 → 0.9.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 +151 -0
- package/dist/controllers/auto_submit_controller.d.ts +14 -3
- package/dist/controllers/auto_submit_controller.js +94 -16
- package/dist/controllers/auto_submit_controller.js.map +1 -1
- package/dist/controllers/bulk_select_controller.d.ts +62 -15
- package/dist/controllers/bulk_select_controller.js +139 -28
- package/dist/controllers/bulk_select_controller.js.map +1 -1
- package/dist/controllers/carousel_controller.d.ts +81 -47
- package/dist/controllers/carousel_controller.js +451 -100
- package/dist/controllers/carousel_controller.js.map +1 -1
- package/dist/controllers/clipboard_controller.d.ts +48 -15
- package/dist/controllers/clipboard_controller.js +102 -20
- package/dist/controllers/clipboard_controller.js.map +1 -1
- package/dist/controllers/color_picker_controller.d.ts +37 -6
- package/dist/controllers/color_picker_controller.js +180 -43
- package/dist/controllers/color_picker_controller.js.map +1 -1
- package/dist/controllers/currency_input_controller.d.ts +39 -5
- package/dist/controllers/currency_input_controller.js +305 -74
- package/dist/controllers/currency_input_controller.js.map +1 -1
- package/dist/controllers/data_grid_controller.d.ts +25 -9
- package/dist/controllers/data_grid_controller.js +150 -24
- package/dist/controllers/data_grid_controller.js.map +1 -1
- package/dist/controllers/direct_upload_controller.d.ts +3 -1
- package/dist/controllers/direct_upload_controller.js +12 -2
- package/dist/controllers/direct_upload_controller.js.map +1 -1
- package/dist/controllers/editable_controller.d.ts +34 -9
- package/dist/controllers/editable_controller.js +83 -30
- package/dist/controllers/editable_controller.js.map +1 -1
- package/dist/controllers/file_dropzone_controller.d.ts +123 -29
- package/dist/controllers/file_dropzone_controller.js +386 -63
- package/dist/controllers/file_dropzone_controller.js.map +1 -1
- package/dist/controllers/filter_controller.d.ts +15 -3
- package/dist/controllers/filter_controller.js +32 -1
- package/dist/controllers/filter_controller.js.map +1 -1
- package/dist/controllers/flash_controller.d.ts +3 -1
- package/dist/controllers/flash_controller.js +3 -1
- package/dist/controllers/flash_controller.js.map +1 -1
- package/dist/controllers/frame_loading_controller.d.ts +4 -2
- package/dist/controllers/frame_loading_controller.js +2 -1
- package/dist/controllers/frame_loading_controller.js.map +1 -1
- package/dist/controllers/input_mask_controller.d.ts +42 -16
- package/dist/controllers/input_mask_controller.js +251 -76
- package/dist/controllers/input_mask_controller.js.map +1 -1
- package/dist/controllers/masonry_controller.d.ts +34 -5
- package/dist/controllers/masonry_controller.js +129 -17
- package/dist/controllers/masonry_controller.js.map +1 -1
- package/dist/controllers/nested_form_controller.d.ts +51 -14
- package/dist/controllers/nested_form_controller.js +450 -42
- package/dist/controllers/nested_form_controller.js.map +1 -1
- package/dist/controllers/otp_controller.d.ts +64 -25
- package/dist/controllers/otp_controller.js +485 -114
- package/dist/controllers/otp_controller.js.map +1 -1
- package/dist/controllers/reset_before_cache_controller.d.ts +25 -2
- package/dist/controllers/reset_before_cache_controller.js +51 -5
- package/dist/controllers/reset_before_cache_controller.js.map +1 -1
- package/dist/controllers/resizable_controller.d.ts +23 -7
- package/dist/controllers/resizable_controller.js +128 -55
- package/dist/controllers/resizable_controller.js.map +1 -1
- package/dist/controllers/spinner_controller.d.ts +3 -2
- package/dist/controllers/spinner_controller.js +7 -5
- package/dist/controllers/spinner_controller.js.map +1 -1
- package/dist/controllers/submit_once_controller.d.ts +4 -1
- package/dist/controllers/submit_once_controller.js +3 -1
- package/dist/controllers/submit_once_controller.js.map +1 -1
- package/dist/controllers/textarea_autosize_controller.d.ts +30 -10
- package/dist/controllers/textarea_autosize_controller.js +131 -3
- package/dist/controllers/textarea_autosize_controller.js.map +1 -1
- package/dist/index.js +2764 -923
- package/dist/index.js.map +1 -1
- package/dist/inspector/cli.d.ts +8 -1
- package/dist/inspector/cli.js +5 -1
- package/dist/inspector/cli.js.map +1 -1
- package/dist/inspector/cli_bin.js +5 -1
- package/dist/inspector/cli_bin.js.map +1 -1
- package/dist/inspector/examples.json +24 -24
- package/dist/inspector/manifest.json +193 -30
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/logical_scroll.ts","../../src/utils/arrow_step.ts","../../src/utils/microtask_coalescer.ts","../../src/utils/roving_tabindex.ts","../../src/utils/safe_timeout.ts","../../src/controllers/carousel_controller.ts"],"names":[],"mappings":";;;;;AAiBO,SAAS,MAAM,OAAA,EAA2B;AAC/C,EAAA,OAAO,MAAA,CAAO,gBAAA,CAAiB,OAAO,CAAA,CAAE,SAAA,KAAc,KAAA;AACxD;;;ACiBO,SAAS,gBAAA,CAAiB,KAAa,OAAA,EAA8B;AAC1E,EAAA,IAAI,GAAA,KAAQ,aAAa,OAAO,CAAA;AAChC,EAAA,IAAI,GAAA,KAAQ,WAAW,OAAO,EAAA;AAC9B,EAAA,IAAI,GAAA,KAAQ,YAAA,IAAgB,GAAA,KAAQ,WAAA,EAAa,OAAO,CAAA;AACxD,EAAA,MAAM,OAAA,GAAU,KAAA,CAAM,OAAO,CAAA,GAAI,WAAA,GAAc,YAAA;AAC/C,EAAA,OAAO,GAAA,KAAQ,UAAU,CAAA,GAAI,EAAA;AAC/B;AAqDO,SAAS,oBAAA,CACd,KAAA,EACA,KAAA,GAAkC,EAAC,EAC1B;AACT,EAAA,IAAI,CAAC,KAAA,CAAM,GAAA,CAAI,UAAA,CAAW,OAAO,GAAG,OAAO,KAAA;AAC3C,EAAA,OACG,KAAA,CAAM,MAAA,IAAU,CAAC,KAAA,CAAM,QAAA,CAAS,KAAK,CAAA,IACrC,KAAA,CAAM,OAAA,IAAW,CAAC,KAAA,CAAM,QAAA,CAAS,MAAM,KACvC,KAAA,CAAM,OAAA,IAAW,CAAC,KAAA,CAAM,QAAA,CAAS,MAAM,CAAA,IACvC,KAAA,CAAM,QAAA,IAAY,CAAC,KAAA,CAAM,QAAA,CAAS,OAAO,CAAA;AAE9C;;;ACrDO,IAAM,qBAAN,MAAyB;AAAA,EACrB,IAAA;AAAA,EACT,OAAA,GAAU,KAAA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CAAC,SAAA,IAAa,IAAA,CAAK,aAAa,IAAA,EAAM;AAC/C,MAAA,IAAA,CAAK,UAAA,CAAW,KAAA,CAAM,IAAA,CAAK,QAAQ,CAAA;AACnC,MAAA,IAAA,CAAK,QAAA,GAAW,IAAA;AAChB,MAAA,IAAA,CAAK,SAAS,OAAO,CAAA;AAAA,IACvB;AAEA,IAAA,IAAI,KAAK,mBAAA,EAAqB;AAC5B,MAAA,IAAA,CAAK,iBAAiB,YAAA,CAAa,cAAA,EAAgB,IAAA,CAAK,QAAA,GAAW,SAAS,OAAO,CAAA;AAAA,IACrF;AAAA,EACF;AACF","file":"carousel_controller.js","sourcesContent":["/** Normalized scroll position and maximum distance on one logical axis. */\nexport interface LogicalScrollMetrics {\n position: number;\n max: number;\n}\n\n/**\n * Whether horizontal scrolling on `element` follows right-to-left inline flow.\n *\n * Resolved from the **computed** `direction`, so the authoring contract is the\n * usual `dir=\"rtl\"` (or a stylesheet) on the element or any ancestor.\n *\n * Scope: horizontal writing modes. A vertical writing mode (`writing-mode:\n * vertical-rl`) also inverts the horizontal axis, which this check does not\n * model — vertical writing modes are out of scope for the scroll utilities\n * (their consumers describe axes as horizontal/vertical, not inline/block).\n */\nexport function isRtl(element: Element): boolean {\n return window.getComputedStyle(element).direction === \"rtl\";\n}\n\n/**\n * Returns scroll distance from the logical start edge.\n *\n * CSSOM View exposes standards-mode RTL horizontal offsets as `0` at the inline\n * start (right) and increasingly negative values toward the inline end (left).\n * The normalized position is always clamped to `[0, max]`, which also absorbs\n * Safari's elastic overscroll values.\n */\nexport function logicalScrollMetrics(\n element: HTMLElement,\n horizontal: boolean,\n): LogicalScrollMetrics {\n const max = Math.max(\n 0,\n horizontal\n ? element.scrollWidth - element.clientWidth\n : element.scrollHeight - element.clientHeight,\n );\n const raw = horizontal ? element.scrollLeft : element.scrollTop;\n const position = horizontal && isRtl(element) ? -raw : raw;\n return { position: Math.min(max, Math.max(0, position)), max };\n}\n\n/**\n * Converts a logical start/end delta to the physical value accepted by\n * `Element.scrollBy`.\n */\nexport function physicalScrollDelta(\n element: HTMLElement,\n horizontal: boolean,\n logicalDelta: number,\n): number {\n return horizontal && isRtl(element) ? -logicalDelta : logicalDelta;\n}\n","import { isRtl } from \"./logical_scroll\";\n\n/**\n * Turns an arrow key into a **logical** step: `+1` for \"next\", `-1` for\n * \"previous\", `0` when the key names neither.\n *\n * APG defines the horizontal pair as *next / previous* and says a vertical\n * arrangement swaps in Down/Up for the same meaning — so the pair is one axis's\n * spelling of an order, and the order reverses with the writing direction. Only\n * the horizontal pair reverses. Down/Up name an axis the writing direction does\n * not mirror, and returning them unchanged is the point: many controllers fold\n * both pairs into one branch, where swapping the branches under RTL would flip\n * the vertical axis too — a bug that reads as \"the arrows work\" until someone\n * presses Down.\n *\n * **Direction is read from the element the caller passes, which should be the\n * container that lays the items out** — not the focused child. A child may carry\n * its own `dir` (an LTR input inside an RTL form is ordinary authoring), and\n * probing per handler makes two handlers disagree at the boundary between them.\n *\n * This decides direction only. Whether the axis is even active (an\n * `orientation=\"horizontal\"` widget ignoring Down/Up), how far the step lands,\n * and what wrapping does all stay with the caller.\n *\n * **It encodes the list-order convention: `ArrowDown` is *next*.** Widgets that\n * pair the arrows by *value* instead — `ArrowUp` meaning \"more\", as a rating or a\n * slider does — must not use this, or their vertical axis inverts. Reverse the\n * horizontal pair on its own there.\n *\n * @example\n * ```ts\n * const step = logicalArrowStep(event.key, this.element);\n * if (step === 0) return;\n * this.#roving.setActive(rovingMove(current, length, step, \"wrap\"), { focus: true });\n * ```\n */\nexport function logicalArrowStep(key: string, element: Element): 1 | -1 | 0 {\n if (key === \"ArrowDown\") return 1;\n if (key === \"ArrowUp\") return -1;\n if (key !== \"ArrowRight\" && key !== \"ArrowLeft\") return 0;\n const forward = isRtl(element) ? \"ArrowLeft\" : \"ArrowRight\";\n return key === forward ? 1 : -1;\n}\n\n/**\n * Rewrites `key` so an existing LTR-shaped branch keeps working under RTL:\n * `ArrowRight` and `ArrowLeft` trade places, everything else passes through.\n *\n * The alternative — negating a delta — silently breaks handlers whose two\n * horizontal branches are **not mirror images**. A grid that clamps one edge but\n * not the other, or a segmented field guarding `index > 0` on one side and\n * `index < length - 1` on the other, ends up applying the wrong guard to the\n * wrong direction. Swapping the key leaves each branch, guards and all, exactly\n * where its author put it.\n *\n * Same rule as {@link logicalArrowStep} about which element to read: pass the\n * container that lays the items out, not the focused child.\n *\n * @example\n * ```ts\n * switch (logicalArrowKey(event.key, this.element)) {\n * case \"ArrowLeft\": // \"previous\" — whatever direction that is on screen\n * ```\n */\nexport function logicalArrowKey(key: string, element: Element): string {\n if (key !== \"ArrowRight\" && key !== \"ArrowLeft\") return key;\n if (!isRtl(element)) return key;\n return key === \"ArrowRight\" ? \"ArrowLeft\" : \"ArrowRight\";\n}\n\n/** Modifiers a widget may claim on an arrow key, named for the `allow` list. */\nexport type ArrowModifier = \"alt\" | \"ctrl\" | \"meta\" | \"shift\";\n\n/**\n * True when an arrow key arrived carrying a modifier the widget must leave to\n * the browser: return without calling `preventDefault()` and without moving any\n * state.\n *\n * A bare arrow belongs to the widget; a chorded one usually does not.\n * `Alt`/`Meta` plus a horizontal arrow is history back/forward on every desktop\n * browser, and a widget that swallows it makes the shortcut work or not\n * depending on where focus happens to sit — a coin-flip the user cannot see.\n *\n * `allow` is for the combinations APG assigns to a pattern **and the widget\n * actually implements** — today only Combobox's optional `Alt+Down`/`Alt+Up`.\n * Listing one the widget does not implement defeats the point: the chord then\n * runs the plain-arrow branch, which is exactly what this guard exists to stop.\n * Non-arrow keys return `false`, so chorded letters and\n * `Control+Home`/`Control+End` are untouched.\n *\n * @example\n * ```ts\n * if (isReservedArrowChord(event)) return;\n * ```\n */\nexport function isReservedArrowChord(\n event: KeyboardEvent,\n allow: readonly ArrowModifier[] = [],\n): boolean {\n if (!event.key.startsWith(\"Arrow\")) return false;\n return (\n (event.altKey && !allow.includes(\"alt\")) ||\n (event.ctrlKey && !allow.includes(\"ctrl\")) ||\n (event.metaKey && !allow.includes(\"meta\")) ||\n (event.shiftKey && !allow.includes(\"shift\"))\n );\n}\n","/**\n * Collapses many Stimulus lifecycle callbacks from one DOM mutation into a\n * single pass.\n *\n * Stimulus fires `<name>TargetConnected` / `Disconnected` once per element and\n * `<name>ValueChanged` once per changed attribute. Replacing a list of N options\n * or morphing several render Values therefore delivers N callbacks — but the\n * useful unit of work is \"reconcile against the resulting declarative input\",\n * once, after the batch has settled. Every controller with reconcilable targets\n * or render Values needs the same shape: a `queued` flag plus `queueMicrotask`.\n *\n * **A microtask is the right horizon, and the reason is specific.** Stimulus\n * drives these callbacks from a `MutationObserver`, whose own callback already\n * runs as a microtask with the whole batch in hand; scheduling one more lands\n * after the last sibling callback of that batch and still before paint or any\n * event handler. A timer would be later than it needs to be, and reconciling\n * synchronously would run once per element against a half-applied DOM.\n *\n * **The two guards are not the same guard.** Scheduling is refused before the\n * controller connects, and running is refused after it disconnects:\n *\n * - **Before `connect()`** — Stimulus delivers initial target and Value callbacks\n * ahead of `connect()`. Reconciling there would compute output against a\n * controller whose own state has not been initialised, and `connect()` is\n * about to do a full pass anyway.\n * - **After `disconnect()`** — Stimulus fires a callback for **every** target\n * during teardown, and a microtask queued just before it would otherwise run\n * against a detached tree. {@link MicrotaskCoalescer.cancel} exists for the\n * teardown path to drop the pending pass outright.\n *\n * Both guards are part of one contract here rather than something each consumer\n * has to remember separately.\n *\n * Scope is the scheduling only. *What* to reconcile — keep the surviving active\n * option, fall back to the next / previous / first visible one, rebuild derived\n * chips or hidden fields — stays in the controller, because no two consumers\n * answer it the same way.\n *\n * This file's own doc block is dropped from `dist`, but every member comment is\n * inlined into each consumer entry (`tsup` builds with `splitting: false`), so\n * rationale belongs here and only the contract belongs on the members.\n *\n * @example\n * ```ts\n * readonly #reconcile = new MicrotaskCoalescer(() => this.#reconcileOptions());\n *\n * connect() { this.#reconcile.activate(); }\n * disconnect() { this.#reconcile.cancel(); }\n *\n * optionTargetConnected() { this.#reconcile.schedule(); }\n * optionTargetDisconnected() { this.#reconcile.schedule(); }\n * ```\n */\nexport class MicrotaskCoalescer {\n readonly #run: () => void;\n #queued = false;\n #active = false;\n #generation = 0;\n\n /** @param run - the single reconciliation pass, invoked at most once per batch. */\n constructor(run: () => void) {\n this.#run = run;\n }\n\n /** Opens the window in which {@link schedule} is honoured; call from `connect()`. */\n activate(): void {\n this.#active = true;\n }\n\n /** Closes the window and drops any pending pass; call from `disconnect()`. */\n cancel(): void {\n this.#active = false;\n this.#queued = false;\n this.#generation += 1;\n }\n\n /** Requests one pass after the batch settles. Idempotent; inert outside the window. */\n schedule(): void {\n if (!this.#active || this.#queued) return;\n this.#queued = true;\n const generation = this.#generation;\n queueMicrotask(() => {\n // A cancelled callback must not consume a pass queued after reconnect.\n if (generation !== this.#generation || !this.#queued || !this.#active) return;\n this.#queued = false;\n this.#run();\n });\n }\n}\n","/**\n * Low-level roving-tabindex primitive shared by composite-widget controllers.\n *\n * The APG roving-tabindex pattern keeps a composite widget a single Tab stop:\n * exactly one item is in the Tab sequence (`tabindex=\"0\"`) while the rest are\n * removed from it (`tabindex=\"-1\"`), and the arrow keys move both DOM focus and\n * that single tabbable position together. {@link RovingTabindex} owns *only* that\n * mechanical bookkeeping — \"which one item is tabbable, and move focus there\".\n *\n * It is intentionally **policy-free**. Orientation, wrapping vs. clamping,\n * selection-follows-focus, typeahead, and `Home`/`End` semantics differ per APG\n * pattern (Radio Group, Toolbar, Rating, …); folding them into one helper would\n * flatten those widgets to a lowest common denominator and lose each pattern's\n * correctness. Those decisions therefore stay in each controller, which calls\n * {@link RovingTabindex.setActive} with an index it computed itself (optionally\n * via the pure {@link rovingMove} helper).\n *\n * @remarks\n * Items are read lazily through a getter so a controller can add or remove\n * targets (Stimulus re-scans the DOM) without re-wiring this helper. A caller\n * that already captured one event-scoped snapshot may pass it to\n * {@link RovingTabindex.setActive}, avoiding a second live-target scan while\n * preserving one coherent collection for the whole operation.\n */\nexport class RovingTabindex {\n /** Returns the current ordered item elements; called on every operation. */\n readonly #getItems: () => HTMLElement[];\n\n /**\n * @param getItems - Returns the current ordered item elements. Called on every\n * operation so the live target list is always used.\n */\n constructor(getItems: () => HTMLElement[]) {\n this.#getItems = getItems;\n }\n\n /** Index of the currently tabbable item (`tabindex=\"0\"`), or `-1` if none. */\n get activeIndex(): number {\n return this.#getItems().findIndex((item) => item.tabIndex === 0);\n }\n\n /**\n * Makes exactly the item at `index` tabbable (`tabindex=\"0\"`) and removes every\n * other item from the Tab sequence (`tabindex=\"-1\"`). An out-of-range `index`\n * (e.g. `-1`) leaves all items at `-1`, which a controller can use to express\n * \"nothing is currently tabbable\".\n *\n * @param index - Position of the item to make tabbable.\n * @param options - Pass `{ focus: true }` to also move DOM focus to that item,\n * and `items` to reuse an event-scoped collection snapshot.\n */\n setActive(\n index: number,\n options: { focus?: boolean; items?: readonly HTMLElement[] } = {},\n ): void {\n const { focus = false } = options;\n const items = options.items ?? this.#getItems();\n items.forEach((item, i) => {\n item.tabIndex = i === index ? 0 : -1;\n });\n if (focus) items[index]?.focus();\n }\n}\n\n/** Edge behavior for {@link rovingMove}: cycle past the ends, or stop at them. */\nexport type RovingWrap = \"wrap\" | \"clamp\";\n\n/**\n * Pure helper that resolves the target index for a one-step directional move.\n *\n * Keyboard/orientation mapping stays in the caller: it decides that a key means\n * `delta` `+1` (next) or `-1` (previous) and whether the widget should `\"wrap\"`\n * (Radio Group, Toolbar) or `\"clamp\"` at the ends.\n *\n * @param current - The index focus is moving from.\n * @param length - Number of items in the set.\n * @param delta - `+1` to move to the next item, `-1` for the previous.\n * @param wrap - `\"wrap\"` cycles around the ends; `\"clamp\"` stops at them.\n * @returns The resolved index, or `-1` when there are no items.\n */\nexport function rovingMove(\n current: number,\n length: number,\n delta: number,\n wrap: RovingWrap,\n): number {\n if (length === 0) return -1;\n const next = current + delta;\n if (wrap === \"wrap\") return (next + length) % length;\n return Math.min(length - 1, Math.max(0, next));\n}\n","/**\n * Self-cleaning timer registries shared by Stimeo controllers.\n *\n * Stimulus controllers frequently schedule `setTimeout` / `setInterval` work\n * (auto-dismiss, debouncing, polling). When the element leaves the DOM — a\n * Turbo Drive navigation, a Turbo Stream replacement, or any `disconnect()` —\n * orphaned timers keep firing against a detached controller, leaking memory and\n * mutating stale state. {@link SafeTimeout} and {@link SafeInterval} track every\n * timer they create so a single {@link TimerRegistry.clearAll | clearAll()} call\n * in `disconnect()` tears them all down.\n *\n * These are intentionally low-level primitives: they own *registration and\n * cleanup only*. Higher-level policy (pause/resume, remaining-time accounting)\n * stays in the individual controllers so per-widget semantics are not flattened\n * into a lowest-common-denominator helper.\n */\n\n/**\n * Shared registry bookkeeping for the timeout/interval variants.\n *\n * Subclasses provide the scheduling primitive ({@link schedule}) and its matching\n * canceller ({@link cancel}); this base owns the set of live ids plus the\n * per-id and bulk teardown shared by both.\n */\nabstract class TimerRegistry {\n /** Live timer ids that have not yet been cleared (or, for timeouts, fired). */\n protected readonly ids = new Set<number>();\n\n /** Schedules the underlying platform timer and returns its id. */\n protected abstract schedule(callback: () => void, delay: number): number;\n\n /** Cancels the underlying platform timer for `id`. */\n protected abstract cancel(id: number): void;\n\n /**\n * Cancels a single tracked timer.\n *\n * No-ops if the id is unknown (already cleared, fired, or never owned by this\n * registry), so callers can clear defensively without guarding.\n */\n clear(id: number): void {\n if (this.ids.delete(id)) {\n this.cancel(id);\n }\n }\n\n /**\n * Cancels every tracked timer. Call this from a controller's `disconnect()`\n * to guarantee no timer outlives the element.\n */\n clearAll(): void {\n for (const id of this.ids) {\n this.cancel(id);\n }\n this.ids.clear();\n }\n\n /** Number of timers currently tracked (pending). */\n get size(): number {\n return this.ids.size;\n }\n}\n\n/**\n * `setTimeout` wrapper that auto-forgets each timer once it fires and supports\n * bulk teardown on disconnect.\n *\n * @example\n * ```ts\n * #timers = new SafeTimeout();\n *\n * connect() {\n * this.#timers.set(() => this.dismiss(), 5000);\n * }\n *\n * disconnect() {\n * this.#timers.clearAll();\n * }\n * ```\n */\nexport class SafeTimeout extends TimerRegistry {\n /**\n * Schedules `callback` after `delay` ms and returns the timer id.\n *\n * The id is removed from the registry automatically when the timeout fires,\n * so {@link TimerRegistry.size | size} reflects only still-pending timers.\n */\n set(callback: () => void, delay: number): number {\n const id = this.schedule(() => {\n this.ids.delete(id);\n callback();\n }, delay);\n this.ids.add(id);\n return id;\n }\n\n protected schedule(callback: () => void, delay: number): number {\n return window.setTimeout(callback, delay);\n }\n\n protected cancel(id: number): void {\n window.clearTimeout(id);\n }\n}\n\n/**\n * `setInterval` wrapper that tracks every interval for bulk teardown on\n * disconnect. Unlike {@link SafeTimeout}, intervals are retained until they are\n * explicitly cleared because they fire repeatedly.\n *\n * @example\n * ```ts\n * #intervals = new SafeInterval();\n *\n * connect() {\n * this.#intervals.set(() => this.tick(), 1000);\n * }\n *\n * disconnect() {\n * this.#intervals.clearAll();\n * }\n * ```\n */\nexport class SafeInterval extends TimerRegistry {\n /** Schedules a repeating `callback` every `delay` ms and returns the timer id. */\n set(callback: () => void, delay: number): number {\n const id = this.schedule(callback, delay);\n this.ids.add(id);\n return id;\n }\n\n protected schedule(callback: () => void, delay: number): number {\n return window.setInterval(callback, delay);\n }\n\n protected cancel(id: number): void {\n window.clearInterval(id);\n }\n}\n","import { Controller } from \"@hotwired/stimulus\";\nimport { isReservedArrowChord, logicalArrowStep } from \"../utils/arrow_step\";\nimport { MicrotaskCoalescer } from \"../utils/microtask_coalescer\";\nimport { RovingTabindex, rovingMove } from \"../utils/roving_tabindex\";\nimport { SafeInterval } from \"../utils/safe_timeout\";\n\n/**\n * Headless, accessible **Carousel** (slideshow) behavior.\n *\n * Markup contract (identifier: `stimeo--carousel`):\n * <section data-controller=\"stimeo--carousel\" aria-roledescription=\"carousel\"\n * aria-label=\"Featured\"\n * data-stimeo--carousel-autoplay-value=\"false\"\n * data-stimeo--carousel-interval-value=\"5000\"\n * data-stimeo--carousel-loop-value=\"true\"\n * data-action=\"mouseenter->stimeo--carousel#pause\n * mouseleave->stimeo--carousel#resume\n * focusin->stimeo--carousel#pause\n * focusout->stimeo--carousel#resume\">\n * <button data-stimeo--carousel-target=\"playToggle\"\n * data-action=\"stimeo--carousel#togglePlay\">…</button>\n * <div data-stimeo--carousel-target=\"viewport\">\n * <div role=\"tabpanel\" data-stimeo--carousel-target=\"slide\">…</div>\n * <div role=\"tabpanel\" data-stimeo--carousel-target=\"slide\" hidden>…</div>\n * </div>\n * <button data-stimeo--carousel-target=\"prev\" data-action=\"stimeo--carousel#prev\">‹</button>\n * <button data-stimeo--carousel-target=\"next\" data-action=\"stimeo--carousel#next\">›</button>\n * <div role=\"tablist\">\n * <button role=\"tab\" data-stimeo--carousel-target=\"picker\"\n * data-action=\"stimeo--carousel#goto\n * keydown->stimeo--carousel#onPickerKeydown\"></button>\n * </div>\n * </section>\n *\n * Implements the WAI-ARIA APG **Carousel** (tabbed) pattern. The current slide is\n * exposed through `data-state` (`active`/`inactive`) and the `hidden` attribute on\n * inactive slides (removing them from focus order); the matching picker carries\n * `aria-selected` and the single roving `tabindex`. The play/pause toggle's\n * `aria-pressed` mirrors the autoplay state.\n *\n * @remarks\n * Behavior only — transitions, layout, and visuals are the consumer's CSS.\n * Autoplay honors WCAG 2.2.2: it suspends while the pointer is over the carousel\n * and **hard-stops** when keyboard focus enters (it does not silently resume on\n * focus out — the user must press play), so motion never surprises a keyboard\n * user. The interval is cleared on `disconnect()` (Turbo navigation included).\n * Picker arrow keys move focus only (manual activation); slide changes never steal\n * focus from the control the user operated. A slide change the user drove is\n * reported as `stimeo--carousel:change` with `{ index, total }`; the same detail\n * arrives as `stimeo--carousel:reconcile` when removing a slide or picker clamps\n * the active index instead.\n */\nexport class CarouselController extends Controller<HTMLElement> {\n static override targets = [\"slide\", \"viewport\", \"prev\", \"next\", \"picker\", \"playToggle\"];\n static override values = {\n autoplay: { type: Boolean, default: false },\n interval: { type: Number, default: 5000 },\n loop: { type: Boolean, default: true },\n };\n static actions = [\n \"goto\",\n \"next\",\n \"onPickerKeydown\",\n \"pause\",\n \"prev\",\n \"resume\",\n \"togglePlay\",\n ] as const;\n static events = [\"change\", \"pause\", \"play\", \"reconcile\"] as const;\n\n declare readonly slideTargets: HTMLElement[];\n declare readonly pickerTargets: HTMLElement[];\n declare readonly playToggleTarget: HTMLElement;\n declare readonly hasPlayToggleTarget: boolean;\n declare autoplayValue: boolean;\n declare intervalValue: number;\n declare loopValue: boolean;\n\n readonly #roving = new RovingTabindex(() => this.pickerTargets);\n readonly #reconcileTargets = new MicrotaskCoalescer(() => this.#reconcileTargetSet());\n /**\n * Whether `connect()` has run. Scheduling is already inert outside that window\n * ({@link MicrotaskCoalescer}), so this only gates the Tab stop a picker\n * present at mount authored for itself.\n */\n #connected = false;\n readonly #intervals = new SafeInterval();\n /** Index of the visible slide. */\n #index = 0;\n /** User intent to autoplay (toggled by the play button / focus hard-stop). */\n #playing = false;\n /** Pointer is hovering the carousel: a temporary, auto-resuming suspension. */\n #pointerPaused = false;\n /** Id of the live autoplay interval, or null when stopped. */\n #timerId: number | null = null;\n\n /**\n * Renders the initial slide and starts autoplay when requested.\n *\n * `findIndex` makes the authored pre-selection first-wins when several pickers\n * are marked; `#render` then writes an explicit value onto every picker.\n */\n override connect(): void {\n const preselected = this.pickerTargets.findIndex(\n (picker) => picker.getAttribute(\"aria-selected\") === \"true\",\n );\n this.#index = preselected === -1 ? 0 : preselected;\n this.#playing = this.#initialPlaying();\n this.#render({ focus: false });\n this.#syncTimer();\n this.#connected = true;\n this.#reconcileTargets.activate();\n }\n\n /**\n * Re-establishes the single selected picker when one is added after connect.\n *\n * Without this an appended picker that arrives `aria-selected=\"true\"` leaves two\n * marked at once — the authored pre-selection is only read on connect, so\n * nothing else ever resolves the conflict. The current slide is kept: the\n * repaint re-derives every picker from `#index`, so a late arrival never steals\n * the selection.\n */\n pickerTargetConnected(picker: HTMLElement): void {\n if (!this.#connected) return;\n picker.tabIndex = -1;\n this.#reconcileTargets.schedule();\n }\n\n /** Repairs selection and roving after a picker leaves a retained carousel. */\n pickerTargetDisconnected(): void {\n this.#reconcileTargets.schedule();\n }\n\n /** Reconciles a slide added in the same DOM batch as its picker. */\n slideTargetConnected(): void {\n this.#reconcileTargets.schedule();\n }\n\n /** Re-clamps the active index after a slide is removed. */\n slideTargetDisconnected(): void {\n this.#reconcileTargets.schedule();\n }\n\n /**\n * Resolves the starting autoplay intent. The play toggle's `aria-pressed` is the\n * source of truth **when present**, so a Turbo Drive cache restore / morph that\n * re-runs `connect()` against existing DOM does not silently resume autoplay the\n * user had stopped (e.g. by focusing into the carousel). Only when no toggle\n * carries `aria-pressed` does it fall back to the declarative `autoplay` value.\n */\n #initialPlaying(): boolean {\n if (this.hasPlayToggleTarget && this.playToggleTarget.hasAttribute(\"aria-pressed\")) {\n return this.playToggleTarget.getAttribute(\"aria-pressed\") === \"true\";\n }\n return this.autoplayValue;\n }\n\n /** Clears the autoplay interval so it never fires after teardown. */\n override disconnect(): void {\n this.#connected = false;\n this.#reconcileTargets.cancel();\n this.#intervals.clearAll();\n this.#timerId = null;\n }\n\n /** Advances to the next slide. Bound via `data-action`. */\n next(): void {\n this.#select(this.#step(1), { focus: false });\n }\n\n /** Returns to the previous slide. Bound via `data-action`. */\n prev(): void {\n this.#select(this.#step(-1), { focus: false });\n }\n\n /** Jumps to the slide whose picker was activated (click / Enter / Space). */\n goto(event: Event): void {\n const target = event.currentTarget as HTMLElement;\n const index = this.pickerTargets.indexOf(target);\n if (index !== -1) this.#select(index, { focus: false });\n }\n\n /** Toggles autoplay on the user's explicit request and syncs the timer. */\n togglePlay(): void {\n this.#playing = !this.#playing;\n this.#syncTimer();\n }\n\n /**\n * Suspends autoplay. Hover (`mouseenter`) is a temporary suspension that resumes\n * on leave; keyboard focus (`focusin`) is a hard stop that turns autoplay off so\n * it cannot resume without an explicit play (WCAG 2.2.2).\n */\n pause(event?: Event): void {\n if (event?.type.startsWith(\"focus\")) {\n this.#playing = false;\n } else {\n this.#pointerPaused = true;\n }\n this.#syncTimer();\n }\n\n /**\n * Lifts a hover suspension (`mouseleave`) and resumes autoplay if it is still\n * on. A `focusout` does nothing here: the focus pause was a hard stop, so the\n * user must press play to restart.\n */\n resume(event?: Event): void {\n if (event?.type.startsWith(\"focus\")) return;\n this.#pointerPaused = false;\n this.#syncTimer();\n }\n\n /** Picker roving: arrows move focus only; Home/End activate first/last slide. */\n onPickerKeydown(event: KeyboardEvent): void {\n // A descendant widget that already claimed the key must not ALSO move the\n // picker focus or change the slide — composition depends on this yield.\n if (event.defaultPrevented) return;\n if (isReservedArrowChord(event)) return;\n const current = this.pickerTargets.indexOf(event.currentTarget as HTMLElement);\n if (current === -1) return;\n\n const length = this.pickerTargets.length;\n // Logical, not physical. The helper reverses only the horizontal\n // pair, so folding Down/Up into the same branch stays correct.\n switch (event.key) {\n case \"ArrowRight\":\n case \"ArrowDown\":\n case \"ArrowLeft\":\n case \"ArrowUp\": {\n event.preventDefault();\n const step = logicalArrowStep(event.key, this.element);\n this.#roving.setActive(rovingMove(current, length, step, \"wrap\"), { focus: true });\n return;\n }\n case \"Home\":\n event.preventDefault();\n this.#select(0, { focus: true });\n return;\n case \"End\":\n event.preventDefault();\n this.#select(length - 1, { focus: true });\n return;\n default:\n }\n }\n\n /** Resolves the index one step away from the current one, honoring `loop`. */\n #step(delta: number): number {\n const total = this.slideTargets.length;\n if (total === 0) return 0;\n const next = this.#index + delta;\n if (this.loopValue) return (next + total) % total;\n return Math.min(total - 1, Math.max(0, next));\n }\n\n /**\n * Changes the active slide, updates state hooks, and emits `change` — but only\n * when the index actually changes, so a `next`/`prev` clamped at the end (or an\n * autoplay tick at a non-looping boundary) re-renders without a spurious event\n * (matching the \"emit on real change\" policy of flash/masonry/bulk-select).\n */\n #select(index: number, { focus }: { focus: boolean }): void {\n const changed = index !== this.#index;\n this.#index = index;\n this.#render({ focus });\n // Re-evaluate autoplay after every move so reaching the non-looping end stops\n // the timer (see `#syncTimer`); idempotent for moves that don't cross a boundary.\n this.#syncTimer();\n if (changed) this.dispatch(\"change\", { detail: { index, total: this.slideTargets.length } });\n }\n\n /**\n * Reflects `this.#index` onto slides and pickers (state hooks + roving).\n *\n * @stimeoRenderRoot\n */\n #render({ focus }: { focus: boolean }): void {\n this.slideTargets.forEach((slide, i) => {\n const active = i === this.#index;\n slide.setAttribute(\"data-state\", active ? \"active\" : \"inactive\");\n slide.hidden = !active;\n });\n // The picker set can be shorter than the slide set (a picker removed on its\n // own, or a carousel that only pickers part of its slides). Resolving the\n // selection inside the picker range keeps exactly one selected tab and one Tab\n // stop; an out-of-range index would leave every picker at `tabindex=\"-1\"` and\n // strand the tablist outside the Tab sequence.\n const pickerIndex = Math.min(this.#index, this.pickerTargets.length - 1);\n this.pickerTargets.forEach((picker, i) => {\n picker.setAttribute(\"aria-selected\", i === pickerIndex ? \"true\" : \"false\");\n });\n this.#roving.setActive(pickerIndex, { focus });\n }\n\n /** Keeps the live active slide when possible and otherwise selects the nearest survivor. */\n #reconcileTargetSet(): void {\n const activeSlide = this.slideTargets.findIndex(\n (slide) => slide.getAttribute(\"data-state\") === \"active\",\n );\n const selectedPicker = this.pickerTargets.findIndex(\n (picker) => picker.getAttribute(\"aria-selected\") === \"true\",\n );\n const lastSlide = this.slideTargets.length - 1;\n const candidate =\n activeSlide !== -1 ? activeSlide : selectedPicker !== -1 ? selectedPicker : this.#index;\n const previous = this.#index;\n this.#index = lastSlide < 0 ? 0 : Math.min(lastSlide, Math.max(0, candidate));\n this.#render({ focus: false });\n this.#syncTimer();\n // `change` stays reserved for user navigation; a clamp onto the nearest\n // surviving slide is this controller's decision, not the reader's.\n if (this.#index !== previous) {\n this.dispatch(\"reconcile\", {\n detail: { index: this.#index, total: this.slideTargets.length },\n });\n }\n }\n\n /**\n * Drives the autoplay interval toward the desired state. Autoplay should run\n * only when the user wants it (`playing`), the pointer is not hovering, and more\n * than one slide exists. Transitions emit `play`/`pause` and keep the toggle's\n * `aria-pressed` in sync.\n */\n #syncTimer(): void {\n // A non-looping carousel sitting on its last slide has nothing left to advance\n // to, so autoplay turns itself off (a hard stop, like the focus pause): the\n // timer is cleared, `aria-pressed` flips to false, and a manual step back will\n // not silently restart it without an explicit play.\n if (!this.loopValue && this.#index >= this.slideTargets.length - 1) {\n this.#playing = false;\n }\n const shouldRun = this.#playing && !this.#pointerPaused && this.slideTargets.length > 1;\n\n if (shouldRun && this.#timerId === null) {\n this.#timerId = this.#intervals.set(() => this.next(), this.intervalValue);\n this.dispatch(\"play\");\n } else if (!shouldRun && this.#timerId !== null) {\n this.#intervals.clear(this.#timerId);\n this.#timerId = null;\n this.dispatch(\"pause\");\n }\n\n if (this.hasPlayToggleTarget) {\n this.playToggleTarget.setAttribute(\"aria-pressed\", this.#playing ? \"true\" : \"false\");\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/logical_scroll.ts","../../src/utils/arrow_step.ts","../../src/utils/attribute_lease.ts","../../src/utils/before_cache_reset.ts","../../src/utils/microtask_coalescer.ts","../../src/utils/reduced_motion.ts","../../src/utils/roving_tabindex.ts","../../src/utils/safe_timeout.ts","../../src/controllers/carousel_controller.ts"],"names":[],"mappings":";;;;;AAiBO,SAAS,MAAM,OAAA,EAA2B;AAC/C,EAAA,OAAO,MAAA,CAAO,gBAAA,CAAiB,OAAO,CAAA,CAAE,SAAA,KAAc,KAAA;AACxD;;;ACiBO,SAAS,gBAAA,CAAiB,KAAa,OAAA,EAA8B;AAC1E,EAAA,IAAI,GAAA,KAAQ,aAAa,OAAO,CAAA;AAChC,EAAA,IAAI,GAAA,KAAQ,WAAW,OAAO,EAAA;AAC9B,EAAA,IAAI,GAAA,KAAQ,YAAA,IAAgB,GAAA,KAAQ,WAAA,EAAa,OAAO,CAAA;AACxD,EAAA,MAAM,OAAA,GAAU,KAAA,CAAM,OAAO,CAAA,GAAI,WAAA,GAAc,YAAA;AAC/C,EAAA,OAAO,GAAA,KAAQ,UAAU,CAAA,GAAI,EAAA;AAC/B;AAqDO,SAAS,oBAAA,CACd,KAAA,EACA,KAAA,GAAkC,EAAC,EAC1B;AACT,EAAA,IA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AAClF,EAAA,IAAI,OAAA,CAAQ,aAAa,IAAI,CAAA,KAAM,OAAO,OAAA,CAAQ,YAAA,CAAa,MAAM,KAAK,CAAA;AAC5E","file":"carousel_controller.js","sourcesContent":["/** Normalized scroll position and maximum distance on one logical axis. */\nexport interface LogicalScrollMetrics {\n position: number;\n max: number;\n}\n\n/**\n * Whether horizontal scrolling on `element` follows right-to-left inline flow.\n *\n * Resolved from the **computed** `direction`, so the authoring contract is the\n * usual `dir=\"rtl\"` (or a stylesheet) on the element or any ancestor.\n *\n * Scope: horizontal writing modes. A vertical writing mode (`writing-mode:\n * vertical-rl`) also inverts the horizontal axis, which this check does not\n * model — vertical writing modes are out of scope for the scroll utilities\n * (their consumers describe axes as horizontal/vertical, not inline/block).\n */\nexport function isRtl(element: Element): boolean {\n return window.getComputedStyle(element).direction === \"rtl\";\n}\n\n/**\n * Returns scroll distance from the logical start edge.\n *\n * CSSOM View exposes standards-mode RTL horizontal offsets as `0` at the inline\n * start (right) and increasingly negative values toward the inline end (left).\n * The normalized position is always clamped to `[0, max]`, which also absorbs\n * Safari's elastic overscroll values.\n */\nexport function logicalScrollMetrics(\n element: HTMLElement,\n horizontal: boolean,\n): LogicalScrollMetrics {\n const max = Math.max(\n 0,\n horizontal\n ? element.scrollWidth - element.clientWidth\n : element.scrollHeight - element.clientHeight,\n );\n const raw = horizontal ? element.scrollLeft : element.scrollTop;\n const position = horizontal && isRtl(element) ? -raw : raw;\n return { position: Math.min(max, Math.max(0, position)), max };\n}\n\n/**\n * Converts a logical start/end delta to the physical value accepted by\n * `Element.scrollBy`.\n */\nexport function physicalScrollDelta(\n element: HTMLElement,\n horizontal: boolean,\n logicalDelta: number,\n): number {\n return horizontal && isRtl(element) ? -logicalDelta : logicalDelta;\n}\n","import { isRtl } from \"./logical_scroll\";\n\n/**\n * Turns an arrow key into a **logical** step: `+1` for \"next\", `-1` for\n * \"previous\", `0` when the key names neither.\n *\n * APG defines the horizontal pair as *next / previous* and says a vertical\n * arrangement swaps in Down/Up for the same meaning — so the pair is one axis's\n * spelling of an order, and the order reverses with the writing direction. Only\n * the horizontal pair reverses. Down/Up name an axis the writing direction does\n * not mirror, and returning them unchanged is the point: many controllers fold\n * both pairs into one branch, where swapping the branches under RTL would flip\n * the vertical axis too — a bug that reads as \"the arrows work\" until someone\n * presses Down.\n *\n * **Direction is read from the element the caller passes, which should be the\n * container that lays the items out** — not the focused child. A child may carry\n * its own `dir` (an LTR input inside an RTL form is ordinary authoring), and\n * probing per handler makes two handlers disagree at the boundary between them.\n *\n * This decides direction only. Whether the axis is even active (an\n * `orientation=\"horizontal\"` widget ignoring Down/Up), how far the step lands,\n * and what wrapping does all stay with the caller.\n *\n * **It encodes the list-order convention: `ArrowDown` is *next*.** Widgets that\n * pair the arrows by *value* instead — `ArrowUp` meaning \"more\", as a rating or a\n * slider does — must not use this, or their vertical axis inverts. Reverse the\n * horizontal pair on its own there.\n *\n * @example\n * ```ts\n * const step = logicalArrowStep(event.key, this.element);\n * if (step === 0) return;\n * this.#roving.setActive(rovingMove(current, length, step, \"wrap\"), { focus: true });\n * ```\n */\nexport function logicalArrowStep(key: string, element: Element): 1 | -1 | 0 {\n if (key === \"ArrowDown\") return 1;\n if (key === \"ArrowUp\") return -1;\n if (key !== \"ArrowRight\" && key !== \"ArrowLeft\") return 0;\n const forward = isRtl(element) ? \"ArrowLeft\" : \"ArrowRight\";\n return key === forward ? 1 : -1;\n}\n\n/**\n * Rewrites `key` so an existing LTR-shaped branch keeps working under RTL:\n * `ArrowRight` and `ArrowLeft` trade places, everything else passes through.\n *\n * The alternative — negating a delta — silently breaks handlers whose two\n * horizontal branches are **not mirror images**. A grid that clamps one edge but\n * not the other, or a segmented field guarding `index > 0` on one side and\n * `index < length - 1` on the other, ends up applying the wrong guard to the\n * wrong direction. Swapping the key leaves each branch, guards and all, exactly\n * where its author put it.\n *\n * Same rule as {@link logicalArrowStep} about which element to read: pass the\n * container that lays the items out, not the focused child.\n *\n * @example\n * ```ts\n * switch (logicalArrowKey(event.key, this.element)) {\n * case \"ArrowLeft\": // \"previous\" — whatever direction that is on screen\n * ```\n */\nexport function logicalArrowKey(key: string, element: Element): string {\n if (key !== \"ArrowRight\" && key !== \"ArrowLeft\") return key;\n if (!isRtl(element)) return key;\n return key === \"ArrowRight\" ? \"ArrowLeft\" : \"ArrowRight\";\n}\n\n/** Modifiers a widget may claim on an arrow key, named for the `allow` list. */\nexport type ArrowModifier = \"alt\" | \"ctrl\" | \"meta\" | \"shift\";\n\n/**\n * True when an arrow key arrived carrying a modifier the widget must leave to\n * the browser: return without calling `preventDefault()` and without moving any\n * state.\n *\n * A bare arrow belongs to the widget; a chorded one usually does not.\n * `Alt`/`Meta` plus a horizontal arrow is history back/forward on every desktop\n * browser, and a widget that swallows it makes the shortcut work or not\n * depending on where focus happens to sit — a coin-flip the user cannot see.\n *\n * `allow` is for the combinations APG assigns to a pattern **and the widget\n * actually implements** — today only Combobox's optional `Alt+Down`/`Alt+Up`.\n * Listing one the widget does not implement defeats the point: the chord then\n * runs the plain-arrow branch, which is exactly what this guard exists to stop.\n * Non-arrow keys return `false`, so chorded letters and\n * `Control+Home`/`Control+End` are untouched.\n *\n * @example\n * ```ts\n * if (isReservedArrowChord(event)) return;\n * ```\n */\nexport function isReservedArrowChord(\n event: KeyboardEvent,\n allow: readonly ArrowModifier[] = [],\n): boolean {\n if (!event.key.startsWith(\"Arrow\")) return false;\n return (\n (event.altKey && !allow.includes(\"alt\")) ||\n (event.ctrlKey && !allow.includes(\"ctrl\")) ||\n (event.metaKey && !allow.includes(\"meta\")) ||\n (event.shiftKey && !allow.includes(\"shift\"))\n );\n}\n","/** One temporarily controlled attribute value and the authored value it displaced. */\ninterface AttributeLeaseRecord {\n readonly original: string | null;\n written: string | null;\n}\n\n/**\n * Temporarily controls one attribute across a changing set of elements.\n *\n * The first write remembers the authored value, including the distinction between\n * an absent attribute and an authored empty string. Returning a lease restores that\n * value only while the attribute still matches the controller's last write. If a\n * consumer changed it in the meantime, the consumer owns the new value and teardown\n * leaves it alone.\n *\n * A `null` write deliberately removes the attribute while retaining the lease. This\n * is useful for derived ARIA whose valid absence is itself controller state, such as\n * an unbounded `aria-valuemin` or a blank spinbutton's `aria-valuenow`.\n *\n * The lease has no lifecycle of its own, so it never subscribes to document events.\n * A consumer that must not let a derived value become the authored baseline of a\n * cached page returns its leases from its own `turbo:before-cache` rewind, where the\n * matching `disconnect()` also releases the subscription.\n */\nexport class AttributeLease<T extends Element = Element> {\n readonly #attribute: string;\n readonly #records = new Map<T, AttributeLeaseRecord>();\n\n /** @param attribute - The attribute whose temporary values this lease owns. */\n constructor(attribute: string) {\n this.#attribute = attribute;\n }\n\n /** Writes or removes the leased attribute while preserving its authored value. */\n write(element: T, value: string | null): void {\n const existing = this.#records.get(element);\n if (existing) {\n existing.written = value;\n } else {\n this.#records.set(element, {\n original: element.getAttribute(this.#attribute),\n written: value,\n });\n }\n\n this.#reflect(element, value);\n }\n\n /** Returns one lease without overwriting a value subsequently authored by a consumer. */\n return(element: T): void {\n const record = this.#records.get(element);\n if (!record) return;\n this.#records.delete(element);\n const stillOwned = element.getAttribute(this.#attribute) === record.written;\n if (stillOwned) this.#reflect(element, record.original);\n }\n\n /** Reflects only a real value transition, avoiding self-triggered mutation work. */\n #reflect(element: T, value: string | null): void {\n if (element.getAttribute(this.#attribute) === value) return;\n if (value === null) element.removeAttribute(this.#attribute);\n else element.setAttribute(this.#attribute, value);\n }\n\n /** Returns every outstanding lease using the same ownership check as {@link return}. */\n returnAll(): void {\n for (const element of Array.from(this.#records.keys())) this.return(element);\n }\n}\n","/**\n * Runs a controller's \"return to the initial state\" pass just before Turbo\n * caches the page.\n *\n * **`disconnect()` cannot do this job, for two independent reasons.** Turbo\n * queues the clone from this event rather than taking it here, and the body swap\n * that runs the controller's `disconnect()` is queued separately — so which of\n * the two lands first is not something a controller can rely on, and a rewind\n * written in `disconnect()` may reach only the DOM being thrown away. In the\n * other direction, `disconnect()` also fires on an in-page move (Stimulus tears\n * down and reconnects the same element), where rewinding would wipe a\n * legitimately in-progress interaction — a spinner mid-load would vanish. One\n * timing is unreliable, the other is too eager; `turbo:before-cache` is the only\n * point that is exactly \"the page is about to be frozen\".\n *\n * Scope is the subscription only: registering on `activate()`, unregistering on\n * `deactivate()`, and one shared document listener no matter how many instances\n * are live. *What* to return to its initial state — which `data-state`, which\n * `hidden`, which `aria-busy` — stays in the controller, because no two\n * consumers answer it the same way (the `MicrotaskCoalescer` split).\n *\n * **Rewind state, not appearance.** The pass writes attributes the controller\n * itself owns; the visual result of those attributes is the consumer's CSS, and\n * a library that reached for style or class names would be guessing at markup\n * it does not own.\n *\n * Both entry points are idempotent, so the lifecycle hooks can call them\n * unconditionally: a second `activate()` does not double-subscribe and does not\n * make the callback run twice, and `deactivate()` on an instance that never\n * subscribed is a no-op.\n *\n * This file's own doc block is dropped from `dist`, but every member comment is\n * inlined into each consumer entry (`tsup` builds with `splitting: false`), so\n * rationale belongs here and only the contract belongs on the members.\n *\n * @example\n * ```ts\n * readonly #beforeCache = new BeforeCacheReset(() => this.#rewind());\n *\n * connect() { this.#beforeCache.activate(); }\n * disconnect() { this.#beforeCache.deactivate(); }\n * ```\n */\nexport class BeforeCacheReset {\n /** Every subscribed instance, iterated by the one shared document listener. */\n static readonly #subscribers = new Set<BeforeCacheReset>();\n\n /** The shared listener; installed while at least one instance is subscribed. */\n static readonly #onBeforeCache = (): void => {\n for (const subscriber of BeforeCacheReset.#subscribers) subscriber.#rewind();\n };\n\n readonly #rewind: () => void;\n\n /** @param rewind - the pass that returns this controller's state to its initial form. */\n constructor(rewind: () => void) {\n this.#rewind = rewind;\n }\n\n /** Subscribes to `turbo:before-cache`; call from `connect()`. Idempotent. */\n activate(): void {\n const first = BeforeCacheReset.#subscribers.size === 0;\n BeforeCacheReset.#subscribers.add(this);\n if (first) {\n document.addEventListener(\"turbo:before-cache\", BeforeCacheReset.#onBeforeCache);\n }\n }\n\n /** Unsubscribes; call from `disconnect()`. Safe when never subscribed. */\n deactivate(): void {\n BeforeCacheReset.#subscribers.delete(this);\n if (BeforeCacheReset.#subscribers.size > 0) return;\n document.removeEventListener(\"turbo:before-cache\", BeforeCacheReset.#onBeforeCache);\n }\n}\n","/**\n * Collapses many Stimulus lifecycle callbacks from one DOM mutation into a\n * single pass.\n *\n * Stimulus fires `<name>TargetConnected` / `Disconnected` once per element and\n * `<name>ValueChanged` once per changed attribute. Replacing a list of N options\n * or morphing several render Values therefore delivers N callbacks — but the\n * useful unit of work is \"reconcile against the resulting declarative input\",\n * once, after the batch has settled. Every controller with reconcilable targets\n * or render Values needs the same shape: a `queued` flag plus `queueMicrotask`.\n *\n * **A microtask is the right horizon, and the reason is specific.** Stimulus\n * drives these callbacks from a `MutationObserver`, whose own callback already\n * runs as a microtask with the whole batch in hand; scheduling one more lands\n * after the last sibling callback of that batch and still before paint or any\n * event handler. A timer would be later than it needs to be, and reconciling\n * synchronously would run once per element against a half-applied DOM.\n *\n * **The two guards are not the same guard.** Scheduling is refused before the\n * controller connects, and running is refused after it disconnects:\n *\n * - **Before `connect()`** — Stimulus delivers initial target and Value callbacks\n * ahead of `connect()`. Reconciling there would compute output against a\n * controller whose own state has not been initialised, and `connect()` is\n * about to do a full pass anyway.\n * - **After `disconnect()`** — Stimulus fires a callback for **every** target\n * during teardown, and a microtask queued just before it would otherwise run\n * against a detached tree. {@link MicrotaskCoalescer.cancel} exists for the\n * teardown path to drop the pending pass outright.\n *\n * Both guards are part of one contract here rather than something each consumer\n * has to remember separately.\n *\n * Scope is the scheduling only. *What* to reconcile — keep the surviving active\n * option, fall back to the next / previous / first visible one, rebuild derived\n * chips or hidden fields — stays in the controller, because no two consumers\n * answer it the same way.\n *\n * This file's own doc block is dropped from `dist`, but every member comment is\n * inlined into each consumer entry (`tsup` builds with `splitting: false`), so\n * rationale belongs here and only the contract belongs on the members.\n *\n * @example\n * ```ts\n * readonly #reconcile = new MicrotaskCoalescer(() => this.#reconcileOptions());\n *\n * connect() { this.#reconcile.activate(); }\n * disconnect() { this.#reconcile.cancel(); }\n *\n * optionTargetConnected() { this.#reconcile.schedule(); }\n * optionTargetDisconnected() { this.#reconcile.schedule(); }\n * ```\n */\nexport class MicrotaskCoalescer {\n readonly #run: () => void;\n #queued = false;\n #active = false;\n #generation = 0;\n\n /** @param run - the single reconciliation pass, invoked at most once per batch. */\n constructor(run: () => void) {\n this.#run = run;\n }\n\n /** Opens the window in which {@link schedule} is honoured; call from `connect()`. */\n activate(): void {\n this.#active = true;\n }\n\n /** Closes the window and drops any pending pass; call from `disconnect()`. */\n cancel(): void {\n this.#active = false;\n this.#queued = false;\n this.#generation += 1;\n }\n\n /** Requests one pass after the batch settles. Idempotent; inert outside the window. */\n schedule(): void {\n if (!this.#active || this.#queued) return;\n this.#queued = true;\n const generation = this.#generation;\n queueMicrotask(() => {\n // A cancelled callback must not consume a pass queued after reconnect.\n if (generation !== this.#generation || !this.#queued || !this.#active) return;\n this.#queued = false;\n this.#run();\n });\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","/**\n * Low-level roving-tabindex primitive shared by composite-widget controllers.\n *\n * The APG roving-tabindex pattern keeps a composite widget a single Tab stop:\n * exactly one item is in the Tab sequence (`tabindex=\"0\"`) while the rest are\n * removed from it (`tabindex=\"-1\"`), and the arrow keys move both DOM focus and\n * that single tabbable position together. {@link RovingTabindex} owns *only* that\n * mechanical bookkeeping — \"which one item is tabbable, and move focus there\".\n *\n * It is intentionally **policy-free**. Orientation, wrapping vs. clamping,\n * selection-follows-focus, typeahead, and `Home`/`End` semantics differ per APG\n * pattern (Radio Group, Toolbar, Rating, …); folding them into one helper would\n * flatten those widgets to a lowest common denominator and lose each pattern's\n * correctness. Those decisions therefore stay in each controller, which calls\n * {@link RovingTabindex.setActive} with an index it computed itself (optionally\n * via the pure {@link rovingMove} helper).\n *\n * @remarks\n * Items are read lazily through a getter so a controller can add or remove\n * targets (Stimulus re-scans the DOM) without re-wiring this helper. A caller\n * that already captured one event-scoped snapshot may pass it to\n * {@link RovingTabindex.setActive}, avoiding a second live-target scan while\n * preserving one coherent collection for the whole operation.\n */\nexport class RovingTabindex {\n /** Returns the current ordered item elements; called on every operation. */\n readonly #getItems: () => HTMLElement[];\n\n /**\n * @param getItems - Returns the current ordered item elements. Called on every\n * operation so the live target list is always used.\n */\n constructor(getItems: () => HTMLElement[]) {\n this.#getItems = getItems;\n }\n\n /** Index of the currently tabbable item (`tabindex=\"0\"`), or `-1` if none. */\n get activeIndex(): number {\n return this.#getItems().findIndex((item) => item.tabIndex === 0);\n }\n\n /**\n * Makes exactly the item at `index` tabbable (`tabindex=\"0\"`) and removes every\n * other item from the Tab sequence (`tabindex=\"-1\"`). An out-of-range `index`\n * (e.g. `-1`) leaves all items at `-1`, which a controller can use to express\n * \"nothing is currently tabbable\".\n *\n * @param index - Position of the item to make tabbable.\n * @param options - Pass `{ focus: true }` to also move DOM focus to that item,\n * and `items` to reuse an event-scoped collection snapshot.\n */\n setActive(\n index: number,\n options: { focus?: boolean; items?: readonly HTMLElement[] } = {},\n ): void {\n const { focus = false } = options;\n const items = options.items ?? this.#getItems();\n items.forEach((item, i) => {\n item.tabIndex = i === index ? 0 : -1;\n });\n if (focus) items[index]?.focus();\n }\n}\n\n/** Edge behavior for {@link rovingMove}: cycle past the ends, or stop at them. */\nexport type RovingWrap = \"wrap\" | \"clamp\";\n\n/**\n * Pure helper that resolves the target index for a one-step directional move.\n *\n * Keyboard/orientation mapping stays in the caller: it decides that a key means\n * `delta` `+1` (next) or `-1` (previous) and whether the widget should `\"wrap\"`\n * (Radio Group, Toolbar) or `\"clamp\"` at the ends.\n *\n * @param current - The index focus is moving from.\n * @param length - Number of items in the set.\n * @param delta - `+1` to move to the next item, `-1` for the previous.\n * @param wrap - `\"wrap\"` cycles around the ends; `\"clamp\"` stops at them.\n * @returns The resolved index, or `-1` when there are no items.\n */\nexport function rovingMove(\n current: number,\n length: number,\n delta: number,\n wrap: RovingWrap,\n): number {\n if (length === 0) return -1;\n const next = current + delta;\n if (wrap === \"wrap\") return (next + length) % length;\n return Math.min(length - 1, Math.max(0, next));\n}\n","/**\n * Self-cleaning timer registries shared by Stimeo controllers.\n *\n * Stimulus controllers frequently schedule `setTimeout` / `setInterval` work\n * (auto-dismiss, debouncing, polling). When the element leaves the DOM — a\n * Turbo Drive navigation, a Turbo Stream replacement, or any `disconnect()` —\n * orphaned timers keep firing against a detached controller, leaking memory and\n * mutating stale state. {@link SafeTimeout} and {@link SafeInterval} track every\n * timer they create so a single {@link TimerRegistry.clearAll | clearAll()} call\n * in `disconnect()` tears them all down.\n *\n * These are intentionally low-level primitives: they own *registration and\n * cleanup only*. Higher-level policy (pause/resume, remaining-time accounting)\n * stays in the individual controllers so per-widget semantics are not flattened\n * into a lowest-common-denominator helper.\n */\n\n/**\n * Shared registry bookkeeping for the timeout/interval variants.\n *\n * Subclasses provide the scheduling primitive ({@link schedule}) and its matching\n * canceller ({@link cancel}); this base owns the set of live ids plus the\n * per-id and bulk teardown shared by both.\n */\nabstract class TimerRegistry {\n /** Live timer ids that have not yet been cleared (or, for timeouts, fired). */\n protected readonly ids = new Set<number>();\n\n /** Schedules the underlying platform timer and returns its id. */\n protected abstract schedule(callback: () => void, delay: number): number;\n\n /** Cancels the underlying platform timer for `id`. */\n protected abstract cancel(id: number): void;\n\n /**\n * Cancels a single tracked timer.\n *\n * No-ops if the id is unknown (already cleared, fired, or never owned by this\n * registry), so callers can clear defensively without guarding.\n */\n clear(id: number): void {\n if (this.ids.delete(id)) {\n this.cancel(id);\n }\n }\n\n /**\n * Cancels every tracked timer. Call this from a controller's `disconnect()`\n * to guarantee no timer outlives the element.\n */\n clearAll(): void {\n for (const id of this.ids) {\n this.cancel(id);\n }\n this.ids.clear();\n }\n\n /** Number of timers currently tracked (pending). */\n get size(): number {\n return this.ids.size;\n }\n}\n\n/**\n * `setTimeout` wrapper that auto-forgets each timer once it fires and supports\n * bulk teardown on disconnect.\n *\n * @example\n * ```ts\n * #timers = new SafeTimeout();\n *\n * connect() {\n * this.#timers.set(() => this.dismiss(), 5000);\n * }\n *\n * disconnect() {\n * this.#timers.clearAll();\n * }\n * ```\n */\nexport class SafeTimeout extends TimerRegistry {\n /**\n * Schedules `callback` after `delay` ms and returns the timer id.\n *\n * The id is removed from the registry automatically when the timeout fires,\n * so {@link TimerRegistry.size | size} reflects only still-pending timers.\n */\n set(callback: () => void, delay: number): number {\n const id = this.schedule(() => {\n this.ids.delete(id);\n callback();\n }, delay);\n this.ids.add(id);\n return id;\n }\n\n protected schedule(callback: () => void, delay: number): number {\n return window.setTimeout(callback, delay);\n }\n\n protected cancel(id: number): void {\n window.clearTimeout(id);\n }\n}\n\n/**\n * `setInterval` wrapper that tracks every interval for bulk teardown on\n * disconnect. Unlike {@link SafeTimeout}, intervals are retained until they are\n * explicitly cleared because they fire repeatedly.\n *\n * @example\n * ```ts\n * #intervals = new SafeInterval();\n *\n * connect() {\n * this.#intervals.set(() => this.tick(), 1000);\n * }\n *\n * disconnect() {\n * this.#intervals.clearAll();\n * }\n * ```\n */\nexport class SafeInterval extends TimerRegistry {\n /** Schedules a repeating `callback` every `delay` ms and returns the timer id. */\n set(callback: () => void, delay: number): number {\n const id = this.schedule(callback, delay);\n this.ids.add(id);\n return id;\n }\n\n protected schedule(callback: () => void, delay: number): number {\n return window.setInterval(callback, delay);\n }\n\n protected cancel(id: number): void {\n window.clearInterval(id);\n }\n}\n","import { Controller } from \"@hotwired/stimulus\";\nimport { isReservedArrowChord, logicalArrowStep } from \"../utils/arrow_step\";\nimport { AttributeLease } from \"../utils/attribute_lease\";\nimport { BeforeCacheReset } from \"../utils/before_cache_reset\";\nimport { MicrotaskCoalescer } from \"../utils/microtask_coalescer\";\nimport { prefersReducedMotion } from \"../utils/reduced_motion\";\nimport { RovingTabindex, rovingMove } from \"../utils/roving_tabindex\";\nimport { SafeInterval } from \"../utils/safe_timeout\";\n\n/** Advance delay used when `interval` is not a finite positive number. */\nconst DEFAULT_INTERVAL = 5000;\n\n/**\n * State attributes whose in-place rewrite changes what the carousel shows without\n * any target connecting or disconnecting — the shape a Turbo morph takes when it\n * keeps the elements and swaps only their attributes.\n */\nconst OBSERVED_ATTRIBUTES = [\"aria-selected\", \"data-state\", \"hidden\"];\n\n/**\n * Headless, accessible **Carousel** (slideshow) behavior.\n *\n * Markup contract (identifier: `stimeo--carousel`):\n * <section data-controller=\"stimeo--carousel\" aria-roledescription=\"carousel\"\n * aria-label=\"Featured\"\n * data-stimeo--carousel-autoplay-value=\"false\"\n * data-stimeo--carousel-interval-value=\"5000\"\n * data-stimeo--carousel-loop-value=\"true\">\n * <button data-stimeo--carousel-target=\"playToggle\">…</button>\n * <div data-stimeo--carousel-target=\"viewport\">\n * <div role=\"tabpanel\" data-stimeo--carousel-target=\"slide\">…</div>\n * <div role=\"tabpanel\" data-stimeo--carousel-target=\"slide\" hidden inert>…</div>\n * </div>\n * <button data-stimeo--carousel-target=\"prev\">‹</button>\n * <button data-stimeo--carousel-target=\"next\">›</button>\n * <div role=\"tablist\">\n * <button role=\"tab\" data-stimeo--carousel-target=\"picker\"></button>\n * </div>\n * </section>\n *\n * Implements the WAI-ARIA APG **Carousel** pattern. With pickers it is the tabbed\n * variant: each picker is a `tab` carrying `aria-selected` and the single roving\n * `tabindex`, and each slide is its `tabpanel`. Without pickers the slides are\n * `group`s and `prev`/`next` drive them. The current slide is exposed through\n * `data-state` (`active`/`inactive`); the rest carry `hidden` **and** `inert`, so\n * they stay out of the focus order and the accessibility tree even when consumer\n * CSS overrides `display` to lay the slides out as a track.\n *\n * @remarks\n * Behavior only — transitions, layout, and visuals are the consumer's CSS.\n *\n * **The controller owns its own wiring.** Clicks, picker keys, hover, and focus\n * are delegated from the controller element, so no `data-action` is required and\n * a target added at runtime works the moment it appears. Explicit `data-action`\n * bindings to the declared actions still work and coexist with the delegated\n * path: the binding runs first and marks the event, and the delegated listener\n * stands down, so one interaction is never handled twice.\n *\n * **`autoplay` is the single source of truth for the rotation intent.** The\n * toggle writes back to it, so the state survives a Turbo Drive cache restore\n * without a second, competing signal; `aria-pressed` is a pure output the\n * controller owns. Rotation is suspended — not cancelled — while the pointer\n * rests on the carousel, while focus is inside it, and while the tab is hidden;\n * each suspension lifts on its own (WCAG 2.2.2 is met by the toggle, which is\n * the one control that stops rotation for good). A carousel with nothing left to\n * advance to (one slide, or the last slide of a non-looping set) normalizes\n * `autoplay` to `false` and marks the toggle `aria-disabled`. `prefers-reduced-motion`\n * does the same at connect, leaving an explicit press free to start rotation.\n *\n * The interval is cleared on `disconnect()` (Turbo navigation included), and the\n * leased ARIA is returned before Turbo caches the page. Picker arrow keys, `Home`,\n * and `End` move focus only (manual activation); slide changes never steal focus\n * from the control the user operated. A slide change the user drove — including an\n * autoplay tick they started — is reported as `stimeo--carousel:change` with\n * `{ index, total }`; the same detail arrives as `stimeo--carousel:reconcile` when\n * the controller re-derives the position itself, whether a target came or went or\n * a retained element's state attributes were rewritten in place.\n */\nexport class CarouselController extends Controller<HTMLElement> {\n static override targets = [\"slide\", \"viewport\", \"prev\", \"next\", \"picker\", \"playToggle\"];\n static override values = {\n autoplay: { type: Boolean, default: false },\n interval: { type: Number, default: DEFAULT_INTERVAL },\n loop: { type: Boolean, default: true },\n };\n static actions = [\n \"goto\",\n \"next\",\n \"onPickerKeydown\",\n \"pause\",\n \"prev\",\n \"resume\",\n \"togglePlay\",\n ] as const;\n static events = [\"change\", \"pause\", \"play\", \"reconcile\"] as const;\n\n declare readonly slideTargets: HTMLElement[];\n declare readonly pickerTargets: HTMLElement[];\n declare readonly viewportTarget: HTMLElement;\n declare readonly hasViewportTarget: boolean;\n declare readonly prevTargets: HTMLElement[];\n declare readonly nextTargets: HTMLElement[];\n declare readonly playToggleTargets: HTMLElement[];\n declare autoplayValue: boolean;\n declare intervalValue: number;\n declare loopValue: boolean;\n\n readonly #roving = new RovingTabindex(() => this.pickerTargets);\n readonly #reconcileTargets = new MicrotaskCoalescer(() => this.#reconcileTargetSet());\n readonly #intervals = new SafeInterval();\n /** Unreachable step controls and the toggle of a carousel that cannot rotate. */\n readonly #ariaDisabled = new AttributeLease<HTMLElement>(\"aria-disabled\");\n /** The slide container's live-region politeness, which tracks the rotation. */\n readonly #ariaLive = new AttributeLease<HTMLElement>(\"aria-live\");\n /** Pairs with {@link CarouselController.#ariaLive}: only the changed slide is read. */\n readonly #ariaAtomic = new AttributeLease<HTMLElement>(\"aria-atomic\");\n readonly #beforeCache = new BeforeCacheReset(() => this.#returnLeases());\n /**\n * Events an authored action binding already took. The delegated listener runs\n * later — it sits on the controller element, above every control — so it can\n * consume the mark and stand down, letting the two wirings coexist without\n * handling one interaction twice.\n */\n readonly #handledEvents = new WeakSet<Event>();\n\n /**\n * Whether `connect()` has run. Scheduling is already inert outside that window\n * ({@link MicrotaskCoalescer}), so this gates the Value callbacks Stimulus\n * delivers ahead of `connect()`.\n */\n #connected = false;\n /** Index of the visible slide. */\n #index = 0;\n /** The visible slide element, which identifies it across a changing target set. */\n #activeSlide: HTMLElement | null = null;\n /** Slide count at the last resolved state, so a changed total is reportable. */\n #total = 0;\n /** Pointer rests on the carousel: a suspension that lifts on `mouseleave`. */\n #pointerPaused = false;\n /** Focus is inside the carousel: a suspension that lifts when it leaves. */\n #focusPaused = false;\n /** The tab is in the background: a suspension that lifts when it returns. */\n #hiddenPaused = false;\n /** Id of the live autoplay interval, or null when stopped. */\n #timerId: number | null = null;\n /** Delay the live interval was armed with, so an `interval` change re-arms it. */\n #timerInterval = 0;\n /** Follows state-attribute rewrites on retained slides and pickers. */\n #observer: MutationObserver | null = null;\n\n /** Keeps a hidden tab from advancing behind the user's back. */\n readonly #onVisibilityChange = (): void => {\n this.#hiddenPaused = document.visibilityState === \"hidden\";\n this.#syncTimer();\n };\n\n /**\n * Renders the initial slide, wires the delegated listeners, and starts autoplay\n * when requested.\n *\n * Every suspension is re-derived from the environment rather than carried, so an\n * in-page move — which Stimulus delivers to the *same* controller instance as\n * `disconnect()` then `connect()` — cannot strand the carousel in a suspension\n * whose lifting event will never arrive. The attribute observer starts after the\n * first render so the controller's own opening writes are not fed back to it.\n */\n override connect(): void {\n this.#pointerPaused = this.element.matches(\":hover\");\n this.#focusPaused = this.element.contains(document.activeElement);\n this.#hiddenPaused = document.visibilityState === \"hidden\";\n if (this.autoplayValue && prefersReducedMotion()) this.autoplayValue = false;\n this.#index = this.#resolveIndex();\n this.#render({ focus: false });\n this.#total = this.slideTargets.length;\n this.#syncTimer();\n this.#connected = true;\n this.#reconcileTargets.activate();\n this.#beforeCache.activate();\n\n this.element.addEventListener(\"click\", this.#onClick);\n this.element.addEventListener(\"keydown\", this.#onKeydown);\n this.element.addEventListener(\"focusin\", this.#onFocusin);\n this.element.addEventListener(\"focusout\", this.#onFocusout);\n this.element.addEventListener(\"mouseenter\", this.#onMouseenter);\n this.element.addEventListener(\"mouseleave\", this.#onMouseleave);\n document.addEventListener(\"visibilitychange\", this.#onVisibilityChange);\n this.#observer = new MutationObserver(this.#onAttributeMutations);\n this.#observer.observe(this.element, {\n subtree: true,\n attributes: true,\n attributeFilter: OBSERVED_ATTRIBUTES,\n });\n }\n\n /** Releases every listener and observer, returns the leased ARIA, drops the suspensions. */\n override disconnect(): void {\n this.#connected = false;\n this.element.removeEventListener(\"click\", this.#onClick);\n this.element.removeEventListener(\"keydown\", this.#onKeydown);\n this.element.removeEventListener(\"focusin\", this.#onFocusin);\n this.element.removeEventListener(\"focusout\", this.#onFocusout);\n this.element.removeEventListener(\"mouseenter\", this.#onMouseenter);\n this.element.removeEventListener(\"mouseleave\", this.#onMouseleave);\n document.removeEventListener(\"visibilitychange\", this.#onVisibilityChange);\n this.#observer?.disconnect();\n this.#observer = null;\n this.#reconcileTargets.cancel();\n this.#intervals.clearAll();\n this.#timerId = null;\n this.#pointerPaused = false;\n this.#focusPaused = false;\n this.#hiddenPaused = false;\n this.#activeSlide = null;\n this.#returnLeases();\n this.#beforeCache.deactivate();\n }\n\n /**\n * Re-establishes the single selected picker when one is added after connect.\n *\n * Without this an appended picker that arrives `aria-selected=\"true\"` leaves two\n * marked at once — the authored pre-selection is only read on connect, so\n * nothing else ever resolves the conflict. The current slide is kept: the\n * repaint re-derives every picker from `#index`, so a late arrival never steals\n * the selection.\n */\n pickerTargetConnected(picker: HTMLElement): void {\n picker.tabIndex = -1;\n this.#reconcileTargets.schedule();\n }\n\n /** Repairs selection and roving after a picker leaves a retained carousel. */\n pickerTargetDisconnected(): void {\n this.#reconcileTargets.schedule();\n }\n\n /** Reconciles a slide added in the same DOM batch as its picker. */\n slideTargetConnected(): void {\n this.#reconcileTargets.schedule();\n }\n\n /** Re-clamps the active index after a slide is removed. */\n slideTargetDisconnected(): void {\n this.#reconcileTargets.schedule();\n }\n\n /** Follows a rotation intent the page changed at runtime. */\n autoplayValueChanged(): void {\n if (this.#connected) this.#syncTimer();\n }\n\n /** Re-arms the live interval at the new delay without reporting a state change. */\n intervalValueChanged(): void {\n if (this.#connected) this.#syncTimer();\n }\n\n /** Re-publishes the step controls and re-evaluates the non-looping end. */\n loopValueChanged(): void {\n if (!this.#connected) return;\n this.#render({ focus: false });\n this.#syncTimer();\n }\n\n /** Advances to the next slide. Delegated; `data-action` wiring is optional. */\n next(event?: Event): void {\n if (event?.defaultPrevented) return;\n this.#markHandled(event);\n this.#select(this.#step(1), { focus: false });\n }\n\n /** Returns to the previous slide. Delegated; `data-action` wiring is optional. */\n prev(event?: Event): void {\n if (event?.defaultPrevented) return;\n this.#markHandled(event);\n this.#select(this.#step(-1), { focus: false });\n }\n\n /** Jumps to the slide whose picker was activated (click / Enter / Space). */\n goto(event: Event): void {\n if (event.defaultPrevented) return;\n this.#markHandled(event);\n const index = this.#pickerIndexFor(event.currentTarget);\n if (index !== -1) this.#select(index, { focus: false });\n }\n\n /**\n * Flips the rotation intent on the user's explicit request.\n *\n * The intent is written back to the `autoplay` Value, which is where every other\n * path reads it from. A carousel with nothing to advance to has no intent to\n * flip: the toggle is marked `aria-disabled` and does nothing.\n */\n togglePlay(event?: Event): void {\n if (event?.defaultPrevented) return;\n this.#markHandled(event);\n this.#togglePlay();\n }\n\n /**\n * Suspends rotation. A `focus`-family event records that focus is inside the\n * carousel; anything else — hover, or a bare programmatic call — records the\n * pointer suspension. Both lift through the matching {@link resume}, and\n * neither touches the rotation intent.\n */\n pause(event?: Event): void {\n this.#markHandled(event);\n if (isFocusEvent(event)) this.#focusPaused = true;\n else this.#pointerPaused = true;\n this.#syncTimer();\n }\n\n /**\n * Lifts the matching suspension. A `focusout` whose `relatedTarget` is still\n * inside the carousel is focus moving between its own controls, which leaves the\n * focus suspension in place — releasing it there would stop and restart the\n * interval on every Tab press.\n */\n resume(event?: Event): void {\n this.#markHandled(event);\n if (isFocusEvent(event)) {\n if (this.#focusStaysInside(event)) return;\n this.#focusPaused = false;\n } else {\n this.#pointerPaused = false;\n }\n this.#syncTimer();\n }\n\n /** Picker roving for authored bindings; the delegated path is `#onKeydown`. */\n onPickerKeydown(event: KeyboardEvent): void {\n const index = this.#pickerIndexFor(event.currentTarget);\n if (index === -1) return;\n this.#markHandled(event);\n this.#handlePickerKeydown(event, index);\n }\n\n /** Delegated activation for pickers and step controls without authored actions. */\n readonly #onClick = (event: MouseEvent): void =>\n this.#delegate(event, () => {\n const index = this.#pickerIndexFor(event.target);\n if (index !== -1) {\n this.#select(index, { focus: false });\n } else if (hits(this.nextTargets, event.target)) {\n this.#select(this.#step(1), { focus: false });\n } else if (hits(this.prevTargets, event.target)) {\n this.#select(this.#step(-1), { focus: false });\n } else if (hits(this.playToggleTargets, event.target)) {\n this.#togglePlay();\n }\n });\n\n /** Delegated picker roving for pickers without authored actions. */\n readonly #onKeydown = (event: KeyboardEvent): void =>\n this.#delegate(event, () => {\n const index = this.#pickerIndexFor(event.target);\n if (index !== -1) this.#handlePickerKeydown(event, index);\n });\n\n /** Focus arriving anywhere inside suspends the rotation. */\n readonly #onFocusin = (event: FocusEvent): void =>\n this.#delegate(event, () => {\n this.#focusPaused = true;\n this.#syncTimer();\n });\n\n /** Focus genuinely leaving lifts the suspension; moves between own controls do not. */\n readonly #onFocusout = (event: FocusEvent): void =>\n this.#delegate(event, () => {\n if (this.#focusStaysInside(event)) return;\n this.#focusPaused = false;\n this.#syncTimer();\n });\n\n /** Pointer entry suspends the rotation. */\n readonly #onMouseenter = (event: MouseEvent): void =>\n this.#delegate(event, () => {\n this.#pointerPaused = true;\n this.#syncTimer();\n });\n\n /** Pointer exit lifts the suspension. */\n readonly #onMouseleave = (event: MouseEvent): void =>\n this.#delegate(event, () => {\n this.#pointerPaused = false;\n this.#syncTimer();\n });\n\n /**\n * Schedules one reconciliation when a state attribute is rewritten in place —\n * the only shape of change no target callback reports.\n *\n * The filter is the `attributeFilter` alone: those three attributes belong to\n * the slides and pickers, and a coalesced pass over an unrelated one costs a\n * repaint that writes nothing. Narrowing further here would add a branch no\n * test could distinguish.\n */\n readonly #onAttributeMutations = (): void => {\n this.#reconcileTargets.schedule();\n };\n\n /**\n * Records that an action binding took this event.\n *\n * An authored binding sits on the control, so it runs while the event is still\n * below the controller element and always precedes the delegated listener.\n * Marking is the one signal that keeps the two wirings from both acting.\n */\n #markHandled(event?: Event): void {\n if (event) this.#handledEvents.add(event);\n }\n\n /** Runs a delegated handler unless an action binding, or a descendant, took the event. */\n #delegate(event: Event, run: () => void): void {\n if (this.#handledEvents.delete(event) || event.defaultPrevented) return;\n run();\n }\n\n /** Position of the picker that is or contains `node`, or `-1` when none does. */\n #pickerIndexFor(node: EventTarget | null): number {\n return this.pickerTargets.findIndex(\n (picker) => node instanceof Node && (picker === node || picker.contains(node)),\n );\n }\n\n /** Whether a focus transition lands on another control of this same carousel. */\n #focusStaysInside(event: FocusEvent): boolean {\n const next = event.relatedTarget;\n return next instanceof Node && this.element.contains(next);\n }\n\n /** Flips the rotation intent, unless there is nothing to rotate to. */\n #togglePlay(): void {\n if (!this.#canAutoplay()) return;\n this.autoplayValue = !this.autoplayValue;\n this.#syncTimer();\n }\n\n /** Applies the APG picker key map: arrows, Home, and End all move focus only. */\n #handlePickerKeydown(event: KeyboardEvent, current: number): void {\n // A descendant widget that already claimed the key must not ALSO move the\n // picker focus — composition depends on this yield.\n if (event.defaultPrevented) return;\n if (isReservedArrowChord(event)) return;\n\n const length = this.pickerTargets.length;\n // Logical, not physical. The helper reverses only the horizontal\n // pair, so folding Down/Up into the same branch stays correct.\n switch (event.key) {\n case \"ArrowRight\":\n case \"ArrowDown\":\n case \"ArrowLeft\":\n case \"ArrowUp\": {\n event.preventDefault();\n const step = logicalArrowStep(event.key, this.element);\n this.#roving.setActive(rovingMove(current, length, step, \"wrap\"), { focus: true });\n return;\n }\n // A chorded Home/End is a document-level shortcut (`Control+Home` scrolls\n // the page) that belongs to the browser, exactly as a chorded arrow does.\n case \"Home\":\n if (hasModifier(event)) return;\n event.preventDefault();\n this.#roving.setActive(0, { focus: true });\n return;\n case \"End\":\n if (hasModifier(event)) return;\n event.preventDefault();\n this.#roving.setActive(length - 1, { focus: true });\n return;\n default:\n }\n }\n\n /**\n * Resolves the index one step away from the current one, honoring `loop`.\n *\n * Bounding is {@link CarouselController.#clampToSlides}'s job alone, so an\n * empty set is allowed to fall out of the arithmetic here rather than being\n * special-cased in two places that could disagree.\n */\n #step(delta: number): number {\n const total = this.slideTargets.length;\n const next = this.#index + delta;\n if (this.loopValue) return (next + total) % total;\n return Math.min(total - 1, Math.max(0, next));\n }\n\n /**\n * Confines an index to the slide range, so no index can hide every slide.\n *\n * The single place an index is bounded: an empty set collapses to the first\n * position, which is also where a non-numeric step from that empty set lands.\n */\n #clampToSlides(index: number): number {\n const last = this.slideTargets.length - 1;\n if (last < 0) return 0;\n return Math.min(last, Math.max(0, index));\n }\n\n /**\n * Changes the active slide, updates state hooks, and emits `change` — but only\n * when the index actually changes, so a `next`/`prev` clamped at the end (or an\n * autoplay tick at a non-looping boundary) re-renders without a spurious event\n * (matching the \"emit on real change\" policy of flash/masonry/bulk-select).\n */\n #select(index: number, { focus }: { focus: boolean }): void {\n const target = this.#clampToSlides(index);\n const changed = target !== this.#index;\n this.#index = target;\n this.#render({ focus });\n // Re-evaluate autoplay after every move so reaching the non-looping end stops\n // the timer (see `#syncTimer`); idempotent for moves that don't cross a boundary.\n this.#syncTimer();\n if (changed) {\n this.dispatch(\"change\", { detail: { index: target, total: this.slideTargets.length } });\n }\n }\n\n /**\n * Reflects `this.#index` onto the slides, the pickers, and the step controls.\n *\n * Every observed attribute is written only when its value actually changes: the\n * same writes are watched by {@link CarouselController.#onAttributeMutations},\n * and an unconditional rewrite would feed the controller its own output.\n *\n * @stimeoRenderRoot\n */\n #render({ focus }: { focus: boolean }): void {\n this.#activeSlide = this.slideTargets[this.#index] ?? null;\n this.slideTargets.forEach((slide, i) => {\n const active = i === this.#index;\n setAttributeIfChanged(slide, \"data-state\", active ? \"active\" : \"inactive\");\n if (slide.hidden !== !active) slide.hidden = !active;\n // `hidden` alone is a style a slide track's own CSS overrides; `inert` is not.\n slide.toggleAttribute(\"inert\", !active);\n });\n // The picker set can be shorter than the slide set (a picker removed on its\n // own, or a carousel that only pickers part of its slides). Resolving the\n // selection inside the picker range keeps exactly one selected tab and one Tab\n // stop; an out-of-range index would leave every picker at `tabindex=\"-1\"` and\n // strand the tablist outside the Tab sequence.\n const pickerIndex = Math.min(this.#index, this.pickerTargets.length - 1);\n this.pickerTargets.forEach((picker, i) => {\n setAttributeIfChanged(picker, \"aria-selected\", i === pickerIndex ? \"true\" : \"false\");\n });\n this.#roving.setActive(pickerIndex, { focus });\n this.#syncStepControls();\n }\n\n /** Marks the step control a non-looping carousel has no slide left to reach. */\n #syncStepControls(): void {\n const last = this.slideTargets.length - 1;\n const atStart = !this.loopValue && this.#index <= 0;\n const atEnd = !this.loopValue && this.#index >= last;\n for (const button of this.prevTargets) {\n this.#ariaDisabled.write(button, atStart ? \"true\" : null);\n }\n for (const button of this.nextTargets) {\n this.#ariaDisabled.write(button, atEnd ? \"true\" : null);\n }\n }\n\n /**\n * Resolves which slide is current from the strongest evidence available.\n *\n * A single `data-state=\"active\"` is unambiguous and wins, which is what restores\n * the visible slide after a Turbo cache restore even with no pickers present.\n * Competing claims — a slide inserted already marked active — are settled by the\n * element the last render actually showed, so a newcomer never displaces what the\n * reader is looking at. With no claim at all the authored picker selection\n * decides, first in DOM order; failing that the previous position is kept.\n */\n #resolveIndex(): number {\n const slides = this.slideTargets;\n const claims: number[] = [];\n slides.forEach((slide, index) => {\n if (slide.getAttribute(\"data-state\") === \"active\") claims.push(index);\n });\n if (claims.length > 1 && this.#activeSlide !== null) {\n const live = slides.indexOf(this.#activeSlide);\n if (claims.includes(live)) return live;\n }\n const claimed = claims[0];\n if (claimed !== undefined) return claimed;\n\n const selected = this.pickerTargets.findIndex(\n (picker) => picker.getAttribute(\"aria-selected\") === \"true\",\n );\n return this.#clampToSlides(selected === -1 ? this.#index : selected);\n }\n\n /** Re-resolves the active slide after the target set changed and reports the move. */\n #reconcileTargetSet(): void {\n const previousIndex = this.#index;\n const previousTotal = this.#total;\n this.#index = this.#resolveIndex();\n this.#render({ focus: false });\n this.#total = this.slideTargets.length;\n this.#syncTimer();\n // `change` stays reserved for user navigation; re-resolving onto a surviving\n // slide, or reporting a set that grew or shrank, is this controller's decision.\n if (this.#index !== previousIndex || this.#total !== previousTotal) {\n this.dispatch(\"reconcile\", { detail: { index: this.#index, total: this.#total } });\n }\n }\n\n /** Whether autoplay has anywhere left to advance to. */\n #canAutoplay(): boolean {\n const total = this.slideTargets.length;\n if (total <= 1) return false;\n return this.loopValue || this.#index < total - 1;\n }\n\n /** The advance delay; a non-finite or non-positive declaration falls back. */\n get #interval(): number {\n const declared = this.intervalValue;\n return Number.isFinite(declared) && declared > 0 ? declared : DEFAULT_INTERVAL;\n }\n\n /**\n * Drives the autoplay interval toward the desired state and publishes it.\n *\n * Rotation runs when the intent is on, nothing suspends it, and a slide is left\n * to advance to. A carousel that has run out normalizes the intent to `false`, so\n * `aria-pressed` never claims a rotation that cannot happen. Crossing the\n * run/stop boundary emits `play`/`pause`; re-arming at a new `interval` is the\n * same state and stays silent.\n */\n #syncTimer(): void {\n const canAutoplay = this.#canAutoplay();\n if (this.autoplayValue && !canAutoplay) this.autoplayValue = false;\n\n const shouldRun =\n this.autoplayValue &&\n canAutoplay &&\n !this.#pointerPaused &&\n !this.#focusPaused &&\n !this.#hiddenPaused;\n const wasRunning = this.#timerId !== null;\n const interval = this.#interval;\n\n if (this.#timerId !== null && (!shouldRun || interval !== this.#timerInterval)) {\n this.#intervals.clear(this.#timerId);\n this.#timerId = null;\n }\n if (shouldRun && this.#timerId === null) {\n this.#timerInterval = interval;\n this.#timerId = this.#intervals.set(() => this.next(), interval);\n }\n // The events are edges. A consumer that subscribes after `connect()` — which\n // is every consumer on a Turbo restore, where the controller reconnects before\n // the page's own scripts run again — would miss the transition it arrived in\n // the middle of, so the same state is published as a hook it can read.\n setAttributeIfChanged(this.element, \"data-state\", shouldRun ? \"playing\" : \"paused\");\n if (shouldRun !== wasRunning) {\n if (shouldRun) this.dispatch(\"play\");\n else this.dispatch(\"pause\");\n }\n\n for (const toggle of this.playToggleTargets) {\n toggle.setAttribute(\"aria-pressed\", this.autoplayValue ? \"true\" : \"false\");\n this.#ariaDisabled.write(toggle, canAutoplay ? null : \"true\");\n }\n if (this.hasViewportTarget) {\n this.#ariaLive.write(this.viewportTarget, shouldRun ? \"off\" : \"polite\");\n this.#ariaAtomic.write(this.viewportTarget, \"false\");\n }\n }\n\n /** Hands every leased attribute back to the value the consumer authored. */\n #returnLeases(): void {\n this.#ariaDisabled.returnAll();\n this.#ariaLive.returnAll();\n this.#ariaAtomic.returnAll();\n }\n}\n\n/** Whether an event names a focus transition rather than a pointer one. */\nfunction isFocusEvent(event?: Event): event is FocusEvent {\n return event?.type.startsWith(\"focus\") === true;\n}\n\n/** Whether a key arrived with a modifier that makes it the browser's shortcut. */\nfunction hasModifier(event: KeyboardEvent): boolean {\n return event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;\n}\n\n/** Whether `node` is one of `elements` or sits inside one. */\nfunction hits(elements: readonly HTMLElement[], node: EventTarget | null): boolean {\n return elements.some(\n (element) => node instanceof Node && (element === node || element.contains(node)),\n );\n}\n\n/** Writes an attribute only on a real transition, so an observer sees no self-echo. */\nfunction setAttributeIfChanged(element: Element, name: string, value: string): void {\n if (element.getAttribute(name) !== value) element.setAttribute(name, value);\n}\n"]}
|
|
@@ -1,30 +1,52 @@
|
|
|
1
1
|
import { Controller } from '@hotwired/stimulus';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Headless copy-to-clipboard behavior with a
|
|
4
|
+
* Headless copy-to-clipboard behavior with a completion slot and a screen-reader
|
|
5
|
+
* announcement.
|
|
5
6
|
*
|
|
6
7
|
* Markup contract (identifier: `stimeo--clipboard`):
|
|
7
8
|
* <div data-controller="stimeo--clipboard"
|
|
8
|
-
* data-stimeo--clipboard-feedback-duration-value="2000"
|
|
9
|
+
* data-stimeo--clipboard-feedback-duration-value="2000"
|
|
10
|
+
* data-stimeo--clipboard-announce-copied-text-value="Copied to clipboard"
|
|
11
|
+
* data-stimeo--clipboard-announce-error-text-value="Copy failed">
|
|
9
12
|
* <input type="text" value="https://example.com" readonly
|
|
10
13
|
* data-stimeo--clipboard-target="source">
|
|
11
14
|
* <button type="button" data-stimeo--clipboard-target="button"
|
|
12
15
|
* data-action="stimeo--clipboard#copy">Copy</button>
|
|
13
|
-
* <span
|
|
14
|
-
* data-stimeo--clipboard-target="feedback"></span>
|
|
16
|
+
* <span data-stimeo--clipboard-target="feedback"></span>
|
|
15
17
|
* </div>
|
|
16
18
|
*
|
|
17
|
-
* No dedicated APG pattern; this follows the Button
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
19
|
+
* No dedicated APG pattern; this follows the Button practice plus a status message
|
|
20
|
+
* ({@link https://www.w3.org/WAI/WCAG22/Understanding/status-changes.html | WCAG 2.2 SC 4.1.3}).
|
|
21
|
+
* The copy uses the standard `navigator.clipboard` API (no extra dependency); every
|
|
22
|
+
* failure mode — an API the browser withholds outside a secure context as much as a
|
|
23
|
+
* rejected permission — settles the same way, as `data-state="error"` plus the
|
|
24
|
+
* `copy` event's `success: false`.
|
|
25
|
+
*
|
|
26
|
+
* Targets: `source` (the text to copy, when `text` is not set), `button` (the
|
|
27
|
+
* control that triggers `copy`), `feedback` (the **visible** completion slot).
|
|
28
|
+
*
|
|
29
|
+
* Values: `text` (copy this instead of reading `source`), `feedbackDuration` (ms the
|
|
30
|
+
* completion state is held; `0` or less arms no timer, so it stands until the next
|
|
31
|
+
* copy — a reconnect and the before-cache rewind still clear it), `copiedLabel` /
|
|
32
|
+
* `errorLabel` (what the visible slot shows), `announceCopiedText` /
|
|
33
|
+
* `announceErrorText` (what assistive tech hears; empty announces nothing).
|
|
22
34
|
*
|
|
23
35
|
* @remarks
|
|
24
|
-
* Behavior only — icon swaps and styling are the consumer's, keyed off
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
36
|
+
* Behavior only — icon swaps and styling are the consumer's, keyed off `data-state`
|
|
37
|
+
* (`idle` / `copied` / `error`).
|
|
38
|
+
*
|
|
39
|
+
* **The `feedback` slot must not carry live-region semantics.** Announcing is the
|
|
40
|
+
* page's shared `stimeo--announcer` job: it is seated before the change it reads,
|
|
41
|
+
* which a slot filled on demand cannot be, and it already collapses a repeat of the
|
|
42
|
+
* same wording so a second copy is still heard. A `role="status"` on the slot as
|
|
43
|
+
* well would say everything twice.
|
|
44
|
+
*
|
|
45
|
+
* `copied` and `error` are transient: the timer that clears them belongs to one
|
|
46
|
+
* connection, so a fresh `connect()` that finds either — a restored snapshot, an
|
|
47
|
+
* in-page move — returns to `idle`, and the state is rewound before Turbo caches
|
|
48
|
+
* the page ({@link BeforeCacheReset}). The rewind is silent: it discards nothing a
|
|
49
|
+
* reconnect does not derive again.
|
|
28
50
|
*/
|
|
29
51
|
declare class ClipboardController extends Controller<HTMLElement> {
|
|
30
52
|
#private;
|
|
@@ -46,6 +68,14 @@ declare class ClipboardController extends Controller<HTMLElement> {
|
|
|
46
68
|
type: StringConstructor;
|
|
47
69
|
default: string;
|
|
48
70
|
};
|
|
71
|
+
announceCopiedText: {
|
|
72
|
+
type: StringConstructor;
|
|
73
|
+
default: string;
|
|
74
|
+
};
|
|
75
|
+
announceErrorText: {
|
|
76
|
+
type: StringConstructor;
|
|
77
|
+
default: string;
|
|
78
|
+
};
|
|
49
79
|
};
|
|
50
80
|
static actions: readonly ["copy"];
|
|
51
81
|
static events: readonly ["copy"];
|
|
@@ -59,12 +89,15 @@ declare class ClipboardController extends Controller<HTMLElement> {
|
|
|
59
89
|
feedbackDurationValue: number;
|
|
60
90
|
copiedLabelValue: string;
|
|
61
91
|
errorLabelValue: string;
|
|
92
|
+
announceCopiedTextValue: string;
|
|
93
|
+
announceErrorTextValue: string;
|
|
62
94
|
connect(): void;
|
|
63
95
|
disconnect(): void;
|
|
64
96
|
/**
|
|
65
97
|
* Copies the resolved text and reports the outcome. Bound via `data-action`
|
|
66
|
-
* (click).
|
|
67
|
-
* — including on failure — so consumers can react either way.
|
|
98
|
+
* (click). Dispatches `stimeo--clipboard:copy` with `{ success, text }` once per
|
|
99
|
+
* completed attempt — including on failure — so consumers can react either way.
|
|
100
|
+
* An attempt whose connection ended while it was in flight reports nothing.
|
|
68
101
|
*/
|
|
69
102
|
copy(): Promise<void>;
|
|
70
103
|
}
|
|
@@ -2,6 +2,46 @@ import { Controller } from '@hotwired/stimulus';
|
|
|
2
2
|
|
|
3
3
|
// src/controllers/clipboard_controller.ts
|
|
4
4
|
|
|
5
|
+
// src/utils/announce.ts
|
|
6
|
+
function announce(message, options = {}) {
|
|
7
|
+
const text = message.trim();
|
|
8
|
+
if (text.length === 0) return;
|
|
9
|
+
window.dispatchEvent(
|
|
10
|
+
new CustomEvent("stimeo--announcer:announce", {
|
|
11
|
+
detail: { message: text, assertive: options.assertive === true }
|
|
12
|
+
})
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// src/utils/before_cache_reset.ts
|
|
17
|
+
var BeforeCacheReset = class _BeforeCacheReset {
|
|
18
|
+
/** Every subscribed instance, iterated by the one shared document listener. */
|
|
19
|
+
static #subscribers = /* @__PURE__ */ new Set();
|
|
20
|
+
/** The shared listener; installed while at least one instance is subscribed. */
|
|
21
|
+
static #onBeforeCache = () => {
|
|
22
|
+
for (const subscriber of _BeforeCacheReset.#subscribers) subscriber.#rewind();
|
|
23
|
+
};
|
|
24
|
+
#rewind;
|
|
25
|
+
/** @param rewind - the pass that returns this controller's state to its initial form. */
|
|
26
|
+
constructor(rewind) {
|
|
27
|
+
this.#rewind = rewind;
|
|
28
|
+
}
|
|
29
|
+
/** Subscribes to `turbo:before-cache`; call from `connect()`. Idempotent. */
|
|
30
|
+
activate() {
|
|
31
|
+
const first = _BeforeCacheReset.#subscribers.size === 0;
|
|
32
|
+
_BeforeCacheReset.#subscribers.add(this);
|
|
33
|
+
if (first) {
|
|
34
|
+
document.addEventListener("turbo:before-cache", _BeforeCacheReset.#onBeforeCache);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/** Unsubscribes; call from `disconnect()`. Safe when never subscribed. */
|
|
38
|
+
deactivate() {
|
|
39
|
+
_BeforeCacheReset.#subscribers.delete(this);
|
|
40
|
+
if (_BeforeCacheReset.#subscribers.size > 0) return;
|
|
41
|
+
document.removeEventListener("turbo:before-cache", _BeforeCacheReset.#onBeforeCache);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
5
45
|
// src/utils/default_attribute.ts
|
|
6
46
|
function setDefaultAttribute(element, name, value) {
|
|
7
47
|
if (element.hasAttribute(name)) return false;
|
|
@@ -63,45 +103,59 @@ var SafeTimeout = class extends TimerRegistry {
|
|
|
63
103
|
};
|
|
64
104
|
|
|
65
105
|
// src/controllers/clipboard_controller.ts
|
|
106
|
+
var TRANSIENT_STATES = /* @__PURE__ */ new Set(["copied", "error"]);
|
|
66
107
|
var ClipboardController = class extends Controller {
|
|
67
108
|
static targets = ["source", "button", "feedback"];
|
|
68
109
|
static values = {
|
|
69
110
|
text: { type: String, default: "" },
|
|
70
111
|
feedbackDuration: { type: Number, default: 2e3 },
|
|
71
112
|
copiedLabel: { type: String, default: "Copied" },
|
|
72
|
-
errorLabel: { type: String, default: "Copy failed" }
|
|
113
|
+
errorLabel: { type: String, default: "Copy failed" },
|
|
114
|
+
announceCopiedText: { type: String, default: "" },
|
|
115
|
+
announceErrorText: { type: String, default: "" }
|
|
73
116
|
};
|
|
74
117
|
static actions = ["copy"];
|
|
75
118
|
static events = ["copy"];
|
|
76
|
-
/**
|
|
119
|
+
/**
|
|
120
|
+
* The pending return to idle — the only timer this controller schedules, so
|
|
121
|
+
* `clearAll()` is exactly "drop the auto-clear" and needs no id of its own.
|
|
122
|
+
*/
|
|
77
123
|
#timers = new SafeTimeout();
|
|
124
|
+
/** Returns the completion state to idle for the snapshot Turbo takes. */
|
|
125
|
+
#beforeCache = new BeforeCacheReset(() => this.#rewind());
|
|
78
126
|
/**
|
|
79
|
-
*
|
|
80
|
-
* a
|
|
81
|
-
*
|
|
127
|
+
* Whether this connection is still live. `copy()` suspends on the Clipboard API,
|
|
128
|
+
* and a teardown that lands while it is suspended must win: the continuation
|
|
129
|
+
* would otherwise write to an element nobody owns and arm a timer past the
|
|
130
|
+
* `clearAll()` that was supposed to be the last word.
|
|
82
131
|
*/
|
|
83
|
-
#
|
|
132
|
+
#connected = false;
|
|
84
133
|
connect() {
|
|
85
|
-
|
|
134
|
+
this.#connected = true;
|
|
135
|
+
this.#adopt();
|
|
136
|
+
this.#beforeCache.activate();
|
|
86
137
|
}
|
|
87
138
|
disconnect() {
|
|
139
|
+
this.#connected = false;
|
|
140
|
+
this.#beforeCache.deactivate();
|
|
88
141
|
this.#timers.clearAll();
|
|
89
142
|
}
|
|
90
143
|
/**
|
|
91
144
|
* Copies the resolved text and reports the outcome. Bound via `data-action`
|
|
92
|
-
* (click).
|
|
93
|
-
* — including on failure — so consumers can react either way.
|
|
145
|
+
* (click). Dispatches `stimeo--clipboard:copy` with `{ success, text }` once per
|
|
146
|
+
* completed attempt — including on failure — so consumers can react either way.
|
|
147
|
+
* An attempt whose connection ended while it was in flight reports nothing.
|
|
94
148
|
*/
|
|
95
149
|
async copy() {
|
|
96
150
|
const text = this.#resolveText();
|
|
97
151
|
let success = false;
|
|
98
152
|
try {
|
|
99
|
-
if (!navigator.clipboard?.writeText) throw new Error("Clipboard API unavailable");
|
|
100
153
|
await navigator.clipboard.writeText(text);
|
|
101
154
|
success = true;
|
|
102
155
|
} catch {
|
|
103
156
|
success = false;
|
|
104
157
|
}
|
|
158
|
+
if (!this.#connected) return;
|
|
105
159
|
this.#reportResult(success);
|
|
106
160
|
this.dispatch("copy", { detail: { success, text } });
|
|
107
161
|
}
|
|
@@ -118,24 +172,52 @@ var ClipboardController = class extends Controller {
|
|
|
118
172
|
}
|
|
119
173
|
return source.textContent ?? "";
|
|
120
174
|
}
|
|
121
|
-
/**
|
|
175
|
+
/**
|
|
176
|
+
* Reads the current state back from the DOM.
|
|
177
|
+
*
|
|
178
|
+
* A `copied` or `error` found at connect time is this controller's own output
|
|
179
|
+
* from a connection that is gone, and so is the timer that would have cleared it
|
|
180
|
+
* — nothing else would ever return the element to `idle`. Any other authored
|
|
181
|
+
* value belongs to the consumer and only a missing attribute takes the default.
|
|
182
|
+
*/
|
|
183
|
+
#adopt() {
|
|
184
|
+
if (this.#inTransientState()) {
|
|
185
|
+
this.#reset();
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
setDefaultAttribute(this.element, "data-state", "idle");
|
|
189
|
+
}
|
|
190
|
+
/** Whether `data-state` currently holds one of the values this controller writes. */
|
|
191
|
+
#inTransientState() {
|
|
192
|
+
const state = this.element.getAttribute("data-state");
|
|
193
|
+
return state !== null && TRANSIENT_STATES.has(state);
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Returns the completion state to idle for the snapshot Turbo is about to take,
|
|
197
|
+
* so a page reached with the Back button does not report a copy that happened
|
|
198
|
+
* before the navigation. Only a state this controller wrote is rewound — an
|
|
199
|
+
* authored one is the consumer's and has to survive into the snapshot, exactly as
|
|
200
|
+
* `connect()` leaves it alone. State only — no `copy` is dispatched, which would
|
|
201
|
+
* claim a fresh copy ran.
|
|
202
|
+
*/
|
|
203
|
+
#rewind() {
|
|
204
|
+
if (!this.#inTransientState()) return;
|
|
205
|
+
this.#timers.clearAll();
|
|
206
|
+
this.#reset();
|
|
207
|
+
}
|
|
208
|
+
/** Reflects the result, announces it, and schedules the return to idle. */
|
|
122
209
|
#reportResult(success) {
|
|
123
210
|
this.element.setAttribute("data-state", success ? "copied" : "error");
|
|
124
211
|
if (this.hasFeedbackTarget) {
|
|
125
212
|
this.feedbackTarget.textContent = success ? this.copiedLabelValue : this.errorLabelValue;
|
|
126
213
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
this.#resetTimerId = null;
|
|
130
|
-
}
|
|
214
|
+
announce(success ? this.announceCopiedTextValue : this.announceErrorTextValue);
|
|
215
|
+
this.#timers.clearAll();
|
|
131
216
|
if (this.feedbackDurationValue > 0) {
|
|
132
|
-
this.#
|
|
133
|
-
this.#resetTimerId = null;
|
|
134
|
-
this.#reset();
|
|
135
|
-
}, this.feedbackDurationValue);
|
|
217
|
+
this.#timers.set(() => this.#reset(), this.feedbackDurationValue);
|
|
136
218
|
}
|
|
137
219
|
}
|
|
138
|
-
/** Returns to the idle state and
|
|
220
|
+
/** Returns to the idle state and empties the completion slot. */
|
|
139
221
|
#reset() {
|
|
140
222
|
this.element.setAttribute("data-state", "idle");
|
|
141
223
|
if (this.hasFeedbackTarget) {
|