stimeo-ui 0.15.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +209 -0
- data/README.md +128 -1
- data/dist/cable/index.js +392 -417
- data/dist/controllers/accordion_controller.js +228 -28
- data/dist/controllers/alert_dialog_controller.js +862 -221
- data/dist/controllers/announcer_controller.js +135 -191
- data/dist/controllers/aspect_ratio_controller.js +0 -10
- data/dist/controllers/auto_submit_controller.js +295 -110
- data/dist/controllers/avatar_controller.js +172 -106
- data/dist/controllers/breadcrumb_controller.js +0 -129
- data/dist/controllers/bulk_select_controller.js +264 -53
- data/dist/controllers/calendar_controller.js +346 -180
- data/dist/controllers/carousel_controller.js +587 -300
- data/dist/controllers/character_counter_controller.js +271 -143
- data/dist/controllers/checkbox_controller.js +77 -75
- data/dist/controllers/clipboard_controller.js +187 -108
- data/dist/controllers/collapsible_controller.js +374 -108
- data/dist/controllers/color_picker_controller.js +183 -127
- data/dist/controllers/combobox_controller.js +426 -109
- data/dist/controllers/command_palette_controller.js +994 -350
- data/dist/controllers/conditional_fields_controller.js +212 -125
- data/dist/controllers/confirm_controller.js +939 -245
- data/dist/controllers/context_menu_controller.js +275 -127
- data/dist/controllers/count_up_controller.js +73 -21
- data/dist/controllers/countdown_controller.js +235 -97
- data/dist/controllers/currency_input_controller.js +241 -118
- data/dist/controllers/data_grid_controller.js +229 -135
- data/dist/controllers/date_range_picker_controller.js +359 -165
- data/dist/controllers/dialog_controller.js +887 -225
- data/dist/controllers/direct_upload_controller.js +80 -142
- data/dist/controllers/dirty_form_controller.js +26 -47
- data/dist/controllers/dismissible_controller.js +175 -20
- data/dist/controllers/drawer_controller.js +963 -336
- data/dist/controllers/dropdown_controller.js +342 -85
- data/dist/controllers/editable_controller.js +182 -58
- data/dist/controllers/empty_state_controller.js +67 -53
- data/dist/controllers/file_dropzone_controller.js +426 -229
- data/dist/controllers/filter_controller.js +78 -36
- data/dist/controllers/flash_controller.js +328 -211
- data/dist/controllers/focus_controller.js +654 -239
- data/dist/controllers/form_field_controller.js +153 -136
- data/dist/controllers/form_validation_controller.js +29 -96
- data/dist/controllers/frame_loading_controller.js +263 -198
- data/dist/controllers/highlight_controller.js +119 -70
- data/dist/controllers/hover_card_controller.js +335 -118
- data/dist/controllers/idle_controller.js +316 -65
- data/dist/controllers/input_mask_controller.js +116 -61
- data/dist/controllers/intersection_controller.js +147 -103
- data/dist/controllers/lazy_frame_controller.js +9 -56
- data/dist/controllers/listbox_controller.js +413 -153
- data/dist/controllers/local_time_controller.js +54 -64
- data/dist/controllers/masonry_controller.js +70 -95
- data/dist/controllers/menu_controller.js +254 -167
- data/dist/controllers/menubar_controller.js +206 -331
- data/dist/controllers/meter_controller.js +159 -71
- data/dist/controllers/multi_select_controller.js +797 -388
- data/dist/controllers/navigation_menu_controller.js +156 -231
- data/dist/controllers/nested_form_controller.js +373 -174
- data/dist/controllers/network_status_controller.js +241 -45
- data/dist/controllers/number_input_controller.js +387 -227
- data/dist/controllers/optimistic_controller.js +28 -75
- data/dist/controllers/otp_controller.js +344 -196
- data/dist/controllers/overflow_indicator_controller.js +167 -93
- data/dist/controllers/overflow_menu_controller.js +408 -277
- data/dist/controllers/pagination_controller.js +342 -120
- data/dist/controllers/password_reveal_controller.js +424 -99
- data/dist/controllers/password_strength_controller.js +99 -153
- data/dist/controllers/persist_controller.js +252 -96
- data/dist/controllers/pointer_drag_controller.js +263 -164
- data/dist/controllers/popover_controller.js +267 -94
- data/dist/controllers/portal_controller.js +209 -72
- data/dist/controllers/preview_guard_controller.js +243 -112
- data/dist/controllers/progress_controller.js +132 -59
- data/dist/controllers/radio_group_controller.js +138 -133
- data/dist/controllers/range_slider_controller.js +245 -112
- data/dist/controllers/rating_controller.js +429 -194
- data/dist/controllers/read_more_controller.js +185 -47
- 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 +294 -118
- data/dist/controllers/roving_controller.js +39 -84
- data/dist/controllers/scroll_area_controller.js +428 -221
- data/dist/controllers/scroll_restore_controller.js +0 -53
- data/dist/controllers/scroll_visibility_controller.js +395 -146
- data/dist/controllers/scrollspy_controller.js +181 -236
- data/dist/controllers/separator_controller.js +288 -132
- data/dist/controllers/sidebar_controller.js +1071 -375
- data/dist/controllers/skeleton_controller.js +248 -92
- data/dist/controllers/slider_controller.js +211 -96
- data/dist/controllers/smart_sticky_header_controller.js +163 -54
- data/dist/controllers/sortable_controller.js +13 -110
- data/dist/controllers/spinner_controller.js +277 -161
- data/dist/controllers/step_indicator_controller.js +107 -53
- data/dist/controllers/stepper_controller.js +171 -48
- data/dist/controllers/stick_to_bottom_controller.js +310 -116
- data/dist/controllers/sticky_observer_controller.js +214 -49
- data/dist/controllers/submit_once_controller.js +294 -192
- data/dist/controllers/switch_controller.js +107 -43
- data/dist/controllers/tabs_controller.js +50 -25
- data/dist/controllers/tags_input_controller.js +290 -149
- data/dist/controllers/textarea_autosize_controller.js +71 -58
- data/dist/controllers/theme_controller.js +148 -80
- data/dist/controllers/time_picker_controller.js +162 -81
- data/dist/controllers/toast_controller.js +365 -193
- data/dist/controllers/toggle_group_controller.js +194 -99
- data/dist/controllers/toolbar_controller.js +92 -90
- data/dist/controllers/tooltip_controller.js +185 -125
- data/dist/controllers/transition_controller.js +123 -115
- data/dist/controllers/tree_view_controller.js +248 -290
- data/dist/index.js +8649 -8572
- data/dist/positioning/index.js +148 -45
- data/lib/stimeo/ui/version.rb +1 -1
- metadata +3 -3
|
@@ -1,87 +1,64 @@
|
|
|
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
|
-
|
|
51
|
+
var TransientHooks = class {
|
|
52
|
+
#attributes;
|
|
53
|
+
constructor(options) {
|
|
54
|
+
this.#attributes = options.attributes;
|
|
55
|
+
}
|
|
56
|
+
reset(element) {
|
|
57
|
+
for (const attribute of this.#attributes) element.removeAttribute(attribute);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
var TRANSIENT = new TransientHooks({ attributes: ["data-optimistic"] });
|
|
85
62
|
var HIDDEN_MARKER = "data-optimistic-toggled";
|
|
86
63
|
var BUSY_MARKER = "data-optimistic-busy";
|
|
87
64
|
var AUTHORED_ABSENT = "absent";
|
|
@@ -94,11 +71,9 @@ function submissionOf(event) {
|
|
|
94
71
|
var OptimisticController = class extends Controller {
|
|
95
72
|
static targets = ["show", "hide"];
|
|
96
73
|
static events = ["commit", "rollback"];
|
|
97
|
-
/** The submission that owns the applied optimistic state, if any. */
|
|
98
74
|
#pending = null;
|
|
99
75
|
#gate = new DetachGate();
|
|
100
76
|
#listeners = new ListenerSet();
|
|
101
|
-
/** True between `connect()` and `disconnect()`, so a repeat connect rewinds nothing. */
|
|
102
77
|
#connected = false;
|
|
103
78
|
connect() {
|
|
104
79
|
const restored = !this.#connected && !this.#gate.pending;
|
|
@@ -141,12 +116,10 @@ var OptimisticController = class extends Controller {
|
|
|
141
116
|
this.dispatch("rollback");
|
|
142
117
|
}
|
|
143
118
|
};
|
|
144
|
-
/** Hides or reveals a target, recording the authored `hidden` on first write. */
|
|
145
119
|
#setHidden(target, hidden) {
|
|
146
120
|
if (target.hasAttribute("hidden") === hidden) return;
|
|
147
121
|
this.#write(target, "hidden", hidden ? "" : null, HIDDEN_MARKER);
|
|
148
122
|
}
|
|
149
|
-
/** Writes an attribute, recording what it displaced under `marker` once. */
|
|
150
123
|
#write(element, attribute, value, marker) {
|
|
151
124
|
if (!element.hasAttribute(marker)) {
|
|
152
125
|
const authored = element.getAttribute(attribute);
|
|
@@ -158,16 +131,6 @@ var OptimisticController = class extends Controller {
|
|
|
158
131
|
if (value === null) element.removeAttribute(attribute);
|
|
159
132
|
else element.setAttribute(attribute, value);
|
|
160
133
|
}
|
|
161
|
-
/**
|
|
162
|
-
* Puts back the value `marker` recorded and drops the record.
|
|
163
|
-
*
|
|
164
|
-
* `written` is what this controller last put in the attribute. Anything else
|
|
165
|
-
* there now belongs to whoever wrote it — Turbo owns `aria-busy` on a form and
|
|
166
|
-
* clears it before the terminal arrives, and a consumer may have moved a face
|
|
167
|
-
* mid-flight — so the record is dropped without touching the attribute. A
|
|
168
|
-
* marker this build did not write names no authored value, so the attribute
|
|
169
|
-
* goes back to being absent.
|
|
170
|
-
*/
|
|
171
134
|
#restore(element, attribute, marker, written) {
|
|
172
135
|
const recorded = element.getAttribute(marker);
|
|
173
136
|
if (recorded === null) return;
|
|
@@ -179,17 +142,8 @@ var OptimisticController = class extends Controller {
|
|
|
179
142
|
}
|
|
180
143
|
element.removeAttribute(attribute);
|
|
181
144
|
}
|
|
182
|
-
/**
|
|
183
|
-
* Puts back exactly the markup this controller displaced (record-owned only).
|
|
184
|
-
*
|
|
185
|
-
* A face can be registered on both sides, and the hide pass runs last, so what
|
|
186
|
-
* this controller wrote there is `hidden` — matching it against the reveal's
|
|
187
|
-
* absent value instead would read as someone else's write and leave the face
|
|
188
|
-
* hidden. Each target is therefore restored once, against the write it last
|
|
189
|
-
* received.
|
|
190
|
-
*/
|
|
191
145
|
#revert() {
|
|
192
|
-
this.element
|
|
146
|
+
TRANSIENT.reset(this.element);
|
|
193
147
|
this.#restore(this.element, "aria-busy", BUSY_MARKER, "true");
|
|
194
148
|
const hidden = new Set(this.hideTargets);
|
|
195
149
|
for (const target of /* @__PURE__ */ new Set([...this.showTargets, ...this.hideTargets])) {
|
|
@@ -199,5 +153,4 @@ var OptimisticController = class extends Controller {
|
|
|
199
153
|
};
|
|
200
154
|
|
|
201
155
|
export { OptimisticController };
|
|
202
|
-
//# sourceMappingURL=optimistic_controller.js.map
|
|
203
156
|
//# sourceMappingURL=optimistic_controller.js.map
|