@digital-realty/ix-dropdown-tree 1.0.2

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 ix-dropdown-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-dropdown-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-dropdown-tree
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```html
14
+ <script type="module">
15
+ import 'ix-dropdown-tree/ix-dropdown-tree.js';
16
+ </script>
17
+
18
+ <ix-dropdown-tree></ix-dropdown-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,13 @@
1
+ import { LitElement, TemplateResult } from 'lit';
2
+ import './ix-dropdown-tree-node.js';
3
+ import { IxDropdownTreeNodeData as TreeNode } from './ix-dropdown-tree-types.js';
4
+ export declare class IxDropdownTree extends LitElement {
5
+ rootNode: TreeNode;
6
+ selectedId: string | undefined;
7
+ hasActionButton: boolean;
8
+ private onToggle;
9
+ private onNodeButtonClick;
10
+ private onSelect;
11
+ renderNodes(nodes?: Array<TreeNode>, level?: number): TemplateResult<1>[];
12
+ render(): TemplateResult<1>;
13
+ }
@@ -0,0 +1,64 @@
1
+ import { __decorate } from "tslib";
2
+ import { LitElement, html, nothing } from 'lit';
3
+ import { property } from 'lit/decorators.js';
4
+ import './ix-dropdown-tree-node.js';
5
+ import { IxDropdownTreeTestIds } from './IxDropdownTreeTestIds.js';
6
+ export class IxDropdownTree extends LitElement {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.rootNode = {};
10
+ this.hasActionButton = false;
11
+ }
12
+ onToggle(e) {
13
+ const newRootNode = { ...this.rootNode };
14
+ const { node } = e.detail.message;
15
+ node.expanded = !node.expanded;
16
+ this.rootNode = newRootNode;
17
+ this.requestUpdate();
18
+ }
19
+ onNodeButtonClick(e) {
20
+ this.dispatchEvent(new CustomEvent('node-action', {
21
+ detail: { message: { id: e.detail.message.id } },
22
+ }));
23
+ }
24
+ onSelect(e) {
25
+ this.dispatchEvent(new CustomEvent('select', { detail: { message: e.detail.message.id } }));
26
+ }
27
+ renderNodes(nodes = [], level = 0) {
28
+ const renderedNodes = [];
29
+ for (const n of nodes) {
30
+ const renderedNode = html `
31
+ <ix-dropdown-tree-node
32
+ .treeNode=${n}
33
+ .level=${level}
34
+ .expanded=${n.expanded ?? false}
35
+ .selected=${n.id === this.selectedId}
36
+ @tree-node-select=${this.onSelect}
37
+ @tree-node-toggle=${this.onToggle}
38
+ @tree-node-action=${this.onNodeButtonClick}
39
+ ?hasActionButton=${this.hasActionButton}
40
+ data-testid=${level === 0
41
+ ? IxDropdownTreeTestIds.PARENT_NODE
42
+ : IxDropdownTreeTestIds.CHILD_NODE}
43
+ >
44
+ ${n.expanded ? this.renderNodes(n.children, level + 1) : nothing}
45
+ </ix-dropdown-tree-node>
46
+ `;
47
+ renderedNodes.push(renderedNode);
48
+ }
49
+ return renderedNodes;
50
+ }
51
+ render() {
52
+ return html ` <div>${this.renderNodes(this.rootNode.children, 0)}</div> `;
53
+ }
54
+ }
55
+ __decorate([
56
+ property({ type: Object })
57
+ ], IxDropdownTree.prototype, "rootNode", void 0);
58
+ __decorate([
59
+ property({ type: String })
60
+ ], IxDropdownTree.prototype, "selectedId", void 0);
61
+ __decorate([
62
+ property({ type: Boolean })
63
+ ], IxDropdownTree.prototype, "hasActionButton", void 0);
64
+ //# sourceMappingURL=IxDropdownTree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IxDropdownTree.js","sourceRoot":"","sources":["../src/IxDropdownTree.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAkB,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,4BAA4B,CAAC;AAEpC,OAAO,EAAE,qBAAqB,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AAI,CAAC,QAAQ;8BACb,IAAI,CAAC,iBAAiB;6BACvB,IAAI,CAAC,eAAe;wBACzB,KAAK,KAAK,CAAC;gBACvB,CAAC,CAAC,qBAAqB,CAAC,WAAW;gBACnC,CAAC,CAAC,qBAAqB,CAAC,UAAU;;YAElC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO;;OAEnE,CAAC;YACF,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACnC,CAAC;QACD,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAA,SAAS,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC,SAAS,CAAC;IAC3E,CAAC;CACF;AAxD6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDAAqC;AAEpC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAAgC;AAE9B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;uDAAkC","sourcesContent":["import { LitElement, TemplateResult, html, nothing } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport './ix-dropdown-tree-node.js';\nimport { IxDropdownTreeNodeData as TreeNode } from './ix-dropdown-tree-types.js';\nimport { IxDropdownTreeTestIds } from './IxDropdownTreeTestIds.js';\n\nexport class IxDropdownTree extends LitElement {\n @property({ type: Object }) rootNode: TreeNode = {} as TreeNode;\n\n @property({ type: String }) selectedId: string | undefined;\n\n @property({ type: Boolean }) hasActionButton: boolean = false;\n\n private onToggle(e: CustomEvent) {\n const newRootNode = { ...this.rootNode };\n const { node } = e.detail.message;\n node.expanded = !node.expanded;\n this.rootNode = newRootNode;\n this.requestUpdate();\n }\n\n private onNodeButtonClick(e: CustomEvent) {\n this.dispatchEvent(\n new CustomEvent('node-action', {\n detail: { message: { id: e.detail.message.id } },\n }),\n );\n }\n\n private onSelect(e: CustomEvent) {\n this.dispatchEvent(\n new CustomEvent('select', { detail: { message: e.detail.message.id } }),\n );\n }\n\n renderNodes(nodes: Array<TreeNode> = [], level: number = 0) {\n const renderedNodes: Array<TemplateResult<1>> = [];\n for (const n of nodes) {\n const renderedNode = html`\n <ix-dropdown-tree-node\n .treeNode=${n}\n .level=${level}\n .expanded=${n.expanded ?? false}\n .selected=${n.id === this.selectedId}\n @tree-node-select=${this.onSelect}\n @tree-node-toggle=${this.onToggle}\n @tree-node-action=${this.onNodeButtonClick}\n ?hasActionButton=${this.hasActionButton}\n data-testid=${level === 0\n ? IxDropdownTreeTestIds.PARENT_NODE\n : IxDropdownTreeTestIds.CHILD_NODE}\n >\n ${n.expanded ? this.renderNodes(n.children, level + 1) : nothing}\n </ix-dropdown-tree-node>\n `;\n renderedNodes.push(renderedNode);\n }\n return renderedNodes;\n }\n\n render() {\n return html` <div>${this.renderNodes(this.rootNode.children, 0)}</div> `;\n }\n}\n"]}
@@ -0,0 +1,7 @@
1
+ export declare class IxDropdownTreeTestIds {
2
+ static readonly PARENT_NODE = "parent_node";
3
+ static readonly PARENT_NODE_LABEL = "parent_node_label";
4
+ static readonly PARENT_NODE_CHEVRON = "parent_node_chevron";
5
+ static readonly CHILD_NODE = "child_node";
6
+ static readonly CHILD_NODE_LABEL = "child_node_label";
7
+ }
@@ -0,0 +1,8 @@
1
+ export class IxDropdownTreeTestIds {
2
+ }
3
+ IxDropdownTreeTestIds.PARENT_NODE = 'parent_node';
4
+ IxDropdownTreeTestIds.PARENT_NODE_LABEL = 'parent_node_label';
5
+ IxDropdownTreeTestIds.PARENT_NODE_CHEVRON = 'parent_node_chevron';
6
+ IxDropdownTreeTestIds.CHILD_NODE = 'child_node';
7
+ IxDropdownTreeTestIds.CHILD_NODE_LABEL = 'child_node_label';
8
+ //# sourceMappingURL=IxDropdownTreeTestIds.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IxDropdownTreeTestIds.js","sourceRoot":"","sources":["../src/IxDropdownTreeTestIds.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,qBAAqB;;AAChB,iCAAW,GAAG,aAAa,CAAC;AAE5B,uCAAiB,GAAG,mBAAmB,CAAC;AAExC,yCAAmB,GAAG,qBAAqB,CAAC;AAE5C,gCAAU,GAAG,YAAY,CAAC;AAE1B,sCAAgB,GAAG,kBAAkB,CAAC","sourcesContent":["export class IxDropdownTreeTestIds {\n static readonly PARENT_NODE = 'parent_node';\n\n static readonly PARENT_NODE_LABEL = 'parent_node_label';\n\n static readonly PARENT_NODE_CHEVRON = 'parent_node_chevron';\n\n static readonly CHILD_NODE = 'child_node';\n\n static readonly CHILD_NODE_LABEL = 'child_node_label';\n}\n"]}
@@ -0,0 +1,3 @@
1
+ export { IxDropdownTree } from './IxDropdownTree.js';
2
+ export { IxDropdownTreeNode } from './ix-dropdown-tree-node.js';
3
+ export { IxDropdownTreeNodeData } from './ix-dropdown-tree-types.js';
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { IxDropdownTree } from './IxDropdownTree.js';
2
+ export { IxDropdownTreeNode } from './ix-dropdown-tree-node.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC","sourcesContent":["export { IxDropdownTree } from './IxDropdownTree.js';\nexport { IxDropdownTreeNode } from './ix-dropdown-tree-node.js';\nexport { IxDropdownTreeNodeData } from './ix-dropdown-tree-types.js';\n"]}
@@ -0,0 +1,22 @@
1
+ import { LitElement, nothing } from 'lit';
2
+ import '@digital-realty/ix-icon-button/ix-icon-button.js';
3
+ import { IxDropdownTreeNodeData as TreeNode } from './ix-dropdown-tree-types.js';
4
+ export declare class IxDropdownTreeNode extends LitElement {
5
+ static readonly styles: import("lit").CSSResult[];
6
+ treeNode: TreeNode;
7
+ level: number;
8
+ expanded: boolean;
9
+ selected: boolean;
10
+ hasActionButton: boolean;
11
+ get isParentNode(): TreeNode[] | undefined;
12
+ onChevronClick(): void;
13
+ private onNodeToggle;
14
+ private onNodeAction;
15
+ private onNodeClick;
16
+ private onKeyDown;
17
+ dispatchSelect(): void;
18
+ renderLabel(): import("lit-html").TemplateResult<1>;
19
+ renderChevron(): import("lit-html").TemplateResult<1>;
20
+ renderNodeButton(): import("lit-html").TemplateResult<1> | typeof nothing;
21
+ render(): import("lit-html").TemplateResult<1>;
22
+ }
@@ -0,0 +1,195 @@
1
+ import { __decorate } from "tslib";
2
+ import { LitElement, html, nothing, css } from 'lit';
3
+ import { customElement, property } from 'lit/decorators.js';
4
+ import '@digital-realty/ix-icon-button/ix-icon-button.js';
5
+ import { IxDropdownTreeTestIds } from './IxDropdownTreeTestIds.js';
6
+ let IxDropdownTreeNode = class IxDropdownTreeNode extends LitElement {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.treeNode = {};
10
+ this.level = 0;
11
+ this.expanded = false;
12
+ this.selected = false;
13
+ this.hasActionButton = false;
14
+ }
15
+ get isParentNode() {
16
+ return this.treeNode.children;
17
+ }
18
+ onChevronClick() {
19
+ this.treeNode = { ...this.treeNode, expanded: !this.treeNode.expanded };
20
+ }
21
+ onNodeToggle(node) {
22
+ const event = new CustomEvent('tree-node-toggle', {
23
+ detail: {
24
+ message: {
25
+ node,
26
+ },
27
+ },
28
+ });
29
+ this.dispatchEvent(event);
30
+ }
31
+ onNodeAction() {
32
+ const event = new CustomEvent('tree-node-action', {
33
+ detail: {
34
+ message: {
35
+ id: this.treeNode.id,
36
+ name: this.treeNode.label,
37
+ },
38
+ },
39
+ });
40
+ this.dispatchEvent(event);
41
+ }
42
+ onNodeClick(ev) {
43
+ const t = ev.target;
44
+ if (t.tagName === 'MD-ICON-BUTTON') {
45
+ return;
46
+ }
47
+ this.dispatchSelect();
48
+ }
49
+ onKeyDown(ev) {
50
+ const t = ev.target;
51
+ if (t.tagName === 'MD-ICON-BUTTON') {
52
+ return;
53
+ }
54
+ this.dispatchSelect();
55
+ }
56
+ dispatchSelect() {
57
+ if (!this.isParentNode) {
58
+ this.dispatchEvent(new CustomEvent('tree-node-select', {
59
+ detail: { message: { id: this.treeNode.id } },
60
+ }));
61
+ }
62
+ }
63
+ renderLabel() {
64
+ return html `<p
65
+ class="dlr-text-small m-0 ${this.isParentNode ? 'font-extrabold' : ''}"
66
+ data-testid=${this.isParentNode
67
+ ? IxDropdownTreeTestIds.PARENT_NODE_LABEL
68
+ : IxDropdownTreeTestIds.CHILD_NODE_LABEL}
69
+ >
70
+ ${this.treeNode.label}
71
+ </p>`;
72
+ }
73
+ renderChevron() {
74
+ if (!this.isParentNode) {
75
+ return html `<div style="width: 4px"></div>`;
76
+ }
77
+ return html `<ix-icon-button
78
+ style="color:black;"
79
+ .icon=${this.expanded ? 'arrow_drop_down' : 'arrow_right'}
80
+ @click=${() => this.onNodeToggle(this.treeNode)}
81
+ data-testid=${IxDropdownTreeTestIds.PARENT_NODE_CHEVRON}
82
+ ></ix-icon-button>`;
83
+ }
84
+ renderNodeButton() {
85
+ return !this.isParentNode
86
+ ? html `
87
+ <ix-icon-button
88
+ class="text-slate-600"
89
+ @click=${() => {
90
+ this.onNodeAction();
91
+ }}
92
+ .icon=${'content_copy'}
93
+ >
94
+ </ix-icon-button>
95
+ `
96
+ : nothing;
97
+ }
98
+ render() {
99
+ return html `<div>
100
+ <div
101
+ class="container
102
+ ${!this.isParentNode ? 'hover-bg-indigo-100' : ''}
103
+ ${this.selected && !this.isParentNode ? 'bg-indigo-100' : ''}
104
+ "
105
+ @keydown=${this.onKeyDown}
106
+ tabindex="0"
107
+ @click=${this.onNodeClick}
108
+ >
109
+ <div
110
+ class="toggle-container ${!this.hasActionButton ? 'my-2' : ''}"
111
+ style="padding-left: ${this.level * 1}rem"
112
+ >
113
+ ${this.renderChevron()} ${this.renderLabel()}
114
+ </div>
115
+ ${this.hasActionButton ? this.renderNodeButton() : nothing}
116
+ </div>
117
+ <slot></slot>
118
+ </div>`;
119
+ }
120
+ };
121
+ IxDropdownTreeNode.styles = [
122
+ css `
123
+ ix-icon-button {
124
+ --md-sys-color-on-surface-variant: var(--md-sys-color-primary);
125
+ }
126
+
127
+ .dlr-text-small {
128
+ font-family: var(--root-primary-font);
129
+ font-size: var(--text-small-size);
130
+ line-height: var(--text-small-line-height);
131
+ letter-spacing: var(--text-small-letter-spacing);
132
+ font-weight: var(--text-small-weight);
133
+ -webkit-text-decoration: var(--text-small-decoration);
134
+ text-decoration: var(--text-small-decoration);
135
+ text-transform: var(--text-small-transform);
136
+ }
137
+
138
+ .font-extrabold {
139
+ font-weight: 800;
140
+ }
141
+
142
+ .text-slate-600 {
143
+ color: rgb(71 85 105 / 1);
144
+ }
145
+
146
+ .container {
147
+ --_indigo-100: rgb(224 231 255 / 1);
148
+ display: flex;
149
+ align-items: center;
150
+ justify-content: space-between;
151
+ border-top-right-radius: 9999px;
152
+ border-bottom-right-radius: 9999px;
153
+ cursor: pointer;
154
+ user-select: none;
155
+ }
156
+
157
+ .hover-bg-indigo-100:hover,
158
+ .bg-indigo-100 {
159
+ background-color: var(--_indigo-100);
160
+ }
161
+
162
+ .toggle-container {
163
+ display: flex;
164
+ align-items: center;
165
+ }
166
+
167
+ .my-2 {
168
+ margin-block: 0.5rem;
169
+ }
170
+
171
+ .m-0 {
172
+ margin: 0;
173
+ }
174
+ `,
175
+ ];
176
+ __decorate([
177
+ property({ type: Object })
178
+ ], IxDropdownTreeNode.prototype, "treeNode", void 0);
179
+ __decorate([
180
+ property({ type: Number })
181
+ ], IxDropdownTreeNode.prototype, "level", void 0);
182
+ __decorate([
183
+ property({ type: Boolean })
184
+ ], IxDropdownTreeNode.prototype, "expanded", void 0);
185
+ __decorate([
186
+ property({ type: Boolean })
187
+ ], IxDropdownTreeNode.prototype, "selected", void 0);
188
+ __decorate([
189
+ property({ type: Boolean })
190
+ ], IxDropdownTreeNode.prototype, "hasActionButton", void 0);
191
+ IxDropdownTreeNode = __decorate([
192
+ customElement('ix-dropdown-tree-node')
193
+ ], IxDropdownTreeNode);
194
+ export { IxDropdownTreeNode };
195
+ //# sourceMappingURL=ix-dropdown-tree-node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ix-dropdown-tree-node.js","sourceRoot":"","sources":["../src/ix-dropdown-tree-node.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,kDAAkD,CAAC;AAE1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAG5D,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,UAAU;IAA3C;;QAyDuB,aAAQ,GAAa,EAAc,CAAC;QAEpC,UAAK,GAAG,CAAC,CAAC;QAET,aAAQ,GAAG,KAAK,CAAC;QAEjB,aAAQ,GAAG,KAAK,CAAC;QAEjB,oBAAe,GAAG,KAAK,CAAC;IAwHvD,CAAC;IAtHC,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;IAChC,CAAC;IAED,cAAc;QACZ,IAAI,CAAC,QAAQ,GAAG,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;IAC1E,CAAC;IAEO,YAAY,CAAC,IAAc;QACjC,MAAM,KAAK,GAAG,IAAI,WAAW,CAAC,kBAAkB,EAAE;YAChD,MAAM,EAAE;gBACN,OAAO,EAAE;oBACP,IAAI;iBACL;aACF;SACF,CAAC,CAAC;QAEH,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAoDF;CACF,AAtDqB,CAsDpB;AAE0B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oDAAqC;AAEpC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iDAAW;AAET;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;oDAAkB;AAEjB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;oDAAkB;AAEjB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;2DAAyB;AAjE1C,kBAAkB;IAD9B,aAAa,CAAC,uBAAuB,CAAC;GAC1B,kBAAkB,CAyL9B","sourcesContent":["import { LitElement, html, nothing, css } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport '@digital-realty/ix-icon-button/ix-icon-button.js';\nimport { IxDropdownTreeNodeData as TreeNode } from './ix-dropdown-tree-types.js';\nimport { IxDropdownTreeTestIds } from './IxDropdownTreeTestIds.js';\n\n@customElement('ix-dropdown-tree-node')\nexport class IxDropdownTreeNode extends LitElement {\n static readonly styles = [\n css`\n ix-icon-button {\n --md-sys-color-on-surface-variant: var(--md-sys-color-primary);\n }\n\n .dlr-text-small {\n font-family: var(--root-primary-font);\n font-size: var(--text-small-size);\n line-height: var(--text-small-line-height);\n letter-spacing: var(--text-small-letter-spacing);\n font-weight: var(--text-small-weight);\n -webkit-text-decoration: var(--text-small-decoration);\n text-decoration: var(--text-small-decoration);\n text-transform: var(--text-small-transform);\n }\n\n .font-extrabold {\n font-weight: 800;\n }\n\n .text-slate-600 {\n color: rgb(71 85 105 / 1);\n }\n\n .container {\n --_indigo-100: rgb(224 231 255 / 1);\n display: flex;\n align-items: center;\n justify-content: space-between;\n border-top-right-radius: 9999px;\n border-bottom-right-radius: 9999px;\n cursor: pointer;\n user-select: none;\n }\n\n .hover-bg-indigo-100:hover,\n .bg-indigo-100 {\n background-color: var(--_indigo-100);\n }\n\n .toggle-container {\n display: flex;\n align-items: center;\n }\n\n .my-2 {\n margin-block: 0.5rem;\n }\n\n .m-0 {\n margin: 0;\n }\n `,\n ];\n\n @property({ type: Object }) treeNode: TreeNode = {} as TreeNode;\n\n @property({ type: Number }) level = 0;\n\n @property({ type: Boolean }) expanded = false;\n\n @property({ type: Boolean }) selected = false;\n\n @property({ type: Boolean }) hasActionButton = false;\n\n get isParentNode() {\n return this.treeNode.children;\n }\n\n onChevronClick() {\n this.treeNode = { ...this.treeNode, expanded: !this.treeNode.expanded };\n }\n\n private onNodeToggle(node: TreeNode): void {\n const event = new CustomEvent('tree-node-toggle', {\n detail: {\n message: {\n node,\n },\n },\n });\n\n this.dispatchEvent(event);\n }\n\n private onNodeAction(): void {\n const event = new CustomEvent('tree-node-action', {\n detail: {\n message: {\n id: this.treeNode.id,\n name: this.treeNode.label,\n },\n },\n });\n this.dispatchEvent(event);\n }\n\n private onNodeClick(ev: Event): void {\n const t = ev.target as HTMLElement;\n if (t.tagName === 'MD-ICON-BUTTON') {\n return;\n }\n this.dispatchSelect();\n }\n\n private onKeyDown(ev: KeyboardEvent): void {\n const t = ev.target as HTMLElement;\n if (t.tagName === 'MD-ICON-BUTTON') {\n return;\n }\n this.dispatchSelect();\n }\n\n dispatchSelect() {\n if (!this.isParentNode) {\n this.dispatchEvent(\n new CustomEvent('tree-node-select', {\n detail: { message: { id: this.treeNode.id } },\n }),\n );\n }\n }\n\n renderLabel() {\n return html`<p\n class=\"dlr-text-small m-0 ${this.isParentNode ? 'font-extrabold' : ''}\"\n data-testid=${this.isParentNode\n ? IxDropdownTreeTestIds.PARENT_NODE_LABEL\n : IxDropdownTreeTestIds.CHILD_NODE_LABEL}\n >\n ${this.treeNode.label}\n </p>`;\n }\n\n renderChevron() {\n if (!this.isParentNode) {\n return html`<div style=\"width: 4px\"></div>`;\n }\n return html`<ix-icon-button\n style=\"color:black;\"\n .icon=${this.expanded ? 'arrow_drop_down' : 'arrow_right'}\n @click=${() => this.onNodeToggle(this.treeNode)}\n data-testid=${IxDropdownTreeTestIds.PARENT_NODE_CHEVRON}\n ></ix-icon-button>`;\n }\n\n renderNodeButton() {\n return !this.isParentNode\n ? html`\n <ix-icon-button\n class=\"text-slate-600\"\n @click=${() => {\n this.onNodeAction();\n }}\n .icon=${'content_copy'}\n >\n </ix-icon-button>\n `\n : nothing;\n }\n\n render() {\n return html`<div>\n <div\n class=\"container\n ${!this.isParentNode ? 'hover-bg-indigo-100' : ''}\n ${this.selected && !this.isParentNode ? 'bg-indigo-100' : ''}\n \"\n @keydown=${this.onKeyDown}\n tabindex=\"0\"\n @click=${this.onNodeClick}\n >\n <div\n class=\"toggle-container ${!this.hasActionButton ? 'my-2' : ''}\"\n style=\"padding-left: ${this.level * 1}rem\"\n >\n ${this.renderChevron()} ${this.renderLabel()}\n </div>\n ${this.hasActionButton ? this.renderNodeButton() : nothing}\n </div>\n <slot></slot>\n </div>`;\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ export declare const DropdownTreeStyles: import("lit").CSSResult;
@@ -0,0 +1,7 @@
1
+ import { css } from 'lit';
2
+ export const DropdownTreeStyles = css `
3
+ ix-icon-button {
4
+ --md-sys-color-on-surface-variant: var(--md-sys-color-primary);
5
+ }
6
+ `;
7
+ //# sourceMappingURL=ix-dropdown-tree-styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ix-dropdown-tree-styles.js","sourceRoot":"","sources":["../src/ix-dropdown-tree-styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CAAA;;;;CAIpC,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport const DropdownTreeStyles = css`\n ix-icon-button {\n --md-sys-color-on-surface-variant: var(--md-sys-color-primary);\n }\n`;\n"]}
@@ -0,0 +1,6 @@
1
+ export interface IxDropdownTreeNodeData {
2
+ label: string;
3
+ id: string;
4
+ children?: IxDropdownTreeNodeData[];
5
+ expanded?: boolean;
6
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ix-dropdown-tree-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ix-dropdown-tree-types.js","sourceRoot":"","sources":["../src/ix-dropdown-tree-types.ts"],"names":[],"mappings":"","sourcesContent":["export interface IxDropdownTreeNodeData {\n label: string;\n id: string;\n children?: IxDropdownTreeNodeData[];\n expanded?: boolean;\n}\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { IxDropdownTree } from './IxDropdownTree.js';
2
+ window.customElements.define('ix-dropdown-tree', IxDropdownTree);
3
+ //# sourceMappingURL=ix-dropdown-tree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ix-dropdown-tree.js","sourceRoot":"","sources":["../src/ix-dropdown-tree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,kBAAkB,EAAE,cAAc,CAAC,CAAC","sourcesContent":["import { IxDropdownTree } from './IxDropdownTree.js';\n\nwindow.customElements.define('ix-dropdown-tree', IxDropdownTree);\n"]}
@@ -0,0 +1 @@
1
+ import '../ix-dropdown-tree.js';
@@ -0,0 +1,54 @@
1
+ import '../ix-dropdown-tree.js';
2
+ import { expect, fixture } from '@open-wc/testing';
3
+ import { html } from 'lit';
4
+ import { IxDropdownTreeTestIds } from '../IxDropdownTreeTestIds.js';
5
+ const testNode = {
6
+ label: 'root',
7
+ id: 'root',
8
+ children: [
9
+ {
10
+ label: 'MICROSOFT EUROPE',
11
+ id: 'MS_EU',
12
+ children: [
13
+ {
14
+ label: 'Test Role 6',
15
+ id: 'role-006',
16
+ },
17
+ ],
18
+ },
19
+ ],
20
+ };
21
+ const createElement = () => fixture(html `<ix-dropdown-tree .rootNode=${testNode}></ix-dropdown-tree>`);
22
+ const selectTestId = (element, target) => element.shadowRoot?.querySelector(`[data-testid="${target}"]`);
23
+ describe('<ix-dropdown-tree>', () => {
24
+ it('should render the correct label', async () => {
25
+ const element = await createElement();
26
+ expect(element, 'element').to.exist;
27
+ const parentNode = selectTestId(element, IxDropdownTreeTestIds.PARENT_NODE);
28
+ expect(parentNode, 'parent node').to.exist;
29
+ const label = selectTestId(parentNode, IxDropdownTreeTestIds.PARENT_NODE_LABEL);
30
+ expect(label).to.exist;
31
+ await expect(label.innerText).to.eq('MICROSOFT EUROPE');
32
+ });
33
+ it('should render the chevron icon', async () => {
34
+ const element = await createElement();
35
+ expect(element, 'element').to.exist;
36
+ const parentNode = selectTestId(element, IxDropdownTreeTestIds.PARENT_NODE);
37
+ expect(parentNode, 'parent node').to.exist;
38
+ const chevron = selectTestId(parentNode, IxDropdownTreeTestIds.PARENT_NODE_CHEVRON);
39
+ expect(chevron, 'chevron').to.exist;
40
+ chevron.click();
41
+ });
42
+ it('should render the tree', async () => {
43
+ const element = await createElement();
44
+ expect(element, 'element').to.exist;
45
+ const parentNode = selectTestId(element, IxDropdownTreeTestIds.PARENT_NODE);
46
+ expect(parentNode, 'parent node').to.exist;
47
+ const childNode = parentNode?.querySelector(`[data-testid="${IxDropdownTreeTestIds.CHILD_NODE}"]`);
48
+ expect(childNode, 'child node').to.exist;
49
+ const label = selectTestId(childNode, IxDropdownTreeTestIds.CHILD_NODE_LABEL);
50
+ expect(label, 'label').to.exist;
51
+ await expect(label.innerText).to.eq('Test Role 6');
52
+ });
53
+ });
54
+ //# sourceMappingURL=ix-dropdown-tree.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ix-dropdown-tree.test.js","sourceRoot":"","sources":["../../src/test/ix-dropdown-tree.test.ts"],"names":[],"mappings":"AAAA,OAAO,wBAAwB,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,k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AM,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import '../ix-dropdown-tree.js';\nimport { expect, fixture } from '@open-wc/testing';\nimport { html } from 'lit';\nimport { IxDropdownTreeNodeData } from '../ix-dropdown-tree-types.js';\nimport { IxDropdownTreeNode as TreeNode } from '../ix-dropdown-tree-node.js';\nimport { IxDropdownTree } from '../IxDropdownTree.js';\nimport { IxDropdownTreeTestIds } from '../IxDropdownTreeTestIds.js';\n\nconst testNode: IxDropdownTreeNodeData = {\n label: 'root',\n id: 'root',\n children: [\n {\n label: 'MICROSOFT EUROPE',\n id: 'MS_EU',\n children: [\n {\n label: 'Test Role 6',\n id: 'role-006',\n },\n ],\n },\n ],\n};\n\nconst createElement = () =>\n fixture<IxDropdownTree>(\n html`<ix-dropdown-tree .rootNode=${testNode}></ix-dropdown-tree>`,\n );\n\nconst selectTestId = <T>(element: HTMLElement, target: string) =>\n element.shadowRoot?.querySelector(`[data-testid=\"${target}\"]`) as\n | T\n | undefined;\n\ndescribe('<ix-dropdown-tree>', () => {\n it('should render the correct label', async () => {\n const element: IxDropdownTree = await createElement();\n expect(element, 'element').to.exist;\n\n const parentNode = selectTestId<TreeNode>(\n element,\n IxDropdownTreeTestIds.PARENT_NODE,\n );\n expect(parentNode, 'parent node').to.exist;\n\n const label = selectTestId<HTMLParagraphElement>(\n parentNode!,\n IxDropdownTreeTestIds.PARENT_NODE_LABEL,\n );\n expect(label).to.exist;\n await expect(label!.innerText).to.eq('MICROSOFT EUROPE');\n });\n\n it('should render the chevron icon', async () => {\n const element: IxDropdownTree = await createElement();\n expect(element, 'element').to.exist;\n\n const parentNode = selectTestId<TreeNode>(\n element,\n IxDropdownTreeTestIds.PARENT_NODE,\n );\n expect(parentNode, 'parent node').to.exist;\n\n const chevron = selectTestId<HTMLElement>(\n parentNode!,\n IxDropdownTreeTestIds.PARENT_NODE_CHEVRON,\n );\n expect(chevron, 'chevron').to.exist;\n chevron!.click();\n });\n\n it('should render the tree', async () => {\n const element: IxDropdownTree = await createElement();\n expect(element, 'element').to.exist;\n\n const parentNode = selectTestId<TreeNode>(\n element,\n IxDropdownTreeTestIds.PARENT_NODE,\n );\n expect(parentNode, 'parent node').to.exist;\n\n const childNode = parentNode?.querySelector(\n `[data-testid=\"${IxDropdownTreeTestIds.CHILD_NODE}\"]`,\n ) as TreeNode;\n expect(childNode, 'child node').to.exist;\n\n const label = selectTestId<HTMLParagraphElement>(\n childNode!,\n IxDropdownTreeTestIds.CHILD_NODE_LABEL,\n );\n expect(label, 'label').to.exist;\n await expect(label!.innerText).to.eq('Test Role 6');\n });\n});\n"]}
package/package.json ADDED
@@ -0,0 +1,94 @@
1
+ {
2
+ "name": "@digital-realty/ix-dropdown-tree",
3
+ "description": "Webcomponent ix-dropdown-tree following open-wc recommendations",
4
+ "license": "MIT",
5
+ "author": "ix-dropdown-tree",
6
+ "version": "1.0.2",
7
+ "type": "module",
8
+ "main": "dist/index.js",
9
+ "module": "dist/index.js",
10
+ "exports": {
11
+ ".": "./dist/index.js",
12
+ "./ix-dropdown-tree.js": "./dist/ix-dropdown-tree.js",
13
+ "./IxDropdownTreeNodeData": "./dist/ix-dropdown-tree-types.js"
14
+ },
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "scripts": {
19
+ "analyze": "cem analyze --litelement",
20
+ "start": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"web-dev-server\"",
21
+ "build": "tsc && npm run analyze -- --exclude dist",
22
+ "prepublish": "tsc && npm run analyze -- --exclude dist",
23
+ "lint": "eslint --ext .ts,.html . --ignore-path .gitignore && prettier \"**/*.ts\" --check --ignore-path .gitignore",
24
+ "format": "eslint --ext .ts,.html . --fix --ignore-path .gitignore && prettier \"**/*.ts\" --write --ignore-path .gitignore",
25
+ "prepare": "husky",
26
+ "test": "tsc && wtr --coverage",
27
+ "test:watch": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wtr --watch\""
28
+ },
29
+ "dependencies": {
30
+ "@digital-realty/ix-icon-button": "^1.1.6",
31
+ "lit": "^3.1.4"
32
+ },
33
+ "devDependencies": {
34
+ "@custom-elements-manifest/analyzer": "^0.10.3",
35
+ "@open-wc/eslint-config": "^12.0.3",
36
+ "@open-wc/testing": "^4.0.0",
37
+ "@types/mocha": "^10.0.7",
38
+ "@typescript-eslint/eslint-plugin": "^7.16.0",
39
+ "@typescript-eslint/parser": "^7.16.0",
40
+ "@web/dev-server": "^0.4.6",
41
+ "@web/test-runner": "^0.18.2",
42
+ "concurrently": "^8.2.2",
43
+ "eslint": "^8.57.0",
44
+ "eslint-config-prettier": "^9.1.0",
45
+ "husky": "^9.0.11",
46
+ "lint-staged": "^15.2.7",
47
+ "prettier": "^3.3.2",
48
+ "tslib": "^2.6.3",
49
+ "typescript": "^5.5.3"
50
+ },
51
+ "customElements": "custom-elements.json",
52
+ "eslintConfig": {
53
+ "parser": "@typescript-eslint/parser",
54
+ "root": true,
55
+ "extends": [
56
+ "@open-wc",
57
+ "prettier"
58
+ ],
59
+ "plugins": [
60
+ "@typescript-eslint"
61
+ ],
62
+ "rules": {
63
+ "no-unused-vars": "off",
64
+ "@typescript-eslint/no-unused-vars": [
65
+ "error"
66
+ ],
67
+ "import/no-unresolved": "off",
68
+ "import/extensions": [
69
+ "error",
70
+ "always",
71
+ {
72
+ "ignorePackages": true
73
+ }
74
+ ]
75
+ }
76
+ },
77
+ "prettier": {
78
+ "singleQuote": true,
79
+ "arrowParens": "avoid"
80
+ },
81
+ "lint-staged": {
82
+ "*.ts": [
83
+ "eslint --fix",
84
+ "prettier --write"
85
+ ]
86
+ },
87
+ "files": [
88
+ "/dist",
89
+ "package.json",
90
+ "README.md",
91
+ "LICENSE"
92
+ ],
93
+ "gitHead": "f19908b2ba8f2d9273559982f0417f724466ae5c"
94
+ }