@digital-realty/ix-generic-tree 1.0.1
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/LICENSE +21 -0
- package/README.md +62 -0
- package/dist/IxGenericTree.d.ts +20 -0
- package/dist/IxGenericTree.js +118 -0
- package/dist/IxGenericTree.js.map +1 -0
- package/dist/IxGenericTreeDemo.d.ts +11 -0
- package/dist/IxGenericTreeDemo.js +55 -0
- package/dist/IxGenericTreeDemo.js.map +1 -0
- package/dist/IxGenericTreeNode.d.ts +28 -0
- package/dist/IxGenericTreeNode.js +177 -0
- package/dist/IxGenericTreeNode.js.map +1 -0
- package/dist/IxGenericTreeTestIds.d.ts +7 -0
- package/dist/IxGenericTreeTestIds.js +8 -0
- package/dist/IxGenericTreeTestIds.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/ix-generic-tree-demo.d.ts +1 -0
- package/dist/ix-generic-tree-demo.js +3 -0
- package/dist/ix-generic-tree-demo.js.map +1 -0
- package/dist/ix-generic-tree-node.d.ts +1 -0
- package/dist/ix-generic-tree-node.js +3 -0
- package/dist/ix-generic-tree-node.js.map +1 -0
- package/dist/ix-generic-tree-styles.d.ts +1 -0
- package/dist/ix-generic-tree-styles.js +116 -0
- package/dist/ix-generic-tree-styles.js.map +1 -0
- package/dist/ix-generic-tree-types.d.ts +17 -0
- package/dist/ix-generic-tree-types.js +2 -0
- package/dist/ix-generic-tree-types.js.map +1 -0
- package/dist/ix-generic-tree-utils.d.ts +30 -0
- package/dist/ix-generic-tree-utils.js +228 -0
- package/dist/ix-generic-tree-utils.js.map +1 -0
- package/dist/ix-generic-tree.d.ts +1 -0
- package/dist/ix-generic-tree.js +3 -0
- package/dist/ix-generic-tree.js.map +1 -0
- package/dist/test/ix-generic-tree.test.d.ts +2 -0
- package/dist/test/ix-generic-tree.test.js +158 -0
- package/dist/test/ix-generic-tree.test.js.map +1 -0
- package/dist/test/test-data.d.ts +3 -0
- package/dist/test/test-data.js +70 -0
- package/dist/test/test-data.js.map +1 -0
- package/package.json +101 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 ix-generic-tree
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# \<ix-generic-tree>
|
|
2
|
+
|
|
3
|
+
This webcomponent follows the [open-wc](https://github.com/open-wc/open-wc) recommendation.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i ix-generic-tree
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```html
|
|
14
|
+
<script type="module">
|
|
15
|
+
import 'ix-generic-tree/ix-generic-tree.js';
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<ix-generic-tree></ix-generic-tree>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Linting and formatting
|
|
22
|
+
|
|
23
|
+
To scan the project for linting and formatting errors, run
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm run lint
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
To automatically fix linting and formatting errors, run
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm run format
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Testing with Web Test Runner
|
|
36
|
+
|
|
37
|
+
To execute a single test run:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm run test
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
To run the tests in interactive watch mode run:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npm run test:watch
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
## Tooling configs
|
|
51
|
+
|
|
52
|
+
For most of the tools, the configuration is in the `package.json` to reduce the amount of files in your project.
|
|
53
|
+
|
|
54
|
+
If you customize the configuration a lot, you can consider moving them to individual files.
|
|
55
|
+
|
|
56
|
+
## Local Demo with `web-dev-server`
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
npm start
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
To run a local development server that serves the basic demo located in `demo/index.html`
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { LitElement, TemplateResult } from 'lit';
|
|
2
|
+
import '@digital-realty/ix-textbox/ix-textbox.js';
|
|
3
|
+
import type { IGenericTreeNode } from './ix-generic-tree-types.js';
|
|
4
|
+
import './ix-generic-tree-node.js';
|
|
5
|
+
export declare class IxGenericTree extends LitElement {
|
|
6
|
+
static styles: import("lit").CSSResult[];
|
|
7
|
+
rootNode: IGenericTreeNode;
|
|
8
|
+
showCheckboxes: boolean;
|
|
9
|
+
disableCheckboxes: boolean;
|
|
10
|
+
filledIcons: boolean;
|
|
11
|
+
searchEnabled: boolean;
|
|
12
|
+
searchPlaceholder: string;
|
|
13
|
+
searchText: string;
|
|
14
|
+
selectedId: string;
|
|
15
|
+
private onTreeNodeExpandToggle;
|
|
16
|
+
private onTreeNodeCheckToggle;
|
|
17
|
+
private renderNodes;
|
|
18
|
+
private renderTextSearch;
|
|
19
|
+
render(): TemplateResult<1>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { LitElement, html, nothing } from 'lit';
|
|
3
|
+
import { property } from 'lit/decorators.js';
|
|
4
|
+
import '@digital-realty/ix-textbox/ix-textbox.js';
|
|
5
|
+
import './ix-generic-tree-node.js';
|
|
6
|
+
import { updateNodeCheckedStatus } from './ix-generic-tree-utils.js';
|
|
7
|
+
import { IxGenericTreeNodeStyles } from './ix-generic-tree-styles.js';
|
|
8
|
+
import { IxGenericTreeTestIds } from './IxGenericTreeTestIds.js';
|
|
9
|
+
export class IxGenericTree extends LitElement {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this.showCheckboxes = false;
|
|
13
|
+
this.disableCheckboxes = false;
|
|
14
|
+
this.filledIcons = false;
|
|
15
|
+
this.searchEnabled = false;
|
|
16
|
+
this.searchPlaceholder = '';
|
|
17
|
+
this.searchText = '';
|
|
18
|
+
this.selectedId = '';
|
|
19
|
+
}
|
|
20
|
+
onTreeNodeExpandToggle(e) {
|
|
21
|
+
const { node } = e.detail.message;
|
|
22
|
+
node.expanded = !node.expanded;
|
|
23
|
+
this.dispatchEvent(new CustomEvent('expand-toggle', {
|
|
24
|
+
detail: {
|
|
25
|
+
message: {
|
|
26
|
+
...e.detail.message,
|
|
27
|
+
update: this.requestUpdate.bind(this),
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
}));
|
|
31
|
+
this.requestUpdate();
|
|
32
|
+
}
|
|
33
|
+
onTreeNodeCheckToggle(e) {
|
|
34
|
+
const { node } = e.detail.message;
|
|
35
|
+
updateNodeCheckedStatus(node, this.rootNode);
|
|
36
|
+
this.rootNode = structuredClone(this.rootNode);
|
|
37
|
+
this.dispatchEvent(new CustomEvent('check-toggle', {
|
|
38
|
+
detail: {
|
|
39
|
+
message: {
|
|
40
|
+
...e.detail.message,
|
|
41
|
+
rootNode: this.rootNode,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
renderNodes(nodes = [], level = 0) {
|
|
47
|
+
const renderedNodes = [];
|
|
48
|
+
for (const node of nodes) {
|
|
49
|
+
const renderedNode = html `<ix-generic-tree-node
|
|
50
|
+
id=${node.id}
|
|
51
|
+
?expanded=${!!node.expanded}
|
|
52
|
+
?loading=${!!node.loading}
|
|
53
|
+
?disabled=${this.disableCheckboxes || !!node.disabled}
|
|
54
|
+
.level=${level}
|
|
55
|
+
.node=${node}
|
|
56
|
+
?showCheckbox=${this.showCheckboxes}
|
|
57
|
+
?filledIcons=${this.filledIcons}
|
|
58
|
+
.selected=${this.selectedId === node.id}
|
|
59
|
+
@check-toggle=${this.onTreeNodeCheckToggle}
|
|
60
|
+
@expand-toggle=${this.onTreeNodeExpandToggle}
|
|
61
|
+
data-testid="${IxGenericTreeTestIds.NODE_ID(node.id)}"
|
|
62
|
+
>
|
|
63
|
+
${node.expanded ? this.renderNodes(node.children, level + 1) : nothing}
|
|
64
|
+
</ix-generic-tree-node>`;
|
|
65
|
+
renderedNodes.push(renderedNode);
|
|
66
|
+
}
|
|
67
|
+
return renderedNodes;
|
|
68
|
+
}
|
|
69
|
+
renderTextSearch() {
|
|
70
|
+
return this.searchEnabled
|
|
71
|
+
? html ` <ix-textbox
|
|
72
|
+
filled
|
|
73
|
+
leading-icon="search"
|
|
74
|
+
has-leading-icon
|
|
75
|
+
placeholder=${this.searchPlaceholder}
|
|
76
|
+
.value=${this.searchText}
|
|
77
|
+
@input=${(e) => {
|
|
78
|
+
const input = e.target;
|
|
79
|
+
this.dispatchEvent(new CustomEvent('search-text-change', {
|
|
80
|
+
detail: { searchText: input.value },
|
|
81
|
+
}));
|
|
82
|
+
}}
|
|
83
|
+
data-testid="${IxGenericTreeTestIds.SEARCH_BOX}"
|
|
84
|
+
></ix-textbox>`
|
|
85
|
+
: nothing;
|
|
86
|
+
}
|
|
87
|
+
render() {
|
|
88
|
+
return html `<div>
|
|
89
|
+
${this.renderTextSearch()} ${this.renderNodes(this.rootNode.children, 0)}
|
|
90
|
+
</div>`;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
IxGenericTree.styles = [IxGenericTreeNodeStyles];
|
|
94
|
+
__decorate([
|
|
95
|
+
property({ type: Object })
|
|
96
|
+
], IxGenericTree.prototype, "rootNode", void 0);
|
|
97
|
+
__decorate([
|
|
98
|
+
property({ type: Boolean })
|
|
99
|
+
], IxGenericTree.prototype, "showCheckboxes", void 0);
|
|
100
|
+
__decorate([
|
|
101
|
+
property({ type: Boolean })
|
|
102
|
+
], IxGenericTree.prototype, "disableCheckboxes", void 0);
|
|
103
|
+
__decorate([
|
|
104
|
+
property({ type: Boolean })
|
|
105
|
+
], IxGenericTree.prototype, "filledIcons", void 0);
|
|
106
|
+
__decorate([
|
|
107
|
+
property({ type: Boolean })
|
|
108
|
+
], IxGenericTree.prototype, "searchEnabled", void 0);
|
|
109
|
+
__decorate([
|
|
110
|
+
property({ type: String })
|
|
111
|
+
], IxGenericTree.prototype, "searchPlaceholder", void 0);
|
|
112
|
+
__decorate([
|
|
113
|
+
property({ type: String })
|
|
114
|
+
], IxGenericTree.prototype, "searchText", void 0);
|
|
115
|
+
__decorate([
|
|
116
|
+
property({ type: String })
|
|
117
|
+
], IxGenericTree.prototype, "selectedId", void 0);
|
|
118
|
+
//# sourceMappingURL=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AAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iDAAiB","sourcesContent":["import { LitElement, html, nothing, TemplateResult } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport '@digital-realty/ix-textbox/ix-textbox.js';\nimport type { IGenericTreeNode } from './ix-generic-tree-types.js';\nimport './ix-generic-tree-node.js';\nimport { updateNodeCheckedStatus } from './ix-generic-tree-utils.js';\nimport { IxGenericTreeNodeStyles } from './ix-generic-tree-styles.js';\nimport { IxGenericTreeTestIds } from './IxGenericTreeTestIds.js';\n\nexport class IxGenericTree extends LitElement {\n static styles = [IxGenericTreeNodeStyles];\n\n @property({ type: Object }) rootNode!: IGenericTreeNode;\n\n @property({ type: Boolean }) showCheckboxes = false;\n\n @property({ type: Boolean }) disableCheckboxes = false;\n\n @property({ type: Boolean }) filledIcons = false;\n\n @property({ type: Boolean }) searchEnabled = false;\n\n @property({ type: String }) searchPlaceholder = '';\n\n @property({ type: String }) searchText = '';\n\n @property({ type: String }) selectedId = '';\n\n private onTreeNodeExpandToggle(e: CustomEvent) {\n const { node } = e.detail.message;\n node.expanded = !node.expanded;\n this.dispatchEvent(\n new CustomEvent('expand-toggle', {\n detail: {\n message: {\n ...e.detail.message,\n update: this.requestUpdate.bind(this),\n },\n },\n }),\n );\n this.requestUpdate();\n }\n\n private onTreeNodeCheckToggle(e: CustomEvent): void {\n const { node } = e.detail.message;\n updateNodeCheckedStatus(node, this.rootNode);\n this.rootNode = structuredClone(this.rootNode);\n this.dispatchEvent(\n new CustomEvent('check-toggle', {\n detail: {\n message: {\n ...e.detail.message,\n rootNode: this.rootNode,\n },\n },\n }),\n );\n }\n\n private renderNodes(\n nodes: Array<IGenericTreeNode> = [],\n level: number = 0,\n ): Array<TemplateResult<1>> {\n const renderedNodes = [];\n\n for (const node of nodes) {\n const renderedNode = html`<ix-generic-tree-node\n id=${node.id}\n ?expanded=${!!node.expanded}\n ?loading=${!!node.loading}\n ?disabled=${this.disableCheckboxes || !!node.disabled}\n .level=${level}\n .node=${node}\n ?showCheckbox=${this.showCheckboxes}\n ?filledIcons=${this.filledIcons}\n .selected=${this.selectedId === node.id}\n @check-toggle=${this.onTreeNodeCheckToggle}\n @expand-toggle=${this.onTreeNodeExpandToggle}\n data-testid=\"${IxGenericTreeTestIds.NODE_ID(node.id)}\"\n >\n ${node.expanded ? this.renderNodes(node.children, level + 1) : nothing}\n </ix-generic-tree-node>`;\n renderedNodes.push(renderedNode);\n }\n\n return renderedNodes;\n }\n\n private renderTextSearch() {\n return this.searchEnabled\n ? html` <ix-textbox\n filled\n leading-icon=\"search\"\n has-leading-icon\n placeholder=${this.searchPlaceholder}\n .value=${this.searchText}\n @input=${(e: Event) => {\n const input = e.target as HTMLInputElement;\n this.dispatchEvent(\n new CustomEvent('search-text-change', {\n detail: { searchText: input.value },\n }),\n );\n }}\n data-testid=\"${IxGenericTreeTestIds.SEARCH_BOX}\"\n ></ix-textbox>`\n : nothing;\n }\n\n render() {\n return html`<div>\n ${this.renderTextSearch()} ${this.renderNodes(this.rootNode.children, 0)}\n </div>`;\n }\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import './ix-generic-tree.js';
|
|
3
|
+
export declare class IxGenericTreeDemo extends LitElement {
|
|
4
|
+
searchEnabled: boolean;
|
|
5
|
+
showCheckboxes: boolean;
|
|
6
|
+
filledIcons: boolean;
|
|
7
|
+
private toggleSearch;
|
|
8
|
+
private toggleCheckboxes;
|
|
9
|
+
private toggleIcons;
|
|
10
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { html, LitElement } from 'lit';
|
|
3
|
+
import { state } from 'lit/decorators.js';
|
|
4
|
+
import './ix-generic-tree.js';
|
|
5
|
+
import testData from './test/test-data.js';
|
|
6
|
+
export class IxGenericTreeDemo extends LitElement {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.searchEnabled = true;
|
|
10
|
+
this.showCheckboxes = true;
|
|
11
|
+
this.filledIcons = true;
|
|
12
|
+
}
|
|
13
|
+
toggleSearch() {
|
|
14
|
+
this.searchEnabled = !this.searchEnabled;
|
|
15
|
+
}
|
|
16
|
+
toggleCheckboxes() {
|
|
17
|
+
this.showCheckboxes = !this.showCheckboxes;
|
|
18
|
+
}
|
|
19
|
+
toggleIcons() {
|
|
20
|
+
this.filledIcons = !this.filledIcons;
|
|
21
|
+
}
|
|
22
|
+
render() {
|
|
23
|
+
return html `
|
|
24
|
+
<div>
|
|
25
|
+
<button @click=${this.toggleSearch}>
|
|
26
|
+
Search: ${this.searchEnabled ? 'On' : 'Off'}
|
|
27
|
+
</button>
|
|
28
|
+
<button @click=${this.toggleCheckboxes}>
|
|
29
|
+
Checkboxes: ${this.showCheckboxes ? 'On' : 'Off'}
|
|
30
|
+
</button>
|
|
31
|
+
<button @click=${this.toggleIcons}>
|
|
32
|
+
Filled icons: ${this.filledIcons ? 'On' : 'Off'}
|
|
33
|
+
</button>
|
|
34
|
+
<ix-generic-tree
|
|
35
|
+
.rootNode=${testData}
|
|
36
|
+
?searchEnabled=${this.searchEnabled}
|
|
37
|
+
?showCheckboxes=${this.showCheckboxes}
|
|
38
|
+
?filledIcons=${this.filledIcons}
|
|
39
|
+
searchPlaceholder="placeholder"
|
|
40
|
+
.selectedId=${testData.children[0].id}
|
|
41
|
+
></ix-generic-tree>
|
|
42
|
+
</div>
|
|
43
|
+
`;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
__decorate([
|
|
47
|
+
state()
|
|
48
|
+
], IxGenericTreeDemo.prototype, "searchEnabled", void 0);
|
|
49
|
+
__decorate([
|
|
50
|
+
state()
|
|
51
|
+
], IxGenericTreeDemo.prototype, "showCheckboxes", void 0);
|
|
52
|
+
__decorate([
|
|
53
|
+
state()
|
|
54
|
+
], IxGenericTreeDemo.prototype, "filledIcons", void 0);
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C,CAAC,EAAE;;;KAG3C,CAAC;IACJ,CAAC;CACF;AAzCU;IAAR,KAAK,EAAE;wDAAsB;AAErB;IAAR,KAAK,EAAE;yDAAuB;AAEtB;IAAR,KAAK,EAAE;sDAAoB","sourcesContent":["import { html, LitElement } from 'lit';\nimport { state } from 'lit/decorators.js';\nimport './ix-generic-tree.js';\nimport testData from './test/test-data.js';\n\nexport class IxGenericTreeDemo extends LitElement {\n @state() searchEnabled = true;\n\n @state() showCheckboxes = true;\n\n @state() filledIcons = true;\n\n private toggleSearch() {\n this.searchEnabled = !this.searchEnabled;\n }\n\n private toggleCheckboxes() {\n this.showCheckboxes = !this.showCheckboxes;\n }\n\n private toggleIcons() {\n this.filledIcons = !this.filledIcons;\n }\n\n render() {\n return html`\n <div>\n <button @click=${this.toggleSearch}>\n Search: ${this.searchEnabled ? 'On' : 'Off'}\n </button>\n <button @click=${this.toggleCheckboxes}>\n Checkboxes: ${this.showCheckboxes ? 'On' : 'Off'}\n </button>\n <button @click=${this.toggleIcons}>\n Filled icons: ${this.filledIcons ? 'On' : 'Off'}\n </button>\n <ix-generic-tree\n .rootNode=${testData}\n ?searchEnabled=${this.searchEnabled}\n ?showCheckboxes=${this.showCheckboxes}\n ?filledIcons=${this.filledIcons}\n searchPlaceholder=\"placeholder\"\n .selectedId=${testData.children![0].id}\n ></ix-generic-tree>\n </div>\n `;\n }\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import '@digital-realty/ix-checkbox/ix-checkbox.js';
|
|
3
|
+
import '@digital-realty/ix-icon/ix-icon.js';
|
|
4
|
+
import '@digital-realty/ix-icon-button/ix-icon-button.js';
|
|
5
|
+
import '@digital-realty/ix-progress/ix-progress.js';
|
|
6
|
+
import type { IGenericTreeNode } from './ix-generic-tree-types.js';
|
|
7
|
+
export declare class IxGenericTreeNode extends LitElement {
|
|
8
|
+
static readonly styles: import("lit").CSSResult[];
|
|
9
|
+
node: IGenericTreeNode;
|
|
10
|
+
showCheckbox: boolean;
|
|
11
|
+
expanded: boolean;
|
|
12
|
+
loading: boolean;
|
|
13
|
+
disabled: boolean;
|
|
14
|
+
selected: boolean;
|
|
15
|
+
level: number;
|
|
16
|
+
filledIcons: boolean;
|
|
17
|
+
private onCheck;
|
|
18
|
+
private onNodeExpand;
|
|
19
|
+
private get expandable();
|
|
20
|
+
private arrowIcon;
|
|
21
|
+
private checkbox;
|
|
22
|
+
private nodeIcon;
|
|
23
|
+
private label;
|
|
24
|
+
private childCount;
|
|
25
|
+
private secondaryLabel;
|
|
26
|
+
private loadingCircle;
|
|
27
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { LitElement, html, nothing } from 'lit';
|
|
3
|
+
import { property } from 'lit/decorators.js';
|
|
4
|
+
import '@digital-realty/ix-checkbox/ix-checkbox.js';
|
|
5
|
+
import '@digital-realty/ix-icon/ix-icon.js';
|
|
6
|
+
import '@digital-realty/ix-icon-button/ix-icon-button.js';
|
|
7
|
+
import '@digital-realty/ix-progress/ix-progress.js';
|
|
8
|
+
import { IxGenericTreeNodeStyles } from './ix-generic-tree-styles.js';
|
|
9
|
+
import { IxGenericTreeTestIds } from './IxGenericTreeTestIds.js';
|
|
10
|
+
export class IxGenericTreeNode extends LitElement {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
this.showCheckbox = false;
|
|
14
|
+
this.expanded = false;
|
|
15
|
+
this.loading = false;
|
|
16
|
+
this.disabled = false;
|
|
17
|
+
this.selected = false;
|
|
18
|
+
this.level = 0;
|
|
19
|
+
this.filledIcons = false;
|
|
20
|
+
}
|
|
21
|
+
onCheck() {
|
|
22
|
+
this.node.isDirty = true;
|
|
23
|
+
if (this.node.checked) {
|
|
24
|
+
this.node.checked = false;
|
|
25
|
+
this.node.indeterminate = false;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
this.node.checked = true;
|
|
29
|
+
this.node.indeterminate = false;
|
|
30
|
+
}
|
|
31
|
+
const event = new CustomEvent('check-toggle', {
|
|
32
|
+
detail: {
|
|
33
|
+
message: {
|
|
34
|
+
node: this.node,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
this.dispatchEvent(event);
|
|
39
|
+
}
|
|
40
|
+
onNodeExpand() {
|
|
41
|
+
if (!this.expandable) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const event = new CustomEvent('expand-toggle', {
|
|
45
|
+
detail: {
|
|
46
|
+
message: {
|
|
47
|
+
node: this.node,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
this.dispatchEvent(event);
|
|
52
|
+
}
|
|
53
|
+
get expandable() {
|
|
54
|
+
const childrenDataIsPresent = this.node.children !== undefined && this.node.children.length > 0;
|
|
55
|
+
const hasChildrenToLoad = this.node.childrenCount !== undefined && this.node.childrenCount > 0;
|
|
56
|
+
return childrenDataIsPresent || hasChildrenToLoad;
|
|
57
|
+
}
|
|
58
|
+
arrowIcon() {
|
|
59
|
+
const icon = this.expanded ? 'arrow_drop_down' : 'arrow_right';
|
|
60
|
+
return html `<ix-icon-button
|
|
61
|
+
@click=${() => this.onNodeExpand()}
|
|
62
|
+
style="visibility: ${this.expandable ? 'visible' : 'hidden'}"
|
|
63
|
+
icon=${icon}
|
|
64
|
+
test-id="tree-node-expand-toggle"
|
|
65
|
+
>
|
|
66
|
+
</ix-icon-button>`;
|
|
67
|
+
}
|
|
68
|
+
checkbox() {
|
|
69
|
+
return this.showCheckbox
|
|
70
|
+
? html `<div class="pl-2" style="margin-top: 0.65rem">
|
|
71
|
+
<ix-checkbox
|
|
72
|
+
.disabled=${this.loading || this.disabled}
|
|
73
|
+
.checked=${this.node.checked}
|
|
74
|
+
.indeterminate=${this.node.indeterminate}
|
|
75
|
+
@click=${() => this.onCheck()}
|
|
76
|
+
data-testid="${IxGenericTreeTestIds.CHECK_BOX_ID(this.node.id)}"
|
|
77
|
+
></ix-checkbox>
|
|
78
|
+
</div>`
|
|
79
|
+
: nothing;
|
|
80
|
+
}
|
|
81
|
+
nodeIcon() {
|
|
82
|
+
const { icon } = this.node;
|
|
83
|
+
return icon
|
|
84
|
+
? html `<div class="pl-4 mt-2">
|
|
85
|
+
<ix-icon
|
|
86
|
+
style="color: #092241; opacity: 0.6; font-size: 20px;"
|
|
87
|
+
?filled=${this.filledIcons}
|
|
88
|
+
>
|
|
89
|
+
${icon}
|
|
90
|
+
</ix-icon>
|
|
91
|
+
</div> `
|
|
92
|
+
: nothing;
|
|
93
|
+
}
|
|
94
|
+
label() {
|
|
95
|
+
return html `
|
|
96
|
+
<p
|
|
97
|
+
class="label dlr-text-small"
|
|
98
|
+
data-testid="${IxGenericTreeTestIds.NODE_LABEL(this.node.id)}"
|
|
99
|
+
>
|
|
100
|
+
${this.node.label}
|
|
101
|
+
</p>
|
|
102
|
+
`;
|
|
103
|
+
}
|
|
104
|
+
childCount() {
|
|
105
|
+
const count = this.node.childrenCount === undefined ? 0 : this.node.childrenCount;
|
|
106
|
+
return html `<p
|
|
107
|
+
class="pl-2 child-count dlr-text-small"
|
|
108
|
+
data-testid="${IxGenericTreeTestIds.NODE_COUNT(this.node.id)}"
|
|
109
|
+
>
|
|
110
|
+
${count !== 0 ? count : nothing}
|
|
111
|
+
</p>`;
|
|
112
|
+
}
|
|
113
|
+
secondaryLabel() {
|
|
114
|
+
return this.node.secondaryLabel
|
|
115
|
+
? html `<p class="secondary-label dlr-text-caption">
|
|
116
|
+
${this.node.secondaryLabel}
|
|
117
|
+
</p>`
|
|
118
|
+
: nothing;
|
|
119
|
+
}
|
|
120
|
+
loadingCircle() {
|
|
121
|
+
return html `<div
|
|
122
|
+
style="visibility: ${this.loading
|
|
123
|
+
? 'visible'
|
|
124
|
+
: 'hidden'}; padding-left: 1rem;"
|
|
125
|
+
class="animate-pulse"
|
|
126
|
+
>
|
|
127
|
+
<ix-progress .linear=${false} .indeterminate=${true}></ix-progress>
|
|
128
|
+
</div>`;
|
|
129
|
+
}
|
|
130
|
+
render() {
|
|
131
|
+
return html `
|
|
132
|
+
<div style="padding-left: ${this.level > 0 ? '2.2rem' : '0'}">
|
|
133
|
+
<div class="node-item ${this.selected ? 'selected' : ''}">
|
|
134
|
+
${this.arrowIcon()} ${this.checkbox()} ${this.nodeIcon()}
|
|
135
|
+
<div
|
|
136
|
+
class="node-item-label"
|
|
137
|
+
@click=${this.onNodeExpand}
|
|
138
|
+
@keydown=${this.onNodeExpand}
|
|
139
|
+
>
|
|
140
|
+
<div class="node-item-inner">
|
|
141
|
+
${this.label()} ${this.childCount()}
|
|
142
|
+
</div>
|
|
143
|
+
${this.secondaryLabel()}
|
|
144
|
+
</div>
|
|
145
|
+
${this.loadingCircle()}
|
|
146
|
+
</div>
|
|
147
|
+
<slot></slot>
|
|
148
|
+
</div>
|
|
149
|
+
`;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
IxGenericTreeNode.styles = [IxGenericTreeNodeStyles];
|
|
153
|
+
__decorate([
|
|
154
|
+
property({ type: Object })
|
|
155
|
+
], IxGenericTreeNode.prototype, "node", void 0);
|
|
156
|
+
__decorate([
|
|
157
|
+
property({ type: Boolean })
|
|
158
|
+
], IxGenericTreeNode.prototype, "showCheckbox", void 0);
|
|
159
|
+
__decorate([
|
|
160
|
+
property({ type: Boolean })
|
|
161
|
+
], IxGenericTreeNode.prototype, "expanded", void 0);
|
|
162
|
+
__decorate([
|
|
163
|
+
property({ type: Boolean })
|
|
164
|
+
], IxGenericTreeNode.prototype, "loading", void 0);
|
|
165
|
+
__decorate([
|
|
166
|
+
property({ type: Boolean })
|
|
167
|
+
], IxGenericTreeNode.prototype, "disabled", void 0);
|
|
168
|
+
__decorate([
|
|
169
|
+
property({ type: Boolean })
|
|
170
|
+
], IxGenericTreeNode.prototype, "selected", void 0);
|
|
171
|
+
__decorate([
|
|
172
|
+
property({ type: Number })
|
|
173
|
+
], IxGenericTreeNode.prototype, "level", void 0);
|
|
174
|
+
__decorate([
|
|
175
|
+
property({ type: Boolean })
|
|
176
|
+
], IxGenericTreeNode.prototype, "filledIcons", void 0);
|
|
177
|
+
//# sourceMappingURL=IxGenericTreeNode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IxGenericTreeNode.js","sourceRoot":"","sources":["../src/IxGenericTreeNode.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,4CAA4C,CAAC;AACpD,OAAO,oCAAoC,CAAC;AAC5C,OAAO,kDAAkD,CAAC;AAC1D,OAAO,4CAA4C,CAAC;AAGpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,MAAM,OAAO,iBAAkB,SAAQ,UAAU;IAAjD;;QAK+B,iBAAY,GAAY,KAAK,CAAC;QAE9B,aAAQ,GAAY,KAAK,CAAC;QAE1B,YAAO,GAAY,KAAK,CAAC;QAEzB,aAAQ,GAAY,KAAK,CAAC;QAE1B,aAAQ,GAAY,KAAK,CAAC;QAE3B,UAAK,GAAG,CAAC,CAAC;QAET,gBAAW,GAAG,KAAK,CAAC;IAmJnD,CAAC;IAjJS,OAAO;QACb,IAAI,CAAC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACzB,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YACtB,IAAI,CAAC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;YAC1B,IAAI,CAAC,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;QAClC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,IAAI,CAAC,OAAO,GAA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,CAAC;gDAAW;AAET;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;sDAAqB","sourcesContent":["import { LitElement, html, nothing } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport '@digital-realty/ix-checkbox/ix-checkbox.js';\nimport '@digital-realty/ix-icon/ix-icon.js';\nimport '@digital-realty/ix-icon-button/ix-icon-button.js';\nimport '@digital-realty/ix-progress/ix-progress.js';\n\nimport type { IGenericTreeNode } from './ix-generic-tree-types.js';\nimport { IxGenericTreeNodeStyles } from './ix-generic-tree-styles.js';\nimport { IxGenericTreeTestIds } from './IxGenericTreeTestIds.js';\n\nexport class IxGenericTreeNode extends LitElement {\n static readonly styles = [IxGenericTreeNodeStyles];\n\n @property({ type: Object }) node!: IGenericTreeNode;\n\n @property({ type: Boolean }) showCheckbox: boolean = false;\n\n @property({ type: Boolean }) expanded: boolean = false;\n\n @property({ type: Boolean }) loading: boolean = false;\n\n @property({ type: Boolean }) disabled: boolean = false;\n\n @property({ type: Boolean }) selected: boolean = false;\n\n @property({ type: Number }) level = 0;\n\n @property({ type: Boolean }) filledIcons = false;\n\n private onCheck() {\n this.node.isDirty = true;\n if (this.node.checked) {\n this.node.checked = false;\n this.node.indeterminate = false;\n } else {\n this.node.checked = true;\n this.node.indeterminate = false;\n }\n const event = new CustomEvent('check-toggle', {\n detail: {\n message: {\n node: this.node,\n },\n },\n });\n\n this.dispatchEvent(event);\n }\n\n private onNodeExpand(): void {\n if (!this.expandable) {\n return;\n }\n\n const event = new CustomEvent('expand-toggle', {\n detail: {\n message: {\n node: this.node,\n },\n },\n });\n\n this.dispatchEvent(event);\n }\n\n private get expandable() {\n const childrenDataIsPresent: boolean =\n this.node.children !== undefined && this.node.children.length > 0;\n const hasChildrenToLoad: boolean =\n this.node.childrenCount !== undefined && this.node.childrenCount > 0;\n return childrenDataIsPresent || hasChildrenToLoad;\n }\n\n private arrowIcon() {\n const icon = this.expanded ? 'arrow_drop_down' : 'arrow_right';\n return html`<ix-icon-button\n @click=${() => this.onNodeExpand()}\n style=\"visibility: ${this.expandable ? 'visible' : 'hidden'}\"\n icon=${icon}\n test-id=\"tree-node-expand-toggle\"\n >\n </ix-icon-button>`;\n }\n\n private checkbox() {\n return this.showCheckbox\n ? html`<div class=\"pl-2\" style=\"margin-top: 0.65rem\">\n <ix-checkbox\n .disabled=${this.loading || this.disabled}\n .checked=${this.node.checked}\n .indeterminate=${this.node.indeterminate}\n @click=${() => this.onCheck()}\n data-testid=\"${IxGenericTreeTestIds.CHECK_BOX_ID(this.node.id)}\"\n ></ix-checkbox>\n </div>`\n : nothing;\n }\n\n private nodeIcon() {\n const { icon } = this.node;\n return icon\n ? html`<div class=\"pl-4 mt-2\">\n <ix-icon\n style=\"color: #092241; opacity: 0.6; font-size: 20px;\"\n ?filled=${this.filledIcons}\n >\n ${icon}\n </ix-icon>\n </div> `\n : nothing;\n }\n\n private label() {\n return html`\n <p\n class=\"label dlr-text-small\"\n data-testid=\"${IxGenericTreeTestIds.NODE_LABEL(this.node.id)}\"\n >\n ${this.node.label}\n </p>\n `;\n }\n\n private childCount() {\n const count =\n this.node.childrenCount === undefined ? 0 : this.node.childrenCount;\n return html`<p\n class=\"pl-2 child-count dlr-text-small\"\n data-testid=\"${IxGenericTreeTestIds.NODE_COUNT(this.node.id)}\"\n >\n ${count !== 0 ? count : nothing}\n </p>`;\n }\n\n private secondaryLabel() {\n return this.node.secondaryLabel\n ? html`<p class=\"secondary-label dlr-text-caption\">\n ${this.node.secondaryLabel}\n </p>`\n : nothing;\n }\n\n private loadingCircle() {\n return html`<div\n style=\"visibility: ${this.loading\n ? 'visible'\n : 'hidden'}; padding-left: 1rem;\"\n class=\"animate-pulse\"\n >\n <ix-progress .linear=${false} .indeterminate=${true}></ix-progress>\n </div>`;\n }\n\n render() {\n return html`\n <div style=\"padding-left: ${this.level > 0 ? '2.2rem' : '0'}\">\n <div class=\"node-item ${this.selected ? 'selected' : ''}\">\n ${this.arrowIcon()} ${this.checkbox()} ${this.nodeIcon()}\n <div\n class=\"node-item-label\"\n @click=${this.onNodeExpand}\n @keydown=${this.onNodeExpand}\n >\n <div class=\"node-item-inner\">\n ${this.label()} ${this.childCount()}\n </div>\n ${this.secondaryLabel()}\n </div>\n ${this.loadingCircle()}\n </div>\n <slot></slot>\n </div>\n `;\n }\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare class IxGenericTreeTestIds {
|
|
2
|
+
static readonly SEARCH_BOX = "search-box";
|
|
3
|
+
static CHECK_BOX_ID: (id: string) => string;
|
|
4
|
+
static NODE_ID: (id: string) => string;
|
|
5
|
+
static NODE_LABEL: (id: string) => string;
|
|
6
|
+
static NODE_COUNT: (id: string) => string;
|
|
7
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export class IxGenericTreeTestIds {
|
|
2
|
+
}
|
|
3
|
+
IxGenericTreeTestIds.SEARCH_BOX = 'search-box';
|
|
4
|
+
IxGenericTreeTestIds.CHECK_BOX_ID = (id) => `checkbox-${id}`;
|
|
5
|
+
IxGenericTreeTestIds.NODE_ID = (id) => `node-${id}`;
|
|
6
|
+
IxGenericTreeTestIds.NODE_LABEL = (id) => `label-${id}`;
|
|
7
|
+
IxGenericTreeTestIds.NODE_COUNT = (id) => `count-${id}`;
|
|
8
|
+
//# sourceMappingURL=IxGenericTreeTestIds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IxGenericTreeTestIds.js","sourceRoot":"","sources":["../src/IxGenericTreeTestIds.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,oBAAoB;;AACR,+BAAU,GAAG,YAAY,CAAC;AAEnC,iCAAY,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,YAAY,EAAE,EAAE,CAAC;AAEhD,4BAAO,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC;AAEvC,+BAAU,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC;AAE3C,+BAAU,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC","sourcesContent":["export class IxGenericTreeTestIds {\n public static readonly SEARCH_BOX = 'search-box';\n\n public static CHECK_BOX_ID = (id: string) => `checkbox-${id}`;\n\n public static NODE_ID = (id: string) => `node-${id}`;\n\n public static NODE_LABEL = (id: string) => `label-${id}`;\n\n public static NODE_COUNT = (id: string) => `count-${id}`;\n}\n"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { IxGenericTree } from './IxGenericTree.js';
|
|
2
|
+
export * from './ix-generic-tree-utils.js';
|
|
3
|
+
export type { IGenericTreeNode } from './ix-generic-tree-types.js';
|
|
4
|
+
export { IxGenericTreeNode } from './IxGenericTreeNode.js';
|
|
5
|
+
export { IxGenericTreeTestIds } from './IxGenericTreeTestIds.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,cAAc,4BAA4B,CAAC;AAE3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC","sourcesContent":["export { IxGenericTree } from './IxGenericTree.js';\nexport * from './ix-generic-tree-utils.js';\nexport type { IGenericTreeNode } from './ix-generic-tree-types.js';\nexport { IxGenericTreeNode } from './IxGenericTreeNode.js';\nexport { IxGenericTreeTestIds } from './IxGenericTreeTestIds.js';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ix-generic-tree-demo.js","sourceRoot":"","sources":["../src/ix-generic-tree-demo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,sBAAsB,EAAE,iBAAiB,CAAC,CAAC","sourcesContent":["import { IxGenericTreeDemo } from './IxGenericTreeDemo.js';\n\nwindow.customElements.define('ix-generic-tree-demo', IxGenericTreeDemo);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ix-generic-tree-node.js","sourceRoot":"","sources":["../src/ix-generic-tree-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,sBAAsB,EAAE,iBAAiB,CAAC,CAAC","sourcesContent":["import { IxGenericTreeNode } from './IxGenericTreeNode.js';\n\nwindow.customElements.define('ix-generic-tree-node', IxGenericTreeNode);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const IxGenericTreeNodeStyles: import("lit").CSSResult;
|