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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +31 -0
- data/README.md +8 -1
- data/dist/cable/index.js +363 -436
- data/dist/controllers/accordion_controller.js +166 -55
- data/dist/controllers/alert_dialog_controller.js +862 -221
- data/dist/controllers/announcer_controller.js +135 -198
- data/dist/controllers/aspect_ratio_controller.js +0 -10
- data/dist/controllers/auto_submit_controller.js +271 -127
- data/dist/controllers/avatar_controller.js +171 -105
- data/dist/controllers/breadcrumb_controller.js +0 -130
- data/dist/controllers/bulk_select_controller.js +262 -52
- data/dist/controllers/calendar_controller.js +175 -209
- data/dist/controllers/carousel_controller.js +461 -399
- data/dist/controllers/character_counter_controller.js +246 -156
- data/dist/controllers/checkbox_controller.js +32 -74
- data/dist/controllers/clipboard_controller.js +168 -147
- data/dist/controllers/collapsible_controller.js +301 -120
- data/dist/controllers/color_picker_controller.js +149 -139
- data/dist/controllers/combobox_controller.js +360 -133
- data/dist/controllers/command_palette_controller.js +970 -358
- data/dist/controllers/conditional_fields_controller.js +166 -124
- data/dist/controllers/confirm_controller.js +939 -248
- data/dist/controllers/context_menu_controller.js +256 -128
- data/dist/controllers/count_up_controller.js +73 -21
- data/dist/controllers/countdown_controller.js +183 -148
- data/dist/controllers/currency_input_controller.js +134 -158
- data/dist/controllers/data_grid_controller.js +114 -186
- data/dist/controllers/date_range_picker_controller.js +288 -206
- data/dist/controllers/dialog_controller.js +858 -223
- data/dist/controllers/direct_upload_controller.js +73 -153
- data/dist/controllers/dirty_form_controller.js +14 -48
- data/dist/controllers/dismissible_controller.js +175 -21
- data/dist/controllers/drawer_controller.js +933 -341
- data/dist/controllers/dropdown_controller.js +312 -82
- data/dist/controllers/editable_controller.js +158 -68
- data/dist/controllers/empty_state_controller.js +67 -53
- data/dist/controllers/file_dropzone_controller.js +311 -207
- data/dist/controllers/filter_controller.js +67 -39
- data/dist/controllers/flash_controller.js +172 -314
- data/dist/controllers/focus_controller.js +654 -240
- data/dist/controllers/form_field_controller.js +147 -132
- data/dist/controllers/form_validation_controller.js +13 -86
- data/dist/controllers/frame_loading_controller.js +264 -213
- data/dist/controllers/highlight_controller.js +107 -75
- data/dist/controllers/hover_card_controller.js +309 -118
- data/dist/controllers/idle_controller.js +267 -101
- data/dist/controllers/input_mask_controller.js +71 -72
- data/dist/controllers/intersection_controller.js +147 -106
- data/dist/controllers/lazy_frame_controller.js +9 -65
- data/dist/controllers/listbox_controller.js +306 -204
- data/dist/controllers/local_time_controller.js +54 -64
- data/dist/controllers/masonry_controller.js +70 -93
- data/dist/controllers/menu_controller.js +214 -156
- data/dist/controllers/menubar_controller.js +170 -329
- data/dist/controllers/meter_controller.js +151 -67
- data/dist/controllers/multi_select_controller.js +593 -358
- data/dist/controllers/navigation_menu_controller.js +124 -232
- data/dist/controllers/nested_form_controller.js +352 -182
- data/dist/controllers/network_status_controller.js +242 -54
- data/dist/controllers/number_input_controller.js +320 -263
- data/dist/controllers/optimistic_controller.js +16 -76
- data/dist/controllers/otp_controller.js +198 -193
- data/dist/controllers/overflow_indicator_controller.js +116 -113
- data/dist/controllers/overflow_menu_controller.js +343 -283
- data/dist/controllers/pagination_controller.js +295 -119
- data/dist/controllers/password_reveal_controller.js +389 -121
- data/dist/controllers/password_strength_controller.js +99 -153
- data/dist/controllers/persist_controller.js +237 -103
- data/dist/controllers/pointer_drag_controller.js +185 -165
- data/dist/controllers/popover_controller.js +236 -97
- data/dist/controllers/portal_controller.js +209 -76
- data/dist/controllers/preview_guard_controller.js +232 -116
- data/dist/controllers/progress_controller.js +125 -56
- data/dist/controllers/radio_group_controller.js +117 -137
- data/dist/controllers/range_slider_controller.js +192 -105
- data/dist/controllers/rating_controller.js +418 -207
- data/dist/controllers/read_more_controller.js +134 -63
- data/dist/controllers/reading_progress_controller.js +147 -135
- data/dist/controllers/relative_time_controller.js +145 -110
- data/dist/controllers/{reset_before_cache_controller.js → reset_on_restore_controller.js} +97 -38
- data/dist/controllers/resizable_controller.js +255 -139
- data/dist/controllers/roving_controller.js +39 -84
- data/dist/controllers/scroll_area_controller.js +428 -225
- data/dist/controllers/scroll_restore_controller.js +0 -53
- data/dist/controllers/scroll_visibility_controller.js +395 -145
- data/dist/controllers/scrollspy_controller.js +181 -242
- data/dist/controllers/separator_controller.js +267 -140
- data/dist/controllers/sidebar_controller.js +1023 -386
- data/dist/controllers/skeleton_controller.js +248 -97
- data/dist/controllers/slider_controller.js +159 -79
- data/dist/controllers/smart_sticky_header_controller.js +162 -63
- data/dist/controllers/sortable_controller.js +0 -112
- data/dist/controllers/spinner_controller.js +277 -169
- data/dist/controllers/step_indicator_controller.js +99 -46
- data/dist/controllers/stepper_controller.js +114 -73
- data/dist/controllers/stick_to_bottom_controller.js +262 -138
- data/dist/controllers/sticky_observer_controller.js +214 -49
- data/dist/controllers/submit_once_controller.js +294 -205
- data/dist/controllers/switch_controller.js +33 -60
- data/dist/controllers/tabs_controller.js +35 -29
- data/dist/controllers/tags_input_controller.js +136 -145
- data/dist/controllers/textarea_autosize_controller.js +71 -58
- data/dist/controllers/theme_controller.js +130 -112
- data/dist/controllers/time_picker_controller.js +146 -80
- data/dist/controllers/toast_controller.js +186 -297
- data/dist/controllers/toggle_group_controller.js +95 -136
- data/dist/controllers/toolbar_controller.js +68 -98
- data/dist/controllers/tooltip_controller.js +158 -124
- data/dist/controllers/transition_controller.js +123 -119
- data/dist/controllers/tree_view_controller.js +150 -345
- data/dist/index.js +6370 -9346
- data/dist/positioning/index.js +148 -47
- data/lib/stimeo/ui/version.rb +1 -1
- metadata +3 -3
|
@@ -1,99 +1,63 @@
|
|
|
1
1
|
import { Controller } from '@hotwired/stimulus';
|
|
2
2
|
|
|
3
|
-
// src/controllers/optimistic_controller.ts
|
|
4
|
-
|
|
5
|
-
// src/utils/detach_gate.ts
|
|
6
3
|
var DetachGate = class _DetachGate {
|
|
7
|
-
/** Set while a probe is queued, waiting for a reconnect to cancel it. */
|
|
8
4
|
#pending = false;
|
|
9
|
-
/**
|
|
10
|
-
* True while a probe is queued — the last disconnect was ambiguous and no
|
|
11
|
-
* reconnect has cancelled it yet. Read it from `connect()` to tell the
|
|
12
|
-
* reconnect half of an in-page move from a first connect: a controller whose
|
|
13
|
-
* initialisation restarts a measurement (a min-duration floor, an elapsed
|
|
14
|
-
* counter) must skip it for the move, where nothing actually restarted.
|
|
15
|
-
*/
|
|
16
5
|
get pending() {
|
|
17
6
|
return this.#pending;
|
|
18
7
|
}
|
|
19
|
-
/**
|
|
20
|
-
* True when the disconnect is definitely a real detach — the element left
|
|
21
|
-
* the document, or `data-controller` no longer lists the identifier. False
|
|
22
|
-
* means ambiguous (in-page move or observed-root exit), NOT "alive".
|
|
23
|
-
*/
|
|
24
8
|
static isDetached(host) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return !tokens.includes(host.identifier);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Call from `disconnect()`: runs `teardown` synchronously on a definite
|
|
31
|
-
* detach (fast path), otherwise defers it one microtask — a reconnect
|
|
32
|
-
* ({@link cancel} from `connect()`) keeps the state, no reconnect runs it.
|
|
33
|
-
* One microtask is the whole probe window: Stimulus reconnects a moved
|
|
34
|
-
* element within the same mutation batch, before the checkpoint drains.
|
|
35
|
-
*/
|
|
9
|
+
return !host.element.isConnected || !_DetachGate.#listed(host);
|
|
10
|
+
}
|
|
36
11
|
disconnected(host, teardown) {
|
|
37
|
-
|
|
12
|
+
const carried = _DetachGate.#carried(host);
|
|
13
|
+
if (!carried && _DetachGate.isDetached(host)) {
|
|
38
14
|
this.#pending = false;
|
|
39
15
|
teardown();
|
|
40
16
|
return;
|
|
41
17
|
}
|
|
42
18
|
this.#pending = true;
|
|
43
|
-
|
|
19
|
+
const probe = () => {
|
|
44
20
|
if (!this.#pending) return;
|
|
45
21
|
this.#pending = false;
|
|
46
22
|
teardown();
|
|
47
|
-
}
|
|
23
|
+
};
|
|
24
|
+
if (carried) setTimeout(probe, 0);
|
|
25
|
+
else queueMicrotask(probe);
|
|
26
|
+
}
|
|
27
|
+
static #carried(host) {
|
|
28
|
+
const element = host.element;
|
|
29
|
+
return !element.isConnected && element.closest("[data-turbo-permanent]") !== null && _DetachGate.#listed(host);
|
|
30
|
+
}
|
|
31
|
+
static #listed(host) {
|
|
32
|
+
const tokens = (host.element.getAttribute("data-controller") ?? "").split(/\s+/);
|
|
33
|
+
return tokens.includes(host.identifier);
|
|
48
34
|
}
|
|
49
|
-
/**
|
|
50
|
-
* Disarms a pending probe. Call from `connect()` (the reconnect that proves
|
|
51
|
-
* an in-page move) and from the head of any teardown path not routed through
|
|
52
|
-
* {@link disconnected} (disabled-toggle, Escape), so an orphaned probe can
|
|
53
|
-
* never run the teardown a second time.
|
|
54
|
-
*/
|
|
55
35
|
cancel() {
|
|
56
36
|
this.#pending = false;
|
|
57
37
|
}
|
|
58
38
|
};
|
|
59
39
|
|
|
60
|
-
// src/utils/listener_set.ts
|
|
61
40
|
var ListenerSet = class {
|
|
62
|
-
/** The generation every `add` joins until the next `dispose()`. */
|
|
63
41
|
#abort = new AbortController();
|
|
64
|
-
/**
|
|
65
|
-
* Attaches `handler` to the open generation, exactly as the caller spelled it.
|
|
66
|
-
*
|
|
67
|
-
* The set supplies the signal, so `options` carries everything else the DOM
|
|
68
|
-
* accepts — `capture` included, which has to match at release time and no
|
|
69
|
-
* longer has a second place to drift from.
|
|
70
|
-
*/
|
|
71
42
|
add(target, type, handler, options) {
|
|
72
43
|
target.addEventListener(type, handler, { ...options, signal: this.#abort.signal });
|
|
73
44
|
}
|
|
74
|
-
/**
|
|
75
|
-
* Releases every listener of the open generation, synchronously, and opens the
|
|
76
|
-
* next one. Idempotent, and safe before anything has been added.
|
|
77
|
-
*/
|
|
78
45
|
dispose() {
|
|
79
46
|
this.#abort.abort();
|
|
80
47
|
this.#abort = new AbortController();
|
|
81
48
|
}
|
|
82
49
|
};
|
|
83
50
|
|
|
84
|
-
// src/utils/transient_hooks.ts
|
|
85
51
|
var TransientHooks = class {
|
|
86
52
|
#attributes;
|
|
87
53
|
constructor(options) {
|
|
88
54
|
this.#attributes = options.attributes;
|
|
89
55
|
}
|
|
90
|
-
/** Drops the declared hooks from `element`; what it carries besides stays. */
|
|
91
56
|
reset(element) {
|
|
92
57
|
for (const attribute of this.#attributes) element.removeAttribute(attribute);
|
|
93
58
|
}
|
|
94
59
|
};
|
|
95
60
|
|
|
96
|
-
// src/controllers/optimistic_controller.ts
|
|
97
61
|
var TRANSIENT = new TransientHooks({ attributes: ["data-optimistic"] });
|
|
98
62
|
var HIDDEN_MARKER = "data-optimistic-toggled";
|
|
99
63
|
var BUSY_MARKER = "data-optimistic-busy";
|
|
@@ -107,11 +71,9 @@ function submissionOf(event) {
|
|
|
107
71
|
var OptimisticController = class extends Controller {
|
|
108
72
|
static targets = ["show", "hide"];
|
|
109
73
|
static events = ["commit", "rollback"];
|
|
110
|
-
/** The submission that owns the applied optimistic state, if any. */
|
|
111
74
|
#pending = null;
|
|
112
75
|
#gate = new DetachGate();
|
|
113
76
|
#listeners = new ListenerSet();
|
|
114
|
-
/** True between `connect()` and `disconnect()`, so a repeat connect rewinds nothing. */
|
|
115
77
|
#connected = false;
|
|
116
78
|
connect() {
|
|
117
79
|
const restored = !this.#connected && !this.#gate.pending;
|
|
@@ -154,12 +116,10 @@ var OptimisticController = class extends Controller {
|
|
|
154
116
|
this.dispatch("rollback");
|
|
155
117
|
}
|
|
156
118
|
};
|
|
157
|
-
/** Hides or reveals a target, recording the authored `hidden` on first write. */
|
|
158
119
|
#setHidden(target, hidden) {
|
|
159
120
|
if (target.hasAttribute("hidden") === hidden) return;
|
|
160
121
|
this.#write(target, "hidden", hidden ? "" : null, HIDDEN_MARKER);
|
|
161
122
|
}
|
|
162
|
-
/** Writes an attribute, recording what it displaced under `marker` once. */
|
|
163
123
|
#write(element, attribute, value, marker) {
|
|
164
124
|
if (!element.hasAttribute(marker)) {
|
|
165
125
|
const authored = element.getAttribute(attribute);
|
|
@@ -171,16 +131,6 @@ var OptimisticController = class extends Controller {
|
|
|
171
131
|
if (value === null) element.removeAttribute(attribute);
|
|
172
132
|
else element.setAttribute(attribute, value);
|
|
173
133
|
}
|
|
174
|
-
/**
|
|
175
|
-
* Puts back the value `marker` recorded and drops the record.
|
|
176
|
-
*
|
|
177
|
-
* `written` is what this controller last put in the attribute. Anything else
|
|
178
|
-
* there now belongs to whoever wrote it — Turbo owns `aria-busy` on a form and
|
|
179
|
-
* clears it before the terminal arrives, and a consumer may have moved a face
|
|
180
|
-
* mid-flight — so the record is dropped without touching the attribute. A
|
|
181
|
-
* marker this build did not write names no authored value, so the attribute
|
|
182
|
-
* goes back to being absent.
|
|
183
|
-
*/
|
|
184
134
|
#restore(element, attribute, marker, written) {
|
|
185
135
|
const recorded = element.getAttribute(marker);
|
|
186
136
|
if (recorded === null) return;
|
|
@@ -192,15 +142,6 @@ var OptimisticController = class extends Controller {
|
|
|
192
142
|
}
|
|
193
143
|
element.removeAttribute(attribute);
|
|
194
144
|
}
|
|
195
|
-
/**
|
|
196
|
-
* Puts back exactly the markup this controller displaced (record-owned only).
|
|
197
|
-
*
|
|
198
|
-
* A face can be registered on both sides, and the hide pass runs last, so what
|
|
199
|
-
* this controller wrote there is `hidden` — matching it against the reveal's
|
|
200
|
-
* absent value instead would read as someone else's write and leave the face
|
|
201
|
-
* hidden. Each target is therefore restored once, against the write it last
|
|
202
|
-
* received.
|
|
203
|
-
*/
|
|
204
145
|
#revert() {
|
|
205
146
|
TRANSIENT.reset(this.element);
|
|
206
147
|
this.#restore(this.element, "aria-busy", BUSY_MARKER, "true");
|
|
@@ -212,5 +153,4 @@ var OptimisticController = class extends Controller {
|
|
|
212
153
|
};
|
|
213
154
|
|
|
214
155
|
export { OptimisticController };
|
|
215
|
-
//# sourceMappingURL=optimistic_controller.js.map
|
|
216
156
|
//# sourceMappingURL=optimistic_controller.js.map
|