21 lines
526 B
TypeScript
21 lines
526 B
TypeScript
import type { Component } from 'vue'
|
|
import { defineComponent, h } from 'vue'
|
|
import Slot from './slot'
|
|
|
|
export const Primitive = defineComponent({
|
|
name: 'Primitive',
|
|
inheritAttrs: false,
|
|
props: {
|
|
as: {
|
|
type: [String, Object, Function] as unknown as () => string | Component,
|
|
default: 'div',
|
|
},
|
|
asChild: { type: Boolean, default: false },
|
|
},
|
|
setup(props, { slots, attrs }) {
|
|
return () => {
|
|
const Tag = props.asChild ? Slot : props.as
|
|
return h(Tag, attrs, slots)
|
|
}
|
|
},
|
|
})
|