@syware/jlib 0.12.0 → 0.13.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.
- package/README.md +1 -1
- package/dist/atoms/jl-avatar.css.js +1 -1
- package/dist/atoms/jl-avatar.js +1 -8
- package/dist/atoms/jl-button.css.js +1 -1
- package/dist/atoms/jl-button.js +4 -6
- package/dist/atoms/jl-checkbox.css.js +1 -1
- package/dist/atoms/jl-checkbox.js +8 -10
- package/dist/atoms/jl-chip.css.js +1 -1
- package/dist/atoms/jl-chip.js +3 -11
- package/dist/atoms/jl-divider.css.js +1 -1
- package/dist/atoms/jl-divider.js +1 -5
- package/dist/atoms/jl-icon.css.js +1 -1
- package/dist/atoms/jl-icon.d.ts +2 -0
- package/dist/atoms/jl-icon.js +5 -1
- package/dist/atoms/jl-input.d.ts +7 -2
- package/dist/atoms/jl-input.js +36 -31
- package/dist/atoms/jl-link.css.js +1 -1
- package/dist/atoms/jl-link.js +3 -6
- package/dist/atoms/jl-rating.css.js +1 -1
- package/dist/atoms/jl-rating.d.ts +2 -2
- package/dist/atoms/jl-rating.js +17 -35
- package/dist/atoms/jl-select.d.ts +8 -3
- package/dist/atoms/jl-select.js +26 -13
- package/dist/atoms/jl-skeleton.d.ts +1 -0
- package/dist/atoms/jl-skeleton.js +4 -1
- package/dist/atoms/jl-slider.d.ts +4 -0
- package/dist/atoms/jl-slider.js +29 -15
- package/dist/atoms/jl-switch.css.js +1 -1
- package/dist/atoms/jl-switch.js +2 -8
- package/dist/atoms/jl-textarea.css.js +1 -1
- package/dist/atoms/jl-textarea.d.ts +4 -5
- package/dist/atoms/jl-textarea.js +15 -30
- package/dist/lib/calendar.js +3 -2
- package/dist/lib/floating.d.ts +10 -0
- package/dist/lib/floating.js +27 -8
- package/dist/lib/flow.d.ts +7 -3
- package/dist/lib/flow.js +19 -8
- package/dist/lib/indicator.d.ts +16 -0
- package/dist/lib/indicator.js +32 -6
- package/dist/lib/intl.d.ts +6 -0
- package/dist/lib/intl.js +19 -0
- package/dist/lib/palette.js +1 -6
- package/dist/lib/table.d.ts +14 -2
- package/dist/lib/table.js +50 -39
- package/dist/molecules/jl-accordion-item.css.js +1 -1
- package/dist/molecules/jl-accordion-item.js +1 -5
- package/dist/molecules/jl-account-button.css.js +1 -1
- package/dist/molecules/jl-account-button.js +1 -5
- package/dist/molecules/jl-alert.css.js +1 -1
- package/dist/molecules/jl-alert.d.ts +5 -5
- package/dist/molecules/jl-alert.js +4 -13
- package/dist/molecules/jl-avatar-group.d.ts +7 -5
- package/dist/molecules/jl-avatar-group.js +15 -5
- package/dist/molecules/jl-breadcrumb.d.ts +7 -4
- package/dist/molecules/jl-breadcrumb.js +32 -8
- package/dist/molecules/jl-calendar.d.ts +12 -3
- package/dist/molecules/jl-calendar.js +79 -48
- package/dist/molecules/jl-card.css.js +1 -1
- package/dist/molecules/jl-card.js +2 -8
- package/dist/molecules/jl-chip-group.css.js +1 -1
- package/dist/molecules/jl-chip-group.d.ts +6 -2
- package/dist/molecules/jl-chip-group.js +13 -18
- package/dist/molecules/jl-code-block.css.js +1 -1
- package/dist/molecules/jl-code-block.d.ts +7 -5
- package/dist/molecules/jl-code-block.js +19 -22
- package/dist/molecules/jl-combobox.css.js +1 -1
- package/dist/molecules/jl-combobox.d.ts +4 -0
- package/dist/molecules/jl-combobox.js +33 -19
- package/dist/molecules/jl-date-picker.d.ts +6 -0
- package/dist/molecules/jl-date-picker.js +29 -9
- package/dist/molecules/jl-empty.css.js +1 -1
- package/dist/molecules/jl-empty.js +4 -19
- package/dist/molecules/jl-field.css.js +1 -1
- package/dist/molecules/jl-field.d.ts +7 -1
- package/dist/molecules/jl-field.js +35 -23
- package/dist/molecules/jl-file-drop.css.js +1 -1
- package/dist/molecules/jl-file-drop.js +1 -3
- package/dist/molecules/jl-input-list.css.js +1 -1
- package/dist/molecules/jl-input-list.d.ts +12 -1
- package/dist/molecules/jl-input-list.js +81 -51
- package/dist/molecules/jl-list-item.css.js +1 -1
- package/dist/molecules/jl-list-item.d.ts +3 -1
- package/dist/molecules/jl-list-item.js +26 -27
- package/dist/molecules/jl-load-state.css.js +1 -1
- package/dist/molecules/jl-load-state.d.ts +6 -1
- package/dist/molecules/jl-load-state.js +15 -18
- package/dist/molecules/jl-menu.d.ts +1 -0
- package/dist/molecules/jl-menu.js +9 -2
- package/dist/molecules/jl-pagination.css.js +1 -1
- package/dist/molecules/jl-pagination.d.ts +7 -1
- package/dist/molecules/jl-pagination.js +43 -35
- package/dist/molecules/jl-search.css.js +1 -1
- package/dist/molecules/jl-search.js +4 -12
- package/dist/molecules/jl-segmented.css.js +1 -1
- package/dist/molecules/jl-segmented.d.ts +4 -2
- package/dist/molecules/jl-segmented.js +19 -26
- package/dist/molecules/jl-stat.css.js +1 -1
- package/dist/molecules/jl-stat.js +2 -8
- package/dist/molecules/jl-steps.d.ts +10 -3
- package/dist/molecules/jl-steps.js +82 -49
- package/dist/molecules/jl-tabs.d.ts +5 -2
- package/dist/molecules/jl-tabs.js +31 -25
- package/dist/molecules/jl-tag-input.css.js +1 -1
- package/dist/molecules/jl-tag-input.d.ts +13 -1
- package/dist/molecules/jl-tag-input.js +57 -30
- package/dist/molecules/jl-timeline.css.js +1 -1
- package/dist/molecules/jl-timeline.d.ts +3 -1
- package/dist/molecules/jl-timeline.js +9 -14
- package/dist/molecules/jl-toast.css.js +1 -1
- package/dist/molecules/jl-toast.js +2 -10
- package/dist/molecules/jl-tooltip.d.ts +2 -1
- package/dist/molecules/jl-tooltip.js +11 -15
- package/dist/organisms/jl-command-palette.css.js +1 -1
- package/dist/organisms/jl-command-palette.d.ts +8 -1
- package/dist/organisms/jl-command-palette.js +73 -42
- package/dist/organisms/jl-confirm.css.js +1 -1
- package/dist/organisms/jl-confirm.js +1 -5
- package/dist/organisms/jl-dialog.css.js +1 -1
- package/dist/organisms/jl-dialog.js +1 -5
- package/dist/organisms/jl-drawer.css.js +1 -1
- package/dist/organisms/jl-drawer.js +1 -3
- package/dist/organisms/jl-flow.d.ts +18 -2
- package/dist/organisms/jl-flow.js +128 -44
- package/dist/organisms/jl-navbar.css.js +1 -1
- package/dist/organisms/jl-navbar.d.ts +1 -1
- package/dist/organisms/jl-navbar.js +3 -5
- package/dist/organisms/jl-page-header.css.js +1 -1
- package/dist/organisms/jl-page-header.js +1 -5
- package/dist/organisms/jl-page-outlet.d.ts +4 -3
- package/dist/organisms/jl-page-outlet.js +7 -8
- package/dist/organisms/jl-side-nav.css.js +1 -1
- package/dist/organisms/jl-side-nav.d.ts +9 -2
- package/dist/organisms/jl-side-nav.js +44 -16
- package/dist/organisms/jl-tab-bar.css.js +1 -1
- package/dist/organisms/jl-tab-bar.js +0 -2
- package/dist/organisms/jl-table.css.js +1 -1
- package/dist/organisms/jl-table.d.ts +18 -6
- package/dist/organisms/jl-table.js +91 -57
- package/dist/organisms/jl-tree.css.js +1 -1
- package/dist/organisms/jl-tree.d.ts +22 -2
- package/dist/organisms/jl-tree.js +101 -41
- package/package.json +1 -1
|
@@ -28,10 +28,13 @@ var FILE_ICON = "file";
|
|
|
28
28
|
var ERROR_ICON = "circle-alert";
|
|
29
29
|
var LEVEL_END_PREFIX = "jl-tree-level-end:";
|
|
30
30
|
var COUNT_PLACEHOLDER = "{count}";
|
|
31
|
+
var CLOSED_GROUP = "[aria-expanded=\"false\"] > .group";
|
|
31
32
|
var levelEndId = (parent) => `${LEVEL_END_PREFIX}${parent ?? ""}`;
|
|
32
33
|
var isLevelEnd = (id) => id.startsWith(LEVEL_END_PREFIX);
|
|
33
34
|
var parentOfLevelEnd = (id) => id.slice(18) || null;
|
|
34
35
|
var messageOf = (error) => error instanceof Error ? error.message : String(error);
|
|
36
|
+
/** The rows of items in these nodes, by id: the nodes themselves and the rows inside them. */
|
|
37
|
+
var rowsIn = (nodes) => new Map(nodes.filter((node) => node instanceof HTMLElement).flatMap((node) => [node, ...node.querySelectorAll("[role=\"treeitem\"]")]).flatMap((row) => row.dataset.id === void 0 ? [] : [[row.dataset.id, row]]));
|
|
35
38
|
/**
|
|
36
39
|
* Nested items that open and close, as files in folders: `items` holds them, `expanded` lists the open folders and
|
|
37
40
|
* `value` is the selected item. With a `loader`, the tree loads itself a level at a time and a page at a time, so a
|
|
@@ -43,7 +46,7 @@ var messageOf = (error) => error instanceof Error ? error.message : String(error
|
|
|
43
46
|
var JlTree = class extends JlElement {
|
|
44
47
|
static selector = "jl-tree";
|
|
45
48
|
events = this.useEvents();
|
|
46
|
-
items = this.useChange([], () => this.
|
|
49
|
+
items = this.useChange([], () => this.renderItemsUnlessQuiet(), {
|
|
47
50
|
attribute: "items",
|
|
48
51
|
parse: jsonOf([])
|
|
49
52
|
});
|
|
@@ -56,7 +59,7 @@ var JlTree = class extends JlElement {
|
|
|
56
59
|
parse: jsonOf([])
|
|
57
60
|
});
|
|
58
61
|
/** The id of the selected item. */
|
|
59
|
-
value = this.useChange("", () => this.
|
|
62
|
+
value = this.useChange("", () => this.drawSelection(this._rows), { attribute: "value" });
|
|
60
63
|
/** The tree's name for screen readers. */
|
|
61
64
|
label = this.useChange("", (value) => setOrRemove(this._refs.tree, "aria-label", value), { attribute: "label" });
|
|
62
65
|
/** What an empty tree says, such as "No object yet"; none by default. */
|
|
@@ -76,6 +79,7 @@ var JlTree = class extends JlElement {
|
|
|
76
79
|
generation: 0,
|
|
77
80
|
levels: /* @__PURE__ */ new Map()
|
|
78
81
|
};
|
|
82
|
+
_drawing = { quiet: false };
|
|
79
83
|
_refs = this.useRefs((ref) => ({ tree: ref(".tree") }));
|
|
80
84
|
/** Loads the items a page at a time; setting it forgets `items` and loads the roots. */
|
|
81
85
|
get loader() {
|
|
@@ -190,7 +194,7 @@ var JlTree = class extends JlElement {
|
|
|
190
194
|
findItem(id) {
|
|
191
195
|
return allItems(this.items.get()).find((entry) => entry.item.id === id)?.item;
|
|
192
196
|
}
|
|
193
|
-
/**
|
|
197
|
+
/** Gives an item the Tab stop, which one item holds, and the focus when asked. */
|
|
194
198
|
moveFocus(id, focus) {
|
|
195
199
|
const row = this._rows.get(id);
|
|
196
200
|
if (row === void 0) return;
|
|
@@ -220,7 +224,7 @@ var JlTree = class extends JlElement {
|
|
|
220
224
|
pending,
|
|
221
225
|
total: level?.total ?? 0
|
|
222
226
|
});
|
|
223
|
-
this.whenRendered(() => this.
|
|
227
|
+
this.whenRendered(() => this.redrawLevelEnd(parent));
|
|
224
228
|
return pending;
|
|
225
229
|
}
|
|
226
230
|
loadNextPage(parent) {
|
|
@@ -236,10 +240,23 @@ var JlTree = class extends JlElement {
|
|
|
236
240
|
pending: null,
|
|
237
241
|
total
|
|
238
242
|
});
|
|
239
|
-
this.
|
|
243
|
+
this.drawPage(parent, withPage(this.items.get(), parent, page.items), page.items);
|
|
240
244
|
this.loadOpenFolders();
|
|
241
245
|
const first = page.items[0];
|
|
242
|
-
|
|
246
|
+
this.moveFocus(focusFirst && first !== void 0 ? first.id : this.tabStop(), focusFirst);
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Shows the items with a page added: only the page's rows when its level is drawn, so a tree of thousands of rows
|
|
250
|
+
* is not drawn and laid out again for each page; the whole tree otherwise.
|
|
251
|
+
*/
|
|
252
|
+
drawPage(parent, items, page) {
|
|
253
|
+
const container = this.levelContainer(parent);
|
|
254
|
+
if (container === null) {
|
|
255
|
+
this.items.set(items);
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
this.setItemsQuietly(items);
|
|
259
|
+
this.appendToLevel(container, parent, page);
|
|
243
260
|
}
|
|
244
261
|
failLevel(parent, error, generation) {
|
|
245
262
|
if (generation !== this._loading.generation) return;
|
|
@@ -249,7 +266,7 @@ var JlTree = class extends JlElement {
|
|
|
249
266
|
pending: null,
|
|
250
267
|
total
|
|
251
268
|
});
|
|
252
|
-
this.whenRendered(() => this.
|
|
269
|
+
this.whenRendered(() => this.redrawLevelEnd(parent));
|
|
253
270
|
}
|
|
254
271
|
/** The open folders whose children the loader has not given yet: their first page. */
|
|
255
272
|
loadOpenFolders() {
|
|
@@ -283,17 +300,62 @@ var JlTree = class extends JlElement {
|
|
|
283
300
|
errorLabel() {
|
|
284
301
|
return this.errorText.get() || jlText("loadError");
|
|
285
302
|
}
|
|
303
|
+
renderItemsUnlessQuiet() {
|
|
304
|
+
if (this._drawing.quiet) return;
|
|
305
|
+
this.renderItems();
|
|
306
|
+
}
|
|
307
|
+
/** Sets `items` without drawing every row again, which its callback does on each set(), even of an equal value. */
|
|
308
|
+
setItemsQuietly(items) {
|
|
309
|
+
this._drawing.quiet = true;
|
|
310
|
+
try {
|
|
311
|
+
this.items.set(items);
|
|
312
|
+
} finally {
|
|
313
|
+
this._drawing.quiet = false;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
286
316
|
renderItems() {
|
|
287
317
|
const hadFocus = this.hasFocusInside();
|
|
288
318
|
this._rows.clear();
|
|
289
|
-
this._refs.tree.replaceChildren(...this.items.get().map((item) => this.itemNode(item
|
|
319
|
+
this._refs.tree.replaceChildren(...this.items.get().map((item) => this.itemNode(item)), ...this.levelEndNodes(null));
|
|
290
320
|
this.renderExpanded();
|
|
291
|
-
this.
|
|
321
|
+
this.drawSelection(this._rows);
|
|
322
|
+
this.moveFocus(this.tabStop(), hadFocus);
|
|
323
|
+
}
|
|
324
|
+
/** Where the Tab stop goes once rows are drawn: where it was, else the selected item, else the first. */
|
|
325
|
+
tabStop() {
|
|
326
|
+
if (this._rows.has(this._focus.id)) return this._focus.id;
|
|
292
327
|
const first = this._rows.keys().next().value ?? "";
|
|
293
|
-
|
|
294
|
-
this.moveFocus(this._rows.has(this._focus.id) ? this._focus.id : start, hadFocus);
|
|
328
|
+
return this._rows.has(this.value.get()) ? this.value.get() : first;
|
|
295
329
|
}
|
|
296
|
-
|
|
330
|
+
/** Draws again the row that ends a level (its spinner, its error), and only it; the whole tree when it is not drawn. */
|
|
331
|
+
redrawLevelEnd(parent) {
|
|
332
|
+
const container = this.levelContainer(parent);
|
|
333
|
+
if (container === null) {
|
|
334
|
+
this.renderItems();
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
const hadFocus = this.hasFocusInside();
|
|
338
|
+
this.appendToLevel(container, parent, []);
|
|
339
|
+
this.moveFocus(this.tabStop(), hadFocus && !this.hasFocusInside());
|
|
340
|
+
}
|
|
341
|
+
/** Draws items at the end of a drawn level, then the row that ends it again; the tree's other rows stay as they are. */
|
|
342
|
+
appendToLevel(container, parent, items) {
|
|
343
|
+
const endId = levelEndId(parent);
|
|
344
|
+
this._rows.get(endId)?.remove();
|
|
345
|
+
this._rows.delete(endId);
|
|
346
|
+
const nodes = [...items.map((item) => this.itemNode(item)), ...this.levelEndNodes(parent)];
|
|
347
|
+
container.append(...nodes);
|
|
348
|
+
const drawn = rowsIn(nodes);
|
|
349
|
+
this.drawExpanded(drawn);
|
|
350
|
+
this.drawSelection(drawn);
|
|
351
|
+
}
|
|
352
|
+
/** The element holding a level's rows; null when they are not drawn, and for an empty tree, whose note only `renderItems` draws. */
|
|
353
|
+
levelContainer(parent) {
|
|
354
|
+
if (parent === null) return this.items.get().length > 0 ? this._refs.tree : null;
|
|
355
|
+
return this._rows.get(parent)?.querySelector(":scope > .group") ?? null;
|
|
356
|
+
}
|
|
357
|
+
/** An item's row, and its children's under a folder: the CSS indents each by its depth. */
|
|
358
|
+
itemNode(item) {
|
|
297
359
|
const folder = isFolder(item);
|
|
298
360
|
const labelId = uniqueId("tree-label");
|
|
299
361
|
const iconClass = item.icon === void 0 && folder ? "icon auto" : "icon";
|
|
@@ -341,30 +403,28 @@ var JlTree = class extends JlElement {
|
|
|
341
403
|
"aria-labelledby": labelId,
|
|
342
404
|
children: row
|
|
343
405
|
});
|
|
344
|
-
node.style.setProperty("--level", String(level - 1));
|
|
345
406
|
this._rows.set(item.id, node);
|
|
346
407
|
if (folder) {
|
|
347
408
|
const group = /* @__PURE__ */ jsx("div", {
|
|
348
409
|
class: "group",
|
|
349
410
|
role: "group"
|
|
350
411
|
});
|
|
351
|
-
group.
|
|
352
|
-
group.replaceChildren(...(item.children ?? []).map((child) => this.itemNode(child, level + 1)), ...this.levelEndNodes(item.id, level + 1));
|
|
412
|
+
group.replaceChildren(...(item.children ?? []).map((child) => this.itemNode(child)), ...this.levelEndNodes(item.id));
|
|
353
413
|
node.append(group);
|
|
354
414
|
}
|
|
355
415
|
return node;
|
|
356
416
|
}
|
|
357
417
|
/** The row that ends a level, if it has one. */
|
|
358
|
-
levelEndNodes(parent
|
|
418
|
+
levelEndNodes(parent) {
|
|
359
419
|
return {
|
|
360
|
-
empty: () => [this.noteNode(this.emptyText.get()
|
|
361
|
-
error: () => [this.errorNode(parent
|
|
362
|
-
loading: () => [this.loadingNode(parent
|
|
363
|
-
more: () => [this.moreNode(parent
|
|
420
|
+
empty: () => [this.noteNode(this.emptyText.get())],
|
|
421
|
+
error: () => [this.errorNode(parent)],
|
|
422
|
+
loading: () => [this.loadingNode(parent)],
|
|
423
|
+
more: () => [this.moreNode(parent)],
|
|
364
424
|
none: () => []
|
|
365
425
|
}[this.levelEnd(parent)]();
|
|
366
426
|
}
|
|
367
|
-
levelEndRow(parent,
|
|
427
|
+
levelEndRow(parent, content, disabled) {
|
|
368
428
|
const id = levelEndId(parent);
|
|
369
429
|
const node = /* @__PURE__ */ jsx("div", {
|
|
370
430
|
class: "item level-end",
|
|
@@ -380,13 +440,12 @@ var JlTree = class extends JlElement {
|
|
|
380
440
|
}), content]
|
|
381
441
|
})
|
|
382
442
|
});
|
|
383
|
-
node.style.setProperty("--level", String(level - 1));
|
|
384
443
|
this._rows.set(id, node);
|
|
385
444
|
return node;
|
|
386
445
|
}
|
|
387
|
-
loadingNode(parent
|
|
446
|
+
loadingNode(parent) {
|
|
388
447
|
const text = this.loadingText.get() || jlText("loadingMore");
|
|
389
|
-
return this.levelEndRow(parent,
|
|
448
|
+
return this.levelEndRow(parent, [/* @__PURE__ */ jsx(JlSpinner, {
|
|
390
449
|
class: "spinner",
|
|
391
450
|
size: ICON_SIZE,
|
|
392
451
|
label: text
|
|
@@ -396,16 +455,16 @@ var JlTree = class extends JlElement {
|
|
|
396
455
|
children: text
|
|
397
456
|
})], true);
|
|
398
457
|
}
|
|
399
|
-
moreNode(parent
|
|
458
|
+
moreNode(parent) {
|
|
400
459
|
const left = (this._loading.levels.get(parent)?.total ?? 0) - childrenOf(this.items.get(), parent).length;
|
|
401
460
|
const text = (this.moreText.get() || jlTemplate("showMoreCount")).replace(COUNT_PLACEHOLDER, left.toLocaleString(pageLocale()));
|
|
402
|
-
return this.levelEndRow(parent,
|
|
461
|
+
return this.levelEndRow(parent, [/* @__PURE__ */ jsx("span", {
|
|
403
462
|
class: "label more",
|
|
404
463
|
children: text
|
|
405
464
|
})], false);
|
|
406
465
|
}
|
|
407
|
-
errorNode(parent
|
|
408
|
-
const node = this.levelEndRow(parent,
|
|
466
|
+
errorNode(parent) {
|
|
467
|
+
const node = this.levelEndRow(parent, [
|
|
409
468
|
/* @__PURE__ */ jsx(JlIcon, {
|
|
410
469
|
class: "icon error",
|
|
411
470
|
size: ICON_SIZE,
|
|
@@ -423,8 +482,8 @@ var JlTree = class extends JlElement {
|
|
|
423
482
|
setOrRemove(node, "title", this._loading.levels.get(parent)?.error ?? "");
|
|
424
483
|
return node;
|
|
425
484
|
}
|
|
426
|
-
noteNode(text
|
|
427
|
-
|
|
485
|
+
noteNode(text) {
|
|
486
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
428
487
|
class: "note",
|
|
429
488
|
children: [/* @__PURE__ */ jsx("span", {
|
|
430
489
|
class: "chevron",
|
|
@@ -434,33 +493,34 @@ var JlTree = class extends JlElement {
|
|
|
434
493
|
children: text
|
|
435
494
|
})]
|
|
436
495
|
});
|
|
437
|
-
node.style.setProperty("--level", String(level - 1));
|
|
438
|
-
return node;
|
|
439
496
|
}
|
|
440
497
|
renderExpanded() {
|
|
498
|
+
this.drawExpanded(this._rows);
|
|
499
|
+
if (!this.isVisible(this._focus.id)) this.moveFocus(this.visibleAncestor(this._focus.id), false);
|
|
500
|
+
}
|
|
501
|
+
/** Opens or closes the groups of these rows, as `expanded` says; a folder already in that state is left alone. */
|
|
502
|
+
drawExpanded(rows) {
|
|
441
503
|
const expanded = new Set(this.expanded.get());
|
|
442
|
-
for (const [id, row] of
|
|
443
|
-
const group = row.querySelector(":scope > .group");
|
|
444
|
-
if (group === null) continue;
|
|
504
|
+
for (const [id, row] of rows) {
|
|
445
505
|
const open = expanded.has(id);
|
|
506
|
+
if (row.getAttribute("aria-expanded") === String(open)) continue;
|
|
507
|
+
if (row.querySelector(":scope > .group") === null) continue;
|
|
446
508
|
row.setAttribute("aria-expanded", String(open));
|
|
447
|
-
group.hidden = !open;
|
|
448
509
|
row.querySelector(":scope > .row > .icon.auto")?.name.set(open ? OPEN_FOLDER_ICON : FOLDER_ICON);
|
|
449
510
|
}
|
|
450
|
-
if (!this.isVisible(this._focus.id)) this.moveFocus(this.visibleAncestor(this._focus.id), false);
|
|
451
511
|
}
|
|
452
512
|
isVisible(id) {
|
|
453
513
|
const row = this._rows.get(id);
|
|
454
|
-
return row !== void 0 && row.closest(
|
|
514
|
+
return row !== void 0 && row.closest(CLOSED_GROUP) === null;
|
|
455
515
|
}
|
|
456
516
|
/** The item itself when it shows, else the nearest folder around it that does: the focus goes there. */
|
|
457
517
|
visibleAncestor(id) {
|
|
458
|
-
const owner = (this._rows.get(id)?.closest(
|
|
518
|
+
const owner = (this._rows.get(id)?.closest(CLOSED_GROUP))?.closest("[role=\"treeitem\"]");
|
|
459
519
|
return owner?.dataset.id === void 0 ? id : this.visibleAncestor(owner.dataset.id);
|
|
460
520
|
}
|
|
461
|
-
|
|
521
|
+
drawSelection(rows) {
|
|
462
522
|
const value = this.value.get();
|
|
463
|
-
for (const [id, row] of
|
|
523
|
+
for (const [id, row] of rows) row.setAttribute("aria-selected", String(id === value));
|
|
464
524
|
}
|
|
465
525
|
};
|
|
466
526
|
JlTree.register();
|