hy-virtual-tree 1.1.48 → 1.1.49
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/CHANGELOG.md +7 -0
- package/dist/index.css +4 -4
- package/dist/index.js +19 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.css
CHANGED
|
@@ -469,12 +469,12 @@
|
|
|
469
469
|
right: 0;
|
|
470
470
|
transform: translateY(-50%);
|
|
471
471
|
}
|
|
472
|
-
.hy-tree .hy-tree-node:not(.hy-tree-channel-node):has(+ .hy-tree-channel-node) {
|
|
473
|
-
background-image: linear-gradient(to bottom, transparent 50%, var(--hy-tree-channel-bg-color) 50%, var(--hy-tree-channel-bg-color) 100%);
|
|
474
|
-
}
|
|
475
472
|
.hy-tree .hy-tree-node:not(.hy-tree-channel-node) + .hy-tree-channel-node .hy-tree-node-container .hy-tree-node__expand::before {
|
|
476
473
|
height: calc(var(--hy-tree-item-height) - var(--hy-tree-item-gap) / 2);
|
|
477
474
|
}
|
|
478
|
-
.hy-tree .hy-tree-
|
|
475
|
+
.hy-tree .hy-tree-node.hy-tree-device-node.hy-tree-node-expand {
|
|
476
|
+
background-image: linear-gradient(to bottom, transparent 50%, var(--hy-tree-channel-bg-color) 50%, var(--hy-tree-channel-bg-color) 100%);
|
|
477
|
+
}
|
|
478
|
+
.hy-tree .hy-tree-channel-node.hy-tree-channel-last-node {
|
|
479
479
|
background: linear-gradient(to bottom, var(--hy-tree-channel-bg-color) 0%, var(--hy-tree-channel-bg-color) calc(100% - var(--hy-tree-item-gap)), transparent calc(100% - var(--hy-tree-item-gap)));
|
|
480
480
|
}
|
package/dist/index.js
CHANGED
|
@@ -465,7 +465,7 @@ class VirtualScroll {
|
|
|
465
465
|
const item = this.items[i];
|
|
466
466
|
if (this.customRenderItem) {
|
|
467
467
|
// Use custom render function
|
|
468
|
-
const itemElement = this.customRenderItem(item, i);
|
|
468
|
+
const itemElement = this.customRenderItem(item, i, this.items[i - 1], this.items[i + 1]);
|
|
469
469
|
if (itemElement) {
|
|
470
470
|
// Only set necessary height styles, other styles are determined by the caller
|
|
471
471
|
itemElement.style.height = `${this.itemHeight * this.heightScale}px`;
|
|
@@ -2649,11 +2649,20 @@ class VirtualTree {
|
|
|
2649
2649
|
}
|
|
2650
2650
|
};
|
|
2651
2651
|
/** 渲染项 */
|
|
2652
|
-
const generateItem = (item) => {
|
|
2652
|
+
const generateItem = (item, index, prev, next) => {
|
|
2653
2653
|
let el = document.createElement('div');
|
|
2654
2654
|
el.classList.add('hy-tree-node');
|
|
2655
|
-
if (item.data.dataType ===
|
|
2655
|
+
if (item.data.dataType === DataType.CHANNEL) {
|
|
2656
2656
|
el.classList.add('hy-tree-channel-node');
|
|
2657
|
+
if (!next || next.data.dataType !== DataType.CHANNEL) {
|
|
2658
|
+
el.classList.add('hy-tree-channel-last-node');
|
|
2659
|
+
}
|
|
2660
|
+
}
|
|
2661
|
+
else if (item.data.dataType === DataType.DEVICE) {
|
|
2662
|
+
el.classList.add('hy-tree-device-node');
|
|
2663
|
+
}
|
|
2664
|
+
if (this._expandedKeySet.has(item.key)) {
|
|
2665
|
+
el.classList.add('hy-tree-node-expand');
|
|
2657
2666
|
}
|
|
2658
2667
|
let nodeContainer = document.createElement('div');
|
|
2659
2668
|
nodeContainer.style.height = `${config.itemHeight}px`;
|
|
@@ -2989,7 +2998,7 @@ class VirtualTree {
|
|
|
2989
2998
|
: data;
|
|
2990
2999
|
return this._tree ? this._tree.treeNodeMap.get(key) : undefined;
|
|
2991
3000
|
};
|
|
2992
|
-
/**
|
|
3001
|
+
/** 获取部门/群组/设备 下 的 设备和通道 */
|
|
2993
3002
|
getDeviceIntegrated = (() => {
|
|
2994
3003
|
const getAllDevice = (children, params, list = []) => {
|
|
2995
3004
|
if (!children?.length)
|
|
@@ -3035,8 +3044,9 @@ class VirtualTree {
|
|
|
3035
3044
|
};
|
|
3036
3045
|
return (params) => {
|
|
3037
3046
|
const { id, isBusiness = false } = params;
|
|
3038
|
-
if (!id)
|
|
3039
|
-
|
|
3047
|
+
if (!id) {
|
|
3048
|
+
throw Error('getDeviceIntegrated:id不能为空');
|
|
3049
|
+
}
|
|
3040
3050
|
let node;
|
|
3041
3051
|
if (isBusiness && this._business) {
|
|
3042
3052
|
switch (this._business) {
|
|
@@ -3055,6 +3065,9 @@ class VirtualTree {
|
|
|
3055
3065
|
node = node?.[0];
|
|
3056
3066
|
}
|
|
3057
3067
|
node = node || this._tree.treeNodeMap.get(params.id);
|
|
3068
|
+
if (!node) {
|
|
3069
|
+
throw Error('getDeviceIntegrated:找不到节点');
|
|
3070
|
+
}
|
|
3058
3071
|
return getAllDevice(node?.children || [], params);
|
|
3059
3072
|
};
|
|
3060
3073
|
})();
|