37 lines
804 B
Vue
37 lines
804 B
Vue
<script setup lang="ts">
|
|
import { watch, onBeforeUnmount } from "vue";
|
|
import { TabsList as RekaList, useForwardExpose } from "reka-ui";
|
|
import { useTabs } from "./context";
|
|
defineOptions({ inheritAttrs: false });
|
|
withDefaults(defineProps<{ as?: string; loop?: boolean }>(), {
|
|
as: "div",
|
|
loop: true,
|
|
});
|
|
const ctx = useTabs();
|
|
const { forwardRef, currentElement } = useForwardExpose();
|
|
watch(
|
|
currentElement,
|
|
(el) => {
|
|
ctx.list.value = el;
|
|
ctx.measure();
|
|
},
|
|
{ flush: "post" },
|
|
);
|
|
onBeforeUnmount(() => {
|
|
ctx.list.value = undefined;
|
|
});
|
|
</script>
|
|
<template>
|
|
<RekaList
|
|
:ref="forwardRef"
|
|
v-bind="$attrs"
|
|
:as="as"
|
|
:loop="loop"
|
|
class="hv-tabs__list"
|
|
data-slot="tabs-list"
|
|
:data-orientation="ctx.orientation.value"
|
|
>
|
|
<slot />
|
|
</RekaList>
|
|
</template>
|