@haiyue/ui 0.1.0 → 0.1.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 +1 -1
- package/README.md +166 -2
- package/dist/border-beam.d.ts +26 -0
- package/dist/border-beam.js +172 -0
- package/dist/button.d.ts +10 -0
- package/dist/button.js +85 -0
- package/dist/checkbox.d.ts +2 -2
- package/dist/checkbox.js +11 -11
- package/dist/context-menu.d.ts +6 -6
- package/dist/context-menu.js +11 -9
- package/dist/dialog.d.ts +5 -5
- package/dist/dialog.js +18 -18
- package/dist/drawer.d.ts +49 -0
- package/dist/drawer.js +377 -0
- package/dist/dropdown.d.ts +9 -9
- package/dist/dropdown.js +9 -9
- package/dist/history-controls.d.ts +40 -0
- package/dist/history-controls.js +123 -0
- package/dist/index.d.ts +34 -31
- package/dist/index.js +32 -85
- package/dist/input.d.ts +5 -5
- package/dist/input.js +13 -13
- package/dist/menu-shared.d.ts +4 -4
- package/dist/menu-shared.js +4 -4
- package/dist/notification.d.ts +55 -0
- package/dist/notification.js +357 -0
- package/dist/radio.d.ts +2 -2
- package/dist/radio.js +12 -12
- package/dist/range.d.ts +74 -0
- package/dist/range.js +393 -0
- package/dist/select.d.ts +6 -6
- package/dist/select.js +20 -20
- package/dist/split.d.ts +6 -6
- package/dist/split.js +14 -14
- package/dist/tabs.d.ts +6 -6
- package/dist/tabs.js +14 -14
- package/dist/tooltip.d.ts +4 -4
- package/dist/tooltip.js +9 -9
- package/dist/tree-model.d.ts +15 -7
- package/dist/tree-model.js +93 -80
- package/dist/tree-node.d.ts +3 -3
- package/dist/tree-node.js +3 -3
- package/dist/tree-types.d.ts +14 -14
- package/dist/tree.d.ts +9 -7
- package/dist/tree.js +68 -66
- package/dist/virtual-list.d.ts +61 -0
- package/dist/virtual-list.js +322 -0
- package/package.json +87 -11
- package/themes/haiyue-dark.css +46 -0
- package/themes/haiyue-light.css +46 -0
- package/src/checkbox.ts +0 -215
- package/src/context-menu.ts +0 -248
- package/src/dialog.ts +0 -195
- package/src/dropdown.ts +0 -249
- package/src/index.ts +0 -192
- package/src/input.ts +0 -150
- package/src/menu-shared.ts +0 -65
- package/src/radio.ts +0 -216
- package/src/select.ts +0 -271
- package/src/split.ts +0 -306
- package/src/tabs.ts +0 -182
- package/src/tooltip.ts +0 -321
- package/src/tree-model.ts +0 -305
- package/src/tree-node.ts +0 -67
- package/src/tree-types.ts +0 -47
- package/src/tree.ts +0 -1002
package/dist/tabs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export class
|
|
1
|
+
export class HYTabs extends HTMLElement {
|
|
2
2
|
_style = document.createElement('style');
|
|
3
3
|
_tabs = document.createElement('div');
|
|
4
4
|
_panels = document.createElement('div');
|
|
@@ -18,8 +18,8 @@ export class GETabs extends HTMLElement {
|
|
|
18
18
|
height: 100%;
|
|
19
19
|
min-width: 0;
|
|
20
20
|
min-height: 0;
|
|
21
|
-
color: var(--
|
|
22
|
-
background: var(--
|
|
21
|
+
color: var(--hy-text-color, #d8e2f2);
|
|
22
|
+
background: var(--hy-panel-bg-color, #171d28);
|
|
23
23
|
font: 12px system-ui, sans-serif;
|
|
24
24
|
}
|
|
25
25
|
.tabs {
|
|
@@ -28,8 +28,8 @@ export class GETabs extends HTMLElement {
|
|
|
28
28
|
gap: 2px;
|
|
29
29
|
min-width: 0;
|
|
30
30
|
padding: 4px 6px 0;
|
|
31
|
-
border-bottom: 1px solid var(--
|
|
32
|
-
background: var(--
|
|
31
|
+
border-bottom: 1px solid var(--hy-border-color, #303746);
|
|
32
|
+
background: var(--hy-tabs-bar-bg-color, var(--hy-menu-bg-color, var(--hy-surface-elevated-color, #1b2230)));
|
|
33
33
|
}
|
|
34
34
|
button {
|
|
35
35
|
height: 28px;
|
|
@@ -38,19 +38,19 @@ export class GETabs extends HTMLElement {
|
|
|
38
38
|
border: 1px solid transparent;
|
|
39
39
|
border-bottom: 0;
|
|
40
40
|
border-radius: 4px 4px 0 0;
|
|
41
|
-
color: var(--
|
|
41
|
+
color: var(--hy-secondary-text-color, #8fa7c8);
|
|
42
42
|
background: transparent;
|
|
43
43
|
font: inherit;
|
|
44
44
|
cursor: pointer;
|
|
45
45
|
}
|
|
46
46
|
button:hover {
|
|
47
|
-
color: var(--
|
|
48
|
-
background: var(--
|
|
47
|
+
color: var(--hy-text-color, #d8e2f2);
|
|
48
|
+
background: var(--hy-hover-bg-color, #222b3a);
|
|
49
49
|
}
|
|
50
50
|
button.active {
|
|
51
|
-
color: var(--
|
|
52
|
-
border-color: var(--
|
|
53
|
-
background: var(--
|
|
51
|
+
color: var(--hy-active-text-color, #eef3ff);
|
|
52
|
+
border-color: var(--hy-border-color, #303746);
|
|
53
|
+
background: var(--hy-panel-bg-color, #171d28);
|
|
54
54
|
}
|
|
55
55
|
button:disabled {
|
|
56
56
|
opacity: 0.45;
|
|
@@ -121,7 +121,7 @@ export class GETabs extends HTMLElement {
|
|
|
121
121
|
: [];
|
|
122
122
|
}
|
|
123
123
|
catch (error) {
|
|
124
|
-
console.warn('Invalid
|
|
124
|
+
console.warn('Invalid hy-tabs options attribute.', error);
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
_render() {
|
|
@@ -154,8 +154,8 @@ export class GETabs extends HTMLElement {
|
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
export function defineTabsComponents() {
|
|
157
|
-
if (!customElements.get('
|
|
158
|
-
customElements.define('
|
|
157
|
+
if (!customElements.get('hy-tabs')) {
|
|
158
|
+
customElements.define('hy-tabs', HYTabs);
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
//# sourceMappingURL=tabs.js.map
|
package/dist/tooltip.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export type
|
|
2
|
-
export declare class
|
|
1
|
+
export type HYTooltipPlacement = 'top' | 'topLeft' | 'topRight' | 'bottom' | 'bottomLeft' | 'bottomRight' | 'left' | 'leftTop' | 'leftBottom' | 'right' | 'rightTop' | 'rightBottom';
|
|
2
|
+
export declare class HYTooltip extends HTMLElement {
|
|
3
3
|
private readonly _root;
|
|
4
4
|
private readonly _style;
|
|
5
5
|
private readonly _slot;
|
|
@@ -15,8 +15,8 @@ export declare class GETooltip extends HTMLElement {
|
|
|
15
15
|
attributeChangedCallback(name: string): void;
|
|
16
16
|
get label(): string;
|
|
17
17
|
set label(value: string);
|
|
18
|
-
get placement():
|
|
19
|
-
set placement(value:
|
|
18
|
+
get placement(): HYTooltipPlacement;
|
|
19
|
+
set placement(value: HYTooltipPlacement);
|
|
20
20
|
get delay(): number;
|
|
21
21
|
set delay(value: number);
|
|
22
22
|
get arrow(): boolean;
|
package/dist/tooltip.js
CHANGED
|
@@ -17,7 +17,7 @@ const TOOLTIP_PLACEMENTS = new Set([
|
|
|
17
17
|
'rightTop',
|
|
18
18
|
'rightBottom',
|
|
19
19
|
]);
|
|
20
|
-
export class
|
|
20
|
+
export class HYTooltip extends HTMLElement {
|
|
21
21
|
_root;
|
|
22
22
|
_style = document.createElement('style');
|
|
23
23
|
_slot = document.createElement('slot');
|
|
@@ -45,10 +45,10 @@ export class GETooltip extends HTMLElement {
|
|
|
45
45
|
max-width: min(280px, calc(100vw - 16px));
|
|
46
46
|
padding: 5px 8px;
|
|
47
47
|
border-radius: 4px;
|
|
48
|
-
color: var(--
|
|
49
|
-
background: var(--
|
|
50
|
-
border: 1px solid var(--
|
|
51
|
-
box-shadow: 0 8px 24px var(--
|
|
48
|
+
color: var(--hy-tooltip-text-color, #f4f7fb);
|
|
49
|
+
background: var(--hy-tooltip-bg-color, #0f141c);
|
|
50
|
+
border: 1px solid var(--hy-tooltip-border-color, rgba(255, 255, 255, 0.08));
|
|
51
|
+
box-shadow: 0 8px 24px var(--hy-tooltip-shadow-color, rgba(0, 0, 0, 0.35));
|
|
52
52
|
font: 12px system-ui, sans-serif;
|
|
53
53
|
line-height: 1.35;
|
|
54
54
|
width: max-content;
|
|
@@ -63,8 +63,8 @@ export class GETooltip extends HTMLElement {
|
|
|
63
63
|
position: absolute;
|
|
64
64
|
width: ${ARROW_SIZE}px;
|
|
65
65
|
height: ${ARROW_SIZE}px;
|
|
66
|
-
background: var(--
|
|
67
|
-
border: solid var(--
|
|
66
|
+
background: var(--hy-tooltip-bg-color, #0f141c);
|
|
67
|
+
border: solid var(--hy-tooltip-border-color, rgba(255, 255, 255, 0.08));
|
|
68
68
|
border-width: 0 1px 1px 0;
|
|
69
69
|
transform: rotate(45deg);
|
|
70
70
|
}
|
|
@@ -279,8 +279,8 @@ function getAlignedLeft(hostRect, tooltipRect, placement) {
|
|
|
279
279
|
return hostRect.left + (hostRect.width - tooltipRect.width) / 2;
|
|
280
280
|
}
|
|
281
281
|
export function defineTooltipComponents() {
|
|
282
|
-
if (!customElements.get('
|
|
283
|
-
customElements.define('
|
|
282
|
+
if (!customElements.get('hy-tooltip')) {
|
|
283
|
+
customElements.define('hy-tooltip', HYTooltip);
|
|
284
284
|
}
|
|
285
285
|
}
|
|
286
286
|
//# sourceMappingURL=tooltip.js.map
|
package/dist/tree-model.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { FlatTreeNode,
|
|
2
|
-
/** Mutable hierarchy model owned by
|
|
3
|
-
export declare class
|
|
1
|
+
import type { FlatTreeNode, HYTreeDropPosition, HYTreeNodeData, IndexedTreeNode } from './tree-types.js';
|
|
2
|
+
/** Mutable hierarchy model owned by hy-tree. It has no DOM dependency and is safe to unit test. */
|
|
3
|
+
export declare class HYTreeModel {
|
|
4
4
|
private _data;
|
|
5
5
|
private readonly _expandedIds;
|
|
6
6
|
private readonly _nodeIndex;
|
|
@@ -13,21 +13,29 @@ export declare class GETreeModel {
|
|
|
13
13
|
get index(): ReadonlyMap<string, IndexedTreeNode>;
|
|
14
14
|
get visibleIndex(): ReadonlyMap<string, number>;
|
|
15
15
|
get isVisibilityDirty(): boolean;
|
|
16
|
-
setData(data:
|
|
16
|
+
setData(data: HYTreeNodeData[]): void;
|
|
17
17
|
invalidateVisibility(): void;
|
|
18
18
|
getVisibleNodes(): readonly FlatTreeNode[];
|
|
19
19
|
getVisibleIds(): readonly string[];
|
|
20
20
|
getIndexedNode(id: string): IndexedTreeNode | null;
|
|
21
21
|
findNode(id: string): {
|
|
22
|
-
node:
|
|
23
|
-
parent:
|
|
22
|
+
node: HYTreeNodeData;
|
|
23
|
+
parent: HYTreeNodeData | null;
|
|
24
24
|
} | null;
|
|
25
25
|
topLevelSelection(ids: Iterable<string>): string[];
|
|
26
26
|
removeNode(id: string): boolean;
|
|
27
|
-
moveNode(sourceId: string, targetId: string, position:
|
|
27
|
+
moveNode(sourceId: string, targetId: string, position: HYTreeDropPosition): boolean;
|
|
28
|
+
private _createMovePlan;
|
|
29
|
+
private _visibleRange;
|
|
30
|
+
private _resolveMoveDestination;
|
|
31
|
+
private _refreshMovedSubtree;
|
|
28
32
|
private _refreshSiblingIndexes;
|
|
29
33
|
private _refreshSubtreeIndex;
|
|
30
34
|
private _moveVisibleSubtree;
|
|
35
|
+
private _removeVisibleRange;
|
|
36
|
+
private _insertExpandedChildren;
|
|
37
|
+
private _resolveVisibleInsertAt;
|
|
38
|
+
private _insertVisibleSubtrees;
|
|
31
39
|
private _collectVisibleSubtree;
|
|
32
40
|
private _visibleSubtreeEnd;
|
|
33
41
|
private _refreshVisibleIndexes;
|
package/dist/tree-model.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/** Mutable hierarchy model owned by
|
|
2
|
-
export class
|
|
1
|
+
/** Mutable hierarchy model owned by hy-tree. It has no DOM dependency and is safe to unit test. */
|
|
2
|
+
export class HYTreeModel {
|
|
3
3
|
_data = [];
|
|
4
4
|
_expandedIds;
|
|
5
5
|
_nodeIndex = new Map();
|
|
@@ -87,58 +87,74 @@ export class GETreeModel {
|
|
|
87
87
|
moveNode(sourceId, targetId, position) {
|
|
88
88
|
this._ensureIndex();
|
|
89
89
|
this.getVisibleNodes();
|
|
90
|
+
const plan = this._createMovePlan(sourceId, targetId);
|
|
91
|
+
if (!plan)
|
|
92
|
+
return false;
|
|
93
|
+
const destination = this._resolveMoveDestination(plan, position);
|
|
94
|
+
if (!destination)
|
|
95
|
+
return false;
|
|
96
|
+
plan.sourceList.splice(plan.sourceIndex, 1);
|
|
97
|
+
destination.targetList.splice(destination.insertIndex, 0, plan.source.node);
|
|
98
|
+
this._refreshSiblingIndexes(plan.sourceList);
|
|
99
|
+
if (destination.targetList !== plan.sourceList)
|
|
100
|
+
this._refreshSiblingIndexes(destination.targetList);
|
|
101
|
+
this._refreshMovedSubtree(plan.source.node, destination.nextParent);
|
|
102
|
+
this._moveVisibleSubtree(plan.source.node, plan.start, plan.count, destination.nextParent, destination.expandedNextParent);
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
_createMovePlan(sourceId, targetId) {
|
|
90
106
|
const source = this._nodeIndex.get(sourceId);
|
|
91
107
|
const target = this._nodeIndex.get(targetId);
|
|
92
108
|
if (!source || !target || sourceId === targetId)
|
|
93
|
-
return
|
|
109
|
+
return null;
|
|
94
110
|
if (target.ancestorIds.includes(sourceId))
|
|
95
|
-
return
|
|
111
|
+
return null;
|
|
96
112
|
const sourceList = source.parent?.children ?? this._data;
|
|
97
113
|
const sourceIndex = source.index;
|
|
98
114
|
if (sourceIndex < 0)
|
|
99
|
-
return
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
115
|
+
return null;
|
|
116
|
+
return { source, target, sourceList, sourceIndex, ...this._visibleRange(source) };
|
|
117
|
+
}
|
|
118
|
+
_visibleRange(source) {
|
|
119
|
+
const start = this._visibleIndex.get(source.node.id) ?? -1;
|
|
120
|
+
if (start < 0)
|
|
121
|
+
return { start, count: 0 };
|
|
122
|
+
let count = 1;
|
|
123
|
+
while (start + count < this._visibleNodes.length
|
|
124
|
+
&& (this._visibleNodes[start + count]?.depth ?? -1) > source.depth) {
|
|
125
|
+
count++;
|
|
109
126
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
let insertIndex;
|
|
114
|
-
let expandedNextParent = false;
|
|
127
|
+
return { start, count };
|
|
128
|
+
}
|
|
129
|
+
_resolveMoveDestination(plan, position) {
|
|
115
130
|
if (position === 'inside') {
|
|
116
|
-
target.node.children ??= [];
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
131
|
+
plan.target.node.children ??= [];
|
|
132
|
+
const expandedNextParent = !this._expandedIds.has(plan.target.node.id);
|
|
133
|
+
this._expandedIds.add(plan.target.node.id);
|
|
134
|
+
return {
|
|
135
|
+
nextParent: plan.target.node,
|
|
136
|
+
targetList: plan.target.node.children,
|
|
137
|
+
insertIndex: plan.target.node.children.length,
|
|
138
|
+
expandedNextParent,
|
|
139
|
+
};
|
|
122
140
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
141
|
+
const targetList = plan.target.parent?.children ?? this._data;
|
|
142
|
+
let targetIndex = plan.target.index;
|
|
143
|
+
if (plan.sourceList === targetList && plan.sourceIndex < targetIndex)
|
|
144
|
+
targetIndex--;
|
|
145
|
+
if (targetIndex < 0)
|
|
146
|
+
return null;
|
|
147
|
+
return {
|
|
148
|
+
nextParent: plan.target.parent,
|
|
149
|
+
targetList,
|
|
150
|
+
insertIndex: position === 'before' ? targetIndex : targetIndex + 1,
|
|
151
|
+
expandedNextParent: false,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
_refreshMovedSubtree(source, nextParent) {
|
|
137
155
|
const parentIndex = nextParent ? this._nodeIndex.get(nextParent.id) : null;
|
|
138
|
-
const ancestorIds = parentIndex ? [...parentIndex.ancestorIds, nextParent.id] : [];
|
|
139
|
-
this._refreshSubtreeIndex(source
|
|
140
|
-
this._moveVisibleSubtree(source.node, visibleStart, visibleCount, nextParent, expandedNextParent);
|
|
141
|
-
return true;
|
|
156
|
+
const ancestorIds = parentIndex && nextParent ? [...parentIndex.ancestorIds, nextParent.id] : [];
|
|
157
|
+
this._refreshSubtreeIndex(source, nextParent, parentIndex ? parentIndex.depth + 1 : 0, ancestorIds);
|
|
142
158
|
}
|
|
143
159
|
_refreshSiblingIndexes(nodes) {
|
|
144
160
|
for (let index = 0; index < nodes.length; index++) {
|
|
@@ -167,49 +183,46 @@ export class GETreeModel {
|
|
|
167
183
|
}
|
|
168
184
|
}
|
|
169
185
|
_moveVisibleSubtree(source, previousStart, previousCount, nextParent, expandedNextParent) {
|
|
170
|
-
|
|
171
|
-
this._visibleNodes.splice(previousStart, previousCount);
|
|
172
|
-
this._visibleIds.splice(previousStart, previousCount);
|
|
173
|
-
this._refreshVisibleIndexes(previousStart);
|
|
174
|
-
}
|
|
186
|
+
this._removeVisibleRange(previousStart, previousCount);
|
|
175
187
|
if (expandedNextParent && nextParent) {
|
|
176
|
-
|
|
177
|
-
if (parentVisible === undefined)
|
|
178
|
-
return;
|
|
179
|
-
const expandedChildren = [];
|
|
180
|
-
for (const child of nextParent.children ?? []) {
|
|
181
|
-
this._collectVisibleSubtree(child, expandedChildren);
|
|
182
|
-
}
|
|
183
|
-
if (expandedChildren.length === 0)
|
|
184
|
-
return;
|
|
185
|
-
const insertAt = parentVisible + 1;
|
|
186
|
-
this._visibleNodes.splice(insertAt, 0, ...expandedChildren);
|
|
187
|
-
this._visibleIds.splice(insertAt, 0, ...expandedChildren.map(item => item.node.id));
|
|
188
|
-
this._refreshVisibleIndexes(insertAt);
|
|
188
|
+
this._insertExpandedChildren(nextParent);
|
|
189
189
|
return;
|
|
190
190
|
}
|
|
191
|
-
|
|
191
|
+
const insertAt = this._resolveVisibleInsertAt(source, nextParent);
|
|
192
|
+
if (insertAt >= 0)
|
|
193
|
+
this._insertVisibleSubtrees(insertAt, [source]);
|
|
194
|
+
}
|
|
195
|
+
_removeVisibleRange(start, count) {
|
|
196
|
+
if (start < 0 || count <= 0)
|
|
197
|
+
return;
|
|
198
|
+
this._visibleNodes.splice(start, count);
|
|
199
|
+
this._visibleIds.splice(start, count);
|
|
200
|
+
this._refreshVisibleIndexes(start);
|
|
201
|
+
}
|
|
202
|
+
_insertExpandedChildren(parent) {
|
|
203
|
+
const parentVisible = this._visibleIndex.get(parent.id);
|
|
204
|
+
if (parentVisible === undefined)
|
|
205
|
+
return;
|
|
206
|
+
this._insertVisibleSubtrees(parentVisible + 1, parent.children ?? []);
|
|
207
|
+
}
|
|
208
|
+
_resolveVisibleInsertAt(source, nextParent) {
|
|
192
209
|
const sourceIndex = this._nodeIndex.get(source.id)?.index ?? -1;
|
|
210
|
+
if (sourceIndex < 0)
|
|
211
|
+
return -1;
|
|
193
212
|
const siblings = nextParent?.children ?? this._data;
|
|
194
|
-
if (
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
insertAt = sourceIndex === 0
|
|
205
|
-
? 0
|
|
206
|
-
: this._visibleSubtreeEnd(siblings[sourceIndex - 1]?.id);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
if (insertAt < 0)
|
|
210
|
-
return;
|
|
213
|
+
if (!nextParent)
|
|
214
|
+
return sourceIndex === 0 ? 0 : this._visibleSubtreeEnd(siblings[sourceIndex - 1]?.id);
|
|
215
|
+
const parentVisible = this._visibleIndex.get(nextParent.id);
|
|
216
|
+
if (parentVisible === undefined || !this._expandedIds.has(nextParent.id))
|
|
217
|
+
return -1;
|
|
218
|
+
return sourceIndex === 0
|
|
219
|
+
? parentVisible + 1
|
|
220
|
+
: this._visibleSubtreeEnd(siblings[sourceIndex - 1]?.id);
|
|
221
|
+
}
|
|
222
|
+
_insertVisibleSubtrees(insertAt, roots) {
|
|
211
223
|
const moved = [];
|
|
212
|
-
|
|
224
|
+
for (const root of roots)
|
|
225
|
+
this._collectVisibleSubtree(root, moved);
|
|
213
226
|
if (moved.length === 0)
|
|
214
227
|
return;
|
|
215
228
|
this._visibleNodes.splice(insertAt, 0, ...moved);
|
package/dist/tree-node.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare class
|
|
1
|
+
import type { HYTreeNodeData } from './tree-types.js';
|
|
2
|
+
export declare class HYTreeNode extends HTMLElement {
|
|
3
3
|
private readonly _icon;
|
|
4
4
|
private readonly _label;
|
|
5
5
|
static get observedAttributes(): string[];
|
|
6
6
|
constructor();
|
|
7
7
|
connectedCallback(): void;
|
|
8
8
|
attributeChangedCallback(): void;
|
|
9
|
-
set node(value:
|
|
9
|
+
set node(value: HYTreeNodeData);
|
|
10
10
|
private _sync;
|
|
11
11
|
}
|
package/dist/tree-node.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export class
|
|
1
|
+
export class HYTreeNode extends HTMLElement {
|
|
2
2
|
_icon = document.createElement('span');
|
|
3
3
|
_label = document.createElement('span');
|
|
4
4
|
static get observedAttributes() {
|
|
@@ -22,7 +22,7 @@ export class GETreeNode extends HTMLElement {
|
|
|
22
22
|
flex: 0 0 16px;
|
|
23
23
|
display: inline-grid;
|
|
24
24
|
place-items: center;
|
|
25
|
-
color: var(--
|
|
25
|
+
color: var(--hy-tree-icon-color, var(--hy-secondary-text-color, #8fa7c8));
|
|
26
26
|
font-size: 12px;
|
|
27
27
|
}
|
|
28
28
|
.label {
|
|
@@ -32,7 +32,7 @@ export class GETreeNode extends HTMLElement {
|
|
|
32
32
|
white-space: nowrap;
|
|
33
33
|
}
|
|
34
34
|
:host([selected]) .label {
|
|
35
|
-
color: var(--
|
|
35
|
+
color: var(--hy-selected-text-color, #ffffff);
|
|
36
36
|
}
|
|
37
37
|
`;
|
|
38
38
|
this._icon.className = 'icon';
|
package/dist/tree-types.d.ts
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface HYTreeNodeData {
|
|
2
2
|
id: string;
|
|
3
3
|
label?: string;
|
|
4
4
|
icon?: string;
|
|
5
5
|
expanded?: boolean;
|
|
6
6
|
renderer?: string;
|
|
7
|
-
children?:
|
|
7
|
+
children?: HYTreeNodeData[];
|
|
8
8
|
[key: string]: unknown;
|
|
9
9
|
}
|
|
10
|
-
export type
|
|
11
|
-
export interface
|
|
10
|
+
export type HYTreeDropPosition = 'before' | 'after' | 'inside';
|
|
11
|
+
export interface HYTreeSelectionChangeDetail {
|
|
12
12
|
selectedId: string | null;
|
|
13
|
-
node:
|
|
13
|
+
node: HYTreeNodeData | null;
|
|
14
14
|
selectedIds: string[];
|
|
15
|
-
nodes:
|
|
15
|
+
nodes: HYTreeNodeData[];
|
|
16
16
|
}
|
|
17
|
-
export interface
|
|
18
|
-
data:
|
|
17
|
+
export interface HYTreeDataChangeDetail {
|
|
18
|
+
data: HYTreeNodeData[];
|
|
19
19
|
action?: 'copy' | 'paste' | 'delete' | 'drop';
|
|
20
20
|
sourceId?: string;
|
|
21
21
|
targetId?: string | null;
|
|
22
|
-
dropPosition?:
|
|
23
|
-
pastedNodes?:
|
|
22
|
+
dropPosition?: HYTreeDropPosition;
|
|
23
|
+
pastedNodes?: HYTreeNodeData[];
|
|
24
24
|
deletedIds?: string[];
|
|
25
25
|
}
|
|
26
|
-
export interface
|
|
26
|
+
export interface HYTreeNodeContextMenuDetail {
|
|
27
27
|
id: string;
|
|
28
|
-
node:
|
|
28
|
+
node: HYTreeNodeData;
|
|
29
29
|
selectedIds: string[];
|
|
30
30
|
clientX: number;
|
|
31
31
|
clientY: number;
|
|
32
32
|
}
|
|
33
33
|
export interface FlatTreeNode {
|
|
34
|
-
node:
|
|
35
|
-
parent:
|
|
34
|
+
node: HYTreeNodeData;
|
|
35
|
+
parent: HYTreeNodeData | null;
|
|
36
36
|
depth: number;
|
|
37
37
|
}
|
|
38
38
|
export interface IndexedTreeNode extends FlatTreeNode {
|
package/dist/tree.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export {
|
|
3
|
-
export type {
|
|
4
|
-
export declare class
|
|
1
|
+
import type { HYTreeNodeData } from './tree-types.js';
|
|
2
|
+
export { HYTreeNode } from './tree-node.js';
|
|
3
|
+
export type { HYTreeDataChangeDetail, HYTreeDropPosition, HYTreeNodeContextMenuDetail, HYTreeNodeData, HYTreeSelectionChangeDetail, } from './tree-types.js';
|
|
4
|
+
export declare class HYTree extends HTMLElement {
|
|
5
5
|
private static readonly VIRTUALIZATION_THRESHOLD;
|
|
6
6
|
private static readonly ROW_HEIGHT;
|
|
7
7
|
private static readonly OVERSCAN_ROWS;
|
|
@@ -25,15 +25,15 @@ export declare class GETree extends HTMLElement {
|
|
|
25
25
|
connectedCallback(): void;
|
|
26
26
|
disconnectedCallback(): void;
|
|
27
27
|
attributeChangedCallback(name: string): void;
|
|
28
|
-
get data():
|
|
29
|
-
set data(value:
|
|
28
|
+
get data(): HYTreeNodeData[];
|
|
29
|
+
set data(value: HYTreeNodeData[]);
|
|
30
30
|
get selectedId(): string | null;
|
|
31
31
|
set selectedId(value: string | null);
|
|
32
32
|
get selectedIds(): string[];
|
|
33
33
|
set selectedIds(value: string[]);
|
|
34
34
|
get allowDrag(): boolean;
|
|
35
35
|
set allowDrag(value: boolean);
|
|
36
|
-
updateData(value:
|
|
36
|
+
updateData(value: HYTreeNodeData[]): void;
|
|
37
37
|
expand(id: string): void;
|
|
38
38
|
collapse(id: string): void;
|
|
39
39
|
toggle(id: string): void;
|
|
@@ -76,6 +76,8 @@ export declare class GETree extends HTMLElement {
|
|
|
76
76
|
private _onDrop;
|
|
77
77
|
private _onKeyDown;
|
|
78
78
|
private _handleNavigationKey;
|
|
79
|
+
private _linearNavigationTarget;
|
|
80
|
+
private _handleNavigationAction;
|
|
79
81
|
private _moveActiveRight;
|
|
80
82
|
private _moveActiveLeft;
|
|
81
83
|
private _getActiveVisibleId;
|