Skip to content

Commit 3608bcd

Browse files
committed
refactor(Carousel): generics and default types
1 parent 859e034 commit 3608bcd

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/runtime/components/Carousel.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ const carousel = tv({ extend: tv(theme), ...(appConfigCarousel.ui?.carousel || {
2222
2323
type CarouselVariants = VariantProps<typeof carousel>
2424
25-
export interface CarouselProps<T> extends Omit<EmblaOptionsType, 'axis' | 'container' | 'slides' | 'direction'> {
25+
export type CarouselItem = AcceptableValue
26+
27+
export interface CarouselProps<T extends CarouselItem = CarouselItem> extends Omit<EmblaOptionsType, 'axis' | 'container' | 'slides' | 'direction'> {
2628
/**
2729
* The element or component this component should render as.
2830
* @defaultValue 'div'
@@ -94,14 +96,14 @@ export interface CarouselProps<T> extends Omit<EmblaOptionsType, 'axis' | 'conta
9496
ui?: PartialString<typeof carousel.slots>
9597
}
9698
97-
export type CarouselSlots<T> = {
99+
export type CarouselSlots<T extends CarouselItem = CarouselItem> = {
98100
default(props: { item: T, index: number }): any
99101
}
100102
101103
extendDevtoolsMeta({ example: 'CarouselExample' })
102104
</script>
103105

104-
<script setup lang="ts" generic="T extends AcceptableValue">
106+
<script setup lang="ts" generic="T extends CarouselItem = CarouselItem">
105107
import { computed, ref, watch, onMounted } from 'vue'
106108
import useEmblaCarousel from 'embla-carousel-vue'
107109
import { Primitive, useForwardProps } from 'reka-ui'

0 commit comments

Comments
 (0)