wip
This commit is contained in:
+57
-9
@@ -1,17 +1,65 @@
|
||||
import { defineComponent, ref, h, PropType } from 'vue'
|
||||
import { Content } from 'tippy.js'
|
||||
import { defineComponent, ref, h, ComponentObjectPropsOptions } from 'vue'
|
||||
import { TippyOptions } from '../types'
|
||||
import { useTippy } from '../composables'
|
||||
import tippy, { DefaultProps } from 'tippy.js'
|
||||
|
||||
declare module '@vue/runtime-core' {
|
||||
interface ComponentCustomProps extends TippyOptions {}
|
||||
}
|
||||
|
||||
const pluginProps = [
|
||||
'animateFill',
|
||||
'followCursor',
|
||||
'inlinePositioning',
|
||||
'sticky',
|
||||
]
|
||||
const booleanProps = [
|
||||
'a11y',
|
||||
'allowHTML',
|
||||
'arrow',
|
||||
'flip',
|
||||
'flipOnUpdate',
|
||||
'hideOnClick',
|
||||
'ignoreAttributes',
|
||||
'inertia',
|
||||
'interactive',
|
||||
'lazy',
|
||||
'multiple',
|
||||
'showOnInit',
|
||||
'touch',
|
||||
'touchHold',
|
||||
]
|
||||
|
||||
let props: ComponentObjectPropsOptions = {}
|
||||
|
||||
Object.keys(tippy.defaultProps).forEach((prop: string) => {
|
||||
if (pluginProps.includes(prop)) return
|
||||
|
||||
if (booleanProps.includes(prop)) {
|
||||
props[prop] = {
|
||||
type: Boolean,
|
||||
default: function () {
|
||||
console.log(tippy.defaultProps[prop as keyof DefaultProps])
|
||||
|
||||
return tippy.defaultProps[prop as keyof DefaultProps] as Boolean
|
||||
},
|
||||
}
|
||||
} else {
|
||||
props[prop] = {
|
||||
default: function () {
|
||||
return tippy.defaultProps[prop as keyof DefaultProps]
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
console.log(props)
|
||||
|
||||
export default defineComponent({
|
||||
props: {
|
||||
content: {} as PropType<Content>,
|
||||
},
|
||||
props,
|
||||
setup(props) {
|
||||
const elem = ref<Element>()
|
||||
|
||||
useTippy(elem, props)
|
||||
|
||||
return { elem }
|
||||
return { elem, ...useTippy(elem, props) }
|
||||
},
|
||||
render() {
|
||||
let slot = this.$slots.default ? this.$slots.default() : []
|
||||
|
||||
+3
-1
@@ -4,5 +4,7 @@ import { useTippy } from './composables/useTippy'
|
||||
import { TippyOptions } from './types'
|
||||
import 'tippy.js/dist/tippy.css'
|
||||
|
||||
export { tippy, Tippy, useTippy }
|
||||
const setDefaultProps = tippy.setDefaultProps
|
||||
|
||||
export { useTippy, tippy, setDefaultProps, Tippy }
|
||||
export { TippyOptions }
|
||||
|
||||
Reference in New Issue
Block a user