hy-virtual-tree 2.0.12 → 2.0.14

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  ## Changelog
2
2
 
3
+ ### 2.0.14
4
+
5
+ _2026-05-11_
6
+
7
+ (1)新增 默认展开 和 筛选展开 逻辑
8
+
9
+ ### 2.0.13
10
+
11
+ _2026-05-07_
12
+
13
+ (1)新增 showExpand 参数,用来控制是否显示展开图标
14
+
3
15
  ### 2.0.12
4
16
 
5
17
  _2026-04-20_
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /* hy-virtual-tree v2.0.12 */
1
+ /* hy-virtual-tree v2.0.14 */
2
2
  import './svg_bundle.js';
3
3
  const isString = (e) => typeof e === 'string';
4
4
  const isNumber = (e) => typeof e === 'number';
@@ -7968,6 +7968,7 @@ const useConfig = (config) => {
7968
7968
  // checkOnClickLeaf: true,
7969
7969
  // checkOnDblclickParentNode: true,
7970
7970
  // indent: 16,
7971
+ showExpand: true,
7971
7972
  ...getGlobalVirtualTreeConfig(),
7972
7973
  ...config,
7973
7974
  props,
@@ -8259,7 +8260,6 @@ function useCheck(props, instance) {
8259
8260
  if (instance._hiddenNodeKeySet.has(node.key) || (tree.hiddenNodeKeySet.has(node.key) && nodeClick))
8260
8261
  return;
8261
8262
  }
8262
- console.log('???', checked);
8263
8263
  checkedKeySet[checked ? 'add' : 'delete'](node.key);
8264
8264
  const children = node.children;
8265
8265
  if ((!checkStrictly || checkOnDbclick) && children) {
@@ -9462,6 +9462,7 @@ class VirtualTree {
9462
9462
  hiddenNodeKeySet: new Set()
9463
9463
  };
9464
9464
  _rowSelection = {};
9465
+ _showExpand = true;
9465
9466
  _business;
9466
9467
  _expandedKeySet = new Set(); // 展开的key
9467
9468
  _hiddenExpandIconKeySet = new Set(); // 隐藏展开图标
@@ -9504,6 +9505,7 @@ class VirtualTree {
9504
9505
  this._getKey = getKey;
9505
9506
  this._businessConfig = config.businessConfig;
9506
9507
  this._rowSelection = config.rowSelection;
9508
+ this._showExpand = isBoolean(config.showExpand) ? config.showExpand : true;
9507
9509
  this._render(config);
9508
9510
  }
9509
9511
  /** 创建树数据 */
@@ -9874,7 +9876,10 @@ class VirtualTree {
9874
9876
  && item.data.deviceStatus === 0) {
9875
9877
  contentContainer.el.style.color = config.placeholderColor;
9876
9878
  }
9877
- contentContainer.el.appendChild(generateExpandIcon(item));
9879
+ if (this._showExpand) {
9880
+ const expandIcon = generateExpandIcon(item);
9881
+ contentContainer.el.appendChild(expandIcon);
9882
+ }
9878
9883
  // 多选框/单选框
9879
9884
  generateCheckbox(contentContainer, item);
9880
9885
  // 整个节点内容
@@ -10025,6 +10030,7 @@ class VirtualTree {
10025
10030
  // }
10026
10031
  }
10027
10032
  });
10033
+ this._renderHandler();
10028
10034
  config.onLoad && config.onLoad();
10029
10035
  // @ts-ignore
10030
10036
  // 更新函数
@@ -10148,6 +10154,7 @@ class VirtualTree {
10148
10154
  // this._destroyDomSet.delete($destroy)
10149
10155
  // }
10150
10156
  this._isForceHiddenExpandIcon = undefined;
10157
+ this._renderHandler();
10151
10158
  this._updateCheckedKeys();
10152
10159
  this._refreshVirtualScroll();
10153
10160
  callback && callback();
@@ -10191,6 +10198,17 @@ class VirtualTree {
10191
10198
  }
10192
10199
  };
10193
10200
  })();
10201
+ /** 渲染初始化 */
10202
+ _isRenderInitial = false;
10203
+ _renderHandler() {
10204
+ if (this._isRenderInitial)
10205
+ return;
10206
+ const expandedKeys = new Set(this._tree.treeNodeMap.keys());
10207
+ if (expandedKeys.size) {
10208
+ this._expandedKeySet = expandedKeys;
10209
+ this._isRenderInitial = true;
10210
+ }
10211
+ }
10194
10212
  /** 获取指定节点 */
10195
10213
  getNode = (data) => {
10196
10214
  const key = isObject(data)
@@ -10330,6 +10348,7 @@ class VirtualTree {
10330
10348
  }, this._filterMethod, this._tree);
10331
10349
  const keys = doFilter(params, filterAll);
10332
10350
  if (keys) {
10351
+ this._expandedKeySet = keys;
10333
10352
  this._hiddenExpandIconKeySet = hiddenExpandIconKeySet;
10334
10353
  this._hiddenNodeKeySet = hiddenNodeKeySet;
10335
10354
  this._isForceHiddenExpandIcon = isForceHiddenExpandIcon;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hy-virtual-tree",
3
- "version": "2.0.12",
3
+ "version": "2.0.14",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite",