stimeo-ui 0.18.1 → 0.18.2
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 +21 -0
- data/dist/cable/index.js +6 -5
- data/dist/controllers/alert_dialog_controller.js +89 -45
- data/dist/controllers/announcer_controller.js +22 -9
- data/dist/controllers/auto_submit_controller.js +77 -11
- data/dist/controllers/bulk_select_controller.js +6 -9
- data/dist/controllers/character_counter_controller.js +77 -11
- data/dist/controllers/clipboard_controller.js +6 -5
- data/dist/controllers/combobox_controller.js +71 -6
- data/dist/controllers/command_palette_controller.js +160 -51
- data/dist/controllers/conditional_fields_controller.js +84 -44
- data/dist/controllers/confirm_controller.js +89 -45
- data/dist/controllers/context_menu_controller.js +1 -1
- data/dist/controllers/countdown_controller.js +6 -5
- data/dist/controllers/currency_input_controller.js +71 -6
- data/dist/controllers/data_grid_controller.js +77 -42
- data/dist/controllers/date_range_picker_controller.js +2 -1
- data/dist/controllers/dialog_controller.js +89 -45
- data/dist/controllers/direct_upload_controller.js +6 -5
- data/dist/controllers/dismissible_controller.js +11 -7
- data/dist/controllers/drawer_controller.js +89 -45
- data/dist/controllers/dropdown_controller.js +1 -1
- data/dist/controllers/editable_controller.js +71 -6
- data/dist/controllers/empty_state_controller.js +6 -5
- data/dist/controllers/file_dropzone_controller.js +13 -11
- data/dist/controllers/flash_controller.js +6 -5
- data/dist/controllers/focus_controller.js +89 -45
- data/dist/controllers/form_field_controller.js +6 -5
- data/dist/controllers/form_validation_controller.js +11 -7
- data/dist/controllers/frame_loading_controller.js +50 -16
- data/dist/controllers/hover_card_controller.js +1 -1
- data/dist/controllers/input_mask_controller.js +94 -36
- data/dist/controllers/intersection_controller.js +61 -29
- data/dist/controllers/lazy_frame_controller.js +61 -29
- data/dist/controllers/listbox_controller.js +80 -47
- data/dist/controllers/local_time_controller.js +1 -7
- data/dist/controllers/menu_controller.js +1 -1
- data/dist/controllers/menubar_controller.js +4 -6
- data/dist/controllers/meter_controller.js +6 -5
- data/dist/controllers/multi_select_controller.js +86 -21
- data/dist/controllers/navigation_menu_controller.js +1 -1
- data/dist/controllers/nested_form_controller.js +17 -12
- data/dist/controllers/network_status_controller.js +6 -5
- data/dist/controllers/number_input_controller.js +154 -66
- data/dist/controllers/otp_controller.js +71 -6
- data/dist/controllers/overflow_menu_controller.js +7 -2
- data/dist/controllers/pagination_controller.js +7 -2
- data/dist/controllers/password_strength_controller.js +6 -5
- data/dist/controllers/popover_controller.js +12 -8
- data/dist/controllers/progress_controller.js +6 -5
- data/dist/controllers/radio_group_controller.js +85 -49
- data/dist/controllers/range_slider_controller.js +72 -54
- data/dist/controllers/relative_time_controller.js +1 -7
- data/dist/controllers/roving_controller.js +7 -2
- data/dist/controllers/scroll_area_controller.js +11 -7
- data/dist/controllers/scrollspy_controller.js +61 -29
- data/dist/controllers/separator_controller.js +72 -54
- data/dist/controllers/sidebar_controller.js +89 -45
- data/dist/controllers/skeleton_controller.js +50 -16
- data/dist/controllers/slider_controller.js +72 -54
- data/dist/controllers/sortable_controller.js +6 -5
- data/dist/controllers/spinner_controller.js +50 -16
- data/dist/controllers/sticky_observer_controller.js +61 -29
- data/dist/controllers/submit_once_controller.js +6 -5
- data/dist/controllers/switch_controller.js +84 -44
- data/dist/controllers/tags_input_controller.js +83 -20
- data/dist/controllers/time_picker_controller.js +77 -42
- data/dist/controllers/toggle_group_controller.js +84 -44
- data/dist/controllers/toolbar_controller.js +78 -8
- data/dist/controllers/tooltip_controller.js +1 -1
- data/dist/controllers/tree_view_controller.js +87 -49
- data/dist/index.js +503 -286
- data/lib/stimeo/ui/version.rb +1 -1
- metadata +2 -2
|
@@ -7,14 +7,15 @@ function fillTemplate(template, values) {
|
|
|
7
7
|
});
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
var afterFocus = /* @__PURE__ */ Symbol.for("stimeo--announcer:after-focus");
|
|
10
11
|
function announce(message, options = {}) {
|
|
11
12
|
const text = message.trim();
|
|
12
13
|
if (text.length === 0) return;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
);
|
|
14
|
+
const event = new CustomEvent("stimeo--announcer:announce", {
|
|
15
|
+
detail: { message: text, assertive: options.assertive === true }
|
|
16
|
+
});
|
|
17
|
+
if (options.afterFocus) event[afterFocus] = true;
|
|
18
|
+
window.dispatchEvent(event);
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
function setAttributeIfChanged(element, name, value, beforeWrite) {
|
|
@@ -209,7 +210,7 @@ var DetachGate = class _DetachGate {
|
|
|
209
210
|
|
|
210
211
|
var MinDurationFloor = class {
|
|
211
212
|
#timers;
|
|
212
|
-
#
|
|
213
|
+
#task = null;
|
|
213
214
|
#since = 0;
|
|
214
215
|
constructor(timers) {
|
|
215
216
|
this.#timers = timers;
|
|
@@ -218,25 +219,19 @@ var MinDurationFloor = class {
|
|
|
218
219
|
this.#since = Date.now();
|
|
219
220
|
}
|
|
220
221
|
get pending() {
|
|
221
|
-
return this.#
|
|
222
|
+
return this.#task?.pending ?? false;
|
|
222
223
|
}
|
|
223
224
|
schedule(minDuration, finish) {
|
|
224
225
|
this.cancel();
|
|
225
226
|
const remaining = minDuration - (Date.now() - this.#since);
|
|
226
227
|
if (remaining > 0) {
|
|
227
|
-
this.#
|
|
228
|
-
this.#timerId = null;
|
|
229
|
-
finish();
|
|
230
|
-
}, remaining);
|
|
228
|
+
this.#task = this.#timers.setTask(finish, remaining);
|
|
231
229
|
} else {
|
|
232
230
|
finish();
|
|
233
231
|
}
|
|
234
232
|
}
|
|
235
233
|
cancel() {
|
|
236
|
-
|
|
237
|
-
this.#timers.clear(this.#timerId);
|
|
238
|
-
this.#timerId = null;
|
|
239
|
-
}
|
|
234
|
+
this.#task?.cancel();
|
|
240
235
|
}
|
|
241
236
|
};
|
|
242
237
|
|
|
@@ -303,6 +298,22 @@ var TimerRegistry = class {
|
|
|
303
298
|
return this.ids.size;
|
|
304
299
|
}
|
|
305
300
|
};
|
|
301
|
+
var TimeoutRegistration = class {
|
|
302
|
+
#registration;
|
|
303
|
+
constructor(owner, id) {
|
|
304
|
+
this.#registration = { owner, id };
|
|
305
|
+
}
|
|
306
|
+
get pending() {
|
|
307
|
+
return this.#registration !== null;
|
|
308
|
+
}
|
|
309
|
+
cancel() {
|
|
310
|
+
const registration = this.#registration;
|
|
311
|
+
if (registration) registration.owner.clear(registration.id);
|
|
312
|
+
}
|
|
313
|
+
expire() {
|
|
314
|
+
this.#registration = null;
|
|
315
|
+
}
|
|
316
|
+
};
|
|
306
317
|
var SafeTimeout = class extends TimerRegistry {
|
|
307
318
|
set(callback, delay) {
|
|
308
319
|
const id = this.schedule(() => {
|
|
@@ -319,6 +330,29 @@ var SafeTimeout = class extends TimerRegistry {
|
|
|
319
330
|
window.clearTimeout(id);
|
|
320
331
|
}
|
|
321
332
|
};
|
|
333
|
+
var TaskTimeout = class extends SafeTimeout {
|
|
334
|
+
#tasks = /* @__PURE__ */ new Map();
|
|
335
|
+
setTask(callback, delay) {
|
|
336
|
+
const id = this.set(() => {
|
|
337
|
+
this.#tasks.delete(id);
|
|
338
|
+
registration.expire();
|
|
339
|
+
callback();
|
|
340
|
+
}, delay);
|
|
341
|
+
const registration = new TimeoutRegistration(this, id);
|
|
342
|
+
this.#tasks.set(id, registration);
|
|
343
|
+
return registration;
|
|
344
|
+
}
|
|
345
|
+
clear(id) {
|
|
346
|
+
this.#tasks.get(id)?.expire();
|
|
347
|
+
this.#tasks.delete(id);
|
|
348
|
+
super.clear(id);
|
|
349
|
+
}
|
|
350
|
+
clearAll() {
|
|
351
|
+
for (const registration of this.#tasks.values()) registration.expire();
|
|
352
|
+
this.#tasks.clear();
|
|
353
|
+
super.clearAll();
|
|
354
|
+
}
|
|
355
|
+
};
|
|
322
356
|
|
|
323
357
|
var SkeletonController = class _SkeletonController extends Controller {
|
|
324
358
|
#numbers = new NumberValueReader();
|
|
@@ -332,7 +366,7 @@ var SkeletonController = class _SkeletonController extends Controller {
|
|
|
332
366
|
};
|
|
333
367
|
static actions = ["ready", "reset"];
|
|
334
368
|
static events = ["ready"];
|
|
335
|
-
#timers = new
|
|
369
|
+
#timers = new TaskTimeout();
|
|
336
370
|
#floor = new MinDurationFloor(this.#timers);
|
|
337
371
|
#gate = new DetachGate();
|
|
338
372
|
#hidden = new AttributeLease("hidden", this.identifier);
|
|
@@ -227,25 +227,22 @@ function snapSteppedValue(raw, range) {
|
|
|
227
227
|
if (!(range.min <= range.max)) return finiteFallback(range.min, range.max);
|
|
228
228
|
const input = Number.isNaN(raw) ? finiteFallback(range.min, range.max) : raw;
|
|
229
229
|
const clamped = Math.min(range.max, Math.max(range.min, input));
|
|
230
|
-
const
|
|
231
|
-
const base = stepBase(range);
|
|
230
|
+
const grid = stepGrid(range);
|
|
232
231
|
const candidates = [];
|
|
233
232
|
if (Number.isFinite(range.min)) candidates.push(range.min);
|
|
234
233
|
if (Number.isFinite(range.max)) candidates.push(range.max);
|
|
235
|
-
const
|
|
236
|
-
if (Number.isFinite(
|
|
237
|
-
|
|
238
|
-
|
|
234
|
+
const position = gridPosition(clamped, grid);
|
|
235
|
+
if (Number.isFinite(position)) {
|
|
236
|
+
for (const index of [Math.floor(position), Math.ceil(position)]) {
|
|
237
|
+
const candidate = gridValue(index, grid);
|
|
238
|
+
if (inRange(candidate, range)) candidates.push(candidate);
|
|
239
|
+
}
|
|
239
240
|
}
|
|
240
241
|
if (candidates.length === 0) return clamped;
|
|
241
242
|
let nearest = candidates[0];
|
|
242
|
-
let nearestDistance = Math.abs(clamped - nearest);
|
|
243
243
|
for (const candidate of candidates.slice(1)) {
|
|
244
|
-
const
|
|
245
|
-
if (
|
|
246
|
-
nearest = candidate;
|
|
247
|
-
nearestDistance = distance;
|
|
248
|
-
}
|
|
244
|
+
const nearer = isMidpoint(clamped, candidate, nearest, range, grid) ? candidate > nearest : Math.abs(clamped - candidate) < Math.abs(clamped - nearest);
|
|
245
|
+
if (nearer) nearest = candidate;
|
|
249
246
|
}
|
|
250
247
|
return nearest;
|
|
251
248
|
}
|
|
@@ -254,46 +251,36 @@ function stepSteppedValue(current, count, range) {
|
|
|
254
251
|
const distance = Math.abs(Math.trunc(count));
|
|
255
252
|
if (!Number.isFinite(distance) || distance === 0) return value;
|
|
256
253
|
const direction = Math.sign(count);
|
|
257
|
-
const adjacent =
|
|
254
|
+
const adjacent = nextGridValue(value, direction, range);
|
|
255
|
+
if (adjacent === value) return value;
|
|
258
256
|
const raw = adjacent + direction * (distance - 1) * effectiveStep(range.step);
|
|
259
|
-
|
|
257
|
+
const endpoint = direction > 0 ? range.max : range.min;
|
|
258
|
+
return Number.isFinite(raw) || Number.isFinite(endpoint) ? snapSteppedValue(raw, range) : value;
|
|
260
259
|
}
|
|
261
|
-
function
|
|
260
|
+
function nextGridValue(current, direction, range) {
|
|
261
|
+
const grid = stepGrid(range);
|
|
262
|
+
const position = gridPosition(current, grid);
|
|
263
|
+
if (!Number.isFinite(position)) return current;
|
|
264
|
+
const index = direction > 0 ? Math.floor(position) + 1 : Math.ceil(position) - 1;
|
|
265
|
+
const first = gridValue(index, grid);
|
|
266
|
+
if (direction * (first - current) > 0 && !sameGridValue(first, current, grid.step)) {
|
|
267
|
+
return first;
|
|
268
|
+
}
|
|
269
|
+
const second = gridValue(index + direction, grid);
|
|
270
|
+
return direction * (second - current) > 0 ? second : current;
|
|
271
|
+
}
|
|
272
|
+
function stepGrid(range) {
|
|
262
273
|
const step = effectiveStep(range.step);
|
|
263
274
|
const base = stepBase(range);
|
|
264
|
-
const
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
if (candidate < current || nearlyEqual(candidate, current)) {
|
|
271
|
-
gridIndex += 1;
|
|
272
|
-
candidate = cleanGridValue(base + gridIndex * step, base, step);
|
|
273
|
-
}
|
|
274
|
-
if (candidate > current && !nearlyEqual(candidate, current) && within(candidate, range.min, range.max)) {
|
|
275
|
-
candidates.push(clamp(candidate, range));
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
return clamp(Math.min(...candidates), range);
|
|
279
|
-
}
|
|
280
|
-
const position = (current - base) / step;
|
|
281
|
-
if (Number.isFinite(position)) {
|
|
282
|
-
let gridIndex = Math.ceil(position) - 1;
|
|
283
|
-
let candidate = cleanGridValue(base + gridIndex * step, base, step);
|
|
284
|
-
if (candidate > current || nearlyEqual(candidate, current)) {
|
|
285
|
-
gridIndex -= 1;
|
|
286
|
-
candidate = cleanGridValue(base + gridIndex * step, base, step);
|
|
287
|
-
}
|
|
288
|
-
if (candidate < current && !nearlyEqual(candidate, current) && within(candidate, range.min, range.max)) {
|
|
289
|
-
candidates.push(clamp(candidate, range));
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
return clamp(Math.max(...candidates), range);
|
|
275
|
+
const near = base - Math.trunc(base / step) * step;
|
|
276
|
+
const origin = cleanGridValue(Number.isFinite(near) ? near % step : base % step, base, step);
|
|
277
|
+
return { step, base, origin };
|
|
278
|
+
}
|
|
279
|
+
function gridPosition(value, grid) {
|
|
280
|
+
return value / grid.step - grid.origin / grid.step;
|
|
293
281
|
}
|
|
294
|
-
function
|
|
295
|
-
|
|
296
|
-
if (within(candidate, range.min, range.max)) candidates.push(clamp(candidate, range));
|
|
282
|
+
function gridValue(index, grid) {
|
|
283
|
+
return cleanGridValue(grid.origin + index * grid.step, grid.base, grid.step);
|
|
297
284
|
}
|
|
298
285
|
function stepBase(range) {
|
|
299
286
|
if (range.base !== void 0 && Number.isFinite(range.base)) return range.base;
|
|
@@ -309,15 +296,46 @@ function decimalPlaces(value) {
|
|
|
309
296
|
const exponent = exponentText === void 0 ? 0 : Number(exponentText);
|
|
310
297
|
return Math.max(0, fractionLength - exponent);
|
|
311
298
|
}
|
|
312
|
-
function
|
|
313
|
-
return (value
|
|
299
|
+
function inRange(value, range) {
|
|
300
|
+
return Number.isFinite(value) && value >= range.min && value <= range.max;
|
|
301
|
+
}
|
|
302
|
+
function sameGridValue(left, right, step) {
|
|
303
|
+
const rounding = Number.EPSILON * Math.max(Math.abs(left), Math.abs(right));
|
|
304
|
+
return Math.abs(left - right) <= Math.min(rounding, step / 4);
|
|
305
|
+
}
|
|
306
|
+
function isMidpoint(value, left, right, range, grid) {
|
|
307
|
+
const imbalance = Math.abs(Math.abs(value - left) - Math.abs(value - right));
|
|
308
|
+
const rounding = 4 * Number.EPSILON * Math.max(Math.abs(value), Math.abs(left), Math.abs(right));
|
|
309
|
+
if (!(imbalance <= rounding)) return false;
|
|
310
|
+
if (imbalance <= Math.abs(left - right) / 4) return true;
|
|
311
|
+
const lower = Math.min(left, right);
|
|
312
|
+
const upper = Math.max(left, right);
|
|
313
|
+
return value > lower && value < upper && isDecimalMidpoint(value, lower, upper, range, grid);
|
|
314
314
|
}
|
|
315
|
-
function
|
|
316
|
-
|
|
315
|
+
function isDecimalMidpoint(value, lower, upper, range, grid) {
|
|
316
|
+
const raw = decimalParts(value);
|
|
317
|
+
const base = decimalParts(grid.base);
|
|
318
|
+
const step = decimalParts(grid.step);
|
|
319
|
+
const min = decimalParts(lower);
|
|
320
|
+
const max = decimalParts(upper);
|
|
321
|
+
const place = Math.min(raw.place, base.place, step.place, min.place, max.place);
|
|
322
|
+
const units = (part) => part.units * 10n ** BigInt(part.place - place);
|
|
323
|
+
const origin = units(base);
|
|
324
|
+
const stride = units(step);
|
|
325
|
+
const rawUnits = units(raw);
|
|
326
|
+
const remainder = (rawUnits - origin) % stride;
|
|
327
|
+
const below = rawUnits - (remainder < 0n ? remainder + stride : remainder);
|
|
328
|
+
const above = below + stride;
|
|
329
|
+
const minUnits = units(min);
|
|
330
|
+
const maxUnits = units(max);
|
|
331
|
+
const lowerUnits = lower === range.min && minUnits > below ? minUnits : below;
|
|
332
|
+
const upperUnits = upper === range.max && maxUnits < above ? maxUnits : above;
|
|
333
|
+
return Number(`${lowerUnits}e${place}`) === lower && Number(`${upperUnits}e${place}`) === upper && Number(`${(lowerUnits + upperUnits) * 5n}e${place - 1}`) === value;
|
|
317
334
|
}
|
|
318
|
-
function
|
|
319
|
-
const
|
|
320
|
-
|
|
335
|
+
function decimalParts(value) {
|
|
336
|
+
const [coefficient = "", exponent = "0"] = value.toString().split("e");
|
|
337
|
+
const [whole = "", fraction = ""] = coefficient.split(".");
|
|
338
|
+
return { units: BigInt(whole + fraction), place: Number(exponent) - fraction.length };
|
|
321
339
|
}
|
|
322
340
|
function finiteFallback(min, max) {
|
|
323
341
|
if (Number.isFinite(min)) return min;
|
|
@@ -7,14 +7,15 @@ function fillTemplate(template, values) {
|
|
|
7
7
|
});
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
var afterFocus = /* @__PURE__ */ Symbol.for("stimeo--announcer:after-focus");
|
|
10
11
|
function announce(message, options = {}) {
|
|
11
12
|
const text = message.trim();
|
|
12
13
|
if (text.length === 0) return;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
);
|
|
14
|
+
const event = new CustomEvent("stimeo--announcer:announce", {
|
|
15
|
+
detail: { message: text, assertive: options.assertive === true }
|
|
16
|
+
});
|
|
17
|
+
if (options.afterFocus) event[afterFocus] = true;
|
|
18
|
+
window.dispatchEvent(event);
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
var ListenerSet = class {
|
|
@@ -7,14 +7,15 @@ function fillTemplate(template, values) {
|
|
|
7
7
|
});
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
var afterFocus = /* @__PURE__ */ Symbol.for("stimeo--announcer:after-focus");
|
|
10
11
|
function announce(message, options = {}) {
|
|
11
12
|
const text = message.trim();
|
|
12
13
|
if (text.length === 0) return;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
);
|
|
14
|
+
const event = new CustomEvent("stimeo--announcer:announce", {
|
|
15
|
+
detail: { message: text, assertive: options.assertive === true }
|
|
16
|
+
});
|
|
17
|
+
if (options.afterFocus) event[afterFocus] = true;
|
|
18
|
+
window.dispatchEvent(event);
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
function setAttributeIfChanged(element, name, value, beforeWrite) {
|
|
@@ -215,7 +216,7 @@ var DetachGate = class _DetachGate {
|
|
|
215
216
|
|
|
216
217
|
var MinDurationFloor = class {
|
|
217
218
|
#timers;
|
|
218
|
-
#
|
|
219
|
+
#task = null;
|
|
219
220
|
#since = 0;
|
|
220
221
|
constructor(timers) {
|
|
221
222
|
this.#timers = timers;
|
|
@@ -224,25 +225,19 @@ var MinDurationFloor = class {
|
|
|
224
225
|
this.#since = Date.now();
|
|
225
226
|
}
|
|
226
227
|
get pending() {
|
|
227
|
-
return this.#
|
|
228
|
+
return this.#task?.pending ?? false;
|
|
228
229
|
}
|
|
229
230
|
schedule(minDuration, finish) {
|
|
230
231
|
this.cancel();
|
|
231
232
|
const remaining = minDuration - (Date.now() - this.#since);
|
|
232
233
|
if (remaining > 0) {
|
|
233
|
-
this.#
|
|
234
|
-
this.#timerId = null;
|
|
235
|
-
finish();
|
|
236
|
-
}, remaining);
|
|
234
|
+
this.#task = this.#timers.setTask(finish, remaining);
|
|
237
235
|
} else {
|
|
238
236
|
finish();
|
|
239
237
|
}
|
|
240
238
|
}
|
|
241
239
|
cancel() {
|
|
242
|
-
|
|
243
|
-
this.#timers.clear(this.#timerId);
|
|
244
|
-
this.#timerId = null;
|
|
245
|
-
}
|
|
240
|
+
this.#task?.cancel();
|
|
246
241
|
}
|
|
247
242
|
};
|
|
248
243
|
|
|
@@ -309,6 +304,22 @@ var TimerRegistry = class {
|
|
|
309
304
|
return this.ids.size;
|
|
310
305
|
}
|
|
311
306
|
};
|
|
307
|
+
var TimeoutRegistration = class {
|
|
308
|
+
#registration;
|
|
309
|
+
constructor(owner, id) {
|
|
310
|
+
this.#registration = { owner, id };
|
|
311
|
+
}
|
|
312
|
+
get pending() {
|
|
313
|
+
return this.#registration !== null;
|
|
314
|
+
}
|
|
315
|
+
cancel() {
|
|
316
|
+
const registration = this.#registration;
|
|
317
|
+
if (registration) registration.owner.clear(registration.id);
|
|
318
|
+
}
|
|
319
|
+
expire() {
|
|
320
|
+
this.#registration = null;
|
|
321
|
+
}
|
|
322
|
+
};
|
|
312
323
|
var SafeTimeout = class extends TimerRegistry {
|
|
313
324
|
set(callback, delay) {
|
|
314
325
|
const id = this.schedule(() => {
|
|
@@ -325,6 +336,29 @@ var SafeTimeout = class extends TimerRegistry {
|
|
|
325
336
|
window.clearTimeout(id);
|
|
326
337
|
}
|
|
327
338
|
};
|
|
339
|
+
var TaskTimeout = class extends SafeTimeout {
|
|
340
|
+
#tasks = /* @__PURE__ */ new Map();
|
|
341
|
+
setTask(callback, delay) {
|
|
342
|
+
const id = this.set(() => {
|
|
343
|
+
this.#tasks.delete(id);
|
|
344
|
+
registration.expire();
|
|
345
|
+
callback();
|
|
346
|
+
}, delay);
|
|
347
|
+
const registration = new TimeoutRegistration(this, id);
|
|
348
|
+
this.#tasks.set(id, registration);
|
|
349
|
+
return registration;
|
|
350
|
+
}
|
|
351
|
+
clear(id) {
|
|
352
|
+
this.#tasks.get(id)?.expire();
|
|
353
|
+
this.#tasks.delete(id);
|
|
354
|
+
super.clear(id);
|
|
355
|
+
}
|
|
356
|
+
clearAll() {
|
|
357
|
+
for (const registration of this.#tasks.values()) registration.expire();
|
|
358
|
+
this.#tasks.clear();
|
|
359
|
+
super.clearAll();
|
|
360
|
+
}
|
|
361
|
+
};
|
|
328
362
|
|
|
329
363
|
var SpinnerController = class _SpinnerController extends Controller {
|
|
330
364
|
#numbers = new NumberValueReader();
|
|
@@ -343,7 +377,7 @@ var SpinnerController = class _SpinnerController extends Controller {
|
|
|
343
377
|
};
|
|
344
378
|
static actions = ["start", "stop"];
|
|
345
379
|
static events = ["hide", "show", "timeout", "reconcile"];
|
|
346
|
-
#timers = new
|
|
380
|
+
#timers = new TaskTimeout();
|
|
347
381
|
#floor = new MinDurationFloor(this.#timers);
|
|
348
382
|
#gate = new DetachGate();
|
|
349
383
|
#busyLease = new AttributeLease("aria-busy", this.identifier);
|
|
@@ -173,70 +173,102 @@ function queryRoot(selector) {
|
|
|
173
173
|
}
|
|
174
174
|
var IntersectionWatcher = class {
|
|
175
175
|
#onEntries;
|
|
176
|
-
#
|
|
177
|
-
#active = false;
|
|
178
|
-
#usingPlatformDefaults = false;
|
|
176
|
+
#session = null;
|
|
179
177
|
constructor(onEntries) {
|
|
180
178
|
this.#onEntries = onEntries;
|
|
181
179
|
}
|
|
182
180
|
get active() {
|
|
183
|
-
return this.#active;
|
|
181
|
+
return this.#session?.active ?? false;
|
|
184
182
|
}
|
|
185
183
|
get usingPlatformDefaults() {
|
|
186
|
-
return this.#usingPlatformDefaults;
|
|
184
|
+
return this.#session?.usingPlatformDefaults ?? false;
|
|
187
185
|
}
|
|
188
186
|
start(targets, options = {}) {
|
|
189
|
-
this
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
187
|
+
const previous = this.#session;
|
|
188
|
+
const session = {
|
|
189
|
+
observer: null,
|
|
190
|
+
active: false,
|
|
191
|
+
usingPlatformDefaults: false
|
|
192
|
+
};
|
|
193
|
+
this.#session = session;
|
|
194
194
|
let observer = null;
|
|
195
195
|
try {
|
|
196
|
+
if (previous) this.#release(previous);
|
|
197
|
+
if (this.#session !== session) return false;
|
|
198
|
+
if (typeof IntersectionObserver === "undefined") return false;
|
|
199
|
+
const list = Array.isArray(targets) ? targets : [targets];
|
|
200
|
+
const empty = list.length === 0;
|
|
201
|
+
if (this.#session !== session) return false;
|
|
202
|
+
if (empty) return false;
|
|
203
|
+
const root = "root" in options ? options.root ?? null : queryRoot(options.rootSelector);
|
|
204
|
+
if (this.#session !== session) return false;
|
|
196
205
|
const onEntries = (entries) => {
|
|
197
|
-
if (this.#
|
|
206
|
+
if (this.#session === session && session.active) this.#onEntries(entries);
|
|
198
207
|
};
|
|
208
|
+
let usingPlatformDefaults = false;
|
|
199
209
|
try {
|
|
200
|
-
|
|
210
|
+
const configured = {
|
|
201
211
|
root,
|
|
202
212
|
rootMargin: options.rootMargin,
|
|
203
213
|
threshold: options.threshold
|
|
204
|
-
}
|
|
214
|
+
};
|
|
215
|
+
if (this.#session !== session) return false;
|
|
216
|
+
observer = new IntersectionObserver(onEntries, configured);
|
|
205
217
|
} catch (error) {
|
|
218
|
+
if (this.#session !== session) return false;
|
|
206
219
|
console.warn(
|
|
207
220
|
"Stimeo UI: IntersectionObserver could not be constructed with the configured options; retrying with platform defaults.",
|
|
208
221
|
error
|
|
209
222
|
);
|
|
223
|
+
if (this.#session !== session) return false;
|
|
210
224
|
observer = new IntersectionObserver(onEntries, { root });
|
|
211
|
-
|
|
225
|
+
usingPlatformDefaults = true;
|
|
226
|
+
}
|
|
227
|
+
if (this.#session !== session) {
|
|
228
|
+
this.#release(session, observer);
|
|
229
|
+
return false;
|
|
212
230
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
231
|
+
session.observer = observer;
|
|
232
|
+
for (const target of list) {
|
|
233
|
+
if (this.#session !== session) return false;
|
|
234
|
+
observer.observe(target);
|
|
235
|
+
if (this.#session !== session) {
|
|
236
|
+
this.#release(session, observer);
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
if (this.#session !== session) return false;
|
|
241
|
+
session.usingPlatformDefaults = usingPlatformDefaults;
|
|
242
|
+
session.active = true;
|
|
216
243
|
return true;
|
|
217
244
|
} catch (error) {
|
|
218
|
-
observer
|
|
219
|
-
this.#observer = null;
|
|
220
|
-
this.#active = false;
|
|
221
|
-
this.#usingPlatformDefaults = false;
|
|
245
|
+
this.#release(session, observer);
|
|
222
246
|
throw error;
|
|
223
247
|
}
|
|
224
248
|
}
|
|
225
249
|
rearm(target) {
|
|
226
|
-
|
|
250
|
+
const session = this.#session;
|
|
251
|
+
const observer = session?.observer;
|
|
252
|
+
if (!session?.active || !observer) return;
|
|
227
253
|
try {
|
|
228
|
-
|
|
229
|
-
this.#
|
|
254
|
+
observer.unobserve(target);
|
|
255
|
+
if (this.#session !== session) return;
|
|
256
|
+
observer.observe(target);
|
|
257
|
+
if (this.#session !== session) this.#release(session, observer);
|
|
230
258
|
} catch (error) {
|
|
231
|
-
this
|
|
259
|
+
if (this.#session === session) this.#session = null;
|
|
260
|
+
this.#release(session, observer);
|
|
232
261
|
throw error;
|
|
233
262
|
}
|
|
234
263
|
}
|
|
235
264
|
stop() {
|
|
236
|
-
|
|
237
|
-
this.#
|
|
238
|
-
this.#
|
|
239
|
-
|
|
265
|
+
const session = this.#session;
|
|
266
|
+
this.#session = null;
|
|
267
|
+
if (session) this.#release(session);
|
|
268
|
+
}
|
|
269
|
+
#release(session, observer = session.observer) {
|
|
270
|
+
session.observer = null;
|
|
271
|
+
observer?.disconnect();
|
|
240
272
|
}
|
|
241
273
|
};
|
|
242
274
|
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Controller } from '@hotwired/stimulus';
|
|
2
2
|
|
|
3
|
+
var afterFocus = /* @__PURE__ */ Symbol.for("stimeo--announcer:after-focus");
|
|
3
4
|
function announce(message, options = {}) {
|
|
4
5
|
const text = message.trim();
|
|
5
6
|
if (text.length === 0) return;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
);
|
|
7
|
+
const event = new CustomEvent("stimeo--announcer:announce", {
|
|
8
|
+
detail: { message: text, assertive: options.assertive === true }
|
|
9
|
+
});
|
|
10
|
+
if (options.afterFocus) event[afterFocus] = true;
|
|
11
|
+
window.dispatchEvent(event);
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
function setAttributeIfChanged(element, name, value, beforeWrite) {
|