chore: use shadcn-ui way to extract types from embla-carousel-vue module
This commit is contained in:
parent
7c8e03d81e
commit
bf0f4ed6b2
|
|
@ -6,5 +6,5 @@ export { default as CarouselNext } from './CarouselNext.vue'
|
|||
export { useCarousel } from './useCarousel'
|
||||
|
||||
export type {
|
||||
EmblaCarouselType as CarouselApi,
|
||||
} from 'embla-carousel'
|
||||
UnwrapRefCarouselApi as CarouselApi,
|
||||
} from './interface'
|
||||
|
|
|
|||
|
|
@ -1,18 +1,24 @@
|
|||
import type { HTMLAttributes, UnwrapRef } from 'vue'
|
||||
import type useEmblaCarousel from 'embla-carousel-vue'
|
||||
import type {
|
||||
EmblaCarouselType as CarouselApi,
|
||||
EmblaOptionsType as CarouselOptions,
|
||||
EmblaPluginType as CarouselPlugin,
|
||||
} from 'embla-carousel'
|
||||
import type { HTMLAttributes, Ref } from 'vue'
|
||||
EmblaCarouselVueType,
|
||||
} from 'embla-carousel-vue'
|
||||
|
||||
type CarouselApi = EmblaCarouselVueType[1]
|
||||
type UseCarouselParameters = Parameters<typeof useEmblaCarousel>
|
||||
type CarouselOptions = UseCarouselParameters[0]
|
||||
type CarouselPlugin = UseCarouselParameters[1]
|
||||
|
||||
export type UnwrapRefCarouselApi = UnwrapRef<CarouselApi>
|
||||
|
||||
export interface CarouselProps {
|
||||
opts?: CarouselOptions | Ref<CarouselOptions>
|
||||
plugins?: CarouselPlugin[] | Ref<CarouselPlugin[]>
|
||||
opts?: CarouselOptions
|
||||
plugins?: CarouselPlugin
|
||||
orientation?: 'horizontal' | 'vertical'
|
||||
}
|
||||
|
||||
export interface CarouselEmits {
|
||||
(e: 'init-api', payload: CarouselApi): void
|
||||
(e: 'init-api', payload: UnwrapRefCarouselApi): void
|
||||
}
|
||||
|
||||
export interface WithClassAsProps {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
import { createInjectionState } from '@vueuse/core'
|
||||
import emblaCarouselVue from 'embla-carousel-vue'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import type {
|
||||
EmblaCarouselType as CarouselApi,
|
||||
} from 'embla-carousel'
|
||||
import type { CarouselEmits, CarouselProps } from './interface'
|
||||
import type { UnwrapRefCarouselApi as CarouselApi, CarouselEmits, CarouselProps } from './interface'
|
||||
|
||||
const [useProvideCarousel, useInjectCarousel] = createInjectionState(
|
||||
({
|
||||
|
|
@ -27,7 +24,7 @@ const [useProvideCarousel, useInjectCarousel] = createInjectionState(
|
|||
const canScrollNext = ref(false)
|
||||
const canScrollPrev = ref(false)
|
||||
|
||||
function onSelect(api?: CarouselApi) {
|
||||
function onSelect(api: CarouselApi) {
|
||||
canScrollNext.value = api?.canScrollNext() || false
|
||||
canScrollPrev.value = api?.canScrollPrev() || false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,5 +6,5 @@ export { default as CarouselNext } from './CarouselNext.vue'
|
|||
export { useCarousel } from './useCarousel'
|
||||
|
||||
export type {
|
||||
EmblaCarouselType as CarouselApi,
|
||||
} from 'embla-carousel'
|
||||
UnwrapRefCarouselApi as CarouselApi,
|
||||
} from './interface'
|
||||
|
|
|
|||
|
|
@ -1,18 +1,24 @@
|
|||
import type { HTMLAttributes, UnwrapRef } from 'vue'
|
||||
import type useEmblaCarousel from 'embla-carousel-vue'
|
||||
import type {
|
||||
EmblaCarouselType as CarouselApi,
|
||||
EmblaOptionsType as CarouselOptions,
|
||||
EmblaPluginType as CarouselPlugin,
|
||||
} from 'embla-carousel'
|
||||
import type { HTMLAttributes, Ref } from 'vue'
|
||||
EmblaCarouselVueType,
|
||||
} from 'embla-carousel-vue'
|
||||
|
||||
type CarouselApi = EmblaCarouselVueType[1]
|
||||
type UseCarouselParameters = Parameters<typeof useEmblaCarousel>
|
||||
type CarouselOptions = UseCarouselParameters[0]
|
||||
type CarouselPlugin = UseCarouselParameters[1]
|
||||
|
||||
export type UnwrapRefCarouselApi = UnwrapRef<CarouselApi>
|
||||
|
||||
export interface CarouselProps {
|
||||
opts?: CarouselOptions | Ref<CarouselOptions>
|
||||
plugins?: CarouselPlugin[] | Ref<CarouselPlugin[]>
|
||||
opts?: CarouselOptions
|
||||
plugins?: CarouselPlugin
|
||||
orientation?: 'horizontal' | 'vertical'
|
||||
}
|
||||
|
||||
export interface CarouselEmits {
|
||||
(e: 'init-api', payload: CarouselApi): void
|
||||
(e: 'init-api', payload: UnwrapRefCarouselApi): void
|
||||
}
|
||||
|
||||
export interface WithClassAsProps {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
import { createInjectionState } from '@vueuse/core'
|
||||
import emblaCarouselVue from 'embla-carousel-vue'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import type {
|
||||
EmblaCarouselType as CarouselApi,
|
||||
} from 'embla-carousel'
|
||||
import type { CarouselEmits, CarouselProps } from './interface'
|
||||
import type { UnwrapRefCarouselApi as CarouselApi, CarouselEmits, CarouselProps } from './interface'
|
||||
|
||||
const [useProvideCarousel, useInjectCarousel] = createInjectionState(
|
||||
({
|
||||
|
|
@ -27,7 +24,7 @@ const [useProvideCarousel, useInjectCarousel] = createInjectionState(
|
|||
const canScrollNext = ref(false)
|
||||
const canScrollPrev = ref(false)
|
||||
|
||||
function onSelect(api?: CarouselApi) {
|
||||
function onSelect(api: CarouselApi) {
|
||||
canScrollNext.value = api?.canScrollNext() || false
|
||||
canScrollPrev.value = api?.canScrollPrev() || false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ const DEPENDENCIES = new Map<string, string[]>([
|
|||
['v-calendar', []],
|
||||
['@tanstack/vue-table', []],
|
||||
['@unovis/vue', ['@unovis/ts']],
|
||||
['embla-carousel-vue', ['embla-carousel']],
|
||||
['embla-carousel-vue', []],
|
||||
['vee-validate', ['@vee-validate/zod', 'zod']],
|
||||
])
|
||||
// Some dependencies latest tag were not compatible with Vue3.
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user