vueless 0.0.793 → 0.0.794
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/directives/tooltip/vTooltip.ts +20 -25
- package/package.json +1 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import tippy from "tippy.js";
|
|
2
2
|
import { merge } from "lodash-es";
|
|
3
|
-
import { toValue, computed, watch } from "vue";
|
|
4
3
|
|
|
5
4
|
import { vuelessConfig } from "../../utils/ui.ts";
|
|
6
5
|
import { isCSR, isSSR } from "../../utils/helper.ts";
|
|
@@ -37,29 +36,7 @@ function onMounted(
|
|
|
37
36
|
): void {
|
|
38
37
|
if (isSSR) return;
|
|
39
38
|
|
|
40
|
-
|
|
41
|
-
tippy(el, merge(settings, { content: bindings.value }));
|
|
42
|
-
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (
|
|
47
|
-
typeof bindings.value !== "string" &&
|
|
48
|
-
bindings.value.content &&
|
|
49
|
-
String(bindings.value.content).length
|
|
50
|
-
) {
|
|
51
|
-
tippy(el, merge(settings, bindings.value || {}));
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const localBindings = computed(() => toValue(bindings));
|
|
55
|
-
|
|
56
|
-
watch(
|
|
57
|
-
localBindings,
|
|
58
|
-
() => {
|
|
59
|
-
updateTippyProps(el._tippy, localBindings.value.value);
|
|
60
|
-
},
|
|
61
|
-
{ deep: true },
|
|
62
|
-
);
|
|
39
|
+
setUpTippy(el, bindings.value);
|
|
63
40
|
}
|
|
64
41
|
|
|
65
42
|
function onUpdated(el: TippyTargetElement, bindings: DirectiveBindingContent): void;
|
|
@@ -68,7 +45,13 @@ function onUpdated(
|
|
|
68
45
|
el: TippyTargetElement,
|
|
69
46
|
bindings: DirectiveBindingProps | DirectiveBindingContent,
|
|
70
47
|
): void {
|
|
71
|
-
if (
|
|
48
|
+
if (isSSR) return;
|
|
49
|
+
|
|
50
|
+
if (!el._tippy) {
|
|
51
|
+
setUpTippy(el, bindings.value);
|
|
52
|
+
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
72
55
|
|
|
73
56
|
updateTippyProps(el._tippy, bindings.value);
|
|
74
57
|
}
|
|
@@ -79,6 +62,18 @@ function onUnmounted(el: TippyTargetElement) {
|
|
|
79
62
|
el._tippy.destroy();
|
|
80
63
|
}
|
|
81
64
|
|
|
65
|
+
function setUpTippy(el: HTMLElement, props: string | TippyProps) {
|
|
66
|
+
if (typeof props === "string" && props.length) {
|
|
67
|
+
tippy(el, merge(settings, { content: props }));
|
|
68
|
+
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (typeof props !== "string" && props.content && String(props.content).length) {
|
|
73
|
+
tippy(el, merge(settings, props || {}));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
82
77
|
function updateTippyProps(tippyInstance: TippyInstance | undefined, props: string | TippyProps) {
|
|
83
78
|
if (!tippyInstance || isSSR) return;
|
|
84
79
|
|