dev
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
<script lang="ts">
|
||||
export const tabsContextKey = Symbol("tabs") as InjectionKey<TabsContextValue>;
|
||||
</script>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { provide } from "vue";
|
||||
import type { InjectionKey, Ref } from "vue";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export interface TabsContextValue {
|
||||
modelValue: Ref<string>;
|
||||
setValue: (value: string) => void;
|
||||
}
|
||||
|
||||
const props = defineProps<{
|
||||
class?: string;
|
||||
}>();
|
||||
|
||||
const modelValue = defineModel<string>({ required: true });
|
||||
|
||||
const setValue = (value: string) => {
|
||||
modelValue.value = value;
|
||||
};
|
||||
|
||||
provide(tabsContextKey, {
|
||||
modelValue,
|
||||
setValue,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div data-slot="tabs" :class="cn('flex flex-col gap-3', props.class)">
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user