mirror of
https://github.com/robonen/tools.git
synced 2026-03-20 10:54:44 +00:00
feat(monorepo): migrate vue packages and apply oxlint refactors
This commit is contained in:
22
vue/primitives/src/primitive/Primitive.ts
Normal file
22
vue/primitives/src/primitive/Primitive.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import type { Component, IntrinsicElementAttributes, SetupContext } from 'vue';
|
||||
import { h } from 'vue';
|
||||
import { Slot } from './Slot';
|
||||
|
||||
type FunctionalComponentContext = Omit<SetupContext, 'expose'>;
|
||||
|
||||
export interface PrimitiveProps {
|
||||
as?: keyof IntrinsicElementAttributes | Component;
|
||||
}
|
||||
|
||||
export function Primitive(props: PrimitiveProps, ctx: FunctionalComponentContext) {
|
||||
return props.as === 'template'
|
||||
? h(Slot, ctx.attrs, ctx.slots)
|
||||
: h(props.as!, ctx.attrs, ctx.slots);
|
||||
}
|
||||
|
||||
Primitive.props = {
|
||||
as: {
|
||||
type: [String, Object],
|
||||
default: 'div' as const,
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user