stimeo-ui 0.18.1 → 0.19.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 +54 -0
- data/dist/cable/index.js +6 -5
- data/dist/controllers/alert_dialog_controller.js +324 -76
- data/dist/controllers/announcer_controller.js +22 -9
- data/dist/controllers/auto_submit_controller.js +103 -16
- data/dist/controllers/avatar_controller.js +29 -9
- data/dist/controllers/breadcrumb_controller.js +205 -17
- data/dist/controllers/bulk_select_controller.js +31 -13
- data/dist/controllers/calendar_controller.js +242 -7
- data/dist/controllers/carousel_controller.js +70 -15
- data/dist/controllers/character_counter_controller.js +103 -16
- data/dist/controllers/clipboard_controller.js +6 -5
- data/dist/controllers/collapsible_controller.js +35 -8
- data/dist/controllers/combobox_controller.js +155 -26
- data/dist/controllers/command_palette_controller.js +445 -117
- data/dist/controllers/conditional_fields_controller.js +84 -44
- data/dist/controllers/confirm_controller.js +303 -68
- data/dist/controllers/context_menu_controller.js +59 -30
- data/dist/controllers/countdown_controller.js +6 -5
- data/dist/controllers/currency_input_controller.js +72 -7
- data/dist/controllers/data_grid_controller.js +273 -51
- data/dist/controllers/date_range_picker_controller.js +27 -5
- data/dist/controllers/dialog_controller.js +330 -79
- data/dist/controllers/direct_upload_controller.js +6 -5
- data/dist/controllers/dismissible_controller.js +68 -18
- data/dist/controllers/drawer_controller.js +362 -92
- data/dist/controllers/dropdown_controller.js +64 -52
- data/dist/controllers/editable_controller.js +140 -12
- data/dist/controllers/empty_state_controller.js +193 -9
- data/dist/controllers/file_dropzone_controller.js +313 -23
- data/dist/controllers/filter_controller.js +194 -5
- data/dist/controllers/flash_controller.js +205 -17
- data/dist/controllers/focus_controller.js +273 -57
- data/dist/controllers/form_field_controller.js +71 -14
- data/dist/controllers/form_validation_controller.js +11 -7
- data/dist/controllers/frame_loading_controller.js +75 -20
- data/dist/controllers/hover_card_controller.js +108 -39
- data/dist/controllers/input_mask_controller.js +95 -37
- data/dist/controllers/intersection_controller.js +61 -29
- data/dist/controllers/lazy_frame_controller.js +61 -29
- data/dist/controllers/listbox_controller.js +174 -83
- data/dist/controllers/local_time_controller.js +1 -7
- data/dist/controllers/menu_controller.js +45 -24
- data/dist/controllers/menubar_controller.js +232 -52
- data/dist/controllers/meter_controller.js +31 -9
- data/dist/controllers/multi_select_controller.js +195 -62
- data/dist/controllers/navigation_menu_controller.js +1 -1
- data/dist/controllers/nested_form_controller.js +275 -21
- data/dist/controllers/network_status_controller.js +31 -9
- data/dist/controllers/number_input_controller.js +180 -71
- data/dist/controllers/otp_controller.js +97 -11
- data/dist/controllers/overflow_menu_controller.js +190 -24
- data/dist/controllers/pagination_controller.js +186 -24
- data/dist/controllers/password_reveal_controller.js +25 -4
- data/dist/controllers/password_strength_controller.js +6 -5
- data/dist/controllers/popover_controller.js +466 -42
- data/dist/controllers/progress_controller.js +31 -9
- data/dist/controllers/radio_group_controller.js +279 -88
- data/dist/controllers/range_slider_controller.js +72 -54
- data/dist/controllers/rating_controller.js +58 -10
- data/dist/controllers/read_more_controller.js +191 -25
- data/dist/controllers/relative_time_controller.js +1 -7
- data/dist/controllers/roving_controller.js +204 -8
- data/dist/controllers/scroll_area_controller.js +61 -19
- data/dist/controllers/scroll_visibility_controller.js +25 -4
- data/dist/controllers/scrollspy_controller.js +240 -32
- data/dist/controllers/separator_controller.js +97 -58
- data/dist/controllers/sidebar_controller.js +368 -127
- data/dist/controllers/skeleton_controller.js +75 -20
- data/dist/controllers/slider_controller.js +72 -54
- data/dist/controllers/sortable_controller.js +6 -5
- data/dist/controllers/spinner_controller.js +75 -20
- data/dist/controllers/step_indicator_controller.js +181 -6
- data/dist/controllers/stepper_controller.js +188 -6
- data/dist/controllers/sticky_observer_controller.js +86 -33
- data/dist/controllers/submit_once_controller.js +31 -9
- data/dist/controllers/switch_controller.js +84 -44
- data/dist/controllers/tabs_controller.js +189 -3
- data/dist/controllers/tags_input_controller.js +293 -29
- data/dist/controllers/theme_controller.js +192 -5
- data/dist/controllers/time_picker_controller.js +77 -42
- data/dist/controllers/toast_controller.js +478 -16
- data/dist/controllers/toggle_group_controller.js +282 -79
- data/dist/controllers/toolbar_controller.js +276 -15
- data/dist/controllers/tooltip_controller.js +244 -46
- data/dist/controllers/tree_view_controller.js +287 -57
- data/dist/index.js +2258 -1016
- data/lib/stimeo/ui/version.rb +1 -1
- metadata +2 -2
|
@@ -7,18 +7,20 @@ 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) {
|
|
21
22
|
if (element.getAttribute(name) === value) return false;
|
|
23
|
+
beforeWrite?.();
|
|
22
24
|
if (value === null) element.removeAttribute(name);
|
|
23
25
|
else element.setAttribute(name, value);
|
|
24
26
|
return true;
|
|
@@ -92,14 +94,34 @@ var AttributeLease = class {
|
|
|
92
94
|
const names = registry.names;
|
|
93
95
|
names.set(attribute, (names.get(attribute) ?? /* @__PURE__ */ new Set()).add(this.#record));
|
|
94
96
|
}
|
|
95
|
-
write(element, value) {
|
|
97
|
+
write(element, value, beforeWrite) {
|
|
96
98
|
const stack = attributeStack(element, this.#attribute);
|
|
97
99
|
const hold = this.#take(stack) ?? this.#acquire(element, stack);
|
|
98
100
|
this.#held.add(element);
|
|
99
101
|
const shows = !this.#covered(element, stack, hold);
|
|
100
102
|
hold.written = value;
|
|
101
103
|
this.#mark(element, stack);
|
|
102
|
-
if (shows) this.#reflect(element, value);
|
|
104
|
+
if (shows) this.#reflect(element, value, beforeWrite);
|
|
105
|
+
}
|
|
106
|
+
adopt(element, options = {}) {
|
|
107
|
+
const known = registry.stacks.get(element)?.has(this.#attribute);
|
|
108
|
+
if (!this.#held.has(element) && !known && !element.hasAttribute(this.#record)) return false;
|
|
109
|
+
const stack = attributeStack(element, this.#attribute);
|
|
110
|
+
const hold = this.#take(stack);
|
|
111
|
+
if (!hold) return false;
|
|
112
|
+
const current = element.getAttribute(this.#attribute);
|
|
113
|
+
if (options.ifChanged && (current === hold.written || this.#covered(element, stack, hold))) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
this.#held.add(element);
|
|
117
|
+
hold.original = current;
|
|
118
|
+
hold.linked = false;
|
|
119
|
+
for (const above of stack.slice(stack.indexOf(hold) + 1)) {
|
|
120
|
+
if (!above.linked) break;
|
|
121
|
+
above.original = current;
|
|
122
|
+
}
|
|
123
|
+
this.#mark(element, stack);
|
|
124
|
+
return true;
|
|
103
125
|
}
|
|
104
126
|
return(element) {
|
|
105
127
|
const held = this.#held.delete(element);
|
|
@@ -165,8 +187,8 @@ var AttributeLease = class {
|
|
|
165
187
|
setAttributeIfChanged(element, name, recorded);
|
|
166
188
|
}
|
|
167
189
|
}
|
|
168
|
-
#reflect(element, value) {
|
|
169
|
-
setAttributeIfChanged(element, this.#attribute, value);
|
|
190
|
+
#reflect(element, value, beforeWrite) {
|
|
191
|
+
setAttributeIfChanged(element, this.#attribute, value, beforeWrite);
|
|
170
192
|
}
|
|
171
193
|
};
|
|
172
194
|
|
|
@@ -355,10 +377,6 @@ var BulkSelectController = class _BulkSelectController extends Controller {
|
|
|
355
377
|
}
|
|
356
378
|
clear() {
|
|
357
379
|
for (const item of this.itemTargets) item.checked = false;
|
|
358
|
-
if (this.hasAllTarget) {
|
|
359
|
-
this.allTarget.checked = false;
|
|
360
|
-
this.allTarget.indeterminate = false;
|
|
361
|
-
}
|
|
362
380
|
this.#exitAllPages();
|
|
363
381
|
this.#reportChange(this.#recompute());
|
|
364
382
|
}
|
|
@@ -22,6 +22,24 @@ function actionSource(source) {
|
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
function fillTemplate(template, values) {
|
|
26
|
+
return template.replace(/\{([a-zA-Z][a-zA-Z0-9]*)\}/g, (match, name) => {
|
|
27
|
+
const replacement = Object.hasOwn(values, name) ? values[name] : void 0;
|
|
28
|
+
return replacement === void 0 ? match : String(replacement);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
var afterFocus = /* @__PURE__ */ Symbol.for("stimeo--announcer:after-focus");
|
|
33
|
+
function announce(message, options = {}) {
|
|
34
|
+
const text = message.trim();
|
|
35
|
+
if (text.length === 0) return;
|
|
36
|
+
const event = new CustomEvent("stimeo--announcer:announce", {
|
|
37
|
+
detail: { message: text, assertive: options.assertive === true }
|
|
38
|
+
});
|
|
39
|
+
if (options.afterFocus) event[afterFocus] = true;
|
|
40
|
+
window.dispatchEvent(event);
|
|
41
|
+
}
|
|
42
|
+
|
|
25
43
|
function isRtl(element) {
|
|
26
44
|
return window.getComputedStyle(element).direction === "rtl";
|
|
27
45
|
}
|
|
@@ -43,6 +61,180 @@ function hasModifierChord(event) {
|
|
|
43
61
|
return event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;
|
|
44
62
|
}
|
|
45
63
|
|
|
64
|
+
function setAttributeIfChanged(element, name, value, beforeWrite) {
|
|
65
|
+
if (element.getAttribute(name) === value) return false;
|
|
66
|
+
beforeWrite?.();
|
|
67
|
+
if (value === null) element.removeAttribute(name);
|
|
68
|
+
else element.setAttribute(name, value);
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function sharedRegistry(key, create) {
|
|
73
|
+
const symbol = Symbol.for(key);
|
|
74
|
+
const scope = globalThis;
|
|
75
|
+
const existing = scope[symbol];
|
|
76
|
+
if (existing !== void 0) return existing;
|
|
77
|
+
const registry2 = create();
|
|
78
|
+
Object.defineProperty(globalThis, symbol, { value: registry2 });
|
|
79
|
+
return registry2;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
var registry = sharedRegistry(
|
|
83
|
+
"stimeo-ui.attribute-lease.registry.v1",
|
|
84
|
+
() => ({ stacks: /* @__PURE__ */ new WeakMap(), names: /* @__PURE__ */ new Map() })
|
|
85
|
+
);
|
|
86
|
+
function isAttributeValue(value) {
|
|
87
|
+
return value === null || typeof value === "string";
|
|
88
|
+
}
|
|
89
|
+
function readLeaseRecord(element, record) {
|
|
90
|
+
try {
|
|
91
|
+
const parsed = JSON.parse(element.getAttribute(record) ?? "null");
|
|
92
|
+
if (!Array.isArray(parsed)) return void 0;
|
|
93
|
+
const [original, written, ...rest] = parsed;
|
|
94
|
+
const linked = rest[0] !== false;
|
|
95
|
+
const beneath = linked ? rest : rest.slice(1);
|
|
96
|
+
if (!beneath.every((under) => typeof under === "string")) return void 0;
|
|
97
|
+
return isAttributeValue(original) && isAttributeValue(written) ? { original, written, linked, beneath } : void 0;
|
|
98
|
+
} catch {
|
|
99
|
+
return void 0;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function attributeStack(element, attribute) {
|
|
103
|
+
const byAttribute = registry.stacks.get(element) ?? /* @__PURE__ */ new Map();
|
|
104
|
+
registry.stacks.set(element, byAttribute);
|
|
105
|
+
const known = byAttribute.get(attribute);
|
|
106
|
+
if (known) return known;
|
|
107
|
+
const found = [];
|
|
108
|
+
for (const record of registry.names.get(attribute) ?? []) {
|
|
109
|
+
const read = readLeaseRecord(element, record);
|
|
110
|
+
if (read) found.push({ ...read, record });
|
|
111
|
+
}
|
|
112
|
+
const depth = ({ beneath }) => beneath.filter((name) => found.some((other) => other.record === name)).length;
|
|
113
|
+
const stack = found.sort((one, other) => depth(one) - depth(other)).map(({ record, written, original, linked }, index) => ({
|
|
114
|
+
lease: null,
|
|
115
|
+
record,
|
|
116
|
+
written,
|
|
117
|
+
original,
|
|
118
|
+
linked: linked && index > 0
|
|
119
|
+
}));
|
|
120
|
+
byAttribute.set(attribute, stack);
|
|
121
|
+
return stack;
|
|
122
|
+
}
|
|
123
|
+
function findHold(stack, lease, record) {
|
|
124
|
+
return stack.find((held) => held.lease === lease) ?? stack.find((held) => held.lease === null && held.record === record);
|
|
125
|
+
}
|
|
126
|
+
var AttributeLease = class {
|
|
127
|
+
#attribute;
|
|
128
|
+
#record;
|
|
129
|
+
#base;
|
|
130
|
+
#preserveAuthor;
|
|
131
|
+
#held = /* @__PURE__ */ new Set();
|
|
132
|
+
constructor(attribute, owner, options = {}) {
|
|
133
|
+
this.#attribute = attribute;
|
|
134
|
+
this.#record = `data-${owner}-${attribute}-lease`;
|
|
135
|
+
this.#base = options.base === true;
|
|
136
|
+
this.#preserveAuthor = options.preserveAuthor === true;
|
|
137
|
+
const names = registry.names;
|
|
138
|
+
names.set(attribute, (names.get(attribute) ?? /* @__PURE__ */ new Set()).add(this.#record));
|
|
139
|
+
}
|
|
140
|
+
write(element, value, beforeWrite) {
|
|
141
|
+
const stack = attributeStack(element, this.#attribute);
|
|
142
|
+
const hold = this.#take(stack) ?? this.#acquire(element, stack);
|
|
143
|
+
this.#held.add(element);
|
|
144
|
+
const shows = !this.#covered(element, stack, hold);
|
|
145
|
+
hold.written = value;
|
|
146
|
+
this.#mark(element, stack);
|
|
147
|
+
if (shows) this.#reflect(element, value, beforeWrite);
|
|
148
|
+
}
|
|
149
|
+
adopt(element, options = {}) {
|
|
150
|
+
const known = registry.stacks.get(element)?.has(this.#attribute);
|
|
151
|
+
if (!this.#held.has(element) && !known && !element.hasAttribute(this.#record)) return false;
|
|
152
|
+
const stack = attributeStack(element, this.#attribute);
|
|
153
|
+
const hold = this.#take(stack);
|
|
154
|
+
if (!hold) return false;
|
|
155
|
+
const current = element.getAttribute(this.#attribute);
|
|
156
|
+
if (options.ifChanged && (current === hold.written || this.#covered(element, stack, hold))) {
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
this.#held.add(element);
|
|
160
|
+
hold.original = current;
|
|
161
|
+
hold.linked = false;
|
|
162
|
+
for (const above of stack.slice(stack.indexOf(hold) + 1)) {
|
|
163
|
+
if (!above.linked) break;
|
|
164
|
+
above.original = current;
|
|
165
|
+
}
|
|
166
|
+
this.#mark(element, stack);
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
return(element) {
|
|
170
|
+
const held = this.#held.delete(element);
|
|
171
|
+
const known = registry.stacks.get(element)?.has(this.#attribute);
|
|
172
|
+
const stack = held || known || element.hasAttribute(this.#record) ? attributeStack(element, this.#attribute) : [];
|
|
173
|
+
const hold = this.#take(stack);
|
|
174
|
+
if (!hold) return false;
|
|
175
|
+
const carries = element.getAttribute(this.#attribute) === hold.written;
|
|
176
|
+
const owns = carries && !this.#covered(element, stack, hold);
|
|
177
|
+
const index = stack.indexOf(hold);
|
|
178
|
+
stack.splice(index, 1);
|
|
179
|
+
const above = stack[index];
|
|
180
|
+
if (above) above.linked &&= hold.linked;
|
|
181
|
+
this.#mark(element, stack);
|
|
182
|
+
if (!owns) return true;
|
|
183
|
+
const below = hold.linked ? stack[index - 1] : void 0;
|
|
184
|
+
this.#reflect(element, below ? below.written : hold.original);
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
returnAll() {
|
|
188
|
+
for (const element of Array.from(this.#held)) this.return(element);
|
|
189
|
+
}
|
|
190
|
+
#take(stack) {
|
|
191
|
+
const hold = findHold(stack, this, this.#record);
|
|
192
|
+
if (hold) hold.lease = this;
|
|
193
|
+
return hold;
|
|
194
|
+
}
|
|
195
|
+
#acquire(element, stack) {
|
|
196
|
+
const current = element.getAttribute(this.#attribute);
|
|
197
|
+
const top = stack.at(-1);
|
|
198
|
+
const bottom = stack[0];
|
|
199
|
+
const over = top?.written === current ? top : void 0;
|
|
200
|
+
const from = this.#base ? this.#preserveAuthor && !stack.some((held) => held.written === current) ? void 0 : bottom : over;
|
|
201
|
+
const hold = {
|
|
202
|
+
lease: this,
|
|
203
|
+
record: this.#record,
|
|
204
|
+
written: current,
|
|
205
|
+
original: from ? from.original : current,
|
|
206
|
+
linked: !this.#base && over !== void 0
|
|
207
|
+
};
|
|
208
|
+
if (this.#base && bottom) {
|
|
209
|
+
bottom.linked = true;
|
|
210
|
+
stack.unshift(hold);
|
|
211
|
+
} else stack.push(hold);
|
|
212
|
+
return hold;
|
|
213
|
+
}
|
|
214
|
+
#covered(element, stack, hold) {
|
|
215
|
+
const current = element.getAttribute(this.#attribute);
|
|
216
|
+
return stack.slice(stack.indexOf(hold) + 1).some((above) => above.written === current);
|
|
217
|
+
}
|
|
218
|
+
#mark(element, stack) {
|
|
219
|
+
const records = /* @__PURE__ */ new Map([[this.#record, null]]);
|
|
220
|
+
stack.forEach((hold, index) => {
|
|
221
|
+
const names = stack.slice(0, index).map((under) => under.record);
|
|
222
|
+
const beneath = [...new Set(names.reverse())].filter((name) => name !== hold.record);
|
|
223
|
+
const marker = hold.linked || beneath.length === 0 ? [] : [false];
|
|
224
|
+
records.set(
|
|
225
|
+
hold.record,
|
|
226
|
+
hold.written === hold.original && beneath.length === 0 && index === stack.length - 1 ? null : JSON.stringify([hold.original, hold.written, ...marker, ...beneath])
|
|
227
|
+
);
|
|
228
|
+
});
|
|
229
|
+
for (const [name, recorded] of records) {
|
|
230
|
+
setAttributeIfChanged(element, name, recorded);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
#reflect(element, value, beforeWrite) {
|
|
234
|
+
setAttributeIfChanged(element, this.#attribute, value, beforeWrite);
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
|
|
46
238
|
var formatters = /* @__PURE__ */ new WeakMap();
|
|
47
239
|
function intlFormatter(factory, locale, options, fallbackLocale) {
|
|
48
240
|
const cache = cacheFor(factory);
|
|
@@ -275,13 +467,19 @@ var CalendarController = class _CalendarController extends Controller {
|
|
|
275
467
|
min: { type: String, default: "" },
|
|
276
468
|
max: { type: String, default: "" },
|
|
277
469
|
weekStart: { type: Number, default: 0 },
|
|
278
|
-
locale: { type: String, default: "" }
|
|
470
|
+
locale: { type: String, default: "" },
|
|
471
|
+
announceText: { type: String, default: "" }
|
|
279
472
|
};
|
|
280
473
|
static valueConstraints = {
|
|
281
474
|
weekStart: { finite: true, integer: true, min: 0, max: 6 }
|
|
282
475
|
};
|
|
283
476
|
static actions = ["next", "onKeydown", "prev", "select"];
|
|
284
477
|
static events = ["monthchange", "reconcile", "select"];
|
|
478
|
+
#daySelection = new AttributeLease("aria-selected", this.identifier);
|
|
479
|
+
#dayTabindex = new AttributeLease("tabindex", this.identifier);
|
|
480
|
+
#dayDate = new AttributeLease("data-date", this.identifier);
|
|
481
|
+
#dayOutside = new AttributeLease("data-outside", this.identifier);
|
|
482
|
+
#dayToday = new AttributeLease("data-today", this.identifier);
|
|
285
483
|
focusedDate = /* @__PURE__ */ new Date();
|
|
286
484
|
#connected = false;
|
|
287
485
|
#published = "";
|
|
@@ -314,6 +512,9 @@ var CalendarController = class _CalendarController extends Controller {
|
|
|
314
512
|
this.#connected = false;
|
|
315
513
|
this.#repaint.disconnect();
|
|
316
514
|
this.#settleFocus.cancel();
|
|
515
|
+
if (!(this.element.getAttribute("data-controller") ?? "").split(/\s+/).includes(this.identifier)) {
|
|
516
|
+
this.#returnAllDayLeases();
|
|
517
|
+
}
|
|
317
518
|
}
|
|
318
519
|
monthValueChanged() {
|
|
319
520
|
if (!this.monthValue) return;
|
|
@@ -461,15 +662,15 @@ var CalendarController = class _CalendarController extends Controller {
|
|
|
461
662
|
if (kept !== void 0) el.setAttribute("aria-disabled", kept);
|
|
462
663
|
}
|
|
463
664
|
this.#paintedDates.set(el, dateStr);
|
|
464
|
-
|
|
665
|
+
this.#dayDate.write(el, dateStr);
|
|
465
666
|
el.textContent = String(date.getDate());
|
|
466
667
|
const isOutside = date.getFullYear() !== year || date.getMonth() !== month - 1;
|
|
467
|
-
|
|
668
|
+
this.#dayOutside.write(el, String(isOutside));
|
|
468
669
|
const todayStr = toISODateString(/* @__PURE__ */ new Date());
|
|
469
|
-
|
|
470
|
-
|
|
670
|
+
this.#dayToday.write(el, String(dateStr === todayStr));
|
|
671
|
+
this.#daySelection.write(el, String(dateStr === selection));
|
|
471
672
|
const isFocused = toISODateString(this.focusedDate) === dateStr;
|
|
472
|
-
|
|
673
|
+
this.#dayTabindex.write(el, isFocused ? "0" : "-1");
|
|
473
674
|
const isDisabled = this.#isDateOutOfBounds(dateStr);
|
|
474
675
|
if (isDisabled) {
|
|
475
676
|
if (!el.hasAttribute("aria-disabled")) el.setAttribute(this.#ownedDisabled, "");
|
|
@@ -481,7 +682,7 @@ var CalendarController = class _CalendarController extends Controller {
|
|
|
481
682
|
}
|
|
482
683
|
if (!dayElements.some((el) => el.getAttribute("tabindex") === "0")) {
|
|
483
684
|
const fallback = dayElements.find((el) => el.getAttribute("data-outside") === "false") ?? dayElements[0];
|
|
484
|
-
fallback
|
|
685
|
+
if (fallback) this.#dayTabindex.write(fallback, "0");
|
|
485
686
|
}
|
|
486
687
|
const painted = toISOMonthString(monthStart);
|
|
487
688
|
const previous = this.#paintedMonth;
|
|
@@ -536,6 +737,12 @@ var CalendarController = class _CalendarController extends Controller {
|
|
|
536
737
|
labelTargetDisconnected() {
|
|
537
738
|
this.#repaint.schedule();
|
|
538
739
|
}
|
|
740
|
+
dayTargetDisconnected(day) {
|
|
741
|
+
queueMicrotask(() => {
|
|
742
|
+
if (this.dayTargets.includes(day)) return;
|
|
743
|
+
this.#returnDayLeases(day);
|
|
744
|
+
});
|
|
745
|
+
}
|
|
539
746
|
fieldTargetConnected(field) {
|
|
540
747
|
this.#writeField(field, this.#selection);
|
|
541
748
|
}
|
|
@@ -553,6 +760,20 @@ var CalendarController = class _CalendarController extends Controller {
|
|
|
553
760
|
this.#fieldWrites.set(field, (this.#fieldWrites.get(field) ?? 0) + 1);
|
|
554
761
|
return true;
|
|
555
762
|
}
|
|
763
|
+
#returnDayLeases(day) {
|
|
764
|
+
this.#daySelection.return(day);
|
|
765
|
+
this.#dayTabindex.return(day);
|
|
766
|
+
this.#dayDate.return(day);
|
|
767
|
+
this.#dayOutside.return(day);
|
|
768
|
+
this.#dayToday.return(day);
|
|
769
|
+
}
|
|
770
|
+
#returnAllDayLeases() {
|
|
771
|
+
this.#daySelection.returnAll();
|
|
772
|
+
this.#dayTabindex.returnAll();
|
|
773
|
+
this.#dayDate.returnAll();
|
|
774
|
+
this.#dayOutside.returnAll();
|
|
775
|
+
this.#dayToday.returnAll();
|
|
776
|
+
}
|
|
556
777
|
#mirrorFields(painted, selection, reconciled) {
|
|
557
778
|
const ownMove = this.#ownMove;
|
|
558
779
|
this.#ownMove = false;
|
|
@@ -584,6 +805,20 @@ var CalendarController = class _CalendarController extends Controller {
|
|
|
584
805
|
this.#repaintKeepingFocus();
|
|
585
806
|
if (!changed || move !== this.#selectionMoves) return;
|
|
586
807
|
this.dispatch("select", { detail: { date: dateStr, reason } });
|
|
808
|
+
if (selected && move === this.#selectionMoves && this.#selection === dateStr) {
|
|
809
|
+
this.#announceSelection(selected);
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
#announceSelection(date) {
|
|
813
|
+
const formatter = intlFormatter(
|
|
814
|
+
Intl.DateTimeFormat,
|
|
815
|
+
resolveLocale(this.element, this.localeValue),
|
|
816
|
+
{ dateStyle: "long" },
|
|
817
|
+
"en"
|
|
818
|
+
);
|
|
819
|
+
announce(fillTemplate(this.announceTextValue, { date: formatter.format(date) }), {
|
|
820
|
+
afterFocus: true
|
|
821
|
+
});
|
|
587
822
|
}
|
|
588
823
|
#focusAndNavigateToDate(date) {
|
|
589
824
|
this.focusedDate = date;
|
|
@@ -43,6 +43,7 @@ function hasModifierChord(event) {
|
|
|
43
43
|
|
|
44
44
|
function setAttributeIfChanged(element, name, value, beforeWrite) {
|
|
45
45
|
if (element.getAttribute(name) === value) return false;
|
|
46
|
+
beforeWrite?.();
|
|
46
47
|
if (value === null) element.removeAttribute(name);
|
|
47
48
|
else element.setAttribute(name, value);
|
|
48
49
|
return true;
|
|
@@ -116,14 +117,34 @@ var AttributeLease = class {
|
|
|
116
117
|
const names = registry.names;
|
|
117
118
|
names.set(attribute, (names.get(attribute) ?? /* @__PURE__ */ new Set()).add(this.#record));
|
|
118
119
|
}
|
|
119
|
-
write(element, value) {
|
|
120
|
+
write(element, value, beforeWrite) {
|
|
120
121
|
const stack = attributeStack(element, this.#attribute);
|
|
121
122
|
const hold = this.#take(stack) ?? this.#acquire(element, stack);
|
|
122
123
|
this.#held.add(element);
|
|
123
124
|
const shows = !this.#covered(element, stack, hold);
|
|
124
125
|
hold.written = value;
|
|
125
126
|
this.#mark(element, stack);
|
|
126
|
-
if (shows) this.#reflect(element, value);
|
|
127
|
+
if (shows) this.#reflect(element, value, beforeWrite);
|
|
128
|
+
}
|
|
129
|
+
adopt(element, options = {}) {
|
|
130
|
+
const known = registry.stacks.get(element)?.has(this.#attribute);
|
|
131
|
+
if (!this.#held.has(element) && !known && !element.hasAttribute(this.#record)) return false;
|
|
132
|
+
const stack = attributeStack(element, this.#attribute);
|
|
133
|
+
const hold = this.#take(stack);
|
|
134
|
+
if (!hold) return false;
|
|
135
|
+
const current = element.getAttribute(this.#attribute);
|
|
136
|
+
if (options.ifChanged && (current === hold.written || this.#covered(element, stack, hold))) {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
this.#held.add(element);
|
|
140
|
+
hold.original = current;
|
|
141
|
+
hold.linked = false;
|
|
142
|
+
for (const above of stack.slice(stack.indexOf(hold) + 1)) {
|
|
143
|
+
if (!above.linked) break;
|
|
144
|
+
above.original = current;
|
|
145
|
+
}
|
|
146
|
+
this.#mark(element, stack);
|
|
147
|
+
return true;
|
|
127
148
|
}
|
|
128
149
|
return(element) {
|
|
129
150
|
const held = this.#held.delete(element);
|
|
@@ -189,8 +210,8 @@ var AttributeLease = class {
|
|
|
189
210
|
setAttributeIfChanged(element, name, recorded);
|
|
190
211
|
}
|
|
191
212
|
}
|
|
192
|
-
#reflect(element, value) {
|
|
193
|
-
setAttributeIfChanged(element, this.#attribute, value);
|
|
213
|
+
#reflect(element, value, beforeWrite) {
|
|
214
|
+
setAttributeIfChanged(element, this.#attribute, value, beforeWrite);
|
|
194
215
|
}
|
|
195
216
|
};
|
|
196
217
|
|
|
@@ -412,8 +433,12 @@ function prefersReducedMotion() {
|
|
|
412
433
|
|
|
413
434
|
var RovingTabindex = class {
|
|
414
435
|
#getItems;
|
|
415
|
-
|
|
436
|
+
#write;
|
|
437
|
+
constructor(getItems, write = (item, tabindex) => {
|
|
438
|
+
item.tabIndex = tabindex;
|
|
439
|
+
}) {
|
|
416
440
|
this.#getItems = getItems;
|
|
441
|
+
this.#write = write;
|
|
417
442
|
}
|
|
418
443
|
get activeIndex() {
|
|
419
444
|
return this.#getItems().findIndex((item) => item.tabIndex === 0);
|
|
@@ -422,7 +447,7 @@ var RovingTabindex = class {
|
|
|
422
447
|
const { focus = false } = options;
|
|
423
448
|
const items = options.items ?? this.#getItems();
|
|
424
449
|
items.forEach((item, i) => {
|
|
425
|
-
item
|
|
450
|
+
this.#write(item, i === index ? 0 : -1);
|
|
426
451
|
});
|
|
427
452
|
if (focus) items[index]?.focus();
|
|
428
453
|
}
|
|
@@ -644,7 +669,17 @@ var CarouselController = class _CarouselController extends Controller {
|
|
|
644
669
|
"togglePlay"
|
|
645
670
|
];
|
|
646
671
|
static events = ["change", "pause", "play", "reconcile"];
|
|
647
|
-
#
|
|
672
|
+
#slideState = new AttributeLease("data-state", this.identifier);
|
|
673
|
+
#slideHidden = new AttributeLease("hidden", this.identifier);
|
|
674
|
+
#slideInert = new AttributeLease("inert", this.identifier);
|
|
675
|
+
#pickerSelected = new AttributeLease("aria-selected", this.identifier);
|
|
676
|
+
#pickerTabindex = new AttributeLease("tabindex", this.identifier);
|
|
677
|
+
#roving = new RovingTabindex(
|
|
678
|
+
() => this.pickerTargets,
|
|
679
|
+
(picker, tabindex) => {
|
|
680
|
+
this.#pickerTabindex.write(picker, String(tabindex));
|
|
681
|
+
}
|
|
682
|
+
);
|
|
648
683
|
#reconcileTargets = new MorphRenderWatcher(() => this.#reconcileTargetSet());
|
|
649
684
|
#intervals = new SafeInterval();
|
|
650
685
|
#ariaDisabled = new AttributeLease("aria-disabled", this.identifier);
|
|
@@ -719,19 +754,32 @@ var CarouselController = class _CarouselController extends Controller {
|
|
|
719
754
|
this.#hiddenPaused = false;
|
|
720
755
|
this.#activeSlide = null;
|
|
721
756
|
this.#returnLeases();
|
|
757
|
+
if (!(this.element.getAttribute("data-controller") ?? "").split(/\s+/).includes(this.identifier)) {
|
|
758
|
+
this.#returnTargetLeases();
|
|
759
|
+
}
|
|
722
760
|
this.#gate.disconnected(this, () => this.#endRun());
|
|
723
761
|
}
|
|
724
|
-
pickerTargetConnected(
|
|
725
|
-
picker.tabIndex = -1;
|
|
762
|
+
pickerTargetConnected() {
|
|
726
763
|
this.#reconcileTargets.schedule();
|
|
727
764
|
}
|
|
728
|
-
pickerTargetDisconnected() {
|
|
765
|
+
pickerTargetDisconnected(picker) {
|
|
766
|
+
queueMicrotask(() => {
|
|
767
|
+
if (this.pickerTargets.includes(picker)) return;
|
|
768
|
+
this.#pickerSelected.return(picker);
|
|
769
|
+
this.#pickerTabindex.return(picker);
|
|
770
|
+
});
|
|
729
771
|
this.#reconcileTargets.schedule();
|
|
730
772
|
}
|
|
731
773
|
slideTargetConnected() {
|
|
732
774
|
this.#reconcileTargets.schedule();
|
|
733
775
|
}
|
|
734
|
-
slideTargetDisconnected() {
|
|
776
|
+
slideTargetDisconnected(slide) {
|
|
777
|
+
queueMicrotask(() => {
|
|
778
|
+
if (this.slideTargets.includes(slide)) return;
|
|
779
|
+
this.#slideState.return(slide);
|
|
780
|
+
this.#slideHidden.return(slide);
|
|
781
|
+
this.#slideInert.return(slide);
|
|
782
|
+
});
|
|
735
783
|
this.#reconcileTargets.schedule();
|
|
736
784
|
}
|
|
737
785
|
viewportTargetConnected() {
|
|
@@ -941,13 +989,13 @@ var CarouselController = class _CarouselController extends Controller {
|
|
|
941
989
|
this.#activeSlide = this.slideTargets[this.#index] ?? null;
|
|
942
990
|
this.slideTargets.forEach((slide, i) => {
|
|
943
991
|
const active = i === this.#index;
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
992
|
+
this.#slideState.write(slide, active ? "active" : "inactive");
|
|
993
|
+
this.#slideHidden.write(slide, active ? null : "");
|
|
994
|
+
this.#slideInert.write(slide, active ? null : "");
|
|
947
995
|
});
|
|
948
996
|
const pickerIndex = Math.min(this.#index, this.pickerTargets.length - 1);
|
|
949
997
|
this.pickerTargets.forEach((picker, i) => {
|
|
950
|
-
|
|
998
|
+
this.#pickerSelected.write(picker, i === pickerIndex ? "true" : "false");
|
|
951
999
|
});
|
|
952
1000
|
this.#syncStepControls();
|
|
953
1001
|
this.#roving.setActive(pickerIndex, { focus });
|
|
@@ -1050,6 +1098,13 @@ var CarouselController = class _CarouselController extends Controller {
|
|
|
1050
1098
|
this.#ariaLive.returnAll();
|
|
1051
1099
|
this.#ariaAtomic.returnAll();
|
|
1052
1100
|
}
|
|
1101
|
+
#returnTargetLeases() {
|
|
1102
|
+
this.#slideState.returnAll();
|
|
1103
|
+
this.#slideHidden.returnAll();
|
|
1104
|
+
this.#slideInert.returnAll();
|
|
1105
|
+
this.#pickerSelected.returnAll();
|
|
1106
|
+
this.#pickerTabindex.returnAll();
|
|
1107
|
+
}
|
|
1053
1108
|
get #safeInterval() {
|
|
1054
1109
|
return this.#numbers.read(
|
|
1055
1110
|
this,
|