stimeo-ui 0.16.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -0
- package/README.md +8 -1
- package/dist/cable/index.d.ts +79 -23
- package/dist/cable/index.js +363 -436
- package/dist/cable/index.js.map +1 -1
- package/dist/controllers/accordion_controller.d.ts +4 -2
- package/dist/controllers/accordion_controller.js +166 -55
- package/dist/controllers/accordion_controller.js.map +1 -1
- package/dist/controllers/alert_dialog_controller.d.ts +12 -2
- package/dist/controllers/alert_dialog_controller.js +862 -221
- package/dist/controllers/alert_dialog_controller.js.map +1 -1
- package/dist/controllers/announcer_controller.d.ts +35 -5
- package/dist/controllers/announcer_controller.js +135 -198
- package/dist/controllers/announcer_controller.js.map +1 -1
- package/dist/controllers/aspect_ratio_controller.js +0 -10
- package/dist/controllers/aspect_ratio_controller.js.map +1 -1
- package/dist/controllers/auto_submit_controller.d.ts +30 -6
- package/dist/controllers/auto_submit_controller.js +271 -127
- package/dist/controllers/auto_submit_controller.js.map +1 -1
- package/dist/controllers/avatar_controller.js +171 -105
- package/dist/controllers/avatar_controller.js.map +1 -1
- package/dist/controllers/breadcrumb_controller.js +0 -130
- package/dist/controllers/breadcrumb_controller.js.map +1 -1
- package/dist/controllers/bulk_select_controller.d.ts +18 -0
- package/dist/controllers/bulk_select_controller.js +262 -52
- package/dist/controllers/bulk_select_controller.js.map +1 -1
- package/dist/controllers/calendar_controller.d.ts +24 -5
- package/dist/controllers/calendar_controller.js +175 -209
- package/dist/controllers/calendar_controller.js.map +1 -1
- package/dist/controllers/carousel_controller.d.ts +34 -7
- package/dist/controllers/carousel_controller.js +461 -399
- package/dist/controllers/carousel_controller.js.map +1 -1
- package/dist/controllers/character_counter_controller.d.ts +17 -1
- package/dist/controllers/character_counter_controller.js +246 -156
- package/dist/controllers/character_counter_controller.js.map +1 -1
- package/dist/controllers/checkbox_controller.d.ts +7 -2
- package/dist/controllers/checkbox_controller.js +32 -74
- package/dist/controllers/checkbox_controller.js.map +1 -1
- package/dist/controllers/clipboard_controller.d.ts +16 -5
- package/dist/controllers/clipboard_controller.js +168 -147
- package/dist/controllers/clipboard_controller.js.map +1 -1
- package/dist/controllers/collapsible_controller.d.ts +16 -4
- package/dist/controllers/collapsible_controller.js +301 -120
- package/dist/controllers/collapsible_controller.js.map +1 -1
- package/dist/controllers/color_picker_controller.d.ts +18 -6
- package/dist/controllers/color_picker_controller.js +149 -139
- package/dist/controllers/color_picker_controller.js.map +1 -1
- package/dist/controllers/combobox_controller.d.ts +23 -5
- package/dist/controllers/combobox_controller.js +360 -133
- package/dist/controllers/combobox_controller.js.map +1 -1
- package/dist/controllers/command_palette_controller.d.ts +45 -14
- package/dist/controllers/command_palette_controller.js +970 -358
- package/dist/controllers/command_palette_controller.js.map +1 -1
- package/dist/controllers/conditional_fields_controller.d.ts +15 -2
- package/dist/controllers/conditional_fields_controller.js +166 -124
- package/dist/controllers/conditional_fields_controller.js.map +1 -1
- package/dist/controllers/confirm_controller.d.ts +49 -12
- package/dist/controllers/confirm_controller.js +939 -248
- package/dist/controllers/confirm_controller.js.map +1 -1
- package/dist/controllers/context_menu_controller.d.ts +31 -4
- package/dist/controllers/context_menu_controller.js +256 -128
- package/dist/controllers/context_menu_controller.js.map +1 -1
- package/dist/controllers/count_up_controller.d.ts +13 -1
- package/dist/controllers/count_up_controller.js +73 -21
- package/dist/controllers/count_up_controller.js.map +1 -1
- package/dist/controllers/countdown_controller.d.ts +45 -1
- package/dist/controllers/countdown_controller.js +183 -148
- package/dist/controllers/countdown_controller.js.map +1 -1
- package/dist/controllers/currency_input_controller.d.ts +21 -2
- package/dist/controllers/currency_input_controller.js +134 -158
- package/dist/controllers/currency_input_controller.js.map +1 -1
- package/dist/controllers/data_grid_controller.d.ts +15 -4
- package/dist/controllers/data_grid_controller.js +114 -186
- package/dist/controllers/data_grid_controller.js.map +1 -1
- package/dist/controllers/date_range_picker_controller.d.ts +30 -5
- package/dist/controllers/date_range_picker_controller.js +288 -206
- package/dist/controllers/date_range_picker_controller.js.map +1 -1
- package/dist/controllers/dialog_controller.d.ts +13 -1
- package/dist/controllers/dialog_controller.js +858 -223
- package/dist/controllers/dialog_controller.js.map +1 -1
- package/dist/controllers/direct_upload_controller.d.ts +24 -7
- package/dist/controllers/direct_upload_controller.js +73 -153
- package/dist/controllers/direct_upload_controller.js.map +1 -1
- package/dist/controllers/dirty_form_controller.js +14 -48
- package/dist/controllers/dirty_form_controller.js.map +1 -1
- package/dist/controllers/dismissible_controller.d.ts +19 -0
- package/dist/controllers/dismissible_controller.js +175 -21
- package/dist/controllers/dismissible_controller.js.map +1 -1
- package/dist/controllers/drawer_controller.d.ts +39 -11
- package/dist/controllers/drawer_controller.js +933 -341
- package/dist/controllers/drawer_controller.js.map +1 -1
- package/dist/controllers/dropdown_controller.d.ts +31 -1
- package/dist/controllers/dropdown_controller.js +312 -82
- package/dist/controllers/dropdown_controller.js.map +1 -1
- package/dist/controllers/editable_controller.d.ts +12 -1
- package/dist/controllers/editable_controller.js +158 -68
- package/dist/controllers/editable_controller.js.map +1 -1
- package/dist/controllers/empty_state_controller.js +67 -53
- package/dist/controllers/empty_state_controller.js.map +1 -1
- package/dist/controllers/file_dropzone_controller.d.ts +60 -18
- package/dist/controllers/file_dropzone_controller.js +311 -207
- package/dist/controllers/file_dropzone_controller.js.map +1 -1
- package/dist/controllers/filter_controller.js +67 -39
- package/dist/controllers/filter_controller.js.map +1 -1
- package/dist/controllers/flash_controller.d.ts +31 -8
- package/dist/controllers/flash_controller.js +172 -314
- package/dist/controllers/flash_controller.js.map +1 -1
- package/dist/controllers/focus_controller.d.ts +12 -3
- package/dist/controllers/focus_controller.js +654 -240
- package/dist/controllers/focus_controller.js.map +1 -1
- package/dist/controllers/form_field_controller.js +147 -132
- package/dist/controllers/form_field_controller.js.map +1 -1
- package/dist/controllers/form_validation_controller.js +13 -86
- package/dist/controllers/form_validation_controller.js.map +1 -1
- package/dist/controllers/frame_loading_controller.d.ts +41 -9
- package/dist/controllers/frame_loading_controller.js +264 -213
- package/dist/controllers/frame_loading_controller.js.map +1 -1
- package/dist/controllers/highlight_controller.d.ts +22 -2
- package/dist/controllers/highlight_controller.js +107 -75
- package/dist/controllers/highlight_controller.js.map +1 -1
- package/dist/controllers/hover_card_controller.d.ts +56 -3
- package/dist/controllers/hover_card_controller.js +309 -118
- package/dist/controllers/hover_card_controller.js.map +1 -1
- package/dist/controllers/idle_controller.d.ts +42 -1
- package/dist/controllers/idle_controller.js +267 -101
- package/dist/controllers/idle_controller.js.map +1 -1
- package/dist/controllers/input_mask_controller.js +71 -72
- package/dist/controllers/input_mask_controller.js.map +1 -1
- package/dist/controllers/intersection_controller.d.ts +32 -13
- package/dist/controllers/intersection_controller.js +147 -106
- package/dist/controllers/intersection_controller.js.map +1 -1
- package/dist/controllers/lazy_frame_controller.d.ts +16 -0
- package/dist/controllers/lazy_frame_controller.js +9 -65
- package/dist/controllers/lazy_frame_controller.js.map +1 -1
- package/dist/controllers/listbox_controller.d.ts +34 -2
- package/dist/controllers/listbox_controller.js +306 -204
- package/dist/controllers/listbox_controller.js.map +1 -1
- package/dist/controllers/local_time_controller.d.ts +1 -1
- package/dist/controllers/local_time_controller.js +54 -64
- package/dist/controllers/local_time_controller.js.map +1 -1
- package/dist/controllers/masonry_controller.d.ts +11 -3
- package/dist/controllers/masonry_controller.js +70 -93
- package/dist/controllers/masonry_controller.js.map +1 -1
- package/dist/controllers/menu_controller.d.ts +32 -7
- package/dist/controllers/menu_controller.js +214 -156
- package/dist/controllers/menu_controller.js.map +1 -1
- package/dist/controllers/menubar_controller.d.ts +4 -4
- package/dist/controllers/menubar_controller.js +170 -329
- package/dist/controllers/menubar_controller.js.map +1 -1
- package/dist/controllers/meter_controller.d.ts +20 -0
- package/dist/controllers/meter_controller.js +151 -67
- package/dist/controllers/meter_controller.js.map +1 -1
- package/dist/controllers/multi_select_controller.d.ts +32 -4
- package/dist/controllers/multi_select_controller.js +593 -358
- package/dist/controllers/multi_select_controller.js.map +1 -1
- package/dist/controllers/navigation_menu_controller.d.ts +8 -1
- package/dist/controllers/navigation_menu_controller.js +124 -232
- package/dist/controllers/navigation_menu_controller.js.map +1 -1
- package/dist/controllers/nested_form_controller.d.ts +10 -0
- package/dist/controllers/nested_form_controller.js +352 -182
- package/dist/controllers/nested_form_controller.js.map +1 -1
- package/dist/controllers/network_status_controller.d.ts +23 -0
- package/dist/controllers/network_status_controller.js +242 -54
- package/dist/controllers/network_status_controller.js.map +1 -1
- package/dist/controllers/number_input_controller.d.ts +26 -2
- package/dist/controllers/number_input_controller.js +320 -263
- package/dist/controllers/number_input_controller.js.map +1 -1
- package/dist/controllers/optimistic_controller.js +16 -76
- package/dist/controllers/optimistic_controller.js.map +1 -1
- package/dist/controllers/otp_controller.d.ts +20 -4
- package/dist/controllers/otp_controller.js +198 -193
- package/dist/controllers/otp_controller.js.map +1 -1
- package/dist/controllers/overflow_indicator_controller.d.ts +5 -0
- package/dist/controllers/overflow_indicator_controller.js +116 -113
- package/dist/controllers/overflow_indicator_controller.js.map +1 -1
- package/dist/controllers/overflow_menu_controller.d.ts +48 -11
- package/dist/controllers/overflow_menu_controller.js +343 -283
- package/dist/controllers/overflow_menu_controller.js.map +1 -1
- package/dist/controllers/pagination_controller.d.ts +35 -6
- package/dist/controllers/pagination_controller.js +295 -119
- package/dist/controllers/pagination_controller.js.map +1 -1
- package/dist/controllers/password_reveal_controller.d.ts +45 -8
- package/dist/controllers/password_reveal_controller.js +389 -121
- package/dist/controllers/password_reveal_controller.js.map +1 -1
- package/dist/controllers/password_strength_controller.d.ts +14 -5
- package/dist/controllers/password_strength_controller.js +99 -153
- package/dist/controllers/password_strength_controller.js.map +1 -1
- package/dist/controllers/persist_controller.d.ts +11 -4
- package/dist/controllers/persist_controller.js +237 -103
- package/dist/controllers/persist_controller.js.map +1 -1
- package/dist/controllers/pointer_drag_controller.d.ts +19 -7
- package/dist/controllers/pointer_drag_controller.js +185 -165
- package/dist/controllers/pointer_drag_controller.js.map +1 -1
- package/dist/controllers/popover_controller.d.ts +38 -2
- package/dist/controllers/popover_controller.js +236 -97
- package/dist/controllers/popover_controller.js.map +1 -1
- package/dist/controllers/portal_controller.d.ts +44 -4
- package/dist/controllers/portal_controller.js +209 -76
- package/dist/controllers/portal_controller.js.map +1 -1
- package/dist/controllers/preview_guard_controller.d.ts +10 -4
- package/dist/controllers/preview_guard_controller.js +232 -116
- package/dist/controllers/preview_guard_controller.js.map +1 -1
- package/dist/controllers/progress_controller.d.ts +11 -0
- package/dist/controllers/progress_controller.js +125 -56
- package/dist/controllers/progress_controller.js.map +1 -1
- package/dist/controllers/radio_group_controller.d.ts +14 -5
- package/dist/controllers/radio_group_controller.js +117 -137
- package/dist/controllers/radio_group_controller.js.map +1 -1
- package/dist/controllers/range_slider_controller.d.ts +43 -3
- package/dist/controllers/range_slider_controller.js +192 -105
- package/dist/controllers/range_slider_controller.js.map +1 -1
- package/dist/controllers/rating_controller.d.ts +20 -4
- package/dist/controllers/rating_controller.js +418 -207
- package/dist/controllers/rating_controller.js.map +1 -1
- package/dist/controllers/read_more_controller.d.ts +2 -0
- package/dist/controllers/read_more_controller.js +134 -63
- package/dist/controllers/read_more_controller.js.map +1 -1
- package/dist/controllers/reading_progress_controller.d.ts +1 -1
- package/dist/controllers/reading_progress_controller.js +147 -135
- package/dist/controllers/reading_progress_controller.js.map +1 -1
- package/dist/controllers/relative_time_controller.d.ts +18 -4
- package/dist/controllers/relative_time_controller.js +145 -110
- package/dist/controllers/relative_time_controller.js.map +1 -1
- package/dist/controllers/reset_on_restore_controller.d.ts +85 -0
- package/dist/controllers/{reset_before_cache_controller.js → reset_on_restore_controller.js} +97 -38
- package/dist/controllers/reset_on_restore_controller.js.map +1 -0
- package/dist/controllers/resizable_controller.d.ts +28 -2
- package/dist/controllers/resizable_controller.js +255 -139
- package/dist/controllers/resizable_controller.js.map +1 -1
- package/dist/controllers/roving_controller.js +39 -84
- package/dist/controllers/roving_controller.js.map +1 -1
- package/dist/controllers/scroll_area_controller.d.ts +7 -3
- package/dist/controllers/scroll_area_controller.js +428 -225
- package/dist/controllers/scroll_area_controller.js.map +1 -1
- package/dist/controllers/scroll_restore_controller.js +0 -53
- package/dist/controllers/scroll_restore_controller.js.map +1 -1
- package/dist/controllers/scroll_visibility_controller.d.ts +28 -12
- package/dist/controllers/scroll_visibility_controller.js +395 -145
- package/dist/controllers/scroll_visibility_controller.js.map +1 -1
- package/dist/controllers/scrollspy_controller.d.ts +6 -1
- package/dist/controllers/scrollspy_controller.js +181 -242
- package/dist/controllers/scrollspy_controller.js.map +1 -1
- package/dist/controllers/separator_controller.d.ts +19 -4
- package/dist/controllers/separator_controller.js +267 -140
- package/dist/controllers/separator_controller.js.map +1 -1
- package/dist/controllers/sidebar_controller.d.ts +64 -7
- package/dist/controllers/sidebar_controller.js +1023 -386
- package/dist/controllers/sidebar_controller.js.map +1 -1
- package/dist/controllers/skeleton_controller.d.ts +23 -0
- package/dist/controllers/skeleton_controller.js +248 -97
- package/dist/controllers/skeleton_controller.js.map +1 -1
- package/dist/controllers/slider_controller.d.ts +27 -1
- package/dist/controllers/slider_controller.js +159 -79
- package/dist/controllers/slider_controller.js.map +1 -1
- package/dist/controllers/smart_sticky_header_controller.d.ts +21 -3
- package/dist/controllers/smart_sticky_header_controller.js +162 -63
- package/dist/controllers/smart_sticky_header_controller.js.map +1 -1
- package/dist/controllers/sortable_controller.js +0 -112
- package/dist/controllers/sortable_controller.js.map +1 -1
- package/dist/controllers/spinner_controller.d.ts +39 -4
- package/dist/controllers/spinner_controller.js +277 -169
- package/dist/controllers/spinner_controller.js.map +1 -1
- package/dist/controllers/step_indicator_controller.d.ts +5 -0
- package/dist/controllers/step_indicator_controller.js +99 -46
- package/dist/controllers/step_indicator_controller.js.map +1 -1
- package/dist/controllers/stepper_controller.d.ts +12 -3
- package/dist/controllers/stepper_controller.js +114 -73
- package/dist/controllers/stepper_controller.js.map +1 -1
- package/dist/controllers/stick_to_bottom_controller.d.ts +6 -0
- package/dist/controllers/stick_to_bottom_controller.js +262 -138
- package/dist/controllers/stick_to_bottom_controller.js.map +1 -1
- package/dist/controllers/sticky_observer_controller.d.ts +11 -0
- package/dist/controllers/sticky_observer_controller.js +214 -49
- package/dist/controllers/sticky_observer_controller.js.map +1 -1
- package/dist/controllers/submit_once_controller.d.ts +23 -8
- package/dist/controllers/submit_once_controller.js +294 -205
- package/dist/controllers/submit_once_controller.js.map +1 -1
- package/dist/controllers/switch_controller.d.ts +12 -1
- package/dist/controllers/switch_controller.js +33 -60
- package/dist/controllers/switch_controller.js.map +1 -1
- package/dist/controllers/tabs_controller.d.ts +2 -2
- package/dist/controllers/tabs_controller.js +35 -29
- package/dist/controllers/tabs_controller.js.map +1 -1
- package/dist/controllers/tags_input_controller.d.ts +12 -0
- package/dist/controllers/tags_input_controller.js +136 -145
- package/dist/controllers/tags_input_controller.js.map +1 -1
- package/dist/controllers/textarea_autosize_controller.d.ts +10 -0
- package/dist/controllers/textarea_autosize_controller.js +71 -58
- package/dist/controllers/textarea_autosize_controller.js.map +1 -1
- package/dist/controllers/theme_controller.d.ts +21 -9
- package/dist/controllers/theme_controller.js +130 -112
- package/dist/controllers/theme_controller.js.map +1 -1
- package/dist/controllers/time_picker_controller.d.ts +18 -1
- package/dist/controllers/time_picker_controller.js +146 -80
- package/dist/controllers/time_picker_controller.js.map +1 -1
- package/dist/controllers/toast_controller.d.ts +36 -11
- package/dist/controllers/toast_controller.js +186 -297
- package/dist/controllers/toast_controller.js.map +1 -1
- package/dist/controllers/toggle_group_controller.d.ts +12 -3
- package/dist/controllers/toggle_group_controller.js +95 -136
- package/dist/controllers/toggle_group_controller.js.map +1 -1
- package/dist/controllers/toolbar_controller.js +68 -98
- package/dist/controllers/toolbar_controller.js.map +1 -1
- package/dist/controllers/tooltip_controller.d.ts +45 -3
- package/dist/controllers/tooltip_controller.js +158 -124
- package/dist/controllers/tooltip_controller.js.map +1 -1
- package/dist/controllers/transition_controller.d.ts +22 -4
- package/dist/controllers/transition_controller.js +123 -119
- package/dist/controllers/transition_controller.js.map +1 -1
- package/dist/controllers/tree_view_controller.d.ts +21 -11
- package/dist/controllers/tree_view_controller.js +150 -345
- package/dist/controllers/tree_view_controller.js.map +1 -1
- package/dist/index.d.ts +8 -5
- package/dist/index.js +6370 -9346
- package/dist/index.js.map +1 -1
- package/dist/inspector/cli.d.ts +23 -3
- package/dist/inspector/cli.js +92 -37
- package/dist/inspector/cli.js.map +1 -1
- package/dist/inspector/cli_bin.js +92 -56
- package/dist/inspector/cli_bin.js.map +1 -1
- package/dist/inspector/examples.json +8 -8
- package/dist/inspector/manifest.json +787 -100
- package/dist/positioning/index.d.ts +8 -0
- package/dist/positioning/index.js +148 -47
- package/dist/positioning/index.js.map +1 -1
- package/package.json +6 -6
- package/dist/controllers/reset_before_cache_controller.d.ts +0 -76
- package/dist/controllers/reset_before_cache_controller.js.map +0 -1
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { Controller } from '@hotwired/stimulus';
|
|
2
2
|
|
|
3
|
-
// src/controllers/sortable_controller.ts
|
|
4
|
-
|
|
5
|
-
// src/utils/announce.ts
|
|
6
3
|
function announce(message, options = {}) {
|
|
7
4
|
const text = message.trim();
|
|
8
5
|
if (text.length === 0) return;
|
|
@@ -19,32 +16,26 @@ function fillTemplate(template, values) {
|
|
|
19
16
|
});
|
|
20
17
|
}
|
|
21
18
|
|
|
22
|
-
// src/utils/logical_scroll.ts
|
|
23
19
|
function isRtl(element) {
|
|
24
20
|
return window.getComputedStyle(element).direction === "rtl";
|
|
25
21
|
}
|
|
26
22
|
|
|
27
|
-
// src/utils/microtask_coalescer.ts
|
|
28
23
|
var MicrotaskCoalescer = class {
|
|
29
24
|
#run;
|
|
30
25
|
#queued = false;
|
|
31
26
|
#active = false;
|
|
32
27
|
#generation = 0;
|
|
33
|
-
/** @param run - the single reconciliation pass, invoked at most once per batch. */
|
|
34
28
|
constructor(run) {
|
|
35
29
|
this.#run = run;
|
|
36
30
|
}
|
|
37
|
-
/** Opens the window in which {@link schedule} is honoured; call from `connect()`. */
|
|
38
31
|
activate() {
|
|
39
32
|
this.#active = true;
|
|
40
33
|
}
|
|
41
|
-
/** Closes the window and drops any pending pass; call from `disconnect()`. */
|
|
42
34
|
cancel() {
|
|
43
35
|
this.#active = false;
|
|
44
36
|
this.#queued = false;
|
|
45
37
|
this.#generation += 1;
|
|
46
38
|
}
|
|
47
|
-
/** Requests one pass after the batch settles. Idempotent; inert outside the window. */
|
|
48
39
|
schedule() {
|
|
49
40
|
if (!this.#active || this.#queued) return;
|
|
50
41
|
this.#queued = true;
|
|
@@ -57,19 +48,16 @@ var MicrotaskCoalescer = class {
|
|
|
57
48
|
}
|
|
58
49
|
};
|
|
59
50
|
|
|
60
|
-
// src/utils/transient_hooks.ts
|
|
61
51
|
var TransientHooks = class {
|
|
62
52
|
#attributes;
|
|
63
53
|
constructor(options) {
|
|
64
54
|
this.#attributes = options.attributes;
|
|
65
55
|
}
|
|
66
|
-
/** Drops the declared hooks from `element`; what it carries besides stays. */
|
|
67
56
|
reset(element) {
|
|
68
57
|
for (const attribute of this.#attributes) element.removeAttribute(attribute);
|
|
69
58
|
}
|
|
70
59
|
};
|
|
71
60
|
|
|
72
|
-
// src/controllers/sortable_controller.ts
|
|
73
61
|
var TRANSIENT = new TransientHooks({ attributes: ["data-sortable-dragging"] });
|
|
74
62
|
var SortableController = class extends Controller {
|
|
75
63
|
static targets = ["list", "item"];
|
|
@@ -82,7 +70,6 @@ var SortableController = class extends Controller {
|
|
|
82
70
|
};
|
|
83
71
|
static events = ["reorder"];
|
|
84
72
|
#session = null;
|
|
85
|
-
/** Defers the lost-item check to after the mutation batch (see below). */
|
|
86
73
|
#settle = new MicrotaskCoalescer(() => this.#dropLostSession());
|
|
87
74
|
connect() {
|
|
88
75
|
TRANSIENT.reset(this.element);
|
|
@@ -101,17 +88,6 @@ var SortableController = class extends Controller {
|
|
|
101
88
|
this.#session = null;
|
|
102
89
|
this.element.removeAttribute("data-sortable-dragging");
|
|
103
90
|
}
|
|
104
|
-
/**
|
|
105
|
-
* Ends a session whose item left the item set.
|
|
106
|
-
*
|
|
107
|
-
* The controller's own reorder detaches and reattaches the item inside one
|
|
108
|
-
* mutation batch, so the loss is only real once the batch has settled — the
|
|
109
|
-
* check therefore runs a microtask later and asks whether the item is a target
|
|
110
|
-
* again. Without it a deleted row (a broadcast that drops it from the board)
|
|
111
|
-
* or a morph that strips the item's target attribute would hold the
|
|
112
|
-
* one-at-a-time session for the rest of the page's life, with the root hook
|
|
113
|
-
* stuck on and every later grab refused with no way out.
|
|
114
|
-
*/
|
|
115
91
|
itemTargetDisconnected(item) {
|
|
116
92
|
if (this.#session?.item !== item) return;
|
|
117
93
|
this.#settle.schedule();
|
|
@@ -125,7 +101,6 @@ var SortableController = class extends Controller {
|
|
|
125
101
|
this.element.removeAttribute("data-sortable-dragging");
|
|
126
102
|
if (session.item.isConnected) this.#restore(session, items);
|
|
127
103
|
}
|
|
128
|
-
/** Picks the item up: remembers its neighbours and announces the grab. */
|
|
129
104
|
#onDragStart = (event) => {
|
|
130
105
|
if (this.#session) return;
|
|
131
106
|
const items = this.#items();
|
|
@@ -153,7 +128,6 @@ var SortableController = class extends Controller {
|
|
|
153
128
|
this.#followPointer(session, detail, items);
|
|
154
129
|
}
|
|
155
130
|
};
|
|
156
|
-
/** Drops the item: announces, then reports `reorder` if the position changed. */
|
|
157
131
|
#onDragEnd = (event) => {
|
|
158
132
|
const session = this.#session;
|
|
159
133
|
if (!session) return;
|
|
@@ -168,7 +142,6 @@ var SortableController = class extends Controller {
|
|
|
168
142
|
this.dispatch("reorder", { detail: { item: session.item, from, to } });
|
|
169
143
|
}
|
|
170
144
|
};
|
|
171
|
-
/** Restores the pickup position (Escape / OS `pointercancel`). */
|
|
172
145
|
#onDragCancel = (event) => {
|
|
173
146
|
const session = this.#session;
|
|
174
147
|
if (!session) return;
|
|
@@ -179,16 +152,6 @@ var SortableController = class extends Controller {
|
|
|
179
152
|
this.#restore(session, items);
|
|
180
153
|
this.#announce("canceled", session.item);
|
|
181
154
|
};
|
|
182
|
-
/**
|
|
183
|
-
* The slot the item was picked up from, read back through the neighbours it
|
|
184
|
-
* had then — `null` when neither survives and the item itself is gone.
|
|
185
|
-
*
|
|
186
|
-
* The anchor is the item that followed it, so restoring means "before that one
|
|
187
|
-
* again". When the anchor was deleted mid-drag the predecessor answers the
|
|
188
|
-
* same question from the other side. With both gone the item's current slot is
|
|
189
|
-
* the honest answer: nothing is known to have moved, so no reorder is reported
|
|
190
|
-
* and a cancel leaves the item where it is.
|
|
191
|
-
*/
|
|
192
155
|
#pickupSlot(session, items) {
|
|
193
156
|
const others = items.filter((candidate) => candidate !== session.item);
|
|
194
157
|
if (session.anchor) {
|
|
@@ -202,7 +165,6 @@ var SortableController = class extends Controller {
|
|
|
202
165
|
const here = items.indexOf(session.item);
|
|
203
166
|
return here === -1 ? null : here;
|
|
204
167
|
}
|
|
205
|
-
/** Puts the item back where it was picked up from. */
|
|
206
168
|
#restore(session, items) {
|
|
207
169
|
const slot = this.#pickupSlot(session, items);
|
|
208
170
|
if (slot === null) return;
|
|
@@ -212,17 +174,6 @@ var SortableController = class extends Controller {
|
|
|
212
174
|
slot
|
|
213
175
|
);
|
|
214
176
|
}
|
|
215
|
-
/**
|
|
216
|
-
* Keyboard stepping: `pointer-drag` reports *cumulative* synthetic deltas, so
|
|
217
|
-
* the difference from the last consumed value is one arrow press — its sign is
|
|
218
|
-
* the direction. Cross-axis arrows never change the primary delta (no move).
|
|
219
|
-
*
|
|
220
|
-
* The sign is physical (`ArrowRight` is always `+dx`), so a right-to-left row
|
|
221
|
-
* has to invert it: there, moving the item rightward means moving it *earlier*
|
|
222
|
-
* in the DOM. Skipping this would also split the two halves of one keypress —
|
|
223
|
-
* `roving` already moves focus logically, so the same arrow would send the
|
|
224
|
-
* focus and the grabbed item opposite ways.
|
|
225
|
-
*/
|
|
226
177
|
#stepFromKeyboard(session, detail, items) {
|
|
227
178
|
const primary = Number(this.#isVertical ? detail.dy : detail.dx) || 0;
|
|
228
179
|
const delta = primary - session.lastPrimary;
|
|
@@ -239,18 +190,6 @@ var SortableController = class extends Controller {
|
|
|
239
190
|
);
|
|
240
191
|
this.#announce("moved", session.item);
|
|
241
192
|
}
|
|
242
|
-
/**
|
|
243
|
-
* Pointer following: the item moves to the slot whose siblings' midpoints the
|
|
244
|
-
* pointer has passed (per `orientation`).
|
|
245
|
-
*
|
|
246
|
-
* Only siblings that occupy space take part. A row with no layout box — a
|
|
247
|
-
* filtered-out item, a `display: none` ancestor, a collapsed `<details>` — is
|
|
248
|
-
* reported with an empty rect at the document origin, and its midpoint of `0`
|
|
249
|
-
* sits below every pointer position: counted, it would read as passed on the
|
|
250
|
-
* very first move and send the item across a slot the pointer never crossed.
|
|
251
|
-
* With no laid-out sibling at all there is nothing to compare against and the
|
|
252
|
-
* move is skipped entirely.
|
|
253
|
-
*/
|
|
254
193
|
#followPointer(session, detail, items) {
|
|
255
194
|
const pointer = Number(this.#isVertical ? detail.y : detail.x) || 0;
|
|
256
195
|
const vertical = this.#isVertical;
|
|
@@ -272,18 +211,6 @@ var SortableController = class extends Controller {
|
|
|
272
211
|
this.#insertAt(session.item, laidOut, target);
|
|
273
212
|
this.#announce("moved", session.item);
|
|
274
213
|
}
|
|
275
|
-
/**
|
|
276
|
-
* Reinserts `item` at `index` among `scope`, relative to the sibling already
|
|
277
|
-
* standing there.
|
|
278
|
-
*
|
|
279
|
-
* The reorder is defined against the items, not against a container: the
|
|
280
|
-
* neighbour's own parent is where the item belongs. A `list` target that is
|
|
281
|
-
* not the items' parent — or none at all, which the markup contract allows —
|
|
282
|
-
* therefore still lands the move in the right place instead of throwing, and
|
|
283
|
-
* the last slot is *after the last item* rather than after whatever else the
|
|
284
|
-
* container holds (a live region, a footer), which would put the row outside
|
|
285
|
-
* the reading order the list publishes.
|
|
286
|
-
*/
|
|
287
214
|
#insertAt(item, scope, index) {
|
|
288
215
|
const clamped = Math.max(0, Math.min(index, scope.length));
|
|
289
216
|
const ahead = scope[clamped] ?? null;
|
|
@@ -297,20 +224,6 @@ var SortableController = class extends Controller {
|
|
|
297
224
|
parent.insertBefore(item, ahead ?? neighbour.nextSibling);
|
|
298
225
|
if (hadFocus) active.focus();
|
|
299
226
|
}
|
|
300
|
-
/**
|
|
301
|
-
* Hands one step to the page's shared announcer.
|
|
302
|
-
*
|
|
303
|
-
* The library carries no live region and no English copy: the wording is the
|
|
304
|
-
* consumer's, written into `announceGrabbedText` / `announceMovedText` /
|
|
305
|
-
* `announceDroppedText` / `announceCanceledText` with `{name}` / `{position}` /
|
|
306
|
-
* `{total}` placeholders, and an unset one announces nothing.
|
|
307
|
-
*
|
|
308
|
-
* Only transitions reach here — the pickup, a step that actually changed the
|
|
309
|
-
* landing slot, and the single end of the session — so a pointer crossing the
|
|
310
|
-
* same slot twice or an arrow clamped at an end stays silent.
|
|
311
|
-
*
|
|
312
|
-
* @stimeoRuntimeOnly The texts word the steps of one reorder, spoken as they happen.
|
|
313
|
-
*/
|
|
314
227
|
#announce(key, item) {
|
|
315
228
|
const template = this.#announceTemplate(key);
|
|
316
229
|
if (template.length === 0) return;
|
|
@@ -323,7 +236,6 @@ var SortableController = class extends Controller {
|
|
|
323
236
|
})
|
|
324
237
|
);
|
|
325
238
|
}
|
|
326
|
-
/** The consumer's wording for one step, or `""` when they authored none. */
|
|
327
239
|
#announceTemplate(key) {
|
|
328
240
|
switch (key) {
|
|
329
241
|
case "grabbed":
|
|
@@ -336,52 +248,28 @@ var SortableController = class extends Controller {
|
|
|
336
248
|
return this.announceCanceledTextValue;
|
|
337
249
|
}
|
|
338
250
|
}
|
|
339
|
-
/** The announced item name: the authored override, else its collapsed text. */
|
|
340
251
|
#nameOf(item) {
|
|
341
252
|
const authored = item.getAttribute(`data-${this.identifier}-name`);
|
|
342
253
|
if (authored) return authored;
|
|
343
254
|
return (item.textContent ?? "").replace(/\s+/g, " ").trim();
|
|
344
255
|
}
|
|
345
|
-
/**
|
|
346
|
-
* Resolves the sortable item owning a bubbled `pointer-drag` event.
|
|
347
|
-
*
|
|
348
|
-
* `pointer-drag` dispatches on its own element, and the markup contract puts
|
|
349
|
-
* one on each item, so the owner is the item that **is** the target. Matching
|
|
350
|
-
* an ancestor instead would make a card's own inner draggable — a knob, a
|
|
351
|
-
* split pane, anything the primitive is composed into — drive the card.
|
|
352
|
-
*/
|
|
353
256
|
#itemFor(target, items) {
|
|
354
257
|
if (!target) return null;
|
|
355
258
|
return items.find((item) => item === target) ?? null;
|
|
356
259
|
}
|
|
357
|
-
/** The items in live DOM order (targets re-query the DOM on every access). */
|
|
358
260
|
#items() {
|
|
359
261
|
return this.itemTargets;
|
|
360
262
|
}
|
|
361
|
-
/** The reorder container: the `list` target when present, else the element. */
|
|
362
263
|
get #list() {
|
|
363
264
|
return this.hasListTarget ? this.listTarget : this.element;
|
|
364
265
|
}
|
|
365
266
|
get #isVertical() {
|
|
366
267
|
return this.orientationValue !== "horizontal";
|
|
367
268
|
}
|
|
368
|
-
/**
|
|
369
|
-
* Whether DOM order runs opposite to the primary coordinate — true only for a
|
|
370
|
-
* horizontal row under `dir="rtl"`, where the first item sits at the largest
|
|
371
|
-
* `x`. Both drag paths reach this controller in physical terms (`pointer-drag`
|
|
372
|
-
* documents its deltas as physical and hands RTL to its consumer, which is
|
|
373
|
-
* this controller), so both have to be mapped back onto DOM order here.
|
|
374
|
-
*
|
|
375
|
-
* Read from the list, the element that lays the items out — never from the
|
|
376
|
-
* dragged item, which may carry its own `dir`. The list inherits the computed
|
|
377
|
-
* direction, so authoring `dir` on the root works too. A vertical list is
|
|
378
|
-
* unaffected: writing direction does not mirror the block axis.
|
|
379
|
-
*/
|
|
380
269
|
get #isReversed() {
|
|
381
270
|
return !this.#isVertical && isRtl(this.#list);
|
|
382
271
|
}
|
|
383
272
|
};
|
|
384
273
|
|
|
385
274
|
export { SortableController };
|
|
386
|
-
//# sourceMappingURL=sortable_controller.js.map
|
|
387
275
|
//# sourceMappingURL=sortable_controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/announce.ts","../../src/utils/logical_scroll.ts","../../src/utils/microtask_coalescer.ts","../../src/utils/transient_hooks.ts","../../src/controllers/sortable_controller.ts"],"names":[],"mappings":";;;;;AAoBO,SAAS,QAAA,CAAS,OAAA,EAAiB,OAAA,GAAmC,EAAC,EAAS;AACrF,EAAA,MAAM,IAAA,GAAO,QAAQ,IAAA,EAAK;AAC1B,EAAA,IAAI,IAAA,CAAK,WAAW,CAAA,EAAG;AACvB,EAAA,MAAA,CAAO,aAAA;AAAA,IACL,IAAI,YAAY,4BAAA,EAA8B;AAAA,MAC5C,QAAQ,EAAE,OAAA,EAAS,MAAM,SAAA,EAAW,OAAA,CAAQ,cAAc,IAAA;AAAK,KAChE;AAAA,GACH;AACF;AAUO,SAAS,YAAA,CAAa,UAAkB,MAAA,EAAiD;AAC9F,EAAA,OAAO,QAAA,CAAS,OAAA,CAAQ,6BAAA,EAA+B,CAAC,OAAO,IAAA,KAAiB;AAC9E,IAAA,MAAM,WAAA,GAAc,OAAO,IAAI,CAAA;AAC/B,IAAA,OAAO,WAAA,KAAgB,MAAA,GAAY,KAAA,GAAQ,MAAA,CAAO,WAAW,CAAA;AAAA,EAC/D,CAAC,CAAA;AACH;;;AC1BO,SAAS,MAAM,OAAA,EAA2B;AAC/C,EAAA,OAAO,MAAA,CAAO,gBAAA,CAAiB,OAAO,CAAA,CAAE,SAAA,KAAc,KAAA;AACxD;;;ACkCO,IAAM,qBAAN,MAAyB;AAAA,EACrB,IAAA;AAAA,EACT,OAAA,GAAU,KAAA;AAAA,EACV,OAAA,GAAU,KAAA;AAAA,EACV,WAAA,GAAc,CAAA;AAAA;AAAA,EAGd,YAAY,GAAA,EAAiB;AAC3B,IAAA,IAAA,CAAK,IAAA,GAAO,GAAA;AAAA,EACd;AAAA;AAAA,EAGA,QAAA,GAAiB;AACf,IAAA,IAAA,CAAK,OAA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,OAAO,IAAA,CAAK,wBAAA;AAAA,MACd,KAAK,UAAA;AACH,QAAA,OAAO,IAAA,CAAK,yBAAA;AAAA;AAChB,EACF;AAAA;AAAA,EAGA,QAAQ,IAAA,EAA2B;AACjC,IAAA,MAAM,WAAW,IAAA,CAAK,YAAA,CAAa,CAAA,KAAA,EAAQ,IAAA,CAAK,UAAU,CAAA,KAAA,CAAO,CAAA;AACjE,IAAA,IAAI,UAAU,OAAO,QAAA;AACrB,IAAA,OAAA,CAAQ,KAAK,WAAA,IAAe,EAAA,EAAI,QAAQ,MAAA,EAAQ,GAAG,EAAE,IAAA,EAAK;AAAA,EAC5D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,QAAA,CAAS,QAA4B,KAAA,EAA0C;AAC7E,IAAA,IAAI,CAAC,QAAQ,OAAO,IAAA;AACpB,IAAA,OAAO,MAAM,IAAA,CAAK,CAAC,IAAA,KAAS,IAAA,KAAS,MAAM,CAAA,IAAK,IAAA;AAAA,EAClD;AAAA;AAAA,EAGA,MAAA,GAAwB;AACtB,IAAA,OAAO,IAAA,CAAK,WAAA;AAAA,EACd;AAAA;AAAA,EAGA,IAAI,KAAA,GAAqB;AACvB,IAAA,OAAO,IAAA,CAAK,aAAA,GAAgB,IAAA,CAAK,UAAA,GAAa,IAAA,CAAK,OAAA;AAAA,EACrD;AAAA,EAEA,IAAI,WAAA,GAAuB;AACzB,IAAA,OAAO,KAAK,gBAAA,KAAqB,YAAA;AAAA,EACnC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcA,IAAI,WAAA,GAAuB;AACzB,IAAA,OAAO,CAAC,IAAA,CAAK,WAAA,IAAe,KAAA,CAAM,KAAK,KAAK,CAAA;AAAA,EAC9C;AACF","file":"sortable_controller.js","sourcesContent":["/**\n * Sends one message to the page's shared `stimeo--announcer`.\n *\n * A component that has to reach assistive tech does not carry a live region of its\n * own: a region only announces what changes *after* assistive tech already knows\n * about it, which a region that appears (or is un-hidden) with its message cannot\n * satisfy. The one region that can is the announcer sitting in the page from the\n * start, so state changes are handed to it as an event and it does the reading.\n *\n * The event goes to `window` because the announcer is usually a sibling high in the\n * document rather than an ancestor of the component dispatching it.\n *\n * Wording comes from the consumer — the library ships no English strings — so an\n * empty message is silently dropped and nothing is announced.\n *\n * @example\n * ```ts\n * announce(this.announceTextValue, { assertive: false });\n * ```\n */\nexport function announce(message: string, options: { assertive?: boolean } = {}): void {\n const text = message.trim();\n if (text.length === 0) return;\n window.dispatchEvent(\n new CustomEvent(\"stimeo--announcer:announce\", {\n detail: { message: text, assertive: options.assertive === true },\n }),\n );\n}\n\n/**\n * Fills `{name}` placeholders in an announcement template from `values`.\n *\n * The same substitution the value-text templates use, so a consumer writes\n * `\"{percent}% complete\"` in one attribute and gets the same rules everywhere. A\n * placeholder with no matching entry is left as authored rather than blanked, which\n * keeps a typo visible instead of silently swallowing the word.\n */\nexport function fillTemplate(template: string, values: Record<string, string | number>): string {\n return template.replace(/\\{([a-zA-Z][a-zA-Z0-9]*)\\}/g, (match, name: string) => {\n const replacement = values[name];\n return replacement === undefined ? match : String(replacement);\n });\n}\n","/** 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","/**\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 * Drops the transient state hooks a connection inherited, so the cycle it opens\n * starts from a DOM that claims nothing.\n *\n * A transient hook is an attribute a controller writes to say \"this is happening\n * right now\" — a drag in progress, a form with unsaved edits, a refused\n * subscription. Its lifetime belongs to the interaction, not to the element, and\n * the two come apart whenever the element outlives the instance that wrote it: a\n * Turbo cache snapshot taken mid-interaction restores the hook with the markup,\n * and an element re-inserted elsewhere in the page carries it along. Nothing\n * takes such a hook off, because the instance that owned it is gone; consumer\n * CSS then keeps claiming a state no one is in.\n *\n * **`turbo:before-cache` cannot do this job**, which is why the pass belongs in\n * `connect()`: that event fires for a navigation only, so an in-page move — the\n * other half of the population — never reaches it, and a hook that arrived with\n * a moved element would survive. `connect()` covers both, because both end in a\n * connection.\n *\n * Scope is the **drop** only. What the fresh cycle should say instead is the\n * consumer's: a value re-read from the live DOM, a roster refilled by the\n * stream, a measurement retaken from the current scroll position, a slot emptied\n * of the last result. Those answers differ per consumer and none of them is a\n * hook removal, so the pass stops where every consumer agrees.\n *\n * A declaration names one group of hooks and carries no per-instance state, so\n * it belongs at module scope, shared by every instance the page connects. A\n * consumer writes as many as it has groups — hooks it drops under different\n * conditions cannot share one. The exception is a hook whose name is only known\n * at runtime, such as one built from the registered identifier: that\n * declaration is a field, because the name is.\n *\n * **A drop is not always right.** The population splits on one question: can the\n * state a hook describes outlive the instance that wrote it? Where it cannot — a\n * drag ends with the pointer, a subscription dies with its socket — dropping on\n * every connection is correct. Where it can — a submission in flight is not\n * interrupted by an in-page move — only a connection that follows a real restore\n * may drop, and the consumer answers \"did a session survive?\" with the signal it\n * already holds for its own teardown (a live-session field, a `DetachGate`\n * probe). The drop then sits behind that answer, as the second example shows.\n *\n * @example Unconditional — the state cannot outlive the instance.\n * ```ts\n * const TRANSIENT = new TransientHooks({ attributes: [\"data-sortable-dragging\"] });\n *\n * connect(): void {\n * TRANSIENT.reset(this.element);\n * }\n * ```\n *\n * @example Gated — an in-page move must not drop a live state.\n * ```ts\n * const TRANSIENT = new TransientHooks({ attributes: [\"data-optimistic\"] });\n *\n * connect(): void {\n * const restored = !this.#connected && !this.#gate.pending;\n * this.#gate.cancel();\n * this.#connected = true;\n * if (restored) TRANSIENT.reset(this.element);\n * }\n * ```\n */\n\n/** What a consumer declares once about the hooks its interaction owns. */\nexport interface TransientHooksOptions {\n /**\n * The attribute names a connection may find written by an earlier one. Hooks\n * a consumer drops under different conditions belong to different\n * declarations, so each one can be reset on its own.\n */\n readonly attributes: readonly string[];\n}\n\n/**\n * One consumer's declaration of the hooks its interaction owns, dropped from an\n * element by {@link TransientHooks.reset}.\n *\n * Every member comment inside this class body is inlined into each consumer\n * bundle (`tsup` builds with `splitting: false`), so rationale belongs in this\n * file's own block, which `dist` drops, and only the contract belongs inside.\n */\nexport class TransientHooks {\n readonly #attributes: readonly string[];\n\n constructor(options: TransientHooksOptions) {\n this.#attributes = options.attributes;\n }\n\n /** Drops the declared hooks from `element`; what it carries besides stays. */\n reset(element: Element): void {\n for (const attribute of this.#attributes) element.removeAttribute(attribute);\n }\n}\n","import { Controller } from \"@hotwired/stimulus\";\nimport { announce, fillTemplate } from \"../utils/announce\";\nimport { isRtl } from \"../utils/logical_scroll\";\nimport { MicrotaskCoalescer } from \"../utils/microtask_coalescer\";\nimport { TransientHooks } from \"../utils/transient_hooks\";\n\n/** The hook a connection may find written by an earlier, now-gone one. */\nconst TRANSIENT = new TransientHooks({ attributes: [\"data-sortable-dragging\"] });\n\n/** The four steps a consumer can give wording to. */\ntype AnnounceKey = \"grabbed\" | \"moved\" | \"dropped\" | \"canceled\";\n\n/** A reorder in flight: one item picked up by pointer or keyboard. */\ninterface SortSession {\n item: HTMLElement;\n /**\n * The item that followed it at pickup, and the one that preceded it.\n *\n * The pickup slot is remembered as nodes rather than as an index because the\n * list can change underneath a live drag — a broadcast board inserts and\n * deletes rows while someone is holding one — and an index taken at pickup\n * stops pointing at that place the moment a row appears above it.\n */\n anchor: HTMLElement | null;\n predecessor: HTMLElement | null;\n /** Last primary-axis cumulative delta consumed by keyboard stepping. */\n lastPrimary: number;\n}\n\n/**\n * Headless, accessible **sortable** (single-list reorder) — the a11y-first\n * drag-and-drop that is the flagship consumer of the\n * `stimeo--pointer-drag` primitive. The composition is markup-level and each\n * layer keeps its job: `pointer-drag` (on every item) emits the normalized drag\n * signal with its built-in keyboard alternative, `roving` (on the list) keeps\n * the handles a single Tab stop, and this controller interprets the signal —\n * live-reordering the DOM, handing each step to the page's shared announcer,\n * and reporting the final `reorder`. No dedicated APG pattern exists for\n * drag-and-drop; the keyboard model (grab → arrows → drop / Escape) comes from\n * `pointer-drag` and the announcements make it non-visually trackable\n * (WCAG 2.1.1 / 2.5.7 / 4.1.3). Core (zero dependencies).\n *\n * Markup contract (identifier: `stimeo--sortable`):\n * <div data-controller=\"stimeo--sortable\">\n * <ul data-stimeo--sortable-target=\"list\" data-controller=\"stimeo--roving\"\n * data-stimeo--roving-orientation-value=\"vertical\">\n * <li data-stimeo--sortable-target=\"item\" data-stimeo--sortable-name=\"Card A\"\n * data-controller=\"stimeo--pointer-drag\"\n * data-stimeo--pointer-drag-axis-value=\"y\">\n * <span>Card A</span>\n * <button type=\"button\" aria-label=\"Reorder Card A\"\n * data-stimeo--pointer-drag-target=\"handle\"\n * data-stimeo--roving-target=\"item\">⠿</button>\n * </li>\n * …\n * </ul>\n * </div>\n *\n * The composed values must follow the sort axis: roving's `orientation`\n * (which defaults to `horizontal`, so a vertical list has to author\n * `vertical`) and pointer-drag's `axis`. `stimeo check` enforces both\n * alignments as composition rules (`composition-mismatch`).\n *\n * Pointer flow: dragging an item live-moves it whenever the pointer crosses a\n * sibling's midpoint (per `orientation`). Keyboard flow: each synthetic\n * `pointer-drag` move steps the item one position. A horizontal list under\n * `dir=\"rtl\"` reverses both, since DOM order then runs right-to-left while\n * `pointer-drag` reports physical coordinates. Dropping dispatches\n * `reorder` (`{ item, from, to }`, zero-based) when the position changed;\n * Escape / `pointercancel` restores the pickup position. Every step is handed to\n * the page's shared `stimeo--announcer` as the consumer's own wording —\n * `announceGrabbedText` / `announceMovedText` / `announceDroppedText` /\n * `announceCanceledText`, with `{name}` / `{position}` / `{total}` placeholders —\n * and an unset one announces nothing.\n *\n * @remarks\n * Behavior only — the ghost/placeholder/drop-hint visuals are the consumer's\n * CSS, keyed off `pointer-drag`'s `data-dragging`/`data-grabbed` on the item\n * and this controller's `data-sortable-dragging` on the root. Persistence is\n * the consumer's `reorder` listener (post the new position; a Turbo Stream\n * broadcast makes the board collaborative). The DOM order is the single source\n * of truth: items are read live on every event, so rows appended by Turbo need\n * no rewiring, and a Turbo cache restore reconnects idempotently (`connect()`\n * clears the transient root hook; a drag cannot survive a navigation). Only the\n * event listeners are held, and they are removed on `disconnect()`. Multi-list\n * / kanban, nested DnD, auto-scroll at the edges, and virtualized lists are\n * deliberately out of this single-list scope.\n */\nexport class SortableController extends Controller<HTMLElement> {\n static override targets = [\"list\", \"item\"];\n static override values = {\n orientation: { type: String, default: \"vertical\" },\n announceGrabbedText: { type: String, default: \"\" },\n announceMovedText: { type: String, default: \"\" },\n announceDroppedText: { type: String, default: \"\" },\n announceCanceledText: { type: String, default: \"\" },\n };\n static events = [\"reorder\"] as const;\n\n declare readonly hasListTarget: boolean;\n declare readonly listTarget: HTMLElement;\n declare readonly itemTargets: HTMLElement[];\n declare orientationValue: string;\n declare announceGrabbedTextValue: string;\n declare announceMovedTextValue: string;\n declare announceDroppedTextValue: string;\n declare announceCanceledTextValue: string;\n\n #session: SortSession | null = null;\n /** Defers the lost-item check to after the mutation batch (see below). */\n readonly #settle = new MicrotaskCoalescer(() => this.#dropLostSession());\n\n override connect(): void {\n // A drag cannot survive a navigation: drop the hook a Turbo cache snapshot\n // may have preserved mid-drag (idempotent reconnect).\n TRANSIENT.reset(this.element);\n this.#settle.activate();\n this.element.addEventListener(\"stimeo--pointer-drag:start\", this.#onDragStart);\n this.element.addEventListener(\"stimeo--pointer-drag:move\", this.#onDragMove);\n this.element.addEventListener(\"stimeo--pointer-drag:end\", this.#onDragEnd);\n this.element.addEventListener(\"stimeo--pointer-drag:cancel\", this.#onDragCancel);\n }\n\n override disconnect(): void {\n this.element.removeEventListener(\"stimeo--pointer-drag:start\", this.#onDragStart);\n this.element.removeEventListener(\"stimeo--pointer-drag:move\", this.#onDragMove);\n this.element.removeEventListener(\"stimeo--pointer-drag:end\", this.#onDragEnd);\n this.element.removeEventListener(\"stimeo--pointer-drag:cancel\", this.#onDragCancel);\n this.#settle.cancel();\n this.#session = null;\n this.element.removeAttribute(\"data-sortable-dragging\");\n }\n\n /**\n * Ends a session whose item left the item set.\n *\n * The controller's own reorder detaches and reattaches the item inside one\n * mutation batch, so the loss is only real once the batch has settled — the\n * check therefore runs a microtask later and asks whether the item is a target\n * again. Without it a deleted row (a broadcast that drops it from the board)\n * or a morph that strips the item's target attribute would hold the\n * one-at-a-time session for the rest of the page's life, with the root hook\n * stuck on and every later grab refused with no way out.\n */\n itemTargetDisconnected(item: HTMLElement): void {\n if (this.#session?.item !== item) return;\n this.#settle.schedule();\n }\n\n #dropLostSession(): void {\n const session = this.#session;\n if (!session) return;\n const items = this.#items();\n if (items.includes(session.item)) return;\n this.#session = null;\n this.element.removeAttribute(\"data-sortable-dragging\");\n // An element that is still in the document (a morph took only its target\n // attribute) goes back where it was picked up. Nothing is announced either\n // way: the row is no longer one of the items, so there is no position to\n // read out — what matters is that the next grab is not refused.\n if (session.item.isConnected) this.#restore(session, items);\n }\n\n /** Picks the item up: remembers its neighbours and announces the grab. */\n readonly #onDragStart = (event: Event): void => {\n // One reorder at a time: a start from another item (each item has its own\n // pointer-drag instance) must not clobber the live session — its pickup\n // slot and cancel restore would be lost.\n if (this.#session) return;\n const items = this.#items();\n const item = this.#itemFor(event.target, items);\n if (!item) return;\n const index = items.indexOf(item);\n this.#session = {\n item,\n anchor: items[index + 1] ?? null,\n predecessor: items[index - 1] ?? null,\n lastPrimary: 0,\n };\n this.element.setAttribute(\"data-sortable-dragging\", \"true\");\n this.#announce(\"grabbed\", item);\n };\n\n readonly #onDragMove = (event: Event): void => {\n const session = this.#session;\n if (!session) return;\n const items = this.#items();\n if (this.#itemFor(event.target, items) !== session.item) return;\n\n const detail = (event as CustomEvent<Record<string, number | string>>).detail;\n if (detail.pointerType === \"keyboard\") {\n this.#stepFromKeyboard(session, detail, items);\n } else {\n this.#followPointer(session, detail, items);\n }\n };\n\n /** Drops the item: announces, then reports `reorder` if the position changed. */\n readonly #onDragEnd = (event: Event): void => {\n const session = this.#session;\n if (!session) return;\n const items = this.#items();\n if (this.#itemFor(event.target, items) !== session.item) return;\n this.#session = null;\n this.element.removeAttribute(\"data-sortable-dragging\");\n this.#announce(\"dropped\", session.item);\n const to = items.indexOf(session.item);\n const from = this.#pickupSlot(session, items) ?? to;\n if (to !== from) {\n this.dispatch(\"reorder\", { detail: { item: session.item, from, to } });\n }\n };\n\n /** Restores the pickup position (Escape / OS `pointercancel`). */\n readonly #onDragCancel = (event: Event): void => {\n const session = this.#session;\n if (!session) return;\n const items = this.#items();\n if (this.#itemFor(event.target, items) !== session.item) return;\n this.#session = null;\n this.element.removeAttribute(\"data-sortable-dragging\");\n this.#restore(session, items);\n this.#announce(\"canceled\", session.item);\n };\n\n /**\n * The slot the item was picked up from, read back through the neighbours it\n * had then — `null` when neither survives and the item itself is gone.\n *\n * The anchor is the item that followed it, so restoring means \"before that one\n * again\". When the anchor was deleted mid-drag the predecessor answers the\n * same question from the other side. With both gone the item's current slot is\n * the honest answer: nothing is known to have moved, so no reorder is reported\n * and a cancel leaves the item where it is.\n */\n #pickupSlot(session: SortSession, items: HTMLElement[]): number | null {\n const others = items.filter((candidate) => candidate !== session.item);\n if (session.anchor) {\n const at = others.indexOf(session.anchor);\n if (at !== -1) return at;\n }\n if (session.predecessor) {\n const at = others.indexOf(session.predecessor);\n if (at !== -1) return at + 1;\n }\n const here = items.indexOf(session.item);\n return here === -1 ? null : here;\n }\n\n /** Puts the item back where it was picked up from. */\n #restore(session: SortSession, items: HTMLElement[]): void {\n const slot = this.#pickupSlot(session, items);\n if (slot === null) return;\n this.#insertAt(\n session.item,\n items.filter((candidate) => candidate !== session.item),\n slot,\n );\n }\n\n /**\n * Keyboard stepping: `pointer-drag` reports *cumulative* synthetic deltas, so\n * the difference from the last consumed value is one arrow press — its sign is\n * the direction. Cross-axis arrows never change the primary delta (no move).\n *\n * The sign is physical (`ArrowRight` is always `+dx`), so a right-to-left row\n * has to invert it: there, moving the item rightward means moving it *earlier*\n * in the DOM. Skipping this would also split the two halves of one keypress —\n * `roving` already moves focus logically, so the same arrow would send the\n * focus and the grabbed item opposite ways.\n */\n #stepFromKeyboard(\n session: SortSession,\n detail: Record<string, number | string>,\n items: HTMLElement[],\n ): void {\n const primary = Number(this.#isVertical ? detail.dy : detail.dx) || 0;\n const delta = primary - session.lastPrimary;\n session.lastPrimary = primary;\n if (delta === 0) return;\n\n const index = items.indexOf(session.item);\n const step = (delta > 0 ? 1 : -1) * (this.#isReversed ? -1 : 1);\n const next = Math.max(0, Math.min(index + step, items.length - 1));\n if (next === index) return;\n this.#insertAt(\n session.item,\n items.filter((candidate) => candidate !== session.item),\n next,\n );\n this.#announce(\"moved\", session.item);\n }\n\n /**\n * Pointer following: the item moves to the slot whose siblings' midpoints the\n * pointer has passed (per `orientation`).\n *\n * Only siblings that occupy space take part. A row with no layout box — a\n * filtered-out item, a `display: none` ancestor, a collapsed `<details>` — is\n * reported with an empty rect at the document origin, and its midpoint of `0`\n * sits below every pointer position: counted, it would read as passed on the\n * very first move and send the item across a slot the pointer never crossed.\n * With no laid-out sibling at all there is nothing to compare against and the\n * move is skipped entirely.\n */\n #followPointer(\n session: SortSession,\n detail: Record<string, number | string>,\n items: HTMLElement[],\n ): void {\n const pointer = Number(this.#isVertical ? detail.y : detail.x) || 0;\n const vertical = this.#isVertical;\n // `target` counts the siblings that precede the pointer *in DOM order*, and\n // the two agree only while DOM order runs the same way as the coordinate. In\n // a right-to-left row it runs the other way, so the comparison flips;\n // leaving it physical would mix two orderings into one number and drop the\n // item at a slot the pointer never crossed. Resolved once: it cannot change\n // mid-loop, and reading it per sibling would re-run `getComputedStyle` on\n // every pointermove.\n const reversed = this.#isReversed;\n const here = items.indexOf(session.item);\n const laidOut: HTMLElement[] = [];\n let target = 0;\n // `current` is the item's own slot in that same laid-out space: the number\n // of laid-out siblings that come before it in DOM order.\n let current = 0;\n items.forEach((item, index) => {\n if (item === session.item) return;\n const rect = item.getBoundingClientRect();\n if (rect.width === 0 && rect.height === 0) return;\n if (index < here) current += 1;\n laidOut.push(item);\n const midpoint = vertical ? rect.top + rect.height / 2 : rect.left + rect.width / 2;\n if (reversed ? pointer < midpoint : pointer > midpoint) target += 1;\n });\n if (laidOut.length === 0 || target === current) return;\n\n this.#insertAt(session.item, laidOut, target);\n this.#announce(\"moved\", session.item);\n }\n\n /**\n * Reinserts `item` at `index` among `scope`, relative to the sibling already\n * standing there.\n *\n * The reorder is defined against the items, not against a container: the\n * neighbour's own parent is where the item belongs. A `list` target that is\n * not the items' parent — or none at all, which the markup contract allows —\n * therefore still lands the move in the right place instead of throwing, and\n * the last slot is *after the last item* rather than after whatever else the\n * container holds (a live region, a footer), which would put the row outside\n * the reading order the list publishes.\n */\n #insertAt(item: HTMLElement, scope: HTMLElement[], index: number): void {\n const clamped = Math.max(0, Math.min(index, scope.length));\n const ahead = scope[clamped] ?? null;\n const behind = ahead ? null : (scope[scope.length - 1] ?? null);\n const neighbour = ahead ?? behind;\n if (!neighbour) return;\n const parent = neighbour.parentNode;\n if (!parent) return;\n // Real browsers drop focus when the focused node is re-inserted (the move\n // is a remove+insert), which would strand the keyboard grab after one\n // arrow press — restore it so focus rides the moved item.\n const active = document.activeElement;\n const hadFocus = active instanceof HTMLElement && item.contains(active);\n parent.insertBefore(item, ahead ?? neighbour.nextSibling);\n if (hadFocus) active.focus();\n }\n\n /**\n * Hands one step to the page's shared announcer.\n *\n * The library carries no live region and no English copy: the wording is the\n * consumer's, written into `announceGrabbedText` / `announceMovedText` /\n * `announceDroppedText` / `announceCanceledText` with `{name}` / `{position}` /\n * `{total}` placeholders, and an unset one announces nothing.\n *\n * Only transitions reach here — the pickup, a step that actually changed the\n * landing slot, and the single end of the session — so a pointer crossing the\n * same slot twice or an arrow clamped at an end stays silent.\n *\n * @stimeoRuntimeOnly The texts word the steps of one reorder, spoken as they happen.\n */\n #announce(key: AnnounceKey, item: HTMLElement): void {\n const template = this.#announceTemplate(key);\n if (template.length === 0) return;\n const items = this.#items();\n announce(\n fillTemplate(template, {\n name: this.#nameOf(item),\n position: items.indexOf(item) + 1,\n total: items.length,\n }),\n );\n }\n\n /** The consumer's wording for one step, or `\"\"` when they authored none. */\n #announceTemplate(key: AnnounceKey): string {\n switch (key) {\n case \"grabbed\":\n return this.announceGrabbedTextValue;\n case \"moved\":\n return this.announceMovedTextValue;\n case \"dropped\":\n return this.announceDroppedTextValue;\n case \"canceled\":\n return this.announceCanceledTextValue;\n }\n }\n\n /** The announced item name: the authored override, else its collapsed text. */\n #nameOf(item: HTMLElement): string {\n const authored = item.getAttribute(`data-${this.identifier}-name`);\n if (authored) return authored;\n return (item.textContent ?? \"\").replace(/\\s+/g, \" \").trim();\n }\n\n /**\n * Resolves the sortable item owning a bubbled `pointer-drag` event.\n *\n * `pointer-drag` dispatches on its own element, and the markup contract puts\n * one on each item, so the owner is the item that **is** the target. Matching\n * an ancestor instead would make a card's own inner draggable — a knob, a\n * split pane, anything the primitive is composed into — drive the card.\n */\n #itemFor(target: EventTarget | null, items: HTMLElement[]): HTMLElement | null {\n if (!target) return null;\n return items.find((item) => item === target) ?? null;\n }\n\n /** The items in live DOM order (targets re-query the DOM on every access). */\n #items(): HTMLElement[] {\n return this.itemTargets;\n }\n\n /** The reorder container: the `list` target when present, else the element. */\n get #list(): HTMLElement {\n return this.hasListTarget ? this.listTarget : this.element;\n }\n\n get #isVertical(): boolean {\n return this.orientationValue !== \"horizontal\";\n }\n\n /**\n * Whether DOM order runs opposite to the primary coordinate — true only for a\n * horizontal row under `dir=\"rtl\"`, where the first item sits at the largest\n * `x`. Both drag paths reach this controller in physical terms (`pointer-drag`\n * documents its deltas as physical and hands RTL to its consumer, which is\n * this controller), so both have to be mapped back onto DOM order here.\n *\n * Read from the list, the element that lays the items out — never from the\n * dragged item, which may carry its own `dir`. The list inherits the computed\n * direction, so authoring `dir` on the root works too. A vertical list is\n * unaffected: writing direction does not mirror the block axis.\n */\n get #isReversed(): boolean {\n return !this.#isVertical && isRtl(this.#list);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/announce.ts","../../src/utils/logical_scroll.ts","../../src/utils/microtask_coalescer.ts","../../src/utils/transient_hooks.ts","../../src/controllers/sortable_controller.ts"],"names":[],"mappings":";;AAoBO,SAAS,QAAA,CAAS,OAAA,EAAiB,OAAA,GAAmC,EAAC,EAAS;AACrF,EAAA,MAAM,IAAA,GAAO,QAAQ,IAAA,EAAK;AAC1B,EAAA,IAAI,IAAA,CAAK,WAAW,CAAA,EAAG;AACvB,EAAA,MAAA,CAAO,aAAA;AAAA,IACL,IAAI,YAAY,4BAAA,EAA8B;AAAA,MAC5C,QAAQ,EAAE,OAAA,EAAS,MAAM,SAAA,EAAW,OAAA,CAAQ,cAAc,IAAA;AAAK,KAChE;AAAA,GACH;AACF;AAUO,SAAS,YAAA,CAAa,UAAkB,MAAA,EAAiD;AAC9F,EAAA,OAAO,QAAA,CAAS,OAAA,CAAQ,6BAAA,EAA+B,CAAC,OAAO,IAAA,KAAiB;AAC9E,IAAA,MAAM,WAAA,GAAc,OAAO,IAAI,CAAA;AAC/B,IAAA,OAAO,WAAA,KAAgB,MAAA,GAAY,KAAA,GAAQ,MAAA,CAAO,WAAW,CAAA;AAAA,EAC/D,CAAC,CAAA;AACH;;AC1BO,SAAS,MAAM,OAAA,EAA2B;AAC/C,EAAA,OAAO,MAAA,CAAO,gBAAA,CAAiB,OAAO,CAAA,CAAE,SAAA,KAAc,KAAA;AACxD;;AC8BO,IAAM,qBAAN,MAAyB;AAAA,EACrB,IAAA;AAAA,EACT,OAAA,GAAU,KAAA;AAAA,EACV,OAAA,GAAU,KAAA;AAAA,EACV,WAAA,GAAc,CAAA;AAAA,EAGd,YAAY,GAAA,EAAiB;AAC3B,IAAA,IAAA,CAAK,IAAA,GAAO,GAAA;AAAA,EACd;AAAA,EAGA,QAAA,GAAiB;AACf,IAAA,IAAA,CAAK,OAAA,GAAU,IAAA;AAAA,EACjB;AAAA,EAGA,MAAA,GAAe;AACb,IAAA,IAAA,CAAK,OAAA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AAA,IAAK,IAAA;AAAA,EAClD;AAAA,EAGA,MAAA,GAAwB;AACtB,IAAA,OAAO,IAAA,CAAK,WAAA;AAAA,EACd;AAAA,EAGA,IAAI,KAAA,GAAqB;AACvB,IAAA,OAAO,IAAA,CAAK,aAAA,GAAgB,IAAA,CAAK,UAAA,GAAa,IAAA,CAAK,OAAA;AAAA,EACrD;AAAA,EAEA,IAAI,WAAA,GAAuB;AACzB,IAAA,OAAO,KAAK,gBAAA,KAAqB,YAAA;AAAA,EACnC;AAAA,EAcA,IAAI,WAAA,GAAuB;AACzB,IAAA,OAAO,CAAC,IAAA,CAAK,WAAA,IAAe,KAAA,CAAM,KAAK,KAAK,CAAA;AAAA,EAC9C;AACF","file":"sortable_controller.js","sourcesContent":["/**\n * Sends one message to the page's shared `stimeo--announcer`.\n *\n * A component that has to reach assistive tech does not carry a live region of its\n * own: a region only announces what changes *after* assistive tech already knows\n * about it, which a region that appears (or is un-hidden) with its message cannot\n * satisfy. The one region that can is the announcer sitting in the page from the\n * start, so state changes are handed to it as an event and it does the reading.\n *\n * The event goes to `window` because the announcer is usually a sibling high in the\n * document rather than an ancestor of the component dispatching it.\n *\n * Wording comes from the consumer — the library ships no English strings — so an\n * empty message is silently dropped and nothing is announced.\n *\n * @example\n * ```ts\n * announce(this.announceTextValue, { assertive: false });\n * ```\n */\nexport function announce(message: string, options: { assertive?: boolean } = {}): void {\n const text = message.trim();\n if (text.length === 0) return;\n window.dispatchEvent(\n new CustomEvent(\"stimeo--announcer:announce\", {\n detail: { message: text, assertive: options.assertive === true },\n }),\n );\n}\n\n/**\n * Fills `{name}` placeholders in an announcement template from `values`.\n *\n * The same substitution the value-text templates use, so a consumer writes\n * `\"{percent}% complete\"` in one attribute and gets the same rules everywhere. A\n * placeholder with no matching entry is left as authored rather than blanked, which\n * keeps a typo visible instead of silently swallowing the word.\n */\nexport function fillTemplate(template: string, values: Record<string, string | number>): string {\n return template.replace(/\\{([a-zA-Z][a-zA-Z0-9]*)\\}/g, (match, name: string) => {\n const replacement = values[name];\n return replacement === undefined ? match : String(replacement);\n });\n}\n","/** 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","/**\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 * Drops the transient state hooks a connection inherited, so the cycle it opens\n * starts from a DOM that claims nothing.\n *\n * A transient hook is an attribute a controller writes to say \"this is happening\n * right now\" — a drag in progress, a form with unsaved edits, a refused\n * subscription. Its lifetime belongs to the interaction, not to the element, and\n * the two come apart whenever the element outlives the instance that wrote it: a\n * Turbo cache snapshot taken mid-interaction restores the hook with the markup,\n * and an element re-inserted elsewhere in the page carries it along. Nothing\n * takes such a hook off, because the instance that owned it is gone; consumer\n * CSS then keeps claiming a state no one is in.\n *\n * **`turbo:before-cache` cannot do this job**, which is why the pass belongs in\n * `connect()`: Turbo also dispatches that event on pages that stay, where the hook\n * is still true, and an in-page move — the other half of the population — never\n * reaches it, so a hook that arrived with a moved element would survive.\n * `connect()` covers both, because both end in a connection.\n *\n * Scope is the **drop** only. What the fresh cycle should say instead is the\n * consumer's: a value re-read from the live DOM, a roster refilled by the\n * stream, a measurement retaken from the current scroll position, a slot emptied\n * of the last result. Those answers differ per consumer and none of them is a\n * hook removal, so the pass stops where every consumer agrees.\n *\n * A declaration names one group of hooks and carries no per-instance state, so\n * it belongs at module scope, shared by every instance the page connects. A\n * consumer writes as many as it has groups — hooks it drops under different\n * conditions cannot share one. The exception is a hook whose name is only known\n * at runtime, such as one built from the registered identifier: that\n * declaration is a field, because the name is.\n *\n * **A drop is not always right.** The population splits on one question: can the\n * state a hook describes outlive the instance that wrote it? Where it cannot — a\n * drag ends with the pointer, a subscription dies with its socket — dropping on\n * every connection is correct. Where it can — a submission in flight is not\n * interrupted by an in-page move — only a connection that follows a real restore\n * may drop, and the consumer answers \"did a session survive?\" with the signal it\n * already holds for its own teardown (a live-session field, a `DetachGate`\n * probe). The drop then sits behind that answer, as the second example shows.\n *\n * @example Unconditional — the state cannot outlive the instance.\n * ```ts\n * const TRANSIENT = new TransientHooks({ attributes: [\"data-sortable-dragging\"] });\n *\n * connect(): void {\n * TRANSIENT.reset(this.element);\n * }\n * ```\n *\n * @example Gated — an in-page move must not drop a live state.\n * ```ts\n * const TRANSIENT = new TransientHooks({ attributes: [\"data-optimistic\"] });\n *\n * connect(): void {\n * const restored = !this.#connected && !this.#gate.pending;\n * this.#gate.cancel();\n * this.#connected = true;\n * if (restored) TRANSIENT.reset(this.element);\n * }\n * ```\n */\n\n/** What a consumer declares once about the hooks its interaction owns. */\nexport interface TransientHooksOptions {\n /**\n * The attribute names a connection may find written by an earlier one. Hooks\n * a consumer drops under different conditions belong to different\n * declarations, so each one can be reset on its own.\n */\n readonly attributes: readonly string[];\n}\n\n/**\n * One consumer's declaration of the hooks its interaction owns, dropped from an\n * element by {@link TransientHooks.reset}.\n */\nexport class TransientHooks {\n readonly #attributes: readonly string[];\n\n constructor(options: TransientHooksOptions) {\n this.#attributes = options.attributes;\n }\n\n /** Drops the declared hooks from `element`; what it carries besides stays. */\n reset(element: Element): void {\n for (const attribute of this.#attributes) element.removeAttribute(attribute);\n }\n}\n","import { Controller } from \"@hotwired/stimulus\";\nimport { announce, fillTemplate } from \"../utils/announce\";\nimport { isRtl } from \"../utils/logical_scroll\";\nimport { MicrotaskCoalescer } from \"../utils/microtask_coalescer\";\nimport { TransientHooks } from \"../utils/transient_hooks\";\n\n/** The hook a connection may find written by an earlier, now-gone one. */\nconst TRANSIENT = new TransientHooks({ attributes: [\"data-sortable-dragging\"] });\n\n/** The four steps a consumer can give wording to. */\ntype AnnounceKey = \"grabbed\" | \"moved\" | \"dropped\" | \"canceled\";\n\n/** A reorder in flight: one item picked up by pointer or keyboard. */\ninterface SortSession {\n item: HTMLElement;\n /**\n * The item that followed it at pickup, and the one that preceded it.\n *\n * The pickup slot is remembered as nodes rather than as an index because the\n * list can change underneath a live drag — a broadcast board inserts and\n * deletes rows while someone is holding one — and an index taken at pickup\n * stops pointing at that place the moment a row appears above it.\n */\n anchor: HTMLElement | null;\n predecessor: HTMLElement | null;\n /** Last primary-axis cumulative delta consumed by keyboard stepping. */\n lastPrimary: number;\n}\n\n/**\n * Headless, accessible **sortable** (single-list reorder) — the a11y-first\n * drag-and-drop that is the flagship consumer of the\n * `stimeo--pointer-drag` primitive. The composition is markup-level and each\n * layer keeps its job: `pointer-drag` (on every item) emits the normalized drag\n * signal with its built-in keyboard alternative, `roving` (on the list) keeps\n * the handles a single Tab stop, and this controller interprets the signal —\n * live-reordering the DOM, handing each step to the page's shared announcer,\n * and reporting the final `reorder`. No dedicated APG pattern exists for\n * drag-and-drop; the keyboard model (grab → arrows → drop / Escape) comes from\n * `pointer-drag` and the announcements make it non-visually trackable\n * (WCAG 2.1.1 / 2.5.7 / 4.1.3). Core (zero dependencies).\n *\n * Markup contract (identifier: `stimeo--sortable`):\n * <div data-controller=\"stimeo--sortable\">\n * <ul data-stimeo--sortable-target=\"list\" data-controller=\"stimeo--roving\"\n * data-stimeo--roving-orientation-value=\"vertical\">\n * <li data-stimeo--sortable-target=\"item\" data-stimeo--sortable-name=\"Card A\"\n * data-controller=\"stimeo--pointer-drag\"\n * data-stimeo--pointer-drag-axis-value=\"y\">\n * <span>Card A</span>\n * <button type=\"button\" aria-label=\"Reorder Card A\"\n * data-stimeo--pointer-drag-target=\"handle\"\n * data-stimeo--roving-target=\"item\">⠿</button>\n * </li>\n * …\n * </ul>\n * </div>\n *\n * The composed values must follow the sort axis: roving's `orientation`\n * (which defaults to `horizontal`, so a vertical list has to author\n * `vertical`) and pointer-drag's `axis`. `stimeo check` enforces both\n * alignments as composition rules (`composition-mismatch`).\n *\n * Pointer flow: dragging an item live-moves it whenever the pointer crosses a\n * sibling's midpoint (per `orientation`). Keyboard flow: each synthetic\n * `pointer-drag` move steps the item one position. A horizontal list under\n * `dir=\"rtl\"` reverses both, since DOM order then runs right-to-left while\n * `pointer-drag` reports physical coordinates. Dropping dispatches\n * `reorder` (`{ item, from, to }`, zero-based) when the position changed;\n * Escape / `pointercancel` restores the pickup position. Every step is handed to\n * the page's shared `stimeo--announcer` as the consumer's own wording —\n * `announceGrabbedText` / `announceMovedText` / `announceDroppedText` /\n * `announceCanceledText`, with `{name}` / `{position}` / `{total}` placeholders —\n * and an unset one announces nothing.\n *\n * @remarks\n * Behavior only — the ghost/placeholder/drop-hint visuals are the consumer's\n * CSS, keyed off `pointer-drag`'s `data-dragging`/`data-grabbed` on the item\n * and this controller's `data-sortable-dragging` on the root. Persistence is\n * the consumer's `reorder` listener (post the new position; a Turbo Stream\n * broadcast makes the board collaborative). The DOM order is the single source\n * of truth: items are read live on every event, so rows appended by Turbo need\n * no rewiring, and a Turbo cache restore reconnects idempotently (`connect()`\n * clears the transient root hook; a drag cannot survive a navigation). Only the\n * event listeners are held, and they are removed on `disconnect()`. Multi-list\n * / kanban, nested DnD, auto-scroll at the edges, and virtualized lists are\n * deliberately out of this single-list scope.\n */\nexport class SortableController extends Controller<HTMLElement> {\n static override targets = [\"list\", \"item\"];\n static override values = {\n orientation: { type: String, default: \"vertical\" },\n announceGrabbedText: { type: String, default: \"\" },\n announceMovedText: { type: String, default: \"\" },\n announceDroppedText: { type: String, default: \"\" },\n announceCanceledText: { type: String, default: \"\" },\n };\n static events = [\"reorder\"] as const;\n\n declare readonly hasListTarget: boolean;\n declare readonly listTarget: HTMLElement;\n declare readonly itemTargets: HTMLElement[];\n declare orientationValue: string;\n declare announceGrabbedTextValue: string;\n declare announceMovedTextValue: string;\n declare announceDroppedTextValue: string;\n declare announceCanceledTextValue: string;\n\n #session: SortSession | null = null;\n /** Defers the lost-item check to after the mutation batch (see below). */\n readonly #settle = new MicrotaskCoalescer(() => this.#dropLostSession());\n\n override connect(): void {\n // A drag cannot survive a navigation: drop the hook a Turbo cache snapshot\n // may have preserved mid-drag (idempotent reconnect).\n TRANSIENT.reset(this.element);\n this.#settle.activate();\n this.element.addEventListener(\"stimeo--pointer-drag:start\", this.#onDragStart);\n this.element.addEventListener(\"stimeo--pointer-drag:move\", this.#onDragMove);\n this.element.addEventListener(\"stimeo--pointer-drag:end\", this.#onDragEnd);\n this.element.addEventListener(\"stimeo--pointer-drag:cancel\", this.#onDragCancel);\n }\n\n override disconnect(): void {\n this.element.removeEventListener(\"stimeo--pointer-drag:start\", this.#onDragStart);\n this.element.removeEventListener(\"stimeo--pointer-drag:move\", this.#onDragMove);\n this.element.removeEventListener(\"stimeo--pointer-drag:end\", this.#onDragEnd);\n this.element.removeEventListener(\"stimeo--pointer-drag:cancel\", this.#onDragCancel);\n this.#settle.cancel();\n this.#session = null;\n this.element.removeAttribute(\"data-sortable-dragging\");\n }\n\n /**\n * Ends a session whose item left the item set.\n *\n * The controller's own reorder detaches and reattaches the item inside one\n * mutation batch, so the loss is only real once the batch has settled — the\n * check therefore runs a microtask later and asks whether the item is a target\n * again. Without it a deleted row (a broadcast that drops it from the board)\n * or a morph that strips the item's target attribute would hold the\n * one-at-a-time session for the rest of the page's life, with the root hook\n * stuck on and every later grab refused with no way out.\n */\n itemTargetDisconnected(item: HTMLElement): void {\n if (this.#session?.item !== item) return;\n this.#settle.schedule();\n }\n\n #dropLostSession(): void {\n const session = this.#session;\n if (!session) return;\n const items = this.#items();\n if (items.includes(session.item)) return;\n this.#session = null;\n this.element.removeAttribute(\"data-sortable-dragging\");\n // An element that is still in the document (a morph took only its target\n // attribute) goes back where it was picked up. Nothing is announced either\n // way: the row is no longer one of the items, so there is no position to\n // read out — what matters is that the next grab is not refused.\n if (session.item.isConnected) this.#restore(session, items);\n }\n\n /** Picks the item up: remembers its neighbours and announces the grab. */\n readonly #onDragStart = (event: Event): void => {\n // One reorder at a time: a start from another item (each item has its own\n // pointer-drag instance) must not clobber the live session — its pickup\n // slot and cancel restore would be lost.\n if (this.#session) return;\n const items = this.#items();\n const item = this.#itemFor(event.target, items);\n if (!item) return;\n const index = items.indexOf(item);\n this.#session = {\n item,\n anchor: items[index + 1] ?? null,\n predecessor: items[index - 1] ?? null,\n lastPrimary: 0,\n };\n this.element.setAttribute(\"data-sortable-dragging\", \"true\");\n this.#announce(\"grabbed\", item);\n };\n\n readonly #onDragMove = (event: Event): void => {\n const session = this.#session;\n if (!session) return;\n const items = this.#items();\n if (this.#itemFor(event.target, items) !== session.item) return;\n\n const detail = (event as CustomEvent<Record<string, number | string>>).detail;\n if (detail.pointerType === \"keyboard\") {\n this.#stepFromKeyboard(session, detail, items);\n } else {\n this.#followPointer(session, detail, items);\n }\n };\n\n /** Drops the item: announces, then reports `reorder` if the position changed. */\n readonly #onDragEnd = (event: Event): void => {\n const session = this.#session;\n if (!session) return;\n const items = this.#items();\n if (this.#itemFor(event.target, items) !== session.item) return;\n this.#session = null;\n this.element.removeAttribute(\"data-sortable-dragging\");\n this.#announce(\"dropped\", session.item);\n const to = items.indexOf(session.item);\n const from = this.#pickupSlot(session, items) ?? to;\n if (to !== from) {\n this.dispatch(\"reorder\", { detail: { item: session.item, from, to } });\n }\n };\n\n /** Restores the pickup position (Escape / OS `pointercancel`). */\n readonly #onDragCancel = (event: Event): void => {\n const session = this.#session;\n if (!session) return;\n const items = this.#items();\n if (this.#itemFor(event.target, items) !== session.item) return;\n this.#session = null;\n this.element.removeAttribute(\"data-sortable-dragging\");\n this.#restore(session, items);\n this.#announce(\"canceled\", session.item);\n };\n\n /**\n * The slot the item was picked up from, read back through the neighbours it\n * had then — `null` when neither survives and the item itself is gone.\n *\n * The anchor is the item that followed it, so restoring means \"before that one\n * again\". When the anchor was deleted mid-drag the predecessor answers the\n * same question from the other side. With both gone the item's current slot is\n * the honest answer: nothing is known to have moved, so no reorder is reported\n * and a cancel leaves the item where it is.\n */\n #pickupSlot(session: SortSession, items: HTMLElement[]): number | null {\n const others = items.filter((candidate) => candidate !== session.item);\n if (session.anchor) {\n const at = others.indexOf(session.anchor);\n if (at !== -1) return at;\n }\n if (session.predecessor) {\n const at = others.indexOf(session.predecessor);\n if (at !== -1) return at + 1;\n }\n const here = items.indexOf(session.item);\n return here === -1 ? null : here;\n }\n\n /** Puts the item back where it was picked up from. */\n #restore(session: SortSession, items: HTMLElement[]): void {\n const slot = this.#pickupSlot(session, items);\n if (slot === null) return;\n this.#insertAt(\n session.item,\n items.filter((candidate) => candidate !== session.item),\n slot,\n );\n }\n\n /**\n * Keyboard stepping: `pointer-drag` reports *cumulative* synthetic deltas, so\n * the difference from the last consumed value is one arrow press — its sign is\n * the direction. Cross-axis arrows never change the primary delta (no move).\n *\n * The sign is physical (`ArrowRight` is always `+dx`), so a right-to-left row\n * has to invert it: there, moving the item rightward means moving it *earlier*\n * in the DOM. Skipping this would also split the two halves of one keypress —\n * `roving` already moves focus logically, so the same arrow would send the\n * focus and the grabbed item opposite ways.\n */\n #stepFromKeyboard(\n session: SortSession,\n detail: Record<string, number | string>,\n items: HTMLElement[],\n ): void {\n const primary = Number(this.#isVertical ? detail.dy : detail.dx) || 0;\n const delta = primary - session.lastPrimary;\n session.lastPrimary = primary;\n if (delta === 0) return;\n\n const index = items.indexOf(session.item);\n const step = (delta > 0 ? 1 : -1) * (this.#isReversed ? -1 : 1);\n const next = Math.max(0, Math.min(index + step, items.length - 1));\n if (next === index) return;\n this.#insertAt(\n session.item,\n items.filter((candidate) => candidate !== session.item),\n next,\n );\n this.#announce(\"moved\", session.item);\n }\n\n /**\n * Pointer following: the item moves to the slot whose siblings' midpoints the\n * pointer has passed (per `orientation`).\n *\n * Only siblings that occupy space take part. A row with no layout box — a\n * filtered-out item, a `display: none` ancestor, a collapsed `<details>` — is\n * reported with an empty rect at the document origin, and its midpoint of `0`\n * sits below every pointer position: counted, it would read as passed on the\n * very first move and send the item across a slot the pointer never crossed.\n * With no laid-out sibling at all there is nothing to compare against and the\n * move is skipped entirely.\n */\n #followPointer(\n session: SortSession,\n detail: Record<string, number | string>,\n items: HTMLElement[],\n ): void {\n const pointer = Number(this.#isVertical ? detail.y : detail.x) || 0;\n const vertical = this.#isVertical;\n // `target` counts the siblings that precede the pointer *in DOM order*, and\n // the two agree only while DOM order runs the same way as the coordinate. In\n // a right-to-left row it runs the other way, so the comparison flips;\n // leaving it physical would mix two orderings into one number and drop the\n // item at a slot the pointer never crossed. Resolved once: it cannot change\n // mid-loop, and reading it per sibling would re-run `getComputedStyle` on\n // every pointermove.\n const reversed = this.#isReversed;\n const here = items.indexOf(session.item);\n const laidOut: HTMLElement[] = [];\n let target = 0;\n // `current` is the item's own slot in that same laid-out space: the number\n // of laid-out siblings that come before it in DOM order.\n let current = 0;\n items.forEach((item, index) => {\n if (item === session.item) return;\n const rect = item.getBoundingClientRect();\n if (rect.width === 0 && rect.height === 0) return;\n if (index < here) current += 1;\n laidOut.push(item);\n const midpoint = vertical ? rect.top + rect.height / 2 : rect.left + rect.width / 2;\n if (reversed ? pointer < midpoint : pointer > midpoint) target += 1;\n });\n if (laidOut.length === 0 || target === current) return;\n\n this.#insertAt(session.item, laidOut, target);\n this.#announce(\"moved\", session.item);\n }\n\n /**\n * Reinserts `item` at `index` among `scope`, relative to the sibling already\n * standing there.\n *\n * The reorder is defined against the items, not against a container: the\n * neighbour's own parent is where the item belongs. A `list` target that is\n * not the items' parent — or none at all, which the markup contract allows —\n * therefore still lands the move in the right place instead of throwing, and\n * the last slot is *after the last item* rather than after whatever else the\n * container holds (a live region, a footer), which would put the row outside\n * the reading order the list publishes.\n */\n #insertAt(item: HTMLElement, scope: HTMLElement[], index: number): void {\n const clamped = Math.max(0, Math.min(index, scope.length));\n const ahead = scope[clamped] ?? null;\n const behind = ahead ? null : (scope[scope.length - 1] ?? null);\n const neighbour = ahead ?? behind;\n if (!neighbour) return;\n const parent = neighbour.parentNode;\n if (!parent) return;\n // Real browsers drop focus when the focused node is re-inserted (the move\n // is a remove+insert), which would strand the keyboard grab after one\n // arrow press — restore it so focus rides the moved item.\n const active = document.activeElement;\n const hadFocus = active instanceof HTMLElement && item.contains(active);\n parent.insertBefore(item, ahead ?? neighbour.nextSibling);\n if (hadFocus) active.focus();\n }\n\n /**\n * Hands one step to the page's shared announcer.\n *\n * The library carries no live region and no English copy: the wording is the\n * consumer's, written into `announceGrabbedText` / `announceMovedText` /\n * `announceDroppedText` / `announceCanceledText` with `{name}` / `{position}` /\n * `{total}` placeholders, and an unset one announces nothing.\n *\n * Only transitions reach here — the pickup, a step that actually changed the\n * landing slot, and the single end of the session — so a pointer crossing the\n * same slot twice or an arrow clamped at an end stays silent.\n *\n * @stimeoRuntimeOnly The texts word the steps of one reorder, spoken as they happen.\n */\n #announce(key: AnnounceKey, item: HTMLElement): void {\n const template = this.#announceTemplate(key);\n if (template.length === 0) return;\n const items = this.#items();\n announce(\n fillTemplate(template, {\n name: this.#nameOf(item),\n position: items.indexOf(item) + 1,\n total: items.length,\n }),\n );\n }\n\n /** The consumer's wording for one step, or `\"\"` when they authored none. */\n #announceTemplate(key: AnnounceKey): string {\n switch (key) {\n case \"grabbed\":\n return this.announceGrabbedTextValue;\n case \"moved\":\n return this.announceMovedTextValue;\n case \"dropped\":\n return this.announceDroppedTextValue;\n case \"canceled\":\n return this.announceCanceledTextValue;\n }\n }\n\n /** The announced item name: the authored override, else its collapsed text. */\n #nameOf(item: HTMLElement): string {\n const authored = item.getAttribute(`data-${this.identifier}-name`);\n if (authored) return authored;\n return (item.textContent ?? \"\").replace(/\\s+/g, \" \").trim();\n }\n\n /**\n * Resolves the sortable item owning a bubbled `pointer-drag` event.\n *\n * `pointer-drag` dispatches on its own element, and the markup contract puts\n * one on each item, so the owner is the item that **is** the target. Matching\n * an ancestor instead would make a card's own inner draggable — a knob, a\n * split pane, anything the primitive is composed into — drive the card.\n */\n #itemFor(target: EventTarget | null, items: HTMLElement[]): HTMLElement | null {\n if (!target) return null;\n return items.find((item) => item === target) ?? null;\n }\n\n /** The items in live DOM order (targets re-query the DOM on every access). */\n #items(): HTMLElement[] {\n return this.itemTargets;\n }\n\n /** The reorder container: the `list` target when present, else the element. */\n get #list(): HTMLElement {\n return this.hasListTarget ? this.listTarget : this.element;\n }\n\n get #isVertical(): boolean {\n return this.orientationValue !== \"horizontal\";\n }\n\n /**\n * Whether DOM order runs opposite to the primary coordinate — true only for a\n * horizontal row under `dir=\"rtl\"`, where the first item sits at the largest\n * `x`. Both drag paths reach this controller in physical terms (`pointer-drag`\n * documents its deltas as physical and hands RTL to its consumer, which is\n * this controller), so both have to be mapped back onto DOM order here.\n *\n * Read from the list, the element that lays the items out — never from the\n * dragged item, which may carry its own `dir`. The list inherits the computed\n * direction, so authoring `dir` on the root works too. A vertical list is\n * unaffected: writing direction does not mirror the block axis.\n */\n get #isReversed(): boolean {\n return !this.#isVertical && isRtl(this.#list);\n }\n}\n"]}
|
|
@@ -34,16 +34,20 @@ import { Controller } from '@hotwired/stimulus';
|
|
|
34
34
|
* - `stimeo--spinner:show` — the indicator became visible, after `delay`.
|
|
35
35
|
* - `stimeo--spinner:hide` — the indicator went away, after `minDuration`.
|
|
36
36
|
* - `stimeo--spinner:timeout` — `timeout` elapsed with the load still running;
|
|
37
|
-
* the controller then ends it
|
|
37
|
+
* the controller then ends it as `stop` would; `hide` follows only if it was shown.
|
|
38
38
|
*
|
|
39
39
|
* `hide`, `show`, `timeout`, and `reconcile` dispatch `{}`. The last of those
|
|
40
|
-
* reports that
|
|
40
|
+
* reports that a connection returned to idle a cycle no instance was running — a page
|
|
41
|
+
* restored from the Turbo cache in the middle of a load.
|
|
41
42
|
*
|
|
42
43
|
* @remarks
|
|
43
44
|
* Behavior only — the visual spinner is the consumer's, alongside the text and
|
|
44
45
|
* `aria-hidden="true"`. Both timers are owned by `SafeTimeout`, kept across
|
|
45
|
-
* an in-page move and dropped on a real detach via `DetachGate
|
|
46
|
-
*
|
|
46
|
+
* an in-page move and dropped on a real detach via `DetachGate`. A load in progress is
|
|
47
|
+
* never undone on `turbo:before-cache`, which Turbo also dispatches on pages that stay
|
|
48
|
+
* (a promoted frame navigation, a state-less `popstate`, a refresh of a cached URL, a
|
|
49
|
+
* `data-turbo-permanent` element carried to the next page): the load is still running
|
|
50
|
+
* there, and its `stop` still hides the spinner and announces the result.
|
|
47
51
|
*/
|
|
48
52
|
declare class SpinnerController extends Controller<HTMLElement> {
|
|
49
53
|
#private;
|
|
@@ -70,10 +74,29 @@ declare class SpinnerController extends Controller<HTMLElement> {
|
|
|
70
74
|
default: number;
|
|
71
75
|
};
|
|
72
76
|
};
|
|
77
|
+
static valueConstraints: {
|
|
78
|
+
delay: {
|
|
79
|
+
readonly finite: true;
|
|
80
|
+
readonly min: 0;
|
|
81
|
+
readonly max: 2147483647;
|
|
82
|
+
};
|
|
83
|
+
minDuration: {
|
|
84
|
+
readonly finite: true;
|
|
85
|
+
readonly min: 0;
|
|
86
|
+
readonly max: 2147483647;
|
|
87
|
+
};
|
|
88
|
+
timeout: {
|
|
89
|
+
readonly finite: true;
|
|
90
|
+
readonly min: 0;
|
|
91
|
+
readonly max: 2147483647;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
73
94
|
static actions: readonly ["start", "stop"];
|
|
74
95
|
static events: readonly ["hide", "show", "timeout", "reconcile"];
|
|
75
96
|
readonly indicatorTarget: HTMLElement;
|
|
97
|
+
readonly indicatorTargets: HTMLElement[];
|
|
76
98
|
readonly regionTarget: HTMLElement;
|
|
99
|
+
readonly regionTargets: HTMLElement[];
|
|
77
100
|
readonly messageTarget: HTMLElement;
|
|
78
101
|
readonly hasIndicatorTarget: boolean;
|
|
79
102
|
readonly hasRegionTarget: boolean;
|
|
@@ -93,6 +116,18 @@ declare class SpinnerController extends Controller<HTMLElement> {
|
|
|
93
116
|
* bring it back.
|
|
94
117
|
*/
|
|
95
118
|
indicatorTargetConnected(target: HTMLElement): void;
|
|
119
|
+
/**
|
|
120
|
+
* Gives an indicator that no longer resolves its own `hidden` back, even after
|
|
121
|
+
* `disconnect()`, and while connected re-applies the current phase to the one that stays.
|
|
122
|
+
*/
|
|
123
|
+
indicatorTargetDisconnected(indicator: HTMLElement): void;
|
|
124
|
+
/** Applies the current busy state to a region inserted or replaced after `connect()`. */
|
|
125
|
+
regionTargetConnected(region: HTMLElement): void;
|
|
126
|
+
/**
|
|
127
|
+
* Gives a region that no longer resolves its own `aria-busy` back, even after
|
|
128
|
+
* `disconnect()`, and while connected resyncs the region that stays.
|
|
129
|
+
*/
|
|
130
|
+
regionTargetDisconnected(region: HTMLElement): void;
|
|
96
131
|
disconnect(): void;
|
|
97
132
|
/** Begins loading. Honors `delay` before the spinner actually appears. */
|
|
98
133
|
start(): void;
|