@ark-ui/vue
Version:
A collection of unstyled, accessible UI components for Vue, utilizing state machines for seamless interaction.
40 lines (35 loc) • 1.35 kB
JavaScript
;
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
const vue = require('vue');
const domQuery = require('@zag-js/dom-query');
const runIfFn = require('../../utils/run-if-fn.cjs');
const useEnvironmentContext = require('./use-environment-context.cjs');
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
__name: "environment-provider",
props: {
value: { type: Function }
},
setup(__props) {
const props = __props;
const spanRef = vue.ref(null);
const getRootNode = () => runIfFn.runIfFn(props.value) ?? spanRef.value?.getRootNode() ?? document;
const environment = vue.computed(() => ({
getRootNode,
getDocument: () => domQuery.getDocument(getRootNode()),
getWindow: () => domQuery.getWindow(getRootNode())
}));
useEnvironmentContext.EnvironmentContextProvider(environment);
return (_ctx, _cache) => {
return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
vue.renderSlot(_ctx.$slots, "default"),
!props.value ? (vue.openBlock(), vue.createElementBlock("span", {
key: 0,
hidden: "",
ref_key: "spanRef",
ref: spanRef
}, null, 512)) : vue.createCommentVNode("", true)
], 64);
};
}
});
exports.default = _sfc_main;