UNPKG

@ark-ui/vue

Version:

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

63 lines (58 loc) 1.85 kB
'use strict'; Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); const vue = require('vue'); const unrefElement = require('./unref-element.cjs'); const isElement = (el) => ( // biome-ignore lint/suspicious/noPrototypeBuiltins: <explanation> Object.prototype.hasOwnProperty.call(el, "nodeName") && typeof el.nodeName === "string" ); function useForwardExpose() { const instance = vue.getCurrentInstance(); const currentRef = vue.ref(); const currentElement = vue.computed(() => { return ["#text", "#comment"].includes(currentRef.value?.$el.nodeName) ? ( // @ts-expect-error ignore ts error currentRef.value?.$el.nextElementSibling ) : ( // @ts-expect-error ignore ts error unrefElement.unrefElement(currentRef) ); }); const localExpose = Object.assign({}, instance.exposed); const ret = {}; for (const key in instance.props) { Object.defineProperty(ret, key, { enumerable: true, configurable: true, get: () => instance.props[key] }); } if (Object.keys(localExpose).length > 0) { for (const key in localExpose) { Object.defineProperty(ret, key, { enumerable: true, configurable: true, // biome-ignore lint/style/noNonNullAssertion: intentional get: () => localExpose[key] }); } } Object.defineProperty(ret, "$el", { enumerable: true, configurable: true, get: () => instance.vnode.el }); instance.exposed = ret; function forwardRef(ref2) { currentRef.value = ref2; if (isElement(ref2) || !ref2) return; Object.defineProperty(ret, "$el", { enumerable: true, configurable: true, get: () => ref2.$el }); instance.exposed = ret; } return { forwardRef, currentRef, currentElement }; } exports.useForwardExpose = useForwardExpose;