stimeo-ui 0.18.2 → 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 +33 -0
- data/dist/controllers/alert_dialog_controller.js +246 -42
- data/dist/controllers/auto_submit_controller.js +26 -5
- data/dist/controllers/avatar_controller.js +29 -9
- data/dist/controllers/breadcrumb_controller.js +205 -17
- data/dist/controllers/bulk_select_controller.js +25 -4
- data/dist/controllers/calendar_controller.js +242 -7
- data/dist/controllers/carousel_controller.js +70 -15
- data/dist/controllers/character_counter_controller.js +26 -5
- data/dist/controllers/collapsible_controller.js +35 -8
- data/dist/controllers/combobox_controller.js +84 -20
- data/dist/controllers/command_palette_controller.js +296 -77
- data/dist/controllers/confirm_controller.js +225 -34
- data/dist/controllers/context_menu_controller.js +58 -29
- data/dist/controllers/currency_input_controller.js +1 -1
- data/dist/controllers/data_grid_controller.js +196 -9
- data/dist/controllers/date_range_picker_controller.js +25 -4
- data/dist/controllers/dialog_controller.js +252 -45
- data/dist/controllers/dismissible_controller.js +57 -11
- data/dist/controllers/drawer_controller.js +284 -58
- data/dist/controllers/dropdown_controller.js +63 -51
- data/dist/controllers/editable_controller.js +69 -6
- data/dist/controllers/empty_state_controller.js +187 -4
- data/dist/controllers/file_dropzone_controller.js +300 -12
- data/dist/controllers/filter_controller.js +194 -5
- data/dist/controllers/flash_controller.js +199 -12
- data/dist/controllers/focus_controller.js +195 -23
- data/dist/controllers/form_field_controller.js +65 -9
- data/dist/controllers/frame_loading_controller.js +25 -4
- data/dist/controllers/hover_card_controller.js +107 -38
- data/dist/controllers/input_mask_controller.js +1 -1
- data/dist/controllers/listbox_controller.js +94 -36
- data/dist/controllers/menu_controller.js +44 -23
- data/dist/controllers/menubar_controller.js +228 -46
- data/dist/controllers/meter_controller.js +25 -4
- data/dist/controllers/multi_select_controller.js +110 -42
- data/dist/controllers/nested_form_controller.js +258 -9
- data/dist/controllers/network_status_controller.js +25 -4
- data/dist/controllers/number_input_controller.js +26 -5
- data/dist/controllers/otp_controller.js +26 -5
- data/dist/controllers/overflow_menu_controller.js +183 -22
- data/dist/controllers/pagination_controller.js +179 -22
- data/dist/controllers/password_reveal_controller.js +25 -4
- data/dist/controllers/popover_controller.js +454 -34
- data/dist/controllers/progress_controller.js +25 -4
- data/dist/controllers/radio_group_controller.js +195 -40
- data/dist/controllers/rating_controller.js +58 -10
- data/dist/controllers/read_more_controller.js +191 -25
- data/dist/controllers/roving_controller.js +197 -6
- data/dist/controllers/scroll_area_controller.js +50 -12
- data/dist/controllers/scroll_visibility_controller.js +25 -4
- data/dist/controllers/scrollspy_controller.js +179 -3
- data/dist/controllers/separator_controller.js +25 -4
- data/dist/controllers/sidebar_controller.js +290 -93
- data/dist/controllers/skeleton_controller.js +25 -4
- data/dist/controllers/spinner_controller.js +25 -4
- data/dist/controllers/step_indicator_controller.js +181 -6
- data/dist/controllers/stepper_controller.js +188 -6
- data/dist/controllers/sticky_observer_controller.js +25 -4
- data/dist/controllers/submit_once_controller.js +25 -4
- data/dist/controllers/tabs_controller.js +189 -3
- data/dist/controllers/tags_input_controller.js +210 -9
- data/dist/controllers/theme_controller.js +192 -5
- data/dist/controllers/toast_controller.js +478 -16
- data/dist/controllers/toggle_group_controller.js +198 -35
- data/dist/controllers/toolbar_controller.js +198 -7
- data/dist/controllers/tooltip_controller.js +243 -45
- data/dist/controllers/tree_view_controller.js +200 -8
- data/dist/index.js +1764 -739
- data/lib/stimeo/ui/version.rb +1 -1
- metadata +2 -2
|
@@ -85,6 +85,7 @@ function hasModifierChord(event) {
|
|
|
85
85
|
|
|
86
86
|
function setAttributeIfChanged(element, name, value, beforeWrite) {
|
|
87
87
|
if (element.getAttribute(name) === value) return false;
|
|
88
|
+
beforeWrite?.();
|
|
88
89
|
if (value === null) element.removeAttribute(name);
|
|
89
90
|
else element.setAttribute(name, value);
|
|
90
91
|
return true;
|
|
@@ -148,14 +149,34 @@ var AttributeLease = class {
|
|
|
148
149
|
const names = registry.names;
|
|
149
150
|
names.set(attribute, (names.get(attribute) ?? /* @__PURE__ */ new Set()).add(this.#record));
|
|
150
151
|
}
|
|
151
|
-
write(element, value) {
|
|
152
|
+
write(element, value, beforeWrite) {
|
|
152
153
|
const stack = attributeStack(element, this.#attribute);
|
|
153
154
|
const hold = this.#take(stack) ?? this.#acquire(element, stack);
|
|
154
155
|
this.#held.add(element);
|
|
155
156
|
const shows = !this.#covered(element, stack, hold);
|
|
156
157
|
hold.written = value;
|
|
157
158
|
this.#mark(element, stack);
|
|
158
|
-
if (shows) this.#reflect(element, value);
|
|
159
|
+
if (shows) this.#reflect(element, value, beforeWrite);
|
|
160
|
+
}
|
|
161
|
+
adopt(element, options = {}) {
|
|
162
|
+
const known = registry.stacks.get(element)?.has(this.#attribute);
|
|
163
|
+
if (!this.#held.has(element) && !known && !element.hasAttribute(this.#record)) return false;
|
|
164
|
+
const stack = attributeStack(element, this.#attribute);
|
|
165
|
+
const hold = this.#take(stack);
|
|
166
|
+
if (!hold) return false;
|
|
167
|
+
const current = element.getAttribute(this.#attribute);
|
|
168
|
+
if (options.ifChanged && (current === hold.written || this.#covered(element, stack, hold))) {
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
this.#held.add(element);
|
|
172
|
+
hold.original = current;
|
|
173
|
+
hold.linked = false;
|
|
174
|
+
for (const above of stack.slice(stack.indexOf(hold) + 1)) {
|
|
175
|
+
if (!above.linked) break;
|
|
176
|
+
above.original = current;
|
|
177
|
+
}
|
|
178
|
+
this.#mark(element, stack);
|
|
179
|
+
return true;
|
|
159
180
|
}
|
|
160
181
|
return(element) {
|
|
161
182
|
const held = this.#held.delete(element);
|
|
@@ -221,8 +242,8 @@ var AttributeLease = class {
|
|
|
221
242
|
setAttributeIfChanged(element, name, recorded);
|
|
222
243
|
}
|
|
223
244
|
}
|
|
224
|
-
#reflect(element, value) {
|
|
225
|
-
setAttributeIfChanged(element, this.#attribute, value);
|
|
245
|
+
#reflect(element, value, beforeWrite) {
|
|
246
|
+
setAttributeIfChanged(element, this.#attribute, value, beforeWrite);
|
|
226
247
|
}
|
|
227
248
|
};
|
|
228
249
|
|
|
@@ -250,8 +271,12 @@ function readLabel(slot) {
|
|
|
250
271
|
|
|
251
272
|
var RovingTabindex = class {
|
|
252
273
|
#getItems;
|
|
253
|
-
|
|
274
|
+
#write;
|
|
275
|
+
constructor(getItems, write = (item, tabindex) => {
|
|
276
|
+
item.tabIndex = tabindex;
|
|
277
|
+
}) {
|
|
254
278
|
this.#getItems = getItems;
|
|
279
|
+
this.#write = write;
|
|
255
280
|
}
|
|
256
281
|
get activeIndex() {
|
|
257
282
|
return this.#getItems().findIndex((item) => item.tabIndex === 0);
|
|
@@ -260,7 +285,7 @@ var RovingTabindex = class {
|
|
|
260
285
|
const { focus = false } = options;
|
|
261
286
|
const items = options.items ?? this.#getItems();
|
|
262
287
|
items.forEach((item, i) => {
|
|
263
|
-
item
|
|
288
|
+
this.#write(item, i === index ? 0 : -1);
|
|
264
289
|
});
|
|
265
290
|
if (focus) items[index]?.focus();
|
|
266
291
|
}
|
|
@@ -494,7 +519,7 @@ var CompositionTracker = class {
|
|
|
494
519
|
this.#confirmedTarget = null;
|
|
495
520
|
if (confirmed === null || confirmed !== event.target) return false;
|
|
496
521
|
const inputType = event.inputType;
|
|
497
|
-
return
|
|
522
|
+
return inputType ? isCompositionInputType(inputType) : event.isTrusted === true;
|
|
498
523
|
}
|
|
499
524
|
#release(target) {
|
|
500
525
|
target.removeEventListener("compositionstart", this.#handleStart);
|
|
@@ -1150,9 +1175,11 @@ var MultiSelectController = class _MultiSelectController extends Controller {
|
|
|
1150
1175
|
#activeOptionId = null;
|
|
1151
1176
|
#tabindex = new TabindexLoan("-1", this.identifier);
|
|
1152
1177
|
#selectionValues = [];
|
|
1178
|
+
#selectionChips = /* @__PURE__ */ new Map();
|
|
1153
1179
|
#connected = false;
|
|
1154
1180
|
#emptyRegion = new StateRegions({ whenTrue: () => this.emptyTargets }, this.identifier);
|
|
1155
|
-
#
|
|
1181
|
+
#hidden = new AttributeLease("hidden", this.identifier);
|
|
1182
|
+
#selected = new AttributeLease("aria-selected", this.identifier);
|
|
1156
1183
|
#expanded = new AttributeLease("aria-expanded", this.identifier);
|
|
1157
1184
|
#activeDescendant = new AttributeLease(
|
|
1158
1185
|
"aria-activedescendant",
|
|
@@ -1172,9 +1199,10 @@ var MultiSelectController = class _MultiSelectController extends Controller {
|
|
|
1172
1199
|
outcome: "changed no selection",
|
|
1173
1200
|
noun: "chip template"
|
|
1174
1201
|
});
|
|
1202
|
+
#rowInert = new AttributeLease("inert", this.identifier);
|
|
1175
1203
|
#chipRow = new ChipRow({
|
|
1176
1204
|
getDirectionElement: () => this.#chipDirectionElement,
|
|
1177
|
-
getItems: () => this
|
|
1205
|
+
getItems: () => this.#chips,
|
|
1178
1206
|
getButton: (tag) => matchingPart(tag, `button${this.#rows.selector("remove")}`),
|
|
1179
1207
|
onRemove: (index) => this.#removeTagAt(index),
|
|
1180
1208
|
focusAfterEnd: () => this.#focusInput()
|
|
@@ -1185,13 +1213,14 @@ var MultiSelectController = class _MultiSelectController extends Controller {
|
|
|
1185
1213
|
this.#tab = null;
|
|
1186
1214
|
this.#tabindex.reclaim(this.element);
|
|
1187
1215
|
this.#rows.connect();
|
|
1216
|
+
this.#settleTagsRows();
|
|
1188
1217
|
this.#normalizeSelection([]);
|
|
1189
1218
|
this.close();
|
|
1190
1219
|
if (this.hasTagsTarget) {
|
|
1191
|
-
this.#chipRow.connect(this.tagsTarget);
|
|
1192
1220
|
this.#rebuildTags();
|
|
1193
1221
|
}
|
|
1194
1222
|
this.#selectionValues = this.#values;
|
|
1223
|
+
this.#selectionChips = this.#chipsByValue;
|
|
1195
1224
|
this.#syncFields();
|
|
1196
1225
|
this.#listeners.add(document, "click", this.#onOutsideClick, { capture: true });
|
|
1197
1226
|
this.#listeners.add(this.element, "keydown", this.#onTab);
|
|
@@ -1208,7 +1237,7 @@ var MultiSelectController = class _MultiSelectController extends Controller {
|
|
|
1208
1237
|
if (!chip) return;
|
|
1209
1238
|
chips.push(chip);
|
|
1210
1239
|
}
|
|
1211
|
-
for (const tag of this
|
|
1240
|
+
for (const tag of this.#chips) tag.remove();
|
|
1212
1241
|
this.tagsTarget.append(...chips);
|
|
1213
1242
|
this.#chipRow.ensureTabStop();
|
|
1214
1243
|
}
|
|
@@ -1225,17 +1254,22 @@ var MultiSelectController = class _MultiSelectController extends Controller {
|
|
|
1225
1254
|
this.#scheduleOptionReconcile();
|
|
1226
1255
|
}
|
|
1227
1256
|
optionTargetDisconnected(option) {
|
|
1257
|
+
if (this.optionTargets.includes(option)) return;
|
|
1228
1258
|
option.removeAttribute("data-active");
|
|
1259
|
+
this.#selected.return(option);
|
|
1260
|
+
if (!this.listTargets.includes(option)) this.#hidden.return(option);
|
|
1229
1261
|
this.#scheduleOptionReconcile();
|
|
1230
1262
|
}
|
|
1231
1263
|
emptyTargetConnected() {
|
|
1232
1264
|
if (this.#connected) this.#reflectEmpty();
|
|
1233
1265
|
}
|
|
1234
|
-
tagsTargetConnected(
|
|
1235
|
-
this.#chipRow.connect(tags);
|
|
1266
|
+
tagsTargetConnected(_tags) {
|
|
1236
1267
|
this.#scheduleOptionReconcile();
|
|
1237
1268
|
}
|
|
1238
1269
|
tagsTargetDisconnected(tags) {
|
|
1270
|
+
if (!this.scope.containsElement(tags) || !this.tagsTargets.includes(tags)) {
|
|
1271
|
+
this.#rowInert.return(tags);
|
|
1272
|
+
}
|
|
1239
1273
|
this.#chipRow.disconnect(tags);
|
|
1240
1274
|
this.#scheduleOptionReconcile();
|
|
1241
1275
|
}
|
|
@@ -1256,7 +1290,7 @@ var MultiSelectController = class _MultiSelectController extends Controller {
|
|
|
1256
1290
|
this.#adoptPageClose();
|
|
1257
1291
|
this.#openList = null;
|
|
1258
1292
|
}
|
|
1259
|
-
this.#
|
|
1293
|
+
if (!this.optionTargets.includes(list)) this.#hidden.return(list);
|
|
1260
1294
|
}
|
|
1261
1295
|
if (!this.#connected) return;
|
|
1262
1296
|
this.#reconcileOpenState();
|
|
@@ -1275,6 +1309,7 @@ var MultiSelectController = class _MultiSelectController extends Controller {
|
|
|
1275
1309
|
this.#reconcile.schedule();
|
|
1276
1310
|
}
|
|
1277
1311
|
#reconcileOptions() {
|
|
1312
|
+
this.#settleTagsRows();
|
|
1278
1313
|
const visible = this.#visibleOptions;
|
|
1279
1314
|
const active = this.#activeOption;
|
|
1280
1315
|
const next = this.#isClosed ? null : active && !active.hidden ? active : visible[0] ?? null;
|
|
@@ -1282,18 +1317,18 @@ var MultiSelectController = class _MultiSelectController extends Controller {
|
|
|
1282
1317
|
this.#reflectEmpty();
|
|
1283
1318
|
const previous = this.#selectionValues;
|
|
1284
1319
|
const previousLabels = new Map(
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
readLabel(matchingPart(
|
|
1320
|
+
Array.from(this.#selectionChips, ([value, { chip, label }]) => [
|
|
1321
|
+
value,
|
|
1322
|
+
chip.dataset.value === value ? readLabel(matchingPart(chip, this.#rows.selector("label"))) : label
|
|
1288
1323
|
])
|
|
1289
1324
|
);
|
|
1290
1325
|
const priority = [
|
|
1291
|
-
.../* @__PURE__ */ new Set([...this.
|
|
1326
|
+
.../* @__PURE__ */ new Set([...this.#chips.map((tag) => tag.dataset.value ?? ""), ...previous])
|
|
1292
1327
|
];
|
|
1293
1328
|
this.#normalizeSelection(priority);
|
|
1294
1329
|
const selected = this.#selectedOptions;
|
|
1295
1330
|
const nextValues = selected.map((option) => this.#optionValue(option)).sort();
|
|
1296
|
-
const tagValues = this.
|
|
1331
|
+
const tagValues = this.#chips.map((tag) => tag.dataset.value ?? "").sort();
|
|
1297
1332
|
const unchanged = nextValues.length === tagValues.length && nextValues.every((value, index) => value === tagValues[index]);
|
|
1298
1333
|
if (unchanged) this.#refreshTagLabels(selected);
|
|
1299
1334
|
else this.#rebuildTags();
|
|
@@ -1301,6 +1336,7 @@ var MultiSelectController = class _MultiSelectController extends Controller {
|
|
|
1301
1336
|
const values = this.#values;
|
|
1302
1337
|
const changed = !this.#sameSelection(previous, values);
|
|
1303
1338
|
this.#selectionValues = values;
|
|
1339
|
+
this.#selectionChips = this.#chipsByValue;
|
|
1304
1340
|
if (!changed) return;
|
|
1305
1341
|
const token = this.#moves.record();
|
|
1306
1342
|
const options = new Map(selected.map((option) => [this.#optionValue(option), option]));
|
|
@@ -1341,9 +1377,13 @@ var MultiSelectController = class _MultiSelectController extends Controller {
|
|
|
1341
1377
|
}
|
|
1342
1378
|
}
|
|
1343
1379
|
for (const option of this.optionTargets) {
|
|
1344
|
-
option
|
|
1380
|
+
this.#writeSelected(option, kept.has(option));
|
|
1345
1381
|
}
|
|
1346
1382
|
}
|
|
1383
|
+
#writeSelected(option, selected) {
|
|
1384
|
+
const value = String(selected);
|
|
1385
|
+
if (option.getAttribute("aria-selected") !== value) this.#selected.write(option, value);
|
|
1386
|
+
}
|
|
1347
1387
|
inputTargetConnected(input) {
|
|
1348
1388
|
this.#composition.observe(input);
|
|
1349
1389
|
this.#describeInput(input);
|
|
@@ -1362,14 +1402,13 @@ var MultiSelectController = class _MultiSelectController extends Controller {
|
|
|
1362
1402
|
this.#activeDescendant.write(input, active ? ensureId(active, "stimeo-ms-opt") : null);
|
|
1363
1403
|
}
|
|
1364
1404
|
#reconcileOpenState() {
|
|
1365
|
-
if (!this.hasListTarget) return;
|
|
1366
1405
|
this.#adoptPageClose();
|
|
1367
|
-
const list = this.listTarget;
|
|
1406
|
+
const list = this.hasListTarget ? this.listTarget : null;
|
|
1368
1407
|
if (list !== this.#openList) {
|
|
1369
|
-
this.#showList(list, this.#open);
|
|
1408
|
+
if (list) this.#showList(list, this.#open);
|
|
1370
1409
|
this.#openList = list;
|
|
1371
1410
|
}
|
|
1372
|
-
if (this.hasInputTarget) this.#expanded.write(this.inputTarget, String(!
|
|
1411
|
+
if (this.hasInputTarget) this.#expanded.write(this.inputTarget, String(!this.#isClosed));
|
|
1373
1412
|
}
|
|
1374
1413
|
#adoptPageClose() {
|
|
1375
1414
|
if (this.#openList?.hidden) this.#open = false;
|
|
@@ -1381,7 +1420,8 @@ var MultiSelectController = class _MultiSelectController extends Controller {
|
|
|
1381
1420
|
const query = this.inputTarget.value.trim().toLowerCase();
|
|
1382
1421
|
for (const option of this.optionTargets) {
|
|
1383
1422
|
const label = (option.textContent ?? "").trim().toLowerCase();
|
|
1384
|
-
|
|
1423
|
+
if (query === "" || label.includes(query)) this.#hidden.return(option);
|
|
1424
|
+
else if (!option.hidden) this.#hidden.write(option, "");
|
|
1385
1425
|
}
|
|
1386
1426
|
this.open();
|
|
1387
1427
|
const visible = this.#visibleOptions;
|
|
@@ -1393,23 +1433,21 @@ var MultiSelectController = class _MultiSelectController extends Controller {
|
|
|
1393
1433
|
this.#tab = null;
|
|
1394
1434
|
return;
|
|
1395
1435
|
}
|
|
1396
|
-
if (!this.
|
|
1436
|
+
if (!this.hasInputTarget) {
|
|
1397
1437
|
this.#reflectEmpty();
|
|
1398
1438
|
return;
|
|
1399
1439
|
}
|
|
1400
|
-
this.#showList(this.listTarget, true);
|
|
1401
1440
|
this.#open = true;
|
|
1402
|
-
this.#openList = this.listTarget;
|
|
1441
|
+
this.#openList = this.hasListTarget ? this.listTarget : null;
|
|
1442
|
+
if (this.#openList) this.#showList(this.#openList, true);
|
|
1403
1443
|
this.#expanded.write(this.inputTarget, "true");
|
|
1404
1444
|
if (!this.#activeOption) this.#setActive(this.#visibleOptions[0] ?? null);
|
|
1405
1445
|
this.#reflectEmpty();
|
|
1406
1446
|
}
|
|
1407
1447
|
close() {
|
|
1408
1448
|
this.#open = false;
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
this.#openList = this.listTarget;
|
|
1412
|
-
}
|
|
1449
|
+
this.#openList = this.hasListTarget ? this.listTarget : null;
|
|
1450
|
+
if (this.#openList) this.#showList(this.#openList, false);
|
|
1413
1451
|
this.#setActive(null);
|
|
1414
1452
|
if (this.hasInputTarget) this.#expanded.write(this.inputTarget, "false");
|
|
1415
1453
|
this.#reflectEmpty();
|
|
@@ -1420,6 +1458,7 @@ var MultiSelectController = class _MultiSelectController extends Controller {
|
|
|
1420
1458
|
if ((event.key === "Home" || event.key === "End") && hasModifierChord(event)) return;
|
|
1421
1459
|
if (!this.hasInputTarget) return;
|
|
1422
1460
|
if (this.#composition.isComposing(event)) return;
|
|
1461
|
+
this.#reconcileOpenState();
|
|
1423
1462
|
this.#reconcileActiveForInteraction();
|
|
1424
1463
|
switch (logicalArrowKey(event.key, this.#chipDirectionElement)) {
|
|
1425
1464
|
case "ArrowDown":
|
|
@@ -1500,6 +1539,33 @@ var MultiSelectController = class _MultiSelectController extends Controller {
|
|
|
1500
1539
|
if (focus && (event !== null || this.element.contains(document.activeElement)))
|
|
1501
1540
|
this.#focusInput();
|
|
1502
1541
|
}
|
|
1542
|
+
get #chips() {
|
|
1543
|
+
if (!this.hasTagsTarget) return this.tagTargets;
|
|
1544
|
+
const row = this.tagsTarget;
|
|
1545
|
+
const selector = this.#rows.selector("tags");
|
|
1546
|
+
return this.tagTargets.filter((tag) => tag.closest(selector) === row);
|
|
1547
|
+
}
|
|
1548
|
+
get #chipsByValue() {
|
|
1549
|
+
return new Map(
|
|
1550
|
+
this.#chips.map((tag) => [
|
|
1551
|
+
tag.dataset.value ?? "",
|
|
1552
|
+
{ chip: tag, label: readLabel(matchingPart(tag, this.#rows.selector("label"))) }
|
|
1553
|
+
])
|
|
1554
|
+
);
|
|
1555
|
+
}
|
|
1556
|
+
#settleTagsRows() {
|
|
1557
|
+
const [current, ...behind] = this.tagsTargets;
|
|
1558
|
+
if (!current) {
|
|
1559
|
+
this.#chipRow.disconnect();
|
|
1560
|
+
return;
|
|
1561
|
+
}
|
|
1562
|
+
this.#rowInert.return(current);
|
|
1563
|
+
this.#chipRow.connect(current);
|
|
1564
|
+
for (const row of behind) {
|
|
1565
|
+
if (row.contains(document.activeElement)) this.#focusInput();
|
|
1566
|
+
this.#rowInert.write(row, "");
|
|
1567
|
+
}
|
|
1568
|
+
}
|
|
1503
1569
|
get #chipDirectionElement() {
|
|
1504
1570
|
return this.hasTagsTarget ? this.tagsTarget : this.element;
|
|
1505
1571
|
}
|
|
@@ -1537,11 +1603,11 @@ var MultiSelectController = class _MultiSelectController extends Controller {
|
|
|
1537
1603
|
return true;
|
|
1538
1604
|
}
|
|
1539
1605
|
if (selected) {
|
|
1540
|
-
option
|
|
1606
|
+
this.#writeSelected(option, false);
|
|
1541
1607
|
this.#removeTagFor(option);
|
|
1542
1608
|
} else {
|
|
1543
1609
|
if (this.hasTagTemplateTarget && !this.#appendTag(option)) return true;
|
|
1544
|
-
option
|
|
1610
|
+
this.#writeSelected(option, true);
|
|
1545
1611
|
}
|
|
1546
1612
|
this.#refreshRoving();
|
|
1547
1613
|
return this.#publishSelection(
|
|
@@ -1553,7 +1619,7 @@ var MultiSelectController = class _MultiSelectController extends Controller {
|
|
|
1553
1619
|
}
|
|
1554
1620
|
#refreshTagLabels(selected) {
|
|
1555
1621
|
const options = new Map(selected.map((option) => [this.#optionValue(option), option]));
|
|
1556
|
-
for (const tag of this
|
|
1622
|
+
for (const tag of this.#chips) {
|
|
1557
1623
|
const option = options.get(tag.dataset.value ?? "");
|
|
1558
1624
|
const text = this.#optionLabel(option);
|
|
1559
1625
|
const label = matchingPart(tag, this.#rows.selector("label"));
|
|
@@ -1591,17 +1657,17 @@ var MultiSelectController = class _MultiSelectController extends Controller {
|
|
|
1591
1657
|
}
|
|
1592
1658
|
#removeTagFor(option) {
|
|
1593
1659
|
const value = this.#optionValue(option);
|
|
1594
|
-
const tag = this.
|
|
1660
|
+
const tag = this.#chips.find((candidate) => candidate.dataset.value === value);
|
|
1595
1661
|
tag?.remove();
|
|
1596
1662
|
}
|
|
1597
1663
|
#removeTagAt(index, focus = "neighbor") {
|
|
1598
|
-
const tags = this
|
|
1664
|
+
const tags = this.#chips;
|
|
1599
1665
|
const tag = tags[index];
|
|
1600
1666
|
if (!tag) return;
|
|
1601
1667
|
const afterFocus2 = focus === "neighbor" && tags.length === 1 && this.hasInputTarget;
|
|
1602
1668
|
const value = tag.dataset.value ?? "";
|
|
1603
1669
|
const option = this.optionTargets.find((candidate) => this.#optionValue(candidate) === value);
|
|
1604
|
-
if (option) option
|
|
1670
|
+
if (option) this.#writeSelected(option, false);
|
|
1605
1671
|
tag.remove();
|
|
1606
1672
|
this.#refreshRoving();
|
|
1607
1673
|
const label = option ? this.#optionLabel(option) : value;
|
|
@@ -1633,7 +1699,7 @@ var MultiSelectController = class _MultiSelectController extends Controller {
|
|
|
1633
1699
|
}
|
|
1634
1700
|
}
|
|
1635
1701
|
#reflectEmpty() {
|
|
1636
|
-
const empty = !this.#isClosed && this.#visibleOptions.length === 0;
|
|
1702
|
+
const empty = this.hasListTarget && !this.#isClosed && this.#visibleOptions.length === 0;
|
|
1637
1703
|
this.element.toggleAttribute(`data-${this.identifier}-empty`, empty);
|
|
1638
1704
|
this.#emptyRegion.reflect(this.element, empty);
|
|
1639
1705
|
}
|
|
@@ -1647,6 +1713,7 @@ var MultiSelectController = class _MultiSelectController extends Controller {
|
|
|
1647
1713
|
const changed = !this.#sameSelection(this.#selectionValues, values);
|
|
1648
1714
|
const fieldChanged = this.#syncFields();
|
|
1649
1715
|
this.#selectionValues = values;
|
|
1716
|
+
this.#selectionChips = this.#chipsByValue;
|
|
1650
1717
|
if (!changed) return true;
|
|
1651
1718
|
const token = this.#moves.record();
|
|
1652
1719
|
if (fieldChanged) commitField(this.fieldsTarget);
|
|
@@ -1679,9 +1746,10 @@ var MultiSelectController = class _MultiSelectController extends Controller {
|
|
|
1679
1746
|
return option.dataset.value ?? this.#optionLabel(option);
|
|
1680
1747
|
}
|
|
1681
1748
|
get #visibleOptions() {
|
|
1682
|
-
return this.optionTargets.filter((option) => !option.hidden);
|
|
1749
|
+
return this.hasListTarget ? this.optionTargets.filter((option) => !option.hidden) : [];
|
|
1683
1750
|
}
|
|
1684
1751
|
get #activeOption() {
|
|
1752
|
+
if (!this.hasListTarget) return null;
|
|
1685
1753
|
return this.optionTargets.find((option) => option.id === this.#activeOptionId) ?? null;
|
|
1686
1754
|
}
|
|
1687
1755
|
get #selectedOptions() {
|
|
@@ -1695,10 +1763,10 @@ var MultiSelectController = class _MultiSelectController extends Controller {
|
|
|
1695
1763
|
return Math.max(1, Math.floor(this.#safeMax));
|
|
1696
1764
|
}
|
|
1697
1765
|
#showList(list, open) {
|
|
1698
|
-
this.#
|
|
1766
|
+
this.#hidden.write(list, open ? null : "");
|
|
1699
1767
|
}
|
|
1700
1768
|
get #isClosed() {
|
|
1701
|
-
return
|
|
1769
|
+
return this.#openList ? this.#openList.hidden !== false : !this.#open;
|
|
1702
1770
|
}
|
|
1703
1771
|
get #safeMax() {
|
|
1704
1772
|
return this.#numbers.read(
|