@fluid-topics/ft-tree-list 1.3.8 → 1.3.10

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.
@@ -23,6 +23,7 @@ export declare class FtdsTreeList extends FtLitElement implements FtdsTreeListPr
23
23
  emptyState?: EmptyStateConfiguration;
24
24
  nodeToFocus?: FtTreeNode;
25
25
  isTreeSelectorCollapsed?: boolean;
26
+ childrenCounts: Map<string, number>;
26
27
  userOpenedNodes: Set<string>;
27
28
  userClosedNodes: Set<string>;
28
29
  expandAll(): void;
@@ -33,6 +33,7 @@ class FtdsTreeList extends FtLitElement {
33
33
  this.collapseParametrizedLabel = "Collapse {0}";
34
34
  this.expandAllLabel = "Expand all";
35
35
  this.collapseAllLabel = "Collapse all";
36
+ this.childrenCounts = new Map();
36
37
  this.userOpenedNodes = new Set();
37
38
  this.userClosedNodes = new Set();
38
39
  }
@@ -381,21 +382,16 @@ class FtdsTreeList extends FtLitElement {
381
382
  }
382
383
  }
383
384
  getChildrenCount(node) {
384
- let count = 0;
385
- traverseVisibleTree(node.children, () => {
386
- count++;
387
- });
388
- return count;
385
+ if (this.childrenCounts.has(node.value)) {
386
+ return this.childrenCounts.get(node.value);
387
+ }
388
+ const childrenCount = node.children.reduce((count, child) => count + this.getChildrenCount(child) + 1, 0);
389
+ this.childrenCounts.set(node.value, childrenCount);
390
+ return childrenCount;
389
391
  }
390
392
  getEntriesCount() {
391
- var _a;
392
- let count = 0;
393
- if ((_a = this.data) === null || _a === void 0 ? void 0 : _a.rootNodes) {
394
- traverseVisibleTree(this.data.rootNodes, () => {
395
- count++;
396
- });
397
- }
398
- return count;
393
+ var _a, _b;
394
+ return (_b = (_a = this.data) === null || _a === void 0 ? void 0 : _a.rootNodes.reduce((count, node) => count + this.getChildrenCount(node) + 1, 0)) !== null && _b !== void 0 ? _b : 0;
399
395
  }
400
396
  hasExpandableChildren(node) {
401
397
  return node.children.some((child) => child.children.length > 0);
@@ -480,6 +476,9 @@ __decorate([
480
476
  __decorate([
481
477
  state()
482
478
  ], FtdsTreeList.prototype, "isTreeSelectorCollapsed", void 0);
479
+ __decorate([
480
+ state()
481
+ ], FtdsTreeList.prototype, "childrenCounts", void 0);
483
482
  __decorate([
484
483
  state({ hasChanged })
485
484
  ], FtdsTreeList.prototype, "userOpenedNodes", void 0);
@@ -1,8 +1,8 @@
1
- import { FtTree, FtTreeNode } from "@fluid-topics/ft-tree-selector/build/model/FtTree";
2
1
  import { TemplateResult } from "lit/development";
2
+ import { FtTreeListData, FtTreeNode } from "./model/FtTreeListData";
3
3
  export interface FtdsTreeListProperties {
4
4
  label?: string;
5
- data?: FtTree;
5
+ data?: FtTreeListData;
6
6
  selectedNode?: FtTreeNode;
7
7
  pageSize?: number;
8
8
  expandLabel: string;
@@ -1,6 +1,7 @@
1
+ import { TemplateResult } from "lit";
1
2
  export interface FtTreeNode {
2
3
  value: string;
3
- label: string;
4
+ label: string | TemplateResult;
4
5
  expanded?: boolean;
5
6
  children: FtTreeNode[];
6
7
  loadedCount?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/ft-tree-list",
3
- "version": "1.3.8",
3
+ "version": "1.3.10",
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.8",
24
- "@fluid-topics/ft-wc-utils": "1.3.8",
23
+ "@fluid-topics/ft-assets": "1.3.10",
24
+ "@fluid-topics/ft-wc-utils": "1.3.10",
25
25
  "lit": "3.1.0"
26
26
  },
27
27
  "devDependencies": {
28
- "@fluid-topics/ft-wc-test-utils": "1.3.8"
28
+ "@fluid-topics/ft-wc-test-utils": "1.3.10"
29
29
  },
30
- "gitHead": "cafb3e5814e9a916392cb95050a9e0f36d30227f"
30
+ "gitHead": "c46b5f2b1d1764a41879e9ff520a4d3656d6b08f"
31
31
  }