UNPKG

@ark-ui/vue

Version:

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

29 lines (24 loc) 933 B
'use strict'; Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); const vue = require('vue'); function useForwardProps(props) { const vm = vue.getCurrentInstance(); const defaultProps = Object.keys(vm?.type.props ?? {}).reduce((prev, curr) => { const defaultValue = (vm?.type.props[curr]).default; if (defaultValue !== void 0) prev[curr] = defaultValue; return prev; }, {}); const refProps = vue.toRef(props); return vue.computed(() => { const preservedProps = {}; const assignedProps = vm?.vnode.props ?? {}; Object.keys(assignedProps).forEach((key) => { preservedProps[vue.camelize(key)] = assignedProps[key]; }); return Object.keys({ ...defaultProps, ...preservedProps }).reduce((prev, curr) => { if (refProps.value[curr] !== void 0) prev[curr] = refProps.value[curr]; return prev; }, {}); }); } exports.useForwardProps = useForwardProps;