hy-virtual-tree 1.1.62 → 1.1.64

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,19 @@
1
1
  ## Changelog
2
2
 
3
+ ### 1.1.64
4
+
5
+ _2026-01-23_
6
+
7
+ - 扩展[VirtualTree] 功能
8
+ (1)优化树形,节点内容添加溢出省略时,移入显示tooltip
9
+
10
+ ### 1.1.63
11
+
12
+ _2026-01-16_
13
+
14
+ - 扩展[VirtualTree] 功能
15
+ (1)优化树形的空数据占位图渲染逻辑为每次显示动态刷新元素
16
+
3
17
  ### 1.1.62
4
18
 
5
19
  _2026-01-09_
package/dist/index.js CHANGED
@@ -8,6 +8,7 @@ const isBoolean = (e) => typeof e === 'boolean';
8
8
  const isUndefined = (e) => e === undefined;
9
9
  const isNull = (e) => e === null;
10
10
  const isEmpty = (e) => isUndefined(e) || isNull(e) || (!isNumber(e) && !e);
11
+ const isOverflowing = (e) => e.clientWidth < e.scrollWidth;
11
12
 
12
13
  var workCard_svg = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iMjBweCIgaGVpZ2h0PSIyMHB4IiB2aWV3Qm94PSIwIDAgMjAgMjAiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+CiAgICAgICA8ZyBpZD0i5bel54mMLXNlbCIgc3Ryb2tlPSJub25lIiBzdHJva2Utd2lkdGg9IjEiIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCI+CiAgICAgICAgPHBhdGggZD0iTTE0Ljc3NjI5NTEsMiBDMTUuNzI4MjcxLDIgMTYuNSwyLjc3MTcyODk1IDE2LjUsMy43MjM3MDQ4NiB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MzgwOTUyNCAxNC43MTA4NjA0LDEwLjE2NDc2MTIgMTQuNzEwODYwNCw5Ljg5ODA3NTkyIEwxNC43MTA4NjA0LDQuNjczODM1NTIgQzE0LjcxMDg2MDQsNC40MDcxNTAyMyAxNC4zMDU1NDE1LDQuMTkwOTU5MDggMTMuODA1NTU1Myw0LjE5MDk1OTA3IFoiIGlkPSIy5aSH5Lu9LTIiIGZpbGw9IiNGRkZGRkYiIGZpbGwtcnVsZT0ibm9uemVybyI+PC9wYXRoPgogICAgPC9nPgo8L3N2Zz4=';
13
14
 
@@ -185,6 +186,8 @@ class Tooltip {
185
186
  };
186
187
  }
187
188
  _render() {
189
+ if (!this._config)
190
+ return;
188
191
  const { bind, content } = this._config;
189
192
  const el = document.createElement('div');
190
193
  el.classList.add('hy-tooltip');
@@ -200,15 +203,17 @@ class Tooltip {
200
203
  this._el = el;
201
204
  this._focus = setElementFocus({
202
205
  container: bind,
203
- trigger: this._config.trigger,
206
+ trigger: this._config.trigger === 'click' ? 'click' : 'hover',
204
207
  onFocus: () => {
205
208
  closeActiveTooltip && closeActiveTooltip();
206
209
  if (!this._el)
207
210
  return;
211
+ if (this._config?.trigger === 'hover-overflow' && !isOverflowing(this._config.bind))
212
+ return;
208
213
  const container = getContainer$1();
209
214
  container.appendChild(this._el);
210
215
  this.setPopper();
211
- if (this._config?.autoClose && isNumber(this._config?.autoClose)) {
216
+ if (this._config?.autoClose && isNumber(this._config.autoClose)) {
212
217
  this._timer && clearTimeout(this._timer);
213
218
  this._timer = setTimeout(() => {
214
219
  this._focus && this._focus.blur();
@@ -425,8 +430,6 @@ class VirtualScroll {
425
430
  this.contentWrapper.appendChild(this.contentContainer);
426
431
  this.scrollContainer.appendChild(this.contentWrapper);
427
432
  this.container.appendChild(this.scrollContainer);
428
- this.emptyContainer = this.renderEmpty();
429
- this.scrollContainer.appendChild(this.emptyContainer);
430
433
  // Render initial visible items
431
434
  this.renderVisibleItems(0, Math.min(100, this.items.length));
432
435
  }
@@ -626,10 +629,17 @@ class VirtualScroll {
626
629
  */
627
630
  switchEmpty(show = true) {
628
631
  if (show) {
629
- this.emptyContainer.style.display = '';
632
+ const newEmptyContainer = this.renderEmpty();
633
+ if (this.emptyContainer) {
634
+ this.scrollContainer.removeChild(this.emptyContainer);
635
+ this.emptyContainer = null;
636
+ }
637
+ this.emptyContainer = newEmptyContainer;
638
+ this.scrollContainer.appendChild(this.emptyContainer);
630
639
  }
631
- else {
632
- this.emptyContainer.style.display = 'none';
640
+ else if (this.emptyContainer) {
641
+ this.scrollContainer.removeChild(this.emptyContainer);
642
+ this.emptyContainer = null;
633
643
  }
634
644
  }
635
645
  }
@@ -1947,6 +1957,24 @@ const useIcon = (config, data, node) => {
1947
1957
  return new Icon({ svgName: 'menu_acquisitionStation_svg' });
1948
1958
  }
1949
1959
  };
1960
+ // 生成内容节点
1961
+ const useContent = (data, node) => {
1962
+ const el = document.createElement('div');
1963
+ el.innerHTML = node.label || '';
1964
+ if (node.label) {
1965
+ let tooltip = new Tooltip({
1966
+ bind: el,
1967
+ content: node.label,
1968
+ placement: 'top',
1969
+ trigger: 'hover-overflow'
1970
+ });
1971
+ // @ts-ignore
1972
+ el.$destroy = () => {
1973
+ tooltip && tooltip.destroy();
1974
+ };
1975
+ }
1976
+ return el;
1977
+ };
1950
1978
 
1951
1979
  function decodeBase64(base64, enableUnicode) {
1952
1980
  var binaryString = atob(base64);
@@ -9135,6 +9163,9 @@ class VirtualTree {
9135
9163
  let value, el, $destroy;
9136
9164
  if (!fn || !isFunction(fn)) {
9137
9165
  value = defaultFn && isFunction(defaultFn) && defaultFn(node.data, node);
9166
+ if (value) {
9167
+ $destroy = value.$destroy;
9168
+ }
9138
9169
  }
9139
9170
  else {
9140
9171
  let dom = fn(node.data, node);
@@ -9262,12 +9293,6 @@ class VirtualTree {
9262
9293
  return;
9263
9294
  return icon._el;
9264
9295
  };
9265
- /** 生成内容 */
9266
- const generateContent = (data, item) => {
9267
- const el = document.createElement('div');
9268
- el.innerHTML = item.label || '';
9269
- return el;
9270
- };
9271
9296
  /** 生成统计 */
9272
9297
  const generateStats = (data, item) => {
9273
9298
  if (!isShowCount(this._props.showCount, item))
@@ -9398,7 +9423,7 @@ class VirtualTree {
9398
9423
  // 图标
9399
9424
  this._customRender(config.renderIcon, node, { inset: true, parent: content, className: 'hy-tree-icon', defaultFn: generateIcon });
9400
9425
  // 内容
9401
- this._customRender(config.renderContent, node, { inset: true, parent: content, className: 'hy-tree-node__content', defaultFn: generateContent });
9426
+ this._customRender(config.renderContent, node, { inset: true, parent: content, className: 'hy-tree-node__content', defaultFn: useContent });
9402
9427
  // 统计
9403
9428
  this._customRender(generateStats, node, { parent: content });
9404
9429
  // 右侧内容
@@ -9859,4 +9884,4 @@ class VirtualTree {
9859
9884
  };
9860
9885
  }
9861
9886
 
9862
- export { Business, DataType, DeviceStatus, VirtualScroll, VirtualTree, getGlobalDeviceStatus, isArray, isBoolean, isElement, isEmpty, isFunction, isNull, isNumber, isObject, isString, isUndefined, setGlobalDeviceStatus };
9887
+ export { Business, DataType, DeviceStatus, VirtualScroll, VirtualTree, getGlobalDeviceStatus, isArray, isBoolean, isElement, isEmpty, isFunction, isNull, isNumber, isObject, isOverflowing, isString, isUndefined, setGlobalDeviceStatus };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hy-virtual-tree",
3
- "version": "1.1.62",
3
+ "version": "1.1.64",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite",