UNPKG

@ark-ui/vue

Version:

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

36 lines (33 loc) 1.25 kB
import { defineComponent, ref, computed, createElementBlock, openBlock, Fragment, renderSlot, createCommentVNode } from 'vue'; import { getWindow, getDocument } from '@zag-js/dom-query'; import { runIfFn } from '../../utils/run-if-fn.js'; import { EnvironmentContextProvider } from './use-environment-context.js'; const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "environment-provider", props: { value: { type: Function } }, setup(__props) { const props = __props; const spanRef = ref(null); const getRootNode = () => runIfFn(props.value) ?? spanRef.value?.getRootNode() ?? document; const environment = computed(() => ({ getRootNode, getDocument: () => getDocument(getRootNode()), getWindow: () => getWindow(getRootNode()) })); EnvironmentContextProvider(environment); return (_ctx, _cache) => { return openBlock(), createElementBlock(Fragment, null, [ renderSlot(_ctx.$slots, "default"), !props.value ? (openBlock(), createElementBlock("span", { key: 0, hidden: "", ref_key: "spanRef", ref: spanRef }, null, 512)) : createCommentVNode("", true) ], 64); }; } }); export { _sfc_main as default };