@digital-realty/ix-tree 3.0.10 → 3.1.2-alpha-NJEN.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.
@@ -1,10 +1,10 @@
1
- export interface IIxTreeNode {
2
- children?: Array<IIxTreeNode>;
3
- expanded?: boolean;
4
- icon?: string;
5
- id: string;
6
- label: string;
7
- parentId?: string;
8
- checked?: boolean;
9
- indeterminate?: boolean;
10
- }
1
+ export interface IIxTreeNode {
2
+ children?: Array<IIxTreeNode>;
3
+ expanded?: boolean;
4
+ icon?: string;
5
+ id: string;
6
+ label: string;
7
+ parentId?: string;
8
+ checked?: boolean;
9
+ indeterminate?: boolean;
10
+ }
@@ -1,2 +1,2 @@
1
- export {};
1
+ export {};
2
2
  //# sourceMappingURL=IIxTreeNode.js.map
package/dist/IxTree.d.ts CHANGED
@@ -1,30 +1,30 @@
1
- import '@digital-realty/ix-icon/ix-icon.js';
2
- import '@digital-realty/theme';
3
- import { LitElement, TemplateResult } from 'lit';
4
- import { IIxTreeNode } from './IIxTreeNode.js';
5
- import './ix-tree-node.js';
6
- export type Appearance = 'filled' | 'filled-tonal' | 'outlined' | 'default';
7
- export declare class IxTree extends LitElement {
8
- static readonly styles: import("lit").CSSResult[];
9
- connectedCallback(): void;
10
- ariaLabel: string;
11
- rootNode: IIxTreeNode;
12
- selectedNodeId: string;
13
- checkboxesEnabled: boolean;
14
- appearance: Appearance;
15
- hasIcons: boolean;
16
- removeChevron: boolean;
17
- private _activeItemId;
18
- private _rootNode;
19
- private _selectedNodeId;
20
- private onTreeNodeClick;
21
- private dispatchTreeNodeExpandToggle;
22
- private onTreeNodeToggle;
23
- private onTreeNodeCheck;
24
- private renderNodes;
25
- /**
26
- * Expand the active tree node and all of its parent nodes.
27
- */
28
- private expandActiveTreeNode;
29
- protected render(): TemplateResult<1>;
30
- }
1
+ import '@digital-realty/ix-icon/ix-icon.js';
2
+ import '@digital-realty/theme';
3
+ import { LitElement, TemplateResult } from 'lit';
4
+ import { IIxTreeNode } from './IIxTreeNode.js';
5
+ import './ix-tree-node.js';
6
+ export type Appearance = 'filled' | 'filled-tonal' | 'outlined' | 'default';
7
+ export declare class IxTree extends LitElement {
8
+ static readonly styles: import("lit").CSSResult[];
9
+ connectedCallback(): void;
10
+ ariaLabel: string;
11
+ rootNode: IIxTreeNode;
12
+ selectedNodeId: string;
13
+ checkboxesEnabled: boolean;
14
+ appearance: Appearance;
15
+ hasIcons: boolean;
16
+ removeChevron: boolean;
17
+ private _activeItemId;
18
+ private _rootNode;
19
+ private _selectedNodeId;
20
+ private onTreeNodeClick;
21
+ private dispatchTreeNodeExpandToggle;
22
+ private onTreeNodeToggle;
23
+ private onTreeNodeCheck;
24
+ private renderNodes;
25
+ /**
26
+ * Expand the active tree node and all of its parent nodes.
27
+ */
28
+ private expandActiveTreeNode;
29
+ protected render(): TemplateResult<1>;
30
+ }
package/dist/IxTree.js CHANGED
@@ -1,67 +1,67 @@
1
- import { __decorate } from "tslib";
2
- import '@digital-realty/ix-icon/ix-icon.js';
3
- import '@digital-realty/theme';
4
- import { nothing, html, LitElement } from 'lit';
5
- import { property, state } from 'lit/decorators.js';
6
- import { findChildNodeById, updateNodeCheckedStatus } from './tree-utils.js';
7
- import { IxTreeStyles } from './ix-tree-styles.js';
8
- import './ix-tree-node.js';
9
- export class IxTree extends LitElement {
10
- constructor() {
11
- super(...arguments);
12
- this.ariaLabel = 'tree';
13
- this.selectedNodeId = '';
14
- this.checkboxesEnabled = false;
15
- this.appearance = 'default';
16
- this.hasIcons = false;
17
- this.removeChevron = false;
18
- this._activeItemId = '';
19
- this._selectedNodeId = '';
20
- }
21
- connectedCallback() {
22
- super.connectedCallback();
23
- this._activeItemId = this.selectedNodeId; // store in state
24
- this._selectedNodeId = this.selectedNodeId; // store in state
25
- this._rootNode = this.rootNode;
26
- }
27
- onTreeNodeClick(e) {
28
- this.dispatchEvent(new CustomEvent('on-tree-node-selected', {
29
- detail: {
30
- message: e.detail.message,
31
- },
32
- }));
33
- this._selectedNodeId = e.detail.message.id;
34
- }
35
- dispatchTreeNodeExpandToggle(e) {
36
- this.dispatchEvent(new CustomEvent('on-tree-node-expand-toggle', {
37
- detail: {
38
- message: e.detail.message,
39
- },
40
- }));
41
- }
42
- onTreeNodeToggle(e) {
43
- const newRootNode = { ...this._rootNode };
44
- const { node } = e.detail.message;
45
- node.expanded = !node.expanded;
46
- this.rootNode = newRootNode;
47
- this._activeItemId = node.id;
48
- this.dispatchTreeNodeExpandToggle(e);
49
- this.requestUpdate();
50
- }
51
- onTreeNodeCheck(e) {
52
- const { node } = e.detail.message;
53
- updateNodeCheckedStatus(node, this._rootNode);
54
- this._rootNode = structuredClone(this._rootNode);
55
- this.rootNode = this._rootNode;
56
- this.dispatchEvent(new CustomEvent('on-tree-node-checked', {
57
- detail: {
58
- message: e.detail.message,
59
- },
60
- }));
61
- }
62
- renderNodes(nodes = [], level = 0) {
63
- const renderedNodes = [];
64
- for (const node of nodes) {
1
+ import { __decorate } from "tslib";
2
+ import '@digital-realty/ix-icon/ix-icon.js';
3
+ import '@digital-realty/theme';
4
+ import { nothing, html, LitElement } from 'lit';
5
+ import { property, state } from 'lit/decorators.js';
6
+ import { findChildNodeById, updateNodeCheckedStatus } from './tree-utils.js';
7
+ import { IxTreeStyles } from './ix-tree-styles.js';
8
+ import './ix-tree-node.js';
9
+ export class IxTree extends LitElement {
10
+ constructor() {
11
+ super(...arguments);
12
+ this.ariaLabel = 'tree';
13
+ this.selectedNodeId = '';
14
+ this.checkboxesEnabled = false;
15
+ this.appearance = 'default';
16
+ this.hasIcons = false;
17
+ this.removeChevron = false;
18
+ this._activeItemId = '';
19
+ this._selectedNodeId = '';
20
+ }
21
+ connectedCallback() {
22
+ super.connectedCallback();
23
+ this._activeItemId = this.selectedNodeId; // store in state
24
+ this._selectedNodeId = this.selectedNodeId; // store in state
25
+ this._rootNode = this.rootNode;
26
+ }
27
+ onTreeNodeClick(e) {
28
+ this.dispatchEvent(new CustomEvent('on-tree-node-selected', {
29
+ detail: {
30
+ message: e.detail.message,
31
+ },
32
+ }));
33
+ this._selectedNodeId = e.detail.message.id;
34
+ }
35
+ dispatchTreeNodeExpandToggle(e) {
36
+ this.dispatchEvent(new CustomEvent('on-tree-node-expand-toggle', {
37
+ detail: {
38
+ message: e.detail.message,
39
+ },
40
+ }));
41
+ }
42
+ onTreeNodeToggle(e) {
43
+ const newRootNode = { ...this._rootNode };
44
+ const { node } = e.detail.message;
45
+ node.expanded = !node.expanded;
46
+ this.rootNode = newRootNode;
47
+ this._activeItemId = node.id;
48
+ this.dispatchTreeNodeExpandToggle(e);
49
+ this.requestUpdate();
50
+ }
51
+ onTreeNodeCheck(e) {
52
+ const { node } = e.detail.message;
53
+ updateNodeCheckedStatus(node, this._rootNode);
54
+ this._rootNode = structuredClone(this._rootNode);
55
+ this.rootNode = this._rootNode;
56
+ this.dispatchEvent(new CustomEvent('on-tree-node-checked', {
57
+ detail: {
58
+ message: e.detail.message,
59
+ },
60
+ }));
61
+ }
62
+ renderNodes(nodes = [], level = 0) {
63
+ const renderedNodes = [];
64
+ for (const node of nodes) {
65
65
  const renderedNode = html `<ix-tree-node
66
66
  .level=${level}
67
67
  .node=${node}
@@ -77,71 +77,71 @@ export class IxTree extends LitElement {
77
77
  @on-tree-node-check=${this.onTreeNodeCheck}
78
78
  >
79
79
  ${node.expanded ? this.renderNodes(node.children, level + 1) : nothing}
80
- </ix-tree-node>`;
81
- renderedNodes.push(renderedNode);
82
- }
83
- return renderedNodes;
84
- }
85
- /**
86
- * Expand the active tree node and all of its parent nodes.
87
- */
88
- expandActiveTreeNode() {
89
- const nodeToSelect = findChildNodeById(this._rootNode, this._activeItemId) || this._rootNode;
90
- let iteration = 0;
91
- const MAX_ITERATIONS = 1000;
92
- if (!nodeToSelect.parentId) {
93
- return;
94
- }
95
- let node = findChildNodeById(this._rootNode, nodeToSelect.parentId);
96
- while (node && iteration < MAX_ITERATIONS) {
97
- node.expanded = true;
98
- if (!node.parentId) {
99
- break;
100
- }
101
- node = findChildNodeById(this._rootNode, node.parentId);
102
- iteration += 1;
103
- }
104
- }
105
- render() {
106
- this.expandActiveTreeNode();
80
+ </ix-tree-node>`;
81
+ renderedNodes.push(renderedNode);
82
+ }
83
+ return renderedNodes;
84
+ }
85
+ /**
86
+ * Expand the active tree node and all of its parent nodes.
87
+ */
88
+ expandActiveTreeNode() {
89
+ const nodeToSelect = findChildNodeById(this._rootNode, this._activeItemId) || this._rootNode;
90
+ let iteration = 0;
91
+ const MAX_ITERATIONS = 1000;
92
+ if (!nodeToSelect.parentId) {
93
+ return;
94
+ }
95
+ let node = findChildNodeById(this._rootNode, nodeToSelect.parentId);
96
+ while (node && iteration < MAX_ITERATIONS) {
97
+ node.expanded = true;
98
+ if (!node.parentId) {
99
+ break;
100
+ }
101
+ node = findChildNodeById(this._rootNode, node.parentId);
102
+ iteration += 1;
103
+ }
104
+ }
105
+ render() {
106
+ this.expandActiveTreeNode();
107
107
  return html `<div
108
108
  aria-label=${this.ariaLabel}
109
109
  class="ix-tree-container"
110
110
  role="tree"
111
111
  >
112
112
  ${this.renderNodes(this._rootNode.children, 0)}
113
- </div>`;
114
- }
115
- }
116
- IxTree.styles = [IxTreeStyles];
117
- __decorate([
118
- property({ type: String })
119
- ], IxTree.prototype, "ariaLabel", void 0);
120
- __decorate([
121
- property({ type: Object })
122
- ], IxTree.prototype, "rootNode", void 0);
123
- __decorate([
124
- property({ type: String })
125
- ], IxTree.prototype, "selectedNodeId", void 0);
126
- __decorate([
127
- property({ type: Boolean })
128
- ], IxTree.prototype, "checkboxesEnabled", void 0);
129
- __decorate([
130
- property({ type: String })
131
- ], IxTree.prototype, "appearance", void 0);
132
- __decorate([
133
- property({ type: Boolean })
134
- ], IxTree.prototype, "hasIcons", void 0);
135
- __decorate([
136
- property({ type: Boolean })
137
- ], IxTree.prototype, "removeChevron", void 0);
138
- __decorate([
139
- state()
140
- ], IxTree.prototype, "_activeItemId", void 0);
141
- __decorate([
142
- state()
143
- ], IxTree.prototype, "_rootNode", void 0);
144
- __decorate([
145
- state()
146
- ], IxTree.prototype, "_selectedNodeId", void 0);
113
+ </div>`;
114
+ }
115
+ }
116
+ IxTree.styles = [IxTreeStyles];
117
+ __decorate([
118
+ property({ type: String })
119
+ ], IxTree.prototype, "ariaLabel", void 0);
120
+ __decorate([
121
+ property({ type: Object })
122
+ ], IxTree.prototype, "rootNode", void 0);
123
+ __decorate([
124
+ property({ type: String })
125
+ ], IxTree.prototype, "selectedNodeId", void 0);
126
+ __decorate([
127
+ property({ type: Boolean })
128
+ ], IxTree.prototype, "checkboxesEnabled", void 0);
129
+ __decorate([
130
+ property({ type: String })
131
+ ], IxTree.prototype, "appearance", void 0);
132
+ __decorate([
133
+ property({ type: Boolean })
134
+ ], IxTree.prototype, "hasIcons", void 0);
135
+ __decorate([
136
+ property({ type: Boolean })
137
+ ], IxTree.prototype, "removeChevron", void 0);
138
+ __decorate([
139
+ state()
140
+ ], IxTree.prototype, "_activeItemId", void 0);
141
+ __decorate([
142
+ state()
143
+ ], IxTree.prototype, "_rootNode", void 0);
144
+ __decorate([
145
+ state()
146
+ ], IxTree.prototype, "_selectedNodeId", void 0);
147
147
  //# sourceMappingURL=IxTree.js.map
@@ -1,26 +1,26 @@
1
- import '@digital-realty/ix-icon-button/ix-icon-button.js';
2
- import '@digital-realty/ix-checkbox/ix-checkbox.js';
3
- import '@digital-realty/theme';
4
- import { LitElement, TemplateResult } from 'lit';
5
- import { IIxTreeNode } from './IIxTreeNode.js';
6
- import { Appearance } from './IxTree.js';
7
- export declare class IxTreeNode extends LitElement {
8
- static readonly styles: import("lit").CSSResult[];
9
- isActiveTreeNode: boolean;
10
- isExpanded: boolean;
11
- isSelected: boolean;
12
- level: number;
13
- node: IIxTreeNode;
14
- checkboxEnabled: boolean;
15
- appearance: Appearance;
16
- hasIcon: boolean;
17
- removeChevron: boolean;
18
- private _hasScrolledToActive;
19
- private hasChildren;
20
- private getChevron;
21
- private onNodeClick;
22
- private onNodeToggle;
23
- private onNodeCheck;
24
- protected render(): TemplateResult<1>;
25
- protected updated(): void;
26
- }
1
+ import '@digital-realty/ix-icon-button/ix-icon-button.js';
2
+ import '@digital-realty/ix-checkbox/ix-checkbox.js';
3
+ import '@digital-realty/theme';
4
+ import { LitElement, TemplateResult } from 'lit';
5
+ import { IIxTreeNode } from './IIxTreeNode.js';
6
+ import { Appearance } from './IxTree.js';
7
+ export declare class IxTreeNode extends LitElement {
8
+ static readonly styles: import("lit").CSSResult[];
9
+ isActiveTreeNode: boolean;
10
+ isExpanded: boolean;
11
+ isSelected: boolean;
12
+ level: number;
13
+ node: IIxTreeNode;
14
+ checkboxEnabled: boolean;
15
+ appearance: Appearance;
16
+ hasIcon: boolean;
17
+ removeChevron: boolean;
18
+ private _hasScrolledToActive;
19
+ private hasChildren;
20
+ private getChevron;
21
+ private onNodeClick;
22
+ private onNodeToggle;
23
+ private onNodeCheck;
24
+ protected render(): TemplateResult<1>;
25
+ protected updated(): void;
26
+ }
@@ -1,28 +1,28 @@
1
- import { __decorate } from "tslib";
2
- import '@digital-realty/ix-icon-button/ix-icon-button.js';
3
- import '@digital-realty/ix-checkbox/ix-checkbox.js';
4
- import '@digital-realty/theme';
5
- import { html, LitElement, nothing } from 'lit';
6
- import { property, state } from 'lit/decorators.js';
7
- import { IxTreeStyles } from './ix-tree-styles.js';
8
- export class IxTreeNode extends LitElement {
9
- constructor() {
10
- super(...arguments);
11
- this.isActiveTreeNode = false;
12
- this.isExpanded = false;
13
- this.isSelected = false;
14
- this.level = 0;
15
- this.checkboxEnabled = false;
16
- this.appearance = 'default';
17
- this.hasIcon = false;
18
- this.removeChevron = false;
19
- this._hasScrolledToActive = false;
20
- }
21
- hasChildren() {
22
- return this.node.children !== undefined && this.node.children.length > 0;
23
- }
24
- getChevron() {
25
- const icon = this.isExpanded ? 'arrow_drop_down' : 'arrow_right';
1
+ import { __decorate } from "tslib";
2
+ import '@digital-realty/ix-icon-button/ix-icon-button.js';
3
+ import '@digital-realty/ix-checkbox/ix-checkbox.js';
4
+ import '@digital-realty/theme';
5
+ import { html, LitElement, nothing } from 'lit';
6
+ import { property, state } from 'lit/decorators.js';
7
+ import { IxTreeStyles } from './ix-tree-styles.js';
8
+ export class IxTreeNode extends LitElement {
9
+ constructor() {
10
+ super(...arguments);
11
+ this.isActiveTreeNode = false;
12
+ this.isExpanded = false;
13
+ this.isSelected = false;
14
+ this.level = 0;
15
+ this.checkboxEnabled = false;
16
+ this.appearance = 'default';
17
+ this.hasIcon = false;
18
+ this.removeChevron = false;
19
+ this._hasScrolledToActive = false;
20
+ }
21
+ hasChildren() {
22
+ return this.node.children !== undefined && this.node.children.length > 0;
23
+ }
24
+ getChevron() {
25
+ const icon = this.isExpanded ? 'arrow_drop_down' : 'arrow_right';
26
26
  return html `<div
27
27
  style=${`${this.hasChildren() ? '' : 'visibility:hidden'}`}
28
28
  >
@@ -33,57 +33,57 @@ export class IxTreeNode extends LitElement {
33
33
  test-id="tree-node-expand-toggle"
34
34
  >
35
35
  </ix-icon-button>
36
- </div>`;
37
- }
38
- onNodeClick(node) {
39
- const event = new CustomEvent('on-tree-node-click', {
40
- detail: {
41
- message: {
42
- node,
43
- id: node.id,
44
- label: node.label,
45
- parentId: node.parentId,
46
- },
47
- },
48
- });
49
- this.dispatchEvent(event);
50
- }
51
- onNodeToggle(node) {
52
- const event = new CustomEvent('on-tree-node-toggle', {
53
- detail: {
54
- message: {
55
- node,
56
- id: node.id,
57
- label: node.label,
58
- parentId: node.parentId,
59
- },
60
- },
61
- });
62
- this.dispatchEvent(event);
63
- }
64
- onNodeCheck(node) {
65
- /* eslint-disable no-param-reassign */
66
- if (node.checked) {
67
- node.checked = false;
68
- node.indeterminate = false;
69
- }
70
- else {
71
- node.checked = true;
72
- node.indeterminate = false;
73
- }
74
- const event = new CustomEvent('on-tree-node-check', {
75
- detail: {
76
- message: {
77
- node,
78
- id: node.id,
79
- },
80
- },
81
- });
82
- this.dispatchEvent(event);
83
- }
84
- render() {
85
- const selectedClass = this.isSelected ? 'selected' : '';
86
- const icon = this.node.icon ? this.node.icon : 'account_box';
36
+ </div>`;
37
+ }
38
+ onNodeClick(node) {
39
+ const event = new CustomEvent('on-tree-node-click', {
40
+ detail: {
41
+ message: {
42
+ node,
43
+ id: node.id,
44
+ label: node.label,
45
+ parentId: node.parentId,
46
+ },
47
+ },
48
+ });
49
+ this.dispatchEvent(event);
50
+ }
51
+ onNodeToggle(node) {
52
+ const event = new CustomEvent('on-tree-node-toggle', {
53
+ detail: {
54
+ message: {
55
+ node,
56
+ id: node.id,
57
+ label: node.label,
58
+ parentId: node.parentId,
59
+ },
60
+ },
61
+ });
62
+ this.dispatchEvent(event);
63
+ }
64
+ onNodeCheck(node) {
65
+ /* eslint-disable no-param-reassign */
66
+ if (node.checked) {
67
+ node.checked = false;
68
+ node.indeterminate = false;
69
+ }
70
+ else {
71
+ node.checked = true;
72
+ node.indeterminate = false;
73
+ }
74
+ const event = new CustomEvent('on-tree-node-check', {
75
+ detail: {
76
+ message: {
77
+ node,
78
+ id: node.id,
79
+ },
80
+ },
81
+ });
82
+ this.dispatchEvent(event);
83
+ }
84
+ render() {
85
+ const selectedClass = this.isSelected ? 'selected' : '';
86
+ const icon = this.node.icon ? this.node.icon : 'account_box';
87
87
  return html `<div
88
88
  ?active-tree-node=${this.isActiveTreeNode}
89
89
  aria-expanded=${!!this.node.expanded}
@@ -96,75 +96,75 @@ export class IxTreeNode extends LitElement {
96
96
  style="padding-left: calc(var(--_tree-icon-size) * ${this.level})"
97
97
  >
98
98
  ${!this.removeChevron ? this.getChevron() : nothing}
99
- ${this.checkboxEnabled
99
+ ${this.checkboxEnabled
100
100
  ? html `<ix-checkbox
101
101
  @click=${() => this.onNodeCheck(this.node)}
102
102
  label=""
103
103
  class="item-checkbox"
104
104
  .checked=${this.node.checked}
105
105
  .indeterminate=${this.node.indeterminate}
106
- ></ix-checkbox>`
106
+ ></ix-checkbox>`
107
107
  : nothing}
108
- ${this.hasIcon
109
- ? html `<ix-icon class="icon">${icon}</ix-icon>`
108
+ ${this.hasIcon
109
+ ? html `<ix-icon class="icon">${icon}</ix-icon>`
110
110
  : nothing}
111
111
  <div
112
112
  class="label"
113
- @click=${() => {
114
- this.checkboxEnabled
115
- ? this.onNodeToggle(this.node)
116
- : this.onNodeClick(this.node);
113
+ @click=${() => {
114
+ this.checkboxEnabled
115
+ ? this.onNodeToggle(this.node)
116
+ : this.onNodeClick(this.node);
117
117
  }}
118
- @keyup=${() => {
119
- this.checkboxEnabled
120
- ? this.onNodeToggle(this.node)
121
- : this.onNodeClick(this.node);
118
+ @keyup=${() => {
119
+ this.checkboxEnabled
120
+ ? this.onNodeToggle(this.node)
121
+ : this.onNodeClick(this.node);
122
122
  }}
123
123
  >
124
124
  ${this.node.label}
125
125
  </div>
126
126
  </div>
127
127
  <slot></slot>
128
- </div>`;
129
- }
130
- updated() {
131
- var _a;
132
- if (!this._hasScrolledToActive) {
133
- const el = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('[active-tree-node]');
134
- el === null || el === void 0 ? void 0 : el.scrollIntoView({ behavior: 'smooth', block: 'start' });
135
- this._hasScrolledToActive = true;
136
- }
137
- }
138
- }
139
- IxTreeNode.styles = [IxTreeStyles];
140
- __decorate([
141
- property({ type: Boolean })
142
- ], IxTreeNode.prototype, "isActiveTreeNode", void 0);
143
- __decorate([
144
- property({ type: Boolean })
145
- ], IxTreeNode.prototype, "isExpanded", void 0);
146
- __decorate([
147
- property({ type: Boolean })
148
- ], IxTreeNode.prototype, "isSelected", void 0);
149
- __decorate([
150
- property({ type: Number })
151
- ], IxTreeNode.prototype, "level", void 0);
152
- __decorate([
153
- property({ type: Object })
154
- ], IxTreeNode.prototype, "node", void 0);
155
- __decorate([
156
- property({ type: Boolean })
157
- ], IxTreeNode.prototype, "checkboxEnabled", void 0);
158
- __decorate([
159
- property({ type: String })
160
- ], IxTreeNode.prototype, "appearance", void 0);
161
- __decorate([
162
- property({ type: Boolean })
163
- ], IxTreeNode.prototype, "hasIcon", void 0);
164
- __decorate([
165
- property({ type: Boolean })
166
- ], IxTreeNode.prototype, "removeChevron", void 0);
167
- __decorate([
168
- state()
169
- ], IxTreeNode.prototype, "_hasScrolledToActive", void 0);
128
+ </div>`;
129
+ }
130
+ updated() {
131
+ var _a;
132
+ if (!this._hasScrolledToActive) {
133
+ const el = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('[active-tree-node]');
134
+ el === null || el === void 0 ? void 0 : el.scrollIntoView({ behavior: 'smooth', block: 'start' });
135
+ this._hasScrolledToActive = true;
136
+ }
137
+ }
138
+ }
139
+ IxTreeNode.styles = [IxTreeStyles];
140
+ __decorate([
141
+ property({ type: Boolean })
142
+ ], IxTreeNode.prototype, "isActiveTreeNode", void 0);
143
+ __decorate([
144
+ property({ type: Boolean })
145
+ ], IxTreeNode.prototype, "isExpanded", void 0);
146
+ __decorate([
147
+ property({ type: Boolean })
148
+ ], IxTreeNode.prototype, "isSelected", void 0);
149
+ __decorate([
150
+ property({ type: Number })
151
+ ], IxTreeNode.prototype, "level", void 0);
152
+ __decorate([
153
+ property({ type: Object })
154
+ ], IxTreeNode.prototype, "node", void 0);
155
+ __decorate([
156
+ property({ type: Boolean })
157
+ ], IxTreeNode.prototype, "checkboxEnabled", void 0);
158
+ __decorate([
159
+ property({ type: String })
160
+ ], IxTreeNode.prototype, "appearance", void 0);
161
+ __decorate([
162
+ property({ type: Boolean })
163
+ ], IxTreeNode.prototype, "hasIcon", void 0);
164
+ __decorate([
165
+ property({ type: Boolean })
166
+ ], IxTreeNode.prototype, "removeChevron", void 0);
167
+ __decorate([
168
+ state()
169
+ ], IxTreeNode.prototype, "_hasScrolledToActive", void 0);
170
170
  //# sourceMappingURL=IxTreeNode.js.map
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { IxTree } from './IxTree.js';
2
- export { IxTreeNode } from './IxTreeNode.js';
3
- export { IIxTreeNode } from './IIxTreeNode.js';
1
+ export { IxTree } from './IxTree.js';
2
+ export { IxTreeNode } from './IxTreeNode.js';
3
+ export { IIxTreeNode } from './IIxTreeNode.js';
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export { IxTree } from './IxTree.js';
2
- export { IxTreeNode } from './IxTreeNode.js';
1
+ export { IxTree } from './IxTree.js';
2
+ export { IxTreeNode } from './IxTreeNode.js';
3
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1,3 +1,3 @@
1
- import { IxTreeNode } from './IxTreeNode.js';
2
- customElements.define('ix-tree-node', IxTreeNode);
1
+ import { IxTreeNode } from './IxTreeNode.js';
2
+ customElements.define('ix-tree-node', IxTreeNode);
3
3
  //# sourceMappingURL=ix-tree-node.js.map
@@ -1 +1 @@
1
- export declare const IxTreeStyles: import("lit").CSSResult;
1
+ export declare const IxTreeStyles: import("lit").CSSResult;
@@ -1,4 +1,4 @@
1
- import { css } from 'lit';
1
+ import { css } from 'lit';
2
2
  export const IxTreeStyles = css `
3
3
  :root,
4
4
  :host :root,
@@ -41,5 +41,5 @@ export const IxTreeStyles = css `
41
41
  border-left: 3px solid
42
42
  var(--ix-tree-active-border-color, var(--md-sys-color-primary));
43
43
  }
44
- `;
44
+ `;
45
45
  //# sourceMappingURL=ix-tree-styles.js.map
package/dist/ix-tree.d.ts CHANGED
@@ -1 +1 @@
1
- export {};
1
+ export {};
package/dist/ix-tree.js CHANGED
@@ -1,3 +1,3 @@
1
- import { IxTree } from './IxTree.js';
2
- customElements.define('ix-tree', IxTree);
1
+ import { IxTree } from './IxTree.js';
2
+ customElements.define('ix-tree', IxTree);
3
3
  //# sourceMappingURL=ix-tree.js.map
@@ -1,3 +1,3 @@
1
- import { IIxTreeNode } from './IIxTreeNode.js';
2
- export declare function findChildNodeById(node: IIxTreeNode, id: string): IIxTreeNode | null;
3
- export declare function updateNodeCheckedStatus(node: IIxTreeNode, rootNode: IIxTreeNode): void;
1
+ import { IIxTreeNode } from './IIxTreeNode.js';
2
+ export declare function findChildNodeById(node: IIxTreeNode, id: string): IIxTreeNode | null;
3
+ export declare function updateNodeCheckedStatus(node: IIxTreeNode, rootNode: IIxTreeNode): void;
@@ -1,56 +1,56 @@
1
- export function findChildNodeById(node, id) {
2
- if (node.id === id) {
3
- return node;
4
- }
5
- if (!node.children) {
6
- return null;
7
- }
8
- for (const childNode of node.children) {
9
- const foundNode = findChildNodeById(childNode, id);
10
- if (foundNode) {
11
- return foundNode;
12
- }
13
- }
14
- return null;
15
- }
16
- export function updateNodeCheckedStatus(node, rootNode) {
17
- /* eslint-disable no-param-reassign */
18
- function updateChildren(n, checked = false) {
19
- n.checked = checked;
20
- n.indeterminate = false;
21
- if (n.children) {
22
- n.children.forEach(child => {
23
- updateChildren(child, checked);
24
- });
25
- }
26
- }
27
- function updateParents(n) {
28
- if (n.parentId) {
29
- const currentParent = findChildNodeById(rootNode, n.parentId);
30
- if (currentParent && currentParent.children) {
31
- if (currentParent.children.every(child => child.checked)) {
32
- currentParent.checked = true;
33
- currentParent.indeterminate = false;
34
- }
35
- else if (currentParent.children.some(child => child.checked)) {
36
- currentParent.checked = false;
37
- currentParent.indeterminate = true;
38
- }
39
- else if (currentParent.children.some(c => c.indeterminate)) {
40
- currentParent.checked = false;
41
- currentParent.indeterminate = true;
42
- }
43
- else {
44
- currentParent.checked = false;
45
- currentParent.indeterminate = false;
46
- }
47
- updateParents(currentParent);
48
- }
49
- }
50
- }
51
- // update all children to match current node checked status
52
- updateChildren(node, node.checked);
53
- // update all parents checked and indeterminate status
54
- updateParents(node);
55
- }
1
+ export function findChildNodeById(node, id) {
2
+ if (node.id === id) {
3
+ return node;
4
+ }
5
+ if (!node.children) {
6
+ return null;
7
+ }
8
+ for (const childNode of node.children) {
9
+ const foundNode = findChildNodeById(childNode, id);
10
+ if (foundNode) {
11
+ return foundNode;
12
+ }
13
+ }
14
+ return null;
15
+ }
16
+ export function updateNodeCheckedStatus(node, rootNode) {
17
+ /* eslint-disable no-param-reassign */
18
+ function updateChildren(n, checked = false) {
19
+ n.checked = checked;
20
+ n.indeterminate = false;
21
+ if (n.children) {
22
+ n.children.forEach(child => {
23
+ updateChildren(child, checked);
24
+ });
25
+ }
26
+ }
27
+ function updateParents(n) {
28
+ if (n.parentId) {
29
+ const currentParent = findChildNodeById(rootNode, n.parentId);
30
+ if (currentParent && currentParent.children) {
31
+ if (currentParent.children.every(child => child.checked)) {
32
+ currentParent.checked = true;
33
+ currentParent.indeterminate = false;
34
+ }
35
+ else if (currentParent.children.some(child => child.checked)) {
36
+ currentParent.checked = false;
37
+ currentParent.indeterminate = true;
38
+ }
39
+ else if (currentParent.children.some(c => c.indeterminate)) {
40
+ currentParent.checked = false;
41
+ currentParent.indeterminate = true;
42
+ }
43
+ else {
44
+ currentParent.checked = false;
45
+ currentParent.indeterminate = false;
46
+ }
47
+ updateParents(currentParent);
48
+ }
49
+ }
50
+ }
51
+ // update all children to match current node checked status
52
+ updateChildren(node, node.checked);
53
+ // update all parents checked and indeterminate status
54
+ updateParents(node);
55
+ }
56
56
  //# sourceMappingURL=tree-utils.js.map
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Webcomponent ix-tree following open-wc recommendations",
4
4
  "license": "MIT",
5
5
  "author": "Digital Realty",
6
- "version": "3.0.10",
6
+ "version": "3.1.2-alpha-NJEN.1",
7
7
  "type": "module",
8
8
  "main": "dist/index.js",
9
9
  "module": "dist/index.js",
@@ -27,13 +27,13 @@
27
27
  "test:watch": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wtr --watch\""
28
28
  },
29
29
  "dependencies": {
30
- "@digital-realty/ix-checkbox": "^1.1.27",
31
- "@digital-realty/ix-icon": "^1.0.37",
32
- "@digital-realty/ix-icon-button": "^1.0.41",
30
+ "@digital-realty/ix-checkbox": "^1.2.2-alpha-NJEN.1",
31
+ "@digital-realty/ix-icon": "^1.1.2-alpha-NJEN.1",
32
+ "@digital-realty/ix-icon-button": "^1.1.2-alpha-NJEN.1",
33
33
  "@digital-realty/theme": "^1.0.30",
34
34
  "@lit-labs/react": "^2.1.0",
35
35
  "@material/web": "1.2.0",
36
- "lit": "^2.0.2",
36
+ "lit": "^2.8.0 || ^3.0.0",
37
37
  "react": "^18.2.0"
38
38
  },
39
39
  "devDependencies": {
@@ -103,5 +103,5 @@
103
103
  "README.md",
104
104
  "LICENSE"
105
105
  ],
106
- "gitHead": "705b8d4a1375a3ce54b1562c65d8636b98b14466"
106
+ "gitHead": "36ec59c8921745261d39d5865fb4bd1a6b97ae46"
107
107
  }