hy-virtual-tree 2.0.7 → 2.0.9

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.9
4
+
5
+ _2026-03-20_
6
+
7
+ (1)修复Tooltip在销毁之间移入,会导致其销毁失败bug
8
+
9
+ ### 2.0.8
10
+
11
+ _2026-03-17_
12
+
13
+ (1)修复自定义元素插槽传入元素节点时没有正常渲染bug
14
+
3
15
  ### 2.0.7
4
16
 
5
17
  _2026-03-16_
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /* hy-virtual-tree v2.0.7 */
1
+ /* hy-virtual-tree v2.0.9 */
2
2
  import './svg_bundle.js';
3
3
  const isString = (e) => typeof e === 'string';
4
4
  const isNumber = (e) => typeof e === 'number';
@@ -7028,6 +7028,7 @@ class Tooltip {
7028
7028
  _closeTimer;
7029
7029
  _style = getGlobalTooltipConfig().style;
7030
7030
  _isHover = false;
7031
+ _isDestroy = false;
7031
7032
  constructor(props) {
7032
7033
  if (!props.bind || !isElement(props.bind))
7033
7034
  throw Error('【bind参数错误】:请传入元素节点');
@@ -7064,7 +7065,7 @@ class Tooltip {
7064
7065
  el.appendChild(arrow);
7065
7066
  this._el = el;
7066
7067
  el.addEventListener('mouseenter', (e) => {
7067
- if (this.isHover)
7068
+ if (this._isDestroy || this.isHover)
7068
7069
  return;
7069
7070
  this.setIsHover(true);
7070
7071
  this._closeTimer && clearTimeout(this._closeTimer);
@@ -7081,7 +7082,7 @@ class Tooltip {
7081
7082
  trigger: this._config.trigger === 'click' ? 'click' : 'hover',
7082
7083
  openDelay: this._config.openDelay || 0,
7083
7084
  onFocus: () => {
7084
- if (this.isHover)
7085
+ if (this._isDestroy || this.isHover)
7085
7086
  return;
7086
7087
  if (!this._el || !this._config)
7087
7088
  return;
@@ -7109,7 +7110,7 @@ class Tooltip {
7109
7110
  }, 200);
7110
7111
  },
7111
7112
  onBlur: () => {
7112
- if (this.isHover)
7113
+ if (!this._isDestroy && this.isHover)
7113
7114
  return;
7114
7115
  this._openTimer && clearTimeout(this._openTimer);
7115
7116
  this._closeTimer && clearTimeout(this._closeTimer);
@@ -7181,6 +7182,7 @@ class Tooltip {
7181
7182
  }, 200);
7182
7183
  }
7183
7184
  destroy() {
7185
+ this._isDestroy = true;
7184
7186
  this.hide();
7185
7187
  this._timer && clearTimeout(this._timer);
7186
7188
  this._trigger && this._trigger.destroy();
@@ -9024,7 +9026,7 @@ const generateStats = (data, node) => {
9024
9026
  };
9025
9027
  // 自定义渲染元素
9026
9028
  const customRender = (options) => {
9027
- const { fn, node, parent, className, defaultFn, inset = false } = options || {};
9029
+ const { fn, node, parent, className, defaultFn } = options || {};
9028
9030
  let value;
9029
9031
  // 没有传入的自定义函数则使用默认函数
9030
9032
  if (!fn || !isFunction(fn)) {
@@ -9054,32 +9056,14 @@ const customRender = (options) => {
9054
9056
  return value;
9055
9057
  }
9056
9058
  else if (isElement(value)) {
9057
- if (inset) {
9058
- return createVNode('div', (vnode) => {
9059
- className && vnode.el.classList.add(className);
9060
- vnode.el.appendChild(value);
9061
- });
9062
- }
9063
- else {
9064
- className && value.classList.add(className);
9059
+ return createVNode('div', (vnode) => {
9060
+ className && vnode.el.classList.add(className);
9061
+ vnode.el.appendChild(value);
9062
+ vnode.$destroy = value.$destroy;
9065
9063
  if (parent) {
9066
- if (parent.el) {
9067
- parent.el.appendChild(value);
9068
- }
9069
- const target = {
9070
- el: value,
9071
- destroy: () => {
9072
- // @ts-ignore
9073
- value && value.$destroy && value.$destroy();
9074
- // @ts-ignore
9075
- value && value.destroy && value.destroy();
9076
- }
9077
- };
9078
- if (!parent.children)
9079
- parent.children = [];
9080
- parent.children.push(target);
9064
+ vnode.mount(parent);
9081
9065
  }
9082
- }
9066
+ });
9083
9067
  }
9084
9068
  if (isEmpty(value))
9085
9069
  return;
@@ -9776,7 +9760,6 @@ class VirtualTree {
9776
9760
  statusSlot = customRender({
9777
9761
  fn: config.renderStatus,
9778
9762
  node: item,
9779
- inset: true,
9780
9763
  className: 'hy-tree-node__status',
9781
9764
  defaultFn: (data, node) => {
9782
9765
  return useStatus(config, data);
@@ -9784,7 +9767,7 @@ class VirtualTree {
9784
9767
  });
9785
9768
  }
9786
9769
  // 右侧内容
9787
- rightSlot = customRender({ fn: config.renderRight, node: item, inset: true, className: 'hy-tree-node__right-content' });
9770
+ rightSlot = customRender({ fn: config.renderRight, node: item, className: 'hy-tree-node__right-content' });
9788
9771
  if (!statusSlot && !rightSlot)
9789
9772
  return;
9790
9773
  return createVNode('div', (vnode) => {
@@ -9895,14 +9878,13 @@ class VirtualTree {
9895
9878
  customRender({
9896
9879
  fn: config.renderItem,
9897
9880
  node: item,
9898
- inset: true,
9899
9881
  parent: contentContainer,
9900
9882
  className: 'hy-tree-node__node-content',
9901
9883
  defaultFn: (data, node) => {
9902
9884
  // 图标
9903
- customRender({ fn: config.renderIcon, node, inset: true, parent: contentContainer, className: 'hy-tree-icon', defaultFn: generateIcon });
9885
+ customRender({ fn: config.renderIcon, node, parent: contentContainer, className: 'hy-tree-icon', defaultFn: generateIcon });
9904
9886
  // 内容
9905
- customRender({ fn: config.renderContent, node, inset: true, parent: contentContainer, className: 'hy-tree-node__content', defaultFn: useContent });
9887
+ customRender({ fn: config.renderContent, node, parent: contentContainer, className: 'hy-tree-node__content', defaultFn: useContent });
9906
9888
  // 统计
9907
9889
  if (isShowCount(this._props.showCount, item)) {
9908
9890
  customRender({ fn: generateStats, node, parent: contentContainer });
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "hy-virtual-tree",
3
- "version": "2.0.7",
3
+ "version": "2.0.9",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite",
7
7
  "build": "vue-tsc --noEmit && vite build",
8
8
  "preview": "vite preview",
9
- "complie": "rollup -c",
9
+ "compile": "rollup -c",
10
10
  "lint:eslint": "eslint --fix --ext .js,.ts,.vue ./components"
11
11
  },
12
12
  "files": [