2022-01-17 18:27:23 +00:00
|
|
|
import { defineComponent, h, Ref } from 'vue'
|
2021-10-21 19:16:52 +00:00
|
|
|
// @ts-ignore
|
2021-06-30 16:32:22 +00:00
|
|
|
import layouts from '#build/layouts'
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
props: {
|
|
|
|
name: {
|
2022-01-17 18:27:23 +00:00
|
|
|
type: [String, Boolean, Object] as unknown as () => string | false | Ref<string | false>,
|
2021-06-30 16:32:22 +00:00
|
|
|
default: 'default'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
setup (props, context) {
|
|
|
|
return () => {
|
2022-01-17 18:27:23 +00:00
|
|
|
const layout = (props.name && typeof props.name === 'object' ? props.name.value : props.name) ?? 'default'
|
2021-06-30 16:32:22 +00:00
|
|
|
if (!layouts[layout]) {
|
|
|
|
if (process.dev && layout && layout !== 'default') {
|
|
|
|
console.warn(`Invalid layout \`${layout}\` selected.`)
|
|
|
|
}
|
|
|
|
return context.slots.default()
|
|
|
|
}
|
|
|
|
return h(layouts[layout], props, context.slots)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|