UNPKG

@ark-ui/vue

Version:

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

41 lines (36 loc) 1.23 kB
'use strict'; Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); const vue$1 = require('@zag-js/vue'); const vue = require('vue'); const Dynamic = vue.defineComponent({ name: "Dynamic", inheritAttrs: false, setup(_, { attrs, slots }) { return () => { if (!slots.default) return null; const children = renderSlotFragments(slots.default()); const [firstChildren, ...otherChildren] = children; if (Object.keys(attrs).length > 0) { delete firstChildren.props?.ref; const mergedProps = vue$1.mergeProps(attrs, firstChildren.props ?? {}); const cloned = vue.cloneVNode(firstChildren, mergedProps); for (const prop in mergedProps) { if (prop.startsWith("on")) { cloned.props ||= {}; cloned.props[prop] = mergedProps[prop]; } } return children.length === 1 ? cloned : [cloned, ...otherChildren]; } return children; }; } }); function renderSlotFragments(children) { if (!children) return []; return children.flatMap((child) => { if (child.type === vue.Fragment) return renderSlotFragments(child.children); return [child]; }); } exports.Dynamic = Dynamic;