|
| 1 | +import type { Ref, UnwrapRef } from 'vue'; |
| 2 | +import type { CarouselSlots, ThemeOrientation } from '@soybean-ui/variants'; |
| 3 | +import type { ClassValue, ClassValueProp } from '@soybean-ui/primitives'; |
| 4 | +import type useEmblaCarousel from 'embla-carousel-vue'; |
| 5 | +import type { EmblaCarouselVueType } from 'embla-carousel-vue'; |
| 6 | +import type { ButtonProps } from '../button/types'; |
| 7 | + |
| 8 | +type CarouselApi = EmblaCarouselVueType[1]; |
| 9 | +type UseCarouselParameters = Parameters<typeof useEmblaCarousel>; |
| 10 | +type CarouselOptions = UseCarouselParameters[0]; |
| 11 | +type CarouselPlugin = UseCarouselParameters[1]; |
| 12 | + |
| 13 | +export type UnwrapRefCarouselApi = UnwrapRef<CarouselApi>; |
| 14 | + |
| 15 | +export interface CarouselContextParams { |
| 16 | + orientation?: ThemeOrientation; |
| 17 | + opts?: CarouselOptions; |
| 18 | + plugins?: CarouselPlugin; |
| 19 | +} |
| 20 | + |
| 21 | +export interface CarouselContext { |
| 22 | + carouselRef: Ref<HTMLElement | undefined>; |
| 23 | + carouselApi: Ref<UnwrapRefCarouselApi | undefined>; |
| 24 | + canScrollPrev: Ref<boolean>; |
| 25 | + canScrollNext: Ref<boolean>; |
| 26 | + scrollNext: () => void; |
| 27 | + scrollPrev: () => void; |
| 28 | + orientation?: ThemeOrientation; |
| 29 | +} |
| 30 | + |
| 31 | +export interface CarouselRootProps extends ClassValueProp, CarouselContextParams {} |
| 32 | + |
| 33 | +export type CarouselRootEmits = { |
| 34 | + (e: 'initApi', payload: UnwrapRefCarouselApi): void; |
| 35 | +}; |
| 36 | + |
| 37 | +export interface CarouselContentProps extends ClassValueProp { |
| 38 | + wrapperClass?: ClassValue; |
| 39 | +} |
| 40 | + |
| 41 | +export interface CarouselItemProps extends ClassValueProp {} |
| 42 | + |
| 43 | +export interface CarouselNextProps extends ButtonProps {} |
| 44 | + |
| 45 | +export interface CarouselPreviousProps extends ButtonProps {} |
| 46 | + |
| 47 | +export type CarouselUi = Partial<Record<CarouselSlots, ClassValue>>; |
| 48 | + |
| 49 | +export interface CarouselProps extends CarouselRootProps { |
| 50 | + counts?: number; |
| 51 | + ui?: CarouselUi; |
| 52 | + nextProps?: Omit<ButtonProps, 'class'>; |
| 53 | + previousProps?: Omit<ButtonProps, 'class'>; |
| 54 | +} |
| 55 | + |
| 56 | +export type CarouselEmits = CarouselRootEmits; |
0 commit comments