stimeo-ui 0.16.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (328) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +8 -1
  3. package/dist/cable/index.d.ts +79 -23
  4. package/dist/cable/index.js +363 -436
  5. package/dist/cable/index.js.map +1 -1
  6. package/dist/controllers/accordion_controller.d.ts +4 -2
  7. package/dist/controllers/accordion_controller.js +166 -55
  8. package/dist/controllers/accordion_controller.js.map +1 -1
  9. package/dist/controllers/alert_dialog_controller.d.ts +12 -2
  10. package/dist/controllers/alert_dialog_controller.js +862 -221
  11. package/dist/controllers/alert_dialog_controller.js.map +1 -1
  12. package/dist/controllers/announcer_controller.d.ts +35 -5
  13. package/dist/controllers/announcer_controller.js +135 -198
  14. package/dist/controllers/announcer_controller.js.map +1 -1
  15. package/dist/controllers/aspect_ratio_controller.js +0 -10
  16. package/dist/controllers/aspect_ratio_controller.js.map +1 -1
  17. package/dist/controllers/auto_submit_controller.d.ts +30 -6
  18. package/dist/controllers/auto_submit_controller.js +271 -127
  19. package/dist/controllers/auto_submit_controller.js.map +1 -1
  20. package/dist/controllers/avatar_controller.js +171 -105
  21. package/dist/controllers/avatar_controller.js.map +1 -1
  22. package/dist/controllers/breadcrumb_controller.js +0 -130
  23. package/dist/controllers/breadcrumb_controller.js.map +1 -1
  24. package/dist/controllers/bulk_select_controller.d.ts +18 -0
  25. package/dist/controllers/bulk_select_controller.js +262 -52
  26. package/dist/controllers/bulk_select_controller.js.map +1 -1
  27. package/dist/controllers/calendar_controller.d.ts +24 -5
  28. package/dist/controllers/calendar_controller.js +175 -209
  29. package/dist/controllers/calendar_controller.js.map +1 -1
  30. package/dist/controllers/carousel_controller.d.ts +34 -7
  31. package/dist/controllers/carousel_controller.js +461 -399
  32. package/dist/controllers/carousel_controller.js.map +1 -1
  33. package/dist/controllers/character_counter_controller.d.ts +17 -1
  34. package/dist/controllers/character_counter_controller.js +246 -156
  35. package/dist/controllers/character_counter_controller.js.map +1 -1
  36. package/dist/controllers/checkbox_controller.d.ts +7 -2
  37. package/dist/controllers/checkbox_controller.js +32 -74
  38. package/dist/controllers/checkbox_controller.js.map +1 -1
  39. package/dist/controllers/clipboard_controller.d.ts +16 -5
  40. package/dist/controllers/clipboard_controller.js +168 -147
  41. package/dist/controllers/clipboard_controller.js.map +1 -1
  42. package/dist/controllers/collapsible_controller.d.ts +16 -4
  43. package/dist/controllers/collapsible_controller.js +301 -120
  44. package/dist/controllers/collapsible_controller.js.map +1 -1
  45. package/dist/controllers/color_picker_controller.d.ts +18 -6
  46. package/dist/controllers/color_picker_controller.js +149 -139
  47. package/dist/controllers/color_picker_controller.js.map +1 -1
  48. package/dist/controllers/combobox_controller.d.ts +23 -5
  49. package/dist/controllers/combobox_controller.js +360 -133
  50. package/dist/controllers/combobox_controller.js.map +1 -1
  51. package/dist/controllers/command_palette_controller.d.ts +45 -14
  52. package/dist/controllers/command_palette_controller.js +970 -358
  53. package/dist/controllers/command_palette_controller.js.map +1 -1
  54. package/dist/controllers/conditional_fields_controller.d.ts +15 -2
  55. package/dist/controllers/conditional_fields_controller.js +166 -124
  56. package/dist/controllers/conditional_fields_controller.js.map +1 -1
  57. package/dist/controllers/confirm_controller.d.ts +49 -12
  58. package/dist/controllers/confirm_controller.js +939 -248
  59. package/dist/controllers/confirm_controller.js.map +1 -1
  60. package/dist/controllers/context_menu_controller.d.ts +31 -4
  61. package/dist/controllers/context_menu_controller.js +256 -128
  62. package/dist/controllers/context_menu_controller.js.map +1 -1
  63. package/dist/controllers/count_up_controller.d.ts +13 -1
  64. package/dist/controllers/count_up_controller.js +73 -21
  65. package/dist/controllers/count_up_controller.js.map +1 -1
  66. package/dist/controllers/countdown_controller.d.ts +45 -1
  67. package/dist/controllers/countdown_controller.js +183 -148
  68. package/dist/controllers/countdown_controller.js.map +1 -1
  69. package/dist/controllers/currency_input_controller.d.ts +21 -2
  70. package/dist/controllers/currency_input_controller.js +134 -158
  71. package/dist/controllers/currency_input_controller.js.map +1 -1
  72. package/dist/controllers/data_grid_controller.d.ts +15 -4
  73. package/dist/controllers/data_grid_controller.js +114 -186
  74. package/dist/controllers/data_grid_controller.js.map +1 -1
  75. package/dist/controllers/date_range_picker_controller.d.ts +30 -5
  76. package/dist/controllers/date_range_picker_controller.js +288 -206
  77. package/dist/controllers/date_range_picker_controller.js.map +1 -1
  78. package/dist/controllers/dialog_controller.d.ts +13 -1
  79. package/dist/controllers/dialog_controller.js +858 -223
  80. package/dist/controllers/dialog_controller.js.map +1 -1
  81. package/dist/controllers/direct_upload_controller.d.ts +24 -7
  82. package/dist/controllers/direct_upload_controller.js +73 -153
  83. package/dist/controllers/direct_upload_controller.js.map +1 -1
  84. package/dist/controllers/dirty_form_controller.js +14 -48
  85. package/dist/controllers/dirty_form_controller.js.map +1 -1
  86. package/dist/controllers/dismissible_controller.d.ts +19 -0
  87. package/dist/controllers/dismissible_controller.js +175 -21
  88. package/dist/controllers/dismissible_controller.js.map +1 -1
  89. package/dist/controllers/drawer_controller.d.ts +39 -11
  90. package/dist/controllers/drawer_controller.js +933 -341
  91. package/dist/controllers/drawer_controller.js.map +1 -1
  92. package/dist/controllers/dropdown_controller.d.ts +31 -1
  93. package/dist/controllers/dropdown_controller.js +312 -82
  94. package/dist/controllers/dropdown_controller.js.map +1 -1
  95. package/dist/controllers/editable_controller.d.ts +12 -1
  96. package/dist/controllers/editable_controller.js +158 -68
  97. package/dist/controllers/editable_controller.js.map +1 -1
  98. package/dist/controllers/empty_state_controller.js +67 -53
  99. package/dist/controllers/empty_state_controller.js.map +1 -1
  100. package/dist/controllers/file_dropzone_controller.d.ts +60 -18
  101. package/dist/controllers/file_dropzone_controller.js +311 -207
  102. package/dist/controllers/file_dropzone_controller.js.map +1 -1
  103. package/dist/controllers/filter_controller.js +67 -39
  104. package/dist/controllers/filter_controller.js.map +1 -1
  105. package/dist/controllers/flash_controller.d.ts +31 -8
  106. package/dist/controllers/flash_controller.js +172 -314
  107. package/dist/controllers/flash_controller.js.map +1 -1
  108. package/dist/controllers/focus_controller.d.ts +12 -3
  109. package/dist/controllers/focus_controller.js +654 -240
  110. package/dist/controllers/focus_controller.js.map +1 -1
  111. package/dist/controllers/form_field_controller.js +147 -132
  112. package/dist/controllers/form_field_controller.js.map +1 -1
  113. package/dist/controllers/form_validation_controller.js +13 -86
  114. package/dist/controllers/form_validation_controller.js.map +1 -1
  115. package/dist/controllers/frame_loading_controller.d.ts +41 -9
  116. package/dist/controllers/frame_loading_controller.js +264 -213
  117. package/dist/controllers/frame_loading_controller.js.map +1 -1
  118. package/dist/controllers/highlight_controller.d.ts +22 -2
  119. package/dist/controllers/highlight_controller.js +107 -75
  120. package/dist/controllers/highlight_controller.js.map +1 -1
  121. package/dist/controllers/hover_card_controller.d.ts +56 -3
  122. package/dist/controllers/hover_card_controller.js +309 -118
  123. package/dist/controllers/hover_card_controller.js.map +1 -1
  124. package/dist/controllers/idle_controller.d.ts +42 -1
  125. package/dist/controllers/idle_controller.js +267 -101
  126. package/dist/controllers/idle_controller.js.map +1 -1
  127. package/dist/controllers/input_mask_controller.js +71 -72
  128. package/dist/controllers/input_mask_controller.js.map +1 -1
  129. package/dist/controllers/intersection_controller.d.ts +32 -13
  130. package/dist/controllers/intersection_controller.js +147 -106
  131. package/dist/controllers/intersection_controller.js.map +1 -1
  132. package/dist/controllers/lazy_frame_controller.d.ts +16 -0
  133. package/dist/controllers/lazy_frame_controller.js +9 -65
  134. package/dist/controllers/lazy_frame_controller.js.map +1 -1
  135. package/dist/controllers/listbox_controller.d.ts +34 -2
  136. package/dist/controllers/listbox_controller.js +306 -204
  137. package/dist/controllers/listbox_controller.js.map +1 -1
  138. package/dist/controllers/local_time_controller.d.ts +1 -1
  139. package/dist/controllers/local_time_controller.js +54 -64
  140. package/dist/controllers/local_time_controller.js.map +1 -1
  141. package/dist/controllers/masonry_controller.d.ts +11 -3
  142. package/dist/controllers/masonry_controller.js +70 -93
  143. package/dist/controllers/masonry_controller.js.map +1 -1
  144. package/dist/controllers/menu_controller.d.ts +32 -7
  145. package/dist/controllers/menu_controller.js +214 -156
  146. package/dist/controllers/menu_controller.js.map +1 -1
  147. package/dist/controllers/menubar_controller.d.ts +4 -4
  148. package/dist/controllers/menubar_controller.js +170 -329
  149. package/dist/controllers/menubar_controller.js.map +1 -1
  150. package/dist/controllers/meter_controller.d.ts +20 -0
  151. package/dist/controllers/meter_controller.js +151 -67
  152. package/dist/controllers/meter_controller.js.map +1 -1
  153. package/dist/controllers/multi_select_controller.d.ts +32 -4
  154. package/dist/controllers/multi_select_controller.js +593 -358
  155. package/dist/controllers/multi_select_controller.js.map +1 -1
  156. package/dist/controllers/navigation_menu_controller.d.ts +8 -1
  157. package/dist/controllers/navigation_menu_controller.js +124 -232
  158. package/dist/controllers/navigation_menu_controller.js.map +1 -1
  159. package/dist/controllers/nested_form_controller.d.ts +10 -0
  160. package/dist/controllers/nested_form_controller.js +352 -182
  161. package/dist/controllers/nested_form_controller.js.map +1 -1
  162. package/dist/controllers/network_status_controller.d.ts +23 -0
  163. package/dist/controllers/network_status_controller.js +242 -54
  164. package/dist/controllers/network_status_controller.js.map +1 -1
  165. package/dist/controllers/number_input_controller.d.ts +26 -2
  166. package/dist/controllers/number_input_controller.js +320 -263
  167. package/dist/controllers/number_input_controller.js.map +1 -1
  168. package/dist/controllers/optimistic_controller.js +16 -76
  169. package/dist/controllers/optimistic_controller.js.map +1 -1
  170. package/dist/controllers/otp_controller.d.ts +20 -4
  171. package/dist/controllers/otp_controller.js +198 -193
  172. package/dist/controllers/otp_controller.js.map +1 -1
  173. package/dist/controllers/overflow_indicator_controller.d.ts +5 -0
  174. package/dist/controllers/overflow_indicator_controller.js +116 -113
  175. package/dist/controllers/overflow_indicator_controller.js.map +1 -1
  176. package/dist/controllers/overflow_menu_controller.d.ts +48 -11
  177. package/dist/controllers/overflow_menu_controller.js +343 -283
  178. package/dist/controllers/overflow_menu_controller.js.map +1 -1
  179. package/dist/controllers/pagination_controller.d.ts +35 -6
  180. package/dist/controllers/pagination_controller.js +295 -119
  181. package/dist/controllers/pagination_controller.js.map +1 -1
  182. package/dist/controllers/password_reveal_controller.d.ts +45 -8
  183. package/dist/controllers/password_reveal_controller.js +389 -121
  184. package/dist/controllers/password_reveal_controller.js.map +1 -1
  185. package/dist/controllers/password_strength_controller.d.ts +14 -5
  186. package/dist/controllers/password_strength_controller.js +99 -153
  187. package/dist/controllers/password_strength_controller.js.map +1 -1
  188. package/dist/controllers/persist_controller.d.ts +11 -4
  189. package/dist/controllers/persist_controller.js +237 -103
  190. package/dist/controllers/persist_controller.js.map +1 -1
  191. package/dist/controllers/pointer_drag_controller.d.ts +19 -7
  192. package/dist/controllers/pointer_drag_controller.js +185 -165
  193. package/dist/controllers/pointer_drag_controller.js.map +1 -1
  194. package/dist/controllers/popover_controller.d.ts +38 -2
  195. package/dist/controllers/popover_controller.js +236 -97
  196. package/dist/controllers/popover_controller.js.map +1 -1
  197. package/dist/controllers/portal_controller.d.ts +44 -4
  198. package/dist/controllers/portal_controller.js +209 -76
  199. package/dist/controllers/portal_controller.js.map +1 -1
  200. package/dist/controllers/preview_guard_controller.d.ts +10 -4
  201. package/dist/controllers/preview_guard_controller.js +232 -116
  202. package/dist/controllers/preview_guard_controller.js.map +1 -1
  203. package/dist/controllers/progress_controller.d.ts +11 -0
  204. package/dist/controllers/progress_controller.js +125 -56
  205. package/dist/controllers/progress_controller.js.map +1 -1
  206. package/dist/controllers/radio_group_controller.d.ts +14 -5
  207. package/dist/controllers/radio_group_controller.js +117 -137
  208. package/dist/controllers/radio_group_controller.js.map +1 -1
  209. package/dist/controllers/range_slider_controller.d.ts +43 -3
  210. package/dist/controllers/range_slider_controller.js +192 -105
  211. package/dist/controllers/range_slider_controller.js.map +1 -1
  212. package/dist/controllers/rating_controller.d.ts +20 -4
  213. package/dist/controllers/rating_controller.js +418 -207
  214. package/dist/controllers/rating_controller.js.map +1 -1
  215. package/dist/controllers/read_more_controller.d.ts +2 -0
  216. package/dist/controllers/read_more_controller.js +134 -63
  217. package/dist/controllers/read_more_controller.js.map +1 -1
  218. package/dist/controllers/reading_progress_controller.d.ts +1 -1
  219. package/dist/controllers/reading_progress_controller.js +147 -135
  220. package/dist/controllers/reading_progress_controller.js.map +1 -1
  221. package/dist/controllers/relative_time_controller.d.ts +18 -4
  222. package/dist/controllers/relative_time_controller.js +145 -110
  223. package/dist/controllers/relative_time_controller.js.map +1 -1
  224. package/dist/controllers/reset_on_restore_controller.d.ts +85 -0
  225. package/dist/controllers/{reset_before_cache_controller.js → reset_on_restore_controller.js} +97 -38
  226. package/dist/controllers/reset_on_restore_controller.js.map +1 -0
  227. package/dist/controllers/resizable_controller.d.ts +28 -2
  228. package/dist/controllers/resizable_controller.js +255 -139
  229. package/dist/controllers/resizable_controller.js.map +1 -1
  230. package/dist/controllers/roving_controller.js +39 -84
  231. package/dist/controllers/roving_controller.js.map +1 -1
  232. package/dist/controllers/scroll_area_controller.d.ts +7 -3
  233. package/dist/controllers/scroll_area_controller.js +428 -225
  234. package/dist/controllers/scroll_area_controller.js.map +1 -1
  235. package/dist/controllers/scroll_restore_controller.js +0 -53
  236. package/dist/controllers/scroll_restore_controller.js.map +1 -1
  237. package/dist/controllers/scroll_visibility_controller.d.ts +28 -12
  238. package/dist/controllers/scroll_visibility_controller.js +395 -145
  239. package/dist/controllers/scroll_visibility_controller.js.map +1 -1
  240. package/dist/controllers/scrollspy_controller.d.ts +6 -1
  241. package/dist/controllers/scrollspy_controller.js +181 -242
  242. package/dist/controllers/scrollspy_controller.js.map +1 -1
  243. package/dist/controllers/separator_controller.d.ts +19 -4
  244. package/dist/controllers/separator_controller.js +267 -140
  245. package/dist/controllers/separator_controller.js.map +1 -1
  246. package/dist/controllers/sidebar_controller.d.ts +64 -7
  247. package/dist/controllers/sidebar_controller.js +1023 -386
  248. package/dist/controllers/sidebar_controller.js.map +1 -1
  249. package/dist/controllers/skeleton_controller.d.ts +23 -0
  250. package/dist/controllers/skeleton_controller.js +248 -97
  251. package/dist/controllers/skeleton_controller.js.map +1 -1
  252. package/dist/controllers/slider_controller.d.ts +27 -1
  253. package/dist/controllers/slider_controller.js +159 -79
  254. package/dist/controllers/slider_controller.js.map +1 -1
  255. package/dist/controllers/smart_sticky_header_controller.d.ts +21 -3
  256. package/dist/controllers/smart_sticky_header_controller.js +162 -63
  257. package/dist/controllers/smart_sticky_header_controller.js.map +1 -1
  258. package/dist/controllers/sortable_controller.js +0 -112
  259. package/dist/controllers/sortable_controller.js.map +1 -1
  260. package/dist/controllers/spinner_controller.d.ts +39 -4
  261. package/dist/controllers/spinner_controller.js +277 -169
  262. package/dist/controllers/spinner_controller.js.map +1 -1
  263. package/dist/controllers/step_indicator_controller.d.ts +5 -0
  264. package/dist/controllers/step_indicator_controller.js +99 -46
  265. package/dist/controllers/step_indicator_controller.js.map +1 -1
  266. package/dist/controllers/stepper_controller.d.ts +12 -3
  267. package/dist/controllers/stepper_controller.js +114 -73
  268. package/dist/controllers/stepper_controller.js.map +1 -1
  269. package/dist/controllers/stick_to_bottom_controller.d.ts +6 -0
  270. package/dist/controllers/stick_to_bottom_controller.js +262 -138
  271. package/dist/controllers/stick_to_bottom_controller.js.map +1 -1
  272. package/dist/controllers/sticky_observer_controller.d.ts +11 -0
  273. package/dist/controllers/sticky_observer_controller.js +214 -49
  274. package/dist/controllers/sticky_observer_controller.js.map +1 -1
  275. package/dist/controllers/submit_once_controller.d.ts +23 -8
  276. package/dist/controllers/submit_once_controller.js +294 -205
  277. package/dist/controllers/submit_once_controller.js.map +1 -1
  278. package/dist/controllers/switch_controller.d.ts +12 -1
  279. package/dist/controllers/switch_controller.js +33 -60
  280. package/dist/controllers/switch_controller.js.map +1 -1
  281. package/dist/controllers/tabs_controller.d.ts +2 -2
  282. package/dist/controllers/tabs_controller.js +35 -29
  283. package/dist/controllers/tabs_controller.js.map +1 -1
  284. package/dist/controllers/tags_input_controller.d.ts +12 -0
  285. package/dist/controllers/tags_input_controller.js +136 -145
  286. package/dist/controllers/tags_input_controller.js.map +1 -1
  287. package/dist/controllers/textarea_autosize_controller.d.ts +10 -0
  288. package/dist/controllers/textarea_autosize_controller.js +71 -58
  289. package/dist/controllers/textarea_autosize_controller.js.map +1 -1
  290. package/dist/controllers/theme_controller.d.ts +21 -9
  291. package/dist/controllers/theme_controller.js +130 -112
  292. package/dist/controllers/theme_controller.js.map +1 -1
  293. package/dist/controllers/time_picker_controller.d.ts +18 -1
  294. package/dist/controllers/time_picker_controller.js +146 -80
  295. package/dist/controllers/time_picker_controller.js.map +1 -1
  296. package/dist/controllers/toast_controller.d.ts +36 -11
  297. package/dist/controllers/toast_controller.js +186 -297
  298. package/dist/controllers/toast_controller.js.map +1 -1
  299. package/dist/controllers/toggle_group_controller.d.ts +12 -3
  300. package/dist/controllers/toggle_group_controller.js +95 -136
  301. package/dist/controllers/toggle_group_controller.js.map +1 -1
  302. package/dist/controllers/toolbar_controller.js +68 -98
  303. package/dist/controllers/toolbar_controller.js.map +1 -1
  304. package/dist/controllers/tooltip_controller.d.ts +45 -3
  305. package/dist/controllers/tooltip_controller.js +158 -124
  306. package/dist/controllers/tooltip_controller.js.map +1 -1
  307. package/dist/controllers/transition_controller.d.ts +22 -4
  308. package/dist/controllers/transition_controller.js +123 -119
  309. package/dist/controllers/transition_controller.js.map +1 -1
  310. package/dist/controllers/tree_view_controller.d.ts +21 -11
  311. package/dist/controllers/tree_view_controller.js +150 -345
  312. package/dist/controllers/tree_view_controller.js.map +1 -1
  313. package/dist/index.d.ts +8 -5
  314. package/dist/index.js +6370 -9346
  315. package/dist/index.js.map +1 -1
  316. package/dist/inspector/cli.d.ts +23 -3
  317. package/dist/inspector/cli.js +92 -37
  318. package/dist/inspector/cli.js.map +1 -1
  319. package/dist/inspector/cli_bin.js +92 -56
  320. package/dist/inspector/cli_bin.js.map +1 -1
  321. package/dist/inspector/examples.json +8 -8
  322. package/dist/inspector/manifest.json +787 -100
  323. package/dist/positioning/index.d.ts +8 -0
  324. package/dist/positioning/index.js +148 -47
  325. package/dist/positioning/index.js.map +1 -1
  326. package/package.json +6 -6
  327. package/dist/controllers/reset_before_cache_controller.d.ts +0 -76
  328. package/dist/controllers/reset_before_cache_controller.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/logical_scroll.ts","../../src/utils/arrow_step.ts","../../src/utils/intl_format.ts","../../src/utils/dates.ts","../../src/utils/field_mirror.ts","../../src/utils/locale.ts","../../src/utils/microtask_coalescer.ts","../../src/utils/target_selector.ts","../../src/controllers/calendar_controller.ts"],"names":[],"mappings":";;;;;AAiBO,SAAS,MAAM,OAAA,EAA2B;AAC/C,EAAA,OAAO,MAAA,CAAO,gBAAA,CAAiB,OAAO,CAAA,CAAE,SAAA,KAAc,KAAA;AACxD;;;AC6CO,SAAS,eAAA,CAAgB,KAAa,OAAA,EAA0B;AACrE,EAAA,IAAI,GAAA,KAAQ,YAAA,IAAgB,GAAA,KAAQ,WAAA,EAAa,OAAO,GAAA;AACxD,EAAA,IAAI,CAAC,KAAA,CAAM,OAAO,CAAA,EAAG,OAAO,GAAA;AAC5B,EAAA,OAAO,GAAA,KAAQ,eAAe,WAAA,GAAc,YAAA;AAC9C;AA2BO,SAAS,oBAAA,CACd,KAAA,EACA,KAAA,GAAkC,EAAC,EAC1B;AACT,EAAA,IAAI,CAAC,KAAA,CAAM,GAAA,CAAI,UAAA,CAAW,OAAO,GAAG,OAAO,KAAA;AAC3C,EAAA,OACG,KAAA,CAAM,MAAA,IAAU,CAAC,KAAA,CAAM,QAAA,CAAS,KAAK,CAAA,IACrC,KAAA,CAAM,OAAA,IAAW,CAAC,KAAA,CAAM,QAAA,CAAS,MAAM,KACvC,KAAA,CAAM,OAAA,IAAW,CAAC,KAAA,CAAM,QAAA,CAAS,MAAM,CAAA,IACvC,KAAA,CAAM,QAAA,IAAY,CAAC,KAAA,CAAM,QAAA,CAAS,OAAO,CAAA;AAE9C;;;ACtFA,IAAM,UAAA,uBAAiB,OA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EA,IAAA,OAAO,IAAA;AAAA,EACT;AACF","file":"calendar_controller.js","sourcesContent":["/** Normalized scroll position and maximum distance on one logical axis. */\nexport interface LogicalScrollMetrics {\n position: number;\n max: number;\n}\n\n/**\n * Whether horizontal scrolling on `element` follows right-to-left inline flow.\n *\n * Resolved from the **computed** `direction`, so the authoring contract is the\n * usual `dir=\"rtl\"` (or a stylesheet) on the element or any ancestor.\n *\n * Scope: horizontal writing modes. A vertical writing mode (`writing-mode:\n * vertical-rl`) also inverts the horizontal axis, which this check does not\n * model — vertical writing modes are out of scope for the scroll utilities\n * (their consumers describe axes as horizontal/vertical, not inline/block).\n */\nexport function isRtl(element: Element): boolean {\n return window.getComputedStyle(element).direction === \"rtl\";\n}\n\n/**\n * Returns scroll distance from the logical start edge.\n *\n * CSSOM View exposes standards-mode RTL horizontal offsets as `0` at the inline\n * start (right) and increasingly negative values toward the inline end (left).\n * The normalized position is always clamped to `[0, max]`, which also absorbs\n * Safari's elastic overscroll values.\n */\nexport function logicalScrollMetrics(\n element: HTMLElement,\n horizontal: boolean,\n): LogicalScrollMetrics {\n const max = Math.max(\n 0,\n horizontal\n ? element.scrollWidth - element.clientWidth\n : element.scrollHeight - element.clientHeight,\n );\n const raw = horizontal ? element.scrollLeft : element.scrollTop;\n const position = horizontal && isRtl(element) ? -raw : raw;\n return { position: Math.min(max, Math.max(0, position)), max };\n}\n\n/**\n * Converts a logical start/end delta to the physical value accepted by\n * `Element.scrollBy`.\n */\nexport function physicalScrollDelta(\n element: HTMLElement,\n horizontal: boolean,\n logicalDelta: number,\n): number {\n return horizontal && isRtl(element) ? -logicalDelta : logicalDelta;\n}\n","import { isRtl } from \"./logical_scroll\";\n\n/**\n * Turns an arrow key into a **logical** step: `+1` for \"next\", `-1` for\n * \"previous\", `0` when the key names neither.\n *\n * APG defines the horizontal pair as *next / previous* and says a vertical\n * arrangement swaps in Down/Up for the same meaning — so the pair is one axis's\n * spelling of an order, and the order reverses with the writing direction. Only\n * the horizontal pair reverses. Down/Up name an axis the writing direction does\n * not mirror, and returning them unchanged is the point: many controllers fold\n * both pairs into one branch, where swapping the branches under RTL would flip\n * the vertical axis too — a bug that reads as \"the arrows work\" until someone\n * presses Down.\n *\n * **Direction is read from the element the caller passes, which should be the\n * container that lays the items out** — not the focused child. A child may carry\n * its own `dir` (an LTR input inside an RTL form is ordinary authoring), and\n * probing per handler makes two handlers disagree at the boundary between them.\n *\n * This decides direction only. Whether the axis is even active (an\n * `orientation=\"horizontal\"` widget ignoring Down/Up), how far the step lands,\n * and what wrapping does all stay with the caller.\n *\n * **It encodes the list-order convention: `ArrowDown` is *next*.** Widgets that\n * pair the arrows by *value* instead — `ArrowUp` meaning \"more\", as a rating or a\n * slider does — must not use this, or their vertical axis inverts. Reverse the\n * horizontal pair on its own there.\n *\n * @example\n * ```ts\n * const step = logicalArrowStep(event.key, this.element);\n * if (step === 0) return;\n * this.#roving.setActive(rovingMove(current, length, step, \"wrap\"), { focus: true });\n * ```\n */\nexport function logicalArrowStep(key: string, element: Element): 1 | -1 | 0 {\n if (key === \"ArrowDown\") return 1;\n if (key === \"ArrowUp\") return -1;\n if (key !== \"ArrowRight\" && key !== \"ArrowLeft\") return 0;\n const forward = isRtl(element) ? \"ArrowLeft\" : \"ArrowRight\";\n return key === forward ? 1 : -1;\n}\n\n/**\n * Rewrites `key` so an existing LTR-shaped branch keeps working under RTL:\n * `ArrowRight` and `ArrowLeft` trade places, everything else passes through.\n *\n * The alternative — negating a delta — silently breaks handlers whose two\n * horizontal branches are **not mirror images**. A grid that clamps one edge but\n * not the other, or a segmented field guarding `index > 0` on one side and\n * `index < length - 1` on the other, ends up applying the wrong guard to the\n * wrong direction. Swapping the key leaves each branch, guards and all, exactly\n * where its author put it.\n *\n * Same rule as {@link logicalArrowStep} about which element to read: pass the\n * container that lays the items out, not the focused child.\n *\n * @example\n * ```ts\n * switch (logicalArrowKey(event.key, this.element)) {\n * case \"ArrowLeft\": // \"previous\" — whatever direction that is on screen\n * ```\n */\nexport function logicalArrowKey(key: string, element: Element): string {\n if (key !== \"ArrowRight\" && key !== \"ArrowLeft\") return key;\n if (!isRtl(element)) return key;\n return key === \"ArrowRight\" ? \"ArrowLeft\" : \"ArrowRight\";\n}\n\n/** Modifiers a widget may claim on an arrow key, named for the `allow` list. */\nexport type ArrowModifier = \"alt\" | \"ctrl\" | \"meta\" | \"shift\";\n\n/**\n * True when an arrow key arrived carrying a modifier the widget must leave to\n * the browser: return without calling `preventDefault()` and without moving any\n * state.\n *\n * A bare arrow belongs to the widget; a chorded one usually does not.\n * `Alt`/`Meta` plus a horizontal arrow is history back/forward on every desktop\n * browser, and a widget that swallows it makes the shortcut work or not\n * depending on where focus happens to sit — a coin-flip the user cannot see.\n *\n * `allow` is for the combinations APG assigns to a pattern **and the widget\n * actually implements** — today only Combobox's optional `Alt+Down`/`Alt+Up`.\n * Listing one the widget does not implement defeats the point: the chord then\n * runs the plain-arrow branch, which is exactly what this guard exists to stop.\n * Non-arrow keys return `false`, so chorded letters and\n * `Control+Home`/`Control+End` are untouched.\n *\n * @example\n * ```ts\n * if (isReservedArrowChord(event)) return;\n * ```\n */\nexport function isReservedArrowChord(\n event: KeyboardEvent,\n allow: readonly ArrowModifier[] = [],\n): boolean {\n if (!event.key.startsWith(\"Arrow\")) return false;\n return (\n (event.altKey && !allow.includes(\"alt\")) ||\n (event.ctrlKey && !allow.includes(\"ctrl\")) ||\n (event.metaKey && !allow.includes(\"meta\")) ||\n (event.shiftKey && !allow.includes(\"shift\"))\n );\n}\n\n/**\n * True when a press arrived carrying any modifier, for the keys the browser and\n * the OS own outright: return without calling `preventDefault()` and without\n * moving any state.\n *\n * `Control+Home` and `Control+End` jump the document to its ends, and a widget\n * that swallows them makes the shortcut work or not depending on where focus\n * happens to sit. {@link isReservedArrowChord} answers the same question for the\n * arrows, but returns `false` for every other key so that this one can decide.\n *\n * There is no `allow` list here on purpose. APG assigns no modifier chord to\n * `Home`/`End`, so a widget that wanted one would be claiming a combination the\n * pattern never gave it.\n *\n * @example\n * ```ts\n * case \"Home\":\n * case \"End\":\n * if (hasModifierChord(event)) return;\n * ```\n */\nexport function hasModifierChord(event: KeyboardEvent): boolean {\n return event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;\n}\n","/**\n * Construction of `Intl` formatters for the controllers that take a locale, and\n * the options that go with it, from a declaration.\n *\n * Every `Intl` constructor resolves locale data on the way in, which makes it\n * too costly to rebuild on a hot path, and rejects a malformed language tag,\n * currency code, time zone or digit count with a `RangeError`. Both concerns are\n * handled here once. A formatter is built at most once per distinct request and\n * shared by every caller that asks for the same one. A `RangeError` is caught\n * and answered the way the caller asked: by rebuilding under a fallback locale,\n * or by returning `null` so the caller can leave its authored text alone. Any\n * other failure is a programming fault and propagates.\n */\n\n/** The constructor shape the `Intl` formatter classes share. */\nexport interface IntlFormatterConstructor<F, O extends object> {\n new (locales?: string | string[], options?: O): F;\n}\n\n/** Built formatters, and refusals, per constructor; see `cacheKey` for the key. */\nconst formatters = new WeakMap<object, Map<string, unknown>>();\n\n/**\n * A formatter for `locale` with `options`.\n *\n * With `fallbackLocale`, a `RangeError` from the constructor is answered by\n * building the same options under the fallback instead, so the result is never\n * `null`; the fallback's own failure propagates. Without it, a `RangeError`\n * yields `null` and the caller decides what to show. Errors of any other kind\n * propagate in both forms.\n *\n * Results are cached per constructor and `(locale, options, fallback)`, `null`\n * included, so asking again on every render costs one map lookup.\n */\nexport function intlFormatter<F, O extends object>(\n factory: IntlFormatterConstructor<F, O>,\n locale: string | undefined,\n options: O,\n fallbackLocale: string,\n): F;\nexport function intlFormatter<F, O extends object>(\n factory: IntlFormatterConstructor<F, O>,\n locale: string | undefined,\n options: O,\n): F | null;\nexport function intlFormatter<F, O extends object>(\n factory: IntlFormatterConstructor<F, O>,\n locale: string | undefined,\n options: O,\n fallbackLocale?: string,\n): F | null {\n const cache = cacheFor(factory);\n const key = cacheKey(locale, options, fallbackLocale);\n if (cache.has(key)) return cache.get(key) as F | null;\n const formatter = construct(factory, locale, options, fallbackLocale);\n cache.set(key, formatter);\n return formatter;\n}\n\n/** The cache for one constructor, created on first use. */\nfunction cacheFor(factory: object): Map<string, unknown> {\n const existing = formatters.get(factory);\n if (existing) return existing;\n const created = new Map<string, unknown>();\n formatters.set(factory, created);\n return created;\n}\n\n/**\n * One key per distinct request. `JSON.stringify` drops an option left\n * `undefined`, which is how the constructor reads it too. Two spellings of the\n * same options differing only in key order key separately; that costs one extra\n * formatter, never a wrong one, and call sites pass a fixed literal anyway.\n */\nfunction cacheKey(\n locale: string | undefined,\n options: object,\n fallbackLocale: string | undefined,\n): string {\n return JSON.stringify([locale, options, fallbackLocale]);\n}\n\n/** Builds the formatter under the `RangeError` contract described on `intlFormatter`. */\nfunction construct<F, O extends object>(\n factory: IntlFormatterConstructor<F, O>,\n locale: string | undefined,\n options: O,\n fallbackLocale: string | undefined,\n): F | null {\n try {\n return new factory(locale, options);\n } catch (error) {\n if (!(error instanceof RangeError)) throw error;\n if (fallbackLocale === undefined) return null;\n return new factory(fallbackLocale, options);\n }\n}\n","/**\n * Date helpers shared by the calendar-family controllers\n * (`calendar`, `date-range-picker`): conversions between `Date` and bare ISO\n * strings, and the formatter for the month label a grid displays.\n *\n * The conversions are intentionally **local time** (not UTC): the grid a user\n * sees is built from `Date` components in their own timezone, so round-tripping\n * through ISO strings must use the same frame to avoid off-by-one-day drift near\n * midnight. Strings are bare `YYYY-MM-DD` / `YYYY-MM` with no time or zone.\n */\n\nimport { intlFormatter } from \"./intl_format\";\n\n/** Formats a {@link Date} as a local-time `YYYY-MM-DD` string. */\nexport function toISODateString(date: Date): string {\n const year = date.getFullYear();\n const month = String(date.getMonth() + 1).padStart(2, \"0\");\n const day = String(date.getDate()).padStart(2, \"0\");\n return `${year}-${month}-${day}`;\n}\n\n/**\n * Parses a `YYYY-MM-DD` string into a local-time {@link Date}, or `null`.\n *\n * Rejects calendar-invalid dates (e.g. `2026-02-31`): the constructed `Date`\n * would silently roll over to another day, so the parsed components are checked\n * back against it and a mismatch returns `null`.\n */\nexport function parseISODateString(dateStr: string): Date | null {\n if (!dateStr) return null;\n const match = dateStr.match(/^(\\d{4})-(\\d{2})-(\\d{2})$/);\n if (!match) return null;\n const [, y, m, d] = match;\n const year = Number(y);\n const month = Number(m);\n const day = Number(d);\n const date = new Date(year, month - 1, day);\n if (date.getFullYear() !== year || date.getMonth() !== month - 1 || date.getDate() !== day) {\n return null;\n }\n return date;\n}\n\n/**\n * Parses a `YYYY-MM` string into its year/month (1-based) parts, or `null`.\n * Rejects months outside `1..12`.\n */\nexport function parseISOMonthString(monthStr: string): { year: number; month: number } | null {\n if (!monthStr) return null;\n const match = monthStr.match(/^(\\d{4})-(\\d{2})$/);\n if (!match) return null;\n const [, y, m] = match;\n const month = Number(m);\n if (month < 1 || month > 12) return null;\n return { year: Number(y), month };\n}\n\n/** Formats a {@link Date} as the local-time `YYYY-MM` string of its month. */\nexport function toISOMonthString(date: Date): string {\n return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, \"0\")}`;\n}\n\n/** The long month name and the numeric year, e.g. `May 2026`. */\nconst MONTH_LABEL_OPTIONS: Intl.DateTimeFormatOptions = { month: \"long\", year: \"numeric\" };\n\n/**\n * Creates the formatter for a month label such as `May 2026`: the long month\n * name and the numeric year in `locale`.\n *\n * `locale` is the one the caller resolved, and `undefined` asks for the runtime\n * default. A tag `Intl` rejects (a `RangeError`, e.g. `en_US`) is replaced by\n * `\"en\"`, so a malformed declaration still yields a label and the grid paint\n * that follows it is never skipped. Any other failure of the constructor is a\n * programming fault and propagates.\n */\nexport function monthLabelFormatter(locale: string | undefined): Intl.DateTimeFormat {\n return intlFormatter(Intl.DateTimeFormat, locale, MONTH_LABEL_OPTIONS, \"en\");\n}\n","/**\n * The hidden form fields a widget keeps in step with the state it owns.\n *\n * A widget whose value lives in ARIA attributes submits nothing on its own, so\n * it mirrors that value into `<input type=\"hidden\">` — one field for a single\n * value, a container of generated fields for a set. The mirror is one-way: the\n * widget's own state stays the source of truth and the field is what the form\n * reads.\n *\n * The write and the report are separate calls because they answer to different\n * rules. A mirror is refreshed on connect, after a morph, and whenever the\n * widget repairs itself — none of which a form should treat as an edit. Only\n * the user's own commit reports one, which is why {@link commitField} is never\n * folded into the writes.\n */\n\n/** How a widget's generated fields identify themselves to the form. */\nexport interface GeneratedFieldOptions {\n /** The `name` every generated input submits under. */\n readonly name: string;\n /** The `form` id, for a widget that sits outside the form it submits to. */\n readonly form?: string;\n}\n\n/**\n * Mirrors one value into a hidden field.\n *\n * @returns Whether the field's value moved.\n *\n * @example\n * ```ts\n * if (writeField(this.fieldTarget, String(value)) && userDriven) {\n * commitField(this.fieldTarget);\n * }\n * ```\n */\nexport function writeField(field: HTMLInputElement, value: string): boolean {\n if (field.value === value) return false;\n field.value = value;\n return true;\n}\n\n/**\n * Mirrors a set of values into `container` as generated hidden fields, in the\n * order given.\n *\n * A container that already submits exactly this set is left untouched, children\n * and all — the mirror is refreshed far more often than it moves (every connect,\n * morph and repair), and a rebuild that changes nothing is still a DOM mutation\n * a consumer's observer and a `:empty` rule can see.\n *\n * @returns Whether the submitted set moved — its values, their order, the\n * `name`, or the `form`.\n */\nexport function writeFields(\n container: HTMLElement,\n values: readonly string[],\n { name, form = \"\" }: GeneratedFieldOptions,\n): boolean {\n const current = [...container.children];\n const submits =\n current.length === values.length &&\n current.every(\n (child, index) =>\n child instanceof HTMLInputElement &&\n child.type === \"hidden\" &&\n child.value === values[index] &&\n child.name === name &&\n (child.getAttribute(\"form\") ?? \"\") === form,\n );\n if (submits) return false;\n\n container.replaceChildren(\n ...values.map((value) => {\n const input = document.createElement(\"input\");\n input.type = \"hidden\";\n input.name = name;\n input.value = value;\n if (form !== \"\") input.setAttribute(\"form\", form);\n return input;\n }),\n );\n return true;\n}\n\n/**\n * Reports a committed value from `target` the way a native form control does:\n * one bubbling, non-cancelable `change`.\n *\n * Call it only for a move the user made. Form-level behaviors listen for this —\n * validation re-checks, auto-submit — and a mirror refreshed by a morph or a\n * repair is not something the user submitted.\n *\n * `target` is the element that carries the value: the hidden field for a single\n * mirrored value, the container for a generated set (whose own inputs are\n * replaced on every write), or a widget's own native control where that is what\n * the form reads.\n */\nexport function commitField(target: HTMLElement): void {\n target.dispatchEvent(new Event(\"change\", { bubbles: true }));\n}\n\n/**\n * Reports an edit a widget made on the user's behalf, the way the browser\n * reports its own: one bubbling `input`, then one bubbling `change`.\n *\n * This is for a widget that owns the stepping or picking its *own* native\n * control would otherwise do — writing `control.value` from script fires\n * nothing, so a form listening for either event never hears the edit. Use\n * {@link commitField} instead where the element is a mirror of state held\n * elsewhere: a hidden field has no native edit to imitate, so it reports the\n * commit alone.\n *\n * Call it only for a move the user made, and only where the widget really did\n * the writing — an edit the browser already reported would be doubled.\n */\nexport function commitEdit(control: HTMLElement): void {\n control.dispatchEvent(new Event(\"input\", { bubbles: true }));\n control.dispatchEvent(new Event(\"change\", { bubbles: true }));\n}\n","/**\n * The locale a component formats in: its own declaration, else the language of\n * the text around it, else the runtime default.\n *\n * `lang` is inherited in HTML, so the language that applies to an element is the\n * nearest one on the element itself or on an ancestor — not the document\n * element's, which is only the farthest of them. An empty `lang` there means the\n * language is unknown and stops the inheritance at that point, so it resolves to\n * the runtime default rather than to a `lang` further up.\n *\n * Resolution only, and the value is passed through as authored. Whether `Intl`\n * accepts the tag, and what to show when it does not, is the caller's contract.\n *\n * @example\n * ```ts\n * intlFormatter(Intl.DateTimeFormat, resolveLocale(this.element, this.localeValue), options);\n * ```\n */\nexport function resolveLocale(element: Element, declared = \"\"): string | undefined {\n return declared || element.closest(\"[lang]\")?.getAttribute(\"lang\") || undefined;\n}\n","/**\n * Collapses many Stimulus lifecycle callbacks from one DOM mutation into a\n * single pass.\n *\n * Stimulus fires `<name>TargetConnected` / `Disconnected` once per element and\n * `<name>ValueChanged` once per changed attribute. Replacing a list of N options\n * or morphing several render Values therefore delivers N callbacks — but the\n * useful unit of work is \"reconcile against the resulting declarative input\",\n * once, after the batch has settled. Every controller with reconcilable targets\n * or render Values needs the same shape: a `queued` flag plus `queueMicrotask`.\n *\n * **A microtask is the right horizon, and the reason is specific.** Stimulus\n * drives these callbacks from a `MutationObserver`, whose own callback already\n * runs as a microtask with the whole batch in hand; scheduling one more lands\n * after the last sibling callback of that batch and still before paint or any\n * event handler. A timer would be later than it needs to be, and reconciling\n * synchronously would run once per element against a half-applied DOM.\n *\n * **The two guards are not the same guard.** Scheduling is refused before the\n * controller connects, and running is refused after it disconnects:\n *\n * - **Before `connect()`** — Stimulus delivers initial target and Value callbacks\n * ahead of `connect()`. Reconciling there would compute output against a\n * controller whose own state has not been initialised, and `connect()` is\n * about to do a full pass anyway.\n * - **After `disconnect()`** — Stimulus fires a callback for **every** target\n * during teardown, and a microtask queued just before it would otherwise run\n * against a detached tree. {@link MicrotaskCoalescer.cancel} exists for the\n * teardown path to drop the pending pass outright.\n *\n * Both guards are part of one contract here rather than something each consumer\n * has to remember separately.\n *\n * Scope is the scheduling only. *What* to reconcile — keep the surviving active\n * option, fall back to the next / previous / first visible one, rebuild derived\n * chips or hidden fields — stays in the controller, because no two consumers\n * answer it the same way.\n *\n * This file's own doc block is dropped from `dist`, but every member comment is\n * inlined into each consumer entry (`tsup` builds with `splitting: false`), so\n * rationale belongs here and only the contract belongs on the members.\n *\n * @example\n * ```ts\n * readonly #reconcile = new MicrotaskCoalescer(() => this.#reconcileOptions());\n *\n * connect() { this.#reconcile.activate(); }\n * disconnect() { this.#reconcile.cancel(); }\n *\n * optionTargetConnected() { this.#reconcile.schedule(); }\n * optionTargetDisconnected() { this.#reconcile.schedule(); }\n * ```\n */\nexport class MicrotaskCoalescer {\n readonly #run: () => void;\n #queued = false;\n #active = false;\n #generation = 0;\n\n /** @param run - the single reconciliation pass, invoked at most once per batch. */\n constructor(run: () => void) {\n this.#run = run;\n }\n\n /** Opens the window in which {@link schedule} is honoured; call from `connect()`. */\n activate(): void {\n this.#active = true;\n }\n\n /** Closes the window and drops any pending pass; call from `disconnect()`. */\n cancel(): void {\n this.#active = false;\n this.#queued = false;\n this.#generation += 1;\n }\n\n /** Requests one pass after the batch settles. Idempotent; inert outside the window. */\n schedule(): void {\n if (!this.#active || this.#queued) return;\n this.#queued = true;\n const generation = this.#generation;\n queueMicrotask(() => {\n // A cancelled callback must not consume a pass queued after reconnect.\n if (generation !== this.#generation || !this.#queued || !this.#active) return;\n this.#queued = false;\n this.#run();\n });\n }\n}\n","/**\n * 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 { isReservedArrowChord, logicalArrowKey } from \"../utils/arrow_step\";\nimport {\n monthLabelFormatter,\n parseISODateString,\n parseISOMonthString,\n toISODateString,\n toISOMonthString,\n} from \"../utils/dates\";\nimport { commitField, writeField } from \"../utils/field_mirror\";\nimport { resolveLocale } from \"../utils/locale\";\nimport { MicrotaskCoalescer } from \"../utils/microtask_coalescer\";\nimport { targetSelector } from \"../utils/target_selector\";\n\n/**\n * Suffix of the marker on an `aria-disabled` this controller wrote, so a re-paint\n * takes back only its own. A consumer marks holidays and booked days with the same\n * attribute; without the marker a paint would clear their intent.\n *\n * The marker is scoped to the date the cell currently shows, not to the cell: the\n * 42 cells are recycled, so a value that outlived its date would disable a\n * different day. A consumer's value belongs to its date as well: a repaint that\n * moves the date to another cell carries the value along, and a date that leaves\n * the grid loses it. A consumer that marks specific dates applies them once for\n * the month the grid opens on, then again after `stimeo--calendar:monthchange`,\n * which reports a move to a different month.\n */\nconst OWNED_DISABLED = \"owns-disabled\";\n\n/**\n * Headless, highly accessible calendar grid behavior.\n *\n * Markup contract (identifier: `stimeo--calendar`):\n * <div data-controller=\"stimeo--calendar\"\n * data-stimeo--calendar-month-value=\"2026-05\"\n * data-stimeo--calendar-selected-value=\"2026-05-31\">\n * <input type=\"hidden\" name=\"on\" data-stimeo--calendar-target=\"field\" />\n * <input type=\"hidden\" name=\"month\" data-stimeo--calendar-target=\"monthField\" />\n * <button data-action=\"click->stimeo--calendar#prev\">Previous</button>\n * <span data-stimeo--calendar-target=\"label\">May 2026</span>\n * <button data-action=\"click->stimeo--calendar#next\">Next</button>\n * <table role=\"grid\">\n * <tbody data-stimeo--calendar-target=\"grid\"\n * data-action=\"keydown->stimeo--calendar#onKeydown\n * click->stimeo--calendar#selectByClick\">\n * <!-- Markup must contain exactly 42 day targets (7 days x 6 rows) -->\n * <tr role=\"row\">\n * <td role=\"gridcell\" data-stimeo--calendar-target=\"day\" tabindex=\"-1\"></td>\n * </tr>\n * </tbody>\n * </table>\n * </div>\n *\n * Implements the WAI-ARIA APG **Date Picker Dialog** grid navigation pattern:\n * - Locale-aware month/year labels using native `Intl.DateTimeFormat`, taken from\n * the `locale` Value, else the nearest `lang` up the ancestor chain, else the\n * runtime default; a malformed language tag falls back to English so the grid\n * still paints.\n * - Without a `month`, the grid opens on the month of the selected day, else on\n * the current month, when an instance first connects, and stays on the month\n * it shows until a month step or the page writes `month` — a later connection\n * of the same instance, after an in-page move or with the identifier added\n * back, keeps it too. Opening on a month writes nothing to `month`.\n * - Roving tabindex focus tracking (exactly one focusable day at any time). The\n * tab stop opens on the selected day, else on today when the shown month\n * holds it, else on the 1st of the shown month; a selected day the grid does\n * not show leaves it on the 1st.\n * - Full grid keyboard controls (arrows, PageUp/Down, Home/End, Shift+PageUp/Down).\n * - Automatic month wrapping and date clamping for missing dates (e.g. leap years, 31st to 30th).\n * - `min`, `max` and `weekStart` changed at runtime repaint the month on screen\n * once connected, and DOM focus in the grid stays on the day it was on while\n * that day is still shown.\n * - A `month` that moves the painted month — written by application code, a\n * morph, or the grid's own month steps — takes DOM focus in the grid to the\n * tab stop of the new month. A key that crosses into another month makes the\n * day it moved to that tab stop, so focus lands there.\n * - An `aria-disabled` the consumer wrote on a day stays with that date while\n * the grid shows it, in whichever cell a repaint moves the date to.\n *\n * `selected` is a request: the grid publishes it as the selection only while\n * `min` / `max` allow that day. A day outside them is neither `aria-selected`\n * nor mirrored into `field`, and it comes back once the bounds allow it again;\n * the Value itself is never rewritten.\n *\n * `monthchange` dispatches `{ month: string }`; `select` dispatches `{ date: string }`.\n * `reconcile` dispatches `{ date: string }` — the selection now published, empty\n * when there is none — once per paint in which a change the page made after\n * connect moved the published selection: `selected` written by application\n * code or a morph, or `min` / `max` withholding the requested day or giving it\n * back. A selection the user picks is reported as `select` alone. Connecting,\n * or connecting again, reports neither `monthchange` nor `reconcile`, whichever\n * month the grid opens on.\n *\n * Two optional fields carry the grid's state into a form, so a server can serve\n * the days it is showing: `field` mirrors the published selection (`YYYY-MM-DD`,\n * empty when nothing is selected) and `monthField` the month being painted\n * (`YYYY-MM`). A move the user made — the previous/next controls, a month\n * crossing by keyboard, picking a day — emits a native bubbling `change` from\n * the field that moved, the way a form control does, so `stimeo--auto-submit`\n * and form-level validation hear it. A repaint driven by the Values, by a\n * replacement field, or by the initial paint refreshes both mirrors silently,\n * and so does a move of the selection a change the page made, which `reconcile`\n * reports even in a paint the user's own move asked for.\n *\n * A day `min` / `max` exclude cannot be picked, even before a paint has marked\n * its cell. A pick is painted — `aria-selected` and both fields — before\n * anything reports it: each field that moved, then `monthchange` when the paint\n * moved the month, then `select`. A listener that replaces the selection before\n * these reports are all out — by picking another day, or with a paint in which\n * `min` / `max` withhold this one — has the newer selection report itself, and\n * what is still pending for the replaced pick is not sent.\n *\n * @remarks\n * Behavior only. The controller updates attributes (`aria-selected`, `data-outside`,\n * `tabindex`, …) and text content on the 42 pre-allocated `day` targets.\n */\nexport class CalendarController extends Controller<HTMLElement> {\n /** The marker above, in the namespace this controller is registered under. */\n get #ownedDisabled(): string {\n return `data-${this.identifier}-${OWNED_DISABLED}`;\n }\n\n static override targets = [\"label\", \"grid\", \"day\", \"field\", \"monthField\"];\n static override values = {\n month: { type: String, default: \"\" },\n selected: { type: String, default: \"\" },\n min: { type: String, default: \"\" },\n max: { type: String, default: \"\" },\n weekStart: { type: Number, default: 0 }, // 0 = Sunday, 1 = Monday, etc.\n locale: { type: String, default: \"\" },\n };\n static actions = [\"next\", \"onKeydown\", \"prev\", \"selectByClick\"] as const;\n static events = [\"monthchange\", \"reconcile\", \"select\"] as const;\n\n declare readonly labelTarget: HTMLElement;\n declare readonly gridTarget: HTMLElement;\n declare readonly dayTargets: HTMLElement[];\n declare readonly fieldTarget: HTMLInputElement;\n declare readonly monthFieldTarget: HTMLInputElement;\n declare readonly hasLabelTarget: boolean;\n declare readonly hasGridTarget: boolean;\n declare readonly hasFieldTarget: boolean;\n declare readonly hasMonthFieldTarget: boolean;\n\n declare monthValue: string;\n declare selectedValue: string;\n declare minValue: string;\n declare maxValue: string;\n declare weekStartValue: number;\n declare localeValue: string;\n\n /** The date currently receiving focus in the grid (local time). */\n focusedDate: Date = new Date();\n\n /**\n * Whether `connect()` has run and `disconnect()` has not since. The paints\n * before and during `connect()` describe the grid, so they report nothing.\n */\n #connected = false;\n\n /**\n * The selection the last paint published — a `YYYY-MM-DD` day, or `\"\"` — which\n * the next move of the selection is measured from. A pick records its own day\n * here before painting it.\n */\n #published = \"\";\n\n /**\n * How many times a pick or a change the page made has moved the selection, so\n * a report still pending for a selection a listener has since replaced can tell.\n */\n #selectionMoves = 0;\n\n /**\n * The month the last paint showed (`YYYY-MM`), or `\"\"` before the first paint.\n * Only a connected grid reports a paint that moves it: settling on the initial\n * month — before `connect()` or in it, from the attribute or derived here — is\n * the grid describing itself, not a navigation, so it must not reach a\n * listener that refetches inventory or pushes history.\n *\n * While `month` is empty this is also the month the next paint shows, so the\n * grid stays where it is; the first `connect()` of this instance sets it to the\n * month the grid opens on.\n */\n #paintedMonth = \"\";\n\n /**\n * Whether this instance has connected before. Only its first connection picks\n * the month a grid with no `month` opens on. A later one keeps the month on\n * screen, and so do the paints Stimulus runs before it.\n */\n #opened = false;\n\n /**\n * Whether the paint about to run was asked for by this grid's own controls.\n * The `month` and `selected` Values are shared with the page — application\n * code and a Turbo morph write them too — so the field mirrors take their\n * \"did the user commit this\" answer from the route, not from the Value.\n */\n #movedByUser = false;\n\n /**\n * Repaints the month on screen after `min`, `max` or `weekStart` changed.\n *\n * A morph that swaps several of them repaints once, and the delivery Stimulus\n * makes before `connect()` is refused, because the grid is painted on\n * connect. None of these Values decides the month on screen; `min` and `max`\n * decide whether the requested day is published.\n */\n readonly #repaint = new MicrotaskCoalescer(() => {\n this.#repaintKeepingFocus();\n });\n\n /**\n * The cell DOM focus was on, its day and the month on screen, recorded by the\n * first repaint of a batch for the pass that settles focus after it.\n */\n #focusOrigin: { cell: HTMLElement; date: string | null; month: string } | null = null;\n\n /**\n * Settles DOM focus once, after the last repaint of a batch. The callbacks of\n * one mutation repaint one by one and each reads every Value as it stands, so\n * a `selected` or `locale` callback can paint a month before that month's own\n * callback has moved the tab stop into it. Outside a connection no pass is\n * scheduled, so a grid that is not connected moves no focus.\n */\n readonly #settleFocus = new MicrotaskCoalescer(() => {\n this.#restoreFocus();\n });\n\n override connect(): void {\n this.#repaint.activate();\n this.#settleFocus.activate();\n // A record a paint left outside the connection has no pass coming.\n this.#focusOrigin = null;\n // No month declared: the first connection opens the grid on the month of the\n // published selection, else on the current one, and a later one keeps the\n // month on screen. The Value stays as the page wrote it.\n if (!this.monthValue && !this.#opened) {\n this.#paintedMonth = toISOMonthString(parseISODateString(this.#selection) ?? new Date());\n }\n this.#opened = true;\n this.#initializeFocusedDate();\n this.#render();\n this.#connected = true;\n }\n\n /**\n * Drops a pending repaint and a pending focus move, and stops reporting, so\n * nothing reaches for a grid that is not connected.\n */\n override disconnect(): void {\n this.#connected = false;\n this.#repaint.cancel();\n this.#settleFocus.cancel();\n }\n\n /**\n * Paints the month `month` names, whether application code, a morph or the\n * grid's own navigation wrote it; focus in the grid follows to the tab stop.\n */\n monthValueChanged(): void {\n if (!this.monthValue) return;\n this.#syncFocusedDateWithMonth();\n this.#repaintKeepingFocus();\n }\n\n /**\n * Repaints the label when application code changes `locale` at runtime.\n *\n * Stimulus runs this for the initial Value too, before `connect()`. The paint\n * it triggers is idempotent — the month comes from `month` (or, while that is\n * still empty, from `focusedDate`) — and a grid that has not connected\n * reports nothing, so that paint never reports a month.\n */\n localeValueChanged(): void {\n this.#repaintKeepingFocus();\n }\n\n /**\n * Repaints `aria-selected` and the field when the requested day changes, and\n * moves the tab stop to the day the grid now publishes. A request `min` /\n * `max` withhold is not published, so the tab stop stays where it was.\n */\n selectedValueChanged(): void {\n const selection = parseISODateString(this.#selection);\n if (selection) this.focusedDate = selection;\n this.#repaintKeepingFocus();\n }\n\n /** Repaints when `min` changes after connect, so the disabled days and the selection follow. */\n minValueChanged(): void {\n this.#repaint.schedule();\n }\n\n /** Repaints when `max` changes after connect, so the disabled days and the selection follow. */\n maxValueChanged(): void {\n this.#repaint.schedule();\n }\n\n /**\n * Lays the grid out again when `weekStart` changes after connect, so every\n * date moves to the column of its weekday.\n *\n * Only the day cells are painted: column headers are author markup, so the\n * author updates them together with the Value.\n */\n weekStartValueChanged(): void {\n this.#repaint.schedule();\n }\n\n /** Navigates to the previous month. */\n prev(event?: Event): void {\n if (event) event.preventDefault();\n this.#shiftMonth(-1);\n }\n\n /** Navigates to the next month. */\n next(event?: Event): void {\n if (event) event.preventDefault();\n this.#shiftMonth(1);\n }\n\n /** Handles day selection when a gridcell is clicked. */\n selectByClick(event: MouseEvent): void {\n const dayElement = (event.target as HTMLElement | null)?.closest<HTMLElement>(\n targetSelector(this.identifier, \"day\"),\n );\n if (!dayElement) return;\n\n this.selectDayElement(dayElement);\n }\n\n /** Handles grid cell keyboard navigation and triggers selection. */\n onKeydown(event: KeyboardEvent): void {\n // A widget that already claimed the key (a nested control, an enclosing\n // composite) must not ALSO move the roving focus or select a day.\n if (event.defaultPrevented) return;\n if (isReservedArrowChord(event)) return;\n const dayElement = (event.target as HTMLElement | null)?.closest<HTMLElement>(\n targetSelector(this.identifier, \"day\"),\n );\n if (!dayElement) return;\n\n // A cell the paint never reached carries no `data-date`, and an empty string\n // parses to null — one exit covers both.\n const date = parseISODateString(dayElement.getAttribute(\"data-date\") ?? \"\");\n if (!date) return;\n\n let handled = true;\n let nextDate = new Date(date);\n\n // Logical, not physical. The key is normalised rather than the\n // delta negated: these two branches are not mirror images — their guards\n // differ — so swapping the key keeps each guard with its own direction.\n switch (logicalArrowKey(event.key, this.element)) {\n case \"ArrowLeft\":\n nextDate.setDate(nextDate.getDate() - 1);\n break;\n case \"ArrowRight\":\n nextDate.setDate(nextDate.getDate() + 1);\n break;\n case \"ArrowUp\":\n nextDate.setDate(nextDate.getDate() - 7);\n break;\n case \"ArrowDown\":\n nextDate.setDate(nextDate.getDate() + 7);\n break;\n case \"PageUp\":\n if (event.shiftKey) {\n nextDate = this.#calculateShiftedYearDate(date, -1);\n } else {\n nextDate = this.#calculateShiftedMonthDate(date, -1);\n }\n break;\n case \"PageDown\":\n if (event.shiftKey) {\n nextDate = this.#calculateShiftedYearDate(date, 1);\n } else {\n nextDate = this.#calculateShiftedMonthDate(date, 1);\n }\n break;\n case \"Home\":\n nextDate = this.#getStartOfWeekDate(date);\n break;\n case \"End\":\n nextDate = this.#getEndOfWeekDate(date);\n break;\n case \"t\":\n case \"T\": {\n // A single printable key must not be claimed out of a modifier chord:\n // Ctrl/Cmd/Alt+T belongs to the browser, not to the grid.\n if (event.ctrlKey || event.metaKey || event.altKey) {\n handled = false;\n break;\n }\n const now = new Date();\n nextDate = new Date(now.getFullYear(), now.getMonth(), now.getDate());\n break;\n }\n case \"Enter\":\n case \" \":\n event.preventDefault();\n this.selectDayElement(dayElement);\n return;\n default:\n handled = false;\n break;\n }\n\n if (handled) {\n event.preventDefault();\n this.#focusAndNavigateToDate(nextDate);\n }\n }\n\n /**\n * First day of the month the grid paints: the `month` Value when it parses —\n * while it is empty, the month on screen — otherwise the focused date's month.\n *\n * A malformed `month` falls back instead of stopping the paint: every cell\n * keeps its `aria-selected` and the grid keeps its tab stop, so a Value typo\n * still leaves the grid reachable by Tab and the author can see what they\n * typed. Every consumer of \"which month is on screen\" reads it from here, so\n * the paint and the `monthchange` report cannot name different months.\n */\n #paintedMonthStart(): Date {\n const monthInfo = parseISOMonthString(this.#monthRequest);\n return monthInfo\n ? new Date(monthInfo.year, monthInfo.month - 1, 1)\n : new Date(this.focusedDate.getFullYear(), this.focusedDate.getMonth(), 1);\n }\n\n /**\n * The month the grid is asked to paint: `month`, or while that is empty the\n * month on screen, which `connect()` opens on the month of the published\n * selection, else on the current one.\n */\n get #monthRequest(): string {\n return this.monthValue || this.#paintedMonth;\n }\n\n /**\n * Renders the grid days and updates the month/year label, mirrors both\n * fields, then reports each field the user's move moved and — once connected\n * — a painted month that differs from the last one painted, and a published\n * selection that a change the page made moved.\n *\n * The report belongs to the paint, not to the `month` Value: the Value is only\n * one of the things that decide the month on screen. While a malformed `month`\n * falls back, changing `selected` and selecting a neighbouring month's cell\n * move the painted month too, and both repaint from here. Reading the report\n * off the paint keeps the event naming the month the grid shows, in the\n * `YYYY-MM` the detail contract promises, whichever route repainted.\n *\n * @stimeoRenderRoot\n */\n #render(): void {\n const monthStart = this.#paintedMonthStart();\n const year = monthStart.getFullYear();\n const month = monthStart.getMonth() + 1;\n const selection = this.#selection;\n\n // Update label with localized month/year\n if (this.hasLabelTarget) {\n const locale = resolveLocale(this.element, this.localeValue);\n this.labelTarget.textContent = monthLabelFormatter(locale).format(monthStart);\n }\n\n const days = this.#calculateGridDays(year, month);\n const dayElements = this.dayTargets;\n\n // A consumer's `aria-disabled` belongs to the date its cell shows, so every\n // one is read off before this paint moves any date to another cell. Values\n // this controller wrote carry its marker and are left out.\n const consumerDisabled = new Map<string, string>();\n for (const el of dayElements) {\n const shown = el.getAttribute(\"data-date\");\n const value = el.getAttribute(\"aria-disabled\");\n if (!shown || value === null || el.hasAttribute(this.#ownedDisabled)) continue;\n consumerDisabled.set(shown, value);\n }\n\n // Driven by the dates, so every iteration has one. A short `day` target set\n // is the consumer's markup contradicting the documented 42 cells: paint the\n // ones that exist rather than dropping the grid out of the tab order.\n for (const [index, date] of days.entries()) {\n const el = dayElements[index];\n if (!el) continue;\n\n const dateStr = toISODateString(date);\n // The 42 cells are recycled, so the `aria-disabled` a cell carries describes\n // the date it showed before this paint; left in place, it would disable an\n // unrelated day. A cell that now shows another date drops it, then takes the\n // consumer's value for its new date before the bounds below decide. A date\n // that left the grid has no cell to take its value, so the value is gone.\n if (el.getAttribute(\"data-date\") !== dateStr) {\n el.removeAttribute(\"aria-disabled\");\n el.removeAttribute(this.#ownedDisabled);\n const kept = consumerDisabled.get(dateStr);\n if (kept !== undefined) el.setAttribute(\"aria-disabled\", kept);\n }\n el.setAttribute(\"data-date\", dateStr);\n el.textContent = String(date.getDate());\n\n // outside current month\n const isOutside = date.getFullYear() !== year || date.getMonth() !== month - 1;\n el.setAttribute(\"data-outside\", String(isOutside));\n\n // today\n const todayStr = toISODateString(new Date());\n el.setAttribute(\"data-today\", String(dateStr === todayStr));\n\n // selection state: the day the grid publishes, which a bound can withhold\n el.setAttribute(\"aria-selected\", String(dateStr === selection));\n\n // roving tabindex\n const isFocused = toISODateString(this.focusedDate) === dateStr;\n el.setAttribute(\"tabindex\", isFocused ? \"0\" : \"-1\");\n\n // min/max limits. Only the value this controller wrote comes back off: a\n // consumer marks holidays and booked days with the same attribute, and\n // clearing it on every paint would silently throw their intent away.\n const isDisabled = this.#isDateOutOfBounds(dateStr);\n if (isDisabled) {\n if (!el.hasAttribute(\"aria-disabled\")) el.setAttribute(this.#ownedDisabled, \"\");\n el.setAttribute(\"aria-disabled\", \"true\");\n } else if (el.hasAttribute(this.#ownedDisabled)) {\n el.removeAttribute(\"aria-disabled\");\n el.removeAttribute(this.#ownedDisabled);\n }\n }\n\n // Roving contract: exactly one focusable cell, always. `focusedDate` can sit\n // outside the rendered range — `selected` names a day in another month, and\n // nothing forces the two Values to agree — in which case no cell matched\n // above and the grid would be unreachable by Tab. Fall back to the first day\n // of the shown month so there is always a way in; arrow navigation reads the\n // date off the focused cell, so it continues from wherever the tab stop is.\n if (!dayElements.some((el) => el.getAttribute(\"tabindex\") === \"0\")) {\n const fallback =\n dayElements.find((el) => el.getAttribute(\"data-outside\") === \"false\") ?? dayElements[0];\n fallback?.setAttribute(\"tabindex\", \"0\");\n }\n\n // Post-paint, so a listener that re-marks holidays and booked days sees the\n // cells of the month it is being told about. State is settled — the month,\n // the published selection and both fields — before any report goes out. A\n // listener of one may replace the selection before the next goes out; the\n // newer selection then reports itself, so a field only reports while it\n // holds the value this paint wrote to it.\n const painted = toISOMonthString(monthStart);\n const previous = this.#paintedMonth;\n this.#paintedMonth = painted;\n const reconciled = this.#settleSelection(selection);\n const move = this.#selectionMoves;\n for (const [field, value] of this.#mirrorFields(painted, selection, reconciled)) {\n if (field.value === value) commitField(field);\n }\n // A listener that picked a day in another month has painted and reported\n // that month already.\n if (this.#connected && previous !== painted && this.#paintedMonth === painted) {\n this.dispatch(\"monthchange\", { detail: { month: painted } });\n }\n // A listener of an earlier report that moved the selection on — a\n // `monthchange` listener that picked a day, say — has had that selection\n // reported, so a report of the move this paint found would be stale.\n if (reconciled && move === this.#selectionMoves) {\n this.dispatch(\"reconcile\", { detail: { date: selection } });\n }\n }\n\n /**\n * Records the selection a paint publishes and says whether it moved from the\n * one published before, which a connected grid reports as `reconcile`. A pick\n * records its own day before its paint, so that paint finds no move, and\n * nothing counts before the grid connects. A move counts as a move of the\n * selection.\n */\n #settleSelection(selection: string): boolean {\n const published = this.#published;\n this.#published = selection;\n if (!this.#connected || selection === published) return false;\n this.#selectionMoves += 1;\n return true;\n }\n\n /**\n * Repaints the grid for a Value callback or a pick. The first repaint of a\n * batch records where DOM focus stood on a day, for the settle pass; focus\n * outside the grid is left alone.\n */\n #repaintKeepingFocus(): void {\n if (!this.#focusOrigin) {\n const cell = this.dayTargets.find((day) => day === document.activeElement);\n if (cell) {\n this.#focusOrigin = {\n cell,\n date: cell.getAttribute(\"data-date\"),\n month: this.#paintedMonth,\n };\n this.#settleFocus.schedule();\n }\n }\n this.#render();\n }\n\n /**\n * Puts DOM focus back on a day it can stay on once a batch of repaints has\n * landed.\n *\n * While the painted month stays, a bound only toggles `aria-disabled` and a\n * disabled day stays focusable, so nothing is called (`focus()` would scroll\n * the day into view); `weekStart` moves every date to another cell, so focus\n * follows its date, or goes to the tab stop once the date has left the grid.\n * When the painted month moves, every cell shows another day, and focus goes\n * to the tab stop of the new month. Focus a listener of the paint's events\n * moved off the recorded cell stays where it went.\n */\n #restoreFocus(): void {\n const origin = this.#focusOrigin;\n this.#focusOrigin = null;\n if (!origin || document.activeElement !== origin.cell) return;\n const moved = this.#paintedMonth !== origin.month;\n if (!moved && origin.cell.getAttribute(\"data-date\") === origin.date) return;\n const destination =\n (moved\n ? undefined\n : this.dayTargets.find((cell) => cell.getAttribute(\"data-date\") === origin.date)) ??\n this.dayTargets.find((cell) => cell.getAttribute(\"tabindex\") === \"0\");\n destination?.focus();\n }\n\n /** Fills a selected-day field inserted or replaced at runtime with the published selection. */\n fieldTargetConnected(field: HTMLInputElement): void {\n writeField(field, this.#selection);\n }\n\n /** Fills a painted-month field inserted or replaced at runtime. */\n monthFieldTargetConnected(field: HTMLInputElement): void {\n writeField(field, toISOMonthString(this.#paintedMonthStart()));\n }\n\n /**\n * Mirrors the painted month and the published selection into their optional\n * fields.\n *\n * @param reconciled - Whether a change the page made moved the selection in\n * this paint, which `reconcile` reports rather than the field.\n * @returns Each field this grid's own controls moved, with the value written\n * to it, for the paint to report.\n */\n #mirrorFields(\n painted: string,\n selection: string,\n reconciled: boolean,\n ): [HTMLInputElement, string][] {\n const byUser = this.#movedByUser;\n this.#movedByUser = false;\n const moved: [HTMLInputElement, string][] = [];\n if (this.hasFieldTarget && writeField(this.fieldTarget, selection) && !reconciled) {\n moved.push([this.fieldTarget, selection]);\n }\n if (this.hasMonthFieldTarget && writeField(this.monthFieldTarget, painted)) {\n moved.push([this.monthFieldTarget, painted]);\n }\n return byUser ? moved : [];\n }\n\n selectDayElement(dayElement: HTMLElement): void {\n if (dayElement.getAttribute(\"aria-disabled\") === \"true\") return;\n\n // A day the bounds exclude is refused even before a paint marks its cell,\n // so the pick and the paint that follows give the same answer.\n const dateStr = dayElement.getAttribute(\"data-date\");\n if (!dateStr || this.#isDateOutOfBounds(dateStr)) return;\n\n this.selectedValue = dateStr;\n // Reflect the selection synchronously (move roving focus to the selected day and\n // repaint aria-selected) instead of waiting on the async value observer, so a\n // click or Enter updates the grid in the same tick — consistent with how the\n // navigation handler re-renders directly. `selectedValueChanged` covers\n // external (consumer-driven) value changes.\n const selected = parseISODateString(dateStr);\n if (selected) this.focusedDate = selected;\n this.#movedByUser = true;\n this.#selectionMoves += 1;\n const move = this.#selectionMoves;\n // The pick is the user's move: recorded as published before the paint, so\n // the paint reports it through the field and `select`, never as `reconcile`.\n this.#published = dateStr;\n this.#repaintKeepingFocus();\n // A listener of the paint's reports that picked another day, or made a\n // paint that withheld this one, has had the newer selection reported.\n if (move !== this.#selectionMoves) return;\n this.dispatch(\"select\", { detail: { date: dateStr } });\n }\n\n #focusAndNavigateToDate(date: Date): void {\n this.focusedDate = date;\n const targetMonthStr = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, \"0\")}`;\n\n this.#movedByUser = true;\n if (targetMonthStr !== this.#monthRequest) {\n // Another month: writing the Value runs `monthValueChanged`, which paints\n // that month once and keeps `focusedDate`, since it lies in that month.\n // The date is therefore the tab stop of the new month, and focus, still\n // on the cell the key was pressed on, goes there once that paint has\n // landed. Painting here as well would paint the month twice.\n this.monthValue = targetMonthStr;\n return;\n }\n\n this.#render();\n const dateStr = toISODateString(date);\n this.dayTargets.find((el) => el.getAttribute(\"data-date\") === dateStr)?.focus();\n }\n\n #isDateOutOfBounds(dateStr: string): boolean {\n if (this.minValue && dateStr < this.minValue) return true;\n if (this.maxValue && dateStr > this.maxValue) return true;\n return false;\n }\n\n /** The day `selected` requests: the Value when it names a real day, else `\"\"`. */\n get #requestedDay(): string {\n return parseISODateString(this.selectedValue) ? this.selectedValue : \"\";\n }\n\n /** The selection published for `requested`: the day while `min` / `max` allow it, else `\"\"`. */\n #publishable(requested: string): string {\n return requested && !this.#isDateOutOfBounds(requested) ? requested : \"\";\n }\n\n /** The selection the grid publishes now. */\n get #selection(): string {\n return this.#publishable(this.#requestedDay);\n }\n\n #shiftMonth(delta: number): void {\n const monthInfo = parseISOMonthString(this.#monthRequest);\n if (!monthInfo) return;\n\n this.#movedByUser = true;\n const nextMonthDate = new Date(monthInfo.year, monthInfo.month - 1 + delta, 1);\n this.monthValue = `${nextMonthDate.getFullYear()}-${String(nextMonthDate.getMonth() + 1).padStart(2, \"0\")}`;\n }\n\n #calculateShiftedMonthDate(baseDate: Date, delta: number): Date {\n const targetDate = new Date(baseDate.getFullYear(), baseDate.getMonth() + delta, 1);\n const lastDayInTarget = new Date(\n targetDate.getFullYear(),\n targetDate.getMonth() + 1,\n 0,\n ).getDate();\n const clampedDay = Math.min(baseDate.getDate(), lastDayInTarget);\n targetDate.setDate(clampedDay);\n return targetDate;\n }\n\n #calculateShiftedYearDate(baseDate: Date, delta: number): Date {\n const targetDate = new Date(baseDate.getFullYear() + delta, baseDate.getMonth(), 1);\n const lastDayInTarget = new Date(\n targetDate.getFullYear(),\n targetDate.getMonth() + 1,\n 0,\n ).getDate();\n const clampedDay = Math.min(baseDate.getDate(), lastDayInTarget);\n targetDate.setDate(clampedDay);\n return targetDate;\n }\n\n #getStartOfWeekDate(date: Date): Date {\n const currentDay = date.getDay();\n const shift = (currentDay - this.weekStartValue + 7) % 7;\n const target = new Date(date);\n target.setDate(date.getDate() - shift);\n return target;\n }\n\n #getEndOfWeekDate(date: Date): Date {\n const start = this.#getStartOfWeekDate(date);\n const target = new Date(start);\n target.setDate(start.getDate() + 6);\n return target;\n }\n\n /**\n * Opens the tab stop on the published selection, else on today when the shown\n * month holds it, else on the 1st of the shown month. A selection the grid\n * does not show falls back to the 1st in the paint.\n */\n #initializeFocusedDate(): void {\n const selection = parseISODateString(this.#selection);\n if (selection) {\n this.focusedDate = selection;\n return;\n }\n\n const monthInfo = parseISOMonthString(this.#monthRequest);\n if (monthInfo) {\n const today = new Date();\n if (today.getFullYear() === monthInfo.year && today.getMonth() === monthInfo.month - 1) {\n this.focusedDate = today;\n } else {\n this.focusedDate = new Date(monthInfo.year, monthInfo.month - 1, 1);\n }\n }\n }\n\n #syncFocusedDateWithMonth(): void {\n const monthInfo = parseISOMonthString(this.monthValue);\n if (!monthInfo) return;\n\n // Only align if focusedDate is outside current monthValue\n if (\n this.focusedDate.getFullYear() !== monthInfo.year ||\n this.focusedDate.getMonth() !== monthInfo.month - 1\n ) {\n const today = new Date();\n if (today.getFullYear() === monthInfo.year && today.getMonth() === monthInfo.month - 1) {\n this.focusedDate = today;\n } else {\n // Keep same day if possible, otherwise clamp to end of target month\n const targetDate = new Date(monthInfo.year, monthInfo.month - 1, 1);\n const lastDayInTarget = new Date(monthInfo.year, monthInfo.month, 0).getDate();\n const clampedDay = Math.min(this.focusedDate.getDate(), lastDayInTarget);\n targetDate.setDate(clampedDay);\n this.focusedDate = targetDate;\n }\n }\n }\n\n #calculateGridDays(year: number, month: number): Date[] {\n const firstDay = new Date(year, month - 1, 1);\n const dayOfWeek = firstDay.getDay();\n\n // calculate offset days based on weekStartValue\n const offset = (dayOfWeek - this.weekStartValue + 7) % 7;\n\n const days: Date[] = [];\n const current = new Date(firstDay);\n current.setDate(firstDay.getDate() - offset);\n\n for (let i = 0; i < 42; i++) {\n days.push(new Date(current));\n current.setDate(current.getDate() + 1);\n }\n\n return days;\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/utils/state_reason.ts","../../src/utils/action_source.ts","../../src/utils/logical_scroll.ts","../../src/utils/arrow_step.ts","../../src/utils/intl_format.ts","../../src/utils/dates.ts","../../src/utils/field_mirror.ts","../../src/utils/locale.ts","../../src/utils/microtask_coalescer.ts","../../src/utils/listener_set.ts","../../src/utils/morph_render_watcher.ts","../../src/utils/number_bounds.ts","../../src/utils/coerce.ts","../../src/utils/number_value.ts","../../src/utils/target_selector.ts","../../src/controllers/calendar_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,EAAQ,KAAA,EAAO,MAAA,YAAkB,OAAA,GAAU,MAAM,MAAA,GAAS,IAAA;AAAA,IAC1D,MAAA,EAAQ,eAAe,KAAK;AAAA,GAC9B;AACF;;ACdO,SAAS,MAAM,OAAA,EAA2B;AAC/C,EAAA,OAAO,MAAA,CAAO,gBAAA,CAAiB,OAAO,CAAA,CAAE,SAAA,KAAc,KAAA;AACxD;;AC6CO,SAAS,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,IAAI,IAAA,CAAK,QAAQ,CAAA;AACjC,IAAA,OAAA,CAAQ,OAAA,CAAQ,QAAA,CAAS,OAAA,EAAQ,GAAI,MAAM,CAAA;AAE3C,IAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,EAAA,EAAI,CAAA,EAAA,EAAK;AAC3B,MAAA,IAAA,CAAK,IAAA,CAAK,IAAI,IAAA,CAAK,OAAO,CAAC,CAAA;AAC3B,MAAA,OAAA,CAAQ,OAAA,CAAQ,OAAA,CAAQ,OAAA,EAAQ,GAAI,CAAC,CAAA;AAAA,IACvC;AAEA,IAAA,OAAO,IAAA;AAAA,EACT;AAAA,EAEA,IAAI,cAAA,GAAyB;AAC3B,IAAA,OAAO,KAAK,QAAA,CAAS,IAAA;AAAA,MACnB,IAAA;AAAA,MACA,WAAA;AAAA,MACA,IAAA,CAAK,cAAA;AAAA,MACL,mBAAA,CAAmB,OAAO,SAAA,CAAU,OAAA;AAAA,MACpC,oBAAmB,gBAAA,CAAiB;AAAA,KACtC;AAAA,EACF;AACF","file":"calendar_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","/** Normalized scroll position and maximum distance on one logical axis. */\nexport interface LogicalScrollMetrics {\n position: number;\n max: number;\n}\n\n/**\n * Whether horizontal scrolling on `element` follows right-to-left inline flow.\n *\n * Resolved from the **computed** `direction`, so the authoring contract is the\n * usual `dir=\"rtl\"` (or a stylesheet) on the element or any ancestor.\n *\n * Scope: horizontal writing modes. A vertical writing mode (`writing-mode:\n * vertical-rl`) also inverts the horizontal axis, which this check does not\n * model — vertical writing modes are out of scope for the scroll utilities\n * (their consumers describe axes as horizontal/vertical, not inline/block).\n */\nexport function isRtl(element: Element): boolean {\n return window.getComputedStyle(element).direction === \"rtl\";\n}\n\n/**\n * Returns scroll distance from the logical start edge.\n *\n * CSSOM View exposes standards-mode RTL horizontal offsets as `0` at the inline\n * start (right) and increasingly negative values toward the inline end (left).\n * The normalized position is always clamped to `[0, max]`, which also absorbs\n * Safari's elastic overscroll values.\n */\nexport function logicalScrollMetrics(\n element: HTMLElement,\n horizontal: boolean,\n): LogicalScrollMetrics {\n const max = Math.max(\n 0,\n horizontal\n ? element.scrollWidth - element.clientWidth\n : element.scrollHeight - element.clientHeight,\n );\n const raw = horizontal ? element.scrollLeft : element.scrollTop;\n const position = horizontal && isRtl(element) ? -raw : raw;\n return { position: Math.min(max, Math.max(0, position)), max };\n}\n\n/**\n * Converts a logical start/end delta to the physical value accepted by\n * `Element.scrollBy`.\n */\nexport function physicalScrollDelta(\n element: HTMLElement,\n horizontal: boolean,\n logicalDelta: number,\n): number {\n return horizontal && isRtl(element) ? -logicalDelta : logicalDelta;\n}\n","import { isRtl } from \"./logical_scroll\";\n\n/**\n * Turns an arrow key into a **logical** step: `+1` for \"next\", `-1` for\n * \"previous\", `0` when the key names neither.\n *\n * APG defines the horizontal pair as *next / previous* and says a vertical\n * arrangement swaps in Down/Up for the same meaning — so the pair is one axis's\n * spelling of an order, and the order reverses with the writing direction. Only\n * the horizontal pair reverses. Down/Up name an axis the writing direction does\n * not mirror, and returning them unchanged is the point: many controllers fold\n * both pairs into one branch, where swapping the branches under RTL would flip\n * the vertical axis too — a bug that reads as \"the arrows work\" until someone\n * presses Down.\n *\n * **Direction is read from the element the caller passes, which should be the\n * container that lays the items out** — not the focused child. A child may carry\n * its own `dir` (an LTR input inside an RTL form is ordinary authoring), and\n * probing per handler makes two handlers disagree at the boundary between them.\n *\n * This decides direction only. Whether the axis is even active (an\n * `orientation=\"horizontal\"` widget ignoring Down/Up), how far the step lands,\n * and what wrapping does all stay with the caller.\n *\n * **It encodes the list-order convention: `ArrowDown` is *next*.** Widgets that\n * pair the arrows by *value* instead — `ArrowUp` meaning \"more\", as a rating or a\n * slider does — must not use this, or their vertical axis inverts. Reverse the\n * horizontal pair on its own there.\n *\n * @example\n * ```ts\n * const step = logicalArrowStep(event.key, this.element);\n * if (step === 0) return;\n * this.#roving.setActive(rovingMove(current, length, step, \"wrap\"), { focus: true });\n * ```\n */\nexport function logicalArrowStep(key: string, element: Element): 1 | -1 | 0 {\n if (key === \"ArrowDown\") return 1;\n if (key === \"ArrowUp\") return -1;\n if (key !== \"ArrowRight\" && key !== \"ArrowLeft\") return 0;\n const forward = isRtl(element) ? \"ArrowLeft\" : \"ArrowRight\";\n return key === forward ? 1 : -1;\n}\n\n/**\n * Rewrites `key` so an existing LTR-shaped branch keeps working under RTL:\n * `ArrowRight` and `ArrowLeft` trade places, everything else passes through.\n *\n * The alternative — negating a delta — silently breaks handlers whose two\n * horizontal branches are **not mirror images**. A grid that clamps one edge but\n * not the other, or a segmented field guarding `index > 0` on one side and\n * `index < length - 1` on the other, ends up applying the wrong guard to the\n * wrong direction. Swapping the key leaves each branch, guards and all, exactly\n * where its author put it.\n *\n * Same rule as {@link logicalArrowStep} about which element to read: pass the\n * container that lays the items out, not the focused child.\n *\n * @example\n * ```ts\n * switch (logicalArrowKey(event.key, this.element)) {\n * case \"ArrowLeft\": // \"previous\" — whatever direction that is on screen\n * ```\n */\nexport function logicalArrowKey(key: string, element: Element): string {\n if (key !== \"ArrowRight\" && key !== \"ArrowLeft\") return key;\n if (!isRtl(element)) return key;\n return key === \"ArrowRight\" ? \"ArrowLeft\" : \"ArrowRight\";\n}\n\n/** Modifiers a widget may claim on an arrow key, named for the `allow` list. */\nexport type ArrowModifier = \"alt\" | \"ctrl\" | \"meta\" | \"shift\";\n\n/**\n * True when an arrow key arrived carrying a modifier the widget must leave to\n * the browser: return without calling `preventDefault()` and without moving any\n * state.\n *\n * A bare arrow belongs to the widget; a chorded one usually does not.\n * `Alt`/`Meta` plus a horizontal arrow is history back/forward on every desktop\n * browser, and a widget that swallows it makes the shortcut work or not\n * depending on where focus happens to sit — a coin-flip the user cannot see.\n *\n * `allow` is for the combinations APG assigns to a pattern **and the widget\n * actually implements** — today only Combobox's optional `Alt+Down`/`Alt+Up`.\n * Listing one the widget does not implement defeats the point: the chord then\n * runs the plain-arrow branch, which is exactly what this guard exists to stop.\n * Non-arrow keys return `false`, so chorded letters and\n * `Control+Home`/`Control+End` are untouched.\n *\n * @example\n * ```ts\n * if (isReservedArrowChord(event)) return;\n * ```\n */\nexport function isReservedArrowChord(\n event: KeyboardEvent,\n allow: readonly ArrowModifier[] = [],\n): boolean {\n if (!event.key.startsWith(\"Arrow\")) return false;\n return (\n (event.altKey && !allow.includes(\"alt\")) ||\n (event.ctrlKey && !allow.includes(\"ctrl\")) ||\n (event.metaKey && !allow.includes(\"meta\")) ||\n (event.shiftKey && !allow.includes(\"shift\"))\n );\n}\n\n/**\n * True when a press arrived carrying any modifier, for the keys the browser and\n * the OS own outright: return without calling `preventDefault()` and without\n * moving any state.\n *\n * `Control+Home` and `Control+End` jump the document to its ends, and a widget\n * that swallows them makes the shortcut work or not depending on where focus\n * happens to sit. {@link isReservedArrowChord} answers the same question for the\n * arrows, but returns `false` for every other key so that this one can decide.\n *\n * There is no `allow` list here on purpose. APG assigns no modifier chord to\n * `Home`/`End`, so a widget that wanted one would be claiming a combination the\n * pattern never gave it.\n *\n * @example\n * ```ts\n * case \"Home\":\n * case \"End\":\n * if (hasModifierChord(event)) return;\n * ```\n */\nexport function hasModifierChord(event: KeyboardEvent): boolean {\n return event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;\n}\n","/**\n * Construction of `Intl` formatters for the controllers that take a locale, and\n * the options that go with it, from a declaration.\n *\n * Every `Intl` constructor resolves locale data on the way in, which makes it\n * too costly to rebuild on a hot path, and rejects a malformed language tag,\n * currency code, time zone or digit count with a `RangeError`. Both concerns are\n * handled here once. A formatter is built at most once per distinct request and\n * shared by every caller that asks for the same one. A `RangeError` is caught\n * and answered the way the caller asked: by rebuilding under a fallback locale,\n * or by returning `null` so the caller can leave its authored text alone. Any\n * other failure is a programming fault and propagates.\n */\n\n/** The constructor shape the `Intl` formatter classes share. */\nexport interface IntlFormatterConstructor<F, O extends object> {\n new (locales?: string | string[], options?: O): F;\n}\n\n/** Built formatters, and refusals, per constructor; see `cacheKey` for the key. */\nconst formatters = new WeakMap<object, Map<string, unknown>>();\n\n/**\n * A formatter for `locale` with `options`.\n *\n * With `fallbackLocale`, a `RangeError` from the constructor is answered by\n * building the same options under the fallback instead, so the result is never\n * `null`; the fallback's own failure propagates. Without it, a `RangeError`\n * yields `null` and the caller decides what to show. Errors of any other kind\n * propagate in both forms.\n *\n * Results are cached per constructor and `(locale, options, fallback)`, `null`\n * included, so asking again on every render costs one map lookup.\n */\nexport function intlFormatter<F, O extends object>(\n factory: IntlFormatterConstructor<F, O>,\n locale: string | undefined,\n options: O,\n fallbackLocale: string,\n): F;\nexport function intlFormatter<F, O extends object>(\n factory: IntlFormatterConstructor<F, O>,\n locale: string | undefined,\n options: O,\n): F | null;\nexport function intlFormatter<F, O extends object>(\n factory: IntlFormatterConstructor<F, O>,\n locale: string | undefined,\n options: O,\n fallbackLocale?: string,\n): F | null {\n const cache = cacheFor(factory);\n const key = cacheKey(locale, options, fallbackLocale);\n if (cache.has(key)) return cache.get(key) as F | null;\n const formatter = construct(factory, locale, options, fallbackLocale);\n cache.set(key, formatter);\n return formatter;\n}\n\n/** The cache for one constructor, created on first use. */\nfunction cacheFor(factory: object): Map<string, unknown> {\n const existing = formatters.get(factory);\n if (existing) return existing;\n const created = new Map<string, unknown>();\n formatters.set(factory, created);\n return created;\n}\n\n/**\n * One key per distinct request. `JSON.stringify` drops an option left\n * `undefined`, which is how the constructor reads it too. Two spellings of the\n * same options differing only in key order key separately; that costs one extra\n * formatter, never a wrong one, and call sites pass a fixed literal anyway.\n */\nfunction cacheKey(\n locale: string | undefined,\n options: object,\n fallbackLocale: string | undefined,\n): string {\n return JSON.stringify([locale, options, fallbackLocale]);\n}\n\n/** Builds the formatter under the `RangeError` contract described on `intlFormatter`. */\nfunction construct<F, O extends object>(\n factory: IntlFormatterConstructor<F, O>,\n locale: string | undefined,\n options: O,\n fallbackLocale: string | undefined,\n): F | null {\n try {\n return new factory(locale, options);\n } catch (error) {\n if (!(error instanceof RangeError)) throw error;\n if (fallbackLocale === undefined) return null;\n return new factory(fallbackLocale, options);\n }\n}\n","/**\n * Date helpers shared by the calendar-family controllers\n * (`calendar`, `date-range-picker`): conversions between `Date` and bare ISO\n * strings, and the formatter for the month label a grid displays.\n *\n * The conversions are intentionally **local time** (not UTC): the grid a user\n * sees is built from `Date` components in their own timezone, so round-tripping\n * through ISO strings must use the same frame to avoid off-by-one-day drift near\n * midnight. Strings are bare `YYYY-MM-DD` / `YYYY-MM` with no time or zone.\n */\n\nimport { intlFormatter } from \"./intl_format\";\n\n/** Formats a {@link Date} as a local-time `YYYY-MM-DD` string. */\nexport function toISODateString(date: Date): string {\n const year = date.getFullYear();\n const month = String(date.getMonth() + 1).padStart(2, \"0\");\n const day = String(date.getDate()).padStart(2, \"0\");\n return `${year}-${month}-${day}`;\n}\n\n/**\n * Parses a `YYYY-MM-DD` string into a local-time {@link Date}, or `null`.\n *\n * Rejects calendar-invalid dates (e.g. `2026-02-31`): the constructed `Date`\n * would silently roll over to another day, so the parsed components are checked\n * back against it and a mismatch returns `null`.\n */\nexport function parseISODateString(dateStr: string): Date | null {\n if (!dateStr) return null;\n const match = dateStr.match(/^(\\d{4})-(\\d{2})-(\\d{2})$/);\n if (!match) return null;\n const [, y, m, d] = match;\n const year = Number(y);\n const month = Number(m);\n const day = Number(d);\n const date = new Date(year, month - 1, day);\n if (date.getFullYear() !== year || date.getMonth() !== month - 1 || date.getDate() !== day) {\n return null;\n }\n return date;\n}\n\n/**\n * Parses a `YYYY-MM` string into its year/month (1-based) parts, or `null`.\n * Rejects months outside `1..12`.\n */\nexport function parseISOMonthString(monthStr: string): { year: number; month: number } | null {\n if (!monthStr) return null;\n const match = monthStr.match(/^(\\d{4})-(\\d{2})$/);\n if (!match) return null;\n const [, y, m] = match;\n const month = Number(m);\n if (month < 1 || month > 12) return null;\n return { year: Number(y), month };\n}\n\n/** Formats a {@link Date} as the local-time `YYYY-MM` string of its month. */\nexport function toISOMonthString(date: Date): string {\n return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, \"0\")}`;\n}\n\n/** The long month name and the numeric year, e.g. `May 2026`. */\nconst MONTH_LABEL_OPTIONS: Intl.DateTimeFormatOptions = { month: \"long\", year: \"numeric\" };\n\n/**\n * Creates the formatter for a month label such as `May 2026`: the long month\n * name and the numeric year in `locale`.\n *\n * `locale` is the one the caller resolved, and `undefined` asks for the runtime\n * default. A tag `Intl` rejects (a `RangeError`, e.g. `en_US`) is replaced by\n * `\"en\"`, so a malformed declaration still yields a label and the grid paint\n * that follows it is never skipped. Any other failure of the constructor is a\n * programming fault and propagates.\n */\nexport function monthLabelFormatter(locale: string | undefined): Intl.DateTimeFormat {\n return intlFormatter(Intl.DateTimeFormat, locale, MONTH_LABEL_OPTIONS, \"en\");\n}\n","/**\n * The hidden form fields a widget keeps in step with the state it owns.\n *\n * A widget whose value lives in ARIA attributes submits nothing on its own, so\n * it mirrors that value into `<input type=\"hidden\">` — one field for a single\n * value, a container of generated fields for a set. The mirror is one-way: the\n * widget's own state stays the source of truth and the field is what the form\n * reads.\n *\n * The write and the report are separate calls because they answer to different\n * rules. A mirror is refreshed on connect, after a morph, and whenever the\n * widget repairs itself — none of which a form should treat as an edit. Only\n * the user's own commit reports one, which is why {@link commitField} is never\n * folded into the writes.\n */\n\n/** How a widget's generated fields identify themselves to the form. */\nexport interface GeneratedFieldOptions {\n /** The `name` every generated input submits under. */\n readonly name: string;\n /** The `form` id, for a widget that sits outside the form it submits to. */\n readonly form?: string;\n}\n\n/**\n * Mirrors one value into a hidden field.\n *\n * @returns Whether the field's value moved.\n *\n * @example\n * ```ts\n * if (writeField(this.fieldTarget, String(value)) && userDriven) {\n * commitField(this.fieldTarget);\n * }\n * ```\n */\nexport function writeField(field: HTMLInputElement, value: string): boolean {\n if (field.value === value) return false;\n field.value = value;\n return true;\n}\n\n/**\n * Mirrors a set of values into `container` as generated hidden fields, in the\n * order given.\n *\n * A container that already submits exactly this set is left untouched, children\n * and all — the mirror is refreshed far more often than it moves (every connect,\n * morph and repair), and a rebuild that changes nothing is still a DOM mutation\n * a consumer's observer and a `:empty` rule can see.\n *\n * @returns Whether the submitted set moved — its values, their order, the\n * `name`, or the `form`.\n */\nexport function writeFields(\n container: HTMLElement,\n values: readonly string[],\n { name, form = \"\" }: GeneratedFieldOptions,\n): boolean {\n const current = [...container.children];\n const submits =\n current.length === values.length &&\n current.every(\n (child, index) =>\n child instanceof HTMLInputElement &&\n child.type === \"hidden\" &&\n child.value === values[index] &&\n child.name === name &&\n (child.getAttribute(\"form\") ?? \"\") === form,\n );\n if (submits) return false;\n\n container.replaceChildren(\n ...values.map((value) => {\n const input = document.createElement(\"input\");\n input.type = \"hidden\";\n input.name = name;\n input.value = value;\n if (form !== \"\") input.setAttribute(\"form\", form);\n return input;\n }),\n );\n return true;\n}\n\n/**\n * Reports a committed value from `target` the way a native form control does:\n * one bubbling, non-cancelable `change`.\n *\n * Call it only for a move the user made. Form-level behaviors listen for this —\n * validation re-checks, auto-submit — and a mirror refreshed by a morph or a\n * repair is not something the user submitted.\n *\n * `target` is the element that carries the value: the hidden field for a single\n * mirrored value, the container for a generated set (whose own inputs are\n * replaced on every write), or a widget's own native control where that is what\n * the form reads.\n */\nexport function commitField(target: HTMLElement): void {\n target.dispatchEvent(new Event(\"change\", { bubbles: true }));\n}\n","/**\n * The locale a component formats in: its own declaration, else the language of\n * the text around it, else the runtime default.\n *\n * `lang` is inherited in HTML, so the language that applies to an element is the\n * nearest one on the element itself or on an ancestor — not the document\n * element's, which is only the farthest of them. An empty `lang` there means the\n * language is unknown and stops the inheritance at that point, so it resolves to\n * the runtime default rather than to a `lang` further up.\n *\n * Resolution only, and the value is passed through as authored. Whether `Intl`\n * accepts the tag, and what to show when it does not, is the caller's contract.\n *\n * @example\n * ```ts\n * intlFormatter(Intl.DateTimeFormat, resolveLocale(this.element, this.localeValue), options);\n * ```\n */\nexport function resolveLocale(element: Element, declared = \"\"): string | undefined {\n return declared || element.closest(\"[lang]\")?.getAttribute(\"lang\") || undefined;\n}\n","/**\n * Collapses many Stimulus lifecycle callbacks from one DOM mutation into a\n * single pass.\n *\n * Stimulus fires `<name>TargetConnected` / `Disconnected` once per element and\n * `<name>ValueChanged` once per changed attribute. Replacing a list of N options\n * or morphing several render Values therefore delivers N callbacks — but the\n * useful unit of work is \"reconcile against the resulting declarative input\",\n * once, after the batch has settled. Every controller with reconcilable targets\n * or render Values needs the same shape: a `queued` flag plus `queueMicrotask`.\n *\n * **A microtask is the right horizon, and the reason is specific.** Stimulus\n * drives these callbacks from a `MutationObserver`, whose own callback already\n * runs as a microtask with the whole batch in hand; scheduling one more lands\n * after the last sibling callback of that batch and still before paint or any\n * event handler. A timer would be later than it needs to be, and reconciling\n * synchronously would run once per element against a half-applied DOM.\n *\n * **The two guards are not the same guard.** Scheduling is refused before the\n * controller connects, and running is refused after it disconnects:\n *\n * - **Before `connect()`** — Stimulus delivers initial target and Value callbacks\n * ahead of `connect()`. Reconciling there would compute output against a\n * controller whose own state has not been initialised, and `connect()` is\n * about to do a full pass anyway.\n * - **After `disconnect()`** — Stimulus fires a callback for **every** target\n * during teardown, and a microtask queued just before it would otherwise run\n * against a detached tree. {@link MicrotaskCoalescer.cancel} exists for the\n * teardown path to drop the pending pass outright.\n *\n * Both guards are part of one contract here rather than something each consumer\n * has to remember separately.\n *\n * Scope is the scheduling only. *What* to reconcile — keep the surviving active\n * option, fall back to the next / previous / first visible one, rebuild derived\n * chips or hidden fields — stays in the controller, because no two consumers\n * answer it the same way.\n *\n * @example\n * ```ts\n * readonly #reconcile = new MicrotaskCoalescer(() => this.#reconcileOptions());\n *\n * connect() { this.#reconcile.activate(); }\n * disconnect() { this.#reconcile.cancel(); }\n *\n * optionTargetConnected() { this.#reconcile.schedule(); }\n * optionTargetDisconnected() { this.#reconcile.schedule(); }\n * ```\n */\nexport class MicrotaskCoalescer {\n readonly #run: () => void;\n #queued = false;\n #active = false;\n #generation = 0;\n\n /** @param run - the single reconciliation pass, invoked at most once per batch. */\n constructor(run: () => void) {\n this.#run = run;\n }\n\n /** Opens the window in which {@link schedule} is honoured; call from `connect()`. */\n activate(): void {\n this.#active = true;\n }\n\n /** Closes the window and drops any pending pass; call from `disconnect()`. */\n cancel(): void {\n this.#active = false;\n this.#queued = false;\n this.#generation += 1;\n }\n\n /** Requests one pass after the batch settles. Idempotent; inert outside the window. */\n schedule(): void {\n if (!this.#active || this.#queued) return;\n this.#queued = true;\n const generation = this.#generation;\n queueMicrotask(() => {\n // A cancelled callback must not consume a pass queued after reconnect.\n if (generation !== this.#generation || !this.#queued || !this.#active) return;\n this.#queued = false;\n this.#run();\n });\n }\n}\n","/**\n * 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","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 * 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 { isReservedArrowChord, logicalArrowKey } from \"../utils/arrow_step\";\nimport {\n monthLabelFormatter,\n parseISODateString,\n parseISOMonthString,\n toISODateString,\n toISOMonthString,\n} from \"../utils/dates\";\nimport { commitField, writeField } from \"../utils/field_mirror\";\nimport { resolveLocale } from \"../utils/locale\";\nimport { MicrotaskCoalescer } from \"../utils/microtask_coalescer\";\nimport { MorphRenderWatcher } from \"../utils/morph_render_watcher\";\nimport type { NumberValueConstraints } from \"../utils/number_bounds\";\nimport { NumberValueReader } from \"../utils/number_value\";\nimport { type StateReason, stateReasonFor } from \"../utils/state_reason\";\nimport { targetSelector } from \"../utils/target_selector\";\n\n/**\n * Suffix of the marker on an `aria-disabled` this controller wrote, so a re-paint\n * takes back only its own. A consumer marks holidays and booked days with the same\n * attribute; without the marker a paint would clear their intent.\n *\n * The marker is scoped to the date the cell currently shows, not to the cell: the\n * 42 cells are recycled, so a value that outlived its date would disable a\n * different day. A consumer's value belongs to its date as well: a repaint that\n * moves the date to another cell carries the value along, and a date that leaves\n * the grid loses it. A consumer that marks specific dates applies them once for\n * the month the grid opens on, then again after `stimeo--calendar:monthchange`,\n * which reports a move to a different month.\n */\nconst OWNED_DISABLED = \"owns-disabled\";\n\n/**\n * Headless, highly accessible calendar grid behavior.\n *\n * Markup contract (identifier: `stimeo--calendar`):\n * <div data-controller=\"stimeo--calendar\"\n * data-stimeo--calendar-month-value=\"2026-05\"\n * data-stimeo--calendar-selected-value=\"2026-05-31\">\n * <input type=\"hidden\" name=\"on\" data-stimeo--calendar-target=\"field\" />\n * <input type=\"hidden\" name=\"month\" data-stimeo--calendar-target=\"monthField\" />\n * <button data-action=\"click->stimeo--calendar#prev\">Previous</button>\n * <span data-stimeo--calendar-target=\"label\">May 2026</span>\n * <button data-action=\"click->stimeo--calendar#next\">Next</button>\n * <table role=\"grid\">\n * <tbody data-stimeo--calendar-target=\"grid\"\n * data-action=\"keydown->stimeo--calendar#onKeydown\n * click->stimeo--calendar#select\">\n * <!-- Markup must contain exactly 42 day targets (7 days x 6 rows) -->\n * <tr role=\"row\">\n * <td role=\"gridcell\" data-stimeo--calendar-target=\"day\" tabindex=\"-1\"></td>\n * </tr>\n * </tbody>\n * </table>\n * </div>\n *\n * Implements the WAI-ARIA APG **Date Picker Dialog** grid navigation pattern:\n * - Locale-aware month/year labels using native `Intl.DateTimeFormat`, taken from\n * the `locale` Value, else the nearest `lang` up the ancestor chain, else the\n * runtime default; a malformed language tag falls back to English so the grid\n * still paints.\n * - Without a `month`, the grid opens on the month of the selected day, else on\n * the current month, when an instance first connects, and stays on the month\n * it shows until a month step or the page writes `month` — a later connection\n * of the same instance, after an in-page move or with the identifier added\n * back, keeps it too. Opening on a month writes nothing to `month`.\n * - Roving tabindex focus tracking (exactly one focusable day at any time). The\n * tab stop opens on the selected day, else on today when the shown month\n * holds it, else on the 1st of the shown month; a selected day the grid does\n * not show leaves it on the 1st.\n * - Full grid keyboard controls (arrows, PageUp/Down, Home/End, Shift+PageUp/Down).\n * - Automatic month wrapping and date clamping for missing dates (e.g. leap years, 31st to 30th).\n * - `min`, `max` and `weekStart` changed at runtime repaint the month on screen\n * once connected, and DOM focus in the grid stays on the day it was on while\n * that day is still shown.\n * - A `month` that moves the painted month — written by application code, a\n * morph, or the grid's own month steps — takes DOM focus in the grid to the\n * tab stop of the new month. A key that crosses into another month makes the\n * day it moved to that tab stop, so focus lands there.\n * - An `aria-disabled` the consumer wrote on a day stays with that date while\n * the grid shows it, in whichever cell a repaint moves the date to.\n *\n * `selected` is a request: the grid publishes it as the selection only while\n * `min` / `max` allow that day. A day outside them is neither `aria-selected`\n * nor mirrored into `field`, and it comes back once the bounds allow it again;\n * the Value itself is never rewritten.\n *\n * `monthchange` dispatches `{ month: string }`; `select` dispatches `{ date: string }`.\n * `reconcile` dispatches `{ date: string }` — the selection now published, empty\n * when there is none — once per paint in which a change the page made after\n * connect moved the published selection: `selected` written by application\n * code or a morph, or `min` / `max` withholding the requested day or giving it\n * back. A selection the user picks is reported as `select` alone. Connecting,\n * or connecting again, reports neither `monthchange` nor `reconcile`, whichever\n * month the grid opens on.\n *\n * A pick is measured from the selection last published. Selecting it again\n * reports nothing; a page request still awaiting its paint is included in the\n * user's pick. Listen to cell clicks separately to observe repeated activation.\n *\n * Two optional fields carry the grid's state into a form, so a server can serve\n * the days it is showing: `field` mirrors the published selection (`YYYY-MM-DD`,\n * empty when nothing is selected) and `monthField` the month being painted\n * (`YYYY-MM`). A move the user made — the previous/next controls, a month\n * crossing by keyboard, picking a day — emits a native bubbling `change` from\n * the field that moved, the way a form control does, so `stimeo--auto-submit`\n * and form-level validation hear it. A repaint driven by the Values, by a\n * replacement field, or by the initial paint refreshes both mirrors silently,\n * and so does a move of the selection a change the page made, which `reconcile`\n * reports even in a paint the user's own move asked for.\n *\n * A day `min` / `max` exclude cannot be picked, even before a paint has marked\n * its cell. A pick is painted — `aria-selected` and both fields — before\n * anything reports it: each field that moved, then `monthchange` when the paint\n * moved the month, then `select`. A listener that replaces the selection before\n * these reports are all out — by picking another day, or with a paint in which\n * `min` / `max` withhold this one — has the newer selection report itself, and\n * what is still pending for the replaced pick is not sent.\n *\n * @remarks\n * Behavior only. The controller updates attributes (`aria-selected`, `data-outside`,\n * `tabindex`, …) and text content on the 42 pre-allocated `day` targets.\n */\nexport class CalendarController extends Controller<HTMLElement> {\n /** Numeric read boundaries share one reader for this controller instance. */\n readonly #numbers = new NumberValueReader();\n\n readonly #fieldWrites = new WeakMap<HTMLInputElement, number>();\n\n /** The marker above, in the namespace this controller is registered under. */\n get #ownedDisabled(): string {\n return `data-${this.identifier}-${OWNED_DISABLED}`;\n }\n\n static override targets = [\"label\", \"grid\", \"day\", \"field\", \"monthField\"];\n static override values = {\n month: { type: String, default: \"\" },\n selected: { type: String, default: \"\" },\n min: { type: String, default: \"\" },\n max: { type: String, default: \"\" },\n weekStart: { type: Number, default: 0 }, // 0 = Sunday, 1 = Monday, etc.\n locale: { type: String, default: \"\" },\n };\n\n static valueConstraints = {\n weekStart: { finite: true, integer: true, min: 0, max: 6 },\n } satisfies NumberValueConstraints<typeof CalendarController.values>;\n static actions = [\"next\", \"onKeydown\", \"prev\", \"select\"] as const;\n static events = [\"monthchange\", \"reconcile\", \"select\"] as const;\n\n declare readonly labelTarget: HTMLElement;\n declare readonly gridTarget: HTMLElement;\n declare readonly dayTargets: HTMLElement[];\n declare readonly fieldTarget: HTMLInputElement;\n declare readonly monthFieldTarget: HTMLInputElement;\n declare readonly hasLabelTarget: boolean;\n declare readonly hasGridTarget: boolean;\n declare readonly hasFieldTarget: boolean;\n declare readonly hasMonthFieldTarget: boolean;\n\n declare monthValue: string;\n declare selectedValue: string;\n declare minValue: string;\n declare maxValue: string;\n declare weekStartValue: number;\n declare localeValue: string;\n\n /** The date currently receiving focus in the grid (local time). */\n focusedDate: Date = new Date();\n\n /**\n * Whether `connect()` has run and `disconnect()` has not since. The paints\n * before and during `connect()` describe the grid, so they report nothing.\n */\n #connected = false;\n\n /**\n * The selection the last paint published — a `YYYY-MM-DD` day, or `\"\"` — which\n * the next move of the selection is measured from. A pick records its own day\n * here before painting it.\n */\n #published = \"\";\n\n /**\n * How many times a pick or a change the page made has moved the selection, so\n * a report still pending for a selection a listener has since replaced can tell.\n */\n #selectionMoves = 0;\n\n /**\n * The month the last paint showed (`YYYY-MM`), or `\"\"` before the first paint.\n * Only a connected grid reports a paint that moves it: settling on the initial\n * month — before `connect()` or in it, from the attribute or derived here — is\n * the grid describing itself, not a navigation, so it must not reach a\n * listener that refetches inventory or pushes history.\n *\n * While `month` is empty this is also the month the next paint shows, so the\n * grid stays where it is; the first `connect()` of this instance sets it to the\n * month the grid opens on.\n */\n #paintedMonth = \"\";\n #monthMoves = 0;\n\n /** Last rendered date per cell, used only to recover focus when its date output is absent. */\n readonly #paintedDates = new WeakMap<HTMLElement, string>();\n\n /**\n * Whether this instance has connected before. Only its first connection picks\n * the month a grid with no `month` opens on. A later one keeps the month on\n * screen, and so do the paints Stimulus runs before it.\n */\n #opened = false;\n\n /**\n * Whether the paint about to run was asked for by this grid's own controls.\n * The `month` and `selected` Values are shared with the page — application\n * code and a Turbo morph write them too — so the field mirrors take their\n * \"did the user commit this\" answer from the route, not from the Value.\n */\n #movedByUser = false;\n\n /**\n * Repaints the month on screen after `min`, `max` or `weekStart` changed.\n *\n * A morph that swaps several of them repaints once, and the delivery Stimulus\n * makes before `connect()` is refused, because the grid is painted on\n * connect. None of these Values decides the month on screen; `min` and `max`\n * decide whether the requested day is published.\n */\n readonly #repaint = new MorphRenderWatcher(() => {\n this.#repaintKeepingFocus();\n });\n\n /**\n * The cell DOM focus was on, its day and the month on screen, recorded by the\n * first repaint of a batch for the pass that settles focus after it.\n */\n #focusOrigin: { cell: HTMLElement; date: string | null; month: string } | null = null;\n\n /**\n * Settles DOM focus once, after the last repaint of a batch. The callbacks of\n * one mutation repaint one by one and each reads every Value as it stands, so\n * a `selected` or `locale` callback can paint a month before that month's own\n * callback has moved the tab stop into it. Outside a connection no pass is\n * scheduled, so a grid that is not connected moves no focus.\n */\n readonly #settleFocus = new MicrotaskCoalescer(() => {\n this.#restoreFocus();\n });\n\n override connect(): void {\n this.#repaint.observe(this.element);\n this.#settleFocus.activate();\n // A record a paint left outside the connection has no pass coming.\n this.#focusOrigin = null;\n // No month declared: the first connection opens the grid on the month of the\n // published selection, else on the current one, and a later one keeps the\n // month on screen. The Value stays as the page wrote it.\n if (!this.monthValue && !this.#opened) {\n this.#paintedMonth = toISOMonthString(parseISODateString(this.#selection) ?? new Date());\n }\n this.#opened = true;\n this.#initializeFocusedDate();\n this.#render();\n this.#connected = true;\n }\n\n /**\n * Drops a pending repaint and a pending focus move, and stops reporting, so\n * nothing reaches for a grid that is not connected.\n */\n override disconnect(): void {\n this.#connected = false;\n this.#repaint.disconnect();\n this.#settleFocus.cancel();\n }\n\n /**\n * Paints the month `month` names, whether application code, a morph or the\n * grid's own navigation wrote it; focus in the grid follows to the tab stop.\n */\n monthValueChanged(): void {\n if (!this.monthValue) return;\n this.#syncFocusedDateWithMonth();\n this.#repaintKeepingFocus();\n }\n\n /**\n * Repaints the label when application code changes `locale` at runtime.\n *\n * Stimulus runs this for the initial Value too, before `connect()`. The paint\n * it triggers is idempotent — the month comes from `month` (or, while that is\n * still empty, from `focusedDate`) — and a grid that has not connected\n * reports nothing, so that paint never reports a month.\n */\n localeValueChanged(): void {\n this.#repaintKeepingFocus();\n }\n\n /**\n * Repaints `aria-selected` and the field when the requested day changes, and\n * moves the tab stop to the day the grid now publishes. A request `min` /\n * `max` withhold is not published, so the tab stop stays where it was.\n */\n selectedValueChanged(): void {\n const selection = parseISODateString(this.#selection);\n if (selection) this.focusedDate = selection;\n this.#repaintKeepingFocus();\n }\n\n /** Repaints when `min` changes after connect, so the disabled days and the selection follow. */\n minValueChanged(): void {\n this.#repaint.schedule();\n }\n\n /** Repaints when `max` changes after connect, so the disabled days and the selection follow. */\n maxValueChanged(): void {\n this.#repaint.schedule();\n }\n\n /**\n * Lays the grid out again when `weekStart` changes after connect, so every\n * date moves to the column of its weekday.\n *\n * Only the day cells are painted: column headers are author markup, so the\n * author updates them together with the Value.\n */\n weekStartValueChanged(): void {\n this.#repaint.schedule();\n }\n\n /** Navigates to the previous month. */\n prev(event?: Event): void {\n if (event) event.preventDefault();\n this.#shiftMonth(-1);\n }\n\n /** Navigates to the next month. */\n next(event?: Event): void {\n if (event) event.preventDefault();\n this.#shiftMonth(1);\n }\n\n /** Selects an owned day or a descendant, preserving focus outside the grid. */\n select(source: Event | HTMLElement): void {\n const { origin, reason } = actionSource(source);\n if (origin && origin.closest(`[data-controller~=\"${this.identifier}\"]`) !== this.element)\n return;\n const day = origin?.closest<HTMLElement>(targetSelector(this.identifier, \"day\"));\n if (!day || !this.dayTargets.includes(day)) return;\n this.#selectDay(day, reason);\n }\n\n /** Handles grid cell keyboard navigation and triggers selection. */\n onKeydown(event: KeyboardEvent): void {\n // A widget that already claimed the key (a nested control, an enclosing\n // composite) must not ALSO move the roving focus or select a day.\n if (event.defaultPrevented) return;\n if (isReservedArrowChord(event)) return;\n const dayElement = (event.target as HTMLElement | null)?.closest<HTMLElement>(\n targetSelector(this.identifier, \"day\"),\n );\n if (!dayElement) return;\n\n // A cell the paint never reached carries no `data-date`, and an empty string\n // parses to null — one exit covers both.\n const date = parseISODateString(dayElement.getAttribute(\"data-date\") ?? \"\");\n if (!date) return;\n\n let handled = true;\n let nextDate = new Date(date);\n\n // Logical, not physical. The key is normalised rather than the\n // delta negated: these two branches are not mirror images — their guards\n // differ — so swapping the key keeps each guard with its own direction.\n switch (logicalArrowKey(event.key, this.element)) {\n case \"ArrowLeft\":\n nextDate.setDate(nextDate.getDate() - 1);\n break;\n case \"ArrowRight\":\n nextDate.setDate(nextDate.getDate() + 1);\n break;\n case \"ArrowUp\":\n nextDate.setDate(nextDate.getDate() - 7);\n break;\n case \"ArrowDown\":\n nextDate.setDate(nextDate.getDate() + 7);\n break;\n case \"PageUp\":\n if (event.shiftKey) {\n nextDate = this.#calculateShiftedYearDate(date, -1);\n } else {\n nextDate = this.#calculateShiftedMonthDate(date, -1);\n }\n break;\n case \"PageDown\":\n if (event.shiftKey) {\n nextDate = this.#calculateShiftedYearDate(date, 1);\n } else {\n nextDate = this.#calculateShiftedMonthDate(date, 1);\n }\n break;\n case \"Home\":\n nextDate = this.#getStartOfWeekDate(date);\n break;\n case \"End\":\n nextDate = this.#getEndOfWeekDate(date);\n break;\n case \"t\":\n case \"T\": {\n // A single printable key must not be claimed out of a modifier chord:\n // Ctrl/Cmd/Alt+T belongs to the browser, not to the grid.\n if (event.ctrlKey || event.metaKey || event.altKey) {\n handled = false;\n break;\n }\n const now = new Date();\n nextDate = new Date(now.getFullYear(), now.getMonth(), now.getDate());\n break;\n }\n case \"Enter\":\n case \" \":\n event.preventDefault();\n this.#selectDay(dayElement, stateReasonFor(event));\n return;\n default:\n handled = false;\n break;\n }\n\n if (handled) {\n event.preventDefault();\n this.#focusAndNavigateToDate(nextDate);\n }\n }\n\n /**\n * First day of the month the grid paints: the `month` Value when it parses —\n * while it is empty, the month on screen — otherwise the focused date's month.\n *\n * A malformed `month` falls back instead of stopping the paint: every cell\n * keeps its `aria-selected` and the grid keeps its tab stop, so a Value typo\n * still leaves the grid reachable by Tab and the author can see what they\n * typed. Every consumer of \"which month is on screen\" reads it from here, so\n * the paint and the `monthchange` report cannot name different months.\n */\n #paintedMonthStart(): Date {\n const monthInfo = parseISOMonthString(this.#monthRequest);\n return monthInfo\n ? new Date(monthInfo.year, monthInfo.month - 1, 1)\n : new Date(this.focusedDate.getFullYear(), this.focusedDate.getMonth(), 1);\n }\n\n /**\n * The month the grid is asked to paint: `month`, or while that is empty the\n * month on screen, which `connect()` opens on the month of the published\n * selection, else on the current one.\n */\n get #monthRequest(): string {\n return this.monthValue || this.#paintedMonth;\n }\n\n /**\n * Renders the grid days and updates the month/year label, mirrors both\n * fields, then reports each field the user's move moved and — once connected\n * — a painted month that differs from the last one painted, and a published\n * selection that a change the page made moved.\n *\n * The report belongs to the paint, not to the `month` Value: the Value is only\n * one of the things that decide the month on screen. While a malformed `month`\n * falls back, changing `selected` and selecting a neighbouring month's cell\n * move the painted month too, and both repaint from here. Reading the report\n * off the paint keeps the event naming the month the grid shows, in the\n * `YYYY-MM` the detail contract promises, whichever route repainted.\n *\n * @stimeoRenderRoot\n */\n #render(): void {\n const monthStart = this.#paintedMonthStart();\n const year = monthStart.getFullYear();\n const month = monthStart.getMonth() + 1;\n const selection = this.#selection;\n\n // Update label with localized month/year\n if (this.hasLabelTarget) {\n const locale = resolveLocale(this.element, this.localeValue);\n this.labelTarget.textContent = monthLabelFormatter(locale).format(monthStart);\n }\n\n const days = this.#calculateGridDays(year, month);\n const dayElements = this.dayTargets;\n\n // A consumer's `aria-disabled` belongs to the date its cell shows, so every\n // one is read off before this paint moves any date to another cell. Values\n // this controller wrote carry its marker and are left out.\n const consumerDisabled = new Map<string, string>();\n for (const el of dayElements) {\n const shown = el.getAttribute(\"data-date\");\n const value = el.getAttribute(\"aria-disabled\");\n if (!shown || value === null || el.hasAttribute(this.#ownedDisabled)) continue;\n consumerDisabled.set(shown, value);\n }\n\n // Driven by the dates, so every iteration has one. A short `day` target set\n // is the consumer's markup contradicting the documented 42 cells: paint the\n // ones that exist rather than dropping the grid out of the tab order.\n for (const [index, date] of days.entries()) {\n const el = dayElements[index];\n if (!el) continue;\n\n const dateStr = toISODateString(date);\n // The 42 cells are recycled, so the `aria-disabled` a cell carries describes\n // the date it showed before this paint; left in place, it would disable an\n // unrelated day. A cell that now shows another date drops it, then takes the\n // consumer's value for its new date before the bounds below decide. A date\n // that left the grid has no cell to take its value, so the value is gone.\n if (el.getAttribute(\"data-date\") !== dateStr) {\n el.removeAttribute(\"aria-disabled\");\n el.removeAttribute(this.#ownedDisabled);\n const kept = consumerDisabled.get(dateStr);\n if (kept !== undefined) el.setAttribute(\"aria-disabled\", kept);\n }\n this.#paintedDates.set(el, dateStr);\n el.setAttribute(\"data-date\", dateStr);\n el.textContent = String(date.getDate());\n\n // outside current month\n const isOutside = date.getFullYear() !== year || date.getMonth() !== month - 1;\n el.setAttribute(\"data-outside\", String(isOutside));\n\n // today\n const todayStr = toISODateString(new Date());\n el.setAttribute(\"data-today\", String(dateStr === todayStr));\n\n // selection state: the day the grid publishes, which a bound can withhold\n el.setAttribute(\"aria-selected\", String(dateStr === selection));\n\n // roving tabindex\n const isFocused = toISODateString(this.focusedDate) === dateStr;\n el.setAttribute(\"tabindex\", isFocused ? \"0\" : \"-1\");\n\n // min/max limits. Only the value this controller wrote comes back off: a\n // consumer marks holidays and booked days with the same attribute, and\n // clearing it on every paint would silently throw their intent away.\n const isDisabled = this.#isDateOutOfBounds(dateStr);\n if (isDisabled) {\n if (!el.hasAttribute(\"aria-disabled\")) el.setAttribute(this.#ownedDisabled, \"\");\n el.setAttribute(\"aria-disabled\", \"true\");\n } else if (el.hasAttribute(this.#ownedDisabled)) {\n el.removeAttribute(\"aria-disabled\");\n el.removeAttribute(this.#ownedDisabled);\n }\n }\n\n // Roving contract: exactly one focusable cell, always. `focusedDate` can sit\n // outside the rendered range — `selected` names a day in another month, and\n // nothing forces the two Values to agree — in which case no cell matched\n // above and the grid would be unreachable by Tab. Fall back to the first day\n // of the shown month so there is always a way in; arrow navigation reads the\n // date off the focused cell, so it continues from wherever the tab stop is.\n if (!dayElements.some((el) => el.getAttribute(\"tabindex\") === \"0\")) {\n const fallback =\n dayElements.find((el) => el.getAttribute(\"data-outside\") === \"false\") ?? dayElements[0];\n fallback?.setAttribute(\"tabindex\", \"0\");\n }\n\n // Post-paint, so a listener that re-marks holidays and booked days sees the\n // cells of the month it is being told about. State is settled — the month,\n // the published selection and both fields — before any report goes out. A\n // listener of one may replace the selection before the next goes out; the\n // newer selection then reports itself, so a field only reports while it\n // holds the value this paint wrote to it and no later paint rewrote it.\n const painted = toISOMonthString(monthStart);\n const previous = this.#paintedMonth;\n this.#paintedMonth = painted;\n if (previous !== painted) this.#monthMoves += 1;\n const monthMove = this.#monthMoves;\n const reconciled = this.#settleSelection(selection);\n const move = this.#selectionMoves;\n for (const [field, value, write] of this.#mirrorFields(painted, selection, reconciled)) {\n if (field.value === value && this.#fieldWrites.get(field) === write) commitField(field);\n }\n // A listener that picked a day in another month has painted and reported\n // that month already.\n if (this.#connected && previous !== painted && monthMove === this.#monthMoves) {\n this.dispatch(\"monthchange\", { detail: { month: painted } });\n }\n // A listener of an earlier report that moved the selection on — a\n // `monthchange` listener that picked a day, say — has had that selection\n // reported, so a report of the move this paint found would be stale.\n if (reconciled && move === this.#selectionMoves) {\n this.dispatch(\"reconcile\", { detail: { date: selection } });\n }\n }\n\n /**\n * Records the selection a paint publishes and says whether it moved from the\n * one published before, which a connected grid reports as `reconcile`. A pick\n * records its own day before its paint, so that paint finds no move, and\n * nothing counts before the grid connects. A move counts as a move of the\n * selection.\n */\n #settleSelection(selection: string): boolean {\n const published = this.#published;\n this.#published = selection;\n if (!this.#connected || selection === published) return false;\n this.#selectionMoves += 1;\n return true;\n }\n\n /**\n * Repaints the grid for a Value callback or a pick. The first repaint of a\n * batch records where DOM focus stood on a day, for the settle pass; focus\n * outside the grid is left alone.\n */\n #repaintKeepingFocus(): void {\n if (!this.#focusOrigin) {\n const cell = this.dayTargets.find((day) => day === document.activeElement);\n if (cell) {\n this.#focusOrigin = {\n cell,\n date: cell.getAttribute(\"data-date\") ?? this.#paintedDates.get(cell) ?? null,\n month: this.#paintedMonth,\n };\n this.#settleFocus.schedule();\n }\n }\n this.#render();\n }\n\n /**\n * Puts DOM focus back on a day it can stay on once a batch of repaints has\n * landed.\n *\n * While the painted month stays, a bound only toggles `aria-disabled` and a\n * disabled day stays focusable, so nothing is called (`focus()` would scroll\n * the day into view); `weekStart` moves every date to another cell, so focus\n * follows its date, or goes to the tab stop once the date has left the grid.\n * When the painted month moves, every cell shows another day, and focus goes\n * to the tab stop of the new month. Focus a listener of the paint's events\n * moved off the recorded cell stays where it went.\n */\n #restoreFocus(): void {\n const origin = this.#focusOrigin;\n this.#focusOrigin = null;\n if (!origin || document.activeElement !== origin.cell) return;\n const moved = this.#paintedMonth !== origin.month;\n if (!moved && origin.cell.getAttribute(\"data-date\") === origin.date) return;\n const destination =\n (moved\n ? undefined\n : this.dayTargets.find((cell) => cell.getAttribute(\"data-date\") === origin.date)) ??\n this.dayTargets.find((cell) => cell.getAttribute(\"tabindex\") === \"0\");\n destination?.focus();\n }\n\n /** Repaints so a month label inserted or replaced at runtime names the month on screen. */\n labelTargetConnected(): void {\n this.#repaint.schedule();\n }\n\n /** Repaints so the label that stays when an earlier one leaves names the month on screen. */\n labelTargetDisconnected(): void {\n this.#repaint.schedule();\n }\n\n /** Fills a selected-day field inserted or replaced at runtime with the published selection. */\n fieldTargetConnected(field: HTMLInputElement): void {\n this.#writeField(field, this.#selection);\n }\n\n /** Repaints so the day field that stays when an earlier one leaves holds the selection. */\n fieldTargetDisconnected(): void {\n this.#repaint.schedule();\n }\n\n /** Fills a painted-month field inserted or replaced at runtime. */\n monthFieldTargetConnected(field: HTMLInputElement): void {\n this.#writeField(field, toISOMonthString(this.#paintedMonthStart()));\n }\n\n /** Repaints so the painted-month field that stays when an earlier one leaves holds the month. */\n monthFieldTargetDisconnected(): void {\n this.#repaint.schedule();\n }\n\n /** Records each field write so a later write back to the same value supersedes it. */\n #writeField(field: HTMLInputElement, value: string): boolean {\n if (!writeField(field, value)) return false;\n this.#fieldWrites.set(field, (this.#fieldWrites.get(field) ?? 0) + 1);\n return true;\n }\n\n /**\n * Mirrors the painted month and the published selection into their optional\n * fields.\n *\n * @param reconciled - Whether a change the page made moved the selection in\n * this paint, which `reconcile` reports rather than the field.\n * @returns Each field this grid's own controls moved, with the value written\n * to it, for the paint to report.\n */\n #mirrorFields(\n painted: string,\n selection: string,\n reconciled: boolean,\n ): [HTMLInputElement, string, number][] {\n const byUser = this.#movedByUser;\n this.#movedByUser = false;\n const moved: [HTMLInputElement, string, number][] = [];\n if (this.hasFieldTarget && this.#writeField(this.fieldTarget, selection) && !reconciled) {\n moved.push([this.fieldTarget, selection, this.#fieldWrites.get(this.fieldTarget) ?? 0]);\n }\n if (this.hasMonthFieldTarget && this.#writeField(this.monthFieldTarget, painted)) {\n moved.push([\n this.monthFieldTarget,\n painted,\n this.#fieldWrites.get(this.monthFieldTarget) ?? 0,\n ]);\n }\n return byUser ? moved : [];\n }\n\n /** Commits one selectable day after recording its publication baseline. */\n #selectDay(dayElement: HTMLElement, reason: StateReason): void {\n if (dayElement.getAttribute(\"aria-disabled\") === \"true\") return;\n\n // A day the bounds exclude is refused even before a paint marks its cell,\n // so the pick and the paint that follows give the same answer.\n const dateStr = dayElement.getAttribute(\"data-date\");\n if (!dateStr || this.#isDateOutOfBounds(dateStr)) return;\n\n this.selectedValue = dateStr;\n // Reflect the selection synchronously (move roving focus to the selected day and\n // repaint aria-selected) instead of waiting on the async value observer, so a\n // click or Enter updates the grid in the same tick — consistent with how the\n // navigation handler re-renders directly. `selectedValueChanged` covers\n // external (consumer-driven) value changes.\n const selected = parseISODateString(dateStr);\n if (selected) this.focusedDate = selected;\n this.#movedByUser = true;\n const changed = dateStr !== this.#published;\n if (changed) this.#selectionMoves += 1;\n const move = this.#selectionMoves;\n // The pick is the user's move: recorded as published before the paint, so\n // the paint reports it through the field and `select`, never as `reconcile`.\n this.#published = dateStr;\n this.#repaintKeepingFocus();\n // A listener of the paint's reports that picked another day, or made a\n // paint that withheld this one, has had the newer selection reported.\n if (!changed || move !== this.#selectionMoves) return;\n this.dispatch(\"select\", { detail: { date: dateStr, reason } });\n }\n\n #focusAndNavigateToDate(date: Date): void {\n this.focusedDate = date;\n const targetMonthStr = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, \"0\")}`;\n\n this.#movedByUser = true;\n if (targetMonthStr !== this.#monthRequest) {\n /**\n * A new month paints from the Value callback. A return to the painted\n * month can cancel a pending declaration before that callback observes it,\n * so the current paint and focus move complete synchronously below.\n */\n this.monthValue = targetMonthStr;\n if (targetMonthStr !== this.#paintedMonth) return;\n }\n\n this.#render();\n const dateStr = toISODateString(date);\n this.dayTargets.find((el) => el.getAttribute(\"data-date\") === dateStr)?.focus();\n }\n\n #isDateOutOfBounds(dateStr: string): boolean {\n if (this.minValue && dateStr < this.minValue) return true;\n if (this.maxValue && dateStr > this.maxValue) return true;\n return false;\n }\n\n /** The day `selected` requests: the Value when it names a real day, else `\"\"`. */\n get #requestedDay(): string {\n return parseISODateString(this.selectedValue) ? this.selectedValue : \"\";\n }\n\n /** The selection published for `requested`: the day while `min` / `max` allow it, else `\"\"`. */\n #publishable(requested: string): string {\n return requested && !this.#isDateOutOfBounds(requested) ? requested : \"\";\n }\n\n /** The selection the grid publishes now. */\n get #selection(): string {\n return this.#publishable(this.#requestedDay);\n }\n\n #shiftMonth(delta: number): void {\n const monthInfo = parseISOMonthString(this.#monthRequest);\n if (!monthInfo) return;\n\n this.#movedByUser = true;\n const nextMonthDate = new Date(monthInfo.year, monthInfo.month - 1 + delta, 1);\n this.monthValue = `${nextMonthDate.getFullYear()}-${String(nextMonthDate.getMonth() + 1).padStart(2, \"0\")}`;\n if (this.monthValue === this.#paintedMonth) {\n this.#syncFocusedDateWithMonth();\n this.#repaintKeepingFocus();\n }\n }\n\n #calculateShiftedMonthDate(baseDate: Date, delta: number): Date {\n const targetDate = new Date(baseDate.getFullYear(), baseDate.getMonth() + delta, 1);\n const lastDayInTarget = new Date(\n targetDate.getFullYear(),\n targetDate.getMonth() + 1,\n 0,\n ).getDate();\n const clampedDay = Math.min(baseDate.getDate(), lastDayInTarget);\n targetDate.setDate(clampedDay);\n return targetDate;\n }\n\n #calculateShiftedYearDate(baseDate: Date, delta: number): Date {\n const targetDate = new Date(baseDate.getFullYear() + delta, baseDate.getMonth(), 1);\n const lastDayInTarget = new Date(\n targetDate.getFullYear(),\n targetDate.getMonth() + 1,\n 0,\n ).getDate();\n const clampedDay = Math.min(baseDate.getDate(), lastDayInTarget);\n targetDate.setDate(clampedDay);\n return targetDate;\n }\n\n #getStartOfWeekDate(date: Date): Date {\n const currentDay = date.getDay();\n const shift = (currentDay - this.#safeWeekStart + 7) % 7;\n const target = new Date(date);\n target.setDate(date.getDate() - shift);\n return target;\n }\n\n #getEndOfWeekDate(date: Date): Date {\n const start = this.#getStartOfWeekDate(date);\n const target = new Date(start);\n target.setDate(start.getDate() + 6);\n return target;\n }\n\n /**\n * Opens the tab stop on the published selection, else on today when the shown\n * month holds it, else on the 1st of the shown month. A selection the grid\n * does not show falls back to the 1st in the paint.\n */\n #initializeFocusedDate(): void {\n const selection = parseISODateString(this.#selection);\n if (selection) {\n this.focusedDate = selection;\n return;\n }\n\n const monthInfo = parseISOMonthString(this.#monthRequest);\n if (monthInfo) {\n const today = new Date();\n if (today.getFullYear() === monthInfo.year && today.getMonth() === monthInfo.month - 1) {\n this.focusedDate = today;\n } else {\n this.focusedDate = new Date(monthInfo.year, monthInfo.month - 1, 1);\n }\n }\n }\n\n #syncFocusedDateWithMonth(): void {\n const monthInfo = parseISOMonthString(this.monthValue);\n if (!monthInfo) return;\n\n // Only align if focusedDate is outside current monthValue\n if (\n this.focusedDate.getFullYear() !== monthInfo.year ||\n this.focusedDate.getMonth() !== monthInfo.month - 1\n ) {\n const today = new Date();\n if (today.getFullYear() === monthInfo.year && today.getMonth() === monthInfo.month - 1) {\n this.focusedDate = today;\n } else {\n // Keep same day if possible, otherwise clamp to end of target month\n const targetDate = new Date(monthInfo.year, monthInfo.month - 1, 1);\n const lastDayInTarget = new Date(monthInfo.year, monthInfo.month, 0).getDate();\n const clampedDay = Math.min(this.focusedDate.getDate(), lastDayInTarget);\n targetDate.setDate(clampedDay);\n this.focusedDate = targetDate;\n }\n }\n }\n\n #calculateGridDays(year: number, month: number): Date[] {\n const firstDay = new Date(year, month - 1, 1);\n const dayOfWeek = firstDay.getDay();\n\n // calculate offset days based on weekStartValue\n const offset = (dayOfWeek - this.#safeWeekStart + 7) % 7;\n\n const days: Date[] = [];\n const current = new Date(firstDay);\n current.setDate(firstDay.getDate() - offset);\n\n for (let i = 0; i < 42; i++) {\n days.push(new Date(current));\n current.setDate(current.getDate() + 1);\n }\n\n return days;\n }\n /** Current `weekStart` declaration resolved against its numeric contract. */\n get #safeWeekStart(): number {\n return this.#numbers.read(\n this,\n \"weekStart\",\n this.weekStartValue,\n CalendarController.values.weekStart.default,\n CalendarController.valueConstraints.weekStart,\n );\n }\n}\n"]}
@@ -3,6 +3,10 @@ import { Controller } from '@hotwired/stimulus';
3
3
  /**
4
4
  * Headless, accessible **Carousel** (slideshow) behavior.
5
5
  *
6
+ * Stepping reads the current slide markup and compares with the last published
7
+ * position. Slide and rotation controls settle before notification; synchronous
8
+ * replacement navigation suppresses any older slide confirmation still pending.
9
+ *
6
10
  * Markup contract (identifier: `stimeo--carousel`):
7
11
  * <section data-controller="stimeo--carousel" aria-roledescription="carousel"
8
12
  * aria-label="Featured"
@@ -63,13 +67,12 @@ import { Controller } from '@hotwired/stimulus';
63
67
  * The rotation ends when the controller really leaves — a Turbo navigation, a
64
68
  * removed element, `data-controller` dropping it — and a carousel still in the
65
69
  * document hears that end as `pause`. An in-page move reconnects the same
66
- * instance and keeps the run: no edge, no restarted interval. The leased ARIA
67
- * is returned before Turbo caches the page. Picker arrow keys, `Home`,
68
- * and `End` move focus only (manual activation); slide changes never steal focus
70
+ * instance and keeps the run: no edge, no restarted interval. Picker arrow keys,
71
+ * `Home`, and `End` move focus only (manual activation); slide changes never steal focus
69
72
  * from the control the user operated. A slide change the user drove — including an
70
73
  * autoplay tick they started — is reported as `stimeo--carousel:change` with
71
- * `{ index, total }`; the same detail arrives as `stimeo--carousel:reconcile` when
72
- * the controller re-derives the position itself, whether a target came or went or
74
+ * `{ index, total, reason }`. `stimeo--carousel:reconcile` carries `{ index, total }`
75
+ * when the controller re-derives the position itself, whether a target came or went or
73
76
  * a retained element's state attributes were rewritten in place.
74
77
  */
75
78
  declare class CarouselController extends Controller<HTMLElement> {
@@ -89,11 +92,19 @@ declare class CarouselController extends Controller<HTMLElement> {
89
92
  default: boolean;
90
93
  };
91
94
  };
95
+ static valueConstraints: {
96
+ interval: {
97
+ readonly finite: true;
98
+ readonly exclusiveMin: 0;
99
+ readonly max: 2147483647;
100
+ };
101
+ };
92
102
  static actions: readonly ["goto", "next", "onPickerKeydown", "pause", "prev", "resume", "togglePlay"];
93
103
  static events: readonly ["change", "pause", "play", "reconcile"];
94
104
  readonly slideTargets: HTMLElement[];
95
105
  readonly pickerTargets: HTMLElement[];
96
106
  readonly viewportTarget: HTMLElement;
107
+ readonly viewportTargets: HTMLElement[];
97
108
  readonly hasViewportTarget: boolean;
98
109
  readonly prevTargets: HTMLElement[];
99
110
  readonly nextTargets: HTMLElement[];
@@ -141,6 +152,22 @@ declare class CarouselController extends Controller<HTMLElement> {
141
152
  slideTargetConnected(): void;
142
153
  /** Re-clamps the active index after a slide is removed. */
143
154
  slideTargetDisconnected(): void;
155
+ /** Publishes the live region on a viewport that joins a connected carousel. */
156
+ viewportTargetConnected(): void;
157
+ /**
158
+ * Gives a viewport that no longer resolves its own live region back, even after
159
+ * `disconnect()`, and republishes it on the viewport that stays.
160
+ */
161
+ viewportTargetDisconnected(viewport: HTMLElement): void;
162
+ /**
163
+ * Gives a toggle that no longer resolves as one its label pair, its `aria-disabled` and
164
+ * its `aria-pressed` back, even after `disconnect()`.
165
+ */
166
+ playToggleTargetDisconnected(toggle: HTMLElement): void;
167
+ /** Gives a button that no longer resolves as a `prev` control its `aria-disabled` back. */
168
+ prevTargetDisconnected(button: HTMLElement): void;
169
+ /** Gives a button that no longer resolves as a `next` control its `aria-disabled` back. */
170
+ nextTargetDisconnected(button: HTMLElement): void;
144
171
  /**
145
172
  * Publishes the rotation state on a toggle that joins a connected carousel.
146
173
  *
@@ -172,8 +199,8 @@ declare class CarouselController extends Controller<HTMLElement> {
172
199
  next(event?: Event): void;
173
200
  /** Returns to the previous slide. Delegated; `data-action` wiring is optional. */
174
201
  prev(event?: Event): void;
175
- /** Jumps to the slide whose picker was activated (click / Enter / Space). */
176
- goto(event: Event): void;
202
+ /** Jumps to the slide of an owned picker or descendant, without moving DOM focus. */
203
+ goto(source: Event | HTMLElement): void;
177
204
  /**
178
205
  * Flips the rotation intent the toggle shows, on the user's explicit request.
179
206
  *