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/announce.ts","../../src/utils/attribute_lease.ts","../../src/utils/before_cache_reset.ts","../../src/utils/composition_tracker.ts","../../src/utils/microtask_coalescer.ts","../../src/utils/safe_timeout.ts","../../src/controllers/character_counter_controller.ts"],"names":[],"mappings":";;;;;AAoBO,SAAS,QAAA,CAAS,OAAA,EAAiB,OAAA,GAAmC,EAAC,EAAS;AACrF,EAAA,MAAM,IAAA,GAAO,QAAQ,IAAA,EAAK;AAC1B,EAAA,IAAI,IAAA,CAAK,WAAW,CAAA,EAAG;AACvB,EAAA,MAAA,CAAO,aAAA;AAAA,IACL,IAAI,YAAY,4BAAA,EAA8B;AAAA,MAC5C,QAAQ,EAAE,OAAA,EAAS,MAAM,SAAA,EAAW,OAAA,CAAQ,cAAc,IAAA;AAAK,KAChE;AAAA,GACH;AACF;AAUO,SAAS,YAAA,CAAa,UAAkB,MAAA,EAAiD;AAC9F,EAAA,OAAO,QAAA,CAAS,OAAA,CAAQ,6BAAA,EAA+B,C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AgB,GAAA,EAAqB;AACnC,IAAA,IAAI,CAAC,MAAA,CAAO,QAAA,CAAS,GAAG,GAAG,OAAO,CAAA;AAClC,IAAA,OAAO,KAAK,GAAA,CAAI,CAAA,EAAG,IAAA,CAAK,KAAA,CAAM,GAAG,CAAC,CAAA;AAAA,EACpC;AAAA;AAAA,EAGA,IAAI,KAAA,GAAqB;AACvB,IAAA,IAAI,KAAK,SAAA,KAAc,MAAA,IAAU,KAAK,SAAA,KAAc,MAAA,SAAe,IAAA,CAAK,SAAA;AACxE,IAAA,OAAO,WAAA;AAAA,EACT;AAAA;AAAA,EAGA,IAAI,MAAA,GAAuC;AACzC,IAAA,IAAI,IAAA,CAAK,cAAA,EAAgB,OAAO,IAAA,CAAK,WAAA;AACrC,IAAA,MAAM,UAAuB,IAAA,CAAK,OAAA;AAClC,IAAA,IAAI,OAAA,YAAmB,oBAAoB,OAAA,YAAmB,mBAAA;AAC5D,MAAA,OAAO,OAAA;AACT,IAAA,OAAO,IAAA;AAAA,EACT;AACF","file":"character_counter_controller.js","sourcesContent":["/**\n * Sends one message to the page's shared `stimeo--announcer`.\n *\n * A component that has to reach assistive tech does not carry a live region of its\n * own: a region only announces what changes *after* assistive tech already knows\n * about it, which a region that appears (or is un-hidden) with its message cannot\n * satisfy. The one region that can is the announcer sitting in the page from the\n * start, so state changes are handed to it as an event and it does the reading.\n *\n * The event goes to `window` because the announcer is usually a sibling high in the\n * document rather than an ancestor of the component dispatching it.\n *\n * Wording comes from the consumer — the library ships no English strings — so an\n * empty message is silently dropped and nothing is announced.\n *\n * @example\n * ```ts\n * announce(this.announceTextValue, { assertive: false });\n * ```\n */\nexport function announce(message: string, options: { assertive?: boolean } = {}): void {\n const text = message.trim();\n if (text.length === 0) return;\n window.dispatchEvent(\n new CustomEvent(\"stimeo--announcer:announce\", {\n detail: { message: text, assertive: options.assertive === true },\n }),\n );\n}\n\n/**\n * Fills `{name}` placeholders in an announcement template from `values`.\n *\n * The same substitution the value-text templates use, so a consumer writes\n * `\"{percent}% complete\"` in one attribute and gets the same rules everywhere. A\n * placeholder with no matching entry is left as authored rather than blanked, which\n * keeps a typo visible instead of silently swallowing the word.\n */\nexport function fillTemplate(template: string, values: Record<string, string | number>): string {\n return template.replace(/\\{([a-zA-Z][a-zA-Z0-9]*)\\}/g, (match, name: string) => {\n const replacement = values[name];\n return replacement === undefined ? match : String(replacement);\n });\n}\n","/** One temporarily controlled attribute value and the authored value it displaced. */\ninterface AttributeLeaseRecord {\n readonly original: string | null;\n written: string | null;\n}\n\n/**\n * Temporarily controls one attribute across a changing set of elements.\n *\n * The first write remembers the authored value, including the distinction between\n * an absent attribute and an authored empty string. Returning a lease restores that\n * value only while the attribute still matches the controller's last write. If a\n * consumer changed it in the meantime, the consumer owns the new value and teardown\n * leaves it alone.\n *\n * A `null` write deliberately removes the attribute while retaining the lease. This\n * is useful for derived ARIA whose valid absence is itself controller state, such as\n * an unbounded `aria-valuemin` or a blank spinbutton's `aria-valuenow`.\n *\n * The lease has no lifecycle of its own, so it never subscribes to document events.\n * A consumer that must not let a derived value become the authored baseline of a\n * cached page returns its leases from its own `turbo:before-cache` rewind, where the\n * matching `disconnect()` also releases the subscription.\n */\nexport class AttributeLease<T extends Element = Element> {\n readonly #attribute: string;\n readonly #records = new Map<T, AttributeLeaseRecord>();\n\n /** @param attribute - The attribute whose temporary values this lease owns. */\n constructor(attribute: string) {\n this.#attribute = attribute;\n }\n\n /** Writes or removes the leased attribute while preserving its authored value. */\n write(element: T, value: string | null): void {\n const existing = this.#records.get(element);\n if (existing) {\n existing.written = value;\n } else {\n this.#records.set(element, {\n original: element.getAttribute(this.#attribute),\n written: value,\n });\n }\n\n this.#reflect(element, value);\n }\n\n /** Returns one lease without overwriting a value subsequently authored by a consumer. */\n return(element: T): void {\n const record = this.#records.get(element);\n if (!record) return;\n this.#records.delete(element);\n const stillOwned = element.getAttribute(this.#attribute) === record.written;\n if (stillOwned) this.#reflect(element, record.original);\n }\n\n /** Reflects only a real value transition, avoiding self-triggered mutation work. */\n #reflect(element: T, value: string | null): void {\n if (element.getAttribute(this.#attribute) === value) return;\n if (value === null) element.removeAttribute(this.#attribute);\n else element.setAttribute(this.#attribute, value);\n }\n\n /** Returns every outstanding lease using the same ownership check as {@link return}. */\n returnAll(): void {\n for (const element of Array.from(this.#records.keys())) this.return(element);\n }\n}\n","/**\n * Runs a controller's \"return to the initial state\" pass just before Turbo\n * caches the page.\n *\n * **`disconnect()` cannot do this job, for two independent reasons.** Turbo\n * queues the clone from this event rather than taking it here, and the body swap\n * that runs the controller's `disconnect()` is queued separately — so which of\n * the two lands first is not something a controller can rely on, and a rewind\n * written in `disconnect()` may reach only the DOM being thrown away. In the\n * other direction, `disconnect()` also fires on an in-page move (Stimulus tears\n * down and reconnects the same element), where rewinding would wipe a\n * legitimately in-progress interaction — a spinner mid-load would vanish. One\n * timing is unreliable, the other is too eager; `turbo:before-cache` is the only\n * point that is exactly \"the page is about to be frozen\".\n *\n * Scope is the subscription only: registering on `activate()`, unregistering on\n * `deactivate()`, and one shared document listener no matter how many instances\n * are live. *What* to return to its initial state — which `data-state`, which\n * `hidden`, which `aria-busy` — stays in the controller, because no two\n * consumers answer it the same way.\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 * Collapses many Stimulus lifecycle callbacks from one DOM mutation into a\n * single pass.\n *\n * Stimulus fires `<name>TargetConnected` / `Disconnected` once per element and\n * `<name>ValueChanged` once per changed attribute. Replacing a list of N options\n * or morphing several render Values therefore delivers N callbacks — but the\n * useful unit of work is \"reconcile against the resulting declarative input\",\n * once, after the batch has settled. Every controller with reconcilable targets\n * or render Values needs the same shape: a `queued` flag plus `queueMicrotask`.\n *\n * **A microtask is the right horizon, and the reason is specific.** Stimulus\n * drives these callbacks from a `MutationObserver`, whose own callback already\n * runs as a microtask with the whole batch in hand; scheduling one more lands\n * after the last sibling callback of that batch and still before paint or any\n * event handler. A timer would be later than it needs to be, and reconciling\n * synchronously would run once per element against a half-applied DOM.\n *\n * **The two guards are not the same guard.** Scheduling is refused before the\n * controller connects, and running is refused after it disconnects:\n *\n * - **Before `connect()`** — Stimulus delivers initial target and Value callbacks\n * ahead of `connect()`. Reconciling there would compute output against a\n * controller whose own state has not been initialised, and `connect()` is\n * about to do a full pass anyway.\n * - **After `disconnect()`** — Stimulus fires a callback for **every** target\n * during teardown, and a microtask queued just before it would otherwise run\n * against a detached tree. {@link MicrotaskCoalescer.cancel} exists for the\n * teardown path to drop the pending pass outright.\n *\n * Both guards are part of one contract here rather than something each consumer\n * has to remember separately.\n *\n * Scope is the scheduling only. *What* to reconcile — keep the surviving active\n * option, fall back to the next / previous / first visible one, rebuild derived\n * chips or hidden fields — stays in the controller, because no two consumers\n * answer it the same way.\n *\n * This file's own doc block is dropped from `dist`, but every member comment is\n * inlined into each consumer entry (`tsup` builds with `splitting: false`), so\n * rationale belongs here and only the contract belongs on the members.\n *\n * @example\n * ```ts\n * readonly #reconcile = new MicrotaskCoalescer(() => this.#reconcileOptions());\n *\n * connect() { this.#reconcile.activate(); }\n * disconnect() { this.#reconcile.cancel(); }\n *\n * optionTargetConnected() { this.#reconcile.schedule(); }\n * optionTargetDisconnected() { this.#reconcile.schedule(); }\n * ```\n */\nexport class MicrotaskCoalescer {\n readonly #run: () => void;\n #queued = false;\n #active = false;\n #generation = 0;\n\n /** @param run - the single reconciliation pass, invoked at most once per batch. */\n constructor(run: () => void) {\n this.#run = run;\n }\n\n /** Opens the window in which {@link schedule} is honoured; call from `connect()`. */\n activate(): void {\n this.#active = true;\n }\n\n /** Closes the window and drops any pending pass; call from `disconnect()`. */\n cancel(): void {\n this.#active = false;\n this.#queued = false;\n this.#generation += 1;\n }\n\n /** Requests one pass after the batch settles. Idempotent; inert outside the window. */\n schedule(): void {\n if (!this.#active || this.#queued) return;\n this.#queued = true;\n const generation = this.#generation;\n queueMicrotask(() => {\n // A cancelled callback must not consume a pass queued after reconnect.\n if (generation !== this.#generation || !this.#queued || !this.#active) return;\n this.#queued = false;\n this.#run();\n });\n }\n}\n","/**\n * Self-cleaning timer registries shared by Stimeo controllers.\n *\n * Stimulus controllers frequently schedule `setTimeout` / `setInterval` work\n * (auto-dismiss, debouncing, polling). When the element leaves the DOM — a\n * Turbo Drive navigation, a Turbo Stream replacement, or any `disconnect()` —\n * orphaned timers keep firing against a detached controller, leaking memory and\n * mutating stale state. {@link SafeTimeout} and {@link SafeInterval} track every\n * timer they create so a single {@link TimerRegistry.clearAll | clearAll()} call\n * in `disconnect()` tears them all down.\n *\n * These are intentionally low-level primitives: they own *registration and\n * cleanup only*. Higher-level policy (pause/resume, remaining-time accounting)\n * stays in the individual controllers so per-widget semantics are not flattened\n * into a lowest-common-denominator helper.\n */\n\n/**\n * Largest delay a timer can hold: the platform stores it in a 32-bit signed\n * integer, and anything larger overflows to `1`, so a delay meant to be far in\n * the future fires almost immediately. A declared delay above this bound names\n * no delay at all, and a controller reading one falls back to its default.\n */\nexport const MAX_TIMER_DELAY_MS = 2_147_483_647;\n\n/**\n * Shared registry bookkeeping for the timeout/interval variants.\n *\n * Subclasses provide the scheduling primitive ({@link schedule}) and its matching\n * canceller ({@link cancel}); this base owns the set of live ids plus the\n * per-id and bulk teardown shared by both.\n */\nabstract class TimerRegistry {\n /** Live timer ids that have not yet been cleared (or, for timeouts, fired). */\n protected readonly ids = new Set<number>();\n\n /** Schedules the underlying platform timer and returns its id. */\n protected abstract schedule(callback: () => void, delay: number): number;\n\n /** Cancels the underlying platform timer for `id`. */\n protected abstract cancel(id: number): void;\n\n /**\n * Cancels a single tracked timer.\n *\n * No-ops if the id is unknown (already cleared, fired, or never owned by this\n * registry), so callers can clear defensively without guarding.\n */\n clear(id: number): void {\n if (this.ids.delete(id)) {\n this.cancel(id);\n }\n }\n\n /**\n * Cancels every tracked timer. Call this from a controller's `disconnect()`\n * to guarantee no timer outlives the element.\n */\n clearAll(): void {\n for (const id of this.ids) {\n this.cancel(id);\n }\n this.ids.clear();\n }\n\n /** Number of timers currently tracked (pending). */\n get size(): number {\n return this.ids.size;\n }\n}\n\n/**\n * `setTimeout` wrapper that auto-forgets each timer once it fires and supports\n * bulk teardown on disconnect.\n *\n * @example\n * ```ts\n * #timers = new SafeTimeout();\n *\n * connect() {\n * this.#timers.set(() => this.dismiss(), 5000);\n * }\n *\n * disconnect() {\n * this.#timers.clearAll();\n * }\n * ```\n */\nexport class SafeTimeout extends TimerRegistry {\n /**\n * Schedules `callback` after `delay` ms and returns the timer id.\n *\n * The id is removed from the registry automatically when the timeout fires,\n * so {@link TimerRegistry.size | size} reflects only still-pending timers.\n */\n set(callback: () => void, delay: number): number {\n const id = this.schedule(() => {\n this.ids.delete(id);\n callback();\n }, delay);\n this.ids.add(id);\n return id;\n }\n\n protected schedule(callback: () => void, delay: number): number {\n return window.setTimeout(callback, delay);\n }\n\n protected cancel(id: number): void {\n window.clearTimeout(id);\n }\n}\n\n/**\n * `setInterval` wrapper that tracks every interval for bulk teardown on\n * disconnect. Unlike {@link SafeTimeout}, intervals are retained until they are\n * explicitly cleared because they fire repeatedly.\n *\n * @example\n * ```ts\n * #intervals = new SafeInterval();\n *\n * connect() {\n * this.#intervals.set(() => this.tick(), 1000);\n * }\n *\n * disconnect() {\n * this.#intervals.clearAll();\n * }\n * ```\n */\nexport class SafeInterval extends TimerRegistry {\n /** Schedules a repeating `callback` every `delay` ms and returns the timer id. */\n set(callback: () => void, delay: number): number {\n const id = this.schedule(callback, delay);\n this.ids.add(id);\n return id;\n }\n\n protected schedule(callback: () => void, delay: number): number {\n return window.setInterval(callback, delay);\n }\n\n protected cancel(id: number): void {\n window.clearInterval(id);\n }\n}\n","import { Controller } from \"@hotwired/stimulus\";\nimport { announce, fillTemplate } from \"../utils/announce\";\nimport { AttributeLease } from \"../utils/attribute_lease\";\nimport { BeforeCacheReset } from \"../utils/before_cache_reset\";\nimport { CompositionTracker } from \"../utils/composition_tracker\";\nimport { MicrotaskCoalescer } from \"../utils/microtask_coalescer\";\nimport { SafeTimeout } from \"../utils/safe_timeout\";\n\ntype CharacterCounterField = HTMLInputElement | HTMLTextAreaElement;\ntype DisplayMode = \"remaining\" | \"used\" | \"both\";\n\ninterface CharacterCountReading {\n readonly length: number;\n readonly remaining: number | null;\n readonly over: boolean;\n readonly max: number;\n readonly text: string;\n}\n\ntype CharacterCounterDetail = Pick<CharacterCountReading, \"length\" | \"remaining\" | \"over\">;\n\n/**\n * Headless character-counter behavior for a text field (no dedicated APG\n * pattern; follows the WCAG 2.2 \"status messages\" practice, 4.1.3).\n *\n * Markup contract (identifier: `stimeo--character-counter`):\n * <div data-controller=\"stimeo--character-counter\"\n * data-stimeo--character-counter-max-value=\"140\"\n * data-stimeo--character-counter-announce-text-value=\"{remaining} characters remaining\">\n * <textarea data-stimeo--character-counter-target=\"input\"\n * aria-describedby=\"cc\"></textarea>\n * <span id=\"cc\" data-stimeo--character-counter-target=\"output\"></span>\n * </div>\n *\n * Watches the field's UTF-16 code-unit length, writes the remaining/used count\n * into `output`, and toggles the `data-near-limit` / `data-over-limit` state\n * hooks. While over the limit it temporarily leases `aria-invalid=\"true\"` on\n * the field and returns the consumer's authored value on recovery or teardown.\n * The field is the first `input` target, or — when the controller is attached\n * straight onto an `<input>`/`<textarea>` — the controller element itself.\n *\n * `change` and `reconcile` dispatch\n * `{ length: number, remaining: number | null, over: boolean }`.\n *\n * @remarks\n * Behavior only — count text and state update synchronously, with no styling.\n * Confirmed user input dispatches `stimeo--character-counter:change` only when\n * the measured length actually changes. Its detail is `{ length, remaining,\n * over }`; `remaining` is `null` when `max` is disabled. IME intermediate input\n * is ignored, and `compositionend` commits the confirmed value exactly once.\n *\n * Assistive notification is opt-in and i18n-neutral. `announceText` accepts\n * `{count}`, `{length}`, `{remaining}`, `{max}`, and `{over}` placeholders and\n * sends the settled message to the page's shared `stimeo--announcer` after a\n * short debounce. The visible `output` is not itself required to be a live\n * region. Initial reflection and Turbo restoration never dispatch or announce.\n * Runtime target/Value reconciliation dispatches\n * `stimeo--character-counter:reconcile` only when the public derived state\n * changes, and never announces.\n */\nexport class CharacterCounterController extends Controller<HTMLElement> {\n static override targets = [\"input\", \"output\"];\n static override values = {\n max: { type: Number, default: 0 },\n warnAt: { type: Number, default: 0 },\n mode: { type: String, default: \"remaining\" },\n announceText: { type: String, default: \"\" },\n };\n static events = [\"change\", \"reconcile\"] as const;\n\n declare readonly inputTarget: CharacterCounterField;\n declare readonly outputTarget: HTMLElement;\n declare readonly hasInputTarget: boolean;\n declare readonly hasOutputTarget: boolean;\n\n declare maxValue: number;\n declare warnAtValue: number;\n declare modeValue: string;\n declare announceTextValue: string;\n\n /** Delay (ms) before one settled count is sent to the shared announcer. */\n static readonly #announceDelay = 200;\n\n readonly #timeouts = new SafeTimeout();\n readonly #ariaInvalid = new AttributeLease<CharacterCounterField>(\"aria-invalid\");\n readonly #beforeCache = new BeforeCacheReset(() => this.#rewindForCache());\n readonly #repaint = new MicrotaskCoalescer(() => this.#reconcile(true));\n readonly #composition = new CompositionTracker({\n onEnd: (event) => this.#commitFrom(event.currentTarget),\n });\n #announceId: number | null = null;\n #boundField: CharacterCounterField | null = null;\n #lastLength: number | null = null;\n #lastDetail: CharacterCounterDetail | null = null;\n #reflectedOver: boolean | null = null;\n\n readonly #onInput = (event: Event): void => {\n const field = this.#boundField;\n if (!field || event.currentTarget !== field || this.#field !== field) return;\n // An engine may echo a confirmed composition with one more `input`;\n // committing it again would re-run the reading the commit already took.\n if (this.#composition.consumesConfirmedInput(event)) return;\n if (this.#composition.isComposing(event as InputEvent)) return;\n this.#commit(field);\n };\n\n /** Reflects the current DOM state and opens the mutation-reconciliation window. */\n override connect(): void {\n this.#repaint.activate();\n this.#beforeCache.activate();\n this.#reconcile(false);\n }\n\n /** Releases listeners, timers, borrowed ARIA, and controller-owned state hooks. */\n override disconnect(): void {\n this.#repaint.cancel();\n this.#beforeCache.deactivate();\n this.#cancelAnnouncement();\n this.#bindField(null);\n this.#composition.disconnect();\n this.#clearStateHooks();\n this.#lastLength = null;\n this.#lastDetail = null;\n }\n\n /** Rebinds and repaints after an input target is added or replaced at runtime. */\n inputTargetConnected(): void {\n this.#repaint.schedule();\n }\n\n /** Releases and repaints after an input target is removed or replaced at runtime. */\n inputTargetDisconnected(): void {\n this.#repaint.schedule();\n }\n\n /** Initializes a display target inserted after the controller connected. */\n outputTargetConnected(): void {\n this.#repaint.schedule();\n }\n\n /** Reconciles the optional display target set after a removal or replacement. */\n outputTargetDisconnected(): void {\n this.#repaint.schedule();\n }\n\n /** Repaints when application code or a Turbo morph changes `max`. */\n maxValueChanged(): void {\n this.#repaint.schedule();\n }\n\n /** Repaints when application code or a Turbo morph changes `warnAt`. */\n warnAtValueChanged(): void {\n this.#repaint.schedule();\n }\n\n /** Repaints when application code or a Turbo morph changes `mode`. */\n modeValueChanged(): void {\n this.#repaint.schedule();\n }\n\n /** Rewords a pending announcement with the template the consumer changed it to. */\n announceTextValueChanged(): void {\n this.#repaint.schedule();\n }\n\n /** Rebinds one mutation batch and reports a changed controller-derived state. */\n #reconcile(report: boolean): void {\n const previous = this.#lastDetail;\n // An edit inside the debounce window has already earned an announcement.\n // Reconciliation never originates one, but it must not swallow that one\n // either: the pending message is retargeted at the settled reading, so the\n // user hears the count that ends up displayed rather than nothing. A\n // replaced field is the exception — its pending message describes a field\n // the reader can no longer reach.\n const owedField = this.#announceId === null ? null : this.#boundField;\n this.#cancelAnnouncement();\n this.#bindField(this.#field);\n if (this.#composition.isComposing()) return;\n const field = this.#boundField;\n if (!field) {\n this.#renderEmpty();\n this.#lastLength = null;\n this.#lastDetail = null;\n return;\n }\n const reading = this.#render(field);\n const detail = this.#detail(reading);\n this.#lastLength = reading.length;\n this.#lastDetail = detail;\n if (owedField === field) this.#scheduleAnnouncement(reading);\n if (report && previous && this.#detailsDiffer(previous, detail)) {\n this.dispatch(\"reconcile\", { detail });\n }\n }\n\n /** Commits a composition only when it came from the field still owned here. */\n #commitFrom(target: EventTarget | null): void {\n const field = this.#boundField;\n if (!field || target !== field || this.#field !== field) return;\n this.#commit(field);\n }\n\n /** Reflects one confirmed user input and reports only a real length transition. */\n #commit(field: CharacterCounterField): void {\n const reading = this.#render(field);\n const previousLength = this.#lastLength;\n const previousDetail = this.#lastDetail;\n const detail = this.#detail(reading);\n this.#lastLength = reading.length;\n this.#lastDetail = detail;\n if (previousLength === reading.length) {\n if (previousDetail && this.#detailsDiffer(previousDetail, detail)) {\n this.dispatch(\"reconcile\", { detail });\n }\n return;\n }\n\n this.dispatch(\"change\", { detail });\n this.#scheduleAnnouncement(reading);\n }\n\n /** Selects the public event state from the richer internal reading. */\n #detail(reading: CharacterCountReading): CharacterCounterDetail {\n return {\n length: reading.length,\n remaining: reading.remaining,\n over: reading.over,\n };\n }\n\n /** Compares exactly the state carried by `change` and `reconcile`. */\n #detailsDiffer(left: CharacterCounterDetail, right: CharacterCounterDetail): boolean {\n return (\n left.length !== right.length || left.remaining !== right.remaining || left.over !== right.over\n );\n }\n\n /**\n * Synchronizes visible count, state hooks, and temporary validation ARIA.\n *\n * @stimeoRenderRoot\n */\n #render(field: CharacterCounterField): CharacterCountReading {\n const length = field.value.length;\n const max = this.#normalizeCount(this.maxValue);\n const warnAt = this.#normalizeCount(this.warnAtValue);\n const remaining = max > 0 ? max - length : null;\n const over = remaining !== null && remaining < 0;\n const near = remaining !== null && warnAt > 0 && !over && remaining <= warnAt;\n\n this.#toggle(\"data-over-limit\", over);\n this.#toggle(\"data-near-limit\", near);\n this.#reflectInvalid(field, over);\n\n const text = this.#format(length, remaining, max);\n this.#writeOutput(text);\n return { length, remaining, over, max, text };\n }\n\n /** Clears derived output when the declarative input set has no usable field. */\n #renderEmpty(): void {\n this.#ariaInvalid.returnAll();\n this.#reflectedOver = null;\n this.#clearStateHooks();\n this.#writeOutput(\"\");\n }\n\n /** Replaces the observed field symmetrically, returning state from the old one. */\n #bindField(field: CharacterCounterField | null): void {\n if (field === this.#boundField) return;\n\n const previous = this.#boundField;\n if (previous) {\n previous.removeEventListener(\"input\", this.#onInput);\n this.#composition.unobserve(previous);\n this.#ariaInvalid.return(previous);\n }\n\n this.#boundField = field;\n this.#lastLength = null;\n this.#reflectedOver = null;\n if (!field) return;\n\n field.addEventListener(\"input\", this.#onInput);\n this.#composition.observe(field);\n }\n\n /** Leases `aria-invalid` only on the edge into over-limit, then returns it. */\n #reflectInvalid(field: CharacterCounterField, over: boolean): void {\n if (this.#reflectedOver === over) return;\n this.#reflectedOver = over;\n if (over) this.#ariaInvalid.write(field, \"true\");\n else this.#ariaInvalid.return(field);\n }\n\n /** Builds the visible count for the normalized display mode. */\n #format(length: number, remaining: number | null, max: number): string {\n if (remaining === null) return String(length);\n switch (this.#mode) {\n case \"used\":\n return String(length);\n case \"both\":\n return `${length}/${max}`;\n default:\n return String(remaining);\n }\n }\n\n /**\n * Debounces one i18n-neutral message into the shared polite announcer.\n *\n * @stimeoRuntimeOnly `announceText` is the template of the one announcement this call schedules;\n * the count is painted by the marked renderer.\n */\n #scheduleAnnouncement(reading: CharacterCountReading): void {\n this.#cancelAnnouncement();\n const message = fillTemplate(this.announceTextValue, {\n count: reading.text,\n length: reading.length,\n remaining: reading.remaining ?? \"\",\n max: reading.max,\n over: String(reading.over),\n });\n if (message.trim().length === 0) return;\n\n this.#announceId = this.#timeouts.set(() => {\n announce(message);\n this.#announceId = null;\n }, CharacterCounterController.#announceDelay);\n }\n\n /** Cancels the one outstanding announcement without touching visible output. */\n #cancelAnnouncement(): void {\n if (this.#announceId !== null) this.#timeouts.clear(this.#announceId);\n this.#announceId = null;\n }\n\n /** Writes the optional display only when its text actually changed. */\n #writeOutput(text: string): void {\n if (!this.hasOutputTarget || this.outputTarget.textContent === text) return;\n this.outputTarget.textContent = text;\n }\n\n /** Reflects a presence-style state hook without redundant attribute writes. */\n #toggle(name: string, on: boolean): void {\n if (on) {\n if (this.element.getAttribute(name) !== \"true\") this.element.setAttribute(name, \"true\");\n } else if (this.element.hasAttribute(name)) {\n this.element.removeAttribute(name);\n }\n }\n\n /** Removes both state hooks owned by this controller. */\n #clearStateHooks(): void {\n this.#toggle(\"data-over-limit\", false);\n this.#toggle(\"data-near-limit\", false);\n }\n\n /** Returns borrowed ARIA and transient hooks before Turbo snapshots the page. */\n #rewindForCache(): void {\n this.#cancelAnnouncement();\n this.#ariaInvalid.returnAll();\n this.#reflectedOver = null;\n this.#clearStateHooks();\n }\n\n /** Converts a public count Value into a finite non-negative integer. */\n #normalizeCount(raw: number): number {\n if (!Number.isFinite(raw)) return 0;\n return Math.max(0, Math.trunc(raw));\n }\n\n /** Falls back to `remaining` when an authored display mode is unknown. */\n get #mode(): DisplayMode {\n if (this.modeValue === \"used\" || this.modeValue === \"both\") return this.modeValue;\n return \"remaining\";\n }\n\n /** The watched field: the first target, or a directly controlled form field. */\n get #field(): CharacterCounterField | null {\n if (this.hasInputTarget) return this.inputTarget;\n const element: HTMLElement = this.element;\n if (element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement)\n return element;\n return null;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/announce.ts","../../src/utils/shared_registry.ts","../../src/utils/attribute_lease.ts","../../src/utils/composition_tracker.ts","../../src/utils/listener_set.ts","../../src/utils/microtask_coalescer.ts","../../src/utils/morph_render_watcher.ts","../../src/utils/number_bounds.ts","../../src/utils/coerce.ts","../../src/utils/number_value.ts","../../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;AAAA,EAGA,IAAI,MAAA,GAAuC;AACzC,IAAA,IAAI,IAAA,CAAK,cAAA,EAAgB,OAAO,IAAA,CAAK,WAAA;AACrC,IAAA,MAAM,UAAuB,IAAA,CAAK,OAAA;AAClC,IAAA,IAAI,OAAA,YAAmB,oBAAoB,OAAA,YAAmB,mBAAA;AAC5D,MAAA,OAAO,OAAA;AACT,IAAA,OAAO,IAAA;AAAA,EACT;AAAA,EAEA,IAAI,QAAA,GAAmB;AACrB,IAAA,OAAO,KAAK,QAAA,CAAS,IAAA;AAAA,MACnB,IAAA;AAAA,MACA,KAAA;AAAA,MACA,IAAA,CAAK,QAAA;AAAA,MACL,2BAAA,CAA2B,OAAO,GAAA,CAAI,OAAA;AAAA,MACtC,4BAA2B,gBAAA,CAAiB;AAAA,KAC9C;AAAA,EACF;AAAA,EAGA,IAAI,WAAA,GAAsB;AACxB,IAAA,OAAO,KAAK,QAAA,CAAS,IAAA;AAAA,MACnB,IAAA;AAAA,MACA,QAAA;AAAA,MACA,IAAA,CAAK,WAAA;AAAA,MACL,2BAAA,CAA2B,OAAO,MAAA,CAAO,OAAA;AAAA,MACzC,4BAA2B,gBAAA,CAAiB;AAAA,KAC9C;AAAA,EACF;AACF","file":"character_counter_controller.js","sourcesContent":["/**\n * Sends one message to the page's shared `stimeo--announcer`.\n *\n * A component that has to reach assistive tech does not carry a live region of its\n * own: a region only announces what changes *after* assistive tech already knows\n * about it, which a region that appears (or is un-hidden) with its message cannot\n * satisfy. The one region that can is the announcer sitting in the page from the\n * start, so state changes are handed to it as an event and it does the reading.\n *\n * The event goes to `window` because the announcer is usually a sibling high in the\n * document rather than an ancestor of the component dispatching it.\n *\n * Wording comes from the consumer — the library ships no English strings — so an\n * empty message is silently dropped and nothing is announced.\n *\n * @example\n * ```ts\n * announce(this.announceTextValue, { assertive: false });\n * ```\n */\nexport function announce(message: string, options: { assertive?: boolean } = {}): void {\n const text = message.trim();\n if (text.length === 0) return;\n window.dispatchEvent(\n new CustomEvent(\"stimeo--announcer:announce\", {\n detail: { message: text, assertive: options.assertive === true },\n }),\n );\n}\n\n/**\n * Fills `{name}` placeholders in an announcement template from `values`.\n *\n * The same substitution the value-text templates use, so a consumer writes\n * `\"{percent}% complete\"` in one attribute and gets the same rules everywhere. A\n * placeholder with no matching entry is left as authored rather than blanked, which\n * keeps a typo visible instead of silently swallowing the word.\n */\nexport function fillTemplate(template: string, values: Record<string, string | number>): string {\n return template.replace(/\\{([a-zA-Z][a-zA-Z0-9]*)\\}/g, (match, name: string) => {\n const replacement = values[name];\n return replacement === undefined ? match : String(replacement);\n });\n}\n","/**\n * One registry per page for every copy of the library.\n *\n * Each `stimeo-ui/controllers/*` file, and each opt-in entry, is built on its own and carries\n * its own copy of every utility it uses, so a page that imports controllers one by one, or one\n * of them next to the barrel, evaluates a utility several times. A registry that coordinates\n * instances of different controllers — the stacks of leased values, the loans of a\n * `tabindex`, the Escape layers, the focus traps — must not be split by that: a dialog inside\n * a drawer, or a character counter and a form field on one input, coordinate whichever files\n * they came from. So such a registry lives once on `globalThis`, under a `Symbol.for` key the\n * copies agree on, and the first copy to ask for it creates it.\n *\n * The key names the registry and the version of its shape\n * (`stimeo-ui.<utility>.registry.v<n>`). Copies whose registries have the same shape share\n * one; a release that changes the shape changes the version, so a copy of another release\n * keeps a registry of its own instead of reading entries it does not understand — the two\n * then coordinate within each release only. An entry another copy put in a registry is read\n * through its fields alone, never through `#private` members, which belong to the class of\n * the copy that created it.\n */\n\n/**\n * The registry stored under `key`, created by `create` on first use.\n *\n * @param key - `stimeo-ui.<utility>.registry.v<n>`: the version is that of the shape `create`\n * returns.\n * @param create - Builds the empty registry.\n */\nexport function sharedRegistry<T extends object>(key: string, create: () => T): T {\n const symbol = Symbol.for(key);\n const scope = globalThis as unknown as Record<symbol, T | undefined>;\n const existing = scope[symbol];\n if (existing !== undefined) return existing;\n const registry = create();\n Object.defineProperty(globalThis, symbol, { value: registry });\n return registry;\n}\n","import { 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 * Owns every listener a controller attaches for one connected lifetime and\n * releases them together, so an event name is spelled once and the release\n * cannot drift from the registration.\n *\n * Detaching by hand repeats three things at the release site — the type, the\n * handler reference and the capture flag — and any one of them drifting leaves\n * a listener alive on an element the controller no longer drives. Aborting the\n * signal a registration was created with releases it whatever it was made of,\n * so the release site names nothing.\n *\n * One set per lifetime, held as a field and never rebuilt. {@link\n * ListenerSet.dispose} is the only thing that closes a generation, and it opens\n * the next one in the same step, so the lifecycle hooks can call `add` and\n * `dispose` in any order any number of times, and no `add` ever meets an\n * already aborted signal — a DOM that registers a listener on such a signal\n * would keep it forever. Rebuilding the set instead would leak:\n * `addEventListener` matches an existing registration on target, type, callback\n * and capture alone, so re-adding the same handler while the first registration\n * is live is discarded, and that live registration keeps the signal it was\n * attached with — a set built by a second `connect()` can never release what it\n * appears to own.\n *\n * Scope is the registration only. Timers, observers, leases and the order they\n * are unwound in stay with the controller, which places `dispose()` in its\n * cleanup sequence. A receiver that changes at runtime (a\n * swapped target) is rebound by calling `dispose()` and then `add()` again from\n * the rebind, not by a second set.\n *\n * The set must own every registration of a tuple it holds: a listener the same\n * target already carries for the same type, callback and capture flag keeps the\n * right to remove it, and this set's `add` for that tuple is discarded. A\n * subscription shared between instances behind a participant count, or one that\n * lives for less than the connection, keeps its own pair of calls.\n *\n * @example\n * ```ts\n * readonly #listeners = new ListenerSet();\n *\n * connect(): void {\n * this.#listeners.add(this.element, \"submit\", this.#onNativeSubmit, { capture: true });\n * this.#listeners.add(this.element, \"turbo:submit-start\", this.#onSubmitStart);\n * this.#listeners.add(this.element, \"turbo:submit-end\", this.#onSubmitEnd);\n * }\n *\n * disconnect(): void {\n * this.#listeners.dispose();\n * }\n * ```\n */\nexport class ListenerSet {\n /** The generation every `add` joins until the next `dispose()`. */\n #abort = new AbortController();\n\n /**\n * Attaches `handler` to the open generation, exactly as the caller spelled it.\n *\n * The set supplies the signal, so `options` carries everything else the DOM\n * accepts — `capture` included, which has to match at release time and no\n * longer has a second place to drift from.\n */\n add(\n target: EventTarget,\n type: string,\n handler: EventListener,\n options?: Omit<AddEventListenerOptions, \"signal\">,\n ): void {\n target.addEventListener(type, handler, { ...options, signal: this.#abort.signal });\n }\n\n /**\n * Releases every listener of the open generation, synchronously, and opens the\n * next one. Idempotent, and safe before anything has been added.\n */\n dispose(): void {\n this.#abort.abort();\n this.#abort = new AbortController();\n }\n}\n","/**\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","import { ListenerSet } from \"./listener_set\";\nimport { MicrotaskCoalescer } from \"./microtask_coalescer\";\n\n/**\n * Coalesces retained-element morphs and explicit lifecycle requests into one pass.\n *\n * Observe the controller's element after its initial state is settled. Morphs on\n * that element and bubbling morphs on its descendants share the same microtask\n * as {@link schedule}. The callback repairs derived output; the controller owns\n * any logical transition reporting. {@link disconnect} releases the listener and\n * cancels pending work, including work from an earlier connected lifetime.\n */\nexport class MorphRenderWatcher {\n readonly #listeners = new ListenerSet();\n readonly #pass: MicrotaskCoalescer;\n #element: Element | null = null;\n readonly #onMorph = (): void => this.#pass.schedule();\n\n /** @param run - the single pass that repairs the settled controller's output. */\n constructor(run: () => void) {\n this.#pass = new MicrotaskCoalescer(run);\n }\n\n /** Opens observation; observing the same element again preserves queued work. */\n observe(element: Element): void {\n if (this.#element === element) return;\n this.disconnect();\n this.#element = element;\n this.#pass.activate();\n this.#listeners.add(element, \"turbo:morph-element\", this.#onMorph);\n }\n\n /** Requests one pass; requests outside an observed lifetime are ignored. */\n schedule(): void {\n this.#pass.schedule();\n }\n\n /** Releases observation and pending work synchronously; safe to repeat. */\n disconnect(): void {\n this.#listeners.dispose();\n this.#pass.cancel();\n this.#element = null;\n }\n}\n","import { MAX_TIMER_DELAY_MS } from \"./timer_bounds\";\n\n/** Semantic constraints on an already decoded number, independent of the DOM. */\nexport interface NumberBounds {\n /** Finite numbers are required, including when this field is omitted. */\n readonly finite?: true;\n /** Inclusive lower endpoint. */\n readonly min?: number;\n /** Inclusive upper endpoint. */\n readonly max?: number;\n /** Exclusive lower endpoint. */\n readonly exclusiveMin?: number;\n /** Require a number without a fractional part. */\n readonly integer?: boolean;\n /** Exact decoded numbers accepted by a discrete contract. */\n readonly allowedValues?: readonly number[];\n /** JSON-safe exceptions to finite-number checking for unbounded endpoints. */\n readonly allowInfinity?: \"negative\" | \"positive\" | \"both\";\n}\n\n/** One constraint for each Number Value, including shorthand declarations. */\nexport type NumberValueConstraints<Values> = {\n readonly [Key in keyof Values as Values[Key] extends\n | NumberConstructor\n | { type: NumberConstructor }\n ? Key\n : never]: NumberBounds;\n};\n\n/** Reusable semantic domains; fractional inputs remain fractional unless excluded. */\nexport const NUMBER_BOUNDS = {\n finite: { finite: true },\n nonNegative: { finite: true, min: 0 },\n positive: { finite: true, exclusiveMin: 0 },\n nonNegativeInteger: { finite: true, min: 0, integer: true },\n positiveInteger: { finite: true, exclusiveMin: 0, integer: true },\n lowerBound: { finite: true, allowInfinity: \"negative\" },\n upperBound: { finite: true, allowInfinity: \"positive\" },\n timer: { finite: true, min: 0, max: MAX_TIMER_DELAY_MS },\n positiveTimer: { finite: true, exclusiveMin: 0, max: MAX_TIMER_DELAY_MS },\n} as const satisfies Record<string, NumberBounds>;\n\n/**\n * Checks all declared bounds without rounding, clamping, or coercing the input.\n * Infinity exceptions relax only finite checking; every other bound still applies.\n */\nexport function matchesNumberBounds(value: number, bounds: NumberBounds): boolean {\n if (!Number.isFinite(value)) {\n const direction = value === Infinity ? \"positive\" : value === -Infinity ? \"negative\" : null;\n if (direction === null) return false;\n if (bounds.allowInfinity !== \"both\" && bounds.allowInfinity !== direction) return false;\n }\n if (bounds.min !== undefined && value < bounds.min) return false;\n if (bounds.max !== undefined && value > bounds.max) return false;\n if (bounds.exclusiveMin !== undefined && value <= bounds.exclusiveMin) return false;\n if (bounds.integer && !Number.isInteger(value)) return false;\n if (bounds.allowedValues !== undefined && !bounds.allowedValues.includes(value)) return false;\n return true;\n}\n\n/** Decodes a Number Value literal; action params use their own JSON decoder. */\nexport function decodeNumberValue(raw: string): number {\n return Number(raw.replace(/_/g, \"\"));\n}\n","/**\n * Numeric coercion for controllers that accept a number through a Value, an action\n * param, or an event detail.\n *\n * Stimulus decodes action params as JSON when possible and leaves other text\n * untouched. CustomEvent detail can also supply a number or numeric string.\n * The reader accepts those two types while rejecting blank and non-finite input.\n */\n\nimport { matchesNumberBounds, type NumberBounds } from \"./number_bounds\";\n\n/**\n * Reads a finite number or nonblank numeric string; other input returns `null`.\n * Blank strings cannot silently reset a value to zero.\n */\nexport function toFiniteNumber(raw: unknown): number | null {\n if (typeof raw !== \"number\" && typeof raw !== \"string\") return null;\n if (typeof raw === \"string\" && raw.trim().length === 0) return null;\n const value = Number(raw);\n return Number.isFinite(value) ? value : null;\n}\n\n/**\n * Returns an accepted decoded Number Value or the caller's fallback unchanged.\n * The caller owns the fallback contract; this reader does not parse or write a Value.\n */\nexport function readNumber(raw: number, fallback: number, bounds: NumberBounds): number {\n return matchesNumberBounds(raw, bounds) ? raw : fallback;\n}\n","import { readNumber } from \"./coerce\";\nimport { matchesNumberBounds, type NumberBounds } from \"./number_bounds\";\n\n/** The instance identity carried by a Number Value read. */\nexport interface NumberValueOwner {\n readonly identifier: string;\n readonly element: Element;\n}\n\n/** Reads current declarations at the point of use without rewriting their attributes. */\nexport class NumberValueReader {\n /** The last rejected literal per Value; no history grows for an unchanged instance. */\n readonly #lastRejected = new Map<string, string>();\n\n /** Resolves the declared number using its own fallback and shared class contract. */\n read(\n owner: NumberValueOwner,\n name: string,\n raw: number,\n fallback: number,\n bounds: NumberBounds,\n ): number {\n const resolved = readNumber(raw, fallback, bounds);\n if (matchesNumberBounds(raw, bounds)) {\n this.#lastRejected.delete(name);\n return resolved;\n }\n const attribute = `data-${owner.identifier}-${name.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)}-value`;\n const literal = owner.element.getAttribute(attribute);\n if (literal === null) {\n this.#lastRejected.delete(name);\n return resolved;\n }\n if (this.#lastRejected.get(name) !== literal) {\n this.#lastRejected.set(name, literal);\n console.warn(\n `Stimeo UI: \"${owner.identifier}\" has an invalid number Value \"${name}\" declaration ${JSON.stringify(literal)}; using ${fallback}.`,\n );\n }\n return resolved;\n }\n}\n","/**\n * Self-cleaning timer registries shared by Stimeo controllers.\n *\n * Stimulus controllers frequently schedule `setTimeout` / `setInterval` work\n * (auto-dismiss, debouncing, polling). When the element leaves the DOM — a\n * Turbo Drive navigation, a Turbo Stream replacement, or any `disconnect()` —\n * orphaned timers keep firing against a detached controller, leaking memory and\n * mutating stale state. {@link SafeTimeout} and {@link SafeInterval} track every\n * timer they create so a single {@link TimerRegistry.clearAll | clearAll()} call\n * in `disconnect()` tears them all down.\n *\n * These are intentionally low-level primitives: they own *registration and\n * cleanup only*. Higher-level policy (pause/resume, remaining-time accounting)\n * stays in the individual controllers so per-widget semantics are not flattened\n * into a lowest-common-denominator helper.\n */\n\nexport { MAX_TIMER_DELAY_MS } from \"./timer_bounds\";\n\n/**\n * Shared registry bookkeeping for the timeout/interval variants.\n *\n * Subclasses provide the scheduling primitive ({@link schedule}) and its matching\n * canceller ({@link cancel}); this base owns the set of live ids plus the\n * per-id and bulk teardown shared by both.\n */\nabstract class TimerRegistry {\n /** Live timer ids that have not yet been cleared (or, for timeouts, fired). */\n protected readonly ids = new Set<number>();\n\n /** Schedules the underlying platform timer and returns its id. */\n protected abstract schedule(callback: () => void, delay: number): number;\n\n /** Cancels the underlying platform timer for `id`. */\n protected abstract cancel(id: number): void;\n\n /**\n * Cancels a single tracked timer.\n *\n * No-ops if the id is unknown (already cleared, fired, or never owned by this\n * registry), so callers can clear defensively without guarding.\n */\n clear(id: number): void {\n if (this.ids.delete(id)) {\n this.cancel(id);\n }\n }\n\n /**\n * Cancels every tracked timer. Call this from a controller's `disconnect()`\n * to guarantee no timer outlives the element.\n */\n clearAll(): void {\n for (const id of this.ids) {\n this.cancel(id);\n }\n this.ids.clear();\n }\n\n /** Number of timers currently tracked (pending). */\n get size(): number {\n return this.ids.size;\n }\n}\n\n/**\n * `setTimeout` wrapper that auto-forgets each timer once it fires and supports\n * bulk teardown on disconnect.\n *\n * @example\n * ```ts\n * #timers = new SafeTimeout();\n *\n * connect() {\n * this.#timers.set(() => this.dismiss(), 5000);\n * }\n *\n * disconnect() {\n * this.#timers.clearAll();\n * }\n * ```\n */\nexport class SafeTimeout extends TimerRegistry {\n /**\n * Schedules `callback` after `delay` ms and returns the timer id.\n *\n * The id is removed from the registry automatically when the timeout fires,\n * so {@link TimerRegistry.size | size} reflects only still-pending timers.\n */\n set(callback: () => void, delay: number): number {\n const id = this.schedule(() => {\n this.ids.delete(id);\n callback();\n }, delay);\n this.ids.add(id);\n return id;\n }\n\n protected schedule(callback: () => void, delay: number): number {\n return window.setTimeout(callback, delay);\n }\n\n protected cancel(id: number): void {\n window.clearTimeout(id);\n }\n}\n\n/**\n * `setInterval` wrapper that tracks every interval for bulk teardown on\n * disconnect. Unlike {@link SafeTimeout}, intervals are retained until they are\n * explicitly cleared because they fire repeatedly.\n *\n * @example\n * ```ts\n * #intervals = new SafeInterval();\n *\n * connect() {\n * this.#intervals.set(() => this.tick(), 1000);\n * }\n *\n * disconnect() {\n * this.#intervals.clearAll();\n * }\n * ```\n */\nexport class SafeInterval extends TimerRegistry {\n /** Schedules a repeating `callback` every `delay` ms and returns the timer id. */\n set(callback: () => void, delay: number): number {\n const id = this.schedule(callback, delay);\n this.ids.add(id);\n return id;\n }\n\n protected schedule(callback: () => void, delay: number): number {\n return window.setInterval(callback, delay);\n }\n\n protected cancel(id: number): void {\n window.clearInterval(id);\n }\n}\n","import { Controller } from \"@hotwired/stimulus\";\nimport { announce, fillTemplate } from \"../utils/announce\";\nimport { AttributeLease } from \"../utils/attribute_lease\";\nimport { CompositionTracker } from \"../utils/composition_tracker\";\nimport { MorphRenderWatcher } from \"../utils/morph_render_watcher\";\nimport { NUMBER_BOUNDS, type NumberValueConstraints } from \"../utils/number_bounds\";\nimport { NumberValueReader } from \"../utils/number_value\";\nimport { SafeTimeout } from \"../utils/safe_timeout\";\n\ntype CharacterCounterField = HTMLInputElement | HTMLTextAreaElement;\ntype DisplayMode = \"remaining\" | \"used\" | \"both\";\n\ninterface CharacterCountReading {\n readonly length: number;\n readonly remaining: number | null;\n readonly over: boolean;\n readonly max: number;\n readonly text: string;\n}\n\ntype CharacterCounterDetail = Pick<CharacterCountReading, \"length\" | \"remaining\" | \"over\">;\n\n/**\n * Headless character-counter behavior for a text field (no dedicated APG\n * pattern; follows the WCAG 2.2 \"status messages\" practice, 4.1.3).\n *\n * Markup contract (identifier: `stimeo--character-counter`):\n * <div data-controller=\"stimeo--character-counter\"\n * data-stimeo--character-counter-max-value=\"140\"\n * data-stimeo--character-counter-announce-text-value=\"{remaining} characters remaining\">\n * <textarea data-stimeo--character-counter-target=\"input\"\n * aria-describedby=\"cc\"></textarea>\n * <span id=\"cc\" data-stimeo--character-counter-target=\"output\"></span>\n * </div>\n *\n * Watches the field's UTF-16 code-unit length, writes the remaining/used count\n * into `output`, and toggles the `data-near-limit` / `data-over-limit` state\n * hooks. While over the limit it temporarily leases `aria-invalid=\"true\"` on\n * the field and, on recovery or teardown, gives the field back the value beneath\n * it: the consumer's authored value, or the latest value of a `stimeo--form-field`\n * whose control is the same field. The lease records the authored value on the\n * field, so the connection that adopts a copy of the page Turbo restores from its\n * cache gives it back once the field is within the limit — a password field comes\n * back empty. Nothing is undone on `turbo:before-cache`, which Turbo also\n * dispatches on pages that stay: an over-limit field stays invalid there.\n * The field is the first `input` target, or — when the controller is attached\n * straight onto an `<input>`/`<textarea>` — the controller element itself.\n *\n * `change` and `reconcile` dispatch\n * `{ length: number, remaining: number | null, over: boolean }`.\n *\n * @remarks\n * Behavior only — count text and state update synchronously, with no styling.\n * Confirmed user input dispatches `stimeo--character-counter:change` only when\n * the measured length actually changes. Its detail is `{ length, remaining,\n * over }`; `remaining` is `null` when `max` is disabled. IME intermediate input\n * is ignored, and `compositionend` commits the confirmed value exactly once.\n *\n * Assistive notification is opt-in and i18n-neutral. `announceText` accepts\n * `{count}`, `{length}`, `{remaining}`, `{max}`, and `{over}` placeholders and\n * sends the settled message to the page's shared `stimeo--announcer` after a\n * short debounce. The visible `output` is not itself required to be a live\n * region. Initial reflection and Turbo restoration never dispatch or announce.\n * Runtime target/Value reconciliation dispatches\n * `stimeo--character-counter:reconcile` only when the public derived state\n * changes, and never announces.\n */\nexport class CharacterCounterController extends Controller<HTMLElement> {\n /** Numeric read boundaries share one reader for this controller instance. */\n readonly #numbers = new NumberValueReader();\n\n static override targets = [\"input\", \"output\"];\n static override values = {\n max: { type: Number, default: 0 },\n warnAt: { type: Number, default: 0 },\n mode: { type: String, default: \"remaining\" },\n announceText: { type: String, default: \"\" },\n };\n\n static valueConstraints = {\n max: NUMBER_BOUNDS.nonNegative,\n warnAt: NUMBER_BOUNDS.nonNegative,\n } satisfies NumberValueConstraints<typeof CharacterCounterController.values>;\n static events = [\"change\", \"reconcile\"] as const;\n\n declare readonly inputTarget: CharacterCounterField;\n declare readonly outputTarget: HTMLElement;\n declare readonly hasInputTarget: boolean;\n declare readonly hasOutputTarget: boolean;\n\n declare maxValue: number;\n declare warnAtValue: number;\n declare modeValue: string;\n declare announceTextValue: string;\n\n /** Delay (ms) before one settled count is sent to the shared announcer. */\n static readonly #announceDelay = 200;\n\n readonly #timeouts = new SafeTimeout();\n readonly #ariaInvalid = new AttributeLease<CharacterCounterField>(\n \"aria-invalid\",\n this.identifier,\n );\n readonly #repaint = new MorphRenderWatcher(() => this.#reconcile(true));\n readonly #composition = new CompositionTracker({\n onEnd: (event) => this.#commitFrom(event.currentTarget),\n });\n #announceId: number | null = null;\n #boundField: CharacterCounterField | null = null;\n #lastLength: number | null = null;\n #lastDetail: CharacterCounterDetail | null = null;\n #reflectedOver: boolean | null = null;\n\n readonly #onInput = (event: Event): void => {\n const field = this.#boundField;\n if (!field || event.currentTarget !== field || this.#field !== field) return;\n // An engine may echo a confirmed composition with one more `input`;\n // committing it again would re-run the reading the commit already took.\n if (this.#composition.consumesConfirmedInput(event)) return;\n if (this.#composition.isComposing(event as InputEvent)) return;\n this.#commit(field);\n };\n\n /** Reflects the current DOM state and opens the mutation-reconciliation window. */\n override connect(): void {\n this.#repaint.observe(this.element);\n this.#reconcile(false);\n }\n\n /** Releases listeners, timers, borrowed ARIA, and controller-owned state hooks. */\n override disconnect(): void {\n this.#repaint.disconnect();\n this.#cancelAnnouncement();\n this.#bindField(null);\n this.#clearStateHooks();\n this.#lastLength = null;\n this.#lastDetail = null;\n }\n\n /** Rebinds and repaints after an input target is added or replaced at runtime. */\n inputTargetConnected(): void {\n this.#repaint.schedule();\n }\n\n /** Releases and repaints after an input target is removed or replaced at runtime. */\n inputTargetDisconnected(): void {\n this.#repaint.schedule();\n }\n\n /** Initializes a display target inserted after the controller connected. */\n outputTargetConnected(): void {\n this.#repaint.schedule();\n }\n\n /** Reconciles the optional display target set after a removal or replacement. */\n outputTargetDisconnected(): void {\n this.#repaint.schedule();\n }\n\n /** Repaints when application code or a Turbo morph changes `max`. */\n maxValueChanged(): void {\n this.#repaint.schedule();\n }\n\n /** Repaints when application code or a Turbo morph changes `warnAt`. */\n warnAtValueChanged(): void {\n this.#repaint.schedule();\n }\n\n /** Repaints when application code or a Turbo morph changes `mode`. */\n modeValueChanged(): void {\n this.#repaint.schedule();\n }\n\n /** Rewords a pending announcement with the template the consumer changed it to. */\n announceTextValueChanged(): void {\n this.#repaint.schedule();\n }\n\n /** Rebinds one mutation batch and reports a changed controller-derived state. */\n #reconcile(report: boolean): void {\n const previous = this.#lastDetail;\n // An edit inside the debounce window has already earned an announcement.\n // Reconciliation never originates one, but it must not swallow that one\n // either: the pending message is retargeted at the settled reading, so the\n // user hears the count that ends up displayed rather than nothing. A\n // replaced field is the exception — its pending message describes a field\n // the reader can no longer reach.\n const owedField = this.#announceId === null ? null : this.#boundField;\n this.#cancelAnnouncement();\n this.#bindField(this.#field);\n if (this.#composition.isComposing()) return;\n const field = this.#boundField;\n if (!field) {\n this.#renderEmpty();\n this.#lastLength = null;\n this.#lastDetail = null;\n return;\n }\n const reading = this.#render(field);\n const detail = this.#detail(reading);\n this.#lastLength = reading.length;\n this.#lastDetail = detail;\n if (owedField === field) this.#scheduleAnnouncement(reading);\n if (report && previous && this.#detailsDiffer(previous, detail)) {\n this.dispatch(\"reconcile\", { detail });\n }\n }\n\n /** Commits a composition only when it came from the field still owned here. */\n #commitFrom(target: EventTarget | null): void {\n const field = this.#boundField;\n if (!field || target !== field || this.#field !== field) return;\n this.#commit(field);\n }\n\n /** Reflects one confirmed user input and reports only a real length transition. */\n #commit(field: CharacterCounterField): void {\n const reading = this.#render(field);\n const previousLength = this.#lastLength;\n const previousDetail = this.#lastDetail;\n const detail = this.#detail(reading);\n this.#lastLength = reading.length;\n this.#lastDetail = detail;\n if (previousLength === reading.length) {\n if (previousDetail && this.#detailsDiffer(previousDetail, detail)) {\n this.dispatch(\"reconcile\", { detail });\n }\n return;\n }\n\n this.dispatch(\"change\", { detail });\n this.#scheduleAnnouncement(reading);\n }\n\n /** Selects the public event state from the richer internal reading. */\n #detail(reading: CharacterCountReading): CharacterCounterDetail {\n return {\n length: reading.length,\n remaining: reading.remaining,\n over: reading.over,\n };\n }\n\n /** Compares exactly the state carried by `change` and `reconcile`. */\n #detailsDiffer(left: CharacterCounterDetail, right: CharacterCounterDetail): boolean {\n return (\n left.length !== right.length || left.remaining !== right.remaining || left.over !== right.over\n );\n }\n\n /**\n * Synchronizes visible count, state hooks, and temporary validation ARIA.\n *\n * @stimeoRenderRoot\n */\n #render(field: CharacterCounterField): CharacterCountReading {\n const length = field.value.length;\n const max = this.#normalizeCount(this.#safeMax);\n const warnAt = this.#normalizeCount(this.#safeWarnAt);\n const remaining = max > 0 ? max - length : null;\n const over = remaining !== null && remaining < 0;\n const near = remaining !== null && warnAt > 0 && !over && remaining <= warnAt;\n\n this.#toggle(\"data-over-limit\", over);\n this.#toggle(\"data-near-limit\", near);\n this.#reflectInvalid(field, over);\n\n const text = this.#format(length, remaining, max);\n this.#writeOutput(text);\n return { length, remaining, over, max, text };\n }\n\n /** Clears derived output when the declarative input set has no usable field. */\n #renderEmpty(): void {\n this.#reflectedOver = null;\n this.#clearStateHooks();\n this.#writeOutput(\"\");\n }\n\n /** Replaces the observed field symmetrically, returning state from the old one. */\n #bindField(field: CharacterCounterField | null): void {\n if (field === this.#boundField) return;\n\n const previous = this.#boundField;\n if (previous) {\n previous.removeEventListener(\"input\", this.#onInput);\n this.#composition.unobserve(previous);\n this.#ariaInvalid.return(previous);\n }\n\n this.#boundField = field;\n this.#lastLength = null;\n this.#reflectedOver = null;\n if (!field) return;\n\n field.addEventListener(\"input\", this.#onInput);\n this.#composition.observe(field);\n }\n\n /** Leases invalid state on an over-limit edge or missing output, preserving authored values. */\n #reflectInvalid(field: CharacterCounterField, over: boolean): void {\n if (this.#reflectedOver === over && (!over || field.hasAttribute(\"aria-invalid\"))) return;\n this.#reflectedOver = over;\n if (over) this.#ariaInvalid.write(field, \"true\");\n else this.#ariaInvalid.return(field);\n }\n\n /** Builds the visible count for the normalized display mode. */\n #format(length: number, remaining: number | null, max: number): string {\n if (remaining === null) return String(length);\n switch (this.#mode) {\n case \"used\":\n return String(length);\n case \"both\":\n return `${length}/${max}`;\n default:\n return String(remaining);\n }\n }\n\n /**\n * Debounces one i18n-neutral message into the shared polite announcer.\n *\n * @stimeoRuntimeOnly `announceText` is the template of the one announcement this call schedules;\n * the count is painted by the marked renderer.\n */\n #scheduleAnnouncement(reading: CharacterCountReading): void {\n this.#cancelAnnouncement();\n const message = fillTemplate(this.announceTextValue, {\n count: reading.text,\n length: reading.length,\n remaining: reading.remaining ?? \"\",\n max: reading.max,\n over: String(reading.over),\n });\n if (message.trim().length === 0) return;\n\n this.#announceId = this.#timeouts.set(() => {\n announce(message);\n this.#announceId = null;\n }, CharacterCounterController.#announceDelay);\n }\n\n /** Cancels the one outstanding announcement without touching visible output. */\n #cancelAnnouncement(): void {\n if (this.#announceId !== null) this.#timeouts.clear(this.#announceId);\n this.#announceId = null;\n }\n\n /** Writes the optional display only when its text actually changed. */\n #writeOutput(text: string): void {\n if (!this.hasOutputTarget || this.outputTarget.textContent === text) return;\n this.outputTarget.textContent = text;\n }\n\n /** Reflects a presence-style state hook without redundant attribute writes. */\n #toggle(name: string, on: boolean): void {\n if (on) {\n if (this.element.getAttribute(name) !== \"true\") this.element.setAttribute(name, \"true\");\n } else if (this.element.hasAttribute(name)) {\n this.element.removeAttribute(name);\n }\n }\n\n /** Removes both state hooks owned by this controller. */\n #clearStateHooks(): void {\n this.#toggle(\"data-over-limit\", false);\n this.#toggle(\"data-near-limit\", false);\n }\n\n /** Normalizes a finite count into a non-negative integer. */\n #normalizeCount(raw: number): number {\n return Math.max(0, Math.trunc(raw));\n }\n\n /** Falls back to `remaining` when an authored display mode is unknown. */\n get #mode(): DisplayMode {\n if (this.modeValue === \"used\" || this.modeValue === \"both\") return this.modeValue;\n return \"remaining\";\n }\n\n /** The watched field: the first target, or a directly controlled form field. */\n get #field(): CharacterCounterField | null {\n if (this.hasInputTarget) return this.inputTarget;\n const element: HTMLElement = this.element;\n if (element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement)\n return element;\n return null;\n }\n /** Current `max` declaration resolved against its numeric contract. */\n get #safeMax(): number {\n return this.#numbers.read(\n this,\n \"max\",\n this.maxValue,\n CharacterCounterController.values.max.default,\n CharacterCounterController.valueConstraints.max,\n );\n }\n\n /** Current `warnAt` declaration resolved against its numeric contract. */\n get #safeWarnAt(): number {\n return this.#numbers.read(\n this,\n \"warnAt\",\n this.warnAtValue,\n CharacterCounterController.values.warnAt.default,\n CharacterCounterController.valueConstraints.warnAt,\n );\n }\n}\n"]}
|
|
@@ -37,7 +37,7 @@ import { Controller } from '@hotwired/stimulus';
|
|
|
37
37
|
* - Parent toggle checks/unchecks every child and clears its own `indeterminate`.
|
|
38
38
|
* All child targets, including disabled ones, participate; omit the target to
|
|
39
39
|
* exclude an input. The cascade does not synthesize native child `change`
|
|
40
|
-
* events — one aggregate custom event
|
|
40
|
+
* events — one aggregate custom event reports a changed aggregate.
|
|
41
41
|
* - A child change recomputes the parent: all → checked, none → unchecked,
|
|
42
42
|
* some → `indeterminate`.
|
|
43
43
|
* - The aggregate (`all` / `partial` / `none`) is mirrored to `data-state` on the
|
|
@@ -45,7 +45,12 @@ import { Controller } from '@hotwired/stimulus';
|
|
|
45
45
|
* form resets are reconciled from the children. Callers that assign the live
|
|
46
46
|
* `checked` property directly must dispatch `change`, because property writes
|
|
47
47
|
* are not observable by a `MutationObserver`.
|
|
48
|
-
* - `stimeo--checkbox:change` is dispatched
|
|
48
|
+
* - `stimeo--checkbox:change` is dispatched by the two public change actions only
|
|
49
|
+
* when the aggregate differs from the last published one. Pending page writes
|
|
50
|
+
* are included in that confirmation; returning to the published aggregate is
|
|
51
|
+
* silent. Browser-dispatched listeners can reconcile a page write before the
|
|
52
|
+
* action runs, while script dispatch and consecutive Stimulus actions in one
|
|
53
|
+
* listener include it in the action's `change`.
|
|
49
54
|
* `stimeo--checkbox:reconcile` is dispatched instead when a reconciliation —
|
|
50
55
|
* not the user — moves the aggregate. Both carry `{ checked: boolean,
|
|
51
56
|
* indeterminate: boolean, state: "all" | "partial" | "none" }` and describe
|
|
@@ -1,26 +1,17 @@
|
|
|
1
1
|
import { Controller } from '@hotwired/stimulus';
|
|
2
2
|
|
|
3
|
-
// src/controllers/checkbox_controller.ts
|
|
4
|
-
|
|
5
|
-
// src/utils/form_reset_watcher.ts
|
|
6
3
|
var FormResetWatcher = class {
|
|
7
4
|
#owns;
|
|
8
5
|
#onReset;
|
|
9
6
|
#frames = /* @__PURE__ */ new Set();
|
|
10
7
|
#generation = 0;
|
|
11
|
-
/**
|
|
12
|
-
* @param owns - whether `form` owns a control this controller derives from.
|
|
13
|
-
* @param onReset - the reconciliation pass, run once per honoured reset.
|
|
14
|
-
*/
|
|
15
8
|
constructor(owns, onReset) {
|
|
16
9
|
this.#owns = owns;
|
|
17
10
|
this.#onReset = onReset;
|
|
18
11
|
}
|
|
19
|
-
/** Subscribes to `reset` at the document; call from `connect()`. Idempotent. */
|
|
20
12
|
observe() {
|
|
21
13
|
document.addEventListener("reset", this.#handleReset, true);
|
|
22
14
|
}
|
|
23
|
-
/** Unsubscribes and drops every pending pass; call from `disconnect()`. */
|
|
24
15
|
disconnect() {
|
|
25
16
|
document.removeEventListener("reset", this.#handleReset, true);
|
|
26
17
|
this.#generation += 1;
|
|
@@ -44,57 +35,38 @@ var FormResetWatcher = class {
|
|
|
44
35
|
this.#frames.add(frame);
|
|
45
36
|
});
|
|
46
37
|
};
|
|
47
|
-
/** Runs the pass unless a listener cancelled the reset before it landed. */
|
|
48
38
|
#settle(event) {
|
|
49
39
|
if (!event.defaultPrevented) this.#onReset();
|
|
50
40
|
}
|
|
51
41
|
};
|
|
52
42
|
|
|
53
|
-
// src/utils/listener_set.ts
|
|
54
43
|
var ListenerSet = class {
|
|
55
|
-
/** The generation every `add` joins until the next `dispose()`. */
|
|
56
44
|
#abort = new AbortController();
|
|
57
|
-
/**
|
|
58
|
-
* Attaches `handler` to the open generation, exactly as the caller spelled it.
|
|
59
|
-
*
|
|
60
|
-
* The set supplies the signal, so `options` carries everything else the DOM
|
|
61
|
-
* accepts — `capture` included, which has to match at release time and no
|
|
62
|
-
* longer has a second place to drift from.
|
|
63
|
-
*/
|
|
64
45
|
add(target, type, handler, options) {
|
|
65
46
|
target.addEventListener(type, handler, { ...options, signal: this.#abort.signal });
|
|
66
47
|
}
|
|
67
|
-
/**
|
|
68
|
-
* Releases every listener of the open generation, synchronously, and opens the
|
|
69
|
-
* next one. Idempotent, and safe before anything has been added.
|
|
70
|
-
*/
|
|
71
48
|
dispose() {
|
|
72
49
|
this.#abort.abort();
|
|
73
50
|
this.#abort = new AbortController();
|
|
74
51
|
}
|
|
75
52
|
};
|
|
76
53
|
|
|
77
|
-
// src/utils/microtask_coalescer.ts
|
|
78
54
|
var MicrotaskCoalescer = class {
|
|
79
55
|
#run;
|
|
80
56
|
#queued = false;
|
|
81
57
|
#active = false;
|
|
82
58
|
#generation = 0;
|
|
83
|
-
/** @param run - the single reconciliation pass, invoked at most once per batch. */
|
|
84
59
|
constructor(run) {
|
|
85
60
|
this.#run = run;
|
|
86
61
|
}
|
|
87
|
-
/** Opens the window in which {@link schedule} is honoured; call from `connect()`. */
|
|
88
62
|
activate() {
|
|
89
63
|
this.#active = true;
|
|
90
64
|
}
|
|
91
|
-
/** Closes the window and drops any pending pass; call from `disconnect()`. */
|
|
92
65
|
cancel() {
|
|
93
66
|
this.#active = false;
|
|
94
67
|
this.#queued = false;
|
|
95
68
|
this.#generation += 1;
|
|
96
69
|
}
|
|
97
|
-
/** Requests one pass after the batch settles. Idempotent; inert outside the window. */
|
|
98
70
|
schedule() {
|
|
99
71
|
if (!this.#active || this.#queued) return;
|
|
100
72
|
this.#queued = true;
|
|
@@ -107,82 +79,92 @@ var MicrotaskCoalescer = class {
|
|
|
107
79
|
}
|
|
108
80
|
};
|
|
109
81
|
|
|
110
|
-
|
|
82
|
+
var MorphRenderWatcher = class {
|
|
83
|
+
#listeners = new ListenerSet();
|
|
84
|
+
#pass;
|
|
85
|
+
#element = null;
|
|
86
|
+
#onMorph = () => this.#pass.schedule();
|
|
87
|
+
constructor(run) {
|
|
88
|
+
this.#pass = new MicrotaskCoalescer(run);
|
|
89
|
+
}
|
|
90
|
+
observe(element) {
|
|
91
|
+
if (this.#element === element) return;
|
|
92
|
+
this.disconnect();
|
|
93
|
+
this.#element = element;
|
|
94
|
+
this.#pass.activate();
|
|
95
|
+
this.#listeners.add(element, "turbo:morph-element", this.#onMorph);
|
|
96
|
+
}
|
|
97
|
+
schedule() {
|
|
98
|
+
this.#pass.schedule();
|
|
99
|
+
}
|
|
100
|
+
disconnect() {
|
|
101
|
+
this.#listeners.dispose();
|
|
102
|
+
this.#pass.cancel();
|
|
103
|
+
this.#element = null;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
111
107
|
var CheckboxController = class extends Controller {
|
|
112
108
|
static targets = ["parent", "child"];
|
|
113
109
|
static actions = ["onChildChange", "onParentChange"];
|
|
114
110
|
static events = ["change", "reconcile"];
|
|
115
|
-
|
|
116
|
-
#reconcile = new MicrotaskCoalescer(() => this.#reconcileFromChildren());
|
|
117
|
-
#listeners = new ListenerSet();
|
|
111
|
+
#reconcile = new MorphRenderWatcher(() => this.#reconcileFromChildren());
|
|
118
112
|
#formReset = new FormResetWatcher(
|
|
119
113
|
(form) => this.#hasCheckboxOwnedBy(form),
|
|
120
114
|
() => this.#reconcile.schedule()
|
|
121
115
|
);
|
|
122
|
-
/** Aggregate this root last settled on, so a derived repair is reported once. */
|
|
123
116
|
#committedState = null;
|
|
124
|
-
/** Watches authored checked-attribute changes on retained target elements. */
|
|
125
117
|
#checkedObserver = new MutationObserver((records) => {
|
|
126
118
|
if (records.some((record) => this.#isManagedCheckbox(record.target))) {
|
|
127
119
|
this.#reconcile.schedule();
|
|
128
120
|
}
|
|
129
121
|
});
|
|
130
|
-
/** Reflects the initial aggregate and starts retained-DOM reconciliation. */
|
|
131
122
|
connect() {
|
|
132
|
-
this.#reconcile.activate();
|
|
133
123
|
this.#syncFromChildren();
|
|
124
|
+
this.#reconcile.observe(this.element);
|
|
134
125
|
this.#checkedObserver.observe(this.element, {
|
|
135
126
|
attributes: true,
|
|
136
127
|
attributeFilter: ["checked"],
|
|
137
128
|
subtree: true
|
|
138
129
|
});
|
|
139
|
-
this.#listeners.add(this.element, "turbo:morph-element", this.#onMorph);
|
|
140
130
|
this.#formReset.observe();
|
|
141
131
|
}
|
|
142
|
-
/** Releases the observer, global reset listener, and every pending reconciliation. */
|
|
143
132
|
disconnect() {
|
|
144
|
-
this.#reconcile.
|
|
133
|
+
this.#reconcile.disconnect();
|
|
145
134
|
this.#checkedObserver.disconnect();
|
|
146
|
-
this.#listeners.dispose();
|
|
147
135
|
this.#formReset.disconnect();
|
|
148
136
|
}
|
|
149
|
-
/** Reconciles the aggregate for a parent added or replaced at runtime. */
|
|
150
137
|
parentTargetConnected() {
|
|
151
138
|
this.#reconcile.schedule();
|
|
152
139
|
}
|
|
153
|
-
/** Reconciles the aggregate after a parent target leaves the group. */
|
|
154
140
|
parentTargetDisconnected() {
|
|
155
141
|
this.#reconcile.schedule();
|
|
156
142
|
}
|
|
157
|
-
/** Reconciles the aggregate for a child added at runtime. */
|
|
158
143
|
childTargetConnected() {
|
|
159
144
|
this.#reconcile.schedule();
|
|
160
145
|
}
|
|
161
|
-
/** Reconciles the aggregate after a child leaves the group. */
|
|
162
146
|
childTargetDisconnected() {
|
|
163
147
|
this.#reconcile.schedule();
|
|
164
148
|
}
|
|
165
|
-
/** Cascades the parent's state to every child. Bound via `data-action` (change). */
|
|
166
149
|
onParentChange() {
|
|
167
150
|
if (!this.hasParentTarget) return;
|
|
151
|
+
const previous = this.#committedState;
|
|
168
152
|
const checked = this.parentTarget.checked;
|
|
169
153
|
for (const child of this.childTargets) {
|
|
170
154
|
child.checked = checked;
|
|
171
155
|
}
|
|
172
156
|
this.#reflect(checked ? "all" : "none", true);
|
|
157
|
+
if (this.#committedState === previous) return;
|
|
173
158
|
const detail = this.#settledDetail();
|
|
174
159
|
if (detail) this.dispatch("change", { detail });
|
|
175
160
|
}
|
|
176
|
-
/** Recomputes the parent from its children. Bound via `data-action` (change). */
|
|
177
161
|
onChildChange() {
|
|
162
|
+
const previous = this.#committedState;
|
|
178
163
|
this.#syncFromChildren();
|
|
164
|
+
if (this.#committedState === previous) return;
|
|
179
165
|
const detail = this.#settledDetail();
|
|
180
166
|
if (detail) this.dispatch("change", { detail });
|
|
181
167
|
}
|
|
182
|
-
/**
|
|
183
|
-
* Announces an aggregate this pass derived rather than the user. `change` stays
|
|
184
|
-
* reserved for the two public actions, so automation never reads a repair as an edit.
|
|
185
|
-
*/
|
|
186
168
|
#reconcileFromChildren() {
|
|
187
169
|
const previous = this.#committedState;
|
|
188
170
|
this.#syncFromChildren();
|
|
@@ -190,20 +172,9 @@ var CheckboxController = class extends Controller {
|
|
|
190
172
|
const detail = this.#settledDetail();
|
|
191
173
|
if (detail) this.dispatch("reconcile", { detail });
|
|
192
174
|
}
|
|
193
|
-
/**
|
|
194
|
-
* Derives the parent's `checked`/`indeterminate` and the root `data-state` from
|
|
195
|
-
* the children. Writing state and reporting it are separate so the caller — not
|
|
196
|
-
* a flag threaded through the write — decides which event describes the cause.
|
|
197
|
-
*/
|
|
198
175
|
#syncFromChildren() {
|
|
199
176
|
this.#reflect(this.#aggregate(), this.childTargets.length > 0);
|
|
200
177
|
}
|
|
201
|
-
/**
|
|
202
|
-
* Reflects one aggregate state.
|
|
203
|
-
*
|
|
204
|
-
* @param writeParent - whether the state is authoritative over the `parent`
|
|
205
|
-
* target's own `checked` / `indeterminate`.
|
|
206
|
-
*/
|
|
207
178
|
#reflect(state, writeParent) {
|
|
208
179
|
if (writeParent && this.hasParentTarget) {
|
|
209
180
|
this.parentTarget.checked = state === "all";
|
|
@@ -212,29 +183,17 @@ var CheckboxController = class extends Controller {
|
|
|
212
183
|
this.element.setAttribute("data-state", state);
|
|
213
184
|
this.#committedState = state;
|
|
214
185
|
}
|
|
215
|
-
/** The settled aggregate as event detail, or `null` before anything has settled. */
|
|
216
186
|
#settledDetail() {
|
|
217
187
|
const state = this.#committedState;
|
|
218
188
|
if (state === null) return null;
|
|
219
189
|
return { checked: state === "all", indeterminate: state === "partial", state };
|
|
220
190
|
}
|
|
221
|
-
/** Reconciles retained targets after Turbo has finished morphing their live state. */
|
|
222
|
-
#onMorph = () => {
|
|
223
|
-
this.#reconcile.schedule();
|
|
224
|
-
};
|
|
225
|
-
/** Whether a form owns at least one current parent or child target. */
|
|
226
191
|
#hasCheckboxOwnedBy(form) {
|
|
227
192
|
return [...this.parentTargets, ...this.childTargets].some((checkbox) => checkbox.form === form);
|
|
228
193
|
}
|
|
229
|
-
/** Whether an observed attribute mutation belongs to this controller's target set. */
|
|
230
194
|
#isManagedCheckbox(node) {
|
|
231
195
|
return this.parentTargets.some((checkbox) => checkbox === node) || this.childTargets.some((checkbox) => checkbox === node);
|
|
232
196
|
}
|
|
233
|
-
/**
|
|
234
|
-
* Computes the aggregate state. With children it counts them; with none it
|
|
235
|
-
* reads the parent so a lone tri-state checkbox still reports a state without
|
|
236
|
-
* its externally-set `indeterminate` being clobbered.
|
|
237
|
-
*/
|
|
238
197
|
#aggregate() {
|
|
239
198
|
const children = this.childTargets;
|
|
240
199
|
if (children.length === 0) {
|
|
@@ -249,5 +208,4 @@ var CheckboxController = class extends Controller {
|
|
|
249
208
|
};
|
|
250
209
|
|
|
251
210
|
export { CheckboxController };
|
|
252
|
-
//# sourceMappingURL=checkbox_controller.js.map
|
|
253
211
|
//# sourceMappingURL=checkbox_controller.js.map
|