This commit is contained in:
Georges KABBOUCHI
2025-03-20 00:39:09 +02:00
parent daf61cb469
commit 41340a06b5
2 changed files with 13 additions and 3 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "vue-tippy", "name": "vue-tippy",
"version": "6.6.0", "version": "6.7.0",
"main": "index.js", "main": "index.js",
"module": "dist/vue-tippy.mjs", "module": "dist/vue-tippy.mjs",
"unpkg": "dist/vue-tippy.iife.js", "unpkg": "dist/vue-tippy.iife.js",
+12 -2
View File
@@ -24,8 +24,14 @@ tippy.setDefaultProps({
}, },
}) })
const isComponentInstance = (value: any): value is { $el: any } => {
return value instanceof Object && '$' in value && '$el' in value
}
type TippyElement = Element | any // TODO: use ComponentPublicInstance
export function useTippy( export function useTippy(
el: Element | (() => Element) | Ref<Element> | Ref<Element | undefined>, el: TippyElement | (() => TippyElement) | Ref<TippyElement> | Ref<TippyElement | undefined>,
opts: TippyOptions = {}, opts: TippyOptions = {},
settings: { settings: {
mount: boolean, mount: boolean,
@@ -231,9 +237,13 @@ export function useTippy(
if (typeof target === 'function') target = target() if (typeof target === 'function') target = target()
if (isComponentInstance(target)) {
target = target.$el as Element
}
if (target) { if (target) {
//@ts-ignore //@ts-ignore
instance.value = tippy(target?.$el ?? target, getProps(opts)) instance.value = tippy(target, getProps(opts))
//@ts-ignore //@ts-ignore
target.$tippy = response target.$tippy = response
} }