@fluid-topics/ft-tree-list 1.3.13 → 1.3.15
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/build/ft-tree-list.light.js +45 -45
- package/build/ft-tree-list.min.js +65 -65
- package/build/ftds-tree-list.d.ts +5 -2
- package/build/ftds-tree-list.js +27 -14
- package/package.json +5 -5
|
@@ -11,7 +11,7 @@ export declare class FtdsTreeList extends FtLitElement implements FtdsTreeListPr
|
|
|
11
11
|
static styles: import("lit").CSSResult;
|
|
12
12
|
data?: FtTreeListData;
|
|
13
13
|
label: string;
|
|
14
|
-
pageSize
|
|
14
|
+
pageSize: number;
|
|
15
15
|
selectedNode?: FtTreeNode;
|
|
16
16
|
expandLabel: string;
|
|
17
17
|
collapseLabel: string;
|
|
@@ -31,6 +31,7 @@ export declare class FtdsTreeList extends FtLitElement implements FtdsTreeListPr
|
|
|
31
31
|
getItemSelector(item: FtTreeNode): HTMLElement;
|
|
32
32
|
isNodeExpanded(node: FtTreeNode): boolean;
|
|
33
33
|
setFocusToTreeItem(item: FtTreeNode): void;
|
|
34
|
+
selectNodeByBreadcrumb(breadcrumb: string[]): Promise<void>;
|
|
34
35
|
protected render(): TemplateResult<1>;
|
|
35
36
|
protected renderNode(node: FtTreeNode): unknown;
|
|
36
37
|
protected renderChildNodes(isNodeExpanded: boolean, visibleChildren: FtTreeNode[], node: FtTreeNode, childrenClasses: {
|
|
@@ -61,5 +62,7 @@ export declare class FtdsTreeList extends FtLitElement implements FtdsTreeListPr
|
|
|
61
62
|
protected hasExpandableChildren(node: FtTreeNode): boolean;
|
|
62
63
|
protected hasChildren(node: FtTreeNode): boolean;
|
|
63
64
|
protected loadMore(node: FtTreeNode): void;
|
|
64
|
-
protected
|
|
65
|
+
protected displayChild(currentNode: FtTreeNode, childValue: string): FtTreeNode;
|
|
66
|
+
protected handleNodeSelectEvent(e: MouseEvent | KeyboardEvent, node: FtTreeNode): void;
|
|
67
|
+
protected selectNode(node: FtTreeNode): void;
|
|
65
68
|
}
|
package/build/ftds-tree-list.js
CHANGED
|
@@ -10,7 +10,7 @@ import { repeat } from "lit/directives/repeat.js";
|
|
|
10
10
|
import { when } from "lit/directives/when.js";
|
|
11
11
|
import { ifDefined } from "lit/directives/if-defined.js";
|
|
12
12
|
import { classMap } from "lit/directives/class-map.js";
|
|
13
|
-
import { DesignSystemFamily, FtLitElement, hasChanged, jsonProperty } from "@fluid-topics/ft-wc-utils";
|
|
13
|
+
import { DesignSystemFamily, FtLitElement, hasChanged, jsonProperty, numberProperty } from "@fluid-topics/ft-wc-utils";
|
|
14
14
|
import { FtTypography, FtTypographyVariants } from "@fluid-topics/ft-typography";
|
|
15
15
|
import { FtIcon, FtIcons } from "@fluid-topics/ft-icon";
|
|
16
16
|
import { FtdsButton } from "@fluid-topics/ft-button";
|
|
@@ -26,6 +26,7 @@ class FtdsTreeList extends FtLitElement {
|
|
|
26
26
|
constructor() {
|
|
27
27
|
super(...arguments);
|
|
28
28
|
this.label = "";
|
|
29
|
+
this.pageSize = 10;
|
|
29
30
|
this.expandLabel = "Expand";
|
|
30
31
|
this.collapseLabel = "Collapse";
|
|
31
32
|
this.showMoreLabel = "Show more";
|
|
@@ -62,6 +63,14 @@ class FtdsTreeList extends FtLitElement {
|
|
|
62
63
|
itemEl === null || itemEl === void 0 ? void 0 : itemEl.focus();
|
|
63
64
|
itemEl === null || itemEl === void 0 ? void 0 : itemEl.setAttribute("tabindex", "0");
|
|
64
65
|
}
|
|
66
|
+
async selectNodeByBreadcrumb(breadcrumb) {
|
|
67
|
+
let currentNode = this.data.rootNodes.find(root => root.value === breadcrumb[0]);
|
|
68
|
+
for (let i = 0; i < breadcrumb.length - 1; i++) {
|
|
69
|
+
currentNode = this.displayChild(currentNode, breadcrumb[i + 1]);
|
|
70
|
+
}
|
|
71
|
+
await this.updateComplete;
|
|
72
|
+
this.selectNode(currentNode);
|
|
73
|
+
}
|
|
65
74
|
render() {
|
|
66
75
|
var _a;
|
|
67
76
|
const atLeastOneRootNodeIsExpandable = this.data && this.data.rootNodes && this.data.rootNodes.length > 0
|
|
@@ -130,7 +139,7 @@ class FtdsTreeList extends FtLitElement {
|
|
|
130
139
|
@click="${() => this.expandNode(!isNodeExpanded, node.value)}"
|
|
131
140
|
></ft-icon>
|
|
132
141
|
`)}
|
|
133
|
-
<div class="node-label-container" @click=${(e) => this.
|
|
142
|
+
<div class="node-label-container" @click=${(e) => this.handleNodeSelectEvent(e, node)}>
|
|
134
143
|
<ft-typography
|
|
135
144
|
part="node-label"
|
|
136
145
|
variant="${FtTypographyVariants.body2medium}"
|
|
@@ -224,7 +233,7 @@ class FtdsTreeList extends FtLitElement {
|
|
|
224
233
|
this.loadMore(parentNode);
|
|
225
234
|
}
|
|
226
235
|
else {
|
|
227
|
-
this.
|
|
236
|
+
this.handleNodeSelectEvent(event, currentNode);
|
|
228
237
|
}
|
|
229
238
|
needToStopPropagation = true;
|
|
230
239
|
break;
|
|
@@ -409,23 +418,27 @@ class FtdsTreeList extends FtLitElement {
|
|
|
409
418
|
this.setFocusToTreeItem(node.children[prevLoadedCount]);
|
|
410
419
|
}
|
|
411
420
|
}
|
|
412
|
-
|
|
421
|
+
displayChild(currentNode, childValue) {
|
|
413
422
|
var _a;
|
|
423
|
+
this.expandNode(true, currentNode.value);
|
|
424
|
+
const childIndex = currentNode.children.findIndex((child => child.value === childValue));
|
|
425
|
+
currentNode.loadedCount = Math.max((_a = currentNode.loadedCount) !== null && _a !== void 0 ? _a : this.pageSize, childIndex + 1);
|
|
426
|
+
return currentNode.children[childIndex];
|
|
427
|
+
}
|
|
428
|
+
handleNodeSelectEvent(e, node) {
|
|
414
429
|
e.preventDefault();
|
|
430
|
+
this.selectNode(node);
|
|
431
|
+
e.stopPropagation();
|
|
432
|
+
}
|
|
433
|
+
selectNode(node) {
|
|
434
|
+
var _a, _b;
|
|
415
435
|
const oldNode = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector("[aria-selected]");
|
|
416
436
|
oldNode === null || oldNode === void 0 ? void 0 : oldNode.removeAttribute("aria-selected");
|
|
417
|
-
const
|
|
418
|
-
|
|
419
|
-
const item = currentTarget === null || currentTarget === void 0 ? void 0 : currentTarget.parentElement;
|
|
420
|
-
item === null || item === void 0 ? void 0 : item.setAttribute("aria-selected", "true");
|
|
421
|
-
}
|
|
422
|
-
else if (e.type === "keydown") {
|
|
423
|
-
currentTarget === null || currentTarget === void 0 ? void 0 : currentTarget.setAttribute("aria-selected", "true");
|
|
424
|
-
}
|
|
437
|
+
const nodeContainer = (_b = this.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector(`[data-value="${node.value}"]`);
|
|
438
|
+
nodeContainer.setAttribute("aria-selected", "true");
|
|
425
439
|
this.selectedNode = node;
|
|
426
440
|
this.dispatchEvent(new NodeSelectedEvent(node));
|
|
427
441
|
this.setFocusToTreeItem(node);
|
|
428
|
-
e.stopPropagation();
|
|
429
442
|
}
|
|
430
443
|
}
|
|
431
444
|
FtdsTreeList.elementDefinitions = {
|
|
@@ -441,7 +454,7 @@ __decorate([
|
|
|
441
454
|
property()
|
|
442
455
|
], FtdsTreeList.prototype, "label", void 0);
|
|
443
456
|
__decorate([
|
|
444
|
-
|
|
457
|
+
numberProperty()
|
|
445
458
|
], FtdsTreeList.prototype, "pageSize", void 0);
|
|
446
459
|
__decorate([
|
|
447
460
|
property()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-topics/ft-tree-list",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.15",
|
|
4
4
|
"description": "A tree list component",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Lit"
|
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@fluid-topics/design-system-variables": "0.1.100",
|
|
23
|
-
"@fluid-topics/ft-assets": "1.3.
|
|
24
|
-
"@fluid-topics/ft-wc-utils": "1.3.
|
|
23
|
+
"@fluid-topics/ft-assets": "1.3.15",
|
|
24
|
+
"@fluid-topics/ft-wc-utils": "1.3.15",
|
|
25
25
|
"lit": "3.1.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@fluid-topics/ft-wc-test-utils": "1.3.
|
|
28
|
+
"@fluid-topics/ft-wc-test-utils": "1.3.15"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "5aa2861244264a93f9ce941c3541191eb22a4650"
|
|
31
31
|
}
|