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
|
@@ -44,45 +44,234 @@ function setAttributeIfChanged(element, name, value, beforeWrite) {
|
|
|
44
44
|
return true;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
function sharedRegistry(key, create) {
|
|
48
|
+
const symbol = Symbol.for(key);
|
|
49
|
+
const scope = globalThis;
|
|
50
|
+
const existing = scope[symbol];
|
|
51
|
+
if (existing !== void 0) return existing;
|
|
52
|
+
const registry2 = create();
|
|
53
|
+
Object.defineProperty(globalThis, symbol, { value: registry2 });
|
|
54
|
+
return registry2;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
var registry = sharedRegistry(
|
|
58
|
+
"stimeo-ui.attribute-lease.registry.v1",
|
|
59
|
+
() => ({ stacks: /* @__PURE__ */ new WeakMap(), names: /* @__PURE__ */ new Map() })
|
|
60
|
+
);
|
|
61
|
+
function isAttributeValue(value) {
|
|
62
|
+
return value === null || typeof value === "string";
|
|
63
|
+
}
|
|
64
|
+
function readLeaseRecord(element, record) {
|
|
65
|
+
try {
|
|
66
|
+
const parsed = JSON.parse(element.getAttribute(record) ?? "null");
|
|
67
|
+
if (!Array.isArray(parsed)) return void 0;
|
|
68
|
+
const [original, written, ...rest] = parsed;
|
|
69
|
+
const linked = rest[0] !== false;
|
|
70
|
+
const beneath = linked ? rest : rest.slice(1);
|
|
71
|
+
if (!beneath.every((under) => typeof under === "string")) return void 0;
|
|
72
|
+
return isAttributeValue(original) && isAttributeValue(written) ? { original, written, linked, beneath } : void 0;
|
|
73
|
+
} catch {
|
|
74
|
+
return void 0;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function attributeStack(element, attribute) {
|
|
78
|
+
const byAttribute = registry.stacks.get(element) ?? /* @__PURE__ */ new Map();
|
|
79
|
+
registry.stacks.set(element, byAttribute);
|
|
80
|
+
const known = byAttribute.get(attribute);
|
|
81
|
+
if (known) return known;
|
|
82
|
+
const found = [];
|
|
83
|
+
for (const record of registry.names.get(attribute) ?? []) {
|
|
84
|
+
const read = readLeaseRecord(element, record);
|
|
85
|
+
if (read) found.push({ ...read, record });
|
|
86
|
+
}
|
|
87
|
+
const depth = ({ beneath }) => beneath.filter((name) => found.some((other) => other.record === name)).length;
|
|
88
|
+
const stack = found.sort((one, other) => depth(one) - depth(other)).map(({ record, written, original, linked }, index) => ({
|
|
89
|
+
lease: null,
|
|
90
|
+
record,
|
|
91
|
+
written,
|
|
92
|
+
original,
|
|
93
|
+
linked: linked && index > 0
|
|
94
|
+
}));
|
|
95
|
+
byAttribute.set(attribute, stack);
|
|
96
|
+
return stack;
|
|
97
|
+
}
|
|
98
|
+
function findHold(stack, lease, record) {
|
|
99
|
+
return stack.find((held) => held.lease === lease) ?? stack.find((held) => held.lease === null && held.record === record);
|
|
100
|
+
}
|
|
101
|
+
var AttributeLease = class {
|
|
102
|
+
#attribute;
|
|
103
|
+
#record;
|
|
104
|
+
#base;
|
|
105
|
+
#preserveAuthor;
|
|
106
|
+
#held = /* @__PURE__ */ new Set();
|
|
107
|
+
constructor(attribute, owner, options = {}) {
|
|
108
|
+
this.#attribute = attribute;
|
|
109
|
+
this.#record = `data-${owner}-${attribute}-lease`;
|
|
110
|
+
this.#base = options.base === true;
|
|
111
|
+
this.#preserveAuthor = options.preserveAuthor === true;
|
|
112
|
+
const names = registry.names;
|
|
113
|
+
names.set(attribute, (names.get(attribute) ?? /* @__PURE__ */ new Set()).add(this.#record));
|
|
114
|
+
}
|
|
115
|
+
write(element, value, beforeWrite) {
|
|
116
|
+
const stack = attributeStack(element, this.#attribute);
|
|
117
|
+
const hold = this.#take(stack) ?? this.#acquire(element, stack);
|
|
118
|
+
this.#held.add(element);
|
|
119
|
+
const shows = !this.#covered(element, stack, hold);
|
|
120
|
+
hold.written = value;
|
|
121
|
+
this.#mark(element, stack);
|
|
122
|
+
if (shows) this.#reflect(element, value, beforeWrite);
|
|
123
|
+
}
|
|
124
|
+
adopt(element, options = {}) {
|
|
125
|
+
const known = registry.stacks.get(element)?.has(this.#attribute);
|
|
126
|
+
if (!this.#held.has(element) && !known && !element.hasAttribute(this.#record)) return false;
|
|
127
|
+
const stack = attributeStack(element, this.#attribute);
|
|
128
|
+
const hold = this.#take(stack);
|
|
129
|
+
if (!hold) return false;
|
|
130
|
+
const current = element.getAttribute(this.#attribute);
|
|
131
|
+
if (options.ifChanged && (current === hold.written || this.#covered(element, stack, hold))) {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
this.#held.add(element);
|
|
135
|
+
hold.original = current;
|
|
136
|
+
hold.linked = false;
|
|
137
|
+
for (const above of stack.slice(stack.indexOf(hold) + 1)) {
|
|
138
|
+
if (!above.linked) break;
|
|
139
|
+
above.original = current;
|
|
140
|
+
}
|
|
141
|
+
this.#mark(element, stack);
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
return(element) {
|
|
145
|
+
const held = this.#held.delete(element);
|
|
146
|
+
const known = registry.stacks.get(element)?.has(this.#attribute);
|
|
147
|
+
const stack = held || known || element.hasAttribute(this.#record) ? attributeStack(element, this.#attribute) : [];
|
|
148
|
+
const hold = this.#take(stack);
|
|
149
|
+
if (!hold) return false;
|
|
150
|
+
const carries = element.getAttribute(this.#attribute) === hold.written;
|
|
151
|
+
const owns = carries && !this.#covered(element, stack, hold);
|
|
152
|
+
const index = stack.indexOf(hold);
|
|
153
|
+
stack.splice(index, 1);
|
|
154
|
+
const above = stack[index];
|
|
155
|
+
if (above) above.linked &&= hold.linked;
|
|
156
|
+
this.#mark(element, stack);
|
|
157
|
+
if (!owns) return true;
|
|
158
|
+
const below = hold.linked ? stack[index - 1] : void 0;
|
|
159
|
+
this.#reflect(element, below ? below.written : hold.original);
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
returnAll() {
|
|
163
|
+
for (const element of Array.from(this.#held)) this.return(element);
|
|
164
|
+
}
|
|
165
|
+
#take(stack) {
|
|
166
|
+
const hold = findHold(stack, this, this.#record);
|
|
167
|
+
if (hold) hold.lease = this;
|
|
168
|
+
return hold;
|
|
169
|
+
}
|
|
170
|
+
#acquire(element, stack) {
|
|
171
|
+
const current = element.getAttribute(this.#attribute);
|
|
172
|
+
const top = stack.at(-1);
|
|
173
|
+
const bottom = stack[0];
|
|
174
|
+
const over = top?.written === current ? top : void 0;
|
|
175
|
+
const from = this.#base ? this.#preserveAuthor && !stack.some((held) => held.written === current) ? void 0 : bottom : over;
|
|
176
|
+
const hold = {
|
|
177
|
+
lease: this,
|
|
178
|
+
record: this.#record,
|
|
179
|
+
written: current,
|
|
180
|
+
original: from ? from.original : current,
|
|
181
|
+
linked: !this.#base && over !== void 0
|
|
182
|
+
};
|
|
183
|
+
if (this.#base && bottom) {
|
|
184
|
+
bottom.linked = true;
|
|
185
|
+
stack.unshift(hold);
|
|
186
|
+
} else stack.push(hold);
|
|
187
|
+
return hold;
|
|
188
|
+
}
|
|
189
|
+
#covered(element, stack, hold) {
|
|
190
|
+
const current = element.getAttribute(this.#attribute);
|
|
191
|
+
return stack.slice(stack.indexOf(hold) + 1).some((above) => above.written === current);
|
|
192
|
+
}
|
|
193
|
+
#mark(element, stack) {
|
|
194
|
+
const records = /* @__PURE__ */ new Map([[this.#record, null]]);
|
|
195
|
+
stack.forEach((hold, index) => {
|
|
196
|
+
const names = stack.slice(0, index).map((under) => under.record);
|
|
197
|
+
const beneath = [...new Set(names.reverse())].filter((name) => name !== hold.record);
|
|
198
|
+
const marker = hold.linked || beneath.length === 0 ? [] : [false];
|
|
199
|
+
records.set(
|
|
200
|
+
hold.record,
|
|
201
|
+
hold.written === hold.original && beneath.length === 0 && index === stack.length - 1 ? null : JSON.stringify([hold.original, hold.written, ...marker, ...beneath])
|
|
202
|
+
);
|
|
203
|
+
});
|
|
204
|
+
for (const [name, recorded] of records) {
|
|
205
|
+
setAttributeIfChanged(element, name, recorded);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
#reflect(element, value, beforeWrite) {
|
|
209
|
+
setAttributeIfChanged(element, this.#attribute, value, beforeWrite);
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
|
|
47
213
|
var AuthoredMutationWatcher = class {
|
|
48
214
|
#onAuthored;
|
|
49
|
-
#
|
|
50
|
-
#observer = null;
|
|
215
|
+
#lifetime = null;
|
|
51
216
|
constructor(onAuthored) {
|
|
52
217
|
this.#onAuthored = onAuthored;
|
|
53
218
|
}
|
|
54
219
|
observe(root, options) {
|
|
55
|
-
this
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
this.#
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
220
|
+
const previous = this.#lifetime;
|
|
221
|
+
const lifetime = {
|
|
222
|
+
observer: null,
|
|
223
|
+
active: false,
|
|
224
|
+
claims: { attributes: /* @__PURE__ */ new Map(), children: /* @__PURE__ */ new Map() }
|
|
225
|
+
};
|
|
226
|
+
this.#lifetime = lifetime;
|
|
227
|
+
let observer = null;
|
|
228
|
+
try {
|
|
229
|
+
if (previous) this.#release(previous);
|
|
230
|
+
if (this.#lifetime !== lifetime) return;
|
|
231
|
+
const attributes = [...options.attributes];
|
|
232
|
+
const subtree = options.subtree ?? false;
|
|
233
|
+
const childList = options.childList ?? false;
|
|
234
|
+
const inherited = options.ancestorAttributes;
|
|
235
|
+
const ancestorAttributes = inherited ? [...inherited] : null;
|
|
236
|
+
if (this.#lifetime !== lifetime) return;
|
|
237
|
+
observer = new MutationObserver((records) => {
|
|
238
|
+
const authored = this.#filter(records, lifetime.claims);
|
|
239
|
+
if (this.#lifetime === lifetime && lifetime.active && authored.length > 0) {
|
|
240
|
+
this.#onAuthored(authored);
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
if (this.#lifetime !== lifetime) return;
|
|
244
|
+
lifetime.observer = observer;
|
|
245
|
+
observer.observe(root, { attributes: true, attributeFilter: attributes, subtree, childList });
|
|
246
|
+
if (this.#lifetime !== lifetime) {
|
|
247
|
+
this.#release(lifetime, observer);
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
if (ancestorAttributes) {
|
|
251
|
+
let ancestor = root.parentElement;
|
|
252
|
+
while (ancestor) {
|
|
253
|
+
observer.observe(ancestor, { attributes: true, attributeFilter: ancestorAttributes });
|
|
254
|
+
if (this.#lifetime !== lifetime) {
|
|
255
|
+
this.#release(lifetime, observer);
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
ancestor = ancestor.parentElement;
|
|
259
|
+
}
|
|
77
260
|
}
|
|
261
|
+
lifetime.active = true;
|
|
262
|
+
} catch (error) {
|
|
263
|
+
this.#release(lifetime, observer);
|
|
264
|
+
throw error;
|
|
78
265
|
}
|
|
79
266
|
}
|
|
80
267
|
claim(target, name, value) {
|
|
81
|
-
const
|
|
82
|
-
|
|
268
|
+
const lifetime = this.#lifetime;
|
|
269
|
+
if (!lifetime?.active) return;
|
|
270
|
+
const claims = lifetime.claims.attributes;
|
|
271
|
+
let attributes = claims.get(target);
|
|
83
272
|
if (!attributes) {
|
|
84
273
|
attributes = /* @__PURE__ */ new Map();
|
|
85
|
-
claims
|
|
274
|
+
claims.set(target, attributes);
|
|
86
275
|
}
|
|
87
276
|
const pending = attributes.get(name);
|
|
88
277
|
attributes.set(name, { value, count: (pending?.count ?? 0) + 1 });
|
|
@@ -91,37 +280,49 @@ var AuthoredMutationWatcher = class {
|
|
|
91
280
|
this.claim(target, name, target.getAttribute(name));
|
|
92
281
|
}
|
|
93
282
|
claimChildList(target, added, removed) {
|
|
94
|
-
const
|
|
95
|
-
|
|
283
|
+
const lifetime = this.#lifetime;
|
|
284
|
+
if (!lifetime?.active) return;
|
|
285
|
+
const claims = lifetime.claims.children;
|
|
286
|
+
const pending = claims.get(target) ?? { added: /* @__PURE__ */ new Map(), removed: /* @__PURE__ */ new Map() };
|
|
96
287
|
for (const node of added) pending.added.set(node, (pending.added.get(node) ?? 0) + 1);
|
|
97
288
|
for (const node of removed) pending.removed.set(node, (pending.removed.get(node) ?? 0) + 1);
|
|
98
|
-
claims
|
|
289
|
+
claims.set(target, pending);
|
|
99
290
|
}
|
|
100
291
|
take() {
|
|
101
|
-
|
|
292
|
+
const lifetime = this.#lifetime;
|
|
293
|
+
const observer = lifetime?.observer;
|
|
294
|
+
if (!lifetime?.active || !observer) return [];
|
|
295
|
+
const records = observer.takeRecords();
|
|
296
|
+
const authored = this.#filter(records, lifetime.claims);
|
|
297
|
+
return this.#lifetime === lifetime && lifetime.active ? authored : [];
|
|
102
298
|
}
|
|
103
299
|
disconnect() {
|
|
104
|
-
this.#
|
|
105
|
-
this.#
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
300
|
+
const lifetime = this.#lifetime;
|
|
301
|
+
if (lifetime) this.#release(lifetime);
|
|
302
|
+
}
|
|
303
|
+
#release(lifetime, observer = lifetime.observer) {
|
|
304
|
+
if (this.#lifetime === lifetime) this.#lifetime = null;
|
|
305
|
+
lifetime.claims.attributes.clear();
|
|
306
|
+
lifetime.claims.children.clear();
|
|
307
|
+
observer?.disconnect();
|
|
308
|
+
}
|
|
309
|
+
#filter(records, claims) {
|
|
310
|
+
const authored = records.filter((record) => !this.#consume(record, claims));
|
|
311
|
+
claims.attributes.clear();
|
|
312
|
+
claims.children.clear();
|
|
112
313
|
return authored;
|
|
113
314
|
}
|
|
114
|
-
#consume(record) {
|
|
315
|
+
#consume(record, claims) {
|
|
115
316
|
if (record.type === "attributes") {
|
|
116
317
|
const target = record.target;
|
|
117
|
-
const pending2 =
|
|
318
|
+
const pending2 = claims.attributes.get(target)?.get(record.attributeName);
|
|
118
319
|
if (!pending2 || pending2.count === 0 || target.getAttribute(record.attributeName) !== pending2.value) {
|
|
119
320
|
return false;
|
|
120
321
|
}
|
|
121
322
|
pending2.count -= 1;
|
|
122
323
|
return true;
|
|
123
324
|
}
|
|
124
|
-
const pending =
|
|
325
|
+
const pending = claims.children.get(record.target);
|
|
125
326
|
if (!pending) return false;
|
|
126
327
|
const added = [...record.addedNodes];
|
|
127
328
|
const removed = [...record.removedNodes];
|
|
@@ -283,6 +484,13 @@ var DataGridController = class extends Controller {
|
|
|
283
484
|
};
|
|
284
485
|
static actions = ["onKeydown", "sort", "toggleSelect"];
|
|
285
486
|
static events = ["selectionchange", "sort", "reconcile"];
|
|
487
|
+
#selected = new AttributeLease("aria-selected", this.identifier);
|
|
488
|
+
#tabindex = new AttributeLease("tabindex", this.identifier);
|
|
489
|
+
#sort = new AttributeLease("aria-sort", this.identifier);
|
|
490
|
+
#multiselectable = new AttributeLease(
|
|
491
|
+
"aria-multiselectable",
|
|
492
|
+
this.identifier
|
|
493
|
+
);
|
|
286
494
|
#reconcile = new MorphRenderWatcher(() => this.#reconcileRows());
|
|
287
495
|
#observer = new AuthoredMutationWatcher((records) => {
|
|
288
496
|
if (this.#concernsRows(records)) this.#reconcile.schedule();
|
|
@@ -298,6 +506,7 @@ var DataGridController = class extends Controller {
|
|
|
298
506
|
this.#connectionGeneration += 1;
|
|
299
507
|
this.#reconcile.disconnect();
|
|
300
508
|
this.#observer.disconnect();
|
|
509
|
+
if (!this.scope.containsElement(this.element)) this.#multiselectable.return(this.element);
|
|
301
510
|
}
|
|
302
511
|
#restoreBaseline() {
|
|
303
512
|
const cells = this.#navigableCells();
|
|
@@ -339,21 +548,34 @@ var DataGridController = class extends Controller {
|
|
|
339
548
|
rowTargetConnected() {
|
|
340
549
|
this.#reconcile.schedule();
|
|
341
550
|
}
|
|
342
|
-
rowTargetDisconnected() {
|
|
551
|
+
rowTargetDisconnected(row) {
|
|
552
|
+
if (!this.scope.containsElement(row) || !this.rowTargets.includes(row)) {
|
|
553
|
+
this.#selected.return(row);
|
|
554
|
+
}
|
|
343
555
|
this.#reconcile.schedule();
|
|
344
556
|
}
|
|
345
557
|
cellTargetConnected() {
|
|
346
558
|
this.#reconcile.schedule();
|
|
347
559
|
}
|
|
348
|
-
cellTargetDisconnected() {
|
|
560
|
+
cellTargetDisconnected(cell) {
|
|
561
|
+
this.#returnTabindex(cell);
|
|
349
562
|
this.#reconcile.schedule();
|
|
350
563
|
}
|
|
351
564
|
columnHeaderTargetConnected() {
|
|
352
565
|
this.#reconcile.schedule();
|
|
353
566
|
}
|
|
354
|
-
columnHeaderTargetDisconnected() {
|
|
567
|
+
columnHeaderTargetDisconnected(header) {
|
|
568
|
+
if (!this.scope.containsElement(header) || !this.columnHeaderTargets.includes(header)) {
|
|
569
|
+
this.#sort.return(header);
|
|
570
|
+
}
|
|
571
|
+
this.#returnTabindex(header);
|
|
355
572
|
this.#reconcile.schedule();
|
|
356
573
|
}
|
|
574
|
+
#returnTabindex(cell) {
|
|
575
|
+
if (this.scope.containsElement(cell) && (this.cellTargets.includes(cell) || this.columnHeaderTargets.includes(cell)))
|
|
576
|
+
return;
|
|
577
|
+
this.#tabindex.return(cell);
|
|
578
|
+
}
|
|
357
579
|
#normalizeSelection() {
|
|
358
580
|
const rows = this.rowTargets;
|
|
359
581
|
if (this.selectionValue === "none") {
|
|
@@ -372,9 +594,9 @@ var DataGridController = class extends Controller {
|
|
|
372
594
|
}
|
|
373
595
|
#syncSelectable() {
|
|
374
596
|
if (this.selectionValue === "multiple") {
|
|
375
|
-
|
|
597
|
+
this.#multiselectable.write(this.element, "true");
|
|
376
598
|
} else {
|
|
377
|
-
this.element
|
|
599
|
+
this.#multiselectable.write(this.element, null);
|
|
378
600
|
}
|
|
379
601
|
}
|
|
380
602
|
sort(source) {
|
|
@@ -388,7 +610,7 @@ var DataGridController = class extends Controller {
|
|
|
388
610
|
if (control && !(control instanceof HTMLButtonElement)) return;
|
|
389
611
|
const direction = nextSortDirection(header.getAttribute("aria-sort") ?? "none");
|
|
390
612
|
for (const other of this.columnHeaderTargets) {
|
|
391
|
-
|
|
613
|
+
this.#sort.write(other, other === header ? direction : "none");
|
|
392
614
|
}
|
|
393
615
|
this.#setActiveCell(header, { focus: false });
|
|
394
616
|
this.dispatch("sort", { detail: { column: header, direction, reason } });
|
|
@@ -471,7 +693,7 @@ var DataGridController = class extends Controller {
|
|
|
471
693
|
#cycleSort(header) {
|
|
472
694
|
const direction = nextSortDirection(header.getAttribute("aria-sort") ?? "none");
|
|
473
695
|
for (const other of this.columnHeaderTargets) {
|
|
474
|
-
|
|
696
|
+
this.#sort.write(other, other === header ? direction : "none");
|
|
475
697
|
}
|
|
476
698
|
this.dispatch("sort", { detail: { column: header, direction, reason: "user" } });
|
|
477
699
|
}
|
|
@@ -533,7 +755,7 @@ var DataGridController = class extends Controller {
|
|
|
533
755
|
this.#stopHolder = cell;
|
|
534
756
|
for (const candidate of cells ?? this.#navigableCells()) {
|
|
535
757
|
const wanted = candidate === cell ? "0" : "-1";
|
|
536
|
-
|
|
758
|
+
this.#tabindex.write(candidate, wanted);
|
|
537
759
|
}
|
|
538
760
|
if (focus) cell.focus();
|
|
539
761
|
}
|
|
@@ -562,7 +784,7 @@ var DataGridController = class extends Controller {
|
|
|
562
784
|
return cells[Math.min(col, cells.length - 1)];
|
|
563
785
|
}
|
|
564
786
|
#writeSelection(target, value) {
|
|
565
|
-
|
|
787
|
+
this.#selected.write(target, value, () => {
|
|
566
788
|
this.#observer.claim(target, "aria-selected", value);
|
|
567
789
|
});
|
|
568
790
|
}
|
|
@@ -45,6 +45,7 @@ function hasModifierChord(event) {
|
|
|
45
45
|
|
|
46
46
|
function setAttributeIfChanged(element, name, value, beforeWrite) {
|
|
47
47
|
if (element.getAttribute(name) === value) return false;
|
|
48
|
+
beforeWrite?.();
|
|
48
49
|
if (value === null) element.removeAttribute(name);
|
|
49
50
|
else element.setAttribute(name, value);
|
|
50
51
|
return true;
|
|
@@ -118,14 +119,34 @@ var AttributeLease = class {
|
|
|
118
119
|
const names = registry.names;
|
|
119
120
|
names.set(attribute, (names.get(attribute) ?? /* @__PURE__ */ new Set()).add(this.#record));
|
|
120
121
|
}
|
|
121
|
-
write(element, value) {
|
|
122
|
+
write(element, value, beforeWrite) {
|
|
122
123
|
const stack = attributeStack(element, this.#attribute);
|
|
123
124
|
const hold = this.#take(stack) ?? this.#acquire(element, stack);
|
|
124
125
|
this.#held.add(element);
|
|
125
126
|
const shows = !this.#covered(element, stack, hold);
|
|
126
127
|
hold.written = value;
|
|
127
128
|
this.#mark(element, stack);
|
|
128
|
-
if (shows) this.#reflect(element, value);
|
|
129
|
+
if (shows) this.#reflect(element, value, beforeWrite);
|
|
130
|
+
}
|
|
131
|
+
adopt(element, options = {}) {
|
|
132
|
+
const known = registry.stacks.get(element)?.has(this.#attribute);
|
|
133
|
+
if (!this.#held.has(element) && !known && !element.hasAttribute(this.#record)) return false;
|
|
134
|
+
const stack = attributeStack(element, this.#attribute);
|
|
135
|
+
const hold = this.#take(stack);
|
|
136
|
+
if (!hold) return false;
|
|
137
|
+
const current = element.getAttribute(this.#attribute);
|
|
138
|
+
if (options.ifChanged && (current === hold.written || this.#covered(element, stack, hold))) {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
this.#held.add(element);
|
|
142
|
+
hold.original = current;
|
|
143
|
+
hold.linked = false;
|
|
144
|
+
for (const above of stack.slice(stack.indexOf(hold) + 1)) {
|
|
145
|
+
if (!above.linked) break;
|
|
146
|
+
above.original = current;
|
|
147
|
+
}
|
|
148
|
+
this.#mark(element, stack);
|
|
149
|
+
return true;
|
|
129
150
|
}
|
|
130
151
|
return(element) {
|
|
131
152
|
const held = this.#held.delete(element);
|
|
@@ -191,8 +212,8 @@ var AttributeLease = class {
|
|
|
191
212
|
setAttributeIfChanged(element, name, recorded);
|
|
192
213
|
}
|
|
193
214
|
}
|
|
194
|
-
#reflect(element, value) {
|
|
195
|
-
setAttributeIfChanged(element, this.#attribute, value);
|
|
215
|
+
#reflect(element, value, beforeWrite) {
|
|
216
|
+
setAttributeIfChanged(element, this.#attribute, value, beforeWrite);
|
|
196
217
|
}
|
|
197
218
|
};
|
|
198
219
|
|
|
@@ -710,7 +731,8 @@ var DateRangePickerController = class extends Controller {
|
|
|
710
731
|
if (!el || !date) continue;
|
|
711
732
|
const iso = toISODateString(date);
|
|
712
733
|
el.setAttribute("data-date", iso);
|
|
713
|
-
|
|
734
|
+
const dayText = String(date.getDate());
|
|
735
|
+
if (el.textContent !== dayText) el.textContent = dayText;
|
|
714
736
|
el.setAttribute("data-outside", String(date.getMonth() !== month - 1));
|
|
715
737
|
el.setAttribute("data-today", String(iso === todayStr));
|
|
716
738
|
el.setAttribute("tabindex", iso === focusedStr ? "0" : "-1");
|