stimeo-ui 0.18.0 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -2
- package/dist/cable/index.d.ts +2 -1
- package/dist/controllers/command_palette_controller.js +1 -0
- package/dist/controllers/command_palette_controller.js.map +1 -1
- package/dist/controllers/dismissible_controller.js +2 -0
- package/dist/controllers/dismissible_controller.js.map +1 -1
- package/dist/controllers/editable_controller.js +1 -0
- package/dist/controllers/editable_controller.js.map +1 -1
- package/dist/controllers/form_field_controller.d.ts +2 -1
- package/dist/controllers/input_mask_controller.d.ts +2 -1
- package/dist/controllers/input_mask_controller.js +23 -0
- package/dist/controllers/input_mask_controller.js.map +1 -1
- package/dist/controllers/multi_select_controller.d.ts +2 -1
- package/dist/controllers/multi_select_controller.js +21 -1
- package/dist/controllers/multi_select_controller.js.map +1 -1
- package/dist/controllers/pointer_drag_controller.d.ts +1 -0
- package/dist/controllers/pointer_drag_controller.js +6 -1
- package/dist/controllers/pointer_drag_controller.js.map +1 -1
- package/dist/controllers/popover_controller.d.ts +6 -2
- package/dist/controllers/popover_controller.js +9 -0
- package/dist/controllers/popover_controller.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +63 -2
- package/dist/index.js.map +1 -1
- package/dist/inspector/cli.d.ts +10 -1
- package/dist/inspector/cli.js +5 -0
- package/dist/inspector/cli.js.map +1 -1
- package/dist/inspector/cli_bin.d.ts +1 -1
- package/dist/inspector/cli_bin.js +9 -0
- package/dist/inspector/cli_bin.js.map +1 -1
- package/dist/inspector/manifest.json +2 -2
- package/dist/positioning/index.d.ts +2 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/attribute_write.ts","../../src/utils/shared_registry.ts","../../src/utils/attribute_lease.ts","../../src/utils/composition_tracker.ts","../../src/utils/listener_set.ts","../../src/controllers/editable_controller.ts"],"names":["registry"],"mappings":";;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,SAAA;AAAA,EACvC;AACF","file":"editable_controller.js","sourcesContent":["/**\n * Reflects a serialized attribute value only when the current value differs.\n *\n * A same-value `setAttribute` still queues a mutation record for every observer, so an\n * unchanged value writes nothing.\n *\n * @param element - The element whose attribute is reflected.\n * @param name - The attribute name, using the non-namespaced DOM API.\n * @param value - The serialized value, or null to remove the attribute.\n * @param beforeWrite - Called only for a change, before the DOM mutation, so the\n * caller can record ownership or identify its own observer records.\n * @returns Whether an attribute was written or removed.\n */\nexport function setAttributeIfChanged(\n element: Element,\n name: string,\n value: string | null,\n beforeWrite?: () => void,\n): boolean {\n if (element.getAttribute(name) === value) return false;\n beforeWrite?.();\n if (value === null) element.removeAttribute(name);\n else element.setAttribute(name, value);\n return true;\n}\n","/**\n * One registry per page for every copy of the library.\n *\n * Each `stimeo-ui/controllers/*` file, and each opt-in entry, is built on its own and carries\n * its own copy of every utility it uses, so a page that imports controllers one by one, or one\n * of them next to the barrel, evaluates a utility several times. A registry that coordinates\n * instances of different controllers — the stacks of leased values, the loans of a\n * `tabindex`, the Escape layers, the focus traps — must not be split by that: a dialog inside\n * a drawer, or a character counter and a form field on one input, coordinate whichever files\n * they came from. So such a registry lives once on `globalThis`, under a `Symbol.for` key the\n * copies agree on, and the first copy to ask for it creates it.\n *\n * The key names the registry and the version of its shape\n * (`stimeo-ui.<utility>.registry.v<n>`). Copies whose registries have the same shape share\n * one; a release that changes the shape changes the version, so a copy of another release\n * keeps a registry of its own instead of reading entries it does not understand — the two\n * then coordinate within each release only. An entry another copy put in a registry is read\n * through its fields alone, never through `#private` members, which belong to the class of\n * the copy that created it.\n */\n\n/**\n * The registry stored under `key`, created by `create` on first use.\n *\n * @param key - `stimeo-ui.<utility>.registry.v<n>`: the version is that of the shape `create`\n * returns.\n * @param create - Builds the empty registry.\n */\nexport function sharedRegistry<T extends object>(key: string, create: () => T): T {\n const symbol = Symbol.for(key);\n const scope = globalThis as unknown as Record<symbol, T | undefined>;\n const existing = scope[symbol];\n if (existing !== undefined) return existing;\n const registry = create();\n Object.defineProperty(globalThis, symbol, { value: registry });\n return registry;\n}\n","import { setAttributeIfChanged } from \"./attribute_write\";\nimport { sharedRegistry } from \"./shared_registry\";\n\n/** What a lease's record says: the author's value, its last write, the leases beneath. */\ninterface AttributeLeaseRecord {\n readonly original: string | null;\n readonly written: string | null;\n /** Whether it hands back what the lease right beneath it wrote last. */\n readonly linked: boolean;\n /** The records of the other owners' leases beneath it, nearest first. */\n readonly beneath: readonly string[];\n}\n\n/** One lease's hold on one element's attribute, in the stack every lease of it shares. */\ninterface AttributeHold {\n /** The lease holding it; `null` for a hold read from a copy's record until its lease takes it. */\n lease: object | null;\n readonly record: string;\n written: string | null;\n /** What it hands back with nothing beneath it: the author's value. */\n readonly original: string | null;\n /** Whether it hands back what the hold beneath it wrote last instead. */\n linked: boolean;\n}\n\n/** The holds on each element by attribute, and every lease's record name by attribute. */\ninterface AttributeLeaseRegistry {\n readonly stacks: WeakMap<Element, Map<string, AttributeHold[]>>;\n readonly names: Map<string, Set<string>>;\n}\n\n/** Holds and record names coordinate across separately built package entries. */\nconst registry = sharedRegistry(\n \"stimeo-ui.attribute-lease.registry.v1\",\n (): AttributeLeaseRegistry => ({ stacks: new WeakMap(), names: new Map() }),\n);\n\n/** Whether a parsed record entry is an attribute value: a string, or `null` for absence. */\nfunction isAttributeValue(value: unknown): value is string | null {\n return value === null || typeof value === \"string\";\n}\n\n/**\n * Reads the record a lease left on `element`: the author's value, the value the lease wrote\n * last, whether it hands back the value beneath it (`false` before the names when it does not)\n * and the records beneath it. `undefined` when the record is missing or holds anything else.\n */\nfunction readLeaseRecord(element: Element, record: string): AttributeLeaseRecord | undefined {\n try {\n const parsed: unknown = JSON.parse(element.getAttribute(record) ?? \"null\");\n if (!Array.isArray(parsed)) return undefined;\n const [original, written, ...rest] = parsed as unknown[];\n const linked = rest[0] !== false;\n const beneath = linked ? rest : rest.slice(1);\n if (!beneath.every((under): under is string => typeof under === \"string\")) return undefined;\n return isAttributeValue(original) && isAttributeValue(written)\n ? { original, written, linked, beneath }\n : undefined;\n } catch {\n return undefined;\n }\n}\n\n/** The element's stack, seeded from complete ownership records once. */\nfunction attributeStack(element: Element, attribute: string): AttributeHold[] {\n const byAttribute = registry.stacks.get(element) ?? new Map<string, AttributeHold[]>();\n registry.stacks.set(element, byAttribute);\n const known = byAttribute.get(attribute);\n if (known) return known;\n const found: (AttributeLeaseRecord & { readonly record: string })[] = [];\n for (const record of registry.names.get(attribute) ?? []) {\n const read = readLeaseRecord(element, record);\n if (read) found.push({ ...read, record });\n }\n const depth = ({ beneath }: (typeof found)[number]) =>\n beneath.filter((name) => found.some((other) => other.record === name)).length;\n const stack = found\n .sort((one, other) => depth(one) - depth(other))\n .map(({ record, written, original, linked }, index) => ({\n lease: null,\n record,\n written,\n original,\n linked: linked && index > 0,\n }));\n byAttribute.set(attribute, stack);\n return stack;\n}\n\n/** The lease's live hold or the unclaimed hold described by its owner's record. */\nfunction findHold(\n stack: readonly AttributeHold[],\n lease: object,\n record: string,\n): AttributeHold | undefined {\n return (\n stack.find((held) => held.lease === lease) ??\n stack.find((held) => held.lease === null && held.record === record)\n );\n}\n\n/**\n * Inspects a derived writer's continuation without acquiring or returning a hold.\n * A covered hold may update beneath its cover. Without a hold, the expected authored\n * value is compared with the original beneath any temporary cover. The original\n * distinguishes an absent attribute from an empty one.\n */\nexport function readAttributeLease(\n element: Element,\n attribute: string,\n owner: string,\n lease: object,\n expected: string | null,\n): { readonly allowed: boolean; readonly original: string | null } {\n const stack = attributeStack(element, attribute);\n const hold = findHold(stack, lease, `data-${owner}-${attribute}-lease`);\n const current = element.getAttribute(attribute);\n const covering = [...stack].reverse().find((other) => other.written === current);\n const original = (hold ?? covering)?.original;\n const authored = original === undefined ? current : original;\n return {\n original: authored,\n allowed: hold\n ? current === hold.written ||\n stack.slice(stack.indexOf(hold) + 1).some((above) => above.written === current)\n : authored === expected,\n };\n}\n\n/**\n * The value `element`'s author wrote for `attribute`, as the record a lease of any owner leaves\n * on the element carries it; `undefined` while no lease leaves one, as when nothing has moved\n * the attribute off the author's value. A field a reveal turned from `password` into `text`\n * still reads `\"password\"` here.\n */\nexport function leasedAuthorValue(element: Element, attribute: string): string | null | undefined {\n const suffix = `-${attribute}-lease`;\n for (const name of element.getAttributeNames()) {\n if (!name.startsWith(\"data-\") || !name.endsWith(suffix)) continue;\n const record = readLeaseRecord(element, name);\n if (record) return record.original;\n }\n return undefined;\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 * **Every lease of an attribute shares one stack of holds per element**, whatever its owner\n * and whichever file of the package constructed it (the stacks are one per page): the holds\n * sit in the order their leases first wrote the element, each with the value it wrote last.\n * The element's value is the highest hold's that carries it, and the page's when none does.\n * A write reaches the element unless a hold above the writer carries the element's value: the\n * top hold always shows its writes, a hold beneath it shows nothing while a hold above keeps\n * its value on the element, and once the page has put a value there that no hold carries, the\n * next write of any hold replaces it. A return gives a value back only from the hold the\n * element's value is: the value the hold beneath it wrote last, or the author's once nothing\n * is beneath it; any other return only leaves the stack, and the page's value stays. Holds\n * that wrote the same value are told apart by the stack, never by the value: the higher one\n * keeps it. A first write over a top hold whose value the page has replaced takes the\n * element's value as the author's. Two instances of one controller on one element — an\n * element outside their scope — stack the same way.\n *\n * A **base lease** (`{ base: true }`) holds the element's own state rather than a value over\n * it — a form field's ARIA on its control is one — so its first write goes to the bottom of\n * the stack, beneath the leases of other owners already there: a temporary value another\n * owner leased stays shown and returns to the base lease's latest value.\n *\n * **The stack travels with the element.** While a hold shows a value other than the author's,\n * lies on another hold or is covered by one, the element carries its owner's record\n * `data-<owner>-<attribute>-lease`: JSON of the author's value and the value the hold wrote\n * last (each a string, or `null` for an absent attribute), `false` where the hold hands back\n * the author's value rather than the latest value of the hold beneath it, and the records of\n * every hold beneath it, nearest first. Returning the last lease of an owner removes its\n * record. A copy of the element — a page Turbo restores from its cache is one — therefore\n * carries the stack, and the first lease to touch the copy reads it back under the record\n * names of the leases constructed so far, which include every lease that wrote a record the\n * cache holds, and orders the holds by the records each one lists beneath it. Each lease takes\n * the hold its owner's record describes over in place. Complete records for distinct owners\n * preserve their order across a copy. The records describe holds by owner, not by instance:\n * one owner holding the element more than once leaves only its topmost hold's record, which\n * the first of its leases to write or return on the copy takes. Lower holds of that owner and\n * their positions are absent; mutually listed owners cannot express their full live order.\n * A hold that showed the author's value alone carries no record and is taken by its first\n * write on the copy. Missing or unreadable records also leave their holds unknown, so copying\n * the DOM does not promise identical decisions for every live stack. Without a record it can\n * read, a new stack takes the current value as the author's. A Turbo morph removes records\n * absent from the server HTML; existing holds remain in memory until their leases return.\n *\n * The lease has no lifecycle of its own, so it never subscribes to document events,\n * and nothing rewinds a live page before Turbo caches it: `turbo:before-cache` also\n * fires on pages that stay.\n */\nexport class AttributeLease<T extends Element = Element> {\n readonly #attribute: string;\n readonly #record: string;\n readonly #base: boolean;\n readonly #preserveAuthor: boolean;\n readonly #held = new Set<T>();\n\n /**\n * @param attribute - The attribute whose temporary values this lease owns.\n * @param owner - Names the record on the element; the controller's identifier.\n * @param options - `base`: written beneath the other owners' leases;\n * `preserveAuthor`: a new base hold keeps a current value that no hold carries as authored.\n */\n constructor(\n attribute: string,\n owner: string,\n options: { readonly base?: boolean; readonly preserveAuthor?: boolean } = {},\n ) {\n this.#attribute = attribute;\n this.#record = `data-${owner}-${attribute}-lease`;\n this.#base = options.base === true;\n this.#preserveAuthor = options.preserveAuthor === true;\n const names = registry.names;\n names.set(attribute, (names.get(attribute) ?? new Set<string>()).add(this.#record));\n }\n\n /** Writes or removes the leased attribute while preserving its authored value. */\n write(element: T, value: string | null): void {\n const stack = attributeStack(element, this.#attribute);\n const hold = this.#take(stack) ?? this.#acquire(element, stack);\n this.#held.add(element);\n const shows = !this.#covered(element, stack, hold);\n hold.written = value;\n this.#mark(element, stack);\n if (shows) this.#reflect(element, value);\n }\n\n /**\n * Returns one lease, also on a restored copy, to the value the hold beneath it wrote last or\n * the author's, without overwriting a value a consumer wrote since. Says whether there was a\n * lease to return: a hold this lease has, or the hold a copy's record describes while no live\n * lease of the owner has taken it — a copy of a page an earlier connection wrote carries one.\n */\n return(element: T): boolean {\n const held = this.#held.delete(element);\n const known = registry.stacks.get(element)?.has(this.#attribute);\n const stack =\n held || known || element.hasAttribute(this.#record)\n ? attributeStack(element, this.#attribute)\n : [];\n const hold = this.#take(stack);\n if (!hold) return false;\n const carries = element.getAttribute(this.#attribute) === hold.written;\n const owns = carries && !this.#covered(element, stack, hold);\n const index = stack.indexOf(hold);\n stack.splice(index, 1);\n const above = stack[index];\n if (above) above.linked &&= hold.linked;\n this.#mark(element, stack);\n if (!owns) return true;\n const below = hold.linked ? stack[index - 1] : undefined;\n this.#reflect(element, below ? below.written : hold.original);\n return true;\n }\n\n /** Returns every lease it holds, with the same ownership check as {@link return}. */\n returnAll(): void {\n for (const element of Array.from(this.#held)) this.return(element);\n }\n\n /** Its hold in `stack`, taking over one read from its record. */\n #take(stack: AttributeHold[]): AttributeHold | undefined {\n const hold = findHold(stack, this, this.#record);\n if (hold) hold.lease = this;\n return hold;\n }\n\n /** A new hold: on top, over the top hold while the element shows it; a base one at the bottom. */\n #acquire(element: T, stack: AttributeHold[]): AttributeHold {\n const current = element.getAttribute(this.#attribute);\n const top = stack.at(-1);\n const bottom = stack[0];\n const over = top?.written === current ? top : undefined;\n const from = this.#base\n ? this.#preserveAuthor && !stack.some((held) => held.written === current)\n ? undefined\n : bottom\n : over;\n const hold: AttributeHold = {\n lease: this,\n record: this.#record,\n written: current,\n original: from ? from.original : current,\n linked: !this.#base && over !== undefined,\n };\n if (this.#base && bottom) {\n bottom.linked = true;\n stack.unshift(hold);\n } else stack.push(hold);\n return hold;\n }\n\n /** Whether a hold above `hold` carries the element's value, which is then that hold's. */\n #covered(element: T, stack: readonly AttributeHold[], hold: AttributeHold): boolean {\n const current = element.getAttribute(this.#attribute);\n return stack.slice(stack.indexOf(hold) + 1).some((above) => above.written === current);\n }\n\n /** Leaves each owner's record of its topmost hold, or none where nothing needs one. */\n #mark(element: T, stack: readonly AttributeHold[]): void {\n const records = new Map<string, string | null>([[this.#record, null]]);\n stack.forEach((hold, index) => {\n const names = stack.slice(0, index).map((under) => under.record);\n const beneath = [...new Set(names.reverse())].filter((name) => name !== hold.record);\n const marker = hold.linked || beneath.length === 0 ? [] : [false];\n records.set(\n hold.record,\n hold.written === hold.original && beneath.length === 0 && index === stack.length - 1\n ? null\n : JSON.stringify([hold.original, hold.written, ...marker, ...beneath]),\n );\n });\n for (const [name, recorded] of records) {\n setAttributeIfChanged(element, name, recorded);\n }\n }\n\n /** Reflects only a real value transition, avoiding self-triggered mutation work. */\n #reflect(element: T, value: string | null): void {\n setAttributeIfChanged(element, this.#attribute, value);\n }\n}\n","/** Minimal event shape carrying the platform's per-event composition signal. */\nexport interface CompositionSignal {\n readonly isComposing?: boolean;\n}\n\n/** Minimal `input` shape needed to tell a composition echo from a fresh edit. */\nexport interface ConfirmedInputSignal {\n readonly target: EventTarget | null;\n readonly inputType?: string;\n}\n\n/**\n * The `inputType` values an engine reports on an `input` that belongs to a\n * composition rather than to an edit the user just made.\n */\nconst COMPOSITION_INPUT_TYPES = new Set([\n \"insertCompositionText\",\n \"insertFromComposition\",\n \"deleteCompositionText\",\n \"deleteByComposition\",\n]);\n\n/** Whether a platform input kind belongs to composition rather than ordinary editing. */\nexport function isCompositionInputType(inputType: string | undefined): boolean {\n return inputType !== undefined && COMPOSITION_INPUT_TYPES.has(inputType);\n}\n\n/** The cancelable notice Turbo dispatches before a morph writes one attribute. */\nconst BEFORE_MORPH_ATTRIBUTE = \"turbo:before-morph-attribute\";\n\n/** Hooks that keep component-specific work outside {@link CompositionTracker}. */\nexport interface CompositionTrackerOptions {\n /** Runs after lifecycle state is set for a `compositionstart` event. */\n readonly onStart?: (event: Event) => void;\n /** Runs after lifecycle state is cleared for a `compositionend` event. */\n readonly onEnd?: (event: Event) => void;\n /**\n * Runs once lifecycle state is cleared for a composition that ended without\n * `compositionend`, with the `element` it ran in. Nothing was confirmed: the\n * element holds what a write left (`inPlace` false), or still holds the text the\n * composition left, which the engine stopped composing (`inPlace` true) — text\n * typed against whatever the page declared while it ran.\n *\n * A hook applies the work the composition held back — and only that — at once,\n * keeping the caret where it was. The event that showed the end is then handled as\n * it would be with no composition: the text the element holds is read by whatever\n * reads it next, as the user's edit if an edit reads it. A consumer whose contract\n * judges what an interrupted conversion leaves may also settle that text here, as\n * `stimeo--otp` returns a residual its `pattern` rejects to the prior character: it reports\n * that as a reconciliation, never as the user's edit, and keeps the selection.\n *\n * When the tracker sees the end in an event it hears — a key, an edit, a focus\n * change, the next `compositionstart` — the hook runs there, in the capture phase,\n * ahead of that event's own handlers and of the edit it announces, whoever\n * dispatched it. When a question ({@link CompositionTracker.isComposing},\n * {@link CompositionTracker.composingElement}) or a Turbo morph's notice for one\n * attribute shows the end, the hook runs in a microtask after them, never inside\n * its caller or a half-applied morph, unless an event the tracker hears comes\n * first. On `compositionstart` it runs after the new composition is set and before\n * `onStart`: {@link CompositionTracker.isComposing} is true again, so work held for\n * the old composition stays held for the new.\n */\n readonly onAbandon?: (element: EventTarget, inPlace: boolean) => void;\n}\n\n/** One composition in progress. */\ninterface Composition {\n /** The observed target the composition was heard on. */\n readonly target: EventTarget;\n /** The element composing: the observed field itself, or a field inside an observed ancestor. */\n readonly element: EventTarget;\n /** The value the composition last left in the element; `undefined` for an element with none. */\n text: unknown;\n}\n\n/**\n * The element's live value; `undefined` for an element without one, which a write never\n * changes.\n */\nconst textOf = (element: EventTarget): unknown => (element as { value?: unknown }).value;\n\n/** Whether `element` is the focused element of the document or shadow root it is in. */\nconst holdsFocus = (element: EventTarget): boolean =>\n element instanceof Node &&\n (element.getRootNode() as Partial<DocumentOrShadowRoot>).activeElement === element;\n\n/**\n * Owns IME composition listeners and transient state for one or more event targets.\n *\n * Some browsers omit `KeyboardEvent.isComposing` on the keydown that confirms a\n * conversion. Tracking `compositionstart` through `compositionend` supplies the\n * missing lifecycle signal without relying on deprecated numeric key codes.\n * Component policy stays with the consumer: filtering, validation, and submission\n * belong in the optional {@link CompositionTrackerOptions.onEnd} callback.\n *\n * The tracker also owns the other half of that lifecycle: **the `input` some\n * engines send after `compositionend` to echo the text just confirmed.** A\n * consumer that ran `onEnd` and then handled the echo would commit the same\n * confirmation twice, so {@link CompositionTracker.consumesConfirmedInput} tells\n * the echo apart and the consumer returns early on it.\n *\n * **What the echo is not, is the harder half.** Not every engine sends one —\n * Chromium ends a confirmation at `compositionend` with no `input` after it — so\n * a window that waits for the echo and only closes on the next key would swallow\n * the first edit that arrives without one: dictation, autofill, a drop,\n * `insertText`. Two things keep that from happening. The window closes on the\n * next anything — a key, a new composition, any `input`, losing the field — and\n * an `input` that reports an `inputType` outside {@link COMPOSITION_INPUT_TYPES}\n * is an edit, so it is never folded. Only an engine that reports no `inputType`\n * at all is left relying on the window alone.\n *\n * **A composition can also end without `compositionend`.** Chromium drops the\n * conversion silently when something other than the IME writes a different value\n * into its field — a Turbo morph, a form reset, a script — and when the field\n * moves or leaves the page, leaving the text it composed. The tracker reads the end\n * from what the engine and the field still say:\n *\n * - **The field holds other text than the composition left.** The IME's edits, and\n * the user's own between them, arrive as an `input` the engine dispatched\n * (`isTrusted`) or one that reports the composition, and the tracker takes the\n * field's text from those. A write by anything else changes the text with no such\n * `input` — at most a synthetic one — so the composition is over, ended with\n * {@link CompositionTrackerOptions.onAbandon}, before anyone acts on the field.\n * Writing the same text keeps the conversion, and the match.\n * - **The engine edits outside a composition.** A `beforeinput` reporting\n * `isComposing: false` with an `inputType` outside {@link COMPOSITION_INPUT_TYPES}\n * is an edit the engine no longer counts as composition — unless the `keydown`\n * right before it reported `isComposing: true`: a key the IME lets through, such\n * as Backspace, edits the field while the conversion goes on. This is what shows\n * a composition that ended with its text in place. Only one field composes at a\n * time, so such an edit on any observed target ends the composition held, with\n * `onAbandon`. A `keydown` can hold this back but never starts it: the keydown\n * that confirms a conversion may carry no `isComposing`, and dictation and\n * autofill edit with no key at all.\n * - **The field stays where it was heard.** A field the consumer observes itself is\n * the consumer's to release when it moves or leaves, which reads what it holds;\n * one that keeps focus through the move keeps composing\n * ({@link CompositionTracker.disconnect}). A field inside an observed ancestor\n * that leaves the ancestor, or loses focus within its document, ends its\n * composition quietly; one that stays the document's active element — the window\n * lost focus — keeps composing.\n * - **No other field composes**: a `compositionstart` ends any composition the\n * tracker still holds, with `onAbandon`, before the new one starts.\n *\n * The tracker checks this before it answers {@link CompositionTracker.isComposing}\n * or {@link CompositionTracker.composingElement}, and at every key, edit, blur,\n * `compositionstart` and morph it hears — keys, edits and blurs in the capture\n * phase, ahead of the consumer's own handlers. While\n * a composition is live, a Turbo morph leaves its field's value alone: Idiomorph\n * asks through `turbo:before-morph-attribute` before it writes `value`, as an\n * attribute or as the live text, and the tracker cancels that one notice for the\n * element composing, so the morph keeps the conversion, as it keeps focus. Every\n * other attribute, and every other element, still morphs.\n *\n * A consumer that observes several fields tells the conversion's own events from\n * edits in the other fields with {@link CompositionTracker.owns}, which holds even\n * while the tracker keeps a composition whose end no event has shown yet.\n *\n * @example\n * ```ts\n * #composition = new CompositionTracker({ onEnd: () => this.filter() });\n *\n * connect(): void {\n * this.#composition.observe(this.inputTarget);\n * }\n *\n * disconnect(): void {\n * this.#composition.disconnect();\n * }\n *\n * onInput(event: InputEvent): void {\n * if (this.#composition.consumesConfirmedInput(event)) return;\n * if (this.#composition.isComposing(event)) return;\n * }\n *\n * onKeydown(event: KeyboardEvent): void {\n * if (this.#composition.isComposing(event)) return;\n * }\n * ```\n */\nexport class CompositionTracker {\n readonly #observedTargets = new Set<EventTarget>();\n /** The composition in progress, if any: only one field composes at a time. */\n #composition: Composition | null = null;\n readonly #onStart: ((event: Event) => void) | undefined;\n readonly #onEnd: ((event: Event) => void) | undefined;\n readonly #onAbandon: ((element: EventTarget, inPlace: boolean) => void) | undefined;\n /** The field whose confirming `input` is still owed, while the window is open. */\n #confirmedTarget: EventTarget | null = null;\n /**\n * Whether the last `keydown` reported a composition, until the `beforeinput`\n * after it: the edit that key announces lands inside the composition.\n */\n #keyComposing = false;\n /** Whether the consumer is connected: from `observe()` until `disconnect()`. */\n #connected = false;\n /** A composition that ended without `compositionend` and whose `onAbandon` has not run yet. */\n #abandoned: { readonly element: EventTarget; readonly inPlace: boolean } | null = null;\n\n constructor(options: CompositionTrackerOptions = {}) {\n this.#onStart = options.onStart;\n this.#onEnd = options.onEnd;\n this.#onAbandon = options.onAbandon;\n }\n\n /**\n * Starts lifecycle tracking for `target`; repeated calls are idempotent. The\n * targets one tracker observes do not contain one another: a composition event\n * reaching two of them would be counted as two.\n */\n observe(target: EventTarget): void {\n this.#connected = true;\n if (this.#observedTargets.has(target)) return;\n target.addEventListener(\"compositionstart\", this.#handleStart);\n target.addEventListener(\"compositionend\", this.#handleEnd);\n target.addEventListener(\"keydown\", this.#handleKeydown, true);\n target.addEventListener(\"beforeinput\", this.#handleBeforeInput, true);\n target.addEventListener(\"input\", this.#handleInput, true);\n target.addEventListener(\"blur\", this.#handleBlur, true);\n target.addEventListener(BEFORE_MORPH_ATTRIBUTE, this.#handleBeforeMorphAttribute);\n this.#observedTargets.add(target);\n }\n\n /**\n * Stops tracking one target. A composition it held ends quietly, unless its element\n * still holds focus — see {@link CompositionTracker.disconnect}.\n */\n unobserve(target: EventTarget): void {\n if (!this.#observedTargets.delete(target)) return;\n this.#release(target);\n if (this.#composition?.target === target) this.#letGo();\n if (this.#confirmedTarget === target) this.#confirmedTarget = null;\n }\n\n /**\n * Releases every listener and clears state so reconnect starts cleanly.\n *\n * A composition whose element still holds focus is the exception. A move that\n * keeps focus — `moveBefore`, which Turbo's morph uses where the browser provides\n * it — can leave the conversion running, and Stimulus releases the moved target, or\n * the controller around it, and observes it again within the one mutation batch. So\n * the composition waits for its target to be observed again before the turn ends,\n * and goes on; otherwise it ends then — quietly once disconnected, and with\n * {@link CompositionTrackerOptions.onAbandon} for a consumer that only let that one\n * target go. A move without `moveBefore`, or a removal, takes focus away.\n */\n disconnect(): void {\n this.#connected = false;\n for (const target of this.#observedTargets) this.#release(target);\n this.#observedTargets.clear();\n this.#letGo();\n this.#confirmedTarget = null;\n this.#keyComposing = false;\n this.#abandoned = null;\n }\n\n /**\n * True when a composition is live or the current event reports one. A\n * composition that ended without `compositionend` ends here first.\n */\n isComposing(event?: CompositionSignal): boolean {\n this.#settle();\n return event?.isComposing === true || this.#composition !== null;\n }\n\n /**\n * The element a live composition is running in, or `null`. A composition that\n * ended without `compositionend` ends here first.\n */\n composingElement(): EventTarget | null {\n this.#settle();\n return this.#composition?.element ?? null;\n }\n\n /**\n * Whether `event` belongs to a composition: it reports one, or it is in the element a\n * live composition runs in. An event in another element — a key there, or a script's\n * write reported with a bare `input` — is an edit outside the composition, even while\n * the tracker holds one whose end it has not seen: only one element composes at a\n * time, and the IME edits nothing else. The composition held stays, since such an\n * event does not show its end. A consumer that observes several fields asks this of\n * each event; {@link CompositionTracker.isComposing} asks of the targets as a whole.\n * A composition that ended without `compositionend` ends here first.\n */\n owns(event: CompositionSignal & { readonly target: EventTarget | null }): boolean {\n const element = this.composingElement();\n return event.isComposing === true || (element !== null && element === event.target);\n }\n\n /**\n * Whether `event` is the `input` echoing the composition just confirmed.\n *\n * Asking closes the window either way, so one confirmation is folded at most\n * once and a consumer asks once per `input`.\n */\n consumesConfirmedInput(event: ConfirmedInputSignal): boolean {\n const confirmed = this.#confirmedTarget;\n this.#confirmedTarget = null;\n if (confirmed === null || confirmed !== event.target) return false;\n // An engine that reports no kind at all leaves `inputType` empty, and the\n // window is then the only signal there is.\n const inputType = event.inputType;\n return !inputType || isCompositionInputType(inputType);\n }\n\n /** Removes every listener {@link CompositionTracker.observe} added to `target`. */\n #release(target: EventTarget): void {\n target.removeEventListener(\"compositionstart\", this.#handleStart);\n target.removeEventListener(\"compositionend\", this.#handleEnd);\n target.removeEventListener(\"keydown\", this.#handleKeydown, true);\n target.removeEventListener(\"beforeinput\", this.#handleBeforeInput, true);\n target.removeEventListener(\"input\", this.#handleInput, true);\n target.removeEventListener(\"blur\", this.#handleBlur, true);\n target.removeEventListener(BEFORE_MORPH_ATTRIBUTE, this.#handleBeforeMorphAttribute);\n }\n\n /**\n * Lets go of the composition held once its target is no longer observed: it is over\n * unless its element kept focus and its target is observed again this turn.\n */\n #letGo(): void {\n const composition = this.#composition;\n if (composition === null) return;\n if (!holdsFocus(composition.element)) {\n this.#composition = null;\n return;\n }\n queueMicrotask(() => {\n if (this.#composition !== composition || this.#observedTargets.has(composition.target)) {\n return;\n }\n this.#composition = null;\n if (!this.#connected) return;\n this.#abandoned = { element: composition.element, inPlace: true };\n this.#runAbandon();\n });\n }\n\n /**\n * Ends the composition held if its field left the observed target, taking the\n * composition's text along, or holds text a write left.\n */\n #settle(): void {\n const composition = this.#composition;\n if (composition === null) return;\n const { target, element, text } = composition;\n if (target instanceof Node && element instanceof Node && !target.contains(element)) {\n this.#composition = null;\n } else if (textOf(element) !== text) {\n this.#abandon(false);\n }\n }\n\n /**\n * Ends the composition held, unconfirmed. Its `onAbandon` runs in a microtask,\n * unless an event the tracker hears runs it first.\n */\n #abandon(inPlace: boolean): void {\n this.#owe(inPlace);\n this.#composition = null;\n queueMicrotask(this.#runAbandon);\n }\n\n /** Records the `onAbandon` the composition held owes. */\n #owe(inPlace: boolean): void {\n const composition = this.#composition;\n if (composition !== null) this.#abandoned = { element: composition.element, inPlace };\n }\n\n /** Runs the `onAbandon` an ended composition owes, once. */\n readonly #runAbandon = (): void => {\n const abandoned = this.#abandoned;\n if (abandoned === null) return;\n this.#abandoned = null;\n this.#onAbandon?.(abandoned.element, abandoned.inPlace);\n };\n\n /** A composition starting while one is held ends the held one, unconfirmed. */\n readonly #handleStart = (event: Event): void => {\n this.#confirmedTarget = null;\n this.#settle();\n this.#owe(true);\n // A listener runs while the event is dispatched, so both targets are set.\n const target = event.currentTarget as EventTarget;\n const element = event.target as EventTarget;\n this.#composition = { target, element, text: textOf(element) };\n this.#runAbandon();\n this.#onStart?.(event);\n };\n\n readonly #handleEnd = (event: Event): void => {\n this.#runAbandon();\n if (this.#composition?.target === event.currentTarget) this.#composition = null;\n this.#confirmedTarget = event.target;\n this.#onEnd?.(event);\n };\n\n /**\n * A key on an observed field opens an edit of its own, so no echo is owed; it\n * also says whether the edit it announces lands inside a composition.\n */\n readonly #handleKeydown = (event: Event): void => {\n this.#settle();\n this.#runAbandon();\n this.#confirmedTarget = null;\n this.#keyComposing = (event as KeyboardEvent).isComposing === true;\n };\n\n /** An edit is about to land: a composition the engine no longer runs ends first. */\n readonly #handleBeforeInput = (event: Event): void => {\n const keyComposing = this.#keyComposing;\n this.#keyComposing = false;\n this.#settle();\n const { isComposing, inputType } = event as InputEvent;\n if (\n this.#composition !== null &&\n !keyComposing &&\n !isComposing &&\n inputType &&\n !isCompositionInputType(inputType)\n ) {\n this.#abandon(true);\n }\n this.#runAbandon();\n };\n\n /**\n * Takes the composing field's text from an `input` the engine dispatched or one\n * that reports the composition; any other `input` follows a write the\n * composition did not make.\n */\n readonly #handleInput = (event: Event): void => {\n const composition = this.#composition;\n const { isTrusted, isComposing, inputType } = event as InputEvent;\n if (\n composition !== null &&\n event.target === composition.element &&\n (isTrusted || isComposing || isCompositionInputType(inputType))\n ) {\n composition.text = textOf(composition.element);\n } else {\n this.#settle();\n }\n this.#runAbandon();\n };\n\n /**\n * Checks the composition as a field loses focus, ahead of the consumer's own blur\n * handlers. A field inside an observed ancestor that loses focus within its\n * document keeps its text and composes no more.\n */\n readonly #handleBlur = (event: Event): void => {\n this.#settle();\n this.#runAbandon();\n const composition = this.#composition;\n if (composition === null || composition.target === composition.element) return;\n const { element } = composition;\n if (!(element instanceof Node) || event.target !== element) return;\n const root = element.getRootNode() as Document | ShadowRoot;\n if (root.activeElement !== element) this.#composition = null;\n };\n\n /** Keeps a Turbo morph from writing the value of the element composing. */\n readonly #handleBeforeMorphAttribute = (event: Event): void => {\n this.#settle();\n const composition = this.#composition;\n if (composition?.target !== event.currentTarget || event.target !== composition.element) return;\n const detail: { readonly attributeName?: unknown } | null = (event as CustomEvent).detail;\n if (detail?.attributeName === \"value\") event.preventDefault();\n };\n}\n","/** What {@link ListenerSet.add} passes on besides the signal it supplies itself. */\nexport type ListenerOptions = Omit<AddEventListenerOptions, \"signal\">;\n\n/**\n * The event map a target's own `addEventListener` types its handlers with: the\n * window's, a document's, an HTML or SVG element's, any other element's, or a\n * media query list's. Other targets name none.\n */\ntype EventMapOf<T extends EventTarget> = T extends Window\n ? WindowEventMap\n : T extends Document\n ? DocumentEventMap\n : T extends HTMLElement\n ? HTMLElementEventMap\n : T extends SVGElement\n ? SVGElementEventMap\n : T extends Element\n ? ElementEventMap\n : T extends MediaQueryList\n ? MediaQueryListEventMap\n : Record<never, never>;\n\n/**\n * Owns every listener a controller attaches for one connected lifetime and\n * releases them together, so an event name is spelled once and the release\n * cannot drift from the registration.\n *\n * Detaching by hand repeats three things at the release site — the type, the\n * handler reference and the capture flag — and any one of them drifting leaves\n * a listener alive on an element the controller no longer drives. Aborting the\n * signal a registration was created with releases it whatever it was made of,\n * so the release site names nothing.\n *\n * One set per lifetime, held as a field and never rebuilt.\n * {@link ListenerSet.dispose} is the only thing that closes a generation, and it opens\n * the next one in the same step, so the lifecycle hooks can call `add` and\n * `dispose` in any order any number of times, and no `add` ever meets an\n * already aborted signal — a DOM that registers a listener on such a signal\n * would keep it forever. Rebuilding the set instead would leak:\n * `addEventListener` matches an existing registration on target, type, callback\n * and capture alone, so re-adding the same handler while the first registration\n * is live is discarded, and that live registration keeps the signal it was\n * attached with — a set built by a second `connect()` can never release what it\n * appears to own.\n *\n * Scope is the registration only. Timers, observers, leases and the order they\n * are unwound in stay with the controller, which places `dispose()` in its\n * cleanup sequence. A receiver that changes at runtime (a\n * swapped target) is rebound by calling `dispose()` and then `add()` again from\n * the rebind, not by a second set.\n *\n * A lifetime shorter than the connection — while a Value holds, until a first\n * load, while a subscription is open — gets a set of its own, which the end of\n * that lifetime disposes. A controller therefore holds one set per lifetime: the\n * connection's, and one for each swapped receiver or shorter span.\n *\n * The set must own every registration of a tuple it holds: a listener the same\n * target already carries for the same type, callback and capture flag keeps the\n * right to remove it, and this set's `add` for that tuple is discarded. A\n * subscription shared between instances behind a participant count, listeners of\n * several elements that come and go one at a time, and those one gesture holds\n * keep their own pair of calls or a signal of their own.\n *\n * @example\n * ```ts\n * readonly #listeners = new ListenerSet();\n *\n * connect(): void {\n * this.#listeners.add(this.element, \"submit\", this.#onNativeSubmit, { capture: true });\n * this.#listeners.add(this.element, \"turbo:submit-start\", this.#onSubmitStart);\n * this.#listeners.add(this.element, \"turbo:submit-end\", this.#onSubmitEnd);\n * }\n *\n * disconnect(): void {\n * this.#listeners.dispose();\n * }\n * ```\n */\nexport class ListenerSet {\n /** The generation every `add` joins until the next `dispose()`. */\n #abort = new AbortController();\n\n /**\n * Attaches `handler` to the open generation, exactly as the caller spelled it.\n *\n * The set supplies the signal, so `options` carries everything else the DOM\n * accepts — `capture` included. A removal by hand would have to repeat that\n * flag; aborting the signal releases the listener without it.\n *\n * A `type` the target's own event map names types `handler` with that event,\n * as the target's `addEventListener` does, so a handler written for a\n * `KeyboardEvent` is passed as it is; any other `type` takes an\n * `EventListener`.\n */\n add<T extends EventTarget, K extends keyof EventMapOf<T> & string>(\n target: T,\n type: K,\n handler: (event: EventMapOf<T>[K]) => void,\n options?: ListenerOptions,\n ): void;\n add(target: EventTarget, type: string, handler: EventListener, options?: ListenerOptions): void;\n add(target: EventTarget, type: string, handler: EventListener, options?: ListenerOptions): void {\n target.addEventListener(type, handler, { ...options, signal: this.#abort.signal });\n }\n\n /**\n * Releases every listener of the open generation, synchronously, and opens the\n * next one. Idempotent, and safe before anything has been added.\n */\n dispose(): void {\n this.#abort.abort();\n this.#abort = new AbortController();\n }\n}\n","import { Controller } from \"@hotwired/stimulus\";\nimport { AttributeLease } from \"../utils/attribute_lease\";\nimport { CompositionTracker } from \"../utils/composition_tracker\";\nimport { ListenerSet } from \"../utils/listener_set\";\n\n/**\n * Headless, accessible inline-editing behavior.\n *\n * Markup contract (identifier: `stimeo--editable`):\n * <div data-controller=\"stimeo--editable\"\n * data-stimeo--editable-submit-on-blur-value=\"true\">\n * <button type=\"button\" aria-label=\"Edit title\"\n * data-stimeo--editable-target=\"display\"\n * data-action=\"click->stimeo--editable#edit\n * keydown->stimeo--editable#onDisplayKeydown\">Current title</button>\n * <input type=\"text\" aria-label=\"Title\" hidden\n * data-stimeo--editable-target=\"input\"\n * data-action=\"keydown->stimeo--editable#onKeydown\" />\n * </div>\n *\n * There is no dedicated APG pattern; this implements a display ⇄ edit toggle with\n * focus management and keyboard commit/cancel, leaning on native form-control\n * labeling (WCAG 1.3.1 / 4.1.2). The look is the consumer's CSS, keyed off\n * `data-mode`.\n *\n * Behavior provided:\n * - Activating the display element (`Enter`/`Space` via the `<button>`, or `F2`)\n * enters edit mode, focuses the input, and selects its text.\n * - `Enter` (single-line) or `Ctrl+Enter` / `Cmd+Enter` (multiline `<textarea>`)\n * saves; `Escape` cancels. Both return focus to the display element. Keys\n * pressed during an IME composition act on the composition, never the edit:\n * a conversion-cancelling `Escape` keeps editing and a conversion-confirming\n * `Enter` never saves (lifecycle-tracked, covering events that omit\n * `isComposing`).\n * - Losing focus while editing saves when `submitOnBlur` is true (the default),\n * honoring wherever focus moved. The departure is watched on the controller\n * element, so it is seen from wherever focus sat — the input, or a Save or\n * Cancel button beside it — and no per-control wiring is required. Focus\n * landing on another element inside this controller has not left the edit, so\n * it commits nothing. When `submitOnBlur` is false, editing is kept.\n * - `save()`, `cancel()`, and `revert()` are actions, so a pointer-only user\n * reaches every path a keyboard user does. `revert()` restores the value from\n * before the last save once, for a consumer whose server rejected it.\n * - Saving dispatches `stimeo--editable:change` with `{ value, previous }` only\n * when the value actually changed; cancelling dispatches\n * `stimeo--editable:cancel` with an empty `{}` detail.\n *\n * The value is whatever the display element declares. A `data-value` attribute\n * holds it when the element's text is a rendering of the value rather than the\n * value itself — a formatted date, a grouped number, an icon beside a label.\n * Without that attribute the trimmed text is the value, and it must then be a\n * string the editing control accepts: `<input type=\"date\">` keeps `2026-08-23`\n * but sanitizes `August 23, 2026` away to an empty string. Saving updates\n * whichever of the two carries the value, so a rendered display keeps its markup\n * and the consumer re-renders it from the `change` event.\n */\nexport class EditableController extends Controller<HTMLElement> {\n static override targets = [\"display\", \"input\"];\n static override values = {\n submitOnBlur: { type: Boolean, default: true },\n };\n static actions = [\"cancel\", \"edit\", \"onDisplayKeydown\", \"onKeydown\", \"revert\", \"save\"] as const;\n static events = [\"cancel\", \"change\"] as const;\n\n declare readonly displayTarget: HTMLElement;\n declare readonly displayTargets: HTMLElement[];\n declare readonly inputTarget: HTMLInputElement | HTMLTextAreaElement;\n declare readonly inputTargets: HTMLElement[];\n declare readonly hasDisplayTarget: boolean;\n declare readonly hasInputTarget: boolean;\n\n declare submitOnBlurValue: boolean;\n\n /** The value captured when edit mode began, used to detect real changes. */\n #previousValue = \"\";\n\n /**\n * The value the last save replaced, or `null` when there is nothing to undo.\n * Cleared on connect: a value from before a page restore is unrecoverable, so\n * `revert()` must not resurrect one.\n */\n #revertValue: string | null = null;\n\n /**\n * Owns IME lifecycle state for the edit surface, so a keydown that belongs to\n * a composition (cancel or confirm) is never treated as an edit command.\n */\n readonly #composition = new CompositionTracker();\n\n /** Owns the `hidden` written on both elements, so one that departs gets its own back. */\n readonly #hidden = new AttributeLease<HTMLElement>(\"hidden\", this.identifier);\n\n /** Whether `connect()` has run and `disconnect()` has not since. */\n #connected = false;\n\n /**\n * Watches focus leaving the editor from wherever it currently sits.\n *\n * `focusout` bubbles where `blur` does not, so one listener on the root sees\n * every departure — including one from a Save or Cancel button the consumer\n * placed beside the input. Binding the input alone would make the promise\n * \"saves wherever focus moved\" true only for focus that leaves the input\n * itself, and tabbing straight past an inner button would strand the editor\n * open.\n *\n * @stimeoRuntimeOnly `submitOnBlur` decides whether this one blur commits the edit.\n */\n readonly #onFocusOut = (event: FocusEvent): void => {\n // Entering edit mode hides the display element, and hiding the element that\n // holds focus reports a departure with nowhere to go. That hand-off is the\n // edit starting, not the user leaving it, and the input is focused moments\n // later in the same task. The display is hidden for the whole edit, so while\n // the page keeps `[hidden]` at `display: none` it cannot be the source of a\n // real departure from one.\n const from = event.target;\n if (this.hasDisplayTarget && from instanceof Node && this.displayTarget.contains(from)) return;\n // Focus reaching another element inside this controller has not left the\n // edit. Without this the commit would beat an inner button's own click —\n // and a Cancel button would save what it promises to discard.\n const next = event.relatedTarget;\n if (next instanceof Node && this.element.contains(next)) return;\n if (this.submitOnBlurValue) this.#commit(false);\n };\n\n /** The listeners of one connection, released together on `disconnect()`. */\n readonly #listeners = new ListenerSet();\n\n /** Establishes the initial display mode (display shown, input hidden). */\n override connect(): void {\n this.#connected = true;\n // The tracker is idempotent, so observing here and in the target callback\n // keeps IME tracking correct whichever of the two the framework runs first.\n if (this.hasInputTarget) this.#composition.observe(this.inputTarget);\n this.#listeners.add(this.element, \"focusout\", this.#onFocusOut);\n this.#revertValue = null;\n this.#setMode(\"display\");\n }\n\n /** Releases the composition and focus listeners so nothing outlives the element. */\n override disconnect(): void {\n this.#connected = false;\n this.#composition.disconnect();\n this.#listeners.dispose();\n }\n\n /** Tracks an input added initially or after connect (e.g. a Turbo swap). */\n inputTargetConnected(input: HTMLElement): void {\n this.#composition.observe(input);\n this.#applyMode();\n }\n\n /**\n * Removes the departing input's composition listeners, gives one that no longer\n * resolves its own `hidden` back, even after `disconnect()`, and while connected\n * re-derives the visibility of the input that stays.\n */\n inputTargetDisconnected(input: HTMLElement): void {\n this.#composition.unobserve(input);\n if (!this.inputTargets.includes(input)) this.#hidden.return(input);\n if (this.#connected) this.#applyMode();\n }\n\n /** Re-hides or re-shows a display element that arrived after the mode was set. */\n displayTargetConnected(): void {\n this.#applyMode();\n }\n\n /**\n * Gives a display element that no longer resolves its own `hidden` back, even after\n * `disconnect()`, and while connected re-hides or re-shows the one that stays.\n */\n displayTargetDisconnected(display: HTMLElement): void {\n if (!this.displayTargets.includes(display)) this.#hidden.return(display);\n if (this.#connected) this.#applyMode();\n }\n\n /** Enters edit mode: seeds the input from the declared value, focuses, selects. */\n edit(): void {\n if (this.#isEditing || !this.hasInputTarget || !this.hasDisplayTarget) return;\n this.#previousValue = this.#currentValue;\n this.inputTarget.value = this.#previousValue;\n this.#setMode(\"editing\");\n this.inputTarget.focus();\n this.inputTarget.select();\n }\n\n /** Commits the edit and returns focus to the display element. */\n save(): void {\n this.#commit(true);\n }\n\n /** Discards edits, returns to display mode, and dispatches `cancel`. */\n cancel(): void {\n if (!this.#isEditing) return;\n this.#setMode(\"display\");\n if (this.hasDisplayTarget) this.displayTarget.focus();\n this.dispatch(\"cancel\", { detail: {} });\n }\n\n /**\n * Puts back the value the last save replaced — for a consumer whose server\n * rejected it. Silent by design: a `change` here would re-enter the same\n * handler that asked for the undo. One save, one undo.\n */\n revert(): void {\n if (this.#revertValue === null || this.#isEditing) return;\n this.#writeValue(this.#revertValue);\n this.#revertValue = null;\n }\n\n /** Adds `F2` as an editing entry point alongside the button's native activation. */\n onDisplayKeydown(event: KeyboardEvent): void {\n if (event.key === \"F2\") {\n event.preventDefault();\n this.edit();\n }\n }\n\n /** Commits on `Enter` (or `Ctrl+Enter` when multiline) and cancels on `Escape`. */\n onKeydown(event: KeyboardEvent): void {\n // Keys fired during IME composition steer the composition (cancel a\n // conversion, confirm a candidate) and must never cancel or save the edit.\n if (this.#composition.isComposing(event)) return;\n if (event.key === \"Escape\") {\n // Leave a press an inner handler already owned.\n if (event.defaultPrevented) return;\n event.preventDefault();\n this.cancel();\n return;\n }\n if (event.key === \"Enter\") {\n // A descendant widget that already claimed the key (a completion popup\n // confirming its candidate) must not ALSO commit the edit — composition\n // depends on this yield. Kept separate from the Escape guard above, which\n // answers a different question: who owns an Escape press.\n if (event.defaultPrevented) return;\n // A bare Enter inserts a newline in a textarea; only Ctrl+Enter (or Cmd+Enter on\n // macOS, the platform-conventional commit chord) saves there.\n if (this.#isMultiline && !(event.ctrlKey || event.metaKey)) return;\n event.preventDefault();\n this.#commit(true);\n }\n }\n\n /**\n * Returns to display mode, storing the input's value and dispatching `change`\n * when it differs from where editing began.\n *\n * @param restoreFocus - Move focus back to the display element (explicit\n * commit) rather than honoring the user's new focus target (blur).\n */\n #commit(restoreFocus: boolean): void {\n if (!this.#isEditing || !this.hasInputTarget) return;\n // One normalization for all three consumers below, so the stored value, the\n // comparison, and the detail can never disagree about what was saved.\n const value = this.inputTarget.value.trim();\n const previous = this.#previousValue;\n this.#writeValue(value);\n this.#setMode(\"display\");\n if (restoreFocus && this.hasDisplayTarget) this.displayTarget.focus();\n if (value !== previous) {\n this.#revertValue = previous;\n this.dispatch(\"change\", { detail: { value, previous } });\n }\n }\n\n /** Stores `value` wherever the display element declares it. */\n #writeValue(value: string): void {\n if (!this.hasDisplayTarget) return;\n const display = this.displayTarget;\n // Text that renders the value is the consumer's to compose; overwriting it\n // with the raw value would destroy a rendering this controller cannot rebuild.\n if (display.hasAttribute(\"data-value\")) display.dataset.value = value;\n else display.textContent = value;\n }\n\n /** Derives both elements' visibility from the mode currently in the DOM. */\n #applyMode(): void {\n const editing = this.#isEditing;\n if (this.hasDisplayTarget) this.#hidden.write(this.displayTarget, editing ? \"\" : null);\n if (this.hasInputTarget) this.#hidden.write(this.inputTarget, editing ? null : \"\");\n }\n\n /** Records the mode, then brings both elements in line with it. */\n #setMode(mode: \"display\" | \"editing\"): void {\n this.element.dataset.mode = mode;\n this.#applyMode();\n }\n\n /** The value the display element declares, trimmed. */\n get #currentValue(): string {\n const display = this.displayTarget;\n return (display.dataset.value ?? display.textContent ?? \"\").trim();\n }\n\n /** Whether the editing control is a multi-line `<textarea>`. */\n get #isMultiline(): boolean {\n return this.inputTarget.tagName === \"TEXTAREA\";\n }\n\n /** Whether the controller is currently in edit mode. */\n get #isEditing(): boolean {\n return this.element.dataset.mode === \"editing\";\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/attribute_write.ts","../../src/utils/shared_registry.ts","../../src/utils/attribute_lease.ts","../../src/utils/composition_tracker.ts","../../src/utils/listener_set.ts","../../src/controllers/editable_controller.ts"],"names":["registry"],"mappings":";;AAaO,SAAS,qBAAA,CACd,OAAA,EACA,IAAA,EACA,KAAA,EACA,WAAA,EACS;AACT,EAAA,IAAI,OAAA,CAAQ,YAAA,CAAa,IAAI,CAAA,KAAM,OAAO,OAAO,KAAA;AAEjD,EAAA,IAAI,KAAA,KAAU,IAAA,EAAM,OAAA,CAAQ,eAAA,CAAgB,IAAI,CAAA;AAAA,OAC3C,OAAA,CAAQ,YAAA,CAAa,IAAA,EAAM,KAAK,CAAA;AACrC,EAAA,OAAO,IAAA;AACT;;ACIO,SAAS,cAAA,CAAiC,KAAa,MAAA,EAAoB;AAChF,EAAA,MAAM,MAAA,GAAS,MAAA,CAAO,GAAA,CAAI,GAAG,CAAA;AAC7B,EAAA,MAAM,KAAA,GAAQ,UAAA;AACd,EAAA,MAAM,QAAA,GAAW,MAAM,MAAM,CAAA;AAC7B,EAAA,IAAI,QAAA,KAAa,QAAW,OAAO,QAAA;AACnC,EAAA,MAAMA,YAAW,MAAA,EAAO;AACxB,EAAA,MAAA,CAAO,eAAe,UAAA,EAAY,MAAA,EAAQ,EAAE,KAAA,EAAOA,WAAU,CAAA;AAC7D,EAAA,OAAOA,SAAAA;AACT;;ACJA,IAAM,QAAA,GAAW,cAAA;AAAA,EACf,uCAAA;AAAA,EACA,OAA+B,EAAE,MAAA,kBAAQ,IAAI,SAAQ,EAAG,KAAA,kBAAO,IAAI,GAAA,EAAI,EAAE;AAC3E,CAAA;AAGA,SAAS,iBAAiB,KAAA,EAAwC;AAChE,EAAA,OAAO,KAAA,KAAU,IAAA,I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AAK,aAAA;AACrB,IAAA,OAAA,CAAQ,QAAQ,OAAA,CAAQ,KAAA,IAAS,OAAA,CAAQ,WAAA,IAAe,IAAI,IAAA,EAAK;AAAA,EACnE;AAAA,EAGA,IAAI,YAAA,GAAwB;AAC1B,IAAA,OAAO,IAAA,CAAK,YAAY,OAAA,KAAY,UAAA;AAAA,EACtC;AAAA,EAGA,IAAI,UAAA,GAAsB;AACxB,IAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,OAAA,CAAQ,IAAA,KAAS,SAAA;AAAA,EACvC;AACF","file":"editable_controller.js","sourcesContent":["/**\n * Reflects a serialized attribute value only when the current value differs.\n *\n * A same-value `setAttribute` still queues a mutation record for every observer, so an\n * unchanged value writes nothing.\n *\n * @param element - The element whose attribute is reflected.\n * @param name - The attribute name, using the non-namespaced DOM API.\n * @param value - The serialized value, or null to remove the attribute.\n * @param beforeWrite - Called only for a change, before the DOM mutation, so the\n * caller can record ownership or identify its own observer records.\n * @returns Whether an attribute was written or removed.\n */\nexport function setAttributeIfChanged(\n element: Element,\n name: string,\n value: string | null,\n beforeWrite?: () => void,\n): boolean {\n if (element.getAttribute(name) === value) return false;\n beforeWrite?.();\n if (value === null) element.removeAttribute(name);\n else element.setAttribute(name, value);\n return true;\n}\n","/**\n * One registry per page for every copy of the library.\n *\n * Each `stimeo-ui/controllers/*` file, and each opt-in entry, is built on its own and carries\n * its own copy of every utility it uses, so a page that imports controllers one by one, or one\n * of them next to the barrel, evaluates a utility several times. A registry that coordinates\n * instances of different controllers — the stacks of leased values, the loans of a\n * `tabindex`, the Escape layers, the focus traps — must not be split by that: a dialog inside\n * a drawer, or a character counter and a form field on one input, coordinate whichever files\n * they came from. So such a registry lives once on `globalThis`, under a `Symbol.for` key the\n * copies agree on, and the first copy to ask for it creates it.\n *\n * The key names the registry and the version of its shape\n * (`stimeo-ui.<utility>.registry.v<n>`). Copies whose registries have the same shape share\n * one; a release that changes the shape changes the version, so a copy of another release\n * keeps a registry of its own instead of reading entries it does not understand — the two\n * then coordinate within each release only. An entry another copy put in a registry is read\n * through its fields alone, never through `#private` members, which belong to the class of\n * the copy that created it.\n */\n\n/**\n * The registry stored under `key`, created by `create` on first use.\n *\n * @param key - `stimeo-ui.<utility>.registry.v<n>`: the version is that of the shape `create`\n * returns.\n * @param create - Builds the empty registry.\n */\nexport function sharedRegistry<T extends object>(key: string, create: () => T): T {\n const symbol = Symbol.for(key);\n const scope = globalThis as unknown as Record<symbol, T | undefined>;\n const existing = scope[symbol];\n if (existing !== undefined) return existing;\n const registry = create();\n Object.defineProperty(globalThis, symbol, { value: registry });\n return registry;\n}\n","import { setAttributeIfChanged } from \"./attribute_write\";\nimport { sharedRegistry } from \"./shared_registry\";\n\n/** What a lease's record says: the author's value, its last write, the leases beneath. */\ninterface AttributeLeaseRecord {\n readonly original: string | null;\n readonly written: string | null;\n /** Whether it hands back what the lease right beneath it wrote last. */\n readonly linked: boolean;\n /** The records of the other owners' leases beneath it, nearest first. */\n readonly beneath: readonly string[];\n}\n\n/** One lease's hold on one element's attribute, in the stack every lease of it shares. */\ninterface AttributeHold {\n /** The lease holding it; `null` for a hold read from a copy's record until its lease takes it. */\n lease: object | null;\n readonly record: string;\n written: string | null;\n /** What it hands back with nothing beneath it: the author's value. */\n readonly original: string | null;\n /** Whether it hands back what the hold beneath it wrote last instead. */\n linked: boolean;\n}\n\n/** The holds on each element by attribute, and every lease's record name by attribute. */\ninterface AttributeLeaseRegistry {\n readonly stacks: WeakMap<Element, Map<string, AttributeHold[]>>;\n readonly names: Map<string, Set<string>>;\n}\n\n/** Holds and record names coordinate across separately built package entries. */\nconst registry = sharedRegistry(\n \"stimeo-ui.attribute-lease.registry.v1\",\n (): AttributeLeaseRegistry => ({ stacks: new WeakMap(), names: new Map() }),\n);\n\n/** Whether a parsed record entry is an attribute value: a string, or `null` for absence. */\nfunction isAttributeValue(value: unknown): value is string | null {\n return value === null || typeof value === \"string\";\n}\n\n/**\n * Reads the record a lease left on `element`: the author's value, the value the lease wrote\n * last, whether it hands back the value beneath it (`false` before the names when it does not)\n * and the records beneath it. `undefined` when the record is missing or holds anything else.\n */\nfunction readLeaseRecord(element: Element, record: string): AttributeLeaseRecord | undefined {\n try {\n const parsed: unknown = JSON.parse(element.getAttribute(record) ?? \"null\");\n if (!Array.isArray(parsed)) return undefined;\n const [original, written, ...rest] = parsed as unknown[];\n const linked = rest[0] !== false;\n const beneath = linked ? rest : rest.slice(1);\n if (!beneath.every((under): under is string => typeof under === \"string\")) return undefined;\n return isAttributeValue(original) && isAttributeValue(written)\n ? { original, written, linked, beneath }\n : undefined;\n } catch {\n return undefined;\n }\n}\n\n/** The element's stack, seeded from complete ownership records once. */\nfunction attributeStack(element: Element, attribute: string): AttributeHold[] {\n const byAttribute = registry.stacks.get(element) ?? new Map<string, AttributeHold[]>();\n registry.stacks.set(element, byAttribute);\n const known = byAttribute.get(attribute);\n if (known) return known;\n const found: (AttributeLeaseRecord & { readonly record: string })[] = [];\n for (const record of registry.names.get(attribute) ?? []) {\n const read = readLeaseRecord(element, record);\n if (read) found.push({ ...read, record });\n }\n const depth = ({ beneath }: (typeof found)[number]) =>\n beneath.filter((name) => found.some((other) => other.record === name)).length;\n const stack = found\n .sort((one, other) => depth(one) - depth(other))\n .map(({ record, written, original, linked }, index) => ({\n lease: null,\n record,\n written,\n original,\n linked: linked && index > 0,\n }));\n byAttribute.set(attribute, stack);\n return stack;\n}\n\n/** The lease's live hold or the unclaimed hold described by its owner's record. */\nfunction findHold(\n stack: readonly AttributeHold[],\n lease: object,\n record: string,\n): AttributeHold | undefined {\n return (\n stack.find((held) => held.lease === lease) ??\n stack.find((held) => held.lease === null && held.record === record)\n );\n}\n\n/**\n * Inspects a derived writer's continuation without acquiring or returning a hold.\n * A covered hold may update beneath its cover. Without a hold, the expected authored\n * value is compared with the original beneath any temporary cover. The original\n * distinguishes an absent attribute from an empty one.\n */\nexport function readAttributeLease(\n element: Element,\n attribute: string,\n owner: string,\n lease: object,\n expected: string | null,\n): { readonly allowed: boolean; readonly original: string | null } {\n const stack = attributeStack(element, attribute);\n const hold = findHold(stack, lease, `data-${owner}-${attribute}-lease`);\n const current = element.getAttribute(attribute);\n const covering = [...stack].reverse().find((other) => other.written === current);\n const original = (hold ?? covering)?.original;\n const authored = original === undefined ? current : original;\n return {\n original: authored,\n allowed: hold\n ? current === hold.written ||\n stack.slice(stack.indexOf(hold) + 1).some((above) => above.written === current)\n : authored === expected,\n };\n}\n\n/**\n * The value `element`'s author wrote for `attribute`, as the record a lease of any owner leaves\n * on the element carries it; `undefined` while no lease leaves one, as when nothing has moved\n * the attribute off the author's value. A field a reveal turned from `password` into `text`\n * still reads `\"password\"` here.\n */\nexport function leasedAuthorValue(element: Element, attribute: string): string | null | undefined {\n const suffix = `-${attribute}-lease`;\n for (const name of element.getAttributeNames()) {\n if (!name.startsWith(\"data-\") || !name.endsWith(suffix)) continue;\n const record = readLeaseRecord(element, name);\n if (record) return record.original;\n }\n return undefined;\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 * **Every lease of an attribute shares one stack of holds per element**, whatever its owner\n * and whichever file of the package constructed it (the stacks are one per page): the holds\n * sit in the order their leases first wrote the element, each with the value it wrote last.\n * The element's value is the highest hold's that carries it, and the page's when none does.\n * A write reaches the element unless a hold above the writer carries the element's value: the\n * top hold always shows its writes, a hold beneath it shows nothing while a hold above keeps\n * its value on the element, and once the page has put a value there that no hold carries, the\n * next write of any hold replaces it. A return gives a value back only from the hold the\n * element's value is: the value the hold beneath it wrote last, or the author's once nothing\n * is beneath it; any other return only leaves the stack, and the page's value stays. Holds\n * that wrote the same value are told apart by the stack, never by the value: the higher one\n * keeps it. A first write over a top hold whose value the page has replaced takes the\n * element's value as the author's. Two instances of one controller on one element — an\n * element outside their scope — stack the same way.\n *\n * A **base lease** (`{ base: true }`) holds the element's own state rather than a value over\n * it — a form field's ARIA on its control is one — so its first write goes to the bottom of\n * the stack, beneath the leases of other owners already there: a temporary value another\n * owner leased stays shown and returns to the base lease's latest value.\n *\n * **The stack travels with the element.** While a hold shows a value other than the author's,\n * lies on another hold or is covered by one, the element carries its owner's record\n * `data-<owner>-<attribute>-lease`: JSON of the author's value and the value the hold wrote\n * last (each a string, or `null` for an absent attribute), `false` where the hold hands back\n * the author's value rather than the latest value of the hold beneath it, and the records of\n * every hold beneath it, nearest first. Returning the last lease of an owner removes its\n * record. A copy of the element — a page Turbo restores from its cache is one — therefore\n * carries the stack, and the first lease to touch the copy reads it back under the record\n * names of the leases constructed so far, which include every lease that wrote a record the\n * cache holds, and orders the holds by the records each one lists beneath it. Each lease takes\n * the hold its owner's record describes over in place. Complete records for distinct owners\n * preserve their order across a copy. The records describe holds by owner, not by instance:\n * one owner holding the element more than once leaves only its topmost hold's record, which\n * the first of its leases to write or return on the copy takes. Lower holds of that owner and\n * their positions are absent; mutually listed owners cannot express their full live order.\n * A hold that showed the author's value alone carries no record and is taken by its first\n * write on the copy. Missing or unreadable records also leave their holds unknown, so copying\n * the DOM does not promise identical decisions for every live stack. Without a record it can\n * read, a new stack takes the current value as the author's. A Turbo morph removes records\n * absent from the server HTML; existing holds remain in memory until their leases return.\n *\n * The lease has no lifecycle of its own, so it never subscribes to document events,\n * and nothing rewinds a live page before Turbo caches it: `turbo:before-cache` also\n * fires on pages that stay.\n */\nexport class AttributeLease<T extends Element = Element> {\n readonly #attribute: string;\n readonly #record: string;\n readonly #base: boolean;\n readonly #preserveAuthor: boolean;\n readonly #held = new Set<T>();\n\n /**\n * @param attribute - The attribute whose temporary values this lease owns.\n * @param owner - Names the record on the element; the controller's identifier.\n * @param options - `base`: written beneath the other owners' leases;\n * `preserveAuthor`: a new base hold keeps a current value that no hold carries as authored.\n */\n constructor(\n attribute: string,\n owner: string,\n options: { readonly base?: boolean; readonly preserveAuthor?: boolean } = {},\n ) {\n this.#attribute = attribute;\n this.#record = `data-${owner}-${attribute}-lease`;\n this.#base = options.base === true;\n this.#preserveAuthor = options.preserveAuthor === true;\n const names = registry.names;\n names.set(attribute, (names.get(attribute) ?? new Set<string>()).add(this.#record));\n }\n\n /** Writes or removes the leased attribute while preserving its authored value. */\n write(element: T, value: string | null): void {\n const stack = attributeStack(element, this.#attribute);\n const hold = this.#take(stack) ?? this.#acquire(element, stack);\n this.#held.add(element);\n const shows = !this.#covered(element, stack, hold);\n hold.written = value;\n this.#mark(element, stack);\n if (shows) this.#reflect(element, value);\n }\n\n /**\n * Returns one lease, also on a restored copy, to the value the hold beneath it wrote last or\n * the author's, without overwriting a value a consumer wrote since. Says whether there was a\n * lease to return: a hold this lease has, or the hold a copy's record describes while no live\n * lease of the owner has taken it — a copy of a page an earlier connection wrote carries one.\n */\n return(element: T): boolean {\n const held = this.#held.delete(element);\n const known = registry.stacks.get(element)?.has(this.#attribute);\n const stack =\n held || known || element.hasAttribute(this.#record)\n ? attributeStack(element, this.#attribute)\n : [];\n const hold = this.#take(stack);\n if (!hold) return false;\n const carries = element.getAttribute(this.#attribute) === hold.written;\n const owns = carries && !this.#covered(element, stack, hold);\n const index = stack.indexOf(hold);\n stack.splice(index, 1);\n const above = stack[index];\n if (above) above.linked &&= hold.linked;\n this.#mark(element, stack);\n if (!owns) return true;\n const below = hold.linked ? stack[index - 1] : undefined;\n this.#reflect(element, below ? below.written : hold.original);\n return true;\n }\n\n /** Returns every lease it holds, with the same ownership check as {@link return}. */\n returnAll(): void {\n for (const element of Array.from(this.#held)) this.return(element);\n }\n\n /** Its hold in `stack`, taking over one read from its record. */\n #take(stack: AttributeHold[]): AttributeHold | undefined {\n const hold = findHold(stack, this, this.#record);\n if (hold) hold.lease = this;\n return hold;\n }\n\n /** A new hold: on top, over the top hold while the element shows it; a base one at the bottom. */\n #acquire(element: T, stack: AttributeHold[]): AttributeHold {\n const current = element.getAttribute(this.#attribute);\n const top = stack.at(-1);\n const bottom = stack[0];\n const over = top?.written === current ? top : undefined;\n const from = this.#base\n ? this.#preserveAuthor && !stack.some((held) => held.written === current)\n ? undefined\n : bottom\n : over;\n const hold: AttributeHold = {\n lease: this,\n record: this.#record,\n written: current,\n original: from ? from.original : current,\n linked: !this.#base && over !== undefined,\n };\n if (this.#base && bottom) {\n bottom.linked = true;\n stack.unshift(hold);\n } else stack.push(hold);\n return hold;\n }\n\n /** Whether a hold above `hold` carries the element's value, which is then that hold's. */\n #covered(element: T, stack: readonly AttributeHold[], hold: AttributeHold): boolean {\n const current = element.getAttribute(this.#attribute);\n return stack.slice(stack.indexOf(hold) + 1).some((above) => above.written === current);\n }\n\n /** Leaves each owner's record of its topmost hold, or none where nothing needs one. */\n #mark(element: T, stack: readonly AttributeHold[]): void {\n const records = new Map<string, string | null>([[this.#record, null]]);\n stack.forEach((hold, index) => {\n const names = stack.slice(0, index).map((under) => under.record);\n const beneath = [...new Set(names.reverse())].filter((name) => name !== hold.record);\n const marker = hold.linked || beneath.length === 0 ? [] : [false];\n records.set(\n hold.record,\n hold.written === hold.original && beneath.length === 0 && index === stack.length - 1\n ? null\n : JSON.stringify([hold.original, hold.written, ...marker, ...beneath]),\n );\n });\n for (const [name, recorded] of records) {\n setAttributeIfChanged(element, name, recorded);\n }\n }\n\n /** Reflects only a real value transition, avoiding self-triggered mutation work. */\n #reflect(element: T, value: string | null): void {\n setAttributeIfChanged(element, this.#attribute, value);\n }\n}\n","/** Minimal event shape carrying the platform's per-event composition signal. */\nexport interface CompositionSignal {\n readonly isComposing?: boolean;\n}\n\n/** Minimal `input` shape needed to tell a composition echo from a fresh edit. */\nexport interface ConfirmedInputSignal {\n readonly target: EventTarget | null;\n readonly inputType?: string;\n}\n\n/**\n * The `inputType` values an engine reports on an `input` that belongs to a\n * composition rather than to an edit the user just made.\n */\nconst COMPOSITION_INPUT_TYPES = new Set([\n \"insertCompositionText\",\n \"insertFromComposition\",\n \"deleteCompositionText\",\n \"deleteByComposition\",\n]);\n\n/** Whether a platform input kind belongs to composition rather than ordinary editing. */\nexport function isCompositionInputType(inputType: string | undefined): boolean {\n return inputType !== undefined && COMPOSITION_INPUT_TYPES.has(inputType);\n}\n\n/** The cancelable notice Turbo dispatches before a morph writes one attribute. */\nconst BEFORE_MORPH_ATTRIBUTE = \"turbo:before-morph-attribute\";\n\n/** Hooks that keep component-specific work outside {@link CompositionTracker}. */\nexport interface CompositionTrackerOptions {\n /** Runs after lifecycle state is set for a `compositionstart` event. */\n readonly onStart?: (event: Event) => void;\n /** Runs after lifecycle state is cleared for a `compositionend` event. */\n readonly onEnd?: (event: Event) => void;\n /**\n * Runs once lifecycle state is cleared for a composition that ended without\n * `compositionend`, with the `element` it ran in. Nothing was confirmed: the\n * element holds what a write left (`inPlace` false), or still holds the text the\n * composition left, which the engine stopped composing (`inPlace` true) — text\n * typed against whatever the page declared while it ran.\n *\n * A hook applies the work the composition held back — and only that — at once,\n * keeping the caret where it was. The event that showed the end is then handled as\n * it would be with no composition: the text the element holds is read by whatever\n * reads it next, as the user's edit if an edit reads it. A consumer whose contract\n * judges what an interrupted conversion leaves may also settle that text here, as\n * `stimeo--otp` returns a residual its `pattern` rejects to the prior character: it reports\n * that as a reconciliation, never as the user's edit, and keeps the selection.\n *\n * When the tracker sees the end in an event it hears — a key, an edit, a focus\n * change, the next `compositionstart` — the hook runs there, in the capture phase,\n * ahead of that event's own handlers and of the edit it announces, whoever\n * dispatched it. When a question ({@link CompositionTracker.isComposing},\n * {@link CompositionTracker.composingElement}) or a Turbo morph's notice for one\n * attribute shows the end, the hook runs in a microtask after them, never inside\n * its caller or a half-applied morph, unless an event the tracker hears comes\n * first. On `compositionstart` it runs after the new composition is set and before\n * `onStart`: {@link CompositionTracker.isComposing} is true again, so work held for\n * the old composition stays held for the new.\n */\n readonly onAbandon?: (element: EventTarget, inPlace: boolean) => void;\n}\n\n/** One composition in progress. */\ninterface Composition {\n /** The observed target the composition was heard on. */\n readonly target: EventTarget;\n /** The element composing: the observed field itself, or a field inside an observed ancestor. */\n readonly element: EventTarget;\n /** The value the composition last left in the element; `undefined` for an element with none. */\n text: unknown;\n}\n\n/**\n * The element's live value; `undefined` for an element without one, which a write never\n * changes.\n */\nconst textOf = (element: EventTarget): unknown => (element as { value?: unknown }).value;\n\n/** Whether `element` is the focused element of the document or shadow root it is in. */\nconst holdsFocus = (element: EventTarget): boolean =>\n element instanceof Node &&\n (element.getRootNode() as Partial<DocumentOrShadowRoot>).activeElement === element;\n\n/**\n * Owns IME composition listeners and transient state for one or more event targets.\n *\n * Some browsers omit `KeyboardEvent.isComposing` on the keydown that confirms a\n * conversion. Tracking `compositionstart` through `compositionend` supplies the\n * missing lifecycle signal without relying on deprecated numeric key codes.\n * Component policy stays with the consumer: filtering, validation, and submission\n * belong in the optional {@link CompositionTrackerOptions.onEnd} callback.\n *\n * The tracker also owns the other half of that lifecycle: **the `input` some\n * engines send after `compositionend` to echo the text just confirmed.** A\n * consumer that ran `onEnd` and then handled the echo would commit the same\n * confirmation twice, so {@link CompositionTracker.consumesConfirmedInput} tells\n * the echo apart and the consumer returns early on it.\n *\n * **What the echo is not, is the harder half.** Not every engine sends one —\n * Chromium ends a confirmation at `compositionend` with no `input` after it — so\n * a window that waits for the echo and only closes on the next key would swallow\n * the first edit that arrives without one: dictation, autofill, a drop,\n * `insertText`. Two things keep that from happening. The window closes on the\n * next anything — a key, a new composition, any `input`, losing the field — and\n * an `input` that reports an `inputType` outside {@link COMPOSITION_INPUT_TYPES}\n * is an edit, so it is never folded. Only an engine that reports no `inputType`\n * at all is left relying on the window alone.\n *\n * **A composition can also end without `compositionend`.** Chromium drops the\n * conversion silently when something other than the IME writes a different value\n * into its field — a Turbo morph, a form reset, a script — and when the field\n * moves or leaves the page, leaving the text it composed. The tracker reads the end\n * from what the engine and the field still say:\n *\n * - **The field holds other text than the composition left.** The IME's edits, and\n * the user's own between them, arrive as an `input` the engine dispatched\n * (`isTrusted`) or one that reports the composition, and the tracker takes the\n * field's text from those. A write by anything else changes the text with no such\n * `input` — at most a synthetic one — so the composition is over, ended with\n * {@link CompositionTrackerOptions.onAbandon}, before anyone acts on the field.\n * Writing the same text keeps the conversion, and the match.\n * - **The engine edits outside a composition.** A `beforeinput` reporting\n * `isComposing: false` with an `inputType` outside {@link COMPOSITION_INPUT_TYPES}\n * is an edit the engine no longer counts as composition — unless the `keydown`\n * right before it reported `isComposing: true`: a key the IME lets through, such\n * as Backspace, edits the field while the conversion goes on. This is what shows\n * a composition that ended with its text in place. Only one field composes at a\n * time, so such an edit on any observed target ends the composition held, with\n * `onAbandon`. A `keydown` can hold this back but never starts it: the keydown\n * that confirms a conversion may carry no `isComposing`, and dictation and\n * autofill edit with no key at all.\n * - **The field stays where it was heard.** A field the consumer observes itself is\n * the consumer's to release when it moves or leaves, which reads what it holds;\n * one that keeps focus through the move keeps composing\n * ({@link CompositionTracker.disconnect}). A field inside an observed ancestor\n * that leaves the ancestor, or loses focus within its document, ends its\n * composition quietly; one that stays the document's active element — the window\n * lost focus — keeps composing.\n * - **No other field composes**: a `compositionstart` ends any composition the\n * tracker still holds, with `onAbandon`, before the new one starts.\n *\n * The tracker checks this before it answers {@link CompositionTracker.isComposing}\n * or {@link CompositionTracker.composingElement}, and at every key, edit, blur,\n * `compositionstart` and morph it hears — keys, edits and blurs in the capture\n * phase, ahead of the consumer's own handlers. While\n * a composition is live, a Turbo morph leaves its field's value alone: Idiomorph\n * asks through `turbo:before-morph-attribute` before it writes `value`, as an\n * attribute or as the live text, and the tracker cancels that one notice for the\n * element composing, so the morph keeps the conversion, as it keeps focus. Every\n * other attribute, and every other element, still morphs.\n *\n * A consumer that observes several fields tells the conversion's own events from\n * edits in the other fields with {@link CompositionTracker.owns}, which holds even\n * while the tracker keeps a composition whose end no event has shown yet.\n *\n * @example\n * ```ts\n * #composition = new CompositionTracker({ onEnd: () => this.filter() });\n *\n * connect(): void {\n * this.#composition.observe(this.inputTarget);\n * }\n *\n * disconnect(): void {\n * this.#composition.disconnect();\n * }\n *\n * onInput(event: InputEvent): void {\n * if (this.#composition.consumesConfirmedInput(event)) return;\n * if (this.#composition.isComposing(event)) return;\n * }\n *\n * onKeydown(event: KeyboardEvent): void {\n * if (this.#composition.isComposing(event)) return;\n * }\n * ```\n */\nexport class CompositionTracker {\n readonly #observedTargets = new Set<EventTarget>();\n /** The composition in progress, if any: only one field composes at a time. */\n #composition: Composition | null = null;\n readonly #onStart: ((event: Event) => void) | undefined;\n readonly #onEnd: ((event: Event) => void) | undefined;\n readonly #onAbandon: ((element: EventTarget, inPlace: boolean) => void) | undefined;\n /** The field whose confirming `input` is still owed, while the window is open. */\n #confirmedTarget: EventTarget | null = null;\n /**\n * Whether the last `keydown` reported a composition, until the `beforeinput`\n * after it: the edit that key announces lands inside the composition.\n */\n #keyComposing = false;\n /** Whether the consumer is connected: from `observe()` until `disconnect()`. */\n #connected = false;\n /** A composition that ended without `compositionend` and whose `onAbandon` has not run yet. */\n #abandoned: { readonly element: EventTarget; readonly inPlace: boolean } | null = null;\n\n constructor(options: CompositionTrackerOptions = {}) {\n this.#onStart = options.onStart;\n this.#onEnd = options.onEnd;\n this.#onAbandon = options.onAbandon;\n }\n\n /**\n * Starts lifecycle tracking for `target`; repeated calls are idempotent. The\n * targets one tracker observes do not contain one another: a composition event\n * reaching two of them would be counted as two.\n */\n observe(target: EventTarget): void {\n this.#connected = true;\n if (this.#observedTargets.has(target)) return;\n target.addEventListener(\"compositionstart\", this.#handleStart);\n target.addEventListener(\"compositionend\", this.#handleEnd);\n target.addEventListener(\"keydown\", this.#handleKeydown, true);\n target.addEventListener(\"beforeinput\", this.#handleBeforeInput, true);\n target.addEventListener(\"input\", this.#handleInput, true);\n target.addEventListener(\"blur\", this.#handleBlur, true);\n target.addEventListener(BEFORE_MORPH_ATTRIBUTE, this.#handleBeforeMorphAttribute);\n this.#observedTargets.add(target);\n }\n\n /**\n * Stops tracking one target. A composition it held ends quietly, unless its element\n * still holds focus — see {@link CompositionTracker.disconnect}.\n */\n unobserve(target: EventTarget): void {\n if (!this.#observedTargets.delete(target)) return;\n this.#release(target);\n if (this.#composition?.target === target) this.#letGo();\n if (this.#confirmedTarget === target) this.#confirmedTarget = null;\n }\n\n /**\n * Releases every listener and clears state so reconnect starts cleanly.\n *\n * A composition whose element still holds focus is the exception. A move that\n * keeps focus — `moveBefore`, which Turbo's morph uses where the browser provides\n * it — can leave the conversion running, and Stimulus releases the moved target, or\n * the controller around it, and observes it again within the one mutation batch. So\n * the composition waits for its target to be observed again before the turn ends,\n * and goes on; otherwise it ends then — quietly once disconnected, and with\n * {@link CompositionTrackerOptions.onAbandon} for a consumer that only let that one\n * target go. A move without `moveBefore`, or a removal, takes focus away.\n */\n disconnect(): void {\n this.#connected = false;\n for (const target of this.#observedTargets) this.#release(target);\n this.#observedTargets.clear();\n this.#letGo();\n this.#confirmedTarget = null;\n this.#keyComposing = false;\n this.#abandoned = null;\n }\n\n /**\n * True when a composition is live or the current event reports one. A\n * composition that ended without `compositionend` ends here first.\n */\n isComposing(event?: CompositionSignal): boolean {\n this.#settle();\n return event?.isComposing === true || this.#composition !== null;\n }\n\n /**\n * The element a live composition is running in, or `null`. A composition that\n * ended without `compositionend` ends here first.\n */\n composingElement(): EventTarget | null {\n this.#settle();\n return this.#composition?.element ?? null;\n }\n\n /**\n * Whether `event` belongs to a composition: it reports one, or it is in the element a\n * live composition runs in. An event in another element — a key there, or a script's\n * write reported with a bare `input` — is an edit outside the composition, even while\n * the tracker holds one whose end it has not seen: only one element composes at a\n * time, and the IME edits nothing else. The composition held stays, since such an\n * event does not show its end. A consumer that observes several fields asks this of\n * each event; {@link CompositionTracker.isComposing} asks of the targets as a whole.\n * A composition that ended without `compositionend` ends here first.\n */\n owns(event: CompositionSignal & { readonly target: EventTarget | null }): boolean {\n const element = this.composingElement();\n return event.isComposing === true || (element !== null && element === event.target);\n }\n\n /**\n * Whether `event` is the `input` echoing the composition just confirmed.\n *\n * Asking closes the window either way, so one confirmation is folded at most\n * once and a consumer asks once per `input`.\n */\n consumesConfirmedInput(event: ConfirmedInputSignal): boolean {\n const confirmed = this.#confirmedTarget;\n this.#confirmedTarget = null;\n if (confirmed === null || confirmed !== event.target) return false;\n // An engine that reports no kind at all leaves `inputType` empty, and the\n // window is then the only signal there is.\n const inputType = event.inputType;\n return !inputType || isCompositionInputType(inputType);\n }\n\n /** Removes every listener {@link CompositionTracker.observe} added to `target`. */\n #release(target: EventTarget): void {\n target.removeEventListener(\"compositionstart\", this.#handleStart);\n target.removeEventListener(\"compositionend\", this.#handleEnd);\n target.removeEventListener(\"keydown\", this.#handleKeydown, true);\n target.removeEventListener(\"beforeinput\", this.#handleBeforeInput, true);\n target.removeEventListener(\"input\", this.#handleInput, true);\n target.removeEventListener(\"blur\", this.#handleBlur, true);\n target.removeEventListener(BEFORE_MORPH_ATTRIBUTE, this.#handleBeforeMorphAttribute);\n }\n\n /**\n * Lets go of the composition held once its target is no longer observed: it is over\n * unless its element kept focus and its target is observed again this turn.\n */\n #letGo(): void {\n const composition = this.#composition;\n if (composition === null) return;\n if (!holdsFocus(composition.element)) {\n this.#composition = null;\n return;\n }\n queueMicrotask(() => {\n if (this.#composition !== composition || this.#observedTargets.has(composition.target)) {\n return;\n }\n this.#composition = null;\n if (!this.#connected) return;\n this.#abandoned = { element: composition.element, inPlace: true };\n this.#runAbandon();\n });\n }\n\n /**\n * Ends the composition held if its field left the observed target, taking the\n * composition's text along, or holds text a write left.\n */\n #settle(): void {\n const composition = this.#composition;\n if (composition === null) return;\n const { target, element, text } = composition;\n if (target instanceof Node && element instanceof Node && !target.contains(element)) {\n this.#composition = null;\n } else if (textOf(element) !== text) {\n this.#abandon(false);\n }\n }\n\n /**\n * Ends the composition held, unconfirmed. Its `onAbandon` runs in a microtask,\n * unless an event the tracker hears runs it first.\n */\n #abandon(inPlace: boolean): void {\n this.#owe(inPlace);\n this.#composition = null;\n queueMicrotask(this.#runAbandon);\n }\n\n /** Records the `onAbandon` the composition held owes. */\n #owe(inPlace: boolean): void {\n const composition = this.#composition;\n if (composition !== null) this.#abandoned = { element: composition.element, inPlace };\n }\n\n /** Runs the `onAbandon` an ended composition owes, once. */\n readonly #runAbandon = (): void => {\n const abandoned = this.#abandoned;\n if (abandoned === null) return;\n this.#abandoned = null;\n this.#onAbandon?.(abandoned.element, abandoned.inPlace);\n };\n\n /** A composition starting while one is held ends the held one, unconfirmed. */\n readonly #handleStart = (event: Event): void => {\n this.#confirmedTarget = null;\n this.#settle();\n this.#owe(true);\n // A listener runs while the event is dispatched, so both targets are set.\n const target = event.currentTarget as EventTarget;\n const element = event.target as EventTarget;\n this.#composition = { target, element, text: textOf(element) };\n this.#runAbandon();\n this.#onStart?.(event);\n };\n\n readonly #handleEnd = (event: Event): void => {\n this.#runAbandon();\n if (this.#composition?.target === event.currentTarget) this.#composition = null;\n this.#confirmedTarget = event.target;\n this.#onEnd?.(event);\n };\n\n /**\n * A key on an observed field opens an edit of its own, so no echo is owed; it\n * also says whether the edit it announces lands inside a composition.\n */\n readonly #handleKeydown = (event: Event): void => {\n this.#settle();\n this.#runAbandon();\n this.#confirmedTarget = null;\n this.#keyComposing = (event as KeyboardEvent).isComposing === true;\n };\n\n /** An edit is about to land: a composition the engine no longer runs ends first. */\n readonly #handleBeforeInput = (event: Event): void => {\n const keyComposing = this.#keyComposing;\n this.#keyComposing = false;\n this.#settle();\n const { isComposing, inputType } = event as InputEvent;\n if (\n this.#composition !== null &&\n !keyComposing &&\n !isComposing &&\n inputType &&\n !isCompositionInputType(inputType)\n ) {\n this.#abandon(true);\n }\n this.#runAbandon();\n };\n\n /**\n * Takes the composing field's text from an `input` the engine dispatched or one\n * that reports the composition; any other `input` follows a write the\n * composition did not make.\n */\n readonly #handleInput = (event: Event): void => {\n const composition = this.#composition;\n const { isTrusted, isComposing, inputType } = event as InputEvent;\n if (\n composition !== null &&\n event.target === composition.element &&\n (isTrusted || isComposing || isCompositionInputType(inputType))\n ) {\n composition.text = textOf(composition.element);\n } else {\n this.#settle();\n }\n this.#runAbandon();\n };\n\n /**\n * Checks the composition as a field loses focus, ahead of the consumer's own blur\n * handlers. A field inside an observed ancestor that loses focus within its\n * document keeps its text and composes no more.\n */\n readonly #handleBlur = (event: Event): void => {\n this.#settle();\n this.#runAbandon();\n const composition = this.#composition;\n if (composition === null || composition.target === composition.element) return;\n const { element } = composition;\n if (!(element instanceof Node) || event.target !== element) return;\n const root = element.getRootNode() as Document | ShadowRoot;\n if (root.activeElement !== element) this.#composition = null;\n };\n\n /** Keeps a Turbo morph from writing the value of the element composing. */\n readonly #handleBeforeMorphAttribute = (event: Event): void => {\n this.#settle();\n const composition = this.#composition;\n if (composition?.target !== event.currentTarget || event.target !== composition.element) return;\n const detail: { readonly attributeName?: unknown } | null = (event as CustomEvent).detail;\n if (detail?.attributeName === \"value\") event.preventDefault();\n };\n}\n","/** What {@link ListenerSet.add} passes on besides the signal it supplies itself. */\nexport type ListenerOptions = Omit<AddEventListenerOptions, \"signal\">;\n\n/**\n * The event map a target's own `addEventListener` types its handlers with: the\n * window's, a document's, an HTML or SVG element's, any other element's, or a\n * media query list's. Other targets name none.\n */\ntype EventMapOf<T extends EventTarget> = T extends Window\n ? WindowEventMap\n : T extends Document\n ? DocumentEventMap\n : T extends HTMLElement\n ? HTMLElementEventMap\n : T extends SVGElement\n ? SVGElementEventMap\n : T extends Element\n ? ElementEventMap\n : T extends MediaQueryList\n ? MediaQueryListEventMap\n : Record<never, never>;\n\n/**\n * Owns every listener a controller attaches for one connected lifetime and\n * releases them together, so an event name is spelled once and the release\n * cannot drift from the registration.\n *\n * Detaching by hand repeats three things at the release site — the type, the\n * handler reference and the capture flag — and any one of them drifting leaves\n * a listener alive on an element the controller no longer drives. Aborting the\n * signal a registration was created with releases it whatever it was made of,\n * so the release site names nothing.\n *\n * One set per lifetime, held as a field and never rebuilt.\n * {@link ListenerSet.dispose} is the only thing that closes a generation, and it opens\n * the next one in the same step, so the lifecycle hooks can call `add` and\n * `dispose` in any order any number of times, and no `add` ever meets an\n * already aborted signal — a DOM that registers a listener on such a signal\n * would keep it forever. Rebuilding the set instead would leak:\n * `addEventListener` matches an existing registration on target, type, callback\n * and capture alone, so re-adding the same handler while the first registration\n * is live is discarded, and that live registration keeps the signal it was\n * attached with — a set built by a second `connect()` can never release what it\n * appears to own.\n *\n * Scope is the registration only. Timers, observers, leases and the order they\n * are unwound in stay with the controller, which places `dispose()` in its\n * cleanup sequence. A receiver that changes at runtime (a\n * swapped target) is rebound by calling `dispose()` and then `add()` again from\n * the rebind, not by a second set.\n *\n * A lifetime shorter than the connection — while a Value holds, until a first\n * load, while a subscription is open — gets a set of its own, which the end of\n * that lifetime disposes. A controller therefore holds one set per lifetime: the\n * connection's, and one for each swapped receiver or shorter span.\n *\n * The set must own every registration of a tuple it holds: a listener the same\n * target already carries for the same type, callback and capture flag keeps the\n * right to remove it, and this set's `add` for that tuple is discarded. A\n * subscription shared between instances behind a participant count, listeners of\n * several elements that come and go one at a time, and those one gesture holds\n * keep their own pair of calls or a signal of their own.\n *\n * @example\n * ```ts\n * readonly #listeners = new ListenerSet();\n *\n * connect(): void {\n * this.#listeners.add(this.element, \"submit\", this.#onNativeSubmit, { capture: true });\n * this.#listeners.add(this.element, \"turbo:submit-start\", this.#onSubmitStart);\n * this.#listeners.add(this.element, \"turbo:submit-end\", this.#onSubmitEnd);\n * }\n *\n * disconnect(): void {\n * this.#listeners.dispose();\n * }\n * ```\n */\nexport class ListenerSet {\n /** The generation every `add` joins until the next `dispose()`. */\n #abort = new AbortController();\n\n /**\n * Attaches `handler` to the open generation, exactly as the caller spelled it.\n *\n * The set supplies the signal, so `options` carries everything else the DOM\n * accepts — `capture` included. A removal by hand would have to repeat that\n * flag; aborting the signal releases the listener without it.\n *\n * A `type` the target's own event map names types `handler` with that event,\n * as the target's `addEventListener` does, so a handler written for a\n * `KeyboardEvent` is passed as it is; any other `type` takes an\n * `EventListener`.\n */\n add<T extends EventTarget, K extends keyof EventMapOf<T> & string>(\n target: T,\n type: K,\n handler: (event: EventMapOf<T>[K]) => void,\n options?: ListenerOptions,\n ): void;\n add(target: EventTarget, type: string, handler: EventListener, options?: ListenerOptions): void;\n add(target: EventTarget, type: string, handler: EventListener, options?: ListenerOptions): void {\n target.addEventListener(type, handler, { ...options, signal: this.#abort.signal });\n }\n\n /**\n * Releases every listener of the open generation, synchronously, and opens the\n * next one. Idempotent, and safe before anything has been added.\n */\n dispose(): void {\n this.#abort.abort();\n this.#abort = new AbortController();\n }\n}\n","import { Controller } from \"@hotwired/stimulus\";\nimport { AttributeLease } from \"../utils/attribute_lease\";\nimport { CompositionTracker } from \"../utils/composition_tracker\";\nimport { ListenerSet } from \"../utils/listener_set\";\n\n/**\n * Headless, accessible inline-editing behavior.\n *\n * Markup contract (identifier: `stimeo--editable`):\n * <div data-controller=\"stimeo--editable\"\n * data-stimeo--editable-submit-on-blur-value=\"true\">\n * <button type=\"button\" aria-label=\"Edit title\"\n * data-stimeo--editable-target=\"display\"\n * data-action=\"click->stimeo--editable#edit\n * keydown->stimeo--editable#onDisplayKeydown\">Current title</button>\n * <input type=\"text\" aria-label=\"Title\" hidden\n * data-stimeo--editable-target=\"input\"\n * data-action=\"keydown->stimeo--editable#onKeydown\" />\n * </div>\n *\n * There is no dedicated APG pattern; this implements a display ⇄ edit toggle with\n * focus management and keyboard commit/cancel, leaning on native form-control\n * labeling (WCAG 1.3.1 / 4.1.2). The look is the consumer's CSS, keyed off\n * `data-mode`.\n *\n * Behavior provided:\n * - Activating the display element (`Enter`/`Space` via the `<button>`, or `F2`)\n * enters edit mode, focuses the input, and selects its text.\n * - `Enter` (single-line) or `Ctrl+Enter` / `Cmd+Enter` (multiline `<textarea>`)\n * saves; `Escape` cancels. Both return focus to the display element. Keys\n * pressed during an IME composition act on the composition, never the edit:\n * a conversion-cancelling `Escape` keeps editing and a conversion-confirming\n * `Enter` never saves (lifecycle-tracked, covering events that omit\n * `isComposing`).\n * - Losing focus while editing saves when `submitOnBlur` is true (the default),\n * honoring wherever focus moved. The departure is watched on the controller\n * element, so it is seen from wherever focus sat — the input, or a Save or\n * Cancel button beside it — and no per-control wiring is required. Focus\n * landing on another element inside this controller has not left the edit, so\n * it commits nothing. When `submitOnBlur` is false, editing is kept.\n * - `save()`, `cancel()`, and `revert()` are actions, so a pointer-only user\n * reaches every path a keyboard user does. `revert()` restores the value from\n * before the last save once, for a consumer whose server rejected it.\n * - Saving dispatches `stimeo--editable:change` with `{ value, previous }` only\n * when the value actually changed; cancelling dispatches\n * `stimeo--editable:cancel` with an empty `{}` detail.\n *\n * The value is whatever the display element declares. A `data-value` attribute\n * holds it when the element's text is a rendering of the value rather than the\n * value itself — a formatted date, a grouped number, an icon beside a label.\n * Without that attribute the trimmed text is the value, and it must then be a\n * string the editing control accepts: `<input type=\"date\">` keeps `2026-08-23`\n * but sanitizes `August 23, 2026` away to an empty string. Saving updates\n * whichever of the two carries the value, so a rendered display keeps its markup\n * and the consumer re-renders it from the `change` event.\n */\nexport class EditableController extends Controller<HTMLElement> {\n static override targets = [\"display\", \"input\"];\n static override values = {\n submitOnBlur: { type: Boolean, default: true },\n };\n static actions = [\"cancel\", \"edit\", \"onDisplayKeydown\", \"onKeydown\", \"revert\", \"save\"] as const;\n static events = [\"cancel\", \"change\"] as const;\n\n declare readonly displayTarget: HTMLElement;\n declare readonly displayTargets: HTMLElement[];\n declare readonly inputTarget: HTMLInputElement | HTMLTextAreaElement;\n declare readonly inputTargets: HTMLElement[];\n declare readonly hasDisplayTarget: boolean;\n declare readonly hasInputTarget: boolean;\n\n declare submitOnBlurValue: boolean;\n\n /** The value captured when edit mode began, used to detect real changes. */\n #previousValue = \"\";\n\n /**\n * The value the last save replaced, or `null` when there is nothing to undo.\n * Cleared on connect: a value from before a page restore is unrecoverable, so\n * `revert()` must not resurrect one.\n */\n #revertValue: string | null = null;\n\n /**\n * Owns IME lifecycle state for the edit surface, so a keydown that belongs to\n * a composition (cancel or confirm) is never treated as an edit command.\n */\n readonly #composition = new CompositionTracker();\n\n /** Owns the `hidden` written on both elements, so one that departs gets its own back. */\n readonly #hidden = new AttributeLease<HTMLElement>(\"hidden\", this.identifier);\n\n /** Whether `connect()` has run and `disconnect()` has not since. */\n #connected = false;\n\n /**\n * Watches focus leaving the editor from wherever it currently sits.\n *\n * `focusout` bubbles where `blur` does not, so one listener on the root sees\n * every departure — including one from a Save or Cancel button the consumer\n * placed beside the input. Binding the input alone would make the promise\n * \"saves wherever focus moved\" true only for focus that leaves the input\n * itself, and tabbing straight past an inner button would strand the editor\n * open.\n *\n * @stimeoRuntimeOnly `submitOnBlur` decides whether this one blur commits the edit.\n */\n readonly #onFocusOut = (event: FocusEvent): void => {\n // Entering edit mode hides the display element, and hiding the element that\n // holds focus reports a departure with nowhere to go. That hand-off is the\n // edit starting, not the user leaving it, and the input is focused moments\n // later in the same task. The display is hidden for the whole edit, so while\n // the page keeps `[hidden]` at `display: none` it cannot be the source of a\n // real departure from one.\n const from = event.target;\n if (this.hasDisplayTarget && from instanceof Node && this.displayTarget.contains(from)) return;\n // Focus reaching another element inside this controller has not left the\n // edit. Without this the commit would beat an inner button's own click —\n // and a Cancel button would save what it promises to discard.\n const next = event.relatedTarget;\n if (next instanceof Node && this.element.contains(next)) return;\n if (this.submitOnBlurValue) this.#commit(false);\n };\n\n /** The listeners of one connection, released together on `disconnect()`. */\n readonly #listeners = new ListenerSet();\n\n /** Establishes the initial display mode (display shown, input hidden). */\n override connect(): void {\n this.#connected = true;\n // The tracker is idempotent, so observing here and in the target callback\n // keeps IME tracking correct whichever of the two the framework runs first.\n if (this.hasInputTarget) this.#composition.observe(this.inputTarget);\n this.#listeners.add(this.element, \"focusout\", this.#onFocusOut);\n this.#revertValue = null;\n this.#setMode(\"display\");\n }\n\n /** Releases the composition and focus listeners so nothing outlives the element. */\n override disconnect(): void {\n this.#connected = false;\n this.#composition.disconnect();\n this.#listeners.dispose();\n }\n\n /** Tracks an input added initially or after connect (e.g. a Turbo swap). */\n inputTargetConnected(input: HTMLElement): void {\n this.#composition.observe(input);\n this.#applyMode();\n }\n\n /**\n * Removes the departing input's composition listeners, gives one that no longer\n * resolves its own `hidden` back, even after `disconnect()`, and while connected\n * re-derives the visibility of the input that stays.\n */\n inputTargetDisconnected(input: HTMLElement): void {\n this.#composition.unobserve(input);\n if (!this.inputTargets.includes(input)) this.#hidden.return(input);\n if (this.#connected) this.#applyMode();\n }\n\n /** Re-hides or re-shows a display element that arrived after the mode was set. */\n displayTargetConnected(): void {\n this.#applyMode();\n }\n\n /**\n * Gives a display element that no longer resolves its own `hidden` back, even after\n * `disconnect()`, and while connected re-hides or re-shows the one that stays.\n */\n displayTargetDisconnected(display: HTMLElement): void {\n if (!this.displayTargets.includes(display)) this.#hidden.return(display);\n if (this.#connected) this.#applyMode();\n }\n\n /** Enters edit mode: seeds the input from the declared value, focuses, selects. */\n edit(): void {\n if (this.#isEditing || !this.hasInputTarget || !this.hasDisplayTarget) return;\n this.#previousValue = this.#currentValue;\n this.inputTarget.value = this.#previousValue;\n this.#setMode(\"editing\");\n this.inputTarget.focus();\n this.inputTarget.select();\n }\n\n /** Commits the edit and returns focus to the display element. */\n save(): void {\n this.#commit(true);\n }\n\n /** Discards edits, returns to display mode, and dispatches `cancel`. */\n cancel(): void {\n if (!this.#isEditing) return;\n this.#setMode(\"display\");\n if (this.hasDisplayTarget) this.displayTarget.focus();\n this.dispatch(\"cancel\", { detail: {} });\n }\n\n /**\n * Puts back the value the last save replaced — for a consumer whose server\n * rejected it. Silent by design: a `change` here would re-enter the same\n * handler that asked for the undo. One save, one undo.\n */\n revert(): void {\n if (this.#revertValue === null || this.#isEditing) return;\n this.#writeValue(this.#revertValue);\n this.#revertValue = null;\n }\n\n /** Adds `F2` as an editing entry point alongside the button's native activation. */\n onDisplayKeydown(event: KeyboardEvent): void {\n if (event.defaultPrevented) return;\n if (event.key === \"F2\") {\n event.preventDefault();\n this.edit();\n }\n }\n\n /** Commits on `Enter` (or `Ctrl+Enter` when multiline) and cancels on `Escape`. */\n onKeydown(event: KeyboardEvent): void {\n // Keys fired during IME composition steer the composition (cancel a\n // conversion, confirm a candidate) and must never cancel or save the edit.\n if (this.#composition.isComposing(event)) return;\n if (event.key === \"Escape\") {\n // Leave a press an inner handler already owned.\n if (event.defaultPrevented) return;\n event.preventDefault();\n this.cancel();\n return;\n }\n if (event.key === \"Enter\") {\n // A descendant widget that already claimed the key (a completion popup\n // confirming its candidate) must not ALSO commit the edit — composition\n // depends on this yield. Kept separate from the Escape guard above, which\n // answers a different question: who owns an Escape press.\n if (event.defaultPrevented) return;\n // A bare Enter inserts a newline in a textarea; only Ctrl+Enter (or Cmd+Enter on\n // macOS, the platform-conventional commit chord) saves there.\n if (this.#isMultiline && !(event.ctrlKey || event.metaKey)) return;\n event.preventDefault();\n this.#commit(true);\n }\n }\n\n /**\n * Returns to display mode, storing the input's value and dispatching `change`\n * when it differs from where editing began.\n *\n * @param restoreFocus - Move focus back to the display element (explicit\n * commit) rather than honoring the user's new focus target (blur).\n */\n #commit(restoreFocus: boolean): void {\n if (!this.#isEditing || !this.hasInputTarget) return;\n // One normalization for all three consumers below, so the stored value, the\n // comparison, and the detail can never disagree about what was saved.\n const value = this.inputTarget.value.trim();\n const previous = this.#previousValue;\n this.#writeValue(value);\n this.#setMode(\"display\");\n if (restoreFocus && this.hasDisplayTarget) this.displayTarget.focus();\n if (value !== previous) {\n this.#revertValue = previous;\n this.dispatch(\"change\", { detail: { value, previous } });\n }\n }\n\n /** Stores `value` wherever the display element declares it. */\n #writeValue(value: string): void {\n if (!this.hasDisplayTarget) return;\n const display = this.displayTarget;\n // Text that renders the value is the consumer's to compose; overwriting it\n // with the raw value would destroy a rendering this controller cannot rebuild.\n if (display.hasAttribute(\"data-value\")) display.dataset.value = value;\n else display.textContent = value;\n }\n\n /** Derives both elements' visibility from the mode currently in the DOM. */\n #applyMode(): void {\n const editing = this.#isEditing;\n if (this.hasDisplayTarget) this.#hidden.write(this.displayTarget, editing ? \"\" : null);\n if (this.hasInputTarget) this.#hidden.write(this.inputTarget, editing ? null : \"\");\n }\n\n /** Records the mode, then brings both elements in line with it. */\n #setMode(mode: \"display\" | \"editing\"): void {\n this.element.dataset.mode = mode;\n this.#applyMode();\n }\n\n /** The value the display element declares, trimmed. */\n get #currentValue(): string {\n const display = this.displayTarget;\n return (display.dataset.value ?? display.textContent ?? \"\").trim();\n }\n\n /** Whether the editing control is a multi-line `<textarea>`. */\n get #isMultiline(): boolean {\n return this.inputTarget.tagName === \"TEXTAREA\";\n }\n\n /** Whether the controller is currently in edit mode. */\n get #isEditing(): boolean {\n return this.element.dataset.mode === \"editing\";\n }\n}\n"]}
|
|
@@ -116,4 +116,5 @@ declare class FormFieldController extends Controller<HTMLElement> {
|
|
|
116
116
|
clearError(): void;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
export { FormFieldController
|
|
119
|
+
export { FormFieldController };
|
|
120
|
+
export type { FormFieldSetErrorOptions, FormFieldValidateDetail };
|
|
@@ -120,4 +120,5 @@ declare class InputMaskController extends Controller<HTMLInputElement> {
|
|
|
120
120
|
format(event?: Event): void;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
export { InputMaskController,
|
|
123
|
+
export { InputMaskController, applyMask, prepareInputMaskForm };
|
|
124
|
+
export type { MaskResult };
|
|
@@ -590,6 +590,27 @@ var InputMaskController = class extends Controller {
|
|
|
590
590
|
#textBeforeComposition = "";
|
|
591
591
|
#formatted = null;
|
|
592
592
|
#shown = { result: null, empty: true };
|
|
593
|
+
#edits = new ListenerSet();
|
|
594
|
+
#onBeforeInput = (event) => {
|
|
595
|
+
const data = event.data;
|
|
596
|
+
if (event.defaultPrevented || !event.cancelable || event.inputType !== "insertText" || data === null || Array.from(data).length !== 1 || !this.#started || this.#composition.isComposing(event))
|
|
597
|
+
return;
|
|
598
|
+
const input = this.element;
|
|
599
|
+
const start = input.selectionStart;
|
|
600
|
+
const end = input.selectionEnd;
|
|
601
|
+
if (start === null || end === null || start === end || input.readOnly || input.disabled || inheritsFieldsetDisabled(input) || !input.isConnected || !this.application.element.contains(input) || !(input.getAttribute("data-controller") ?? "").split(/\s+/).includes(this.identifier) || this.patternValue === "" || this.#formatted !== this.#declared || input.value !== this.#lastValue)
|
|
602
|
+
return;
|
|
603
|
+
const prefix = applyMask(input.value.slice(0, start), this.patternValue, this.#tokens);
|
|
604
|
+
for (const character of Array.from(this.patternValue).slice(prefix.tokenFlags.length)) {
|
|
605
|
+
const token = this.#tokens.get(character);
|
|
606
|
+
if (token) {
|
|
607
|
+
if (acceptedForm(token, data) === null) event.preventDefault();
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
610
|
+
if (halfWidthChar(data) === halfWidthChar(character)) return;
|
|
611
|
+
}
|
|
612
|
+
event.preventDefault();
|
|
613
|
+
};
|
|
593
614
|
#composition = new CompositionTracker({
|
|
594
615
|
onStart: () => {
|
|
595
616
|
this.#textBeforeComposition = this.element.value;
|
|
@@ -625,6 +646,7 @@ var InputMaskController = class extends Controller {
|
|
|
625
646
|
this.#morph.observe(this.element);
|
|
626
647
|
this.#started = true;
|
|
627
648
|
this.#composition.observe(this.element);
|
|
649
|
+
this.#edits.add(this.element, "beforeinput", this.#onBeforeInput);
|
|
628
650
|
if (!this.unmaskToHiddenValue) this.#withdraw();
|
|
629
651
|
if (this.#composition.isComposing()) {
|
|
630
652
|
this.#reformat("reconcile");
|
|
@@ -639,6 +661,7 @@ var InputMaskController = class extends Controller {
|
|
|
639
661
|
disconnect() {
|
|
640
662
|
this.#morph.disconnect();
|
|
641
663
|
this.#started = false;
|
|
664
|
+
this.#edits.dispose();
|
|
642
665
|
this.#composition.disconnect();
|
|
643
666
|
this.#adoption.clearAll();
|
|
644
667
|
this.#gate.disconnected(this, () => this.#retractRaw());
|