stimeo-ui 0.15.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 +209 -0
- package/README.md +128 -1
- package/dist/cable/index.d.ts +79 -23
- package/dist/cable/index.js +392 -417
- package/dist/cable/index.js.map +1 -1
- package/dist/controllers/accordion_controller.d.ts +34 -5
- package/dist/controllers/accordion_controller.js +228 -28
- package/dist/controllers/accordion_controller.js.map +1 -1
- package/dist/controllers/alert_dialog_controller.d.ts +20 -9
- 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 +38 -7
- package/dist/controllers/announcer_controller.js +135 -191
- 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 +295 -110
- package/dist/controllers/auto_submit_controller.js.map +1 -1
- package/dist/controllers/avatar_controller.js +172 -106
- package/dist/controllers/avatar_controller.js.map +1 -1
- package/dist/controllers/breadcrumb_controller.d.ts +10 -7
- package/dist/controllers/breadcrumb_controller.js +0 -129
- package/dist/controllers/breadcrumb_controller.js.map +1 -1
- package/dist/controllers/bulk_select_controller.d.ts +22 -4
- package/dist/controllers/bulk_select_controller.js +264 -53
- package/dist/controllers/bulk_select_controller.js.map +1 -1
- package/dist/controllers/calendar_controller.d.ts +109 -28
- package/dist/controllers/calendar_controller.js +346 -180
- package/dist/controllers/calendar_controller.js.map +1 -1
- package/dist/controllers/carousel_controller.d.ts +99 -27
- package/dist/controllers/carousel_controller.js +587 -300
- package/dist/controllers/carousel_controller.js.map +1 -1
- package/dist/controllers/character_counter_controller.d.ts +18 -2
- package/dist/controllers/character_counter_controller.js +271 -143
- 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 +77 -75
- package/dist/controllers/checkbox_controller.js.map +1 -1
- package/dist/controllers/clipboard_controller.d.ts +44 -7
- package/dist/controllers/clipboard_controller.js +187 -108
- package/dist/controllers/clipboard_controller.js.map +1 -1
- package/dist/controllers/collapsible_controller.d.ts +41 -5
- package/dist/controllers/collapsible_controller.js +374 -108
- package/dist/controllers/collapsible_controller.js.map +1 -1
- package/dist/controllers/color_picker_controller.d.ts +47 -14
- package/dist/controllers/color_picker_controller.js +183 -127
- package/dist/controllers/color_picker_controller.js.map +1 -1
- package/dist/controllers/combobox_controller.d.ts +33 -6
- package/dist/controllers/combobox_controller.js +426 -109
- 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 +994 -350
- 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 +212 -125
- 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 -245
- package/dist/controllers/confirm_controller.js.map +1 -1
- package/dist/controllers/context_menu_controller.d.ts +36 -3
- package/dist/controllers/context_menu_controller.js +275 -127
- 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 +75 -2
- package/dist/controllers/countdown_controller.js +235 -97
- package/dist/controllers/countdown_controller.js.map +1 -1
- package/dist/controllers/currency_input_controller.d.ts +93 -15
- package/dist/controllers/currency_input_controller.js +241 -118
- package/dist/controllers/currency_input_controller.js.map +1 -1
- package/dist/controllers/data_grid_controller.d.ts +78 -22
- package/dist/controllers/data_grid_controller.js +229 -135
- package/dist/controllers/data_grid_controller.js.map +1 -1
- package/dist/controllers/date_range_picker_controller.d.ts +64 -11
- package/dist/controllers/date_range_picker_controller.js +359 -165
- package/dist/controllers/date_range_picker_controller.js.map +1 -1
- package/dist/controllers/dialog_controller.d.ts +22 -3
- package/dist/controllers/dialog_controller.js +887 -225
- 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 +80 -142
- package/dist/controllers/direct_upload_controller.js.map +1 -1
- package/dist/controllers/dirty_form_controller.d.ts +2 -2
- package/dist/controllers/dirty_form_controller.js +26 -47
- 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 -20
- package/dist/controllers/dismissible_controller.js.map +1 -1
- package/dist/controllers/drawer_controller.d.ts +52 -16
- package/dist/controllers/drawer_controller.js +963 -336
- package/dist/controllers/drawer_controller.js.map +1 -1
- package/dist/controllers/dropdown_controller.d.ts +39 -3
- package/dist/controllers/dropdown_controller.js +342 -85
- package/dist/controllers/dropdown_controller.js.map +1 -1
- package/dist/controllers/editable_controller.d.ts +12 -1
- package/dist/controllers/editable_controller.js +182 -58
- 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 +426 -229
- package/dist/controllers/file_dropzone_controller.js.map +1 -1
- package/dist/controllers/filter_controller.d.ts +10 -4
- package/dist/controllers/filter_controller.js +78 -36
- package/dist/controllers/filter_controller.js.map +1 -1
- package/dist/controllers/flash_controller.d.ts +57 -14
- package/dist/controllers/flash_controller.js +328 -211
- 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 -239
- package/dist/controllers/focus_controller.js.map +1 -1
- package/dist/controllers/form_field_controller.js +153 -136
- package/dist/controllers/form_field_controller.js.map +1 -1
- package/dist/controllers/form_validation_controller.js +29 -96
- 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 +263 -198
- 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 +119 -70
- package/dist/controllers/highlight_controller.js.map +1 -1
- package/dist/controllers/hover_card_controller.d.ts +65 -4
- package/dist/controllers/hover_card_controller.js +335 -118
- package/dist/controllers/hover_card_controller.js.map +1 -1
- package/dist/controllers/idle_controller.d.ts +58 -4
- package/dist/controllers/idle_controller.js +316 -65
- package/dist/controllers/idle_controller.js.map +1 -1
- package/dist/controllers/input_mask_controller.d.ts +5 -2
- package/dist/controllers/input_mask_controller.js +116 -61
- 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 -103
- 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 -56
- package/dist/controllers/lazy_frame_controller.js.map +1 -1
- package/dist/controllers/listbox_controller.d.ts +84 -10
- package/dist/controllers/listbox_controller.js +413 -153
- 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 -95
- package/dist/controllers/masonry_controller.js.map +1 -1
- package/dist/controllers/menu_controller.d.ts +40 -9
- package/dist/controllers/menu_controller.js +254 -167
- package/dist/controllers/menu_controller.js.map +1 -1
- package/dist/controllers/menubar_controller.d.ts +15 -4
- package/dist/controllers/menubar_controller.js +206 -331
- package/dist/controllers/menubar_controller.js.map +1 -1
- package/dist/controllers/meter_controller.d.ts +20 -0
- package/dist/controllers/meter_controller.js +159 -71
- package/dist/controllers/meter_controller.js.map +1 -1
- package/dist/controllers/multi_select_controller.d.ts +50 -7
- package/dist/controllers/multi_select_controller.js +797 -388
- package/dist/controllers/multi_select_controller.js.map +1 -1
- package/dist/controllers/navigation_menu_controller.d.ts +19 -1
- package/dist/controllers/navigation_menu_controller.js +156 -231
- 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 +373 -174
- 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 +241 -45
- package/dist/controllers/network_status_controller.js.map +1 -1
- package/dist/controllers/number_input_controller.d.ts +62 -10
- package/dist/controllers/number_input_controller.js +387 -227
- package/dist/controllers/number_input_controller.js.map +1 -1
- package/dist/controllers/optimistic_controller.js +28 -75
- package/dist/controllers/optimistic_controller.js.map +1 -1
- package/dist/controllers/otp_controller.d.ts +38 -7
- package/dist/controllers/otp_controller.js +344 -196
- package/dist/controllers/otp_controller.js.map +1 -1
- package/dist/controllers/overflow_indicator_controller.d.ts +13 -12
- package/dist/controllers/overflow_indicator_controller.js +167 -93
- package/dist/controllers/overflow_indicator_controller.js.map +1 -1
- package/dist/controllers/overflow_menu_controller.d.ts +66 -9
- package/dist/controllers/overflow_menu_controller.js +408 -277
- package/dist/controllers/overflow_menu_controller.js.map +1 -1
- package/dist/controllers/pagination_controller.d.ts +52 -15
- package/dist/controllers/pagination_controller.js +342 -120
- package/dist/controllers/pagination_controller.js.map +1 -1
- package/dist/controllers/password_reveal_controller.d.ts +60 -9
- package/dist/controllers/password_reveal_controller.js +424 -99
- 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 +252 -96
- 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 +263 -164
- package/dist/controllers/pointer_drag_controller.js.map +1 -1
- package/dist/controllers/popover_controller.d.ts +46 -4
- package/dist/controllers/popover_controller.js +267 -94
- 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 -72
- 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 +243 -112
- 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 +132 -59
- package/dist/controllers/progress_controller.js.map +1 -1
- package/dist/controllers/radio_group_controller.d.ts +19 -8
- package/dist/controllers/radio_group_controller.js +138 -133
- package/dist/controllers/radio_group_controller.js.map +1 -1
- package/dist/controllers/range_slider_controller.d.ts +92 -4
- package/dist/controllers/range_slider_controller.js +245 -112
- package/dist/controllers/range_slider_controller.js.map +1 -1
- package/dist/controllers/rating_controller.d.ts +33 -6
- package/dist/controllers/rating_controller.js +429 -194
- package/dist/controllers/rating_controller.js.map +1 -1
- package/dist/controllers/read_more_controller.d.ts +26 -2
- package/dist/controllers/read_more_controller.js +185 -47
- 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 +44 -4
- package/dist/controllers/resizable_controller.js +294 -118
- 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 -221
- 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 -146
- package/dist/controllers/scroll_visibility_controller.js.map +1 -1
- package/dist/controllers/scrollspy_controller.d.ts +9 -3
- package/dist/controllers/scrollspy_controller.js +181 -236
- package/dist/controllers/scrollspy_controller.js.map +1 -1
- package/dist/controllers/separator_controller.d.ts +59 -17
- package/dist/controllers/separator_controller.js +288 -132
- package/dist/controllers/separator_controller.js.map +1 -1
- package/dist/controllers/sidebar_controller.d.ts +81 -7
- package/dist/controllers/sidebar_controller.js +1071 -375
- 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 -92
- package/dist/controllers/skeleton_controller.js.map +1 -1
- package/dist/controllers/slider_controller.d.ts +72 -8
- package/dist/controllers/slider_controller.js +211 -96
- 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 +163 -54
- package/dist/controllers/smart_sticky_header_controller.js.map +1 -1
- package/dist/controllers/sortable_controller.js +13 -110
- 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 -161
- package/dist/controllers/spinner_controller.js.map +1 -1
- package/dist/controllers/step_indicator_controller.d.ts +24 -17
- package/dist/controllers/step_indicator_controller.js +107 -53
- package/dist/controllers/step_indicator_controller.js.map +1 -1
- package/dist/controllers/stepper_controller.d.ts +43 -9
- package/dist/controllers/stepper_controller.js +171 -48
- package/dist/controllers/stepper_controller.js.map +1 -1
- package/dist/controllers/stick_to_bottom_controller.d.ts +25 -0
- package/dist/controllers/stick_to_bottom_controller.js +310 -116
- 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 +22 -6
- package/dist/controllers/submit_once_controller.js +294 -192
- package/dist/controllers/submit_once_controller.js.map +1 -1
- package/dist/controllers/switch_controller.d.ts +40 -7
- package/dist/controllers/switch_controller.js +107 -43
- package/dist/controllers/switch_controller.js.map +1 -1
- package/dist/controllers/tabs_controller.d.ts +13 -1
- package/dist/controllers/tabs_controller.js +50 -25
- package/dist/controllers/tabs_controller.js.map +1 -1
- package/dist/controllers/tags_input_controller.d.ts +27 -3
- package/dist/controllers/tags_input_controller.js +290 -149
- 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 +37 -8
- package/dist/controllers/theme_controller.js +148 -80
- 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 +162 -81
- package/dist/controllers/time_picker_controller.js.map +1 -1
- package/dist/controllers/toast_controller.d.ts +85 -23
- package/dist/controllers/toast_controller.js +365 -193
- package/dist/controllers/toast_controller.js.map +1 -1
- package/dist/controllers/toggle_group_controller.d.ts +60 -9
- package/dist/controllers/toggle_group_controller.js +194 -99
- package/dist/controllers/toggle_group_controller.js.map +1 -1
- package/dist/controllers/toolbar_controller.js +92 -90
- package/dist/controllers/toolbar_controller.js.map +1 -1
- package/dist/controllers/tooltip_controller.d.ts +52 -2
- package/dist/controllers/tooltip_controller.js +185 -125
- 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 -115
- package/dist/controllers/transition_controller.js.map +1 -1
- package/dist/controllers/tree_view_controller.d.ts +59 -18
- package/dist/controllers/tree_view_controller.js +248 -290
- package/dist/controllers/tree_view_controller.js.map +1 -1
- package/dist/index.d.ts +33 -3
- package/dist/index.js +8649 -8572
- package/dist/index.js.map +1 -1
- package/dist/inspector/cli.d.ts +95 -9
- package/dist/inspector/cli.js +343 -77
- package/dist/inspector/cli.js.map +1 -1
- package/dist/inspector/cli_bin.js +390 -96
- package/dist/inspector/cli_bin.js.map +1 -1
- package/dist/inspector/examples.json +45 -45
- package/dist/inspector/manifest.json +1308 -155
- package/dist/positioning/index.d.ts +8 -0
- package/dist/positioning/index.js +148 -45
- package/dist/positioning/index.js.map +1 -1
- package/package.json +7 -7
- 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/declared_value.ts","../../src/utils/frame_coalescer.ts","../../src/utils/intersection_watcher.ts","../../src/utils/reduced_motion.ts","../../src/utils/scroll_source.ts","../../src/controllers/scrollspy_controller.ts"],"names":[],"mappings":";;;;;AAuBO,SAAS,aAAA,CAAiB,GAAA,EAAa,KAAA,EAA2B,QAAA,EAAgB;AACvF,EAAA,IAAI;AACF,IAAA,OAAO,MAAM,GAAG,CAAA;AAAA,EAClB,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,QAAA;AAAA,EACT;AACF;AAkBO,SAAS,aAAA,CAAc,OAAA,EAAwB,GAAA,EAAa,QAAA,EAA0B;AAC3F,EAAA,IAAI,GAAA,CAAI,MAAA,KAAW,CAAA,EAAG,OAAO,QAAA;AAC7B,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A,CAAK,gBAAgB,cAAc,CAAA;AAAA,MACrC;AAAA,IACF;AAEA,IAAA,IAAI,CAAC,QAAA,EAAU;AAEf,IAAA,MAAM,WAAA,GAAc,YAAY,CAAC,CAAA;AACjC,IAAA,IAAI,WAAA,EAAa;AACf,MAAA,IAAA,CAAK,QAAA,CAAS,QAAA,EAAU,EAAE,MAAA,EAAQ,EAAE,EAAA,EAAI,IAAA,CAAK,gBAAA,EAAkB,IAAA,EAAM,WAAA,EAAY,EAAG,CAAA;AAAA,IACtF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,gBAAA,GAA2B;AACzB,IAAA,KAAA,MAAW,IAAA,IAAQ,KAAK,WAAA,EAAa;AACnC,MAAA,IAAI,IAAA,CAAK,YAAA,CAAa,cAAc,CAAA,KAAM,UAAA,EAAY;AACtD,MAAA,MAAM,EAAA,GAAK,IAAA,CAAK,YAAA,CAAa,IAAI,CAAA;AACjC,MAAA,IAAI,IAAI,OAAO,EAAA;AAAA,IACjB;AACA,IAAA,OAAO,EAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBA,aAAa,IAAA,EAAkC;AAC7C,IAAA,OACE,IAAA,CAAK,WAAA,CAAY,IAAA,CAAK,YAAA,CAAa,MAAM,CAAC,CAAA,IAC1C,IAAA,CAAK,WAAA,CAAY,IAAA,CAAK,YAAA,CAAa,WAAW,CAAC,CAAA;AAAA,EAEnD;AAAA;AAAA,EAGA,YAAY,KAAA,EAAqC;AAC/C,IAAA,IAAI,CAAC,KAAA,EAAO,UAAA,CAAW,GAAG,GAAG,OAAO,IAAA;AACpC,IAAA,OAAO,KAAA,CAAM,SAAA,CAAU,CAAC,CAAA,IAAK,IAAA;AAAA,EAC/B;AACF","file":"scrollspy_controller.js","sourcesContent":["/**\n * Readers for the String Values whose text can only be checked by handing it to\n * a parser: a CSS selector, a regular-expression source, a JSON object.\n *\n * Stimulus reads each of them as an ordinary string, so the controller connects\n * and the flaw surfaces later, inside the first handler that consumes the value\n * (a `SyntaxError` from `new RegExp`, a `DOMException` from the selector engine),\n * where it takes the whole handler down on every event. Parsing here, once, in\n * the `<name>ValueChanged` callback keeps the failure local to the declaration:\n * an unreadable value falls back to its default, the element stays alive, and\n * the hot path only ever receives a value that parsed.\n *\n * Which default a broken declaration falls back to is the caller's contract, so\n * every reader takes (or returns) the fallback rather than choosing one.\n */\n\n/**\n * The result of `parse(raw)`, or `fallback` when `parse` throws.\n *\n * Any exception counts as \"does not parse\": the parsers these Values feed\n * (`RegExp`, `JSON.parse`, the selector engine) all report a malformed input by\n * throwing, and none of them throws for another reason.\n */\nexport function parseDeclared<T>(raw: string, parse: (raw: string) => T, fallback: T): T {\n try {\n return parse(raw);\n } catch {\n return fallback;\n }\n}\n\n/** What {@link validSelector} needs of the element it probes with. */\nexport interface SelectorProbe {\n matches(selector: string): boolean;\n}\n\n/**\n * `raw` when it is a non-empty selector the DOM accepts, otherwise `fallback`.\n *\n * `element.matches` is the probe: the engine parses the selector and throws for\n * one it cannot read. Whether the selector actually matches `element` plays no\n * part, so a selector aimed at another element still passes.\n *\n * The parameter names the one method the probe uses rather than `Element`, so\n * this module carries no DOM type and the readers below stay importable from\n * the Node-side Inspector, which checks the same declarations statically.\n */\nexport function validSelector(element: SelectorProbe, raw: string, fallback: string): string {\n if (raw.length === 0) return fallback;\n return parseDeclared(\n raw,\n (selector) => {\n element.matches(selector);\n return selector;\n },\n fallback,\n );\n}\n\n/** How `compileRegExp` wraps a source before compiling it. */\nexport type RegExpAnchor = \"none\" | \"exact\";\n\n/**\n * `source` compiled as a `RegExp`, or `null` when it does not compile.\n *\n * `\"exact\"` wraps the source as `^(?:source)$`, so the whole input has to match\n * and an alternation inside the source cannot escape the anchors. The source is\n * compiled on its own first, because an unbalanced source can be made to parse\n * by the wrapper's own parentheses — `0)|(1` becomes `^(?:0)|(1)$` — which would\n * accept a declaration that is not a regular expression and leave half of it\n * outside the anchors. The default that replaces a broken source is the\n * caller's, so `null` is returned rather than a fallback pattern.\n */\nexport function compileRegExp(source: string, anchor: RegExpAnchor = \"none\"): RegExp | null {\n return parseDeclared(\n source,\n (text) => {\n const bare = new RegExp(text);\n return anchor === \"exact\" ? new RegExp(`^(?:${text})$`) : bare;\n },\n null,\n );\n}\n\n/**\n * The JSON object `raw` declares, or `null` when the text does not parse or\n * parses to something other than a plain object (`null`, an array, a scalar).\n * Values are returned as parsed; narrowing them is the caller's contract.\n */\nexport function parseJsonObject(raw: string): Record<string, unknown> | null {\n const parsed = parseDeclared<unknown>(raw, (text) => JSON.parse(text), null);\n if (parsed === null || typeof parsed !== \"object\" || Array.isArray(parsed)) return null;\n return parsed as Record<string, unknown>;\n}\n","/**\n * Runs one piece of scroll-driven work per animation frame.\n *\n * A `scroll` listener fires many times between two paints, and each firing would\n * measure the same layout. Requesting a frame on the first firing and ignoring\n * the rest until it runs keeps the reads to one per frame; running on the frame\n * — rather than on a timer — keeps the measurement in step with what the reader\n * sees.\n *\n * **The first request of a burst wins.** Work handed in while a frame is already\n * pending is dropped, so a caller that queues a special first pass and then\n * receives scrolls gets that first pass, not the last scroll's.\n *\n * Cancelling drops the pending frame outright, and does nothing at all when none\n * is pending. A frame really is cancelled, so nothing needs a generation to tell\n * a stale callback from a fresh one, and nothing has to be refused before the\n * caller starts listening.\n *\n * Scope is the scheduling only. What to measure stays with the caller.\n *\n * @example\n * ```ts\n * readonly #frames = new FrameCoalescer();\n *\n * readonly #onScroll = (): void => this.#frames.schedule(() => this.#measure());\n *\n * disconnect(): void {\n * this.#frames.cancel();\n * }\n * ```\n */\nexport class FrameCoalescer {\n #frame: number | null = null;\n\n /**\n * Runs `run` on the next frame, unless a frame is already pending — the first\n * request of a burst wins and the rest are dropped. The pending frame is\n * released before `run`, so `run` may request the next one.\n */\n schedule(run: () => void): void {\n if (this.#frame !== null) return;\n this.#frame = requestAnimationFrame(() => {\n this.#frame = null;\n run();\n });\n }\n\n /**\n * Drops the pending frame, and reaches the platform only when there is one.\n *\n * There is no handle value that stands for \"nothing pending\":\n * `cancelAnimationFrame` takes an `unsigned long`, so a negative placeholder\n * arrives as a large positive number that the same allocator can hand out, and\n * an idle cancel would then drop a frame belonging to someone else.\n */\n cancel(): void {\n if (this.#frame === null) return;\n cancelAnimationFrame(this.#frame);\n this.#frame = null;\n }\n}\n","/**\n * Shared `IntersectionObserver` plumbing for Stimeo's scroll-triggered\n * controllers (`intersection`, `scrollspy`, `sticky-observer`, `lazy-frame`).\n *\n * It centralizes the `IntersectionObserver` support guard, root resolution from\n * a selector (degrading to the viewport rather than failing), observer\n * creation/teardown, the **active guard** (the browser may\n * flush a final queued callback batch right after `disconnect()`, and a\n * detached controller must not mutate possibly-cached DOM), and the\n * unobserve→observe **re-arm** that re-delivers the current state even when the\n * target never leaves the viewport.\n *\n * Like `RovingTabindex` and `FocusTrap`, this is a policy-free internal\n * util: what an intersection *means* (a spied link, a stuck header, a lazy\n * load) stays in each controller. The public `stimeo--intersection` controller\n * is its thin declarative face.\n */\n\nimport { parseDeclared } from \"./declared_value\";\n\n/**\n * Whether `entry`'s target sits entirely before the root's **start (top)** edge —\n * the \"scrolled past the top\" half of a non-intersecting entry, as opposed to\n * \"not reached yet\" below the root.\n *\n * A target with no layout box (`display: none`, a `hidden` ancestor, a collapsed\n * `<details>`) is reported with an **empty rect**, whose `bottom` of `0` would\n * otherwise satisfy `bottom <= rootTop` for a viewport root and read as \"passed\"\n * even though the target was never scrolled anywhere. An empty rect carries no\n * position at all, so it is deliberately never \"before the edge\"; what a caller\n * publishes for that case is its own policy (both consumers treat it as the\n * neutral \"not passed\"/\"not stuck\", and the real rect that arrives once the\n * target is laid out re-establishes the true state).\n */\nexport function isBeforeRootStart(entry: IntersectionObserverEntry): boolean {\n const rect = entry.boundingClientRect;\n if (rect.width === 0 && rect.height === 0) return false;\n // rootBounds is null for a cross-origin/removed root; fall back to the\n // viewport origin.\n const rootTop = entry.rootBounds?.top ?? 0;\n return rect.bottom <= rootTop;\n}\n\n/**\n * Resolves an observation root from a selector. Every reading of \"no root\" ends\n * at the same place — absent, matching nothing, or not parsing at all (a typo in\n * a data attribute) — so the observation falls back to the viewport instead of\n * leaving the caller inert with no state hooks published at all.\n */\nfunction queryRoot(selector: string | undefined): Element | null {\n if (!selector) return null;\n return parseDeclared(selector, (raw) => document.querySelector(raw), null);\n}\n\nexport interface IntersectionWatchOptions {\n /**\n * The observation root. Pass an element (or `null` for the viewport) when\n * the caller already resolved it; omit to resolve from `rootSelector`.\n */\n root?: Element | null;\n /**\n * Selector for the observation root; empty/omitted = viewport. A selector\n * that matches nothing or does not parse also means the viewport.\n */\n rootSelector?: string;\n rootMargin?: string;\n threshold?: number | number[];\n}\n\nexport class IntersectionWatcher {\n readonly #onEntries: (entries: IntersectionObserverEntry[]) => void;\n #observer: IntersectionObserver | null = null;\n #active = false;\n #usingPlatformDefaults = false;\n\n constructor(onEntries: (entries: IntersectionObserverEntry[]) => void) {\n this.#onEntries = onEntries;\n }\n\n /** Whether an observer is live (started, `IntersectionObserver` supported). */\n get active(): boolean {\n return this.#active;\n }\n\n /** Whether the live observer discarded configured options after construction failed. */\n get usingPlatformDefaults(): boolean {\n return this.#usingPlatformDefaults;\n }\n\n /**\n * (Re)creates the observer and observes `targets`. Returns `false` — leaving\n * the watcher inert — without `IntersectionObserver` support (very old\n * browsers; the caller's no-JS fallback stays in charge) or with no targets.\n * If initial construction with the configured options fails, the watcher\n * warns and retries once with the same root and platform defaults. A\n * `rootSelector` that does not parse resolves to the viewport (see\n * {@link IntersectionWatchOptions.rootSelector}), so a typo never fails the\n * call.\n *\n * @throws The fallback constructor error if both construction attempts fail,\n * or whatever the platform throws from `observe()`. The exception is passed\n * through unchanged, but the watcher rolls back first: every target observed\n * so far is released and `active` stays `false`, so a caller that retries\n * starts from a clean slate.\n */\n start(targets: Element | readonly Element[], options: IntersectionWatchOptions = {}): boolean {\n this.stop();\n if (typeof IntersectionObserver === \"undefined\") return false;\n const list = Array.isArray(targets) ? (targets as readonly Element[]) : [targets as Element];\n if (list.length === 0) return false;\n\n const root = \"root\" in options ? (options.root ?? null) : queryRoot(options.rootSelector);\n\n let observer: IntersectionObserver | null = null;\n try {\n const onEntries = (entries: IntersectionObserverEntry[]): void => {\n // Identity matters across an immediate restart: the old observer can\n // flush a queued batch after the new observer has made `active` true.\n if (this.#active && this.#observer === observer) this.#onEntries(entries);\n };\n try {\n observer = new IntersectionObserver(onEntries, {\n root,\n rootMargin: options.rootMargin,\n threshold: options.threshold,\n });\n } catch (error) {\n console.warn(\n \"Stimeo UI: IntersectionObserver could not be constructed with the configured options; retrying with platform defaults.\",\n error,\n );\n observer = new IntersectionObserver(onEntries, { root });\n this.#usingPlatformDefaults = true;\n }\n for (const target of list) observer.observe(target);\n this.#observer = observer;\n this.#active = true;\n return true;\n } catch (error) {\n // A constructor or partial observe failure must not leave earlier targets\n // observed or report an active watcher. Preserve the platform exception.\n observer?.disconnect();\n this.#observer = null;\n this.#active = false;\n this.#usingPlatformDefaults = false;\n throw error;\n }\n }\n\n /**\n * Re-delivers `target`'s CURRENT intersection state: `IntersectionObserver`\n * only reports *changes*, but `observe()` always reports the present state,\n * so unobserve→observe turns \"still intersecting\" into a fresh callback.\n *\n * @throws Whatever `unobserve()`/`observe()` throws. The watcher is stopped\n * first, so it never stays live with a half-rearmed target.\n */\n rearm(target: Element): void {\n if (!this.#observer) return;\n try {\n this.#observer.unobserve(target);\n this.#observer.observe(target);\n } catch (error) {\n this.stop();\n throw error;\n }\n }\n\n /** Severs the observer; late queued callbacks become no-ops via the guard. */\n stop(): void {\n this.#active = false;\n this.#observer?.disconnect();\n this.#observer = null;\n this.#usingPlatformDefaults = false;\n }\n}\n","/**\n * Shared `prefers-reduced-motion` lookup for the motion-aware controllers.\n *\n * This one-liner keeps the media query string and the environment guard\n * single-sourced across them. The preference is intentionally re-read on every\n * call — the controllers check it at each animation/scroll start (WCAG 2.2\n * **2.3.3**), so flipping the OS setting takes effect immediately without any\n * listener or cache bookkeeping here.\n */\n\n/**\n * Whether the user currently requests reduced motion.\n *\n * @returns `true` when `(prefers-reduced-motion: reduce)` matches; `false`\n * otherwise, including environments without `window.matchMedia` (treated as\n * \"no preference\").\n */\nexport function prefersReducedMotion(): boolean {\n return (\n typeof window.matchMedia === \"function\" &&\n window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches\n );\n}\n","/**\n * What a scroll-driven component listens to and measures: a scroll container\n * somewhere in the page, or the window when nothing names one.\n *\n * A component that reacts to scrolling takes a selector for the container it\n * lives in and falls back to the viewport. Resolving that, and reading how far\n * the result has scrolled, are the same two steps everywhere — and the read is\n * the one that drifts, because the window and an element expose the offset under\n * different names.\n *\n * Resolution only. A selector reaches here already validated, or empty; whether\n * a declaration parses is decided once where it is declared, not on every\n * resolve.\n */\n\n/** A scroll container, or the window. */\nexport type ScrollSource = HTMLElement | Window;\n\n/**\n * The scroll container `selector` names, or `null` for the viewport.\n *\n * `null` covers every way a container can fail to be one: an empty selector, a\n * selector that matches nothing, and a match that is not an `HTMLElement` — an\n * SVG node answers a query but does not scroll.\n *\n * `selector` must be empty or already validated: an unparsable one makes the\n * query throw rather than fall back.\n */\nexport function resolveScrollContainer(selector: string): HTMLElement | null {\n const match = selector ? document.querySelector(selector) : null;\n return match instanceof HTMLElement ? match : null;\n}\n\n/** The scroll source `selector` names: its container, else the window. */\nexport function resolveScrollSource(selector: string): ScrollSource {\n return resolveScrollContainer(selector) ?? window;\n}\n\n/**\n * How far `source` has scrolled vertically.\n *\n * The window is compared by identity rather than with `instanceof`, which a\n * cross-realm or synthetic DOM fails. Its offset is read through the modern name\n * first and the legacy one after, so a runtime that exposes only one still gives\n * a number.\n */\nexport function scrollOffset(source: ScrollSource): number {\n return source === window\n ? (window.scrollY ?? window.pageYOffset ?? 0)\n : (source as HTMLElement).scrollTop;\n}\n","import { Controller } from \"@hotwired/stimulus\";\nimport { validSelector } from \"../utils/declared_value\";\nimport { FrameCoalescer } from \"../utils/frame_coalescer\";\nimport { IntersectionWatcher } from \"../utils/intersection_watcher\";\nimport { prefersReducedMotion } from \"../utils/reduced_motion\";\nimport { resolveScrollContainer, scrollOffset } from \"../utils/scroll_source\";\n\n/**\n * The attributes a link may anchor its section with, and therefore the only\n * ones whose rewrite has to re-sync the observation set. `aria-current` — the\n * attribute this controller writes itself — is deliberately absent, so\n * publishing the current location cannot feed back into a rebuild.\n */\nconst ANCHOR_ATTRIBUTES = [\"href\", \"data-href\"];\n\n/**\n * Headless, accessible **Scrollspy**: keeps a table of contents in sync with the\n * section the reader is currently in, published as `aria-current=\"location\"`.\n * There is no dedicated APG widget; it follows the `aria-current`\n * current-location practice inside a `<nav>` landmark.\n *\n * Markup contract (identifier: `stimeo--scrollspy`):\n * <nav data-controller=\"stimeo--scrollspy\"\n * data-stimeo--scrollspy-offset-value=\"80\"\n * data-stimeo--scrollspy-root-selector-value=\".content\"\n * aria-label=\"Table of contents\">\n * <a href=\"#intro\" data-stimeo--scrollspy-target=\"link\"\n * data-action=\"click->stimeo--scrollspy#scrollTo\">Intro</a>\n * <a href=\"#usage\" data-stimeo--scrollspy-target=\"link\"\n * data-action=\"click->stimeo--scrollspy#scrollTo\">Usage</a>\n * </nav>\n * <div class=\"content\">\n * <section id=\"intro\">…</section>\n * <section id=\"usage\">…</section>\n * </div>\n *\n * The active section is the one whose top edge sits closest to the **trigger\n * line**: `offset` px below the top of the *scroll root* — the `rootSelector`\n * container, or the viewport when that value is empty. It is not the viewport\n * top whenever a nested container is spied on. Intersecting sections win; when\n * none intersects (between two sections, scrolled past the last one) the\n * closest tracked section keeps the highlight, so a table of contents never\n * goes blank.\n *\n * `data-action` on the links is optional and opts into {@link scrollTo}, which\n * scrolls the nested container instead of bouncing the whole window.\n *\n * `change` dispatches `{ id: string, link: HTMLElement }`.\n *\n * @remarks\n * Behavior only — how a current link looks is the consumer's CSS\n * (`[aria-current=\"location\"] { … }`). `connect()` reads the current location\n * back from the DOM so a Turbo cache restore re-establishes it without a\n * redundant `change`, and `disconnect()` severs every resource acquired here:\n * the observers, the scroll listener, and any pending frame or queued rebuild.\n *\n * **What is followed automatically**, and what is not (the boundary a consumer\n * has to know, because everything outside it needs a re-`connect()`):\n *\n * - `link` targets added or removed — Stimulus's target callbacks.\n * - a `link` target's `href` / `data-href` rewritten in place — a Turbo 8 morph\n * keeps the element *and* its target marker, so no target callback fires;\n * those two attributes are watched for exactly this case.\n * - the reader's scroll position, including inside a stretch where no section\n * crosses an observation threshold.\n *\n * Not followed: a *split* lifecycle in which the nav survives while the scroll\n * root or the sections are replaced underneath it. `rootSelector` is resolved\n * against the whole document and re-resolved once the cached container leaves\n * it, but section elements are looked up only while the observation set is\n * (re)built — swap those alone and nothing tells this controller to look again.\n */\nexport class ScrollspyController extends Controller<HTMLElement> {\n static override targets = [\"link\"];\n static override values = {\n offset: { type: Number, default: 0 },\n rootMargin: { type: String, default: \"\" },\n rootSelector: { type: String, default: \"\" },\n focusSection: { type: Boolean, default: false },\n };\n static actions = [\"scrollTo\"] as const;\n static events = [\"change\"] as const;\n\n declare readonly linkTargets: HTMLElement[];\n\n declare offsetValue: number;\n declare rootMarginValue: string;\n declare rootSelectorValue: string;\n declare focusSectionValue: boolean;\n\n /**\n * The one offset shared by observation, active-section selection, and\n * scrolling. Stimulus parses a malformed Number Value as `NaN`; degrading it\n * to the declared default keeps every path aligned instead of only repairing\n * the observer margin while selection and scrolling still receive `NaN`.\n */\n get #offset(): number {\n return Number.isFinite(this.offsetValue) ? this.offsetValue : 0;\n }\n\n /** Shared IO plumbing (support guard, active guard, teardown). */\n readonly #watcher = new IntersectionWatcher((entries) => this.#onIntersection(entries));\n #isConnected = false;\n\n /**\n * Sections currently tracked, by id. Only the *latest reported* intersection\n * flag is stored — never a coordinate. Positions are re-measured when the\n * active section is evaluated, so a section observed several batches ago is\n * never compared against a trigger line computed now.\n */\n #intersectionStates = new Map<string, { element: Element; isIntersecting: boolean }>();\n\n /** Current active section ID; comparing it suppresses duplicate `change` events. */\n #activeSectionId = \"\";\n\n /**\n * Scroll root resolved when the observer was (re)built; `null` = viewport.\n * Cached so a click and every intersection batch reuse the element the\n * observer is actually watching instead of re-querying the document.\n */\n #rootElement: HTMLElement | null = null;\n\n /**\n * The source the `scroll` listener is currently attached to — the resolved\n * root, or the window while the viewport is spied. `null` means \"nothing\n * attached\", so teardown always detaches from the source it attached to\n * rather than from whatever the selector resolves to now.\n */\n #scrollSource: HTMLElement | Window | null = null;\n\n /** Coalesces a scroll burst into one measurement per frame. */\n readonly #frames = new FrameCoalescer();\n\n /** The validated `rootSelector`, or `\"\"` when the declaration cannot be parsed. */\n #rootSelector = \"\";\n\n /** Watches the link targets' anchor attributes for an in-place morph rewrite. */\n #anchorObserver: MutationObserver | null = null;\n\n /** True while a coalesced observation rebuild is queued; see {@link #scheduleResync}. */\n #resyncQueued = false;\n\n override connect(): void {\n this.#isConnected = true;\n this.#observeAnchorAttributes();\n this.#initializeObserver();\n }\n\n override disconnect(): void {\n this.#isConnected = false;\n // Dropping the flag is what discards a rebuild queued moments ago: the\n // drain reads it, so the queued microtask becomes a no-op.\n this.#resyncQueued = false;\n this.#watcher.stop();\n this.#anchorObserver?.disconnect();\n this.#anchorObserver = null;\n this.#detachScrollListener();\n this.#frames.cancel();\n this.#intersectionStates.clear();\n this.#activeSectionId = \"\";\n this.#rootElement = null;\n }\n\n /**\n * Re-initializes the observer if the offset or rootMargin values change dynamically.\n */\n offsetValueChanged(): void {\n if (!this.#isConnected) return;\n this.#initializeObserver();\n }\n\n rootMarginValueChanged(): void {\n if (!this.#isConnected) return;\n this.#initializeObserver();\n }\n\n rootSelectorValueChanged(): void {\n this.#rootSelector = validSelector(this.element, this.rootSelectorValue, \"\");\n if (!this.#isConnected) return;\n this.#initializeObserver();\n }\n\n /**\n * Re-syncs the observation set when a Turbo Stream/morph swaps the table of\n * contents. Stimulus fires these before `connect()` for the links already in\n * the markup, hence the guard: the initial observer is built exactly once, by\n * `connect()`.\n */\n linkTargetConnected(): void {\n if (this.#isConnected) this.#scheduleResync();\n }\n\n linkTargetDisconnected(): void {\n if (this.#isConnected) this.#scheduleResync();\n }\n\n /**\n * Queues **one** observation rebuild for the current mutation batch.\n *\n * A single Turbo morph can append one link, drop another, and rewrite a\n * third's `href`, and those arrive through two independent channels —\n * Stimulus's target callbacks and {@link #anchorObserver}. Each channel just\n * raises the flag and queues a drain; the first drain to run does the work and\n * clears it, so every later drain in the same batch finds nothing to do and\n * the set is rebuilt once instead of three times. `disconnect()` clears the\n * same flag, which is how a queued rebuild is dropped rather than run against\n * a detached controller.\n */\n #scheduleResync(): void {\n this.#resyncQueued = true;\n queueMicrotask(this.#drainResync);\n }\n\n readonly #drainResync = (): void => {\n if (!this.#resyncQueued) return;\n this.#resyncQueued = false;\n this.#initializeObserver();\n };\n\n /**\n * Watches the link targets' anchor attributes so an in-place rewrite re-syncs.\n *\n * A Turbo 8 morph keeps the element **and** its `data-*-target` marker and\n * only rewrites attributes, so Stimulus fires no target callback: without\n * this, a link re-pointed from `#intro` to `#faq` would keep the controller\n * observing `#intro` for the rest of the page's life. The filter is exactly\n * `href` and `data-href`; guarding on `MutationObserver` keeps the\n * controller usable where the API is absent, matching `IntersectionWatcher`'s\n * own support guard.\n */\n #observeAnchorAttributes(): void {\n if (typeof MutationObserver !== \"undefined\") {\n this.#anchorObserver = new MutationObserver(this.#onAnchorMutation);\n this.#anchorObserver.observe(this.element, {\n subtree: true,\n attributes: true,\n attributeFilter: ANCHOR_ATTRIBUTES,\n });\n }\n }\n\n /**\n * Rebuilds only for a rewrite on a *current* link target. The observer is\n * scoped to this controller's element, but that subtree also holds links the\n * author never marked as targets (a \"back to top\" anchor, a nested nav), and\n * those anchor nothing here.\n */\n readonly #onAnchorMutation = (records: MutationRecord[]): void => {\n const links = this.linkTargets;\n for (const record of records) {\n if (!links.includes(record.target as HTMLElement)) continue;\n this.#scheduleResync();\n return;\n }\n };\n\n /**\n * Scrolls to the section the clicked link anchors, honoring `offset` and any\n * nested scroll container (a plain fragment jump would scroll the window).\n *\n * Honors `prefers-reduced-motion` (WCAG 2.2 **2.3.3**) by forcing an instant\n * jump independently of the consumer's CSS `scroll-behavior`. With\n * `focusSection` enabled it also moves the sequential focus starting point\n * into the destination; the URL fragment is deliberately not touched.\n */\n scrollTo(event: Event): void {\n const link = event.currentTarget as HTMLElement;\n const id = this.#getAnchorId(link);\n if (!id) return;\n\n event.preventDefault();\n\n const targetElement = document.getElementById(id);\n if (!targetElement) return;\n\n const behavior: ScrollBehavior = prefersReducedMotion() ? \"instant\" : \"smooth\";\n const rootElement = this.#scrollRoot();\n const targetRect = targetElement.getBoundingClientRect();\n const offset = this.#offset;\n\n if (rootElement) {\n const containerRect = rootElement.getBoundingClientRect();\n const scrollPosition =\n scrollOffset(rootElement) + (targetRect.top - containerRect.top) - offset;\n\n rootElement.scrollTo({ top: scrollPosition, behavior });\n } else {\n const scrollPosition = scrollOffset(window) + targetRect.top - offset;\n\n window.scrollTo({ top: scrollPosition, behavior });\n }\n\n if (this.focusSectionValue) this.#focusSection(targetElement);\n }\n\n /**\n * Moves the sequential focus starting point into the section `scrollTo` just\n * jumped to, so the next Tab continues *inside* the destination instead of\n * resuming in the table of contents (`preventDefault()` alone would leave the\n * starting point on the link). Opt-in through `focusSection`, because moving\n * focus is a decision only the consuming page can make.\n *\n * `tabindex=\"-1\"` is established only when the section is not already\n * focusable and is never removed, so an author-owned tabindex is left alone.\n * `preventScroll` keeps the focus call from cancelling the smooth scroll\n * started just above.\n */\n #focusSection(section: HTMLElement): void {\n if (!section.hasAttribute(\"tabindex\")) section.setAttribute(\"tabindex\", \"-1\");\n section.focus({ preventScroll: true });\n }\n\n /**\n * The cached scroll root, re-resolved when the cached element has left the\n * document (a Turbo morph replaced the container) so `scrollTo` never\n * scrolls a detached node.\n */\n #scrollRoot(): HTMLElement | null {\n if (this.#rootElement && !this.#rootElement.isConnected) {\n this.#rootElement = this.#queryRootElement();\n }\n return this.#rootElement;\n }\n\n /**\n * Resolves `rootSelector` to a scrollable element.\n *\n * @returns The container, or `null` meaning \"spy the viewport\" when the\n * declaration is empty, matches nothing, or matches a non-HTML element. A typo\n * reads as empty: the declaration is validated once when it changes, so a\n * selector that cannot be parsed degrades to viewport spying rather than\n * leaving the controller inert.\n */\n #queryRootElement(): HTMLElement | null {\n return resolveScrollContainer(this.#rootSelector);\n }\n\n /**\n * Re-evaluates once per frame while the reader scrolls.\n *\n * `IntersectionObserver` reports **threshold crossings**, not positions, so a\n * reader moving inside one long section — or across a gap wider than the\n * observation band — produces no batch at all and the highlight would stay\n * frozen at whatever the last crossing decided. That would make the current\n * location depend on the *route* to a position instead of the position: a\n * stepwise scroll crosses thresholds an instant jump to the same offset never\n * does. Listening to the scroll source closes the gap, and because both paths\n * end in {@link #evaluateActiveSection} — which measures section rects and the\n * root's top edge at that instant — they converge on the same answer.\n */\n readonly #onScroll = (): void => this.#frames.schedule(() => this.#evaluateActiveSection());\n\n /**\n * Points the `scroll` listener at whatever the reader actually scrolls: the\n * resolved root, or the window when the viewport is spied.\n *\n * The detach is unconditional, so rebuilding the observation set (a Value\n * change, a morph) **moves** the listener rather than stacking a second one on\n * a container the reader has stopped scrolling.\n */\n #syncScrollListener(): void {\n this.#detachScrollListener();\n this.#scrollSource = this.#rootElement ?? window;\n this.#scrollSource.addEventListener(\"scroll\", this.#onScroll, { passive: true });\n }\n\n #detachScrollListener(): void {\n this.#scrollSource?.removeEventListener(\"scroll\", this.#onScroll);\n this.#scrollSource = null;\n }\n\n #initializeObserver(): void {\n this.#watcher.stop();\n this.#intersectionStates.clear();\n // The DOM is the source of truth for the current location **only when this\n // controller has none of its own** — a fresh `connect()`, which is also the\n // Turbo cache-restore case, where the links still carry `aria-current` from\n // the snapshot. Adopting it there makes the observer's first batch a silent\n // confirmation instead of a duplicate `change`.\n //\n // On a *live* rebuild the memory wins, because the DOM has stopped meaning\n // what this controller wrote: an anchor rewritten underneath us leaves\n // `aria-current` on a link that now points somewhere else, so reading it\n // back would hand the current location to a section the reader never\n // scrolled to — and then announce the correction as a `change`, as if they\n // had travelled there and back.\n this.#activeSectionId = this.#activeSectionId || this.#activeIdFromDom();\n this.#rootElement = this.#queryRootElement();\n this.#syncScrollListener();\n\n if (this.linkTargets.length === 0) return;\n\n // Negate the numeric value so a valid negative offset becomes a positive margin.\n const margin = this.rootMarginValue || `${-this.#offset}px 0px -80% 0px`;\n\n // Observe each target section mapped by the href anchors.\n const sections: Element[] = [];\n for (const link of this.linkTargets) {\n const id = this.#getAnchorId(link);\n if (!id) continue;\n const section = document.getElementById(id);\n if (section && !sections.includes(section)) sections.push(section);\n }\n\n this.#watcher.start(sections, {\n root: this.#rootElement,\n rootMargin: margin,\n threshold: [0, 0.2, 0.4, 0.6, 0.8, 1], // Multiple thresholds handle large sections safely\n });\n\n // Republish the adopted location over the *current* link set. Evaluation\n // writes attributes only when the winning section changes, so a link added\n // — or re-anchored — while the reader stays put would otherwise never be\n // marked: a mobile table of contents rendered after the sidebar one would\n // stay blank until the reader happened to cross into another section.\n //\n // Unconditional, including when the adopted location is empty: a link whose\n // anchor was rewritten to something that resolves nowhere cannot be the\n // reader's location, and this controller is the one that published the\n // attribute saying it was, so it is the one that has to take it back.\n this.#syncActiveStates(false);\n }\n\n readonly #onIntersection = (entries: IntersectionObserverEntry[]): void => {\n // Defense in depth. `IntersectionWatcher` already drops a batch the browser\n // flushes after `stop()` (its active/identity guard), so this flag is the\n // second line that keeps a detached controller from mutating `aria-current`\n // on (possibly cached) links.\n const isDetached = !this.#isConnected;\n if (isDetached) return;\n\n for (const entry of entries) {\n const sectionId = entry.target.id;\n if (!sectionId) continue;\n\n this.#intersectionStates.set(sectionId, {\n element: entry.target,\n isIntersecting: entry.isIntersecting,\n });\n }\n\n this.#evaluateActiveSection();\n };\n\n /**\n * Picks the section closest to the trigger line and publishes it.\n *\n * Every coordinate is read **now**: the section rects *and* the root's top\n * edge share one measurement instant. Comparing an entry's recorded\n * `boundingClientRect.top` (captured whenever that section last crossed a\n * threshold) against a freshly computed trigger line mixes two moments in\n * time, which would make the result depend on how the reader arrived at a\n * position — a smooth scroll and an instant jump to the same offset disagree.\n */\n #evaluateActiveSection(): void {\n // The trigger line is `offset` px below the top of the scroll root. When a\n // nested `rootSelector` container is used it is not at the viewport top, so\n // the line must be measured from the container's current top — comparing the\n // viewport-based rect top against a bare `offset` would otherwise pick the\n // section nearest the viewport top, not the container's.\n const rootEl = this.#scrollRoot();\n const triggerLine = (rootEl ? rootEl.getBoundingClientRect().top : 0) + this.#offset;\n\n let intersectingId = \"\";\n let intersectingDistance = Number.POSITIVE_INFINITY;\n let trackedId = \"\";\n let trackedDistance = Number.POSITIVE_INFINITY;\n\n for (const [id, state] of this.#intersectionStates) {\n const rect = state.element.getBoundingClientRect();\n // A section with no layout box (`display: none`, a collapsed `<details>`,\n // an undisplayed Turbo Frame) is reported with an empty rect whose `top`\n // of 0 carries no position at all. Letting it compete would hand it the\n // fallback below; it re-enters the race once it is actually laid out.\n if (rect.width === 0 && rect.height === 0) continue;\n\n const distance = Math.abs(rect.top - triggerLine);\n if (distance < trackedDistance) {\n trackedDistance = distance;\n trackedId = id;\n }\n if (state.isIntersecting && distance < intersectingDistance) {\n intersectingDistance = distance;\n intersectingId = id;\n }\n }\n\n // Fallback: when no section currently intersects (e.g. scrolled past the\n // bottom, or between sections), keep the tracked section whose top is\n // closest to the trigger line so something stays highlighted.\n const bestId = intersectingId || trackedId;\n\n if (bestId && bestId !== this.#activeSectionId) {\n this.#activeSectionId = bestId;\n this.#syncActiveStates(true);\n }\n }\n\n /**\n * Writes `aria-current` across the current link set, optionally announcing.\n *\n * The two halves are separate because they answer different questions.\n * *Attributes* must be idempotently re-established whenever the link set\n * changes, even though the reader has not moved — otherwise a link that\n * appears (or is re-anchored) while its section is already current never gets\n * marked. *The `change` event* announces that the reader moved, so it fires\n * only from the evaluation path; re-publishing over a new link set is not\n * news, and dispatching there would make a rebuild look like navigation.\n *\n * @param announce Whether this sync represents a change of current section.\n */\n #syncActiveStates(announce: boolean): void {\n // Every link anchoring the active section is marked, not just the first:\n // a page may render the same table of contents twice (a sidebar and a\n // collapsed mobile menu) and both must show the current location.\n const activeLinks = this.linkTargets.filter(\n (link) => this.#getAnchorId(link) === this.#activeSectionId,\n );\n\n for (const link of this.linkTargets) {\n if (activeLinks.includes(link)) {\n link.setAttribute(\"aria-current\", \"location\");\n } else if (link.getAttribute(\"aria-current\") === \"location\") {\n // Reclaim only the value this controller publishes, so an author-owned\n // `aria-current=\"page\"` on a table-of-contents link survives.\n link.removeAttribute(\"aria-current\");\n }\n }\n\n if (!announce) return;\n\n const primaryLink = activeLinks[0];\n if (primaryLink) {\n this.dispatch(\"change\", { detail: { id: this.#activeSectionId, link: primaryLink } });\n }\n }\n\n /**\n * The current location already encoded in the DOM, i.e. the section anchored\n * by the first link carrying this controller's `aria-current=\"location\"`.\n * Empty when no link claims it (a genuinely fresh render).\n */\n #activeIdFromDom(): string {\n for (const link of this.linkTargets) {\n if (link.getAttribute(\"aria-current\") !== \"location\") continue;\n const id = this.#getAnchorId(link);\n if (id) return id;\n }\n return \"\";\n }\n\n /**\n * The section id a link anchors, resolved in a fixed order:\n *\n * 1. `href`, when it is a non-empty same-document fragment — the contract.\n * 2. otherwise `data-href`'s fragment — the fallback for a link whose `href`\n * must stay a real URL (a server-rendered permalink) or that is not an\n * `<a>` at all.\n * 3. otherwise `null`: the link anchors nothing here and is not observed.\n *\n * Step 2 is reached whenever `href` yields nothing usable — absent, `\"#\"`, or\n * a real URL — which is the whole point of the fallback: `href=\"/guide/usage\"`\n * with `data-href=\"#usage\"` is a permalink that also spies, and picking the\n * first *present* attribute instead of the first *usable* one would silently\n * exclude exactly that markup. When both are valid fragments `href` wins.\n */\n #getAnchorId(link: HTMLElement): string | null {\n return (\n this.#fragmentId(link.getAttribute(\"href\")) ??\n this.#fragmentId(link.getAttribute(\"data-href\"))\n );\n }\n\n /** The id in a `#fragment` value; `null` for absent, empty, or non-fragment. */\n #fragmentId(value: string | null): string | null {\n if (!value?.startsWith(\"#\")) return null;\n return value.substring(1) || null;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/state_reason.ts","../../src/utils/action_source.ts","../../src/utils/declared_value.ts","../../src/utils/frame_coalescer.ts","../../src/utils/intersection_watcher.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","../../src/utils/reduced_motion.ts","../../src/utils/scroll_source.ts","../../src/utils/target_selector.ts","../../src/controllers/scrollspy_controller.ts"],"names":[],"mappings":";;AA0CA,IAAM,YAAA,uBAAmB,GAAA,CAAI,CAAC,QAAQ,OAAA,EAAS,SAAA,EAAW,UAAU,CAAC,CAAA;AAGrE,IAAM,cAAA,uBAAqB,GAAA,CAAI,CAAC,cAAc,YAAA,EAAc,cAAA,EAAgB,cAAc,CAAC,CAAA;AA0BpF,SAAS,eAAe,KAAA,EAA4D;AACzF,EAAA,IAAI,CAAC,OAAO,OAAO,KAAA;AACnB,EAAA,IAAI,YAAA,CAAa,GAAA,CAAI,KAAA,CAAM,IAAI,GAAG,OAAO,OAAA;AACzC,EAAA,IAAI,cAAA,CAAe,GAAA,CAAI,KAAA,CAAM,IAAI,GAAG,OAAO,SAAA;AAC3C,EAAA,OAAO,MAAA;AACT;;ACxDO,SAAS,aAAa,MAAA,EAA4C;AACvE,EAAA,IAAI,kBAAkB,WAAA,EAAa;AACjC,IAAA,OAAO,EAAE,OAAO,IAAA,EAAM,IAAA,EAAM,QAAQ,MAAA,EAAQ,MAAA,EAAQ,QAAQ,KAAA,EAAM;AAAA,EACpE;AACA,EAAA,MAAM,QAAQ,MAAA,IAAU,IAAA;AACxB,EAAA,OAAO;AAAA,IACL,KAAA;AAAA,IACA,IAAA,EAAM,KAAA,EAAO,aAAA,YAAyB,OAAA,GAAU,MAAM,aAAA,GAAgB,IAAA;AAAA,IACtE,MAAA,EAA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,CAAS,IAAA;AAAA,MACnB,IAAA;AAAA,MACA,QAAA;AAAA,MACA,IAAA,CAAK,WAAA;AAAA,MACL,oBAAA,CAAoB,OAAO,MAAA,CAAO,OAAA;AAAA,MAClC,qBAAoB,gBAAA,CAAiB;AAAA,KACvC;AAAA,EACF;AACF","file":"scrollspy_controller.js","sourcesContent":["/**\n * Why a component's public state moved, carried as `detail.reason`\n * on the state event that reports the move.\n *\n * The attribute a component publishes (`aria-expanded`, `hidden`, `data-state`)\n * only says *what* the state is now. A subscriber that mirrors the state\n * elsewhere, or reports it, needs *why*: closing on `Escape` and closing because\n * the consumer called the action are the same attribute write and different\n * events to the page around it.\n *\n * `\"api\"` is the one every subscriber has to look at. A close the consumer asked\n * for arrives back at their own listener, so a listener that closes something\n * else on `close` loops unless it ignores its own calls.\n *\n * | Reason | The state moved because |\n * | --- | --- |\n * | `\"user\"` | a control of this component was operated |\n * | `\"select\"` | an item inside it was activated |\n * | `\"escape\"` | `Escape` was pressed and this layer owned it |\n * | `\"outside\"` | a pointer landed outside it, or on its backdrop |\n * | `\"focus\"` | focus entered or left it |\n * | `\"pointer\"` | the pointer entered or left it |\n * | `\"scroll\"` | a tracked scroll container scrolled |\n * | `\"api\"` | a public action was called with no DOM event |\n * | `\"timeout\"` | an automatic timer advanced or dismissed the state |\n * | `\"limit\"` | a capacity limit dismissed an item |\n * | `\"media\"` | an operating-system media preference changed |\n */\nexport type StateReason =\n | \"user\"\n | \"select\"\n | \"escape\"\n | \"outside\"\n | \"focus\"\n | \"pointer\"\n | \"scroll\"\n | \"api\"\n | \"timeout\"\n | \"limit\"\n | \"media\";\n\n/** Focus modality: the events a focus move delivers to an action. */\nconst FOCUS_EVENTS = new Set([\"blur\", \"focus\", \"focusin\", \"focusout\"]);\n\n/** Pointer modality: the crossing events an action is bound to for hover. */\nconst POINTER_EVENTS = new Set([\"mouseenter\", \"mouseleave\", \"pointerenter\", \"pointerleave\"]);\n\n/**\n * Reads the interaction behind a **public action** from the DOM event it was\n * handed.\n *\n * Stimulus always passes the event to an action it invoked from `data-action`,\n * and a consumer calling the method themselves passes nothing — which is what\n * separates `\"api\"` from the rest.\n *\n * Only an action entry may resolve a reason this way. Inside the component the\n * event type no longer identifies the interaction: one `click` is the trigger\n * being pressed, the page outside being pressed, and an item being activated,\n * and those paths pass their own reason instead.\n *\n * @param event - The event the action received, if any.\n * @returns `\"api\"` with no event, else the modality the event type names, else\n * `\"user\"`.\n *\n * @example\n * ```ts\n * toggle(event?: Event): void {\n * this.#apply(!this.#isOpen, stateReasonFor(event));\n * }\n * ```\n */\nexport function stateReasonFor(event?: Event | null): \"user\" | \"focus\" | \"pointer\" | \"api\" {\n if (!event) return \"api\";\n if (FOCUS_EVENTS.has(event.type)) return \"focus\";\n if (POINTER_EVENTS.has(event.type)) return \"pointer\";\n return \"user\";\n}\n","import { stateReasonFor } from \"./state_reason\";\n\n/** The DOM binding and origin of a public action, or its explicit API element. */\nexport interface ActionSource {\n readonly event: Event | null;\n readonly host: Element | null;\n readonly origin: Element | null;\n readonly reason: ReturnType<typeof stateReasonFor>;\n}\n\n/**\n * Normalizes an action's DOM event or explicit element without choosing an owned target.\n *\n * Event hosts and origins stay separate so consumers can yield to nested controls.\n * An explicit element supplies both, with no DOM event and an `\"api\"` reason.\n * Consumers resolve current targets and enforce their own scope and interaction rules.\n *\n * @param source - The DOM event, explicit element, or absent optional argument.\n * @returns The source elements, original event and public interaction reason.\n */\nexport function actionSource(source?: Event | HTMLElement): ActionSource {\n if (source instanceof HTMLElement) {\n return { event: null, host: source, origin: source, reason: \"api\" };\n }\n const event = source ?? null;\n return {\n event,\n host: event?.currentTarget instanceof Element ? event.currentTarget : null,\n origin: event?.target instanceof Element ? event.target : null,\n reason: stateReasonFor(event),\n };\n}\n","/**\n * Readers for the String Values whose text can only be checked by handing it to\n * a parser: a CSS selector, a regular-expression source, a JSON object.\n *\n * Stimulus reads each of them as an ordinary string, so the controller connects\n * and the flaw surfaces later, inside the first handler that consumes the value\n * (a `SyntaxError` from `new RegExp`, a `DOMException` from the selector engine),\n * where it takes the whole handler down on every event. Parsing here, once, in\n * the `<name>ValueChanged` callback keeps the failure local to the declaration:\n * an unreadable value falls back to its default, the element stays alive, and\n * the hot path only ever receives a value that parsed.\n *\n * Which default a broken declaration falls back to is the caller's contract, so\n * every reader takes (or returns) the fallback rather than choosing one.\n */\n\n/**\n * The result of `parse(raw)`, or `fallback` when `parse` throws.\n *\n * Any exception counts as \"does not parse\": the parsers these Values feed\n * (`RegExp`, `JSON.parse`, the selector engine) all report a malformed input by\n * throwing, and none of them throws for another reason.\n */\nexport function parseDeclared<T>(raw: string, parse: (raw: string) => T, fallback: T): T {\n try {\n return parse(raw);\n } catch {\n return fallback;\n }\n}\n\n/** What {@link validSelector} needs of the element it probes with. */\nexport interface SelectorProbe {\n matches(selector: string): boolean;\n}\n\n/**\n * `raw` when it is a non-empty selector the DOM accepts, otherwise `fallback`.\n *\n * `element.matches` is the probe: the engine parses the selector and throws for\n * one it cannot read. Whether the selector actually matches `element` plays no\n * part, so a selector aimed at another element still passes.\n *\n * The parameter names the one method the probe uses rather than `Element`, so\n * this module carries no DOM type and the readers below stay importable from\n * the Node-side Inspector, which checks the same declarations statically.\n */\nexport function validSelector(element: SelectorProbe, raw: string, fallback: string): string {\n if (raw.length === 0) return fallback;\n return parseDeclared(\n raw,\n (selector) => {\n element.matches(selector);\n return selector;\n },\n fallback,\n );\n}\n\n/** How `compileRegExp` wraps a source before compiling it. */\nexport type RegExpAnchor = \"none\" | \"exact\";\n\n/**\n * `source` compiled as a `RegExp`, or `null` when it does not compile.\n *\n * `\"exact\"` wraps the source as `^(?:source)$`, so the whole input has to match\n * and an alternation inside the source cannot escape the anchors. The source is\n * compiled on its own first, because an unbalanced source can be made to parse\n * by the wrapper's own parentheses — `0)|(1` becomes `^(?:0)|(1)$` — which would\n * accept a declaration that is not a regular expression and leave half of it\n * outside the anchors. The default that replaces a broken source is the\n * caller's, so `null` is returned rather than a fallback pattern.\n */\nexport function compileRegExp(source: string, anchor: RegExpAnchor = \"none\"): RegExp | null {\n return parseDeclared(\n source,\n (text) => {\n const bare = new RegExp(text);\n return anchor === \"exact\" ? new RegExp(`^(?:${text})$`) : bare;\n },\n null,\n );\n}\n\n/**\n * The JSON object `raw` declares, or `null` when the text does not parse or\n * parses to something other than a plain object (`null`, an array, a scalar).\n * Values are returned as parsed; narrowing them is the caller's contract.\n */\nexport function parseJsonObject(raw: string): Record<string, unknown> | null {\n const parsed = parseDeclared<unknown>(raw, (text) => JSON.parse(text), null);\n if (parsed === null || typeof parsed !== \"object\" || Array.isArray(parsed)) return null;\n return parsed as Record<string, unknown>;\n}\n","/**\n * Runs one piece of scroll-driven work per animation frame.\n *\n * A `scroll` listener fires many times between two paints, and each firing would\n * measure the same layout. Requesting a frame on the first firing and ignoring\n * the rest until it runs keeps the reads to one per frame; running on the frame\n * — rather than on a timer — keeps the measurement in step with what the reader\n * sees.\n *\n * **The first request of a burst wins.** Work handed in while a frame is already\n * pending is dropped, so a caller that queues a special first pass and then\n * receives scrolls gets that first pass, not the last scroll's.\n *\n * Cancelling drops the pending frame outright, and does nothing at all when none\n * is pending. A frame really is cancelled, so nothing needs a generation to tell\n * a stale callback from a fresh one, and nothing has to be refused before the\n * caller starts listening.\n *\n * Scope is the scheduling only. What to measure stays with the caller.\n *\n * @example\n * ```ts\n * readonly #frames = new FrameCoalescer();\n *\n * readonly #onScroll = (): void => this.#frames.schedule(() => this.#measure());\n *\n * disconnect(): void {\n * this.#frames.cancel();\n * }\n * ```\n */\nexport class FrameCoalescer {\n #frame: number | null = null;\n\n /**\n * Runs `run` on the next frame, unless a frame is already pending — the first\n * request of a burst wins and the rest are dropped. The pending frame is\n * released before `run`, so `run` may request the next one.\n */\n schedule(run: () => void): void {\n if (this.#frame !== null) return;\n this.#frame = requestAnimationFrame(() => {\n this.#frame = null;\n run();\n });\n }\n\n /**\n * Drops the pending frame, and reaches the platform only when there is one.\n *\n * There is no handle value that stands for \"nothing pending\":\n * `cancelAnimationFrame` takes an `unsigned long`, so a negative placeholder\n * arrives as a large positive number that the same allocator can hand out, and\n * an idle cancel would then drop a frame belonging to someone else.\n */\n cancel(): void {\n if (this.#frame === null) return;\n cancelAnimationFrame(this.#frame);\n this.#frame = null;\n }\n}\n","/**\n * Shared `IntersectionObserver` plumbing for Stimeo's scroll-triggered\n * controllers (`intersection`, `scrollspy`, `sticky-observer`, `lazy-frame`).\n *\n * It centralizes the `IntersectionObserver` support guard, root resolution from\n * a selector (degrading to the viewport rather than failing), observer\n * creation/teardown, the **active guard** (the browser may\n * flush a final queued callback batch right after `disconnect()`, and a\n * detached controller must not mutate possibly-cached DOM), and the\n * unobserve→observe **re-arm** that re-delivers the current state even when the\n * target never leaves the viewport.\n *\n * Like `RovingTabindex` and `FocusTrap`, this is a policy-free internal\n * util: what an intersection *means* (a spied link, a stuck header, a lazy\n * load) stays in each controller. The public `stimeo--intersection` controller\n * is its thin declarative face.\n */\n\nimport { parseDeclared } from \"./declared_value\";\n\n/**\n * Whether `entry`'s target sits entirely before the root's **start (top)** edge —\n * the \"scrolled past the top\" half of a non-intersecting entry, as opposed to\n * \"not reached yet\" below the root.\n *\n * A target with no layout box (`display: none`, a `hidden` ancestor, a collapsed\n * `<details>`) is reported with an **empty rect**, whose `bottom` of `0` would\n * otherwise satisfy `bottom <= rootTop` for a viewport root and read as \"passed\"\n * even though the target was never scrolled anywhere. An empty rect carries no\n * position at all, so it is deliberately never \"before the edge\"; what a caller\n * publishes for that case is its own policy (both consumers treat it as the\n * neutral \"not passed\"/\"not stuck\", and the real rect that arrives once the\n * target is laid out re-establishes the true state).\n */\nexport function isBeforeRootStart(entry: IntersectionObserverEntry): boolean {\n const rect = entry.boundingClientRect;\n if (rect.width === 0 && rect.height === 0) return false;\n // rootBounds is null for a cross-origin/removed root; fall back to the\n // viewport origin.\n const rootTop = entry.rootBounds?.top ?? 0;\n return rect.bottom <= rootTop;\n}\n\n/**\n * Resolves an observation root from a selector. Every reading of \"no root\" ends\n * at the same place — absent, matching nothing, or not parsing at all (a typo in\n * a data attribute) — so the observation falls back to the viewport instead of\n * leaving the caller inert with no state hooks published at all.\n */\nfunction queryRoot(selector: string | undefined): Element | null {\n if (!selector) return null;\n return parseDeclared(selector, (raw) => document.querySelector(raw), null);\n}\n\nexport interface IntersectionWatchOptions {\n /**\n * The observation root. Pass an element (or `null` for the viewport) when\n * the caller already resolved it; omit to resolve from `rootSelector`.\n */\n root?: Element | null;\n /**\n * Selector for the observation root; empty/omitted = viewport. A selector\n * that matches nothing or does not parse also means the viewport.\n */\n rootSelector?: string;\n rootMargin?: string;\n threshold?: number | number[];\n}\n\nexport class IntersectionWatcher {\n readonly #onEntries: (entries: IntersectionObserverEntry[]) => void;\n #observer: IntersectionObserver | null = null;\n #active = false;\n #usingPlatformDefaults = false;\n\n constructor(onEntries: (entries: IntersectionObserverEntry[]) => void) {\n this.#onEntries = onEntries;\n }\n\n /** Whether an observer is live (started, `IntersectionObserver` supported). */\n get active(): boolean {\n return this.#active;\n }\n\n /** Whether the live observer discarded configured options after construction failed. */\n get usingPlatformDefaults(): boolean {\n return this.#usingPlatformDefaults;\n }\n\n /**\n * (Re)creates the observer and observes `targets`. Returns `false` — leaving\n * the watcher inert — without `IntersectionObserver` support (very old\n * browsers; the caller's no-JS fallback stays in charge) or with no targets.\n * If initial construction with the configured options fails, the watcher\n * warns and retries once with the same root and platform defaults. A\n * `rootSelector` that does not parse resolves to the viewport (see\n * {@link IntersectionWatchOptions.rootSelector}), so a typo never fails the\n * call.\n *\n * @throws The fallback constructor error if both construction attempts fail,\n * or whatever the platform throws from `observe()`. The exception is passed\n * through unchanged, but the watcher rolls back first: every target observed\n * so far is released and `active` stays `false`, so a caller that retries\n * starts from a clean slate.\n */\n start(targets: Element | readonly Element[], options: IntersectionWatchOptions = {}): boolean {\n this.stop();\n if (typeof IntersectionObserver === \"undefined\") return false;\n const list = Array.isArray(targets) ? (targets as readonly Element[]) : [targets as Element];\n if (list.length === 0) return false;\n\n const root = \"root\" in options ? (options.root ?? null) : queryRoot(options.rootSelector);\n\n let observer: IntersectionObserver | null = null;\n try {\n const onEntries = (entries: IntersectionObserverEntry[]): void => {\n // Identity matters across an immediate restart: the old observer can\n // flush a queued batch after the new observer has made `active` true.\n if (this.#active && this.#observer === observer) this.#onEntries(entries);\n };\n try {\n observer = new IntersectionObserver(onEntries, {\n root,\n rootMargin: options.rootMargin,\n threshold: options.threshold,\n });\n } catch (error) {\n console.warn(\n \"Stimeo UI: IntersectionObserver could not be constructed with the configured options; retrying with platform defaults.\",\n error,\n );\n observer = new IntersectionObserver(onEntries, { root });\n this.#usingPlatformDefaults = true;\n }\n for (const target of list) observer.observe(target);\n this.#observer = observer;\n this.#active = true;\n return true;\n } catch (error) {\n // A constructor or partial observe failure must not leave earlier targets\n // observed or report an active watcher. Preserve the platform exception.\n observer?.disconnect();\n this.#observer = null;\n this.#active = false;\n this.#usingPlatformDefaults = false;\n throw error;\n }\n }\n\n /**\n * Re-delivers `target`'s CURRENT intersection state: `IntersectionObserver`\n * only reports *changes*, but `observe()` always reports the present state,\n * so unobserve→observe turns \"still intersecting\" into a fresh callback.\n *\n * @throws Whatever `unobserve()`/`observe()` throws. The watcher is stopped\n * first, so it never stays live with a half-rearmed target.\n */\n rearm(target: Element): void {\n if (!this.#observer) return;\n try {\n this.#observer.unobserve(target);\n this.#observer.observe(target);\n } catch (error) {\n this.stop();\n throw error;\n }\n }\n\n /** Severs the observer; late queued callbacks become no-ops via the guard. */\n stop(): void {\n this.#active = false;\n this.#observer?.disconnect();\n this.#observer = null;\n this.#usingPlatformDefaults = false;\n }\n}\n","/**\n * 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 * Shared `prefers-reduced-motion` lookup for the motion-aware controllers.\n *\n * This one-liner keeps the media query string and the environment guard\n * single-sourced across them. The preference is intentionally re-read on every\n * call — the controllers check it at each animation/scroll start (WCAG 2.2\n * **2.3.3**), so flipping the OS setting takes effect immediately without any\n * listener or cache bookkeeping here.\n */\n\n/**\n * Whether the user currently requests reduced motion.\n *\n * @returns `true` when `(prefers-reduced-motion: reduce)` matches; `false`\n * otherwise, including environments without `window.matchMedia` (treated as\n * \"no preference\").\n */\nexport function prefersReducedMotion(): boolean {\n return (\n typeof window.matchMedia === \"function\" &&\n window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches\n );\n}\n","/**\n * What a scroll-driven component listens to and measures: a scroll container\n * somewhere in the page, or the window when nothing names one.\n *\n * A component that reacts to scrolling takes a selector for the container it\n * lives in and falls back to the viewport. Resolving that, and reading how far\n * the result has scrolled, are the same two steps everywhere — and the read is\n * the one that drifts, because the window and an element expose the offset under\n * different names.\n *\n * Resolution only. A selector reaches here already validated, or empty; whether\n * a declaration parses is decided once where it is declared, not on every\n * resolve.\n */\n\n/** A scroll container, or the window. */\nexport type ScrollSource = HTMLElement | Window;\n\n/**\n * The scroll container `selector` names, or `null` for the viewport.\n *\n * `null` covers every way a container can fail to be one: an empty selector, a\n * selector that matches nothing, and a match that is not an `HTMLElement` — an\n * SVG node answers a query but does not scroll.\n *\n * `selector` must be empty or already validated: an unparsable one makes the\n * query throw rather than fall back.\n */\nexport function resolveScrollContainer(selector: string): HTMLElement | null {\n const match = selector ? document.querySelector(selector) : null;\n return match instanceof HTMLElement ? match : null;\n}\n\n/** The scroll source `selector` names: its container, else the window. */\nexport function resolveScrollSource(selector: string): ScrollSource {\n return resolveScrollContainer(selector) ?? window;\n}\n\n/**\n * How far `source` has scrolled vertically.\n *\n * The window is compared by identity rather than with `instanceof`, which a\n * cross-realm or synthetic DOM fails. Its offset is read through the modern name\n * first and the legacy one after, so a runtime that exposes only one still gives\n * a number.\n */\nexport function scrollOffset(source: ScrollSource): number {\n return source === window\n ? (window.scrollY ?? window.pageYOffset ?? 0)\n : (source as HTMLElement).scrollTop;\n}\n","/**\n * The attribute selector for one declared target, in a controller's own namespace.\n *\n * Stimulus reads `data-<identifier>-target` as a **space-separated token list**, so a\n * single element can carry several target names at once. Matching the attribute value\n * whole would reach only the elements that declare exactly one name, which is why the\n * name is paired with `~=`.\n *\n * `identifier` is the name the controller is registered under, so the selector reaches\n * the markup that registration renders rather than one fixed spelling.\n */\nexport function targetSelector(identifier: string, name: string): string {\n return `[data-${identifier}-target~=\"${name}\"]`;\n}\n","import { Controller } from \"@hotwired/stimulus\";\nimport { actionSource } from \"../utils/action_source\";\nimport { validSelector } from \"../utils/declared_value\";\nimport { FrameCoalescer } from \"../utils/frame_coalescer\";\nimport { IntersectionWatcher } from \"../utils/intersection_watcher\";\nimport { MorphRenderWatcher } from \"../utils/morph_render_watcher\";\nimport { NUMBER_BOUNDS, type NumberValueConstraints } from \"../utils/number_bounds\";\nimport { NumberValueReader } from \"../utils/number_value\";\nimport { prefersReducedMotion } from \"../utils/reduced_motion\";\nimport { resolveScrollContainer, scrollOffset } from \"../utils/scroll_source\";\nimport { targetSelector } from \"../utils/target_selector\";\n\n/**\n * The attributes a link may anchor its section with, and therefore the only\n * ones whose rewrite has to re-sync the observation set. `aria-current` — the\n * attribute this controller writes itself — is deliberately absent, so\n * publishing the current location cannot feed back into a rebuild.\n */\nconst ANCHOR_ATTRIBUTES = [\"href\", \"data-href\"];\n\n/**\n * Headless, accessible **Scrollspy**: keeps a table of contents in sync with the\n * section the reader is currently in, published as `aria-current=\"location\"`.\n * There is no dedicated APG widget; it follows the `aria-current`\n * current-location practice inside a `<nav>` landmark.\n *\n * Markup contract (identifier: `stimeo--scrollspy`):\n * <nav data-controller=\"stimeo--scrollspy\"\n * data-stimeo--scrollspy-offset-value=\"80\"\n * data-stimeo--scrollspy-root-selector-value=\".content\"\n * aria-label=\"Table of contents\">\n * <a href=\"#intro\" data-stimeo--scrollspy-target=\"link\"\n * data-action=\"click->stimeo--scrollspy#scrollTo\">Intro</a>\n * <a href=\"#usage\" data-stimeo--scrollspy-target=\"link\"\n * data-action=\"click->stimeo--scrollspy#scrollTo\">Usage</a>\n * </nav>\n * <div class=\"content\">\n * <section id=\"intro\">…</section>\n * <section id=\"usage\">…</section>\n * </div>\n *\n * The active section is the one whose top edge sits closest to the **trigger\n * line**: `offset` px below the top of the *scroll root* — the `rootSelector`\n * container, or the viewport when that value is empty. It is not the viewport\n * top whenever a nested container is spied on. Intersecting sections win; when\n * none intersects (between two sections, scrolled past the last one) the\n * closest tracked section keeps the highlight, so a table of contents never\n * goes blank.\n *\n * `data-action` on the links is optional and opts into\n * {@link ScrollspyController.scrollTo | scrollTo}, which scrolls the nested\n * container instead of bouncing the whole window.\n *\n * `change` dispatches `{ id: string, link: HTMLElement }`.\n *\n * @remarks\n * Behavior only — how a current link looks is the consumer's CSS\n * (`[aria-current=\"location\"] { … }`). `connect()` reads the current location\n * back from the DOM so a Turbo cache restore re-establishes it without a\n * redundant `change`, and `disconnect()` severs every resource acquired here:\n * the observers, the scroll listener, and any pending frame or queued rebuild.\n *\n * **What is followed automatically**, and what is not (the boundary a consumer\n * has to know, because everything outside it needs a re-`connect()`):\n *\n * - `link` targets added or removed — Stimulus's target callbacks.\n * - a `link` target's `href` / `data-href` rewritten in place — a Turbo 8 morph\n * keeps the element *and* its target marker, so no target callback fires;\n * those two attributes are watched for exactly this case.\n * - the reader's scroll position, including inside a stretch where no section\n * crosses an observation threshold.\n *\n * Not followed: a *split* lifecycle in which the nav survives while the scroll\n * root or the sections are replaced underneath it. `rootSelector` is resolved\n * against the whole document and re-resolved once the cached container leaves\n * it, but section elements are looked up only while the observation set is\n * (re)built — swap those alone and nothing tells this controller to look again.\n */\nexport class ScrollspyController extends Controller<HTMLElement> {\n /** Numeric read boundaries share one reader for this controller instance. */\n readonly #numbers = new NumberValueReader();\n\n static override targets = [\"link\"];\n static override values = {\n offset: { type: Number, default: 0 },\n rootMargin: { type: String, default: \"\" },\n rootSelector: { type: String, default: \"\" },\n focusSection: { type: Boolean, default: false },\n };\n\n static valueConstraints = {\n offset: NUMBER_BOUNDS.finite,\n } satisfies NumberValueConstraints<typeof ScrollspyController.values>;\n static actions = [\"scrollTo\"] as const;\n static events = [\"change\"] as const;\n\n declare readonly linkTargets: HTMLElement[];\n\n declare offsetValue: number;\n declare rootMarginValue: string;\n declare rootSelectorValue: string;\n declare focusSectionValue: boolean;\n\n /**\n * The one offset shared by observation, active-section selection, and\n * scrolling. Stimulus parses a malformed Number Value as `NaN`; degrading it\n * to the declared default keeps every path aligned instead of only repairing\n * the observer margin while selection and scrolling still receive `NaN`.\n */\n get #offset(): number {\n return this.#safeOffset;\n }\n\n /** Shared IO plumbing (support guard, active guard, teardown). */\n readonly #watcher = new IntersectionWatcher((entries) => this.#onIntersection(entries));\n #isConnected = false;\n\n /**\n * Sections currently tracked, by id. Only the *latest reported* intersection\n * flag is stored — never a coordinate. Positions are re-measured when the\n * active section is evaluated, so a section observed several batches ago is\n * never compared against a trigger line computed now.\n */\n #intersectionStates = new Map<string, { element: Element; isIntersecting: boolean }>();\n\n /** Current active section ID; comparing it suppresses duplicate `change` events. */\n #activeSectionId = \"\";\n\n /**\n * Scroll root resolved when the observer was (re)built; `null` = viewport.\n * Cached so a click and every intersection batch reuse the element the\n * observer is actually watching instead of re-querying the document.\n */\n #rootElement: HTMLElement | null = null;\n\n /**\n * The source the `scroll` listener is currently attached to — the resolved\n * root, or the window while the viewport is spied. `null` means \"nothing\n * attached\", so teardown always detaches from the source it attached to\n * rather than from whatever the selector resolves to now.\n */\n #scrollSource: HTMLElement | Window | null = null;\n\n /** Coalesces a scroll burst into one measurement per frame. */\n readonly #frames = new FrameCoalescer();\n\n /** The validated `rootSelector`, or `\"\"` when the declaration cannot be parsed. */\n #rootSelector = \"\";\n\n /** Watches the link targets' anchor attributes for an in-place morph rewrite. */\n #anchorObserver: MutationObserver | null = null;\n\n #resyncInputsChanged = false;\n\n readonly #resync = new MorphRenderWatcher(() => {\n const retainStates = !this.#resyncInputsChanged;\n this.#resyncInputsChanged = false;\n this.#initializeObserver(retainStates);\n this.#evaluateActiveSection();\n });\n\n override connect(): void {\n this.#resync.observe(this.element);\n this.#isConnected = true;\n this.#observeAnchorAttributes();\n this.#initializeObserver();\n }\n\n override disconnect(): void {\n this.#isConnected = false;\n this.#resync.disconnect();\n this.#resyncInputsChanged = false;\n this.#watcher.stop();\n this.#anchorObserver?.disconnect();\n this.#anchorObserver = null;\n this.#detachScrollListener();\n this.#frames.cancel();\n this.#activeSectionId = \"\";\n this.#rootElement = null;\n }\n\n /**\n * Re-initializes the observer if the offset or rootMargin values change dynamically.\n */\n offsetValueChanged(): void {\n if (!this.#isConnected) return;\n this.#initializeObserver();\n }\n\n rootMarginValueChanged(): void {\n if (!this.#isConnected) return;\n this.#initializeObserver();\n }\n\n rootSelectorValueChanged(): void {\n this.#rootSelector = validSelector(this.element, this.rootSelectorValue, \"\");\n if (!this.#isConnected) return;\n this.#initializeObserver();\n }\n\n /**\n * Re-syncs the observation set when a Turbo Stream/morph swaps the table of\n * contents. Stimulus fires these before `connect()` for the links already in\n * the markup, hence the guard: the initial observer is built exactly once, by\n * `connect()`.\n */\n linkTargetConnected(): void {\n if (this.#isConnected) this.#scheduleResync();\n }\n\n linkTargetDisconnected(): void {\n if (this.#isConnected) this.#scheduleResync();\n }\n\n /**\n * Queues **one** observation rebuild for the current mutation batch.\n *\n * A single Turbo morph can append one link, drop another, and rewrite a\n * third's `href`, and those arrive through two independent channels —\n * Stimulus's target callbacks and {@link #anchorObserver}. Both channels share one\n * microtask queue, whose pending pass is cancelled on disconnect.\n */\n #scheduleResync(): void {\n this.#resyncInputsChanged = true;\n this.#resync.schedule();\n }\n\n /**\n * Watches the link targets' anchor attributes so an in-place rewrite re-syncs.\n *\n * A Turbo 8 morph keeps the element **and** its `data-*-target` marker and\n * only rewrites attributes, so Stimulus fires no target callback: without\n * this, a link re-pointed from `#intro` to `#faq` would keep the controller\n * observing `#intro` for the rest of the page's life. The filter is exactly\n * `href` and `data-href`; guarding on `MutationObserver` keeps the\n * controller usable where the API is absent, matching `IntersectionWatcher`'s\n * own support guard.\n */\n #observeAnchorAttributes(): void {\n if (typeof MutationObserver !== \"undefined\") {\n this.#anchorObserver = new MutationObserver(this.#onAnchorMutation);\n this.#anchorObserver.observe(this.element, {\n subtree: true,\n attributes: true,\n attributeFilter: ANCHOR_ATTRIBUTES,\n });\n }\n }\n\n /**\n * Rebuilds only for a rewrite on a *current* link target. The observer is\n * scoped to this controller's element, but that subtree also holds links the\n * author never marked as targets (a \"back to top\" anchor, a nested nav), and\n * those anchor nothing here.\n */\n readonly #onAnchorMutation = (records: MutationRecord[]): void => {\n const links = this.linkTargets;\n for (const record of records) {\n if (!links.includes(record.target as HTMLElement)) continue;\n this.#scheduleResync();\n return;\n }\n };\n\n /**\n * Scrolls to the section the clicked link anchors, honoring `offset` and any\n * nested scroll container (a plain fragment jump would scroll the window).\n *\n * Honors `prefers-reduced-motion` (WCAG 2.2 **2.3.3**) by forcing an instant\n * jump independently of the consumer's CSS `scroll-behavior`. With\n * `focusSection` enabled it also moves the sequential focus starting point\n * into the destination; the URL fragment is deliberately not touched.\n */\n scrollTo(source: Event | HTMLElement): void {\n const { event, host, origin } = actionSource(source);\n const link = host?.closest<HTMLElement>(targetSelector(this.identifier, \"link\"));\n if (!link || !this.linkTargets.includes(link)) return;\n if (origin && origin.closest(`[data-controller~=\"${this.identifier}\"]`) !== this.element)\n return;\n const moveFocus = event !== null || this.element.contains(document.activeElement);\n const id = this.#getAnchorId(link);\n if (!id) return;\n\n event?.preventDefault();\n\n const targetElement = document.getElementById(id);\n if (!targetElement) return;\n\n const behavior: ScrollBehavior = prefersReducedMotion() ? \"instant\" : \"smooth\";\n const rootElement = this.#scrollRoot();\n const targetRect = targetElement.getBoundingClientRect();\n const offset = this.#offset;\n\n if (rootElement) {\n const containerRect = rootElement.getBoundingClientRect();\n const scrollPosition =\n scrollOffset(rootElement) + (targetRect.top - containerRect.top) - offset;\n\n rootElement.scrollTo({ top: scrollPosition, behavior });\n } else {\n const scrollPosition = scrollOffset(window) + targetRect.top - offset;\n\n window.scrollTo({ top: scrollPosition, behavior });\n }\n\n if (this.focusSectionValue && moveFocus) this.#focusSection(targetElement);\n }\n\n /**\n * Moves the sequential focus starting point into the section `scrollTo` just\n * jumped to, so the next Tab continues *inside* the destination instead of\n * resuming in the table of contents (`preventDefault()` alone would leave the\n * starting point on the link). Opt-in through `focusSection`, because moving\n * focus is a decision only the consuming page can make.\n *\n * `tabindex=\"-1\"` is established only when the section is not already\n * focusable and is never removed, so an author-owned tabindex is left alone.\n * `preventScroll` keeps the focus call from cancelling the smooth scroll\n * started just above.\n */\n #focusSection(section: HTMLElement): void {\n if (!section.hasAttribute(\"tabindex\")) section.setAttribute(\"tabindex\", \"-1\");\n section.focus({ preventScroll: true });\n }\n\n /**\n * The cached scroll root, re-resolved when the cached element has left the\n * document (a Turbo morph replaced the container) so `scrollTo` never\n * scrolls a detached node.\n */\n #scrollRoot(): HTMLElement | null {\n if (this.#rootElement && !this.#rootElement.isConnected) {\n this.#rootElement = this.#queryRootElement();\n }\n return this.#rootElement;\n }\n\n /**\n * Resolves `rootSelector` to a scrollable element.\n *\n * @returns The container, or `null` meaning \"spy the viewport\" when the\n * declaration is empty, matches nothing, or matches a non-HTML element. A typo\n * reads as empty: the declaration is validated once when it changes, so a\n * selector that cannot be parsed degrades to viewport spying rather than\n * leaving the controller inert.\n */\n #queryRootElement(): HTMLElement | null {\n return resolveScrollContainer(this.#rootSelector);\n }\n\n /**\n * Re-evaluates once per frame while the reader scrolls.\n *\n * `IntersectionObserver` reports **threshold crossings**, not positions, so a\n * reader moving inside one long section — or across a gap wider than the\n * observation band — produces no batch at all and the highlight would stay\n * frozen at whatever the last crossing decided. That would make the current\n * location depend on the *route* to a position instead of the position: a\n * stepwise scroll crosses thresholds an instant jump to the same offset never\n * does. Listening to the scroll source closes the gap, and because both paths\n * end in {@link #evaluateActiveSection} — which measures section rects and the\n * root's top edge at that instant — they converge on the same answer.\n */\n readonly #onScroll = (): void => this.#frames.schedule(() => this.#evaluateActiveSection());\n\n /**\n * Points the `scroll` listener at whatever the reader actually scrolls: the\n * resolved root, or the window when the viewport is spied.\n *\n * The detach is unconditional, so rebuilding the observation set (a Value\n * change, a morph) **moves** the listener rather than stacking a second one on\n * a container the reader has stopped scrolling.\n */\n #syncScrollListener(): void {\n this.#detachScrollListener();\n this.#scrollSource = this.#rootElement ?? window;\n this.#scrollSource.addEventListener(\"scroll\", this.#onScroll, { passive: true });\n }\n\n #detachScrollListener(): void {\n this.#scrollSource?.removeEventListener(\"scroll\", this.#onScroll);\n this.#scrollSource = null;\n }\n\n /**\n * @stimeoRuntimeOnly `rootMargin` wires the observer this call installs; the active section it\n * republishes is the one already recorded.\n */\n #initializeObserver(retainStates = false): void {\n this.#watcher.stop();\n const previousStates = retainStates ? this.#intersectionStates : null;\n const previousRoot = this.#rootElement;\n this.#intersectionStates = new Map();\n // The DOM is the source of truth for the current location **only when this\n // controller has none of its own** — a fresh `connect()`, which is also the\n // Turbo cache-restore case, where the links still carry `aria-current` from\n // the snapshot. Adopting it there makes the observer's first batch a silent\n // confirmation instead of a duplicate `change`.\n //\n // On a *live* rebuild the memory wins, because the DOM has stopped meaning\n // what this controller wrote: an anchor rewritten underneath us leaves\n // `aria-current` on a link that now points somewhere else, so reading it\n // back would hand the current location to a section the reader never\n // scrolled to — and then announce the correction as a `change`, as if they\n // had travelled there and back.\n this.#activeSectionId = this.#activeSectionId || this.#activeIdFromDom();\n this.#rootElement = this.#queryRootElement();\n this.#syncScrollListener();\n\n if (this.linkTargets.length === 0) return;\n\n // Negate the numeric value so a valid negative offset becomes a positive margin.\n const margin = this.rootMarginValue || `${-this.#offset}px 0px -80% 0px`;\n\n // Observe each target section mapped by the href anchors.\n const sections: Element[] = [];\n for (const link of this.linkTargets) {\n const id = this.#getAnchorId(link);\n if (!id) continue;\n const section = document.getElementById(id);\n if (section && !sections.includes(section)) {\n sections.push(section);\n const previous = previousStates?.get(id);\n if (previous?.element === section && previousRoot === this.#rootElement) {\n this.#intersectionStates.set(id, previous);\n }\n }\n }\n\n this.#watcher.start(sections, {\n root: this.#rootElement,\n rootMargin: margin,\n threshold: [0, 0.2, 0.4, 0.6, 0.8, 1], // Multiple thresholds handle large sections safely\n });\n\n // Republish the adopted location over the *current* link set. Evaluation\n // writes attributes only when the winning section changes, so a link added\n // — or re-anchored — while the reader stays put would otherwise never be\n // marked: a mobile table of contents rendered after the sidebar one would\n // stay blank until the reader happened to cross into another section.\n //\n // Unconditional, including when the adopted location is empty: a link whose\n // anchor was rewritten to something that resolves nowhere cannot be the\n // reader's location, and this controller is the one that published the\n // attribute saying it was, so it is the one that has to take it back.\n this.#syncActiveStates(false);\n }\n\n readonly #onIntersection = (entries: IntersectionObserverEntry[]): void => {\n // Defense in depth. `IntersectionWatcher` already drops a batch the browser\n // flushes after `stop()` (its active/identity guard), so this flag is the\n // second line that keeps a detached controller from mutating `aria-current`\n // on (possibly cached) links.\n const isDetached = !this.#isConnected;\n if (isDetached) return;\n\n for (const entry of entries) {\n const sectionId = entry.target.id;\n if (!sectionId) continue;\n\n this.#intersectionStates.set(sectionId, {\n element: entry.target,\n isIntersecting: entry.isIntersecting,\n });\n }\n\n this.#evaluateActiveSection();\n };\n\n /**\n * Picks the section closest to the trigger line and publishes it.\n *\n * Every coordinate is read **now**: the section rects *and* the root's top\n * edge share one measurement instant. Comparing an entry's recorded\n * `boundingClientRect.top` (captured whenever that section last crossed a\n * threshold) against a freshly computed trigger line mixes two moments in\n * time, which would make the result depend on how the reader arrived at a\n * position — a smooth scroll and an instant jump to the same offset disagree.\n *\n * @stimeoRenderRoot\n */\n #evaluateActiveSection(): void {\n // The trigger line is `offset` px below the top of the scroll root. When a\n // nested `rootSelector` container is used it is not at the viewport top, so\n // the line must be measured from the container's current top — comparing the\n // viewport-based rect top against a bare `offset` would otherwise pick the\n // section nearest the viewport top, not the container's.\n const rootEl = this.#scrollRoot();\n const triggerLine = (rootEl ? rootEl.getBoundingClientRect().top : 0) + this.#offset;\n\n let intersectingId = \"\";\n let intersectingDistance = Number.POSITIVE_INFINITY;\n let trackedId = \"\";\n let trackedDistance = Number.POSITIVE_INFINITY;\n\n for (const [id, state] of this.#intersectionStates) {\n const rect = state.element.getBoundingClientRect();\n // A section with no layout box (`display: none`, a collapsed `<details>`,\n // an undisplayed Turbo Frame) is reported with an empty rect whose `top`\n // of 0 carries no position at all. Letting it compete would hand it the\n // fallback below; it re-enters the race once it is actually laid out.\n if (rect.width === 0 && rect.height === 0) continue;\n\n const distance = Math.abs(rect.top - triggerLine);\n if (distance < trackedDistance) {\n trackedDistance = distance;\n trackedId = id;\n }\n if (state.isIntersecting && distance < intersectingDistance) {\n intersectingDistance = distance;\n intersectingId = id;\n }\n }\n\n // Fallback: when no section currently intersects (e.g. scrolled past the\n // bottom, or between sections), keep the tracked section whose top is\n // closest to the trigger line so something stays highlighted.\n const bestId = intersectingId || trackedId;\n\n if (bestId && bestId !== this.#activeSectionId) {\n this.#activeSectionId = bestId;\n this.#syncActiveStates(true);\n }\n }\n\n /**\n * Writes `aria-current` across the current link set, optionally announcing.\n *\n * The two halves are separate because they answer different questions.\n * *Attributes* must be idempotently re-established whenever the link set\n * changes, even though the reader has not moved — otherwise a link that\n * appears (or is re-anchored) while its section is already current never gets\n * marked. *The `change` event* announces that the reader moved, so it fires\n * only from the evaluation path; re-publishing over a new link set is not\n * news, and dispatching there would make a rebuild look like navigation.\n *\n * @param announce Whether this sync represents a change of current section.\n */\n #syncActiveStates(announce: boolean): void {\n // Every link anchoring the active section is marked, not just the first:\n // a page may render the same table of contents twice (a sidebar and a\n // collapsed mobile menu) and both must show the current location.\n const activeLinks = this.linkTargets.filter(\n (link) => this.#getAnchorId(link) === this.#activeSectionId,\n );\n\n for (const link of this.linkTargets) {\n if (activeLinks.includes(link)) {\n link.setAttribute(\"aria-current\", \"location\");\n } else if (link.getAttribute(\"aria-current\") === \"location\") {\n // Reclaim only the value this controller publishes, so an author-owned\n // `aria-current=\"page\"` on a table-of-contents link survives.\n link.removeAttribute(\"aria-current\");\n }\n }\n\n if (!announce) return;\n\n const primaryLink = activeLinks[0];\n if (primaryLink) {\n this.dispatch(\"change\", { detail: { id: this.#activeSectionId, link: primaryLink } });\n }\n }\n\n /**\n * The current location already encoded in the DOM, i.e. the section anchored\n * by the first link carrying this controller's `aria-current=\"location\"`.\n * Empty when no link claims it (a genuinely fresh render).\n */\n #activeIdFromDom(): string {\n for (const link of this.linkTargets) {\n if (link.getAttribute(\"aria-current\") !== \"location\") continue;\n const id = this.#getAnchorId(link);\n if (id) return id;\n }\n return \"\";\n }\n\n /**\n * The section id a link anchors, resolved in a fixed order:\n *\n * 1. `href`, when it is a non-empty same-document fragment — the contract.\n * 2. otherwise `data-href`'s fragment — the fallback for a link whose `href`\n * must stay a real URL (a server-rendered permalink) or that is not an\n * `<a>` at all.\n * 3. otherwise `null`: the link anchors nothing here and is not observed.\n *\n * Step 2 is reached whenever `href` yields nothing usable — absent, `\"#\"`, or\n * a real URL — which is the whole point of the fallback: `href=\"/guide/usage\"`\n * with `data-href=\"#usage\"` is a permalink that also spies, and picking the\n * first *present* attribute instead of the first *usable* one would silently\n * exclude exactly that markup. When both are valid fragments `href` wins.\n */\n #getAnchorId(link: HTMLElement): string | null {\n return (\n this.#fragmentId(link.getAttribute(\"href\")) ??\n this.#fragmentId(link.getAttribute(\"data-href\"))\n );\n }\n\n /** The id in a `#fragment` value; `null` for absent, empty, or non-fragment. */\n #fragmentId(value: string | null): string | null {\n if (!value?.startsWith(\"#\")) return null;\n return value.substring(1) || null;\n }\n /** Current `offset` declaration resolved against its numeric contract. */\n get #safeOffset(): number {\n return this.#numbers.read(\n this,\n \"offset\",\n this.offsetValue,\n ScrollspyController.values.offset.default,\n ScrollspyController.valueConstraints.offset,\n );\n }\n}\n"]}
|
|
@@ -25,12 +25,15 @@ import { Controller } from '@hotwired/stimulus';
|
|
|
25
25
|
*
|
|
26
26
|
* The Stimulus Values are the live inputs. The controller reflects them as
|
|
27
27
|
* `role`, `tabindex`, `aria-orientation`, and the range ARIA while connected,
|
|
28
|
-
* then restores the attributes it displaced on disconnect
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
28
|
+
* then restores the attributes it displaced on disconnect. Existing finite
|
|
29
|
+
* range ARIA is hydrated into otherwise absent Values once, which preserves
|
|
30
|
+
* progressively enhanced server markup without leaving two live sources of
|
|
31
|
+
* truth. That fill is the one write
|
|
32
|
+
* `connect()` makes to a Value: a declared Value is never overwritten, and the
|
|
33
|
+
* normalized value is published through `aria-valuenow` without being written
|
|
34
|
+
* back.
|
|
32
35
|
*
|
|
33
|
-
* `change`
|
|
36
|
+
* `change` and `reconcile` dispatch `{ value: number }`.
|
|
34
37
|
*
|
|
35
38
|
* @remarks
|
|
36
39
|
* Behavior only — line drawing is the consumer's CSS. The axis follows Window
|
|
@@ -39,10 +42,30 @@ import { Controller } from '@hotwired/stimulus';
|
|
|
39
42
|
* there, so it follows the slider convention (ArrowRight/ArrowUp increase).
|
|
40
43
|
* Home/End are optional in the pattern and are implemented here; F6 is not.
|
|
41
44
|
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
45
|
+
* A maximum below the effective minimum collapses to that minimum; non-finite
|
|
46
|
+
* bounds use `0`/`100`, and an invalid or non-positive step uses `1`. Finite
|
|
47
|
+
* endpoints remain reachable even when they do not align to the step grid.
|
|
48
|
+
* `change` reports a key the user pressed that left the value somewhere other
|
|
49
|
+
* than the value last published. Runtime Value changes — a Turbo morph or
|
|
50
|
+
* application code — repaint once per batch, and when they move the value a
|
|
51
|
+
* focusable separator publishes, `reconcile` reports it with the same detail,
|
|
52
|
+
* so a consumer can tell its user's move from the page's. A key handled before
|
|
53
|
+
* a page write is repainted reads the written value, so its `change` covers the
|
|
54
|
+
* write as well, and a key that ends on the value last published reports
|
|
55
|
+
* nothing. A key dispatched from script runs every listener with no microtask
|
|
56
|
+
* between them, so a write made just before it, or by a listener that runs
|
|
57
|
+
* ahead of the separator, is handled that way. A key the browser dispatches
|
|
58
|
+
* runs microtasks between the listeners it calls separately, so a write made
|
|
59
|
+
* by one called ahead of the separator's — a capture listener on an ancestor or
|
|
60
|
+
* on `document`, a `:capture` action, or a listener added to the separator
|
|
61
|
+
* before its action was bound — is repainted, and reported as `reconcile`,
|
|
62
|
+
* before the key is measured from it. Stimulus calls the actions an element
|
|
63
|
+
* declares for one event and one set of listener options from a single
|
|
64
|
+
* listener, in declaration order, so a write made by an action declared before
|
|
65
|
+
* the separator's own is handled like a write within a key dispatched from
|
|
66
|
+
* script. A decorative
|
|
67
|
+
* separator publishes no value and reports nothing; one that becomes focusable
|
|
68
|
+
* again reports a value that moved meanwhile. Connecting reports neither.
|
|
46
69
|
*
|
|
47
70
|
* Because no position is ever applied here, two Window Splitter requirements
|
|
48
71
|
* fall to the consumer: `aria-controls` naming the **primary** pane — the one
|
|
@@ -81,29 +104,48 @@ declare class SeparatorController extends Controller<HTMLElement> {
|
|
|
81
104
|
default: number;
|
|
82
105
|
};
|
|
83
106
|
};
|
|
107
|
+
static valueConstraints: {
|
|
108
|
+
min: {
|
|
109
|
+
readonly finite: true;
|
|
110
|
+
};
|
|
111
|
+
max: {
|
|
112
|
+
readonly finite: true;
|
|
113
|
+
};
|
|
114
|
+
step: {
|
|
115
|
+
readonly finite: true;
|
|
116
|
+
readonly exclusiveMin: 0;
|
|
117
|
+
};
|
|
118
|
+
value: {
|
|
119
|
+
readonly finite: true;
|
|
120
|
+
};
|
|
121
|
+
};
|
|
84
122
|
static actions: readonly ["onKeydown"];
|
|
85
|
-
static events: readonly ["change"];
|
|
123
|
+
static events: readonly ["change", "reconcile"];
|
|
86
124
|
orientationValue: string;
|
|
87
125
|
focusableValue: boolean;
|
|
88
126
|
minValue: number;
|
|
89
127
|
maxValue: number;
|
|
90
128
|
stepValue: number;
|
|
91
129
|
valueValue: number;
|
|
92
|
-
/**
|
|
130
|
+
/**
|
|
131
|
+
* Hydrates authored range ARIA into absent Values once and renders them
|
|
132
|
+
* without writing the normalized value back. What the first render publishes
|
|
133
|
+
* is the baseline, so connecting reports nothing.
|
|
134
|
+
*/
|
|
93
135
|
connect(): void;
|
|
94
136
|
/** Cancels repaint work and returns every semantic attribute this instance controlled. */
|
|
95
137
|
disconnect(): void;
|
|
96
|
-
/**
|
|
138
|
+
/** Repaints an orientation changed by application code or a Turbo morph. */
|
|
97
139
|
orientationValueChanged(): void;
|
|
98
|
-
/**
|
|
140
|
+
/** Adds or removes the focusable range semantics at runtime. */
|
|
99
141
|
focusableValueChanged(): void;
|
|
100
|
-
/**
|
|
142
|
+
/** Repaints a minimum changed by application code or a Turbo morph. */
|
|
101
143
|
minValueChanged(): void;
|
|
102
|
-
/**
|
|
144
|
+
/** Repaints a maximum changed by application code or a Turbo morph. */
|
|
103
145
|
maxValueChanged(): void;
|
|
104
|
-
/**
|
|
146
|
+
/** Repaints a step changed by application code or a Turbo morph. */
|
|
105
147
|
stepValueChanged(): void;
|
|
106
|
-
/**
|
|
148
|
+
/** Repaints a current value changed by application code or a Turbo morph. */
|
|
107
149
|
valueValueChanged(): void;
|
|
108
150
|
/** Adjusts the value on arrow / Home / End keys (focusable variant only). */
|
|
109
151
|
onKeydown(event: KeyboardEvent): void;
|