hy-virtual-tree 1.1.25 → 1.1.27
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 +15 -0
- package/dist/index.js +46 -32
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
## Changelog
|
|
2
2
|
|
|
3
|
+
### 1.1.27
|
|
4
|
+
|
|
5
|
+
_2025-09-16_
|
|
6
|
+
|
|
7
|
+
- 扩展[VirtualTree] 功能
|
|
8
|
+
(1)添加双击回调onNodeDblClick
|
|
9
|
+
(2)onNodeClick 和 onNodeDblClick 添加返回 Promise 拦截内置逻辑
|
|
10
|
+
|
|
11
|
+
### 1.1.26
|
|
12
|
+
|
|
13
|
+
_2025-09-16_
|
|
14
|
+
|
|
15
|
+
- 扩展[VirtualTree] 功能
|
|
16
|
+
(1)树节点添加添加缓存条数
|
|
17
|
+
|
|
3
18
|
### 1.1.25
|
|
4
19
|
|
|
5
20
|
_2025-09-13_
|
package/dist/index.js
CHANGED
|
@@ -499,7 +499,7 @@ const useConfig = (config) => {
|
|
|
499
499
|
config = {
|
|
500
500
|
itemHeight: 30,
|
|
501
501
|
itemGap: 10,
|
|
502
|
-
bufferSize:
|
|
502
|
+
bufferSize: 50,
|
|
503
503
|
color: '#fff',
|
|
504
504
|
placeholderColor: '#909399',
|
|
505
505
|
fontSize: 14,
|
|
@@ -2071,28 +2071,33 @@ class VirtualTree {
|
|
|
2071
2071
|
let nodeClickCount = 0;
|
|
2072
2072
|
let isSelecting = false;
|
|
2073
2073
|
let isMouseDown = false;
|
|
2074
|
-
const nodeClickHandle = (e) => {
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
if (config.checkOnClickNode) {
|
|
2079
|
-
toggleCheckbox(item, !(isChecked(item) || isIndeterminate(item)), true, true);
|
|
2080
|
-
if (!config.expandOnClickNode || item.isLeaf) {
|
|
2081
|
-
this.refresh();
|
|
2082
|
-
}
|
|
2074
|
+
const nodeClickHandle = async (e) => {
|
|
2075
|
+
try {
|
|
2076
|
+
if (config.onNodeClick) {
|
|
2077
|
+
await config.onNodeClick(item.data, item, e);
|
|
2083
2078
|
}
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2079
|
+
if (!getDisabled(config, item) && (isBoolean(showSelect)
|
|
2080
|
+
? showSelect
|
|
2081
|
+
: isFunction(showSelect) && showSelect(item.data, item))) {
|
|
2082
|
+
if (config.checkOnClickNode) {
|
|
2083
|
+
toggleCheckbox(item, !(isChecked(item) || isIndeterminate(item)), true, true);
|
|
2084
|
+
if (!config.expandOnClickNode || item.isLeaf) {
|
|
2085
|
+
this.refresh();
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
else if (item.isLeaf && config.checkOnClickLeaf) {
|
|
2089
|
+
toggleCheckbox(item, !isChecked(item), true, true);
|
|
2090
|
+
if (!config.expandOnClickNode || item.isLeaf) {
|
|
2091
|
+
this.refresh();
|
|
2092
|
+
}
|
|
2088
2093
|
}
|
|
2089
2094
|
}
|
|
2095
|
+
if (config.expandOnClickNode && !item.isLeaf) {
|
|
2096
|
+
this._expandedHandle(item);
|
|
2097
|
+
this._refreshVirtualScroll();
|
|
2098
|
+
}
|
|
2090
2099
|
}
|
|
2091
|
-
|
|
2092
|
-
this._expandedHandle(item);
|
|
2093
|
-
this._refreshVirtualScroll();
|
|
2094
|
-
}
|
|
2095
|
-
config.onNodeClick && config.onNodeClick(item.data, item, e);
|
|
2100
|
+
catch { }
|
|
2096
2101
|
};
|
|
2097
2102
|
nodeContainer.addEventListener('mousedown', (e) => {
|
|
2098
2103
|
isSelecting = false;
|
|
@@ -2108,9 +2113,10 @@ class VirtualTree {
|
|
|
2108
2113
|
if (isSelecting)
|
|
2109
2114
|
return;
|
|
2110
2115
|
e.stopPropagation();
|
|
2111
|
-
if (getDisabled(config, item) ||
|
|
2116
|
+
if ((getDisabled(config, item) ||
|
|
2112
2117
|
item.isLeaf ||
|
|
2113
|
-
!config.checkOnDblclickParentNode)
|
|
2118
|
+
!config.checkOnDblclickParentNode) &&
|
|
2119
|
+
!config.onNodeDblClick) {
|
|
2114
2120
|
nodeClickHandle(e);
|
|
2115
2121
|
}
|
|
2116
2122
|
else {
|
|
@@ -2127,21 +2133,29 @@ class VirtualTree {
|
|
|
2127
2133
|
}
|
|
2128
2134
|
});
|
|
2129
2135
|
// 鼠标左键双击事件
|
|
2130
|
-
nodeContainer.addEventListener('dblclick', (e) => {
|
|
2136
|
+
nodeContainer.addEventListener('dblclick', async (e) => {
|
|
2131
2137
|
if (isSelecting)
|
|
2132
2138
|
return;
|
|
2133
2139
|
e.stopPropagation();
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2140
|
+
try {
|
|
2141
|
+
// 双击回调
|
|
2142
|
+
if (config.onNodeDblClick) {
|
|
2143
|
+
await config.onNodeDblClick(item.data, item, e);
|
|
2144
|
+
}
|
|
2145
|
+
if (getDisabled(config, item) ||
|
|
2146
|
+
item.isLeaf ||
|
|
2147
|
+
!config.checkOnDblclickParentNode ||
|
|
2148
|
+
!(isBoolean(showSelect)
|
|
2149
|
+
? showSelect
|
|
2150
|
+
: isFunction(showSelect) && showSelect(item.data, item))) {
|
|
2151
|
+
return;
|
|
2152
|
+
}
|
|
2153
|
+
nodeClickCount = 0;
|
|
2154
|
+
toggleCheckbox(item, !(isChecked(item) || isIndeterminate(item)), true, true, true);
|
|
2155
|
+
this.refresh();
|
|
2156
|
+
}
|
|
2157
|
+
catch {
|
|
2141
2158
|
}
|
|
2142
|
-
nodeClickCount = 0;
|
|
2143
|
-
toggleCheckbox(item, !(isChecked(item) || isIndeterminate(item)), true, true, true);
|
|
2144
|
-
this.refresh();
|
|
2145
2159
|
});
|
|
2146
2160
|
// 鼠标右键点击事件
|
|
2147
2161
|
nodeContainer.addEventListener('contextmenu', (e) => {
|