@ark-ui/vue
Version:
A collection of unstyled, accessible UI components for Vue, utilizing state machines for seamless interaction.
44 lines (39 loc) • 1.09 kB
JavaScript
;
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const vue = require('vue');
const dynamic = require('../utils/dynamic.cjs');
const withAsChild = (component) => {
return vue.defineComponent({
name: "Polymorphic",
inheritAttrs: false,
props: {
asChild: {
type: Boolean,
default: false
}
},
setup(props, { attrs, slots }) {
if (!props.asChild) return () => vue.h(component, { ...attrs }, slots.default?.());
return () => vue.h(dynamic.Dynamic, attrs, { default: slots.default });
}
});
};
function jsxFactory() {
const cache = /* @__PURE__ */ new Map();
const factory = new Proxy(withAsChild, {
apply(_target, _thisArg, argArray) {
return withAsChild(argArray[0]);
},
get(_, element) {
const asElement = element;
if (!cache.has(asElement)) {
cache.set(asElement, withAsChild(asElement));
}
return cache.get(asElement);
}
});
return factory;
}
const ark = jsxFactory();
exports.ark = ark;
exports.jsxFactory = jsxFactory;