reka-ui
Version:
Vue port for Radix UI Primitives.
64 lines (61 loc) • 2.13 kB
JavaScript
import { defineComponent, toRefs, ref, createBlock, openBlock, unref, withCtx, renderSlot } from 'vue';
import { useVModel } from '@vueuse/core';
import { c as createContext } from '../shared/createContext.js';
import { u as useDirection } from '../shared/useDirection.js';
import { u as useForwardExpose } from '../shared/useForwardExpose.js';
import { u as useId } from '../shared/useId.js';
import { P as Primitive } from '../Primitive/Primitive.js';
const [injectTabsRootContext, provideTabsRootContext] = createContext("TabsRoot");
const _sfc_main = /* @__PURE__ */ defineComponent({
__name: "TabsRoot",
props: {
defaultValue: {},
orientation: { default: "horizontal" },
dir: {},
activationMode: { default: "automatic" },
modelValue: {},
unmountOnHide: { type: Boolean, default: true },
asChild: { type: Boolean },
as: {}
},
emits: ["update:modelValue"],
setup(__props, { emit: __emit }) {
const props = __props;
const emits = __emit;
const { orientation, unmountOnHide, dir: propDir } = toRefs(props);
const dir = useDirection(propDir);
useForwardExpose();
const modelValue = useVModel(props, "modelValue", emits, {
defaultValue: props.defaultValue,
passive: props.modelValue === void 0
});
const tabsList = ref();
provideTabsRootContext({
modelValue,
changeModelValue: (value) => {
modelValue.value = value;
},
orientation,
dir,
unmountOnHide,
activationMode: props.activationMode,
baseId: useId(void 0, "reka-tabs"),
tabsList
});
return (_ctx, _cache) => {
return openBlock(), createBlock(unref(Primitive), {
dir: unref(dir),
"data-orientation": unref(orientation),
"as-child": _ctx.asChild,
as: _ctx.as
}, {
default: withCtx(() => [
renderSlot(_ctx.$slots, "default", { modelValue: unref(modelValue) })
]),
_: 3
}, 8, ["dir", "data-orientation", "as-child", "as"]);
};
}
});
export { _sfc_main as _, injectTabsRootContext as i };
//# sourceMappingURL=TabsRoot.js.map