UNPKG

@ark-ui/vue

Version:

A collection of unstyled, accessible UI components for Vue, utilizing state machines for seamless interaction.

36 lines (35 loc) 1.1 kB
const require_dynamic = require("../utils/dynamic.cjs"); let vue = require("vue"); //#region src/components/factory.ts var SELF_CLOSING_TAGS = "br, hr, img, input, area, textarea".split(", "); var isSelfClosingTag = (tag) => typeof tag === "string" && SELF_CLOSING_TAGS.includes(tag); var withAsChild = (component) => { return (0, vue.defineComponent)({ name: "Polymorphic", inheritAttrs: false, props: { asChild: { type: Boolean, default: false } }, setup(props, { attrs, slots }) { if (!props.asChild) return () => (0, vue.h)(component, attrs, isSelfClosingTag(component) ? void 0 : slots.default?.()); return () => (0, vue.h)(require_dynamic.Dynamic, attrs, slots); } }); }; function jsxFactory() { const cache = /* @__PURE__ */ new Map(); return new Proxy(withAsChild, { apply(_target, _thisArg, argArray) { return withAsChild(argArray[0]); }, get(_, element) { if (!cache.has(element)) cache.set(element, withAsChild(element)); return cache.get(element); } }); } var ark = jsxFactory(); //#endregion exports.ark = ark; exports.jsxFactory = jsxFactory;