stimeo-ui 0.16.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -0
- package/README.md +8 -1
- package/dist/cable/index.d.ts +79 -23
- package/dist/cable/index.js +363 -436
- package/dist/cable/index.js.map +1 -1
- package/dist/controllers/accordion_controller.d.ts +4 -2
- package/dist/controllers/accordion_controller.js +166 -55
- package/dist/controllers/accordion_controller.js.map +1 -1
- package/dist/controllers/alert_dialog_controller.d.ts +12 -2
- package/dist/controllers/alert_dialog_controller.js +862 -221
- package/dist/controllers/alert_dialog_controller.js.map +1 -1
- package/dist/controllers/announcer_controller.d.ts +35 -5
- package/dist/controllers/announcer_controller.js +135 -198
- package/dist/controllers/announcer_controller.js.map +1 -1
- package/dist/controllers/aspect_ratio_controller.js +0 -10
- package/dist/controllers/aspect_ratio_controller.js.map +1 -1
- package/dist/controllers/auto_submit_controller.d.ts +30 -6
- package/dist/controllers/auto_submit_controller.js +271 -127
- package/dist/controllers/auto_submit_controller.js.map +1 -1
- package/dist/controllers/avatar_controller.js +171 -105
- package/dist/controllers/avatar_controller.js.map +1 -1
- package/dist/controllers/breadcrumb_controller.js +0 -130
- package/dist/controllers/breadcrumb_controller.js.map +1 -1
- package/dist/controllers/bulk_select_controller.d.ts +18 -0
- package/dist/controllers/bulk_select_controller.js +262 -52
- package/dist/controllers/bulk_select_controller.js.map +1 -1
- package/dist/controllers/calendar_controller.d.ts +24 -5
- package/dist/controllers/calendar_controller.js +175 -209
- package/dist/controllers/calendar_controller.js.map +1 -1
- package/dist/controllers/carousel_controller.d.ts +34 -7
- package/dist/controllers/carousel_controller.js +461 -399
- package/dist/controllers/carousel_controller.js.map +1 -1
- package/dist/controllers/character_counter_controller.d.ts +17 -1
- package/dist/controllers/character_counter_controller.js +246 -156
- package/dist/controllers/character_counter_controller.js.map +1 -1
- package/dist/controllers/checkbox_controller.d.ts +7 -2
- package/dist/controllers/checkbox_controller.js +32 -74
- package/dist/controllers/checkbox_controller.js.map +1 -1
- package/dist/controllers/clipboard_controller.d.ts +16 -5
- package/dist/controllers/clipboard_controller.js +168 -147
- package/dist/controllers/clipboard_controller.js.map +1 -1
- package/dist/controllers/collapsible_controller.d.ts +16 -4
- package/dist/controllers/collapsible_controller.js +301 -120
- package/dist/controllers/collapsible_controller.js.map +1 -1
- package/dist/controllers/color_picker_controller.d.ts +18 -6
- package/dist/controllers/color_picker_controller.js +149 -139
- package/dist/controllers/color_picker_controller.js.map +1 -1
- package/dist/controllers/combobox_controller.d.ts +23 -5
- package/dist/controllers/combobox_controller.js +360 -133
- package/dist/controllers/combobox_controller.js.map +1 -1
- package/dist/controllers/command_palette_controller.d.ts +45 -14
- package/dist/controllers/command_palette_controller.js +970 -358
- package/dist/controllers/command_palette_controller.js.map +1 -1
- package/dist/controllers/conditional_fields_controller.d.ts +15 -2
- package/dist/controllers/conditional_fields_controller.js +166 -124
- package/dist/controllers/conditional_fields_controller.js.map +1 -1
- package/dist/controllers/confirm_controller.d.ts +49 -12
- package/dist/controllers/confirm_controller.js +939 -248
- package/dist/controllers/confirm_controller.js.map +1 -1
- package/dist/controllers/context_menu_controller.d.ts +31 -4
- package/dist/controllers/context_menu_controller.js +256 -128
- package/dist/controllers/context_menu_controller.js.map +1 -1
- package/dist/controllers/count_up_controller.d.ts +13 -1
- package/dist/controllers/count_up_controller.js +73 -21
- package/dist/controllers/count_up_controller.js.map +1 -1
- package/dist/controllers/countdown_controller.d.ts +45 -1
- package/dist/controllers/countdown_controller.js +183 -148
- package/dist/controllers/countdown_controller.js.map +1 -1
- package/dist/controllers/currency_input_controller.d.ts +21 -2
- package/dist/controllers/currency_input_controller.js +134 -158
- package/dist/controllers/currency_input_controller.js.map +1 -1
- package/dist/controllers/data_grid_controller.d.ts +15 -4
- package/dist/controllers/data_grid_controller.js +114 -186
- package/dist/controllers/data_grid_controller.js.map +1 -1
- package/dist/controllers/date_range_picker_controller.d.ts +30 -5
- package/dist/controllers/date_range_picker_controller.js +288 -206
- package/dist/controllers/date_range_picker_controller.js.map +1 -1
- package/dist/controllers/dialog_controller.d.ts +13 -1
- package/dist/controllers/dialog_controller.js +858 -223
- package/dist/controllers/dialog_controller.js.map +1 -1
- package/dist/controllers/direct_upload_controller.d.ts +24 -7
- package/dist/controllers/direct_upload_controller.js +73 -153
- package/dist/controllers/direct_upload_controller.js.map +1 -1
- package/dist/controllers/dirty_form_controller.js +14 -48
- package/dist/controllers/dirty_form_controller.js.map +1 -1
- package/dist/controllers/dismissible_controller.d.ts +19 -0
- package/dist/controllers/dismissible_controller.js +175 -21
- package/dist/controllers/dismissible_controller.js.map +1 -1
- package/dist/controllers/drawer_controller.d.ts +39 -11
- package/dist/controllers/drawer_controller.js +933 -341
- package/dist/controllers/drawer_controller.js.map +1 -1
- package/dist/controllers/dropdown_controller.d.ts +31 -1
- package/dist/controllers/dropdown_controller.js +312 -82
- package/dist/controllers/dropdown_controller.js.map +1 -1
- package/dist/controllers/editable_controller.d.ts +12 -1
- package/dist/controllers/editable_controller.js +158 -68
- package/dist/controllers/editable_controller.js.map +1 -1
- package/dist/controllers/empty_state_controller.js +67 -53
- package/dist/controllers/empty_state_controller.js.map +1 -1
- package/dist/controllers/file_dropzone_controller.d.ts +60 -18
- package/dist/controllers/file_dropzone_controller.js +311 -207
- package/dist/controllers/file_dropzone_controller.js.map +1 -1
- package/dist/controllers/filter_controller.js +67 -39
- package/dist/controllers/filter_controller.js.map +1 -1
- package/dist/controllers/flash_controller.d.ts +31 -8
- package/dist/controllers/flash_controller.js +172 -314
- package/dist/controllers/flash_controller.js.map +1 -1
- package/dist/controllers/focus_controller.d.ts +12 -3
- package/dist/controllers/focus_controller.js +654 -240
- package/dist/controllers/focus_controller.js.map +1 -1
- package/dist/controllers/form_field_controller.js +147 -132
- package/dist/controllers/form_field_controller.js.map +1 -1
- package/dist/controllers/form_validation_controller.js +13 -86
- package/dist/controllers/form_validation_controller.js.map +1 -1
- package/dist/controllers/frame_loading_controller.d.ts +41 -9
- package/dist/controllers/frame_loading_controller.js +264 -213
- package/dist/controllers/frame_loading_controller.js.map +1 -1
- package/dist/controllers/highlight_controller.d.ts +22 -2
- package/dist/controllers/highlight_controller.js +107 -75
- package/dist/controllers/highlight_controller.js.map +1 -1
- package/dist/controllers/hover_card_controller.d.ts +56 -3
- package/dist/controllers/hover_card_controller.js +309 -118
- package/dist/controllers/hover_card_controller.js.map +1 -1
- package/dist/controllers/idle_controller.d.ts +42 -1
- package/dist/controllers/idle_controller.js +267 -101
- package/dist/controllers/idle_controller.js.map +1 -1
- package/dist/controllers/input_mask_controller.js +71 -72
- package/dist/controllers/input_mask_controller.js.map +1 -1
- package/dist/controllers/intersection_controller.d.ts +32 -13
- package/dist/controllers/intersection_controller.js +147 -106
- package/dist/controllers/intersection_controller.js.map +1 -1
- package/dist/controllers/lazy_frame_controller.d.ts +16 -0
- package/dist/controllers/lazy_frame_controller.js +9 -65
- package/dist/controllers/lazy_frame_controller.js.map +1 -1
- package/dist/controllers/listbox_controller.d.ts +34 -2
- package/dist/controllers/listbox_controller.js +306 -204
- package/dist/controllers/listbox_controller.js.map +1 -1
- package/dist/controllers/local_time_controller.d.ts +1 -1
- package/dist/controllers/local_time_controller.js +54 -64
- package/dist/controllers/local_time_controller.js.map +1 -1
- package/dist/controllers/masonry_controller.d.ts +11 -3
- package/dist/controllers/masonry_controller.js +70 -93
- package/dist/controllers/masonry_controller.js.map +1 -1
- package/dist/controllers/menu_controller.d.ts +32 -7
- package/dist/controllers/menu_controller.js +214 -156
- package/dist/controllers/menu_controller.js.map +1 -1
- package/dist/controllers/menubar_controller.d.ts +4 -4
- package/dist/controllers/menubar_controller.js +170 -329
- package/dist/controllers/menubar_controller.js.map +1 -1
- package/dist/controllers/meter_controller.d.ts +20 -0
- package/dist/controllers/meter_controller.js +151 -67
- package/dist/controllers/meter_controller.js.map +1 -1
- package/dist/controllers/multi_select_controller.d.ts +32 -4
- package/dist/controllers/multi_select_controller.js +593 -358
- package/dist/controllers/multi_select_controller.js.map +1 -1
- package/dist/controllers/navigation_menu_controller.d.ts +8 -1
- package/dist/controllers/navigation_menu_controller.js +124 -232
- package/dist/controllers/navigation_menu_controller.js.map +1 -1
- package/dist/controllers/nested_form_controller.d.ts +10 -0
- package/dist/controllers/nested_form_controller.js +352 -182
- package/dist/controllers/nested_form_controller.js.map +1 -1
- package/dist/controllers/network_status_controller.d.ts +23 -0
- package/dist/controllers/network_status_controller.js +242 -54
- package/dist/controllers/network_status_controller.js.map +1 -1
- package/dist/controllers/number_input_controller.d.ts +26 -2
- package/dist/controllers/number_input_controller.js +320 -263
- package/dist/controllers/number_input_controller.js.map +1 -1
- package/dist/controllers/optimistic_controller.js +16 -76
- package/dist/controllers/optimistic_controller.js.map +1 -1
- package/dist/controllers/otp_controller.d.ts +20 -4
- package/dist/controllers/otp_controller.js +198 -193
- package/dist/controllers/otp_controller.js.map +1 -1
- package/dist/controllers/overflow_indicator_controller.d.ts +5 -0
- package/dist/controllers/overflow_indicator_controller.js +116 -113
- package/dist/controllers/overflow_indicator_controller.js.map +1 -1
- package/dist/controllers/overflow_menu_controller.d.ts +48 -11
- package/dist/controllers/overflow_menu_controller.js +343 -283
- package/dist/controllers/overflow_menu_controller.js.map +1 -1
- package/dist/controllers/pagination_controller.d.ts +35 -6
- package/dist/controllers/pagination_controller.js +295 -119
- package/dist/controllers/pagination_controller.js.map +1 -1
- package/dist/controllers/password_reveal_controller.d.ts +45 -8
- package/dist/controllers/password_reveal_controller.js +389 -121
- package/dist/controllers/password_reveal_controller.js.map +1 -1
- package/dist/controllers/password_strength_controller.d.ts +14 -5
- package/dist/controllers/password_strength_controller.js +99 -153
- package/dist/controllers/password_strength_controller.js.map +1 -1
- package/dist/controllers/persist_controller.d.ts +11 -4
- package/dist/controllers/persist_controller.js +237 -103
- package/dist/controllers/persist_controller.js.map +1 -1
- package/dist/controllers/pointer_drag_controller.d.ts +19 -7
- package/dist/controllers/pointer_drag_controller.js +185 -165
- package/dist/controllers/pointer_drag_controller.js.map +1 -1
- package/dist/controllers/popover_controller.d.ts +38 -2
- package/dist/controllers/popover_controller.js +236 -97
- package/dist/controllers/popover_controller.js.map +1 -1
- package/dist/controllers/portal_controller.d.ts +44 -4
- package/dist/controllers/portal_controller.js +209 -76
- package/dist/controllers/portal_controller.js.map +1 -1
- package/dist/controllers/preview_guard_controller.d.ts +10 -4
- package/dist/controllers/preview_guard_controller.js +232 -116
- package/dist/controllers/preview_guard_controller.js.map +1 -1
- package/dist/controllers/progress_controller.d.ts +11 -0
- package/dist/controllers/progress_controller.js +125 -56
- package/dist/controllers/progress_controller.js.map +1 -1
- package/dist/controllers/radio_group_controller.d.ts +14 -5
- package/dist/controllers/radio_group_controller.js +117 -137
- package/dist/controllers/radio_group_controller.js.map +1 -1
- package/dist/controllers/range_slider_controller.d.ts +43 -3
- package/dist/controllers/range_slider_controller.js +192 -105
- package/dist/controllers/range_slider_controller.js.map +1 -1
- package/dist/controllers/rating_controller.d.ts +20 -4
- package/dist/controllers/rating_controller.js +418 -207
- package/dist/controllers/rating_controller.js.map +1 -1
- package/dist/controllers/read_more_controller.d.ts +2 -0
- package/dist/controllers/read_more_controller.js +134 -63
- package/dist/controllers/read_more_controller.js.map +1 -1
- package/dist/controllers/reading_progress_controller.d.ts +1 -1
- package/dist/controllers/reading_progress_controller.js +147 -135
- package/dist/controllers/reading_progress_controller.js.map +1 -1
- package/dist/controllers/relative_time_controller.d.ts +18 -4
- package/dist/controllers/relative_time_controller.js +145 -110
- package/dist/controllers/relative_time_controller.js.map +1 -1
- package/dist/controllers/reset_on_restore_controller.d.ts +85 -0
- package/dist/controllers/{reset_before_cache_controller.js → reset_on_restore_controller.js} +97 -38
- package/dist/controllers/reset_on_restore_controller.js.map +1 -0
- package/dist/controllers/resizable_controller.d.ts +28 -2
- package/dist/controllers/resizable_controller.js +255 -139
- package/dist/controllers/resizable_controller.js.map +1 -1
- package/dist/controllers/roving_controller.js +39 -84
- package/dist/controllers/roving_controller.js.map +1 -1
- package/dist/controllers/scroll_area_controller.d.ts +7 -3
- package/dist/controllers/scroll_area_controller.js +428 -225
- package/dist/controllers/scroll_area_controller.js.map +1 -1
- package/dist/controllers/scroll_restore_controller.js +0 -53
- package/dist/controllers/scroll_restore_controller.js.map +1 -1
- package/dist/controllers/scroll_visibility_controller.d.ts +28 -12
- package/dist/controllers/scroll_visibility_controller.js +395 -145
- package/dist/controllers/scroll_visibility_controller.js.map +1 -1
- package/dist/controllers/scrollspy_controller.d.ts +6 -1
- package/dist/controllers/scrollspy_controller.js +181 -242
- package/dist/controllers/scrollspy_controller.js.map +1 -1
- package/dist/controllers/separator_controller.d.ts +19 -4
- package/dist/controllers/separator_controller.js +267 -140
- package/dist/controllers/separator_controller.js.map +1 -1
- package/dist/controllers/sidebar_controller.d.ts +64 -7
- package/dist/controllers/sidebar_controller.js +1023 -386
- package/dist/controllers/sidebar_controller.js.map +1 -1
- package/dist/controllers/skeleton_controller.d.ts +23 -0
- package/dist/controllers/skeleton_controller.js +248 -97
- package/dist/controllers/skeleton_controller.js.map +1 -1
- package/dist/controllers/slider_controller.d.ts +27 -1
- package/dist/controllers/slider_controller.js +159 -79
- package/dist/controllers/slider_controller.js.map +1 -1
- package/dist/controllers/smart_sticky_header_controller.d.ts +21 -3
- package/dist/controllers/smart_sticky_header_controller.js +162 -63
- package/dist/controllers/smart_sticky_header_controller.js.map +1 -1
- package/dist/controllers/sortable_controller.js +0 -112
- package/dist/controllers/sortable_controller.js.map +1 -1
- package/dist/controllers/spinner_controller.d.ts +39 -4
- package/dist/controllers/spinner_controller.js +277 -169
- package/dist/controllers/spinner_controller.js.map +1 -1
- package/dist/controllers/step_indicator_controller.d.ts +5 -0
- package/dist/controllers/step_indicator_controller.js +99 -46
- package/dist/controllers/step_indicator_controller.js.map +1 -1
- package/dist/controllers/stepper_controller.d.ts +12 -3
- package/dist/controllers/stepper_controller.js +114 -73
- package/dist/controllers/stepper_controller.js.map +1 -1
- package/dist/controllers/stick_to_bottom_controller.d.ts +6 -0
- package/dist/controllers/stick_to_bottom_controller.js +262 -138
- package/dist/controllers/stick_to_bottom_controller.js.map +1 -1
- package/dist/controllers/sticky_observer_controller.d.ts +11 -0
- package/dist/controllers/sticky_observer_controller.js +214 -49
- package/dist/controllers/sticky_observer_controller.js.map +1 -1
- package/dist/controllers/submit_once_controller.d.ts +23 -8
- package/dist/controllers/submit_once_controller.js +294 -205
- package/dist/controllers/submit_once_controller.js.map +1 -1
- package/dist/controllers/switch_controller.d.ts +12 -1
- package/dist/controllers/switch_controller.js +33 -60
- package/dist/controllers/switch_controller.js.map +1 -1
- package/dist/controllers/tabs_controller.d.ts +2 -2
- package/dist/controllers/tabs_controller.js +35 -29
- package/dist/controllers/tabs_controller.js.map +1 -1
- package/dist/controllers/tags_input_controller.d.ts +12 -0
- package/dist/controllers/tags_input_controller.js +136 -145
- package/dist/controllers/tags_input_controller.js.map +1 -1
- package/dist/controllers/textarea_autosize_controller.d.ts +10 -0
- package/dist/controllers/textarea_autosize_controller.js +71 -58
- package/dist/controllers/textarea_autosize_controller.js.map +1 -1
- package/dist/controllers/theme_controller.d.ts +21 -9
- package/dist/controllers/theme_controller.js +130 -112
- package/dist/controllers/theme_controller.js.map +1 -1
- package/dist/controllers/time_picker_controller.d.ts +18 -1
- package/dist/controllers/time_picker_controller.js +146 -80
- package/dist/controllers/time_picker_controller.js.map +1 -1
- package/dist/controllers/toast_controller.d.ts +36 -11
- package/dist/controllers/toast_controller.js +186 -297
- package/dist/controllers/toast_controller.js.map +1 -1
- package/dist/controllers/toggle_group_controller.d.ts +12 -3
- package/dist/controllers/toggle_group_controller.js +95 -136
- package/dist/controllers/toggle_group_controller.js.map +1 -1
- package/dist/controllers/toolbar_controller.js +68 -98
- package/dist/controllers/toolbar_controller.js.map +1 -1
- package/dist/controllers/tooltip_controller.d.ts +45 -3
- package/dist/controllers/tooltip_controller.js +158 -124
- package/dist/controllers/tooltip_controller.js.map +1 -1
- package/dist/controllers/transition_controller.d.ts +22 -4
- package/dist/controllers/transition_controller.js +123 -119
- package/dist/controllers/transition_controller.js.map +1 -1
- package/dist/controllers/tree_view_controller.d.ts +21 -11
- package/dist/controllers/tree_view_controller.js +150 -345
- package/dist/controllers/tree_view_controller.js.map +1 -1
- package/dist/index.d.ts +8 -5
- package/dist/index.js +6370 -9346
- package/dist/index.js.map +1 -1
- package/dist/inspector/cli.d.ts +23 -3
- package/dist/inspector/cli.js +92 -37
- package/dist/inspector/cli.js.map +1 -1
- package/dist/inspector/cli_bin.js +92 -56
- package/dist/inspector/cli_bin.js.map +1 -1
- package/dist/inspector/examples.json +8 -8
- package/dist/inspector/manifest.json +787 -100
- package/dist/positioning/index.d.ts +8 -0
- package/dist/positioning/index.js +148 -47
- package/dist/positioning/index.js.map +1 -1
- package/package.json +6 -6
- package/dist/controllers/reset_before_cache_controller.d.ts +0 -76
- package/dist/controllers/reset_before_cache_controller.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/aria_ids.ts","../../src/utils/logical_scroll.ts","../../src/utils/arrow_step.ts","../../src/utils/attribute_lease.ts","../../src/utils/before_cache_reset.ts","../../src/utils/composition_tracker.ts","../../src/utils/declared_value.ts","../../src/utils/form_reset_watcher.ts","../../src/utils/half_width.ts","../../src/utils/microtask_coalescer.ts","../../src/controllers/otp_controller.ts"],"names":[],"mappings":";;;;;AAkBA,IAAI,OAAA,GAAU,CAAA;AAeP,SAAS,QAAA,CAAS,SAAS,QAAA,EAAkB;AAClD,EAAA,IAAI,SAAA;AACJ,EAAA,GAAG;AACD,IAAA,OAAA,IAAW,CAAA;AACX,IAAA,SAAA,GAAY,CAAA,EAAG,MAAM,CAAA,CAAA,EAAI,OAAO,CAAA,CAAA;AAAA,EAClC,SAAS,OAAO,QAAA,KAAa,eAAe,QAAA,CAAS,cAAA,CAAe,SAAS,CAAA,KAAM,IAAA;AACnF,EAAA,OAAO,SAAA;AACT;AAYO,SAAS,QAAA,CAAS,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AAC,OAAA,EAAS;AACd,MAAA,IAAA,CAAK,MAAA,CAAO,KAAA,EAAO,mBAAA,EAAqB,OAAO,CAAA;AAE/C,MAAA,MAAM,SAAA,GAAY,KAAA,CAAM,YAAA,CAAa,kBAAkB,CAAA;AACvD,MAAA,IAAA,CAAK,OAAO,KAAA,EAAO,kBAAA,EAAoB,eAAA,CAAgB,SAAA,EAAW,OAAO,CAAC,CAAA;AAAA,IAC5E;AACA,IAAA,IAAI,KAAK,cAAA,EAAgB,IAAA,CAAK,aAAa,KAAA,CAAM,IAAA,CAAK,aAAa,IAAI,CAAA;AAIvE,IAAA,IAAA,CAAK,QAAA,CAAS,WAAW,EAAE,MAAA,EAAQ,EAAE,OAAA,EAAS,IAAA,CAAK,cAAA,EAAe,EAAG,CAAA;AAAA,EACvE;AAAA;AAAA,EAGA,WAAA,GAAoB;AAClB,IAAA,KAAA,MAAW,KAAA,IAAS,IAAA,CAAK,YAAA,EAAc,IAAA,CAAK,cAAc,KAAK,CAAA;AAC/D,IAAA,IAAA,CAAK,aAAa,SAAA,EAAU;AAAA,EAC9B;AACF","file":"otp_controller.js","sourcesContent":["/**\n * Minimal id primitives for wiring ARIA relationships.\n *\n * Accessible relationships such as `aria-describedby`, `aria-errormessage`,\n * `aria-labelledby`, and `aria-activedescendant` reference their targets by DOM\n * `id`. When a controller must establish such a relationship but the consumer's\n * markup left the target without an `id`, it needs to mint one that is stable for\n * the page's lifetime and guaranteed not to collide with another generated id.\n *\n * These helpers own *only* id generation/assignment. The linking policy (which\n * attribute, what order, when to add or remove it) stays in each controller —\n * this deliberately avoids a premature generic \"ARIA linker\" abstraction.\n */\n\n/**\n * Monotonic counter backing {@link uniqueId}. Module-scoped so every generated\n * id is unique across all controller instances sharing this module in a document.\n */\nlet counter = 0;\n\n/**\n * Returns a unique, DOM-id-safe string of the form `` `${prefix}-${n}` `` where\n * `n` increases on each call.\n *\n * The counter alone guarantees uniqueness against other *generated* ids, but a\n * consumer-authored element could already own `` `${prefix}-${n}` ``. When a\n * `document` is available the candidate is therefore advanced until no element\n * with that id exists, so a generated id never collides with author markup\n * either — the minimal \"id registry\" guarantee these helpers exist to provide.\n *\n * @param prefix - Leading segment of the id (e.g. a controller's identifier).\n * Defaults to `\"stimeo\"`.\n */\nexport function uniqueId(prefix = \"stimeo\"): string {\n let candidate: string;\n do {\n counter += 1;\n candidate = `${prefix}-${counter}`;\n } while (typeof document !== \"undefined\" && document.getElementById(candidate) !== null);\n return candidate;\n}\n\n/**\n * Returns `element`'s existing `id`, or assigns it a freshly generated\n * {@link uniqueId} (with the given `prefix`) and returns that. Idempotent: an\n * element that already has an id keeps it, so consumer-authored ids are never\n * overwritten.\n *\n * @param element - The element to read or stamp an `id` onto.\n * @param prefix - Prefix forwarded to {@link uniqueId} when one must be generated.\n * @returns The element's id (existing or newly assigned).\n */\nexport function ensureId(element: Element, prefix = \"stimeo\"): string {\n if (element.id) return element.id;\n const id = uniqueId(prefix);\n element.id = id;\n return id;\n}\n","/** Normalized scroll position and maximum distance on one logical axis. */\nexport interface LogicalScrollMetrics {\n position: number;\n max: number;\n}\n\n/**\n * Whether horizontal scrolling on `element` follows right-to-left inline flow.\n *\n * Resolved from the **computed** `direction`, so the authoring contract is the\n * usual `dir=\"rtl\"` (or a stylesheet) on the element or any ancestor.\n *\n * Scope: horizontal writing modes. A vertical writing mode (`writing-mode:\n * vertical-rl`) also inverts the horizontal axis, which this check does not\n * model — vertical writing modes are out of scope for the scroll utilities\n * (their consumers describe axes as horizontal/vertical, not inline/block).\n */\nexport function isRtl(element: Element): boolean {\n return window.getComputedStyle(element).direction === \"rtl\";\n}\n\n/**\n * Returns scroll distance from the logical start edge.\n *\n * CSSOM View exposes standards-mode RTL horizontal offsets as `0` at the inline\n * start (right) and increasingly negative values toward the inline end (left).\n * The normalized position is always clamped to `[0, max]`, which also absorbs\n * Safari's elastic overscroll values.\n */\nexport function logicalScrollMetrics(\n element: HTMLElement,\n horizontal: boolean,\n): LogicalScrollMetrics {\n const max = Math.max(\n 0,\n horizontal\n ? element.scrollWidth - element.clientWidth\n : element.scrollHeight - element.clientHeight,\n );\n const raw = horizontal ? element.scrollLeft : element.scrollTop;\n const position = horizontal && isRtl(element) ? -raw : raw;\n return { position: Math.min(max, Math.max(0, position)), max };\n}\n\n/**\n * Converts a logical start/end delta to the physical value accepted by\n * `Element.scrollBy`.\n */\nexport function physicalScrollDelta(\n element: HTMLElement,\n horizontal: boolean,\n logicalDelta: number,\n): number {\n return horizontal && isRtl(element) ? -logicalDelta : logicalDelta;\n}\n","import { isRtl } from \"./logical_scroll\";\n\n/**\n * Turns an arrow key into a **logical** step: `+1` for \"next\", `-1` for\n * \"previous\", `0` when the key names neither.\n *\n * APG defines the horizontal pair as *next / previous* and says a vertical\n * arrangement swaps in Down/Up for the same meaning — so the pair is one axis's\n * spelling of an order, and the order reverses with the writing direction. Only\n * the horizontal pair reverses. Down/Up name an axis the writing direction does\n * not mirror, and returning them unchanged is the point: many controllers fold\n * both pairs into one branch, where swapping the branches under RTL would flip\n * the vertical axis too — a bug that reads as \"the arrows work\" until someone\n * presses Down.\n *\n * **Direction is read from the element the caller passes, which should be the\n * container that lays the items out** — not the focused child. A child may carry\n * its own `dir` (an LTR input inside an RTL form is ordinary authoring), and\n * probing per handler makes two handlers disagree at the boundary between them.\n *\n * This decides direction only. Whether the axis is even active (an\n * `orientation=\"horizontal\"` widget ignoring Down/Up), how far the step lands,\n * and what wrapping does all stay with the caller.\n *\n * **It encodes the list-order convention: `ArrowDown` is *next*.** Widgets that\n * pair the arrows by *value* instead — `ArrowUp` meaning \"more\", as a rating or a\n * slider does — must not use this, or their vertical axis inverts. Reverse the\n * horizontal pair on its own there.\n *\n * @example\n * ```ts\n * const step = logicalArrowStep(event.key, this.element);\n * if (step === 0) return;\n * this.#roving.setActive(rovingMove(current, length, step, \"wrap\"), { focus: true });\n * ```\n */\nexport function logicalArrowStep(key: string, element: Element): 1 | -1 | 0 {\n if (key === \"ArrowDown\") return 1;\n if (key === \"ArrowUp\") return -1;\n if (key !== \"ArrowRight\" && key !== \"ArrowLeft\") return 0;\n const forward = isRtl(element) ? \"ArrowLeft\" : \"ArrowRight\";\n return key === forward ? 1 : -1;\n}\n\n/**\n * Rewrites `key` so an existing LTR-shaped branch keeps working under RTL:\n * `ArrowRight` and `ArrowLeft` trade places, everything else passes through.\n *\n * The alternative — negating a delta — silently breaks handlers whose two\n * horizontal branches are **not mirror images**. A grid that clamps one edge but\n * not the other, or a segmented field guarding `index > 0` on one side and\n * `index < length - 1` on the other, ends up applying the wrong guard to the\n * wrong direction. Swapping the key leaves each branch, guards and all, exactly\n * where its author put it.\n *\n * Same rule as {@link logicalArrowStep} about which element to read: pass the\n * container that lays the items out, not the focused child.\n *\n * @example\n * ```ts\n * switch (logicalArrowKey(event.key, this.element)) {\n * case \"ArrowLeft\": // \"previous\" — whatever direction that is on screen\n * ```\n */\nexport function logicalArrowKey(key: string, element: Element): string {\n if (key !== \"ArrowRight\" && key !== \"ArrowLeft\") return key;\n if (!isRtl(element)) return key;\n return key === \"ArrowRight\" ? \"ArrowLeft\" : \"ArrowRight\";\n}\n\n/** Modifiers a widget may claim on an arrow key, named for the `allow` list. */\nexport type ArrowModifier = \"alt\" | \"ctrl\" | \"meta\" | \"shift\";\n\n/**\n * True when an arrow key arrived carrying a modifier the widget must leave to\n * the browser: return without calling `preventDefault()` and without moving any\n * state.\n *\n * A bare arrow belongs to the widget; a chorded one usually does not.\n * `Alt`/`Meta` plus a horizontal arrow is history back/forward on every desktop\n * browser, and a widget that swallows it makes the shortcut work or not\n * depending on where focus happens to sit — a coin-flip the user cannot see.\n *\n * `allow` is for the combinations APG assigns to a pattern **and the widget\n * actually implements** — today only Combobox's optional `Alt+Down`/`Alt+Up`.\n * Listing one the widget does not implement defeats the point: the chord then\n * runs the plain-arrow branch, which is exactly what this guard exists to stop.\n * Non-arrow keys return `false`, so chorded letters and\n * `Control+Home`/`Control+End` are untouched.\n *\n * @example\n * ```ts\n * if (isReservedArrowChord(event)) return;\n * ```\n */\nexport function isReservedArrowChord(\n event: KeyboardEvent,\n allow: readonly ArrowModifier[] = [],\n): boolean {\n if (!event.key.startsWith(\"Arrow\")) return false;\n return (\n (event.altKey && !allow.includes(\"alt\")) ||\n (event.ctrlKey && !allow.includes(\"ctrl\")) ||\n (event.metaKey && !allow.includes(\"meta\")) ||\n (event.shiftKey && !allow.includes(\"shift\"))\n );\n}\n\n/**\n * True when a press arrived carrying any modifier, for the keys the browser and\n * the OS own outright: return without calling `preventDefault()` and without\n * moving any state.\n *\n * `Control+Home` and `Control+End` jump the document to its ends, and a widget\n * that swallows them makes the shortcut work or not depending on where focus\n * happens to sit. {@link isReservedArrowChord} answers the same question for the\n * arrows, but returns `false` for every other key so that this one can decide.\n *\n * There is no `allow` list here on purpose. APG assigns no modifier chord to\n * `Home`/`End`, so a widget that wanted one would be claiming a combination the\n * pattern never gave it.\n *\n * @example\n * ```ts\n * case \"Home\":\n * case \"End\":\n * if (hasModifierChord(event)) return;\n * ```\n */\nexport function hasModifierChord(event: KeyboardEvent): boolean {\n return event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;\n}\n","/** One temporarily controlled attribute value and the authored value it displaced. */\ninterface AttributeLeaseRecord {\n readonly original: string | null;\n written: string | null;\n}\n\n/**\n * Temporarily controls one attribute across a changing set of elements.\n *\n * The first write remembers the authored value, including the distinction between\n * an absent attribute and an authored empty string. Returning a lease restores that\n * value only while the attribute still matches the controller's last write. If a\n * consumer changed it in the meantime, the consumer owns the new value and teardown\n * leaves it alone.\n *\n * A `null` write deliberately removes the attribute while retaining the lease. This\n * is useful for derived ARIA whose valid absence is itself controller state, such as\n * an unbounded `aria-valuemin` or a blank spinbutton's `aria-valuenow`.\n *\n * The lease has no lifecycle of its own, so it never subscribes to document events.\n * A consumer that must not let a derived value become the authored baseline of a\n * cached page returns its leases from its own `turbo:before-cache` rewind, where the\n * matching `disconnect()` also releases the subscription.\n */\nexport class AttributeLease<T extends Element = Element> {\n readonly #attribute: string;\n readonly #records = new Map<T, AttributeLeaseRecord>();\n\n /** @param attribute - The attribute whose temporary values this lease owns. */\n constructor(attribute: string) {\n this.#attribute = attribute;\n }\n\n /** Writes or removes the leased attribute while preserving its authored value. */\n write(element: T, value: string | null): void {\n const existing = this.#records.get(element);\n if (existing) {\n existing.written = value;\n } else {\n this.#records.set(element, {\n original: element.getAttribute(this.#attribute),\n written: value,\n });\n }\n\n this.#reflect(element, value);\n }\n\n /** Returns one lease without overwriting a value subsequently authored by a consumer. */\n return(element: T): void {\n const record = this.#records.get(element);\n if (!record) return;\n this.#records.delete(element);\n const stillOwned = element.getAttribute(this.#attribute) === record.written;\n if (stillOwned) this.#reflect(element, record.original);\n }\n\n /** Reflects only a real value transition, avoiding self-triggered mutation work. */\n #reflect(element: T, value: string | null): void {\n if (element.getAttribute(this.#attribute) === value) return;\n if (value === null) element.removeAttribute(this.#attribute);\n else element.setAttribute(this.#attribute, value);\n }\n\n /** Returns every outstanding lease using the same ownership check as {@link return}. */\n returnAll(): void {\n for (const element of Array.from(this.#records.keys())) this.return(element);\n }\n}\n","/**\n * Runs a controller's \"return to the initial state\" pass just before Turbo\n * caches the page.\n *\n * **`disconnect()` cannot do this job, for two independent reasons.** Turbo\n * queues the clone from this event rather than taking it here, and the body swap\n * that runs the controller's `disconnect()` is queued separately — so which of\n * the two lands first is not something a controller can rely on, and a rewind\n * written in `disconnect()` may reach only the DOM being thrown away. In the\n * other direction, `disconnect()` also fires on an in-page move (Stimulus tears\n * down and reconnects the same element), where rewinding would wipe a\n * legitimately in-progress interaction — a spinner mid-load would vanish. One\n * timing is unreliable, the other is too eager; `turbo:before-cache` is the only\n * point that is exactly \"the page is about to be frozen\".\n *\n * Scope is the subscription only: registering on `activate()`, unregistering on\n * `deactivate()`, and one shared document listener no matter how many instances\n * are live. *What* to return to its initial state — which `data-state`, which\n * `hidden`, which `aria-busy` — stays in the controller, because no two\n * consumers answer it the same way.\n *\n * **Rewind state, not appearance.** The pass writes attributes the controller\n * itself owns; the visual result of those attributes is the consumer's CSS, and\n * a library that reached for style or class names would be guessing at markup\n * it does not own.\n *\n * Both entry points are idempotent, so the lifecycle hooks can call them\n * unconditionally: a second `activate()` does not double-subscribe and does not\n * make the callback run twice, and `deactivate()` on an instance that never\n * subscribed is a no-op.\n *\n * This file's own doc block is dropped from `dist`, but every member comment is\n * inlined into each consumer entry (`tsup` builds with `splitting: false`), so\n * rationale belongs here and only the contract belongs on the members.\n *\n * @example\n * ```ts\n * readonly #beforeCache = new BeforeCacheReset(() => this.#rewind());\n *\n * connect() { this.#beforeCache.activate(); }\n * disconnect() { this.#beforeCache.deactivate(); }\n * ```\n */\nexport class BeforeCacheReset {\n /** Every subscribed instance, iterated by the one shared document listener. */\n static readonly #subscribers = new Set<BeforeCacheReset>();\n\n /** The shared listener; installed while at least one instance is subscribed. */\n static readonly #onBeforeCache = (): void => {\n for (const subscriber of BeforeCacheReset.#subscribers) subscriber.#rewind();\n };\n\n readonly #rewind: () => void;\n\n /** @param rewind - the pass that returns this controller's state to its initial form. */\n constructor(rewind: () => void) {\n this.#rewind = rewind;\n }\n\n /** Subscribes to `turbo:before-cache`; call from `connect()`. Idempotent. */\n activate(): void {\n const first = BeforeCacheReset.#subscribers.size === 0;\n BeforeCacheReset.#subscribers.add(this);\n if (first) {\n document.addEventListener(\"turbo:before-cache\", BeforeCacheReset.#onBeforeCache);\n }\n }\n\n /** Unsubscribes; call from `disconnect()`. Safe when never subscribed. */\n deactivate(): void {\n BeforeCacheReset.#subscribers.delete(this);\n if (BeforeCacheReset.#subscribers.size > 0) return;\n document.removeEventListener(\"turbo:before-cache\", BeforeCacheReset.#onBeforeCache);\n }\n}\n","/** 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/** 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\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 * @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 readonly #activeTargets = new Set<EventTarget>();\n readonly #onStart: ((event: Event) => void) | undefined;\n readonly #onEnd: ((event: Event) => void) | undefined;\n /** The field whose confirming `input` is still owed, while the window is open. */\n #confirmedTarget: EventTarget | null = null;\n\n constructor(options: CompositionTrackerOptions = {}) {\n this.#onStart = options.onStart;\n this.#onEnd = options.onEnd;\n }\n\n /** Starts lifecycle tracking for `target`; repeated calls are idempotent. */\n observe(target: EventTarget): void {\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);\n this.#observedTargets.add(target);\n }\n\n /** Stops tracking one target and clears any active composition it owned. */\n unobserve(target: EventTarget): void {\n if (!this.#observedTargets.delete(target)) return;\n target.removeEventListener(\"compositionstart\", this.#handleStart);\n target.removeEventListener(\"compositionend\", this.#handleEnd);\n target.removeEventListener(\"keydown\", this.#handleKeydown);\n this.#activeTargets.delete(target);\n if (this.#confirmedTarget === target) this.#confirmedTarget = null;\n }\n\n /** Releases every listener and clears state so reconnect starts cleanly. */\n disconnect(): void {\n for (const target of this.#observedTargets) {\n target.removeEventListener(\"compositionstart\", this.#handleStart);\n target.removeEventListener(\"compositionend\", this.#handleEnd);\n target.removeEventListener(\"keydown\", this.#handleKeydown);\n }\n this.#observedTargets.clear();\n this.#activeTargets.clear();\n this.#confirmedTarget = null;\n }\n\n /** True when lifecycle tracking or the current event reports composition. */\n isComposing(event?: CompositionSignal): boolean {\n return this.#activeTargets.size > 0 || event?.isComposing === true;\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 || COMPOSITION_INPUT_TYPES.has(inputType);\n }\n\n readonly #handleStart = (event: Event): void => {\n this.#confirmedTarget = null;\n if (event.currentTarget) this.#activeTargets.add(event.currentTarget);\n this.#onStart?.(event);\n };\n\n readonly #handleEnd = (event: Event): void => {\n if (event.currentTarget) this.#activeTargets.delete(event.currentTarget);\n this.#confirmedTarget = event.target;\n this.#onEnd?.(event);\n };\n\n /** A key on an observed field opens an edit of its own, so no echo is owed. */\n readonly #handleKeydown = (): void => {\n this.#confirmedTarget = null;\n };\n}\n","/**\n * Readers for the String Values whose text can only be checked by handing it to\n * a parser: a CSS selector, a regular-expression source, a JSON object.\n *\n * Stimulus reads each of them as an ordinary string, so the controller connects\n * and the flaw surfaces later, inside the first handler that consumes the value\n * (a `SyntaxError` from `new RegExp`, a `DOMException` from the selector engine),\n * where it takes the whole handler down on every event. Parsing here, once, in\n * the `<name>ValueChanged` callback keeps the failure local to the declaration:\n * an unreadable value falls back to its default, the element stays alive, and\n * the hot path only ever receives a value that parsed.\n *\n * Which default a broken declaration falls back to is the caller's contract, so\n * every reader takes (or returns) the fallback rather than choosing one.\n */\n\n/**\n * The result of `parse(raw)`, or `fallback` when `parse` throws.\n *\n * Any exception counts as \"does not parse\": the parsers these Values feed\n * (`RegExp`, `JSON.parse`, the selector engine) all report a malformed input by\n * throwing, and none of them throws for another reason.\n */\nexport function parseDeclared<T>(raw: string, parse: (raw: string) => T, fallback: T): T {\n try {\n return parse(raw);\n } catch {\n return fallback;\n }\n}\n\n/** What {@link validSelector} needs of the element it probes with. */\nexport interface SelectorProbe {\n matches(selector: string): boolean;\n}\n\n/**\n * `raw` when it is a non-empty selector the DOM accepts, otherwise `fallback`.\n *\n * `element.matches` is the probe: the engine parses the selector and throws for\n * one it cannot read. Whether the selector actually matches `element` plays no\n * part, so a selector aimed at another element still passes.\n *\n * The parameter names the one method the probe uses rather than `Element`, so\n * this module carries no DOM type and the readers below stay importable from\n * the Node-side Inspector, which checks the same declarations statically.\n */\nexport function validSelector(element: SelectorProbe, raw: string, fallback: string): string {\n if (raw.length === 0) return fallback;\n return parseDeclared(\n raw,\n (selector) => {\n element.matches(selector);\n return selector;\n },\n fallback,\n );\n}\n\n/** How `compileRegExp` wraps a source before compiling it. */\nexport type RegExpAnchor = \"none\" | \"exact\";\n\n/**\n * `source` compiled as a `RegExp`, or `null` when it does not compile.\n *\n * `\"exact\"` wraps the source as `^(?:source)$`, so the whole input has to match\n * and an alternation inside the source cannot escape the anchors. The source is\n * compiled on its own first, because an unbalanced source can be made to parse\n * by the wrapper's own parentheses — `0)|(1` becomes `^(?:0)|(1)$` — which would\n * accept a declaration that is not a regular expression and leave half of it\n * outside the anchors. The default that replaces a broken source is the\n * caller's, so `null` is returned rather than a fallback pattern.\n */\nexport function compileRegExp(source: string, anchor: RegExpAnchor = \"none\"): RegExp | null {\n return parseDeclared(\n source,\n (text) => {\n const bare = new RegExp(text);\n return anchor === \"exact\" ? new RegExp(`^(?:${text})$`) : bare;\n },\n null,\n );\n}\n\n/**\n * The JSON object `raw` declares, or `null` when the text does not parse or\n * parses to something other than a plain object (`null`, an array, a scalar).\n * Values are returned as parsed; narrowing them is the caller's contract.\n */\nexport function parseJsonObject(raw: string): Record<string, unknown> | null {\n const parsed = parseDeclared<unknown>(raw, (text) => JSON.parse(text), null);\n if (parsed === null || typeof parsed !== \"object\" || Array.isArray(parsed)) return null;\n return parsed as Record<string, unknown>;\n}\n","/**\n * Runs a controller's reconciliation pass after a native form reset has\n * restored the form's own controls.\n *\n * **A microtask alone is not \"after the reset\", and the reason is where the\n * dispatch came from.** `form.reset()` fires the event and restores the\n * controls inside one script frame, so a microtask queued from a listener lands\n * after both. A reset the user triggers — activating a `reset` button — is\n * dispatched by the browser with an empty script stack, so the microtask\n * checkpoint runs the moment the listener returns: still inside the dispatch,\n * before the controls are restored and before a later listener has had its\n * chance to cancel. Reconciling there reads the pre-reset values and treats a\n * cancelled reset as a real one.\n *\n * The event itself tells the two origins apart. `eventPhase` returns to\n * `Event.NONE` at the end of dispatch, so a microtask that sees `NONE` is\n * already past the default action and settles on the spot — that is the\n * scripted path, and its timing is exactly a microtask. A microtask\n * that still sees a dispatch phase is the browser-driven path and settles on\n * the next animation frame instead: the default action completes before that\n * frame, and `defaultPrevented` has reached its final value. A frame is only\n * ever reached from a real user interaction, which requires a rendered\n * document, so the frame cannot starve.\n *\n * Pending frames are held per handle rather than collapsed into one slot: a set\n * needs no branch to stay accurate, and every handle in it is cancellable at\n * teardown.\n *\n * Scope is the timing and the ownership test only. *What* to reconcile — an\n * aggregate, a visibility pass, a re-read of every field — stays in the\n * controller, because no two consumers answer it the same way. Ownership stays\n * there too: a control associated through `form=` is reached by the consumer's\n * own `control.form` read.\n *\n * This file's own doc block is dropped from `dist`, but every member comment is\n * inlined into each consumer entry (`tsup` builds with `splitting: false`), so\n * rationale belongs here and only the contract belongs on the members.\n *\n * @example\n * ```ts\n * readonly #formReset = new FormResetWatcher(\n * (form) => this.fieldTargets.some((field) => field.form === form),\n * () => this.#reconcile.schedule(),\n * );\n *\n * connect() { this.#formReset.observe(); }\n * disconnect() { this.#formReset.disconnect(); }\n * ```\n */\nexport class FormResetWatcher {\n readonly #owns: (form: HTMLFormElement) => boolean;\n readonly #onReset: () => void;\n readonly #frames = new Set<number>();\n #generation = 0;\n\n /**\n * @param owns - whether `form` owns a control this controller derives from.\n * @param onReset - the reconciliation pass, run once per honoured reset.\n */\n constructor(owns: (form: HTMLFormElement) => boolean, onReset: () => void) {\n this.#owns = owns;\n this.#onReset = onReset;\n }\n\n /** Subscribes to `reset` at the document; call from `connect()`. Idempotent. */\n observe(): void {\n document.addEventListener(\"reset\", this.#handleReset, true);\n }\n\n /** Unsubscribes and drops every pending pass; call from `disconnect()`. */\n disconnect(): void {\n document.removeEventListener(\"reset\", this.#handleReset, true);\n this.#generation += 1;\n for (const frame of this.#frames) cancelAnimationFrame(frame);\n this.#frames.clear();\n }\n\n readonly #handleReset = (event: Event): void => {\n const form = event.target;\n if (!(form instanceof HTMLFormElement) || !this.#owns(form)) return;\n const generation = this.#generation;\n queueMicrotask(() => {\n // A pass queued before teardown must not reach a disconnected controller.\n if (generation !== this.#generation) return;\n if (event.eventPhase === Event.NONE) {\n this.#settle(event);\n return;\n }\n const frame = requestAnimationFrame(() => {\n this.#frames.delete(frame);\n this.#settle(event);\n });\n this.#frames.add(frame);\n });\n };\n\n /** Runs the pass unless a listener cancelled the reset before it landed. */\n #settle(event: Event): void {\n if (!event.defaultPrevented) this.#onReset();\n }\n}\n","/** The distance between a full-width ASCII code point and its half-width twin. */\nconst FULL_WIDTH_SHIFT = 0xfee0;\n\n/**\n * The half-width form of `char`, or `char` itself when it has none.\n *\n * An IME confirming in full-width mode produces U+FF01–U+FF5E (and U+3000 for\n * the space) where the page means ASCII — the digits of a phone number, the\n * letters of a code, the separators between them. Reading those as their ASCII\n * equivalents keeps confirmed text usable instead of discarding it. Characters\n * outside that block, including kana and astral code points, are returned\n * unchanged, so this never rewrites text a consumer meant to keep as typed.\n */\nexport function halfWidthChar(char: string): string {\n if (char >= \"!\" && char <= \"~\") {\n return String.fromCharCode(char.charCodeAt(0) - FULL_WIDTH_SHIFT);\n }\n return char === \" \" ? \" \" : char;\n}\n\n/** Every full-width ASCII character in `text` rewritten by {@link halfWidthChar}. */\nexport function toHalfWidth(text: string): string {\n let out = \"\";\n for (const char of text) out += halfWidthChar(char);\n return out;\n}\n","/**\n * Collapses many Stimulus lifecycle callbacks from one DOM mutation into a\n * single pass.\n *\n * Stimulus fires `<name>TargetConnected` / `Disconnected` once per element and\n * `<name>ValueChanged` once per changed attribute. Replacing a list of N options\n * or morphing several render Values therefore delivers N callbacks — but the\n * useful unit of work is \"reconcile against the resulting declarative input\",\n * once, after the batch has settled. Every controller with reconcilable targets\n * or render Values needs the same shape: a `queued` flag plus `queueMicrotask`.\n *\n * **A microtask is the right horizon, and the reason is specific.** Stimulus\n * drives these callbacks from a `MutationObserver`, whose own callback already\n * runs as a microtask with the whole batch in hand; scheduling one more lands\n * after the last sibling callback of that batch and still before paint or any\n * event handler. A timer would be later than it needs to be, and reconciling\n * synchronously would run once per element against a half-applied DOM.\n *\n * **The two guards are not the same guard.** Scheduling is refused before the\n * controller connects, and running is refused after it disconnects:\n *\n * - **Before `connect()`** — Stimulus delivers initial target and Value callbacks\n * ahead of `connect()`. Reconciling there would compute output against a\n * controller whose own state has not been initialised, and `connect()` is\n * about to do a full pass anyway.\n * - **After `disconnect()`** — Stimulus fires a callback for **every** target\n * during teardown, and a microtask queued just before it would otherwise run\n * against a detached tree. {@link MicrotaskCoalescer.cancel} exists for the\n * teardown path to drop the pending pass outright.\n *\n * Both guards are part of one contract here rather than something each consumer\n * has to remember separately.\n *\n * Scope is the scheduling only. *What* to reconcile — keep the surviving active\n * option, fall back to the next / previous / first visible one, rebuild derived\n * chips or hidden fields — stays in the controller, because no two consumers\n * answer it the same way.\n *\n * This file's own doc block is dropped from `dist`, but every member comment is\n * inlined into each consumer entry (`tsup` builds with `splitting: false`), so\n * rationale belongs here and only the contract belongs on the members.\n *\n * @example\n * ```ts\n * readonly #reconcile = new MicrotaskCoalescer(() => this.#reconcileOptions());\n *\n * connect() { this.#reconcile.activate(); }\n * disconnect() { this.#reconcile.cancel(); }\n *\n * optionTargetConnected() { this.#reconcile.schedule(); }\n * optionTargetDisconnected() { this.#reconcile.schedule(); }\n * ```\n */\nexport class MicrotaskCoalescer {\n readonly #run: () => void;\n #queued = false;\n #active = false;\n #generation = 0;\n\n /** @param run - the single reconciliation pass, invoked at most once per batch. */\n constructor(run: () => void) {\n this.#run = run;\n }\n\n /** Opens the window in which {@link schedule} is honoured; call from `connect()`. */\n activate(): void {\n this.#active = true;\n }\n\n /** Closes the window and drops any pending pass; call from `disconnect()`. */\n cancel(): void {\n this.#active = false;\n this.#queued = false;\n this.#generation += 1;\n }\n\n /** Requests one pass after the batch settles. Idempotent; inert outside the window. */\n schedule(): void {\n if (!this.#active || this.#queued) return;\n this.#queued = true;\n const generation = this.#generation;\n queueMicrotask(() => {\n // A cancelled callback must not consume a pass queued after reconnect.\n if (generation !== this.#generation || !this.#queued || !this.#active) return;\n this.#queued = false;\n this.#run();\n });\n }\n}\n","import { Controller } from \"@hotwired/stimulus\";\nimport { ensureId } from \"../utils/aria_ids\";\nimport { isReservedArrowChord, logicalArrowKey } from \"../utils/arrow_step\";\nimport { AttributeLease } from \"../utils/attribute_lease\";\nimport { BeforeCacheReset } from \"../utils/before_cache_reset\";\nimport { CompositionTracker } from \"../utils/composition_tracker\";\nimport { compileRegExp } from \"../utils/declared_value\";\nimport { FormResetWatcher } from \"../utils/form_reset_watcher\";\nimport { toHalfWidth } from \"../utils/half_width\";\nimport { MicrotaskCoalescer } from \"../utils/microtask_coalescer\";\n\n/** The error attributes this component writes on each field while input is rejected. */\ntype ErrorAttribute = \"aria-invalid\" | \"aria-errormessage\" | \"aria-describedby\";\n\n/**\n * Each error attribute's lease, kept on the field itself.\n *\n * `AttributeLease` keeps its records in memory, which the connection that adopts\n * a restored DOM does not have. These records travel with the markup instead,\n * so any connection can give the authored value back — and only while the\n * attribute still holds what this component last wrote there, so a value a\n * consumer changed in the meantime is theirs and stays.\n */\nconst LEASE_MARKERS: Readonly<Record<ErrorAttribute, string>> = {\n \"aria-invalid\": \"data-otp-invalid-lease\",\n \"aria-errormessage\": \"data-otp-errormessage-lease\",\n \"aria-describedby\": \"data-otp-describedby-lease\",\n};\n\n/** What an error attribute carried before this component wrote it, and what it wrote. */\ninterface ErrorLease {\n readonly authored: string | null;\n readonly written: string;\n}\n\n/** Whether a parsed marker holds a lease this component could have recorded. */\nfunction isErrorLease(value: unknown): value is ErrorLease {\n const lease = value as Partial<Record<keyof ErrorLease, unknown>> | null;\n return (\n typeof lease?.written === \"string\" &&\n (lease.authored === null || typeof lease.authored === \"string\")\n );\n}\n\n/** Reads the lease a field carries; a marker holding anything else is not one. */\nfunction readLease(field: Element, marker: string): ErrorLease | null {\n try {\n const parsed: unknown = JSON.parse(field.getAttribute(marker) ?? \"null\");\n return isErrorLease(parsed) ? parsed : null;\n } catch {\n return null;\n }\n}\n\n/** The field's own description tokens with the error id appended once. */\nfunction describedByWith(described: string | null, errorId: string): string {\n const tokens = (described ?? \"\")\n .split(/\\s+/)\n .filter((token) => token.length > 0 && token !== errorId);\n return [...tokens, errorId].join(\" \");\n}\n\n/** Single-character pattern used when a `pattern` declaration cannot compile. */\nconst DEFAULT_PATTERN = \"[0-9]\";\n\n/**\n * {@link DEFAULT_PATTERN} compiled, in the same whole-input form\n * `compileRegExp(…, \"exact\")` produces. A literal character class always\n * compiles, so the fallback is a value rather than another parse.\n */\nconst DEFAULT_MATCHER = new RegExp(`^(?:${DEFAULT_PATTERN})$`);\n\n/** Whether a press carries a modifier, which makes it the document's to handle. */\nfunction hasModifier(event: KeyboardEvent): boolean {\n return event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;\n}\n\n/**\n * The controller-derived state a consumer can observe.\n *\n * The combined value alone does not identify it: the same string spread over a\n * different number of fields reads as a different `data-state`, so completeness\n * is carried alongside the value rather than inferred from it.\n */\ninterface OtpState {\n readonly value: string;\n readonly state: string;\n}\n\n/** Compares exactly the derived state the root publishes. */\nfunction statesDiffer(left: OtpState, right: OtpState): boolean {\n return left.value !== right.value || left.state !== right.state;\n}\n\n/**\n * Headless, accessible One-Time Password / PIN input logic.\n *\n * Markup contract (identifier: `stimeo--otp`):\n * <div data-controller=\"stimeo--otp\"\n * data-stimeo--otp-pattern-value=\"[0-9]\"\n * role=\"group\" aria-label=\"One-time passcode\">\n * <input data-stimeo--otp-target=\"field\" inputmode=\"numeric\" maxlength=\"1\"\n * autocomplete=\"one-time-code\" aria-label=\"Digit 1\"\n * data-action=\"input->stimeo--otp#onInput\n * keydown->stimeo--otp#onKeydown\n * paste->stimeo--otp#onPaste\n * pointerdown->stimeo--otp#onPointerDown\" />\n * <!-- repeat one field per digit -->\n * <p data-stimeo--otp-target=\"error\" hidden>Digits only.</p>\n * <input type=\"hidden\" data-stimeo--otp-target=\"value\" name=\"otp\" />\n * </div>\n *\n * The passcode length is the number of connected `field` targets, so nothing has\n * to declare it twice and fields added or removed at runtime are absorbed.\n *\n * Entry rules:\n * - Text carrying more than one accepted character — an OS `one-time-code`\n * autofill, a password manager, an IME committing several digits, a paste —\n * is spread across the following writable fields from the entry point.\n * - `disabled` and `readonly` fields keep their value: they are never written\n * and never receive auto-advance focus, matching what the platform allows a\n * user to do by hand.\n * - Input that lands nowhere rolls the field back to the digit it last\n * committed, and is the only thing that reports `invalid` or reveals the\n * `error` target. Discarding a separator inside otherwise usable text\n * (`\"1234-56\"`) is a successful entry.\n * - Pointing at an empty field ahead of an earlier empty one lands on the\n * earliest empty field instead, so a passcode fills in order. Keyboard focus\n * is never redirected.\n *\n * `change` and `complete` dispatch `{ value: string }` and fire only when the\n * combined value actually moves — one confirmed IME character emits one event,\n * and a passcode re-completed with a different digit reports the new value.\n * State moved by adding or removing fields, by a `pattern` change dropping\n * entered digits it no longer accepts, or by a native form reset restoring the\n * fields is not an edit of the passcode, so it is reported as `reconcile` with\n * the same `{ value: string }` — once per change, after it settles — and never\n * as `change` or `complete`. While a field is composing, the IME's uncommitted\n * text is neither read nor written: a change already in the DOM — fields added\n * or removed, a reset — is reported at once, counting that field by the\n * character it had committed, while a `pattern` change's drop waits for the\n * composition to end and is then applied and reported before the commit is\n * taken. A composition that ends on the text the field held when it began was\n * cancelled: no edit, so it reports nothing and focus stays.\n * Completeness belongs to that state: dropping a trailing empty field completes\n * a passcode whose combined value never moved, and that transition is reported\n * too, so a consumer reading `data-state` is never left behind a silent move.\n * `invalid` dispatches `{ pattern: string }` carrying the compiled pattern.\n *\n * Controller-owned output: `data-filled` on each entered field, `data-state`\n * (`empty` / `partial` / `complete`) on the root, and — while input is being\n * reported invalid — `aria-invalid`, `aria-errormessage`, `aria-describedby`,\n * and the `error` target's `hidden`. Authored values return on teardown and\n * before the page is cached: the three ARIA attributes keep their lease on the\n * field itself, so a connection that adopts a restored DOM can give them back\n * too, and the `hidden` is leased.\n *\n * @remarks\n * Behavior only. `connect()` reads the fields back as the source of truth, which\n * is what restores consistency after a `type=\"password\"` field returns from the\n * Turbo cache emptied; a native form reset is read back the same way once the\n * browser has restored the fields. A `pattern` that cannot compile falls back to\n * `[0-9]`; the compiled matcher is built once per declaration rather than per\n * keystroke.\n */\nexport class OtpController extends Controller<HTMLElement> {\n static override targets = [\"field\", \"value\", \"error\"];\n static override values = {\n pattern: { type: String, default: DEFAULT_PATTERN },\n };\n static actions = [\"onInput\", \"onKeydown\", \"onPaste\", \"onPointerDown\", \"clear\"] as const;\n static events = [\"change\", \"complete\", \"invalid\", \"reconcile\"] as const;\n\n declare readonly fieldTargets: HTMLInputElement[];\n declare readonly valueTarget: HTMLInputElement;\n declare readonly errorTarget: HTMLElement;\n declare readonly hasValueTarget: boolean;\n declare readonly hasErrorTarget: boolean;\n\n declare patternValue: string;\n\n /** Validated matcher; the hot path never compiles a raw declaration. */\n #pattern = DEFAULT_MATCHER;\n /** Source of {@link #pattern}, reported in `invalid` so consumers can word it. */\n #patternSource = DEFAULT_PATTERN;\n /** Public state carried by the last dispatch; keeps a no-op sync silent. */\n #published: OtpState | null = null;\n /** True between connect and disconnect, so pre-connect Value changes stay silent. */\n #connected = false;\n /** Digit each field last committed, restored when rejected input replaced it. */\n readonly #committed = new WeakMap<HTMLInputElement, string>();\n /** The field being composed, and the text it held when the composition began. */\n #composing: { readonly field: HTMLInputElement; readonly before: string } | null = null;\n /** A `pattern` change whose rejected characters wait for the composition to end. */\n #dropHeld = false;\n\n /**\n * Collapses one batch of page changes — field target and `pattern` callbacks, a\n * form reset — into a single reconciliation.\n */\n readonly #reconcile = new MicrotaskCoalescer(() => this.#reconcileFields());\n\n readonly #errorHidden = new AttributeLease<HTMLElement>(\"hidden\");\n readonly #state = new AttributeLease<HTMLElement>(\"data-state\");\n\n /** Rewinds the transient error surface before Turbo freezes the page. */\n readonly #beforeCache = new BeforeCacheReset(() => this.#clearError());\n /** Reads the fields back once a native reset restored them, as a reconciliation. */\n readonly #formReset = new FormResetWatcher(\n (form) => this.#ownedBy(form),\n () => {\n this.#adopt();\n this.#reconcile.schedule();\n },\n );\n\n /**\n * Owns IME lifecycle state across every digit field. When a composition ends, a\n * `pattern` drop it held back applies first — it was declared first — and the\n * user's commit is taken after it.\n */\n readonly #composition = new CompositionTracker({\n onStart: (event) => {\n const field = this.#fieldFrom(event);\n if (field) this.#composing = { field, before: field.value };\n },\n onEnd: (event) => {\n const composing = this.#composing;\n this.#composing = null;\n const input = this.#fieldFrom(event);\n // `maxlength` has already cut the field down to one character, but the\n // commit itself carries the whole confirmed string — so a conversion that\n // ends in several characters still reaches the fields after this one.\n const data = (event as CompositionEvent).data ?? \"\";\n const text = input && data.length <= input.value.length ? input.value : data;\n // A composition that ends on the text the field held when it began was\n // cancelled: the user entered nothing, so there is nothing to take.\n const commit = input !== null && (composing?.field !== input || text !== composing.before);\n if (this.#dropHeld) {\n // The drop judges what the fields had committed; the commit waits aside.\n if (input && commit) input.value = this.#committed.get(input) ?? \"\";\n this.#reconcileFields();\n }\n if (input && commit) this.#accept(input, text);\n },\n });\n\n override connect(): void {\n this.#connected = true;\n for (const field of this.fieldTargets) this.#bind(field);\n this.#formReset.observe();\n this.#beforeCache.activate();\n this.#reconcile.activate();\n this.#adopt();\n this.#sync();\n }\n\n override disconnect(): void {\n this.#connected = false;\n for (const field of this.fieldTargets) this.#unbind(field);\n this.#composition.disconnect();\n this.#formReset.disconnect();\n this.#beforeCache.deactivate();\n this.#reconcile.cancel();\n // A drop a composition held goes with the connection, like a pending pass.\n this.#dropHeld = false;\n this.#clearError();\n this.#state.return(this.element);\n }\n\n /**\n * Stimulus lifecycle callback when a new field target enters the DOM.\n * Wires the new field and folds the wider digit count into one reconciliation,\n * which stays inert until `connect()` opens the window.\n */\n fieldTargetConnected(element: HTMLInputElement): void {\n this.#bind(element);\n this.#adoptField(element);\n this.#reconcile.schedule();\n }\n\n /** Releases a dropped field's listeners and leases, then reconciles the rest. */\n fieldTargetDisconnected(element: HTMLInputElement): void {\n this.#unbind(element);\n this.#returnLeases(element);\n this.#reconcile.schedule();\n }\n\n /**\n * Re-validates a changed `pattern` declaration once and drops any entered digit\n * the new pattern no longer accepts, so the combined value stays interpretable.\n * The page changed the declaration, so the move joins the same reconciliation\n * as fields added or removed in that mutation. While a field is composing, its\n * text is the IME's, and the drop waits for the composition to end.\n */\n patternValueChanged(): void {\n const compiled = compileRegExp(this.patternValue, \"exact\");\n this.#patternSource = compiled ? this.patternValue : DEFAULT_PATTERN;\n this.#pattern = compiled ?? DEFAULT_MATCHER;\n if (!this.#connected) return;\n if (this.#composing !== null) {\n this.#dropHeld = true;\n return;\n }\n if (this.#dropRejected()) this.#reconcile.schedule();\n }\n\n /** Empties every writable field holding a character the pattern rejects; whether one did. */\n #dropRejected(): boolean {\n let dropped = false;\n for (const field of this.fieldTargets) {\n if (field.value === \"\" || !this.#isWritable(field)) continue;\n if (this.#pattern.test(field.value)) continue;\n this.#writeField(field, \"\");\n dropped = true;\n }\n return dropped;\n }\n\n /** Handles keystroke inputs, distributes autofilled text, and advances focus. */\n onInput(event: Event): void {\n const input = this.#fieldFrom(event);\n if (!input) return;\n\n // The browser may follow a commit with one more `input` carrying the same\n // text; running it again would spread the commit twice.\n if (this.#composition.consumesConfirmedInput(event)) return;\n\n // Guard during active composition to prevent premature focus switching\n if (this.#composition.isComposing(event as InputEvent)) return;\n\n this.#accept(input);\n }\n\n /** Handles Backspace clearing, arrows, and home/end navigation. */\n onKeydown(event: KeyboardEvent): void {\n if (isReservedArrowChord(event)) return;\n const input = this.#fieldFrom(event);\n if (!input) return;\n\n // Do not trigger keydown actions during composition\n if (this.#composition.isComposing(event)) return;\n\n const index = this.fieldTargets.indexOf(input);\n const fields = this.fieldTargets;\n // Logical, not physical. The key is normalised rather than the\n // delta negated: these two branches are not mirror images — their bounds\n // guards differ — so swapping the key keeps each guard with its own direction.\n\n switch (logicalArrowKey(event.key, this.element)) {\n case \"Backspace\":\n if (hasModifier(event)) break;\n if (input.value && this.#isWritable(input)) {\n // Filled field: clear it where it stands\n event.preventDefault();\n this.#writeField(input, \"\");\n this.#clearError();\n this.#syncAndDispatch();\n } else {\n // Empty field: step back to the previous writable digit and wipe it\n const previous = this.#writableBefore(index);\n if (previous) {\n event.preventDefault();\n this.#writeField(previous, \"\");\n previous.focus();\n this.#clearError();\n this.#syncAndDispatch();\n }\n }\n break;\n\n case \"ArrowLeft\": {\n const previous = this.#focusableBefore(index);\n if (previous) {\n event.preventDefault();\n previous.focus();\n }\n break;\n }\n\n case \"ArrowRight\": {\n const next = this.#focusableAfter(index);\n if (next) {\n event.preventDefault();\n next.focus();\n }\n break;\n }\n\n case \"Home\": {\n // Control+Home belongs to the document, not to the digit group\n if (hasModifier(event)) break;\n const first = fields.find((field) => this.#isFocusable(field));\n if (first) {\n event.preventDefault();\n first.focus();\n }\n break;\n }\n\n case \"End\": {\n if (hasModifier(event)) break;\n const last = fields\n .slice()\n .reverse()\n .find((field) => this.#isFocusable(field));\n if (last) {\n event.preventDefault();\n last.focus();\n }\n break;\n }\n\n default:\n break;\n }\n }\n\n /** Divides pasted string characters across the available input fields. */\n onPaste(event: ClipboardEvent): void {\n const input = this.#fieldFrom(event);\n if (!input) return;\n\n event.preventDefault();\n this.#distribute(input, toHalfWidth(event.clipboardData?.getData(\"text\") ?? \"\"));\n }\n\n /**\n * Redirects a pointer landing on an empty field to the earliest empty one, so\n * a passcode is entered in order. Filled fields stay directly reachable for\n * correction, and keyboard focus is left alone.\n */\n onPointerDown(event: Event): void {\n const input = this.#fieldFrom(event);\n if (input?.value !== \"\") return;\n\n const first = this.fieldTargets.find((field) => this.#isWritable(field) && field.value === \"\");\n if (!first || first === input) return;\n\n event.preventDefault();\n first.focus();\n }\n\n /** Empties every writable field and restarts entry at the first of them. */\n clear(): void {\n for (const field of this.fieldTargets) {\n if (this.#isWritable(field)) this.#writeField(field, \"\");\n }\n this.#clearError();\n this.fieldTargets.find((field) => this.#isWritable(field))?.focus();\n this.#syncAndDispatch();\n }\n\n readonly #onFieldFocus = (event: FocusEvent): void => {\n const input = event.currentTarget as HTMLInputElement | null;\n if (input) {\n // Auto-selection enables effortless character overwrites\n input.select();\n }\n };\n\n /** Whether a form owns at least one field or the hidden combined value. */\n #ownedBy(form: HTMLFormElement): boolean {\n if (this.fieldTargets.some((field) => field.form === form)) return true;\n return this.hasValueTarget && this.valueTarget.form === form;\n }\n\n #bind(field: HTMLInputElement): void {\n field.addEventListener(\"focus\", this.#onFieldFocus);\n this.#composition.observe(field);\n }\n\n #unbind(field: HTMLInputElement): void {\n field.removeEventListener(\"focus\", this.#onFieldFocus);\n this.#composition.unobserve(field);\n // A field that leaves mid-composition never ends that composition here.\n if (this.#composing?.field === field) this.#composing = null;\n }\n\n /** Reads every field back so a restored or reset group starts consistent. */\n #adopt(): void {\n for (const field of this.fieldTargets) this.#adoptField(field);\n this.#clearError();\n // Nothing has been rejected yet, whatever visibility the restored DOM carries\n if (this.hasErrorTarget) this.errorTarget.setAttribute(\"hidden\", \"\");\n }\n\n /** Writes one error attribute, keeping the first authored value it displaces. */\n #lease(field: HTMLInputElement, attribute: ErrorAttribute, value: string): void {\n const marker = LEASE_MARKERS[attribute];\n const held = readLease(field, marker);\n const authored = held ? held.authored : field.getAttribute(attribute);\n field.setAttribute(marker, JSON.stringify({ authored, written: value }));\n field.setAttribute(attribute, value);\n }\n\n /** Gives one field's error attributes back where they still hold what this wrote. */\n #returnLeases(field: HTMLInputElement): void {\n for (const [attribute, marker] of Object.entries(LEASE_MARKERS)) {\n const held = readLease(field, marker);\n if (!held) continue;\n field.removeAttribute(marker);\n if (field.getAttribute(attribute) !== held.written) continue;\n if (held.authored === null) field.removeAttribute(attribute);\n else field.setAttribute(attribute, held.authored);\n }\n }\n\n /** Takes one field's current value as the truth behind its derived state. */\n #adoptField(field: HTMLInputElement): void {\n this.#committed.set(field, field.value);\n this.#markFilled(field, field.value);\n }\n\n /**\n * Absorbs one batch of page changes — fields added or removed, entered digits a\n * new `pattern` rejects, fields a native form reset restored — as one state\n * transition.\n *\n * Nobody edited the passcode here, so the move is reported as `reconcile`:\n * automation listening for `change` must not read a re-render or a reset as an\n * edit, and a passcode that happens to end up full must not fire the\n * `complete` that submits it.\n *\n * Completeness moves on its own when the field count changes: dropping a\n * trailing empty field completes a passcode whose combined value never moved,\n * and adding one un-completes it. Comparing the whole derived state, not the\n * string it contains, is what makes those transitions reportable.\n *\n * A change already in the DOM — a field added or removed, a reset — is\n * published at once, even while a field is composing: that field counts by the\n * character it had committed, never by the IME's uncommitted text. Only a\n * `pattern` drop waits for the composition to end.\n */\n #reconcileFields(): void {\n if (this.#dropHeld && this.#composing === null) {\n this.#dropHeld = false;\n this.#dropRejected();\n }\n const previous = this.#published;\n const current = this.#sync();\n if (previous && !statesDiffer(previous, current)) return;\n this.dispatch(\"reconcile\", { detail: { value: current.value } });\n }\n\n /**\n * Validates the text an entry point received and distributes what it accepts.\n * `text` defaults to the field's own value; a confirmation passes the string it\n * committed, which `maxlength` would otherwise have truncated.\n */\n #accept(input: HTMLInputElement, text: string = input.value): void {\n const raw = toHalfWidth(text);\n if (raw === \"\") {\n // Emptying a field is a legitimate edit, not rejected input\n this.#writeField(input, \"\");\n this.#clearError();\n this.#syncAndDispatch();\n return;\n }\n\n this.#distribute(input, raw);\n }\n\n /**\n * Fills `text`'s accepted characters into the writable fields at and after the\n * entry point, then leaves focus on the field after the last one filled.\n */\n #distribute(from: HTMLInputElement, text: string): void {\n const accepted = Array.from(text).filter((char) => this.#pattern.test(char));\n let reached = false;\n const slots = this.fieldTargets.filter((field) => {\n reached ||= field === from;\n return reached && this.#isWritable(field);\n });\n const filled = Math.min(accepted.length, slots.length);\n\n if (filled === 0) {\n // Nothing landed: restore the digit the entry point had committed\n this.#restore(from);\n this.#showError();\n this.#sync();\n return;\n }\n\n for (let i = 0; i < filled; i++) {\n const field = slots[i];\n const char = accepted[i];\n if (field && char) this.#writeField(field, char);\n }\n\n const last = slots[filled - 1];\n if (last) (this.#writableAfter(last) ?? last).focus();\n\n this.#clearError();\n this.#syncAndDispatch();\n }\n\n /** Restores the digit a field committed before rejected input replaced it. */\n #restore(field: HTMLInputElement): void {\n this.#writeField(field, this.#committed.get(field) ?? \"\");\n }\n\n /** Commits one field's value and the derived hook that reports it as entered. */\n #writeField(field: HTMLInputElement, value: string): void {\n field.value = value;\n this.#committed.set(field, value);\n this.#markFilled(field, value);\n }\n\n #markFilled(field: HTMLInputElement, value: string): void {\n if (value) field.setAttribute(\"data-filled\", \"true\");\n else field.removeAttribute(\"data-filled\");\n }\n\n #isWritable(field: HTMLInputElement): boolean {\n return !field.disabled && !field.readOnly;\n }\n\n #isFocusable(field: HTMLInputElement): boolean {\n return !field.disabled;\n }\n\n #writableAfter(field: HTMLInputElement): HTMLInputElement | null {\n const fields = this.fieldTargets;\n return fields.slice(fields.indexOf(field) + 1).find((next) => this.#isWritable(next)) ?? null;\n }\n\n #writableBefore(index: number): HTMLInputElement | null {\n return this.#before(index).find((field) => this.#isWritable(field)) ?? null;\n }\n\n #focusableAfter(index: number): HTMLInputElement | null {\n return this.fieldTargets.slice(index + 1).find((field) => this.#isFocusable(field)) ?? null;\n }\n\n #focusableBefore(index: number): HTMLInputElement | null {\n return this.#before(index).find((field) => this.#isFocusable(field)) ?? null;\n }\n\n /** Fields before `index`, nearest first; empty at the first field. */\n #before(index: number): HTMLInputElement[] {\n return this.fieldTargets.slice(0, Math.max(index, 0)).reverse();\n }\n\n /** The event's field target, or `null` when the wiring points somewhere else. */\n #fieldFrom(event: Event): HTMLInputElement | null {\n const input = event.currentTarget;\n return this.fieldTargets.find((field) => field === input) ?? null;\n }\n\n #combinedValue(): string {\n return this.fieldTargets.map((field) => this.#publishedText(field)).join(\"\");\n }\n\n /** Every field carries a character, and there is at least one field. */\n #isComplete(): boolean {\n const fields = this.fieldTargets;\n return fields.length > 0 && fields.every((field) => this.#publishedText(field).length > 0);\n }\n\n /** A field's text as the combined value counts it: a composing field by its committed character. */\n #publishedText(field: HTMLInputElement): string {\n return field === this.#composing?.field ? (this.#committed.get(field) ?? \"\") : field.value;\n }\n\n /**\n * Mirrors the combined value into the form and the root's readable state, and\n * records what was published so the next pass can compare against it.\n */\n #sync(): OtpState {\n const combined = this.#combinedValue();\n\n if (this.hasValueTarget) {\n this.valueTarget.value = combined;\n }\n const state = this.#stateName(combined);\n this.#state.write(this.element, state);\n\n const published: OtpState = { value: combined, state };\n this.#published = published;\n return published;\n }\n\n #stateName(combined: string): string {\n if (combined.length === 0) return \"empty\";\n return this.#isComplete() ? \"complete\" : \"partial\";\n }\n\n #syncAndDispatch(): void {\n const previous = this.#published;\n const { value: combined } = this.#sync();\n if (previous?.value === combined) return;\n\n this.dispatch(\"change\", { detail: { value: combined } });\n\n // Completed state when every field carries a character\n if (this.#isComplete()) {\n this.dispatch(\"complete\", { detail: { value: combined } });\n }\n }\n\n /** Surfaces rejected input on every field and on the optional error target. */\n #showError(): void {\n const errorId = this.hasErrorTarget ? ensureId(this.errorTarget, \"stimeo--otp-error\") : null;\n\n for (const field of this.fieldTargets) {\n this.#lease(field, \"aria-invalid\", \"true\");\n if (!errorId) continue;\n this.#lease(field, \"aria-errormessage\", errorId);\n // Assistive tech without aria-errormessage support still reads a description\n const described = field.getAttribute(\"aria-describedby\");\n this.#lease(field, \"aria-describedby\", describedByWith(described, errorId));\n }\n if (this.hasErrorTarget) this.#errorHidden.write(this.errorTarget, null);\n\n // Behavior only: emit a neutral payload and let the consumer compose/localize\n // the user-facing message. The pattern is reported so consumers can word it.\n this.dispatch(\"invalid\", { detail: { pattern: this.#patternSource } });\n }\n\n /** Returns every error lease, restoring the authored error surface. */\n #clearError(): void {\n for (const field of this.fieldTargets) this.#returnLeases(field);\n this.#errorHidden.returnAll();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/shared_registry.ts","../../src/utils/aria_ids.ts","../../src/utils/logical_scroll.ts","../../src/utils/arrow_step.ts","../../src/utils/attribute_lease.ts","../../src/utils/composition_tracker.ts","../../src/utils/declared_value.ts","../../src/utils/form_reset_watcher.ts","../../src/utils/half_width.ts","../../src/utils/microtask_coalescer.ts","../../src/utils/move_counter.ts","../../src/controllers/otp_controller.ts"],"names":[],"mappings":";;AA4BO,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,MAAM,WAAW,MAAA,EAAO;AACxB,EAAA,MAAA,CAAO,eAAe,UAAA,EAAY,MAAA,EAAQ,EAAE,KAAA,EAAO,UAAU,CAAA;AAC7D,EAAA,OAAO,QAAA;AACT;;AChBA,IAAM,MAAM,cAAA,CAAe,gCAAA,EAAkC,OAAO,EAAE,OAAA,EAAS,GAAE,CAAE,CAAA;AAe5E,SAAS,QAAA,CAAS,SAAS,QAAA,EAAkB;AAClD,EAAA,IAAI,SAAA;AACJ,EAAA,GAAG;AACD,IAAA,GAAA,CAAI,OAAA,IAAW,CAAA;AACf,IAAA,SAAA,GAAY,CAAA,EAAG,MAAM,CAAA,CAAA,EAAI,GAAA,CAAI,OAAO,CAAA,CAAA;AAAA,EACtC,SAAS,OAAO,QAAA,KAAa,eAAe,QAAA,CAAS,cAAA,CAAe,SAAS,CAAA,KAAM,IAAA;AACnF,EAAA,OAAO,SAAA;AACT;AAYO,SAAS,QAAA,CAAS,OAAA,EAAkB,MAAA,GAAS,QAAA,EAAkB;AACpE,EAAA,IAAI,OAAA,CAAQ,EAAA,EAAI,OAAO,OAAA,CAAQ,EAAA;AAC/B,EAAA,MAAM,EAAA,GAAK,S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AAO,KAAK,CAAA;AAC1D,IAAA,IAAI,KAAA,EAAO,IAAA,CAAK,YAAA,CAAa,KAAA,CAAM,OAAO,EAAE,CAAA;AAAA,EAC9C;AACF","file":"otp_controller.js","sourcesContent":["/**\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 { sharedRegistry } from \"./shared_registry\";\n\n/**\n * Minimal id primitives for wiring ARIA relationships.\n *\n * Accessible relationships such as `aria-describedby`, `aria-errormessage`,\n * `aria-labelledby`, and `aria-activedescendant` reference their targets by DOM\n * `id`. When a controller must establish such a relationship but the consumer's\n * markup left the target without an `id`, it needs to mint one that is stable for\n * the page's lifetime and guaranteed not to collide with another generated id.\n *\n * These helpers own *only* id generation/assignment. The linking policy (which\n * attribute, what order, when to add or remove it) stays in each controller —\n * this deliberately avoids a premature generic \"ARIA linker\" abstraction.\n */\n\n/**\n * Monotonic counter backing {@link uniqueId}, shared by every entry copy so generated\n * ids are distinct even before their elements enter the document.\n */\nconst ids = sharedRegistry(\"stimeo-ui.aria-ids.registry.v1\", () => ({ counter: 0 }));\n\n/**\n * Returns a unique, DOM-id-safe string of the form `` `${prefix}-${n}` `` where\n * `n` increases on each call.\n *\n * The counter alone guarantees uniqueness against other *generated* ids, but a\n * consumer-authored element could already own `` `${prefix}-${n}` ``. When a\n * `document` is available the candidate is therefore advanced until no element\n * with that id exists, so a generated id never collides with author markup\n * either — the minimal \"id registry\" guarantee these helpers exist to provide.\n *\n * @param prefix - Leading segment of the id (e.g. a controller's identifier).\n * Defaults to `\"stimeo\"`.\n */\nexport function uniqueId(prefix = \"stimeo\"): string {\n let candidate: string;\n do {\n ids.counter += 1;\n candidate = `${prefix}-${ids.counter}`;\n } while (typeof document !== \"undefined\" && document.getElementById(candidate) !== null);\n return candidate;\n}\n\n/**\n * Returns `element`'s existing `id`, or assigns it a freshly generated\n * {@link uniqueId} (with the given `prefix`) and returns that. Idempotent: an\n * element that already has an id keeps it, so consumer-authored ids are never\n * overwritten.\n *\n * @param element - The element to read or stamp an `id` onto.\n * @param prefix - Prefix forwarded to {@link uniqueId} when one must be generated.\n * @returns The element's id (existing or newly assigned).\n */\nexport function ensureId(element: Element, prefix = \"stimeo\"): string {\n if (element.id) return element.id;\n const id = uniqueId(prefix);\n element.id = id;\n return id;\n}\n","/** Normalized scroll position and maximum distance on one logical axis. */\nexport interface LogicalScrollMetrics {\n position: number;\n max: number;\n}\n\n/**\n * Whether horizontal scrolling on `element` follows right-to-left inline flow.\n *\n * Resolved from the **computed** `direction`, so the authoring contract is the\n * usual `dir=\"rtl\"` (or a stylesheet) on the element or any ancestor.\n *\n * Scope: horizontal writing modes. A vertical writing mode (`writing-mode:\n * vertical-rl`) also inverts the horizontal axis, which this check does not\n * model — vertical writing modes are out of scope for the scroll utilities\n * (their consumers describe axes as horizontal/vertical, not inline/block).\n */\nexport function isRtl(element: Element): boolean {\n return window.getComputedStyle(element).direction === \"rtl\";\n}\n\n/**\n * Returns scroll distance from the logical start edge.\n *\n * CSSOM View exposes standards-mode RTL horizontal offsets as `0` at the inline\n * start (right) and increasingly negative values toward the inline end (left).\n * The normalized position is always clamped to `[0, max]`, which also absorbs\n * Safari's elastic overscroll values.\n */\nexport function logicalScrollMetrics(\n element: HTMLElement,\n horizontal: boolean,\n): LogicalScrollMetrics {\n const max = Math.max(\n 0,\n horizontal\n ? element.scrollWidth - element.clientWidth\n : element.scrollHeight - element.clientHeight,\n );\n const raw = horizontal ? element.scrollLeft : element.scrollTop;\n const position = horizontal && isRtl(element) ? -raw : raw;\n return { position: Math.min(max, Math.max(0, position)), max };\n}\n\n/**\n * Converts a logical start/end delta to the physical value accepted by\n * `Element.scrollBy`.\n */\nexport function physicalScrollDelta(\n element: HTMLElement,\n horizontal: boolean,\n logicalDelta: number,\n): number {\n return horizontal && isRtl(element) ? -logicalDelta : logicalDelta;\n}\n","import { isRtl } from \"./logical_scroll\";\n\n/**\n * Turns an arrow key into a **logical** step: `+1` for \"next\", `-1` for\n * \"previous\", `0` when the key names neither.\n *\n * APG defines the horizontal pair as *next / previous* and says a vertical\n * arrangement swaps in Down/Up for the same meaning — so the pair is one axis's\n * spelling of an order, and the order reverses with the writing direction. Only\n * the horizontal pair reverses. Down/Up name an axis the writing direction does\n * not mirror, and returning them unchanged is the point: many controllers fold\n * both pairs into one branch, where swapping the branches under RTL would flip\n * the vertical axis too — a bug that reads as \"the arrows work\" until someone\n * presses Down.\n *\n * **Direction is read from the element the caller passes, which should be the\n * container that lays the items out** — not the focused child. A child may carry\n * its own `dir` (an LTR input inside an RTL form is ordinary authoring), and\n * probing per handler makes two handlers disagree at the boundary between them.\n *\n * This decides direction only. Whether the axis is even active (an\n * `orientation=\"horizontal\"` widget ignoring Down/Up), how far the step lands,\n * and what wrapping does all stay with the caller.\n *\n * **It encodes the list-order convention: `ArrowDown` is *next*.** Widgets that\n * pair the arrows by *value* instead — `ArrowUp` meaning \"more\", as a rating or a\n * slider does — must not use this, or their vertical axis inverts. Reverse the\n * horizontal pair on its own there.\n *\n * @example\n * ```ts\n * const step = logicalArrowStep(event.key, this.element);\n * if (step === 0) return;\n * this.#roving.setActive(rovingMove(current, length, step, \"wrap\"), { focus: true });\n * ```\n */\nexport function logicalArrowStep(key: string, element: Element): 1 | -1 | 0 {\n if (key === \"ArrowDown\") return 1;\n if (key === \"ArrowUp\") return -1;\n if (key !== \"ArrowRight\" && key !== \"ArrowLeft\") return 0;\n const forward = isRtl(element) ? \"ArrowLeft\" : \"ArrowRight\";\n return key === forward ? 1 : -1;\n}\n\n/**\n * Rewrites `key` so an existing LTR-shaped branch keeps working under RTL:\n * `ArrowRight` and `ArrowLeft` trade places, everything else passes through.\n *\n * The alternative — negating a delta — silently breaks handlers whose two\n * horizontal branches are **not mirror images**. A grid that clamps one edge but\n * not the other, or a segmented field guarding `index > 0` on one side and\n * `index < length - 1` on the other, ends up applying the wrong guard to the\n * wrong direction. Swapping the key leaves each branch, guards and all, exactly\n * where its author put it.\n *\n * Same rule as {@link logicalArrowStep} about which element to read: pass the\n * container that lays the items out, not the focused child.\n *\n * @example\n * ```ts\n * switch (logicalArrowKey(event.key, this.element)) {\n * case \"ArrowLeft\": // \"previous\" — whatever direction that is on screen\n * ```\n */\nexport function logicalArrowKey(key: string, element: Element): string {\n if (key !== \"ArrowRight\" && key !== \"ArrowLeft\") return key;\n if (!isRtl(element)) return key;\n return key === \"ArrowRight\" ? \"ArrowLeft\" : \"ArrowRight\";\n}\n\n/** Modifiers a widget may claim on an arrow key, named for the `allow` list. */\nexport type ArrowModifier = \"alt\" | \"ctrl\" | \"meta\" | \"shift\";\n\n/**\n * True when an arrow key arrived carrying a modifier the widget must leave to\n * the browser: return without calling `preventDefault()` and without moving any\n * state.\n *\n * A bare arrow belongs to the widget; a chorded one usually does not.\n * `Alt`/`Meta` plus a horizontal arrow is history back/forward on every desktop\n * browser, and a widget that swallows it makes the shortcut work or not\n * depending on where focus happens to sit — a coin-flip the user cannot see.\n *\n * `allow` is for the combinations APG assigns to a pattern **and the widget\n * actually implements** — today only Combobox's optional `Alt+Down`/`Alt+Up`.\n * Listing one the widget does not implement defeats the point: the chord then\n * runs the plain-arrow branch, which is exactly what this guard exists to stop.\n * Non-arrow keys return `false`, so chorded letters and\n * `Control+Home`/`Control+End` are untouched.\n *\n * @example\n * ```ts\n * if (isReservedArrowChord(event)) return;\n * ```\n */\nexport function isReservedArrowChord(\n event: KeyboardEvent,\n allow: readonly ArrowModifier[] = [],\n): boolean {\n if (!event.key.startsWith(\"Arrow\")) return false;\n return (\n (event.altKey && !allow.includes(\"alt\")) ||\n (event.ctrlKey && !allow.includes(\"ctrl\")) ||\n (event.metaKey && !allow.includes(\"meta\")) ||\n (event.shiftKey && !allow.includes(\"shift\"))\n );\n}\n\n/**\n * True when a press arrived carrying any modifier, for the keys the browser and\n * the OS own outright: return without calling `preventDefault()` and without\n * moving any state.\n *\n * `Control+Home` and `Control+End` jump the document to its ends, and a widget\n * that swallows them makes the shortcut work or not depending on where focus\n * happens to sit. {@link isReservedArrowChord} answers the same question for the\n * arrows, but returns `false` for every other key so that this one can decide.\n *\n * There is no `allow` list here on purpose. APG assigns no modifier chord to\n * `Home`/`End`, so a widget that wanted one would be claiming a combination the\n * pattern never gave it.\n *\n * @example\n * ```ts\n * case \"Home\":\n * case \"End\":\n * if (hasModifierChord(event)) return;\n * ```\n */\nexport function hasModifierChord(event: KeyboardEvent): boolean {\n return event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;\n}\n","import { 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/** 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/**\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 /** The holds on each element, bottom first, and the record names; one per page. */\n static readonly #registry = sharedRegistry(\n \"stimeo-ui.attribute-lease.registry.v1\",\n (): AttributeLeaseRegistry => ({ stacks: new WeakMap(), names: new Map() }),\n );\n readonly #attribute: string;\n readonly #record: string;\n readonly #base: 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 */\n constructor(attribute: string, owner: string, options: { readonly base?: boolean } = {}) {\n this.#attribute = attribute;\n this.#record = `data-${owner}-${attribute}-lease`;\n this.#base = options.base === true;\n const names = AttributeLease.#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 = this.#stack(element);\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 = AttributeLease.#registry.stacks.get(element)?.has(this.#attribute);\n const stack = held || known || element.hasAttribute(this.#record) ? this.#stack(element) : [];\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 /** The element's stack, read from its records the first time. */\n #stack(element: T): AttributeHold[] {\n const stacks = AttributeLease.#registry.stacks;\n const byAttribute = stacks.get(element) ?? new Map<string, AttributeHold[]>();\n stacks.set(element, byAttribute);\n const stack = byAttribute.get(this.#attribute) ?? this.#seed(element);\n byAttribute.set(this.#attribute, stack);\n return stack;\n }\n\n /** The holds a copy's records describe, each above every hold its record lists beneath. */\n #seed(element: T): AttributeHold[] {\n const found: (AttributeLeaseRecord & { readonly record: string })[] = [];\n for (const record of AttributeLease.#registry.names.get(this.#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 return 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 }\n\n /** Its hold in `stack`, taking over one read from its record. */\n #take(stack: AttributeHold[]): AttributeHold | undefined {\n const hold =\n stack.find((held) => held.lease === this) ??\n stack.find((held) => held.lease === null && held.record === 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 ? bottom : 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 if (element.getAttribute(name) === recorded) continue;\n if (recorded === null) element.removeAttribute(name);\n else element.setAttribute(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 if (element.getAttribute(this.#attribute) === value) return;\n if (value === null) element.removeAttribute(this.#attribute);\n else element.setAttribute(this.#attribute, value);\n }\n}\n","/** 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/** 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\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 * @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 readonly #activeTargets = new Set<EventTarget>();\n readonly #onStart: ((event: Event) => void) | undefined;\n readonly #onEnd: ((event: Event) => void) | undefined;\n /** The field whose confirming `input` is still owed, while the window is open. */\n #confirmedTarget: EventTarget | null = null;\n\n constructor(options: CompositionTrackerOptions = {}) {\n this.#onStart = options.onStart;\n this.#onEnd = options.onEnd;\n }\n\n /** Starts lifecycle tracking for `target`; repeated calls are idempotent. */\n observe(target: EventTarget): void {\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);\n this.#observedTargets.add(target);\n }\n\n /** Stops tracking one target and clears any active composition it owned. */\n unobserve(target: EventTarget): void {\n if (!this.#observedTargets.delete(target)) return;\n target.removeEventListener(\"compositionstart\", this.#handleStart);\n target.removeEventListener(\"compositionend\", this.#handleEnd);\n target.removeEventListener(\"keydown\", this.#handleKeydown);\n this.#activeTargets.delete(target);\n if (this.#confirmedTarget === target) this.#confirmedTarget = null;\n }\n\n /** Releases every listener and clears state so reconnect starts cleanly. */\n disconnect(): void {\n for (const target of this.#observedTargets) {\n target.removeEventListener(\"compositionstart\", this.#handleStart);\n target.removeEventListener(\"compositionend\", this.#handleEnd);\n target.removeEventListener(\"keydown\", this.#handleKeydown);\n }\n this.#observedTargets.clear();\n this.#activeTargets.clear();\n this.#confirmedTarget = null;\n }\n\n /** True when lifecycle tracking or the current event reports composition. */\n isComposing(event?: CompositionSignal): boolean {\n return this.#activeTargets.size > 0 || event?.isComposing === true;\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 || COMPOSITION_INPUT_TYPES.has(inputType);\n }\n\n readonly #handleStart = (event: Event): void => {\n this.#confirmedTarget = null;\n if (event.currentTarget) this.#activeTargets.add(event.currentTarget);\n this.#onStart?.(event);\n };\n\n readonly #handleEnd = (event: Event): void => {\n if (event.currentTarget) this.#activeTargets.delete(event.currentTarget);\n this.#confirmedTarget = event.target;\n this.#onEnd?.(event);\n };\n\n /** A key on an observed field opens an edit of its own, so no echo is owed. */\n readonly #handleKeydown = (): void => {\n this.#confirmedTarget = null;\n };\n}\n","/**\n * Readers for the String Values whose text can only be checked by handing it to\n * a parser: a CSS selector, a regular-expression source, a JSON object.\n *\n * Stimulus reads each of them as an ordinary string, so the controller connects\n * and the flaw surfaces later, inside the first handler that consumes the value\n * (a `SyntaxError` from `new RegExp`, a `DOMException` from the selector engine),\n * where it takes the whole handler down on every event. Parsing here, once, in\n * the `<name>ValueChanged` callback keeps the failure local to the declaration:\n * an unreadable value falls back to its default, the element stays alive, and\n * the hot path only ever receives a value that parsed.\n *\n * Which default a broken declaration falls back to is the caller's contract, so\n * every reader takes (or returns) the fallback rather than choosing one.\n */\n\n/**\n * The result of `parse(raw)`, or `fallback` when `parse` throws.\n *\n * Any exception counts as \"does not parse\": the parsers these Values feed\n * (`RegExp`, `JSON.parse`, the selector engine) all report a malformed input by\n * throwing, and none of them throws for another reason.\n */\nexport function parseDeclared<T>(raw: string, parse: (raw: string) => T, fallback: T): T {\n try {\n return parse(raw);\n } catch {\n return fallback;\n }\n}\n\n/** What {@link validSelector} needs of the element it probes with. */\nexport interface SelectorProbe {\n matches(selector: string): boolean;\n}\n\n/**\n * `raw` when it is a non-empty selector the DOM accepts, otherwise `fallback`.\n *\n * `element.matches` is the probe: the engine parses the selector and throws for\n * one it cannot read. Whether the selector actually matches `element` plays no\n * part, so a selector aimed at another element still passes.\n *\n * The parameter names the one method the probe uses rather than `Element`, so\n * this module carries no DOM type and the readers below stay importable from\n * the Node-side Inspector, which checks the same declarations statically.\n */\nexport function validSelector(element: SelectorProbe, raw: string, fallback: string): string {\n if (raw.length === 0) return fallback;\n return parseDeclared(\n raw,\n (selector) => {\n element.matches(selector);\n return selector;\n },\n fallback,\n );\n}\n\n/** How `compileRegExp` wraps a source before compiling it. */\nexport type RegExpAnchor = \"none\" | \"exact\";\n\n/**\n * `source` compiled as a `RegExp`, or `null` when it does not compile.\n *\n * `\"exact\"` wraps the source as `^(?:source)$`, so the whole input has to match\n * and an alternation inside the source cannot escape the anchors. The source is\n * compiled on its own first, because an unbalanced source can be made to parse\n * by the wrapper's own parentheses — `0)|(1` becomes `^(?:0)|(1)$` — which would\n * accept a declaration that is not a regular expression and leave half of it\n * outside the anchors. The default that replaces a broken source is the\n * caller's, so `null` is returned rather than a fallback pattern.\n */\nexport function compileRegExp(source: string, anchor: RegExpAnchor = \"none\"): RegExp | null {\n return parseDeclared(\n source,\n (text) => {\n const bare = new RegExp(text);\n return anchor === \"exact\" ? new RegExp(`^(?:${text})$`) : bare;\n },\n null,\n );\n}\n\n/**\n * The JSON object `raw` declares, or `null` when the text does not parse or\n * parses to something other than a plain object (`null`, an array, a scalar).\n * Values are returned as parsed; narrowing them is the caller's contract.\n */\nexport function parseJsonObject(raw: string): Record<string, unknown> | null {\n const parsed = parseDeclared<unknown>(raw, (text) => JSON.parse(text), null);\n if (parsed === null || typeof parsed !== \"object\" || Array.isArray(parsed)) return null;\n return parsed as Record<string, unknown>;\n}\n","/**\n * Runs a controller's reconciliation pass after a native form reset has\n * restored the form's own controls.\n *\n * **A microtask alone is not \"after the reset\", and the reason is where the\n * dispatch came from.** `form.reset()` fires the event and restores the\n * controls inside one script frame, so a microtask queued from a listener lands\n * after both. A reset the user triggers — activating a `reset` button — is\n * dispatched by the browser with an empty script stack, so the microtask\n * checkpoint runs the moment the listener returns: still inside the dispatch,\n * before the controls are restored and before a later listener has had its\n * chance to cancel. Reconciling there reads the pre-reset values and treats a\n * cancelled reset as a real one.\n *\n * The event itself tells the two origins apart. `eventPhase` returns to\n * `Event.NONE` at the end of dispatch, so a microtask that sees `NONE` is\n * already past the default action and settles on the spot — that is the\n * scripted path, and its timing is exactly a microtask. A microtask\n * that still sees a dispatch phase is the browser-driven path and settles on\n * the next animation frame instead: the default action completes before that\n * frame, and `defaultPrevented` has reached its final value. A frame is only\n * ever reached from a real user interaction, which requires a rendered\n * document, so the frame cannot starve.\n *\n * Pending frames are held per handle rather than collapsed into one slot: a set\n * needs no branch to stay accurate, and every handle in it is cancellable at\n * teardown.\n *\n * Scope is the timing and the ownership test only. *What* to reconcile — an\n * aggregate, a visibility pass, a re-read of every field — stays in the\n * controller, because no two consumers answer it the same way. Ownership stays\n * there too: a control associated through `form=` is reached by the consumer's\n * own `control.form` read.\n *\n * @example\n * ```ts\n * readonly #formReset = new FormResetWatcher(\n * (form) => this.fieldTargets.some((field) => field.form === form),\n * () => this.#reconcile.schedule(),\n * );\n *\n * connect() { this.#formReset.observe(); }\n * disconnect() { this.#formReset.disconnect(); }\n * ```\n */\nexport class FormResetWatcher {\n readonly #owns: (form: HTMLFormElement) => boolean;\n readonly #onReset: () => void;\n readonly #frames = new Set<number>();\n #generation = 0;\n\n /**\n * @param owns - whether `form` owns a control this controller derives from.\n * @param onReset - the reconciliation pass, run once per honoured reset.\n */\n constructor(owns: (form: HTMLFormElement) => boolean, onReset: () => void) {\n this.#owns = owns;\n this.#onReset = onReset;\n }\n\n /** Subscribes to `reset` at the document; call from `connect()`. Idempotent. */\n observe(): void {\n document.addEventListener(\"reset\", this.#handleReset, true);\n }\n\n /** Unsubscribes and drops every pending pass; call from `disconnect()`. */\n disconnect(): void {\n document.removeEventListener(\"reset\", this.#handleReset, true);\n this.#generation += 1;\n for (const frame of this.#frames) cancelAnimationFrame(frame);\n this.#frames.clear();\n }\n\n readonly #handleReset = (event: Event): void => {\n const form = event.target;\n if (!(form instanceof HTMLFormElement) || !this.#owns(form)) return;\n const generation = this.#generation;\n queueMicrotask(() => {\n // A pass queued before teardown must not reach a disconnected controller.\n if (generation !== this.#generation) return;\n if (event.eventPhase === Event.NONE) {\n this.#settle(event);\n return;\n }\n const frame = requestAnimationFrame(() => {\n this.#frames.delete(frame);\n this.#settle(event);\n });\n this.#frames.add(frame);\n });\n };\n\n /** Runs the pass unless a listener cancelled the reset before it landed. */\n #settle(event: Event): void {\n if (!event.defaultPrevented) this.#onReset();\n }\n}\n","/** The distance between a full-width ASCII code point and its half-width twin. */\nconst FULL_WIDTH_SHIFT = 0xfee0;\n\n/**\n * The half-width form of `char`, or `char` itself when it has none.\n *\n * An IME confirming in full-width mode produces U+FF01–U+FF5E (and U+3000 for\n * the space) where the page means ASCII — the digits of a phone number, the\n * letters of a code, the separators between them. Reading those as their ASCII\n * equivalents keeps confirmed text usable instead of discarding it. Characters\n * outside that block, including kana and astral code points, are returned\n * unchanged, so this never rewrites text a consumer meant to keep as typed.\n */\nexport function halfWidthChar(char: string): string {\n if (char >= \"!\" && char <= \"~\") {\n return String.fromCharCode(char.charCodeAt(0) - FULL_WIDTH_SHIFT);\n }\n return char === \" \" ? \" \" : char;\n}\n\n/** Every full-width ASCII character in `text` rewritten by {@link halfWidthChar}. */\nexport function toHalfWidth(text: string): string {\n let out = \"\";\n for (const char of text) out += halfWidthChar(char);\n return out;\n}\n","/**\n * Collapses many Stimulus lifecycle callbacks from one DOM mutation into a\n * single pass.\n *\n * Stimulus fires `<name>TargetConnected` / `Disconnected` once per element and\n * `<name>ValueChanged` once per changed attribute. Replacing a list of N options\n * or morphing several render Values therefore delivers N callbacks — but the\n * useful unit of work is \"reconcile against the resulting declarative input\",\n * once, after the batch has settled. Every controller with reconcilable targets\n * or render Values needs the same shape: a `queued` flag plus `queueMicrotask`.\n *\n * **A microtask is the right horizon, and the reason is specific.** Stimulus\n * drives these callbacks from a `MutationObserver`, whose own callback already\n * runs as a microtask with the whole batch in hand; scheduling one more lands\n * after the last sibling callback of that batch and still before paint or any\n * event handler. A timer would be later than it needs to be, and reconciling\n * synchronously would run once per element against a half-applied DOM.\n *\n * **The two guards are not the same guard.** Scheduling is refused before the\n * controller connects, and running is refused after it disconnects:\n *\n * - **Before `connect()`** — Stimulus delivers initial target and Value callbacks\n * ahead of `connect()`. Reconciling there would compute output against a\n * controller whose own state has not been initialised, and `connect()` is\n * about to do a full pass anyway.\n * - **After `disconnect()`** — Stimulus fires a callback for **every** target\n * during teardown, and a microtask queued just before it would otherwise run\n * against a detached tree. {@link MicrotaskCoalescer.cancel} exists for the\n * teardown path to drop the pending pass outright.\n *\n * Both guards are part of one contract here rather than something each consumer\n * has to remember separately.\n *\n * Scope is the scheduling only. *What* to reconcile — keep the surviving active\n * option, fall back to the next / previous / first visible one, rebuild derived\n * chips or hidden fields — stays in the controller, because no two consumers\n * answer it the same way.\n *\n * @example\n * ```ts\n * readonly #reconcile = new MicrotaskCoalescer(() => this.#reconcileOptions());\n *\n * connect() { this.#reconcile.activate(); }\n * disconnect() { this.#reconcile.cancel(); }\n *\n * optionTargetConnected() { this.#reconcile.schedule(); }\n * optionTargetDisconnected() { this.#reconcile.schedule(); }\n * ```\n */\nexport class MicrotaskCoalescer {\n readonly #run: () => void;\n #queued = false;\n #active = false;\n #generation = 0;\n\n /** @param run - the single reconciliation pass, invoked at most once per batch. */\n constructor(run: () => void) {\n this.#run = run;\n }\n\n /** Opens the window in which {@link schedule} is honoured; call from `connect()`. */\n activate(): void {\n this.#active = true;\n }\n\n /** Closes the window and drops any pending pass; call from `disconnect()`. */\n cancel(): void {\n this.#active = false;\n this.#queued = false;\n this.#generation += 1;\n }\n\n /** Requests one pass after the batch settles. Idempotent; inert outside the window. */\n schedule(): void {\n if (!this.#active || this.#queued) return;\n this.#queued = true;\n const generation = this.#generation;\n queueMicrotask(() => {\n // A cancelled callback must not consume a pass queued after reconnect.\n if (generation !== this.#generation || !this.#queued || !this.#active) return;\n this.#queued = false;\n this.#run();\n });\n }\n}\n","/**\n * Identifies the latest reported state transition of one owner.\n *\n * Record a transition after its state is written and before invoking external\n * code. Check the returned token before each later report: a synchronous\n * transition made by a listener supersedes reports that have not been sent.\n * Reading state or committing an unchanged state must not advance the counter.\n * Reports stay in the caller so their ordering remains explicit.\n */\nexport class MoveCounter {\n #sequence = 0;\n\n /** Records a state transition and returns its report token. */\n record(): number {\n this.#sequence += 1;\n return this.#sequence;\n }\n\n /** Whether no later state transition has superseded this report token. */\n isLatest(token: number): boolean {\n return token === this.#sequence;\n }\n}\n","import { Controller } from \"@hotwired/stimulus\";\nimport { ensureId } from \"../utils/aria_ids\";\nimport { isReservedArrowChord, logicalArrowKey } from \"../utils/arrow_step\";\nimport { AttributeLease } from \"../utils/attribute_lease\";\nimport { CompositionTracker } from \"../utils/composition_tracker\";\nimport { compileRegExp } from \"../utils/declared_value\";\nimport { FormResetWatcher } from \"../utils/form_reset_watcher\";\nimport { toHalfWidth } from \"../utils/half_width\";\nimport { MicrotaskCoalescer } from \"../utils/microtask_coalescer\";\nimport { MoveCounter } from \"../utils/move_counter\";\n\n/** The error attributes this component writes on each field while input is rejected. */\ntype ErrorAttribute = \"aria-invalid\" | \"aria-errormessage\" | \"aria-describedby\";\n\n/**\n * Each error attribute's lease, kept on the field itself.\n *\n * These records travel with the markup, so any connection can give the authored\n * value back — and only while the\n * attribute still holds what this component last wrote there, so a value a\n * consumer changed in the meantime is theirs and stays.\n */\nconst LEASE_MARKERS: Readonly<Record<ErrorAttribute, string>> = {\n \"aria-invalid\": \"data-otp-invalid-lease\",\n \"aria-errormessage\": \"data-otp-errormessage-lease\",\n \"aria-describedby\": \"data-otp-describedby-lease\",\n};\n\n/** What an error attribute carried before this component wrote it, and what it wrote. */\ninterface ErrorLease {\n readonly authored: string | null;\n readonly written: string;\n}\n\n/** Whether a parsed marker holds a lease this component could have recorded. */\nfunction isErrorLease(value: unknown): value is ErrorLease {\n const lease = value as Partial<Record<keyof ErrorLease, unknown>> | null;\n return (\n typeof lease?.written === \"string\" &&\n (lease.authored === null || typeof lease.authored === \"string\")\n );\n}\n\n/** Reads the lease a field carries; a marker holding anything else is not one. */\nfunction readLease(field: Element, marker: string): ErrorLease | null {\n try {\n const parsed: unknown = JSON.parse(field.getAttribute(marker) ?? \"null\");\n return isErrorLease(parsed) ? parsed : null;\n } catch {\n return null;\n }\n}\n\n/**\n * The field's own description tokens with the error id appended once, dropping the\n * id of an earlier error target this component pointed the field at.\n */\nfunction describedByWith(\n described: string | null,\n errorId: string,\n earlier: string | null,\n): string {\n const tokens = (described ?? \"\")\n .split(/\\s+/)\n .filter((token) => token.length > 0 && token !== errorId && token !== earlier);\n return [...tokens, errorId].join(\" \");\n}\n\n/** Single-character pattern used when a `pattern` declaration cannot compile. */\nconst DEFAULT_PATTERN = \"[0-9]\";\n\n/**\n * {@link DEFAULT_PATTERN} compiled, in the same whole-input form\n * `compileRegExp(…, \"exact\")` produces. A literal character class always\n * compiles, so the fallback is a value rather than another parse.\n */\nconst DEFAULT_MATCHER = new RegExp(`^(?:${DEFAULT_PATTERN})$`);\n\n/** Whether a press carries a modifier, which makes it the document's to handle. */\nfunction hasModifier(event: KeyboardEvent): boolean {\n return event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;\n}\n\n/**\n * The controller-derived state a consumer can observe.\n *\n * The combined value alone does not identify it: the same string spread over a\n * different number of fields reads as a different `data-state`, so completeness\n * is carried alongside the value rather than inferred from it.\n */\ninterface OtpState {\n readonly value: string;\n readonly state: string;\n}\n\n/** Compares exactly the derived state the root publishes. */\nfunction statesDiffer(left: OtpState, right: OtpState): boolean {\n return left.value !== right.value || left.state !== right.state;\n}\n\n/**\n * Headless, accessible One-Time Password / PIN input logic.\n *\n * Markup contract (identifier: `stimeo--otp`):\n * <div data-controller=\"stimeo--otp\"\n * data-stimeo--otp-pattern-value=\"[0-9]\"\n * role=\"group\" aria-label=\"One-time passcode\">\n * <input data-stimeo--otp-target=\"field\" inputmode=\"numeric\" maxlength=\"1\"\n * autocomplete=\"one-time-code\" aria-label=\"Digit 1\"\n * data-action=\"input->stimeo--otp#onInput\n * keydown->stimeo--otp#onKeydown\n * paste->stimeo--otp#onPaste\n * pointerdown->stimeo--otp#onPointerDown\" />\n * <!-- repeat one field per digit -->\n * <p data-stimeo--otp-target=\"error\" hidden>Digits only.</p>\n * <input type=\"hidden\" data-stimeo--otp-target=\"value\" name=\"otp\" />\n * </div>\n *\n * The passcode length is the number of connected `field` targets, so nothing has\n * to declare it twice and fields added or removed at runtime are absorbed.\n *\n * Entry rules:\n * - Text carrying more than one accepted character — an OS `one-time-code`\n * autofill, a password manager, an IME committing several digits, a paste —\n * is spread across the following writable fields from the entry point.\n * - `disabled` and `readonly` fields keep their value: they are never written\n * and never receive auto-advance focus, matching what the platform allows a\n * user to do by hand.\n * - Input that lands nowhere rolls the field back to the digit it last\n * committed, and is the only thing that reports `invalid` or reveals the\n * `error` target. Discarding a separator inside otherwise usable text\n * (`\"1234-56\"`) is a successful entry.\n * - Pointing at an empty field ahead of an earlier empty one lands on the\n * earliest empty field instead, so a passcode fills in order. Keyboard focus\n * is never redirected.\n *\n * `change` and `complete` dispatch `{ value: string }` and fire only when the\n * combined value actually moves — one confirmed IME character emits one event,\n * and a passcode re-completed with a different digit reports the new value.\n * State moved by adding or removing fields, by a `pattern` change dropping\n * entered digits it no longer accepts, or by a native form reset restoring the\n * fields is not an edit of the passcode, so it is reported as `reconcile` with\n * the same `{ value: string }` — once per change, after it settles — and never\n * as `change` or `complete`. While a field is composing, the IME's uncommitted\n * text is neither read nor written: a change already in the DOM — fields added\n * or removed, a reset — is reported at once, counting that field by the\n * character it had committed, while a `pattern` change's drop waits for the\n * composition to end and is then applied and reported before the commit is\n * taken. A composition that ends on the text the field held when it began was\n * cancelled: no edit, so it reports nothing and focus stays.\n * Completeness belongs to that state: dropping a trailing empty field completes\n * a passcode whose combined value never moved, and that transition is reported\n * too, so a consumer reading `data-state` is never left behind a silent move.\n * `invalid` dispatches `{ pattern: string }` carrying the compiled pattern.\n *\n * Controller-owned output: `data-filled` on each entered field, `data-state`\n * (`empty` / `partial` / `complete`) on the root, and — while input is being\n * reported invalid — `aria-invalid`, `aria-errormessage`, `aria-describedby`,\n * and the `error` target's `hidden`. Authored values return on teardown: the\n * three ARIA attributes keep their lease on the field itself, so a connection\n * that adopts a restored DOM can give them back too, and the `hidden` is leased.\n *\n * @remarks\n * Behavior only. `connect()` reads the fields back as the source of truth, which\n * is what restores consistency after a `type=\"password\"` field returns from the\n * Turbo cache emptied; a native form reset is read back the same way once the\n * browser has restored the fields. A `pattern` that cannot compile falls back to\n * `[0-9]`; the compiled matcher is built once per declaration rather than per\n * keystroke.\n */\nexport class OtpController extends Controller<HTMLElement> {\n /** Identifies the latest published state transition. */\n readonly #moves = new MoveCounter();\n\n static override targets = [\"field\", \"value\", \"error\"];\n static override values = {\n pattern: { type: String, default: DEFAULT_PATTERN },\n };\n static actions = [\"onInput\", \"onKeydown\", \"onPaste\", \"onPointerDown\", \"clear\"] as const;\n static events = [\"change\", \"complete\", \"invalid\", \"reconcile\"] as const;\n\n declare readonly fieldTargets: HTMLInputElement[];\n declare readonly valueTarget: HTMLInputElement;\n declare readonly errorTarget: HTMLElement;\n declare readonly errorTargets: HTMLElement[];\n declare readonly hasValueTarget: boolean;\n declare readonly hasErrorTarget: boolean;\n\n declare patternValue: string;\n\n /** Validated matcher; the hot path never compiles a raw declaration. */\n #pattern = DEFAULT_MATCHER;\n /** Source of {@link #pattern}, reported in `invalid` so consumers can word it. */\n #patternSource = DEFAULT_PATTERN;\n /** Public state carried by the last dispatch; keeps a no-op sync silent. */\n #published: OtpState | null = null;\n /** True between connect and disconnect, so pre-connect Value changes stay silent. */\n #connected = false;\n /** Digit each field last committed, restored when rejected input replaced it. */\n readonly #committed = new WeakMap<HTMLInputElement, string>();\n /** The field being composed, and the text it held when the composition began. */\n #composing: { readonly field: HTMLInputElement; readonly before: string } | null = null;\n /** A `pattern` change whose rejected characters wait for the composition to end. */\n #dropHeld = false;\n\n /**\n * Collapses one batch of page changes — field and value target and `pattern`\n * callbacks, a form reset — into a single reconciliation.\n */\n readonly #reconcile = new MicrotaskCoalescer(() => this.#reconcileFields());\n\n readonly #errorHidden = new AttributeLease<HTMLElement>(\"hidden\", this.identifier);\n readonly #state = new AttributeLease<HTMLElement>(\"data-state\", this.identifier);\n\n /** Reads the fields back once a native reset restored them, as a reconciliation. */\n readonly #formReset = new FormResetWatcher(\n (form) => this.#ownedBy(form),\n () => {\n this.#adopt();\n this.#reconcile.schedule();\n },\n );\n\n /**\n * Owns IME lifecycle state across every digit field. When a composition ends, a\n * `pattern` drop it held back applies first — it was declared first — and the\n * user's commit is taken after it.\n */\n readonly #composition = new CompositionTracker({\n onStart: (event) => {\n const field = this.#fieldFrom(event);\n if (field) this.#composing = { field, before: field.value };\n },\n onEnd: (event) => {\n const composing = this.#composing;\n this.#composing = null;\n const input = this.#fieldFrom(event);\n // `maxlength` has already cut the field down to one character, but the\n // commit itself carries the whole confirmed string — so a conversion that\n // ends in several characters still reaches the fields after this one.\n const data = (event as CompositionEvent).data ?? \"\";\n const text = input && data.length <= input.value.length ? input.value : data;\n // A composition that ends on the text the field held when it began was\n // cancelled: the user entered nothing, so there is nothing to take.\n const commit = input !== null && (composing?.field !== input || text !== composing.before);\n if (this.#dropHeld) {\n // The drop judges what the fields had committed; the commit waits aside.\n if (input && commit) input.value = this.#committed.get(input) ?? \"\";\n this.#reconcileFields();\n }\n if (input && commit) this.#accept(input, text);\n },\n });\n\n override connect(): void {\n this.#connected = true;\n for (const field of this.fieldTargets) this.#bind(field);\n this.#formReset.observe();\n this.#reconcile.activate();\n this.#adopt();\n this.#sync();\n }\n\n override disconnect(): void {\n this.#connected = false;\n for (const field of this.fieldTargets) this.#unbind(field);\n this.#composition.disconnect();\n this.#formReset.disconnect();\n this.#reconcile.cancel();\n // A drop a composition held goes with the connection, like a pending pass.\n this.#dropHeld = false;\n this.#clearError();\n this.#state.return(this.element);\n }\n\n /**\n * Stimulus lifecycle callback when a new field target enters the DOM.\n * Wires the new field and folds the wider digit count into one reconciliation,\n * which stays inert until `connect()` opens the window.\n */\n fieldTargetConnected(element: HTMLInputElement): void {\n this.#bind(element);\n this.#adoptField(element);\n this.#reconcile.schedule();\n }\n\n /** Releases a dropped field's listeners and leases, then reconciles the rest. */\n fieldTargetDisconnected(element: HTMLInputElement): void {\n this.#unbind(element);\n this.#returnLeases(element);\n this.#reconcile.schedule();\n }\n\n /** Writes the combined value into a value field that arrives, in the next reconciliation. */\n valueTargetConnected(): void {\n this.#reconcile.schedule();\n }\n\n /** Writes the combined value into the value field that stays when an earlier one leaves. */\n valueTargetDisconnected(): void {\n this.#reconcile.schedule();\n }\n\n /**\n * Moves rejected input still being reported onto the first error target as one arrives,\n * and hides the first one while nothing is reported.\n */\n errorTargetConnected(): void {\n this.#followError();\n }\n\n /**\n * Gives an error target that no longer resolves as one its own `hidden` back — after\n * `disconnect()` too, since dropping the identifier leaves the element on the page —\n * and shows rejected input still being reported on the error target that stays, or\n * hides it while nothing is reported.\n */\n errorTargetDisconnected(element: HTMLElement): void {\n if (!this.errorTargets.includes(element)) this.#errorHidden.return(element);\n this.#followError();\n }\n\n /**\n * Re-validates a changed `pattern` declaration once and drops any entered digit\n * the new pattern no longer accepts, so the combined value stays interpretable.\n * The page changed the declaration, so the move joins the same reconciliation\n * as fields added or removed in that mutation. While a field is composing, its\n * text is the IME's, and the drop waits for the composition to end.\n */\n patternValueChanged(): void {\n const compiled = compileRegExp(this.patternValue, \"exact\");\n this.#patternSource = compiled ? this.patternValue : DEFAULT_PATTERN;\n this.#pattern = compiled ?? DEFAULT_MATCHER;\n if (!this.#connected) return;\n if (this.#composing !== null) {\n this.#dropHeld = true;\n return;\n }\n if (this.#dropRejected()) this.#reconcile.schedule();\n }\n\n /** Empties every writable field holding a character the pattern rejects; whether one did. */\n #dropRejected(): boolean {\n let dropped = false;\n for (const field of this.fieldTargets) {\n if (field.value === \"\" || !this.#isWritable(field)) continue;\n if (this.#pattern.test(field.value)) continue;\n this.#writeField(field, \"\");\n dropped = true;\n }\n return dropped;\n }\n\n /** Handles keystroke inputs, distributes autofilled text, and advances focus. */\n onInput(event: Event): void {\n const input = this.#fieldFrom(event);\n if (!input) return;\n\n // The browser may follow a commit with one more `input` carrying the same\n // text; running it again would spread the commit twice.\n if (this.#composition.consumesConfirmedInput(event)) return;\n\n // Guard during active composition to prevent premature focus switching\n if (this.#composition.isComposing(event as InputEvent)) return;\n\n this.#accept(input);\n }\n\n /** Handles Backspace clearing, arrows, and home/end navigation. */\n onKeydown(event: KeyboardEvent): void {\n if (isReservedArrowChord(event)) return;\n const input = this.#fieldFrom(event);\n if (!input) return;\n\n // Do not trigger keydown actions during composition\n if (this.#composition.isComposing(event)) return;\n\n const index = this.fieldTargets.indexOf(input);\n const fields = this.fieldTargets;\n // Logical, not physical. The key is normalised rather than the\n // delta negated: these two branches are not mirror images — their bounds\n // guards differ — so swapping the key keeps each guard with its own direction.\n\n switch (logicalArrowKey(event.key, this.element)) {\n case \"Backspace\":\n if (hasModifier(event)) break;\n if (input.value && this.#isWritable(input)) {\n // Filled field: clear it where it stands\n event.preventDefault();\n this.#writeField(input, \"\");\n this.#clearError();\n this.#syncAndDispatch();\n } else {\n // Empty field: step back to the previous writable digit and wipe it\n const previous = this.#writableBefore(index);\n if (previous) {\n event.preventDefault();\n this.#writeField(previous, \"\");\n previous.focus();\n this.#clearError();\n this.#syncAndDispatch();\n }\n }\n break;\n\n case \"ArrowLeft\": {\n const previous = this.#focusableBefore(index);\n if (previous) {\n event.preventDefault();\n previous.focus();\n }\n break;\n }\n\n case \"ArrowRight\": {\n const next = this.#focusableAfter(index);\n if (next) {\n event.preventDefault();\n next.focus();\n }\n break;\n }\n\n case \"Home\": {\n // Control+Home belongs to the document, not to the digit group\n if (hasModifier(event)) break;\n const first = fields.find((field) => this.#isFocusable(field));\n if (first) {\n event.preventDefault();\n first.focus();\n }\n break;\n }\n\n case \"End\": {\n if (hasModifier(event)) break;\n const last = fields\n .slice()\n .reverse()\n .find((field) => this.#isFocusable(field));\n if (last) {\n event.preventDefault();\n last.focus();\n }\n break;\n }\n\n default:\n break;\n }\n }\n\n /** Divides pasted string characters across the available input fields. */\n onPaste(event: ClipboardEvent): void {\n const input = this.#fieldFrom(event);\n if (!input) return;\n\n event.preventDefault();\n this.#distribute(input, toHalfWidth(event.clipboardData?.getData(\"text\") ?? \"\"));\n }\n\n /**\n * Redirects a pointer landing on an empty field to the earliest empty one, so\n * a passcode is entered in order. Filled fields stay directly reachable for\n * correction, and keyboard focus is left alone.\n */\n onPointerDown(event: Event): void {\n const input = this.#fieldFrom(event);\n if (input?.value !== \"\") return;\n\n const first = this.fieldTargets.find((field) => this.#isWritable(field) && field.value === \"\");\n if (!first || first === input) return;\n\n event.preventDefault();\n first.focus();\n }\n\n /** Empties every writable field and restarts entry at the first of them. */\n clear(): void {\n for (const field of this.fieldTargets) {\n if (this.#isWritable(field)) this.#writeField(field, \"\");\n }\n this.#clearError();\n this.fieldTargets.find((field) => this.#isWritable(field))?.focus();\n this.#syncAndDispatch();\n }\n\n readonly #onFieldFocus = (event: FocusEvent): void => {\n const input = event.currentTarget as HTMLInputElement | null;\n if (input) {\n // Auto-selection enables effortless character overwrites\n input.select();\n }\n };\n\n /** Whether a form owns at least one field or the hidden combined value. */\n #ownedBy(form: HTMLFormElement): boolean {\n if (this.fieldTargets.some((field) => field.form === form)) return true;\n return this.hasValueTarget && this.valueTarget.form === form;\n }\n\n #bind(field: HTMLInputElement): void {\n field.addEventListener(\"focus\", this.#onFieldFocus);\n this.#composition.observe(field);\n }\n\n #unbind(field: HTMLInputElement): void {\n field.removeEventListener(\"focus\", this.#onFieldFocus);\n this.#composition.unobserve(field);\n // A field that leaves mid-composition never ends that composition here.\n if (this.#composing?.field === field) this.#composing = null;\n }\n\n /**\n * Reads every field back so a restored or reset group starts consistent: nothing has\n * been rejected yet, whatever error surface the restored DOM carries.\n */\n #adopt(): void {\n for (const field of this.fieldTargets) this.#adoptField(field);\n this.#clearError();\n }\n\n /** Writes one error attribute, keeping the first authored value it displaces. */\n #lease(field: HTMLInputElement, attribute: ErrorAttribute, value: string): void {\n const marker = LEASE_MARKERS[attribute];\n const held = readLease(field, marker);\n const authored = held ? held.authored : field.getAttribute(attribute);\n field.setAttribute(marker, JSON.stringify({ authored, written: value }));\n field.setAttribute(attribute, value);\n }\n\n /** Gives one field's error attributes back where they still hold what this wrote. */\n #returnLeases(field: HTMLInputElement): void {\n for (const [attribute, marker] of Object.entries(LEASE_MARKERS)) {\n const held = readLease(field, marker);\n if (!held) continue;\n field.removeAttribute(marker);\n if (field.getAttribute(attribute) !== held.written) continue;\n if (held.authored === null) field.removeAttribute(attribute);\n else field.setAttribute(attribute, held.authored);\n }\n }\n\n /** Takes one field's current value as the truth behind its derived state. */\n #adoptField(field: HTMLInputElement): void {\n this.#committed.set(field, field.value);\n this.#markFilled(field, field.value);\n }\n\n /**\n * Absorbs one batch of page changes — fields added or removed, entered digits a\n * new `pattern` rejects, fields a native form reset restored — as one state\n * transition.\n *\n * Nobody edited the passcode here, so the move is reported as `reconcile`:\n * automation listening for `change` must not read a re-render or a reset as an\n * edit, and a passcode that happens to end up full must not fire the\n * `complete` that submits it.\n *\n * Completeness moves on its own when the field count changes: dropping a\n * trailing empty field completes a passcode whose combined value never moved,\n * and adding one un-completes it. Comparing the whole derived state, not the\n * string it contains, is what makes those transitions reportable.\n *\n * A change already in the DOM — a field added or removed, a reset — is\n * published at once, even while a field is composing: that field counts by the\n * character it had committed, never by the IME's uncommitted text. Only a\n * `pattern` drop waits for the composition to end.\n */\n #reconcileFields(): void {\n if (this.#dropHeld && this.#composing === null) {\n this.#dropHeld = false;\n this.#dropRejected();\n }\n const previous = this.#published;\n const current = this.#sync();\n if (previous && !statesDiffer(previous, current)) return;\n this.#moves.record();\n this.dispatch(\"reconcile\", { detail: { value: current.value } });\n }\n\n /**\n * Validates the text an entry point received and distributes what it accepts.\n * `text` defaults to the field's own value; a confirmation passes the string it\n * committed, which `maxlength` would otherwise have truncated.\n */\n #accept(input: HTMLInputElement, text: string = input.value): void {\n const raw = toHalfWidth(text);\n if (raw === \"\") {\n // Emptying a field is a legitimate edit, not rejected input\n this.#writeField(input, \"\");\n this.#clearError();\n this.#syncAndDispatch();\n return;\n }\n\n this.#distribute(input, raw);\n }\n\n /**\n * Fills `text`'s accepted characters into the writable fields at and after the\n * entry point, then leaves focus on the field after the last one filled.\n */\n #distribute(from: HTMLInputElement, text: string): void {\n const accepted = Array.from(text).filter((char) => this.#pattern.test(char));\n let reached = false;\n const slots = this.fieldTargets.filter((field) => {\n reached ||= field === from;\n return reached && this.#isWritable(field);\n });\n const filled = Math.min(accepted.length, slots.length);\n\n if (filled === 0) {\n // Nothing landed: restore the digit the entry point had committed\n this.#restore(from);\n this.#showError();\n this.#sync();\n return;\n }\n\n for (let i = 0; i < filled; i++) {\n const field = slots[i];\n const char = accepted[i];\n if (field && char) this.#writeField(field, char);\n }\n\n const last = slots[filled - 1];\n if (last) (this.#writableAfter(last) ?? last).focus();\n\n this.#clearError();\n this.#syncAndDispatch();\n }\n\n /** Restores the digit a field committed before rejected input replaced it. */\n #restore(field: HTMLInputElement): void {\n this.#writeField(field, this.#committed.get(field) ?? \"\");\n }\n\n /** Commits one field's value and the derived hook that reports it as entered. */\n #writeField(field: HTMLInputElement, value: string): void {\n field.value = value;\n this.#committed.set(field, value);\n this.#markFilled(field, value);\n }\n\n #markFilled(field: HTMLInputElement, value: string): void {\n if (value) field.setAttribute(\"data-filled\", \"true\");\n else field.removeAttribute(\"data-filled\");\n }\n\n #isWritable(field: HTMLInputElement): boolean {\n return !field.disabled && !field.readOnly;\n }\n\n #isFocusable(field: HTMLInputElement): boolean {\n return !field.disabled;\n }\n\n #writableAfter(field: HTMLInputElement): HTMLInputElement | null {\n const fields = this.fieldTargets;\n return fields.slice(fields.indexOf(field) + 1).find((next) => this.#isWritable(next)) ?? null;\n }\n\n #writableBefore(index: number): HTMLInputElement | null {\n return this.#before(index).find((field) => this.#isWritable(field)) ?? null;\n }\n\n #focusableAfter(index: number): HTMLInputElement | null {\n return this.fieldTargets.slice(index + 1).find((field) => this.#isFocusable(field)) ?? null;\n }\n\n #focusableBefore(index: number): HTMLInputElement | null {\n return this.#before(index).find((field) => this.#isFocusable(field)) ?? null;\n }\n\n /** Fields before `index`, nearest first; empty at the first field. */\n #before(index: number): HTMLInputElement[] {\n return this.fieldTargets.slice(0, Math.max(index, 0)).reverse();\n }\n\n /** The event's field target, or `null` when the wiring points somewhere else. */\n #fieldFrom(event: Event): HTMLInputElement | null {\n const input = event.currentTarget;\n return this.fieldTargets.find((field) => field === input) ?? null;\n }\n\n #combinedValue(): string {\n return this.fieldTargets.map((field) => this.#publishedText(field)).join(\"\");\n }\n\n /** Every field carries a character, and there is at least one field. */\n #isComplete(): boolean {\n const fields = this.fieldTargets;\n return fields.length > 0 && fields.every((field) => this.#publishedText(field).length > 0);\n }\n\n /** A field's text as the combined value counts it: a composing field by its committed character. */\n #publishedText(field: HTMLInputElement): string {\n return field === this.#composing?.field ? (this.#committed.get(field) ?? \"\") : field.value;\n }\n\n /**\n * Mirrors the combined value into the form and the root's readable state, and\n * records what was published so the next pass can compare against it.\n */\n #sync(): OtpState {\n const combined = this.#combinedValue();\n\n if (this.hasValueTarget) {\n this.valueTarget.value = combined;\n }\n const state = this.#stateName(combined);\n this.#state.write(this.element, state);\n\n const published: OtpState = { value: combined, state };\n this.#published = published;\n return published;\n }\n\n #stateName(combined: string): string {\n if (combined.length === 0) return \"empty\";\n return this.#isComplete() ? \"complete\" : \"partial\";\n }\n\n #syncAndDispatch(): void {\n const previous = this.#published;\n const { value: combined } = this.#sync();\n if (previous?.value === combined) return;\n\n const token = this.#moves.record();\n this.dispatch(\"change\", { detail: { value: combined } });\n if (!this.#moves.isLatest(token)) return;\n\n // Completed state when every field carries a character\n if (this.#isComplete()) {\n this.dispatch(\"complete\", { detail: { value: combined } });\n }\n }\n\n /** Surfaces rejected input on every field and on the optional error target. */\n #showError(): void {\n const errorId = this.hasErrorTarget ? ensureId(this.errorTarget, \"stimeo--otp-error\") : null;\n\n for (const field of this.fieldTargets) {\n this.#lease(field, \"aria-invalid\", \"true\");\n if (errorId) this.#pointAtError(field, errorId);\n }\n if (this.hasErrorTarget) this.#errorHidden.write(this.errorTarget, null);\n\n // Behavior only: emit a neutral payload and let the consumer compose/localize\n // the user-facing message. The pattern is reported so consumers can word it.\n this.dispatch(\"invalid\", { detail: { pattern: this.#patternSource } });\n }\n\n /** Points one field's error message and description at the error target `errorId` names. */\n #pointAtError(field: HTMLInputElement, errorId: string): void {\n const earlier = readLease(field, LEASE_MARKERS[\"aria-errormessage\"])?.written ?? null;\n this.#lease(field, \"aria-errormessage\", errorId);\n // Assistive tech without aria-errormessage support still reads a description\n const described = field.getAttribute(\"aria-describedby\");\n this.#lease(field, \"aria-describedby\", describedByWith(described, errorId, earlier));\n }\n\n /**\n * While connected, brings the error targets in line with the report the fields carry. A\n * report still standing — the fields it marked invalid carry their record — moves onto the\n * error target that is now first: it shows, and those fields point at it. With nothing\n * reported, the first error target is hidden and any other gives its own `hidden` back.\n * Nothing is dispatched.\n */\n #followError(): void {\n if (!this.#connected) return;\n const reported = this.fieldTargets.filter(\n (field) => readLease(field, LEASE_MARKERS[\"aria-invalid\"]) !== null,\n );\n if (reported.length === 0) {\n this.#hideErrors();\n return;\n }\n if (!this.hasErrorTarget) return;\n const errorId = ensureId(this.errorTarget, \"stimeo--otp-error\");\n for (const field of reported) this.#pointAtError(field, errorId);\n this.#errorHidden.write(this.errorTarget, null);\n }\n\n /**\n * Ends a report: every field's error attributes go back to what the author wrote. While\n * connected the first error target is hidden again and any other gives its own `hidden`\n * back; teardown gives every error target its own `hidden` back.\n */\n #clearError(): void {\n for (const field of this.fieldTargets) this.#returnLeases(field);\n if (!this.#connected) {\n this.#errorHidden.returnAll();\n return;\n }\n this.#hideErrors();\n }\n\n /** Hides the first error target and gives any other its own `hidden` back. */\n #hideErrors(): void {\n const [first, ...others] = this.errorTargets;\n for (const other of others) this.#errorHidden.return(other);\n if (first) this.#errorHidden.write(first, \"\");\n }\n}\n"]}
|
|
@@ -50,6 +50,11 @@ declare class OverflowIndicatorController extends Controller<HTMLElement> {
|
|
|
50
50
|
default: number;
|
|
51
51
|
};
|
|
52
52
|
};
|
|
53
|
+
static valueConstraints: {
|
|
54
|
+
threshold: {
|
|
55
|
+
readonly finite: true;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
53
58
|
static actions: readonly ["scrollByPage"];
|
|
54
59
|
static events: readonly ["change"];
|
|
55
60
|
readonly viewportTarget: HTMLElement;
|