hy-virtual-tree 1.1.64 → 1.1.65
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 +8 -0
- package/dist/index.css +5 -0
- package/dist/index.js +30 -18
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.css
CHANGED
|
@@ -14,6 +14,11 @@
|
|
|
14
14
|
background: var(--hy-tooltip-bg);
|
|
15
15
|
border: 1px solid #375C86;
|
|
16
16
|
transform: translateX(-50%) translateY(calc(-100% - 10px));
|
|
17
|
+
opacity: 0;
|
|
18
|
+
transition: opacity 0.2s linear;
|
|
19
|
+
}
|
|
20
|
+
.hy-tooltip.hy-tooltip-show {
|
|
21
|
+
opacity: 1;
|
|
17
22
|
}
|
|
18
23
|
.hy-tooltip.top .hy-popper__arrow {
|
|
19
24
|
left: 50%;
|
package/dist/index.js
CHANGED
|
@@ -170,6 +170,7 @@ class Tooltip {
|
|
|
170
170
|
_config;
|
|
171
171
|
_focus;
|
|
172
172
|
_timer;
|
|
173
|
+
_openTimer;
|
|
173
174
|
constructor(props) {
|
|
174
175
|
if (!props.bind || !isElement(props.bind))
|
|
175
176
|
throw Error('【bind参数错误】:请传入元素节点');
|
|
@@ -181,6 +182,7 @@ class Tooltip {
|
|
|
181
182
|
placement: "top",
|
|
182
183
|
offset: 0,
|
|
183
184
|
trigger: "hover",
|
|
185
|
+
openDelay: 200,
|
|
184
186
|
autoClose: 0,
|
|
185
187
|
...config
|
|
186
188
|
};
|
|
@@ -206,19 +208,29 @@ class Tooltip {
|
|
|
206
208
|
trigger: this._config.trigger === 'click' ? 'click' : 'hover',
|
|
207
209
|
onFocus: () => {
|
|
208
210
|
closeActiveTooltip && closeActiveTooltip();
|
|
209
|
-
if (!this._el)
|
|
211
|
+
if (!this._el || !this._config)
|
|
210
212
|
return;
|
|
211
213
|
if (this._config?.trigger === 'hover-overflow' && !isOverflowing(this._config.bind))
|
|
212
214
|
return;
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
this.
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
215
|
+
this._openTimer && clearTimeout(this._openTimer);
|
|
216
|
+
this._openTimer = setTimeout(() => {
|
|
217
|
+
if (!this._config || !this._el)
|
|
218
|
+
return;
|
|
219
|
+
const container = getContainer$1();
|
|
220
|
+
container.appendChild(this._el);
|
|
221
|
+
setTimeout(() => {
|
|
222
|
+
if (!this._el)
|
|
223
|
+
return;
|
|
224
|
+
this._el.classList.add('hy-tooltip-show');
|
|
225
|
+
});
|
|
226
|
+
this.setPopper();
|
|
227
|
+
if (this._config?.autoClose && isNumber(this._config.autoClose)) {
|
|
228
|
+
this._timer && clearTimeout(this._timer);
|
|
229
|
+
this._timer = setTimeout(() => {
|
|
230
|
+
this._focus && this._focus.blur();
|
|
231
|
+
}, this._config?.autoClose);
|
|
232
|
+
}
|
|
233
|
+
}, this._config.openDelay || 0);
|
|
222
234
|
},
|
|
223
235
|
onBlur: () => {
|
|
224
236
|
this._timer && clearTimeout(this._timer);
|
|
@@ -253,11 +265,13 @@ class Tooltip {
|
|
|
253
265
|
closeActiveTooltip = this.hide.bind(this);
|
|
254
266
|
}
|
|
255
267
|
hide() {
|
|
268
|
+
this._openTimer && clearTimeout(this._openTimer);
|
|
256
269
|
if (!this._el || !this._el.parentElement)
|
|
257
270
|
return;
|
|
258
271
|
this._el.style.setProperty('top', '-10000px');
|
|
259
272
|
this._el.style.setProperty('left', '-10000px');
|
|
260
273
|
this._el.parentElement.removeChild(this._el);
|
|
274
|
+
this._el.classList.remove('hy-tooltip-show');
|
|
261
275
|
}
|
|
262
276
|
destroy() {
|
|
263
277
|
this._timer && clearTimeout(this._timer);
|
|
@@ -1962,16 +1976,17 @@ const useContent = (data, node) => {
|
|
|
1962
1976
|
const el = document.createElement('div');
|
|
1963
1977
|
el.innerHTML = node.label || '';
|
|
1964
1978
|
if (node.label) {
|
|
1965
|
-
|
|
1979
|
+
new Tooltip({
|
|
1966
1980
|
bind: el,
|
|
1967
1981
|
content: node.label,
|
|
1968
1982
|
placement: 'top',
|
|
1969
1983
|
trigger: 'hover-overflow'
|
|
1970
1984
|
});
|
|
1971
|
-
// @ts-ignore
|
|
1972
|
-
el.$destroy = () => {
|
|
1973
|
-
|
|
1974
|
-
|
|
1985
|
+
// // @ts-ignore
|
|
1986
|
+
// el.$destroy = () => {
|
|
1987
|
+
// tooltip.hide()
|
|
1988
|
+
// tooltip && tooltip.destroy()
|
|
1989
|
+
// }
|
|
1975
1990
|
}
|
|
1976
1991
|
return el;
|
|
1977
1992
|
};
|
|
@@ -9163,9 +9178,6 @@ class VirtualTree {
|
|
|
9163
9178
|
let value, el, $destroy;
|
|
9164
9179
|
if (!fn || !isFunction(fn)) {
|
|
9165
9180
|
value = defaultFn && isFunction(defaultFn) && defaultFn(node.data, node);
|
|
9166
|
-
if (value) {
|
|
9167
|
-
$destroy = value.$destroy;
|
|
9168
|
-
}
|
|
9169
9181
|
}
|
|
9170
9182
|
else {
|
|
9171
9183
|
let dom = fn(node.data, node);
|