@syware/jlib 0.12.1 → 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/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 +16 -13
- package/dist/organisms/jl-tree.js +72 -70
- 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,7 +79,7 @@ var JlTree = class extends JlElement {
|
|
|
76
79
|
generation: 0,
|
|
77
80
|
levels: /* @__PURE__ */ new Map()
|
|
78
81
|
};
|
|
79
|
-
_drawing = {
|
|
82
|
+
_drawing = { quiet: false };
|
|
80
83
|
_refs = this.useRefs((ref) => ({ tree: ref(".tree") }));
|
|
81
84
|
/** Loads the items a page at a time; setting it forgets `items` and loads the roots. */
|
|
82
85
|
get loader() {
|
|
@@ -191,7 +194,7 @@ var JlTree = class extends JlElement {
|
|
|
191
194
|
findItem(id) {
|
|
192
195
|
return allItems(this.items.get()).find((entry) => entry.item.id === id)?.item;
|
|
193
196
|
}
|
|
194
|
-
/**
|
|
197
|
+
/** Gives an item the Tab stop, which one item holds, and the focus when asked. */
|
|
195
198
|
moveFocus(id, focus) {
|
|
196
199
|
const row = this._rows.get(id);
|
|
197
200
|
if (row === void 0) return;
|
|
@@ -221,7 +224,7 @@ var JlTree = class extends JlElement {
|
|
|
221
224
|
pending,
|
|
222
225
|
total: level?.total ?? 0
|
|
223
226
|
});
|
|
224
|
-
this.whenRendered(() => this.
|
|
227
|
+
this.whenRendered(() => this.redrawLevelEnd(parent));
|
|
225
228
|
return pending;
|
|
226
229
|
}
|
|
227
230
|
loadNextPage(parent) {
|
|
@@ -237,21 +240,23 @@ var JlTree = class extends JlElement {
|
|
|
237
240
|
pending: null,
|
|
238
241
|
total
|
|
239
242
|
});
|
|
240
|
-
|
|
241
|
-
if (this.levelContainer(parent) === null) this.items.set(items);
|
|
242
|
-
else {
|
|
243
|
-
this._drawing.pageOnly = true;
|
|
244
|
-
try {
|
|
245
|
-
this.items.set(items);
|
|
246
|
-
} finally {
|
|
247
|
-
this._drawing.pageOnly = false;
|
|
248
|
-
}
|
|
249
|
-
const level = this.levelOf(parent);
|
|
250
|
-
this.drawLevelEnd(parent, page.items.map((item) => this.itemNode(item, level)));
|
|
251
|
-
}
|
|
243
|
+
this.drawPage(parent, withPage(this.items.get(), parent, page.items), page.items);
|
|
252
244
|
this.loadOpenFolders();
|
|
253
245
|
const first = page.items[0];
|
|
254
|
-
|
|
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);
|
|
255
260
|
}
|
|
256
261
|
failLevel(parent, error, generation) {
|
|
257
262
|
if (generation !== this._loading.generation) return;
|
|
@@ -261,7 +266,7 @@ var JlTree = class extends JlElement {
|
|
|
261
266
|
pending: null,
|
|
262
267
|
total
|
|
263
268
|
});
|
|
264
|
-
this.whenRendered(() => this.
|
|
269
|
+
this.whenRendered(() => this.redrawLevelEnd(parent));
|
|
265
270
|
}
|
|
266
271
|
/** The open folders whose children the loader has not given yet: their first page. */
|
|
267
272
|
loadOpenFolders() {
|
|
@@ -295,15 +300,25 @@ var JlTree = class extends JlElement {
|
|
|
295
300
|
errorLabel() {
|
|
296
301
|
return this.errorText.get() || jlText("loadError");
|
|
297
302
|
}
|
|
298
|
-
|
|
299
|
-
if (
|
|
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
|
+
}
|
|
300
315
|
}
|
|
301
316
|
renderItems() {
|
|
302
317
|
const hadFocus = this.hasFocusInside();
|
|
303
318
|
this._rows.clear();
|
|
304
|
-
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));
|
|
305
320
|
this.renderExpanded();
|
|
306
|
-
this.
|
|
321
|
+
this.drawSelection(this._rows);
|
|
307
322
|
this.moveFocus(this.tabStop(), hadFocus);
|
|
308
323
|
}
|
|
309
324
|
/** Where the Tab stop goes once rows are drawn: where it was, else the selected item, else the first. */
|
|
@@ -312,39 +327,35 @@ var JlTree = class extends JlElement {
|
|
|
312
327
|
const first = this._rows.keys().next().value ?? "";
|
|
313
328
|
return this._rows.has(this.value.get()) ? this.value.get() : first;
|
|
314
329
|
}
|
|
315
|
-
/**
|
|
316
|
-
|
|
317
|
-
* page or an error leaves the other rows as they are. A level not drawn yet draws the whole tree. The focus that
|
|
318
|
-
* was on the row ending the level moves to the one replacing it.
|
|
319
|
-
*/
|
|
320
|
-
drawLevelEnd(parent, added = []) {
|
|
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) {
|
|
321
332
|
const container = this.levelContainer(parent);
|
|
322
333
|
if (container === null) {
|
|
323
334
|
this.renderItems();
|
|
324
335
|
return;
|
|
325
336
|
}
|
|
326
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) {
|
|
327
343
|
const endId = levelEndId(parent);
|
|
328
344
|
this._rows.get(endId)?.remove();
|
|
329
345
|
this._rows.delete(endId);
|
|
330
|
-
const
|
|
331
|
-
container.append(...
|
|
332
|
-
const drawn =
|
|
346
|
+
const nodes = [...items.map((item) => this.itemNode(item)), ...this.levelEndNodes(parent)];
|
|
347
|
+
container.append(...nodes);
|
|
348
|
+
const drawn = rowsIn(nodes);
|
|
333
349
|
this.drawExpanded(drawn);
|
|
334
350
|
this.drawSelection(drawn);
|
|
335
|
-
this.moveFocus(this.tabStop(), hadFocus && !this.hasFocusInside());
|
|
336
351
|
}
|
|
337
|
-
/** The element holding a level's rows; null when they are not drawn,
|
|
352
|
+
/** The element holding a level's rows; null when they are not drawn, and for an empty tree, whose note only `renderItems` draws. */
|
|
338
353
|
levelContainer(parent) {
|
|
339
|
-
if (parent === null) return this.items.get().length > 0
|
|
354
|
+
if (parent === null) return this.items.get().length > 0 ? this._refs.tree : null;
|
|
340
355
|
return this._rows.get(parent)?.querySelector(":scope > .group") ?? null;
|
|
341
356
|
}
|
|
342
|
-
/**
|
|
343
|
-
|
|
344
|
-
if (parent === null) return 1;
|
|
345
|
-
return (allItems(this.items.get()).find((entry) => entry.item.id === parent)?.level ?? 0) + 1;
|
|
346
|
-
}
|
|
347
|
-
itemNode(item, level) {
|
|
357
|
+
/** An item's row, and its children's under a folder: the CSS indents each by its depth. */
|
|
358
|
+
itemNode(item) {
|
|
348
359
|
const folder = isFolder(item);
|
|
349
360
|
const labelId = uniqueId("tree-label");
|
|
350
361
|
const iconClass = item.icon === void 0 && folder ? "icon auto" : "icon";
|
|
@@ -392,30 +403,28 @@ var JlTree = class extends JlElement {
|
|
|
392
403
|
"aria-labelledby": labelId,
|
|
393
404
|
children: row
|
|
394
405
|
});
|
|
395
|
-
node.style.setProperty("--level", String(level - 1));
|
|
396
406
|
this._rows.set(item.id, node);
|
|
397
407
|
if (folder) {
|
|
398
408
|
const group = /* @__PURE__ */ jsx("div", {
|
|
399
409
|
class: "group",
|
|
400
410
|
role: "group"
|
|
401
411
|
});
|
|
402
|
-
group.
|
|
403
|
-
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));
|
|
404
413
|
node.append(group);
|
|
405
414
|
}
|
|
406
415
|
return node;
|
|
407
416
|
}
|
|
408
417
|
/** The row that ends a level, if it has one. */
|
|
409
|
-
levelEndNodes(parent
|
|
418
|
+
levelEndNodes(parent) {
|
|
410
419
|
return {
|
|
411
|
-
empty: () => [this.noteNode(this.emptyText.get()
|
|
412
|
-
error: () => [this.errorNode(parent
|
|
413
|
-
loading: () => [this.loadingNode(parent
|
|
414
|
-
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)],
|
|
415
424
|
none: () => []
|
|
416
425
|
}[this.levelEnd(parent)]();
|
|
417
426
|
}
|
|
418
|
-
levelEndRow(parent,
|
|
427
|
+
levelEndRow(parent, content, disabled) {
|
|
419
428
|
const id = levelEndId(parent);
|
|
420
429
|
const node = /* @__PURE__ */ jsx("div", {
|
|
421
430
|
class: "item level-end",
|
|
@@ -431,13 +440,12 @@ var JlTree = class extends JlElement {
|
|
|
431
440
|
}), content]
|
|
432
441
|
})
|
|
433
442
|
});
|
|
434
|
-
node.style.setProperty("--level", String(level - 1));
|
|
435
443
|
this._rows.set(id, node);
|
|
436
444
|
return node;
|
|
437
445
|
}
|
|
438
|
-
loadingNode(parent
|
|
446
|
+
loadingNode(parent) {
|
|
439
447
|
const text = this.loadingText.get() || jlText("loadingMore");
|
|
440
|
-
return this.levelEndRow(parent,
|
|
448
|
+
return this.levelEndRow(parent, [/* @__PURE__ */ jsx(JlSpinner, {
|
|
441
449
|
class: "spinner",
|
|
442
450
|
size: ICON_SIZE,
|
|
443
451
|
label: text
|
|
@@ -447,16 +455,16 @@ var JlTree = class extends JlElement {
|
|
|
447
455
|
children: text
|
|
448
456
|
})], true);
|
|
449
457
|
}
|
|
450
|
-
moreNode(parent
|
|
458
|
+
moreNode(parent) {
|
|
451
459
|
const left = (this._loading.levels.get(parent)?.total ?? 0) - childrenOf(this.items.get(), parent).length;
|
|
452
460
|
const text = (this.moreText.get() || jlTemplate("showMoreCount")).replace(COUNT_PLACEHOLDER, left.toLocaleString(pageLocale()));
|
|
453
|
-
return this.levelEndRow(parent,
|
|
461
|
+
return this.levelEndRow(parent, [/* @__PURE__ */ jsx("span", {
|
|
454
462
|
class: "label more",
|
|
455
463
|
children: text
|
|
456
464
|
})], false);
|
|
457
465
|
}
|
|
458
|
-
errorNode(parent
|
|
459
|
-
const node = this.levelEndRow(parent,
|
|
466
|
+
errorNode(parent) {
|
|
467
|
+
const node = this.levelEndRow(parent, [
|
|
460
468
|
/* @__PURE__ */ jsx(JlIcon, {
|
|
461
469
|
class: "icon error",
|
|
462
470
|
size: ICON_SIZE,
|
|
@@ -474,8 +482,8 @@ var JlTree = class extends JlElement {
|
|
|
474
482
|
setOrRemove(node, "title", this._loading.levels.get(parent)?.error ?? "");
|
|
475
483
|
return node;
|
|
476
484
|
}
|
|
477
|
-
noteNode(text
|
|
478
|
-
|
|
485
|
+
noteNode(text) {
|
|
486
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
479
487
|
class: "note",
|
|
480
488
|
children: [/* @__PURE__ */ jsx("span", {
|
|
481
489
|
class: "chevron",
|
|
@@ -485,37 +493,31 @@ var JlTree = class extends JlElement {
|
|
|
485
493
|
children: text
|
|
486
494
|
})]
|
|
487
495
|
});
|
|
488
|
-
node.style.setProperty("--level", String(level - 1));
|
|
489
|
-
return node;
|
|
490
496
|
}
|
|
491
497
|
renderExpanded() {
|
|
492
498
|
this.drawExpanded(this._rows);
|
|
493
499
|
if (!this.isVisible(this._focus.id)) this.moveFocus(this.visibleAncestor(this._focus.id), false);
|
|
494
500
|
}
|
|
495
|
-
/** Opens or closes the groups of these rows, as `expanded` says. */
|
|
501
|
+
/** Opens or closes the groups of these rows, as `expanded` says; a folder already in that state is left alone. */
|
|
496
502
|
drawExpanded(rows) {
|
|
497
503
|
const expanded = new Set(this.expanded.get());
|
|
498
504
|
for (const [id, row] of rows) {
|
|
499
|
-
const group = row.querySelector(":scope > .group");
|
|
500
|
-
if (group === null) continue;
|
|
501
505
|
const open = expanded.has(id);
|
|
506
|
+
if (row.getAttribute("aria-expanded") === String(open)) continue;
|
|
507
|
+
if (row.querySelector(":scope > .group") === null) continue;
|
|
502
508
|
row.setAttribute("aria-expanded", String(open));
|
|
503
|
-
group.hidden = !open;
|
|
504
509
|
row.querySelector(":scope > .row > .icon.auto")?.name.set(open ? OPEN_FOLDER_ICON : FOLDER_ICON);
|
|
505
510
|
}
|
|
506
511
|
}
|
|
507
512
|
isVisible(id) {
|
|
508
513
|
const row = this._rows.get(id);
|
|
509
|
-
return row !== void 0 && row.closest(
|
|
514
|
+
return row !== void 0 && row.closest(CLOSED_GROUP) === null;
|
|
510
515
|
}
|
|
511
516
|
/** The item itself when it shows, else the nearest folder around it that does: the focus goes there. */
|
|
512
517
|
visibleAncestor(id) {
|
|
513
|
-
const owner = (this._rows.get(id)?.closest(
|
|
518
|
+
const owner = (this._rows.get(id)?.closest(CLOSED_GROUP))?.closest("[role=\"treeitem\"]");
|
|
514
519
|
return owner?.dataset.id === void 0 ? id : this.visibleAncestor(owner.dataset.id);
|
|
515
520
|
}
|
|
516
|
-
renderSelection() {
|
|
517
|
-
this.drawSelection(this._rows);
|
|
518
|
-
}
|
|
519
521
|
drawSelection(rows) {
|
|
520
522
|
const value = this.value.get();
|
|
521
523
|
for (const [id, row] of rows) row.setAttribute("aria-selected", String(id === value));
|