stimeo-ui 0.17.0 → 0.18.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 +106 -1
- data/README.md +19 -10
- data/dist/cable/index.js +22 -14
- data/dist/controllers/accordion_controller.js +14 -6
- data/dist/controllers/alert_dialog_controller.js +145 -118
- data/dist/controllers/announcer_controller.js +113 -17
- data/dist/controllers/auto_submit_controller.js +185 -60
- data/dist/controllers/avatar_controller.js +55 -43
- data/dist/controllers/bulk_select_controller.js +64 -50
- data/dist/controllers/calendar_controller.js +55 -53
- data/dist/controllers/carousel_controller.js +124 -86
- data/dist/controllers/character_counter_controller.js +291 -95
- data/dist/controllers/checkbox_controller.js +6 -0
- data/dist/controllers/clipboard_controller.js +118 -27
- data/dist/controllers/collapsible_controller.js +52 -49
- data/dist/controllers/color_picker_controller.js +29 -7
- data/dist/controllers/combobox_controller.js +210 -71
- data/dist/controllers/command_palette_controller.js +289 -140
- data/dist/controllers/conditional_fields_controller.js +145 -58
- data/dist/controllers/confirm_controller.js +145 -118
- data/dist/controllers/context_menu_controller.js +138 -73
- data/dist/controllers/countdown_controller.js +109 -21
- data/dist/controllers/currency_input_controller.js +446 -72
- data/dist/controllers/data_grid_controller.js +134 -28
- data/dist/controllers/date_range_picker_controller.js +93 -72
- data/dist/controllers/dialog_controller.js +145 -118
- data/dist/controllers/direct_upload_controller.js +24 -14
- data/dist/controllers/dirty_form_controller.js +68 -31
- data/dist/controllers/dismissible_controller.js +64 -46
- data/dist/controllers/drawer_controller.js +145 -118
- data/dist/controllers/dropdown_controller.js +76 -63
- data/dist/controllers/editable_controller.js +199 -62
- data/dist/controllers/empty_state_controller.js +13 -6
- data/dist/controllers/file_dropzone_controller.js +55 -48
- data/dist/controllers/filter_controller.js +9 -2
- data/dist/controllers/flash_controller.js +66 -33
- data/dist/controllers/focus_controller.js +39 -14
- data/dist/controllers/form_field_controller.js +52 -43
- data/dist/controllers/form_validation_controller.js +18 -11
- data/dist/controllers/frame_loading_controller.js +55 -48
- data/dist/controllers/hover_card_controller.js +67 -61
- data/dist/controllers/idle_controller.js +10 -6
- data/dist/controllers/input_mask_controller.js +411 -24
- data/dist/controllers/intersection_controller.js +3 -0
- data/dist/controllers/lazy_frame_controller.js +15 -3
- data/dist/controllers/listbox_controller.js +260 -79
- data/dist/controllers/local_time_controller.js +48 -13
- data/dist/controllers/masonry_controller.js +11 -4
- data/dist/controllers/menu_controller.js +138 -82
- data/dist/controllers/menubar_controller.js +65 -19
- data/dist/controllers/meter_controller.js +270 -24
- data/dist/controllers/multi_select_controller.js +251 -94
- data/dist/controllers/navigation_menu_controller.js +67 -19
- data/dist/controllers/nested_form_controller.js +98 -64
- data/dist/controllers/network_status_controller.js +70 -52
- data/dist/controllers/number_input_controller.js +344 -94
- data/dist/controllers/optimistic_controller.js +29 -11
- data/dist/controllers/otp_controller.js +502 -104
- data/dist/controllers/overflow_indicator_controller.js +6 -0
- data/dist/controllers/overflow_menu_controller.js +136 -21
- data/dist/controllers/pagination_controller.js +47 -14
- data/dist/controllers/password_reveal_controller.js +52 -49
- data/dist/controllers/password_strength_controller.js +13 -6
- data/dist/controllers/persist_controller.js +48 -128
- data/dist/controllers/pointer_drag_controller.js +249 -23
- data/dist/controllers/popover_controller.js +82 -65
- data/dist/controllers/portal_controller.js +6 -0
- data/dist/controllers/preview_guard_controller.js +14 -3
- data/dist/controllers/progress_controller.js +271 -27
- data/dist/controllers/radio_group_controller.js +167 -80
- data/dist/controllers/range_slider_controller.js +27 -7
- data/dist/controllers/rating_controller.js +93 -57
- data/dist/controllers/read_more_controller.js +10 -6
- data/dist/controllers/reading_progress_controller.js +22 -5
- data/dist/controllers/relative_time_controller.js +75 -11
- data/dist/controllers/reset_on_restore_controller.js +6 -0
- data/dist/controllers/resizable_controller.js +55 -22
- data/dist/controllers/roving_controller.js +10 -4
- data/dist/controllers/scroll_area_controller.js +129 -88
- data/dist/controllers/scroll_restore_controller.js +14 -2
- data/dist/controllers/scroll_visibility_controller.js +93 -60
- data/dist/controllers/scrollspy_controller.js +11 -5
- data/dist/controllers/separator_controller.js +59 -43
- data/dist/controllers/sidebar_controller.js +150 -122
- data/dist/controllers/skeleton_controller.js +55 -48
- data/dist/controllers/slider_controller.js +27 -6
- data/dist/controllers/smart_sticky_header_controller.js +13 -5
- data/dist/controllers/sortable_controller.js +27 -14
- data/dist/controllers/spinner_controller.js +55 -48
- data/dist/controllers/step_indicator_controller.js +6 -0
- data/dist/controllers/stepper_controller.js +6 -0
- data/dist/controllers/stick_to_bottom_controller.js +19 -8
- data/dist/controllers/sticky_observer_controller.js +49 -43
- data/dist/controllers/submit_once_controller.js +145 -85
- data/dist/controllers/switch_controller.js +172 -28
- data/dist/controllers/tabs_controller.js +6 -1
- data/dist/controllers/tags_input_controller.js +157 -28
- data/dist/controllers/textarea_autosize_controller.js +40 -19
- data/dist/controllers/theme_controller.js +10 -4
- data/dist/controllers/time_picker_controller.js +192 -54
- data/dist/controllers/toast_controller.js +58 -27
- data/dist/controllers/toggle_group_controller.js +158 -56
- data/dist/controllers/toolbar_controller.js +150 -21
- data/dist/controllers/tree_view_controller.js +134 -25
- data/dist/index.js +2451 -1312
- data/dist/positioning/index.js +6 -0
- data/lib/generators/stimeo/install/install_generator.rb +7 -2
- data/lib/generators/stimeo/install/templates/stimeo.js +19 -6
- data/lib/stimeo/ui/version.rb +1 -1
- metadata +2 -2
|
@@ -36,6 +36,104 @@ function isReservedArrowChord(event, allow = []) {
|
|
|
36
36
|
return event.altKey && !allow.includes("alt") || event.ctrlKey && !allow.includes("ctrl") || event.metaKey && !allow.includes("meta") || event.shiftKey && !allow.includes("shift");
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
function setAttributeIfChanged(element, name, value, beforeWrite) {
|
|
40
|
+
if (element.getAttribute(name) === value) return false;
|
|
41
|
+
beforeWrite?.();
|
|
42
|
+
if (value === null) element.removeAttribute(name);
|
|
43
|
+
else element.setAttribute(name, value);
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
var AuthoredMutationWatcher = class {
|
|
48
|
+
#onAuthored;
|
|
49
|
+
#claims = null;
|
|
50
|
+
#observer = null;
|
|
51
|
+
constructor(onAuthored) {
|
|
52
|
+
this.#onAuthored = onAuthored;
|
|
53
|
+
}
|
|
54
|
+
observe(root, options) {
|
|
55
|
+
this.disconnect();
|
|
56
|
+
const observer = new MutationObserver((records) => {
|
|
57
|
+
if (this.#observer !== observer) return;
|
|
58
|
+
const authored = this.#filter(records);
|
|
59
|
+
if (authored.length > 0) this.#onAuthored(authored);
|
|
60
|
+
});
|
|
61
|
+
this.#observer = observer;
|
|
62
|
+
this.#claims = { attributes: /* @__PURE__ */ new Map(), children: /* @__PURE__ */ new Map() };
|
|
63
|
+
observer.observe(root, {
|
|
64
|
+
attributes: true,
|
|
65
|
+
attributeFilter: [...options.attributes],
|
|
66
|
+
subtree: options.subtree ?? false,
|
|
67
|
+
childList: options.childList ?? false
|
|
68
|
+
});
|
|
69
|
+
if (options.ancestorAttributes) {
|
|
70
|
+
let ancestor = root.parentElement;
|
|
71
|
+
while (ancestor) {
|
|
72
|
+
observer.observe(ancestor, {
|
|
73
|
+
attributes: true,
|
|
74
|
+
attributeFilter: [...options.ancestorAttributes]
|
|
75
|
+
});
|
|
76
|
+
ancestor = ancestor.parentElement;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
claim(target, name, value) {
|
|
81
|
+
const claims = this.#claims?.attributes;
|
|
82
|
+
let attributes = claims?.get(target);
|
|
83
|
+
if (!attributes) {
|
|
84
|
+
attributes = /* @__PURE__ */ new Map();
|
|
85
|
+
claims?.set(target, attributes);
|
|
86
|
+
}
|
|
87
|
+
const pending = attributes.get(name);
|
|
88
|
+
attributes.set(name, { value, count: (pending?.count ?? 0) + 1 });
|
|
89
|
+
}
|
|
90
|
+
claimCurrent(target, name) {
|
|
91
|
+
this.claim(target, name, target.getAttribute(name));
|
|
92
|
+
}
|
|
93
|
+
claimChildList(target, added, removed) {
|
|
94
|
+
const claims = this.#claims?.children;
|
|
95
|
+
const pending = claims?.get(target) ?? { added: /* @__PURE__ */ new Map(), removed: /* @__PURE__ */ new Map() };
|
|
96
|
+
for (const node of added) pending.added.set(node, (pending.added.get(node) ?? 0) + 1);
|
|
97
|
+
for (const node of removed) pending.removed.set(node, (pending.removed.get(node) ?? 0) + 1);
|
|
98
|
+
claims?.set(target, pending);
|
|
99
|
+
}
|
|
100
|
+
take() {
|
|
101
|
+
return this.#filter(this.#observer?.takeRecords() ?? []);
|
|
102
|
+
}
|
|
103
|
+
disconnect() {
|
|
104
|
+
this.#observer?.disconnect();
|
|
105
|
+
this.#observer = null;
|
|
106
|
+
this.#claims = null;
|
|
107
|
+
}
|
|
108
|
+
#filter(records) {
|
|
109
|
+
const authored = records.filter((record) => !this.#consume(record));
|
|
110
|
+
this.#claims?.attributes.clear();
|
|
111
|
+
this.#claims?.children.clear();
|
|
112
|
+
return authored;
|
|
113
|
+
}
|
|
114
|
+
#consume(record) {
|
|
115
|
+
if (record.type === "attributes") {
|
|
116
|
+
const target = record.target;
|
|
117
|
+
const pending2 = this.#claims?.attributes.get(target)?.get(record.attributeName);
|
|
118
|
+
if (!pending2 || pending2.count === 0 || target.getAttribute(record.attributeName) !== pending2.value) {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
pending2.count -= 1;
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
const pending = this.#claims?.children.get(record.target);
|
|
125
|
+
if (!pending) return false;
|
|
126
|
+
const added = [...record.addedNodes];
|
|
127
|
+
const removed = [...record.removedNodes];
|
|
128
|
+
if (added.some((node) => !pending.added.get(node)) || removed.some((node) => !pending.removed.get(node))) {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
for (const node of added) pending.added.set(node, (pending.added.get(node) ?? 0) - 1);
|
|
132
|
+
for (const node of removed) pending.removed.set(node, (pending.removed.get(node) ?? 0) - 1);
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
|
|
39
137
|
function writeFields(container, values, { name, form = "" }) {
|
|
40
138
|
const current = [...container.children];
|
|
41
139
|
const submits = current.length === values.length && current.every(
|
|
@@ -101,6 +199,9 @@ var MicrotaskCoalescer = class {
|
|
|
101
199
|
this.#queued = false;
|
|
102
200
|
this.#generation += 1;
|
|
103
201
|
}
|
|
202
|
+
get pending() {
|
|
203
|
+
return this.#queued;
|
|
204
|
+
}
|
|
104
205
|
schedule() {
|
|
105
206
|
if (!this.#active || this.#queued) return;
|
|
106
207
|
this.#queued = true;
|
|
@@ -131,6 +232,9 @@ var MorphRenderWatcher = class {
|
|
|
131
232
|
schedule() {
|
|
132
233
|
this.#pass.schedule();
|
|
133
234
|
}
|
|
235
|
+
get pending() {
|
|
236
|
+
return this.#pass.pending;
|
|
237
|
+
}
|
|
134
238
|
disconnect() {
|
|
135
239
|
this.#listeners.dispose();
|
|
136
240
|
this.#pass.cancel();
|
|
@@ -155,9 +259,6 @@ function targetSelector(identifier, name) {
|
|
|
155
259
|
|
|
156
260
|
var SORT_CYCLE = ["none", "ascending", "descending"];
|
|
157
261
|
var OBSERVED_ATTRIBUTES = ["aria-selected", "data-value"];
|
|
158
|
-
function setAttributeIfChanged(element, name, value) {
|
|
159
|
-
if (element.getAttribute(name) !== value) element.setAttribute(name, value);
|
|
160
|
-
}
|
|
161
262
|
function sameSelection(a, b) {
|
|
162
263
|
if (a.size !== b.size) return false;
|
|
163
264
|
for (const [row, value] of a) {
|
|
@@ -172,6 +273,7 @@ function nextSortDirection(current) {
|
|
|
172
273
|
}
|
|
173
274
|
var DataGridController = class extends Controller {
|
|
174
275
|
#moves = new MoveCounter();
|
|
276
|
+
#connectionGeneration = 0;
|
|
175
277
|
#stopHolder = null;
|
|
176
278
|
static targets = ["columnHeader", "row", "cell", "fields"];
|
|
177
279
|
static values = {
|
|
@@ -182,7 +284,9 @@ var DataGridController = class extends Controller {
|
|
|
182
284
|
static actions = ["onKeydown", "sort", "toggleSelect"];
|
|
183
285
|
static events = ["selectionchange", "sort", "reconcile"];
|
|
184
286
|
#reconcile = new MorphRenderWatcher(() => this.#reconcileRows());
|
|
185
|
-
#observer =
|
|
287
|
+
#observer = new AuthoredMutationWatcher((records) => {
|
|
288
|
+
if (this.#concernsRows(records)) this.#reconcile.schedule();
|
|
289
|
+
});
|
|
186
290
|
#settled = /* @__PURE__ */ new Map();
|
|
187
291
|
connect() {
|
|
188
292
|
this.#restoreBaseline();
|
|
@@ -191,9 +295,9 @@ var DataGridController = class extends Controller {
|
|
|
191
295
|
this.#observeRows();
|
|
192
296
|
}
|
|
193
297
|
disconnect() {
|
|
298
|
+
this.#connectionGeneration += 1;
|
|
194
299
|
this.#reconcile.disconnect();
|
|
195
|
-
this.#observer
|
|
196
|
-
this.#observer = null;
|
|
300
|
+
this.#observer.disconnect();
|
|
197
301
|
}
|
|
198
302
|
#restoreBaseline() {
|
|
199
303
|
const cells = this.#navigableCells();
|
|
@@ -204,7 +308,7 @@ var DataGridController = class extends Controller {
|
|
|
204
308
|
this.#syncSelectable();
|
|
205
309
|
const pageWrote = this.#takePageRecords();
|
|
206
310
|
this.#normalizeSelection();
|
|
207
|
-
this.#
|
|
311
|
+
this.#flushMutations(pageWrote);
|
|
208
312
|
this.#mirrorFields(false);
|
|
209
313
|
}
|
|
210
314
|
#reconcileRows() {
|
|
@@ -253,16 +357,16 @@ var DataGridController = class extends Controller {
|
|
|
253
357
|
#normalizeSelection() {
|
|
254
358
|
const rows = this.rowTargets;
|
|
255
359
|
if (this.selectionValue === "none") {
|
|
256
|
-
for (const row of rows) row
|
|
360
|
+
for (const row of rows) this.#writeSelection(row, null);
|
|
257
361
|
return;
|
|
258
362
|
}
|
|
259
363
|
const single = this.selectionValue === "single";
|
|
260
364
|
const first = rows.find((row) => row.getAttribute("aria-selected") === "true");
|
|
261
365
|
for (const row of rows) {
|
|
262
366
|
if (single) {
|
|
263
|
-
|
|
367
|
+
this.#writeSelection(row, row === first ? "true" : "false");
|
|
264
368
|
} else if (row.getAttribute("aria-selected") !== "true") {
|
|
265
|
-
|
|
369
|
+
this.#writeSelection(row, "false");
|
|
266
370
|
}
|
|
267
371
|
}
|
|
268
372
|
}
|
|
@@ -303,6 +407,9 @@ var DataGridController = class extends Controller {
|
|
|
303
407
|
if (event.defaultPrevented) return;
|
|
304
408
|
if (isReservedArrowChord(event)) return;
|
|
305
409
|
if (event.isComposing) return;
|
|
410
|
+
if ((event.key === "Home" || event.key === "End") && (event.altKey || event.metaKey || event.shiftKey)) {
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
306
413
|
const cell = event.currentTarget;
|
|
307
414
|
if (this.#claimedByDescendant(event, cell)) return;
|
|
308
415
|
const matrix = this.#matrix();
|
|
@@ -369,15 +476,16 @@ var DataGridController = class extends Controller {
|
|
|
369
476
|
this.dispatch("sort", { detail: { column: header, direction, reason: "user" } });
|
|
370
477
|
}
|
|
371
478
|
#toggleRow(row, reason = "user") {
|
|
479
|
+
const generation = this.#connectionGeneration;
|
|
372
480
|
const selected = row.getAttribute("aria-selected") === "true";
|
|
373
481
|
const pageWrote = this.#takePageRecords();
|
|
374
482
|
if (this.selectionValue === "single") {
|
|
375
483
|
for (const other of this.rowTargets) {
|
|
376
|
-
if (other !== row)
|
|
484
|
+
if (other !== row) this.#writeSelection(other, "false");
|
|
377
485
|
}
|
|
378
486
|
}
|
|
379
|
-
row
|
|
380
|
-
this.#
|
|
487
|
+
this.#writeSelection(row, selected ? "false" : "true");
|
|
488
|
+
this.#flushMutations(pageWrote);
|
|
381
489
|
const selection = this.#selection();
|
|
382
490
|
const changed = !sameSelection(selection, this.#settled);
|
|
383
491
|
this.#settled = selection;
|
|
@@ -387,7 +495,7 @@ var DataGridController = class extends Controller {
|
|
|
387
495
|
}
|
|
388
496
|
const token = this.#moves.record();
|
|
389
497
|
this.#mirrorFields(true);
|
|
390
|
-
if (!this.#moves.isLatest(token)) return;
|
|
498
|
+
if (generation !== this.#connectionGeneration || !this.#moves.isLatest(token)) return;
|
|
391
499
|
this.dispatch("selectionchange", { detail: { rows: [...selection.keys()], reason } });
|
|
392
500
|
}
|
|
393
501
|
#selection() {
|
|
@@ -396,27 +504,22 @@ var DataGridController = class extends Controller {
|
|
|
396
504
|
);
|
|
397
505
|
}
|
|
398
506
|
#observeRows() {
|
|
399
|
-
|
|
400
|
-
if (this.#concernsRows(records)) this.#reconcile.schedule();
|
|
401
|
-
});
|
|
402
|
-
observer.observe(this.element, {
|
|
507
|
+
this.#observer.observe(this.element, {
|
|
403
508
|
subtree: true,
|
|
404
|
-
attributes:
|
|
405
|
-
attributeFilter: OBSERVED_ATTRIBUTES
|
|
509
|
+
attributes: OBSERVED_ATTRIBUTES
|
|
406
510
|
});
|
|
407
|
-
this.#observer = observer;
|
|
408
511
|
}
|
|
409
512
|
#takePageRecords() {
|
|
410
|
-
const records = this.#observer
|
|
513
|
+
const records = this.#observer.take();
|
|
411
514
|
return records.length > 0 && this.#concernsRows(records);
|
|
412
515
|
}
|
|
413
516
|
#concernsRows(records) {
|
|
414
517
|
const rows = new Set(this.rowTargets);
|
|
415
518
|
return records.some((record) => rows.has(record.target));
|
|
416
519
|
}
|
|
417
|
-
#
|
|
418
|
-
this.#observer
|
|
419
|
-
if (pageWrote) this.#reconcile.schedule();
|
|
520
|
+
#flushMutations(pageWrote) {
|
|
521
|
+
const authored = this.#concernsRows(this.#observer.take());
|
|
522
|
+
if (pageWrote || authored) this.#reconcile.schedule();
|
|
420
523
|
}
|
|
421
524
|
#mirrorFields(notify) {
|
|
422
525
|
if (!this.hasFieldsTarget) return;
|
|
@@ -430,9 +533,7 @@ var DataGridController = class extends Controller {
|
|
|
430
533
|
this.#stopHolder = cell;
|
|
431
534
|
for (const candidate of cells ?? this.#navigableCells()) {
|
|
432
535
|
const wanted = candidate === cell ? "0" : "-1";
|
|
433
|
-
|
|
434
|
-
candidate.setAttribute("tabindex", wanted);
|
|
435
|
-
}
|
|
536
|
+
setAttributeIfChanged(candidate, "tabindex", wanted);
|
|
436
537
|
}
|
|
437
538
|
if (focus) cell.focus();
|
|
438
539
|
}
|
|
@@ -460,6 +561,11 @@ var DataGridController = class extends Controller {
|
|
|
460
561
|
if (!cells || cells.length === 0) return void 0;
|
|
461
562
|
return cells[Math.min(col, cells.length - 1)];
|
|
462
563
|
}
|
|
564
|
+
#writeSelection(target, value) {
|
|
565
|
+
setAttributeIfChanged(target, "aria-selected", value, () => {
|
|
566
|
+
this.#observer.claim(target, "aria-selected", value);
|
|
567
|
+
});
|
|
568
|
+
}
|
|
463
569
|
};
|
|
464
570
|
|
|
465
571
|
export { DataGridController };
|
|
@@ -31,21 +31,39 @@ function logicalArrowKey(key, element) {
|
|
|
31
31
|
if (!isRtl(element)) return key;
|
|
32
32
|
return key === "ArrowRight" ? "ArrowLeft" : "ArrowRight";
|
|
33
33
|
}
|
|
34
|
+
function gridDirectionElement(grid, root) {
|
|
35
|
+
const table = grid.closest("table");
|
|
36
|
+
return table !== null && root.contains(table) ? table : grid;
|
|
37
|
+
}
|
|
34
38
|
function isReservedArrowChord(event, allow = []) {
|
|
35
39
|
if (!event.key.startsWith("Arrow")) return false;
|
|
36
40
|
return event.altKey && !allow.includes("alt") || event.ctrlKey && !allow.includes("ctrl") || event.metaKey && !allow.includes("meta") || event.shiftKey && !allow.includes("shift");
|
|
37
41
|
}
|
|
42
|
+
function hasModifierChord(event) {
|
|
43
|
+
return event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function setAttributeIfChanged(element, name, value, beforeWrite) {
|
|
47
|
+
if (element.getAttribute(name) === value) return false;
|
|
48
|
+
if (value === null) element.removeAttribute(name);
|
|
49
|
+
else element.setAttribute(name, value);
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
38
52
|
|
|
39
53
|
function sharedRegistry(key, create) {
|
|
40
54
|
const symbol = Symbol.for(key);
|
|
41
55
|
const scope = globalThis;
|
|
42
56
|
const existing = scope[symbol];
|
|
43
57
|
if (existing !== void 0) return existing;
|
|
44
|
-
const
|
|
45
|
-
Object.defineProperty(globalThis, symbol, { value:
|
|
46
|
-
return
|
|
58
|
+
const registry2 = create();
|
|
59
|
+
Object.defineProperty(globalThis, symbol, { value: registry2 });
|
|
60
|
+
return registry2;
|
|
47
61
|
}
|
|
48
62
|
|
|
63
|
+
var registry = sharedRegistry(
|
|
64
|
+
"stimeo-ui.attribute-lease.registry.v1",
|
|
65
|
+
() => ({ stacks: /* @__PURE__ */ new WeakMap(), names: /* @__PURE__ */ new Map() })
|
|
66
|
+
);
|
|
49
67
|
function isAttributeValue(value) {
|
|
50
68
|
return value === null || typeof value === "string";
|
|
51
69
|
}
|
|
@@ -62,24 +80,46 @@ function readLeaseRecord(element, record) {
|
|
|
62
80
|
return void 0;
|
|
63
81
|
}
|
|
64
82
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
);
|
|
83
|
+
function attributeStack(element, attribute) {
|
|
84
|
+
const byAttribute = registry.stacks.get(element) ?? /* @__PURE__ */ new Map();
|
|
85
|
+
registry.stacks.set(element, byAttribute);
|
|
86
|
+
const known = byAttribute.get(attribute);
|
|
87
|
+
if (known) return known;
|
|
88
|
+
const found = [];
|
|
89
|
+
for (const record of registry.names.get(attribute) ?? []) {
|
|
90
|
+
const read = readLeaseRecord(element, record);
|
|
91
|
+
if (read) found.push({ ...read, record });
|
|
92
|
+
}
|
|
93
|
+
const depth = ({ beneath }) => beneath.filter((name) => found.some((other) => other.record === name)).length;
|
|
94
|
+
const stack = found.sort((one, other) => depth(one) - depth(other)).map(({ record, written, original, linked }, index) => ({
|
|
95
|
+
lease: null,
|
|
96
|
+
record,
|
|
97
|
+
written,
|
|
98
|
+
original,
|
|
99
|
+
linked: linked && index > 0
|
|
100
|
+
}));
|
|
101
|
+
byAttribute.set(attribute, stack);
|
|
102
|
+
return stack;
|
|
103
|
+
}
|
|
104
|
+
function findHold(stack, lease, record) {
|
|
105
|
+
return stack.find((held) => held.lease === lease) ?? stack.find((held) => held.lease === null && held.record === record);
|
|
106
|
+
}
|
|
107
|
+
var AttributeLease = class {
|
|
70
108
|
#attribute;
|
|
71
109
|
#record;
|
|
72
110
|
#base;
|
|
111
|
+
#preserveAuthor;
|
|
73
112
|
#held = /* @__PURE__ */ new Set();
|
|
74
113
|
constructor(attribute, owner, options = {}) {
|
|
75
114
|
this.#attribute = attribute;
|
|
76
115
|
this.#record = `data-${owner}-${attribute}-lease`;
|
|
77
116
|
this.#base = options.base === true;
|
|
78
|
-
|
|
117
|
+
this.#preserveAuthor = options.preserveAuthor === true;
|
|
118
|
+
const names = registry.names;
|
|
79
119
|
names.set(attribute, (names.get(attribute) ?? /* @__PURE__ */ new Set()).add(this.#record));
|
|
80
120
|
}
|
|
81
121
|
write(element, value) {
|
|
82
|
-
const stack = this.#
|
|
122
|
+
const stack = attributeStack(element, this.#attribute);
|
|
83
123
|
const hold = this.#take(stack) ?? this.#acquire(element, stack);
|
|
84
124
|
this.#held.add(element);
|
|
85
125
|
const shows = !this.#covered(element, stack, hold);
|
|
@@ -89,8 +129,8 @@ var AttributeLease = class _AttributeLease {
|
|
|
89
129
|
}
|
|
90
130
|
return(element) {
|
|
91
131
|
const held = this.#held.delete(element);
|
|
92
|
-
const known =
|
|
93
|
-
const stack = held || known || element.hasAttribute(this.#record) ? this.#
|
|
132
|
+
const known = registry.stacks.get(element)?.has(this.#attribute);
|
|
133
|
+
const stack = held || known || element.hasAttribute(this.#record) ? attributeStack(element, this.#attribute) : [];
|
|
94
134
|
const hold = this.#take(stack);
|
|
95
135
|
if (!hold) return false;
|
|
96
136
|
const carries = element.getAttribute(this.#attribute) === hold.written;
|
|
@@ -108,31 +148,8 @@ var AttributeLease = class _AttributeLease {
|
|
|
108
148
|
returnAll() {
|
|
109
149
|
for (const element of Array.from(this.#held)) this.return(element);
|
|
110
150
|
}
|
|
111
|
-
#stack(element) {
|
|
112
|
-
const stacks = _AttributeLease.#registry.stacks;
|
|
113
|
-
const byAttribute = stacks.get(element) ?? /* @__PURE__ */ new Map();
|
|
114
|
-
stacks.set(element, byAttribute);
|
|
115
|
-
const stack = byAttribute.get(this.#attribute) ?? this.#seed(element);
|
|
116
|
-
byAttribute.set(this.#attribute, stack);
|
|
117
|
-
return stack;
|
|
118
|
-
}
|
|
119
|
-
#seed(element) {
|
|
120
|
-
const found = [];
|
|
121
|
-
for (const record of _AttributeLease.#registry.names.get(this.#attribute) ?? []) {
|
|
122
|
-
const read = readLeaseRecord(element, record);
|
|
123
|
-
if (read) found.push({ ...read, record });
|
|
124
|
-
}
|
|
125
|
-
const depth = ({ beneath }) => beneath.filter((name) => found.some((other) => other.record === name)).length;
|
|
126
|
-
return found.sort((one, other) => depth(one) - depth(other)).map(({ record, written, original, linked }, index) => ({
|
|
127
|
-
lease: null,
|
|
128
|
-
record,
|
|
129
|
-
written,
|
|
130
|
-
original,
|
|
131
|
-
linked: linked && index > 0
|
|
132
|
-
}));
|
|
133
|
-
}
|
|
134
151
|
#take(stack) {
|
|
135
|
-
const hold = stack
|
|
152
|
+
const hold = findHold(stack, this, this.#record);
|
|
136
153
|
if (hold) hold.lease = this;
|
|
137
154
|
return hold;
|
|
138
155
|
}
|
|
@@ -141,7 +158,7 @@ var AttributeLease = class _AttributeLease {
|
|
|
141
158
|
const top = stack.at(-1);
|
|
142
159
|
const bottom = stack[0];
|
|
143
160
|
const over = top?.written === current ? top : void 0;
|
|
144
|
-
const from = this.#base ? bottom : over;
|
|
161
|
+
const from = this.#base ? this.#preserveAuthor && !stack.some((held) => held.written === current) ? void 0 : bottom : over;
|
|
145
162
|
const hold = {
|
|
146
163
|
lease: this,
|
|
147
164
|
record: this.#record,
|
|
@@ -171,15 +188,11 @@ var AttributeLease = class _AttributeLease {
|
|
|
171
188
|
);
|
|
172
189
|
});
|
|
173
190
|
for (const [name, recorded] of records) {
|
|
174
|
-
|
|
175
|
-
if (recorded === null) element.removeAttribute(name);
|
|
176
|
-
else element.setAttribute(name, recorded);
|
|
191
|
+
setAttributeIfChanged(element, name, recorded);
|
|
177
192
|
}
|
|
178
193
|
}
|
|
179
194
|
#reflect(element, value) {
|
|
180
|
-
|
|
181
|
-
if (value === null) element.removeAttribute(this.#attribute);
|
|
182
|
-
else element.setAttribute(this.#attribute, value);
|
|
195
|
+
setAttributeIfChanged(element, this.#attribute, value);
|
|
183
196
|
}
|
|
184
197
|
};
|
|
185
198
|
|
|
@@ -243,6 +256,30 @@ function parseISOMonthString(monthStr) {
|
|
|
243
256
|
function toISOMonthString(date) {
|
|
244
257
|
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}`;
|
|
245
258
|
}
|
|
259
|
+
function monthGridDays(year, month, weekStart) {
|
|
260
|
+
const first = new Date(year, month - 1, 1);
|
|
261
|
+
const offset = (first.getDay() - weekStart + 7) % 7;
|
|
262
|
+
const current = new Date(first);
|
|
263
|
+
current.setDate(first.getDate() - offset);
|
|
264
|
+
const days = [];
|
|
265
|
+
for (let i = 0; i < 42; i++) {
|
|
266
|
+
days.push(new Date(current));
|
|
267
|
+
current.setDate(current.getDate() + 1);
|
|
268
|
+
}
|
|
269
|
+
return days;
|
|
270
|
+
}
|
|
271
|
+
function dateInMonthClamped(date, year, month) {
|
|
272
|
+
const target = new Date(year, month - 1, 1);
|
|
273
|
+
const lastDay = new Date(target.getFullYear(), target.getMonth() + 1, 0).getDate();
|
|
274
|
+
target.setDate(Math.min(date.getDate(), lastDay));
|
|
275
|
+
return target;
|
|
276
|
+
}
|
|
277
|
+
function shiftMonthClamped(date, delta) {
|
|
278
|
+
return dateInMonthClamped(date, date.getFullYear(), date.getMonth() + 1 + delta);
|
|
279
|
+
}
|
|
280
|
+
function shiftYearClamped(date, delta) {
|
|
281
|
+
return dateInMonthClamped(date, date.getFullYear() + delta, date.getMonth() + 1);
|
|
282
|
+
}
|
|
246
283
|
var MONTH_LABEL_OPTIONS = { month: "long", year: "numeric" };
|
|
247
284
|
function monthLabelFormatter(locale) {
|
|
248
285
|
return intlFormatter(Intl.DateTimeFormat, locale, MONTH_LABEL_OPTIONS, "en");
|
|
@@ -288,6 +325,9 @@ var MicrotaskCoalescer = class {
|
|
|
288
325
|
this.#queued = false;
|
|
289
326
|
this.#generation += 1;
|
|
290
327
|
}
|
|
328
|
+
get pending() {
|
|
329
|
+
return this.#queued;
|
|
330
|
+
}
|
|
291
331
|
schedule() {
|
|
292
332
|
if (!this.#active || this.#queued) return;
|
|
293
333
|
this.#queued = true;
|
|
@@ -318,6 +358,9 @@ var MorphRenderWatcher = class {
|
|
|
318
358
|
schedule() {
|
|
319
359
|
this.#pass.schedule();
|
|
320
360
|
}
|
|
361
|
+
get pending() {
|
|
362
|
+
return this.#pass.pending;
|
|
363
|
+
}
|
|
321
364
|
disconnect() {
|
|
322
365
|
this.#listeners.dispose();
|
|
323
366
|
this.#pass.cancel();
|
|
@@ -526,6 +569,9 @@ var DateRangePickerController = class extends Controller {
|
|
|
526
569
|
onKeydown(event) {
|
|
527
570
|
if (event.defaultPrevented) return;
|
|
528
571
|
if (isReservedArrowChord(event)) return;
|
|
572
|
+
if ((event.key === "Home" || event.key === "End") && hasModifierChord(event)) return;
|
|
573
|
+
if ((event.key === "PageUp" || event.key === "PageDown") && (event.ctrlKey || event.altKey || event.metaKey))
|
|
574
|
+
return;
|
|
529
575
|
const cell = this.#cellFrom(event.target);
|
|
530
576
|
if (!cell) return;
|
|
531
577
|
const dateStr = cell.getAttribute("data-date") ?? "";
|
|
@@ -546,7 +592,8 @@ var DateRangePickerController = class extends Controller {
|
|
|
546
592
|
return;
|
|
547
593
|
}
|
|
548
594
|
let next = null;
|
|
549
|
-
|
|
595
|
+
const directionElement = this.hasGridTarget ? gridDirectionElement(this.gridTarget, this.element) : this.element;
|
|
596
|
+
switch (logicalArrowKey(event.key, directionElement)) {
|
|
550
597
|
case "ArrowLeft":
|
|
551
598
|
next = addDays(date, -1);
|
|
552
599
|
break;
|
|
@@ -632,10 +679,8 @@ var DateRangePickerController = class extends Controller {
|
|
|
632
679
|
#shiftMonth(delta) {
|
|
633
680
|
const info = parseISOMonthString(this.#viewMonth);
|
|
634
681
|
if (!info) return;
|
|
635
|
-
const target =
|
|
682
|
+
const target = dateInMonthClamped(this.#focusedDate, info.year, info.month + delta);
|
|
636
683
|
this.#viewMonth = toISOMonthString(target);
|
|
637
|
-
const lastDay = new Date(target.getFullYear(), target.getMonth() + 1, 0).getDate();
|
|
638
|
-
target.setDate(Math.min(this.#focusedDate.getDate(), lastDay));
|
|
639
684
|
this.#focusedDate = target;
|
|
640
685
|
this.#render();
|
|
641
686
|
}
|
|
@@ -655,7 +700,7 @@ var DateRangePickerController = class extends Controller {
|
|
|
655
700
|
this.monthLabelTarget.textContent = formatter.format(new Date(year, month - 1, 1));
|
|
656
701
|
}
|
|
657
702
|
const [rangeStart, rangeEnd] = this.#visualRange();
|
|
658
|
-
const days =
|
|
703
|
+
const days = monthGridDays(year, month, 0);
|
|
659
704
|
const focusedStr = toISODateString(this.#focusedDate);
|
|
660
705
|
const todayStr = toISODateString(/* @__PURE__ */ new Date());
|
|
661
706
|
const cells = this.cellTargets;
|
|
@@ -794,30 +839,6 @@ function addDays(date, n) {
|
|
|
794
839
|
next.setDate(next.getDate() + n);
|
|
795
840
|
return next;
|
|
796
841
|
}
|
|
797
|
-
function shiftMonthClamped(date, delta) {
|
|
798
|
-
const target = new Date(date.getFullYear(), date.getMonth() + delta, 1);
|
|
799
|
-
const lastDay = new Date(target.getFullYear(), target.getMonth() + 1, 0).getDate();
|
|
800
|
-
target.setDate(Math.min(date.getDate(), lastDay));
|
|
801
|
-
return target;
|
|
802
|
-
}
|
|
803
|
-
function shiftYearClamped(date, delta) {
|
|
804
|
-
const target = new Date(date.getFullYear() + delta, date.getMonth(), 1);
|
|
805
|
-
const lastDay = new Date(target.getFullYear(), target.getMonth() + 1, 0).getDate();
|
|
806
|
-
target.setDate(Math.min(date.getDate(), lastDay));
|
|
807
|
-
return target;
|
|
808
|
-
}
|
|
809
|
-
function gridDays(year, month) {
|
|
810
|
-
const first = new Date(year, month - 1, 1);
|
|
811
|
-
const start = new Date(first);
|
|
812
|
-
start.setDate(first.getDate() - first.getDay());
|
|
813
|
-
const days = [];
|
|
814
|
-
const current = new Date(start);
|
|
815
|
-
for (let i = 0; i < GRID_SIZE; i++) {
|
|
816
|
-
days.push(new Date(current));
|
|
817
|
-
current.setDate(current.getDate() + 1);
|
|
818
|
-
}
|
|
819
|
-
return days;
|
|
820
|
-
}
|
|
821
842
|
function normalizeISO(value) {
|
|
822
843
|
const date = parseISODateString(value.trim());
|
|
823
844
|
return date ? toISODateString(date) : "";
|