diff --git a/packages/vue-final-modal/src/components/CoreModal/useBodyScrollLock.ts b/packages/vue-final-modal/src/components/CoreModal/useBodyScrollLock.ts index 4e009e64..286ad89e 100644 --- a/packages/vue-final-modal/src/components/CoreModal/useBodyScrollLock.ts +++ b/packages/vue-final-modal/src/components/CoreModal/useBodyScrollLock.ts @@ -1,5 +1,6 @@ import type { Ref } from 'vue' import { onBeforeUnmount, watch } from 'vue' +import type { ComponentProps } from 'vue-component-type-helpers' import type CoreModal from './CoreModal.vue' type BodyScrollOptions = { @@ -233,7 +234,7 @@ export const enableBodyScroll = (targetElement?: HTMLElement) => { } } -export function useLockScroll(props: InstanceType['$props'], options: { +export function useLockScroll(props: ComponentProps, options: { lockScrollEl: Ref modelValueLocal: Ref }) { diff --git a/packages/vue-final-modal/src/components/CoreModal/useEvent.ts b/packages/vue-final-modal/src/components/CoreModal/useEvent.ts index 56bc2832..74efacf1 100644 --- a/packages/vue-final-modal/src/components/CoreModal/useEvent.ts +++ b/packages/vue-final-modal/src/components/CoreModal/useEvent.ts @@ -1,8 +1,9 @@ +import type { ComponentEmit } from 'vue-component-type-helpers' import type CoreModal from './CoreModal.vue' type Event = 'beforeOpen' | 'beforeClose' | 'opened' | 'closed' -export function useEvent(emit: InstanceType['$emit']) { +export function useEvent(emit: ComponentEmit) { function emitEvent(e: Event) { switch (e) { case 'beforeOpen': diff --git a/packages/vue-final-modal/src/components/CoreModal/useFocusTrap.ts b/packages/vue-final-modal/src/components/CoreModal/useFocusTrap.ts index eb539319..e818fc50 100644 --- a/packages/vue-final-modal/src/components/CoreModal/useFocusTrap.ts +++ b/packages/vue-final-modal/src/components/CoreModal/useFocusTrap.ts @@ -1,9 +1,10 @@ import type { Ref } from 'vue' import { useFocusTrap as _useFocusTrap } from '@vueuse/integrations/useFocusTrap' +import type { ComponentProps } from 'vue-component-type-helpers' import type CoreModal from './CoreModal.vue' export function useFocusTrap( - props: InstanceType['$props'], + props: ComponentProps, options: { focusEl: Ref }, diff --git a/packages/vue-final-modal/src/components/CoreModal/useModelValue.ts b/packages/vue-final-modal/src/components/CoreModal/useModelValue.ts index a24f1a03..bc3f8365 100644 --- a/packages/vue-final-modal/src/components/CoreModal/useModelValue.ts +++ b/packages/vue-final-modal/src/components/CoreModal/useModelValue.ts @@ -1,10 +1,11 @@ import type { Ref } from 'vue' import { ref, watch } from 'vue' +import type { ComponentEmit, ComponentProps } from 'vue-component-type-helpers' import type CoreModal from './CoreModal.vue' export function useModelValue( - props: InstanceType['$props'], - emit: InstanceType['$emit'], + props: ComponentProps, + emit: ComponentEmit, ): { modelValueLocal: Ref } { const modelValueLocal = ref(!!props.modelValue) watch(() => props.modelValue, (val) => { diff --git a/packages/vue-final-modal/src/components/CoreModal/useToClose.ts b/packages/vue-final-modal/src/components/CoreModal/useToClose.ts index b405c79b..3108cc4d 100644 --- a/packages/vue-final-modal/src/components/CoreModal/useToClose.ts +++ b/packages/vue-final-modal/src/components/CoreModal/useToClose.ts @@ -1,10 +1,11 @@ import type { Ref } from 'vue' import { ref } from 'vue' +import type { ComponentEmit, ComponentProps } from 'vue-component-type-helpers' import type CoreModal from './CoreModal.vue' export function useToClose( - props: InstanceType['$props'], - emit: InstanceType['$emit'], + props: ComponentProps, + emit: ComponentEmit, options: { vfmRootEl: Ref vfmContentEl: Ref diff --git a/packages/vue-final-modal/src/components/CoreModal/useTransition.ts b/packages/vue-final-modal/src/components/CoreModal/useTransition.ts index 6e5de968..ac0faea2 100644 --- a/packages/vue-final-modal/src/components/CoreModal/useTransition.ts +++ b/packages/vue-final-modal/src/components/CoreModal/useTransition.ts @@ -1,4 +1,5 @@ import type { ComputedRef, Ref, TransitionProps } from 'vue' +import type { ComponentProps } from 'vue-component-type-helpers' import { computed, nextTick, ref, watch } from 'vue' import type CoreModal from './CoreModal.vue' @@ -31,7 +32,7 @@ function useTransitionState(_visible = false): [Ref, Ref['$props'], + props: ComponentProps, options: { modelValueLocal: Ref onEntering?: () => void diff --git a/packages/vue-final-modal/src/components/CoreModal/useZIndex.ts b/packages/vue-final-modal/src/components/CoreModal/useZIndex.ts index 2558755d..a4965a55 100644 --- a/packages/vue-final-modal/src/components/CoreModal/useZIndex.ts +++ b/packages/vue-final-modal/src/components/CoreModal/useZIndex.ts @@ -1,8 +1,9 @@ import { ref } from 'vue' +import type { ComponentProps } from 'vue-component-type-helpers' import type CoreModal from './CoreModal.vue' export function useZIndex( - props: InstanceType['$props'], + props: ComponentProps, ) { const zIndex = ref() diff --git a/packages/vue-final-modal/src/useApi.ts b/packages/vue-final-modal/src/useApi.ts index e97996d4..4008bd97 100644 --- a/packages/vue-final-modal/src/useApi.ts +++ b/packages/vue-final-modal/src/useApi.ts @@ -1,6 +1,8 @@ import { computed, inject, markRaw, nextTick, reactive, useAttrs } from 'vue' import { tryOnUnmounted } from '@vueuse/core' import type { Component, ComponentPublicInstance } from 'vue' +import type { ComponentEmit, ComponentProps } from 'vue-component-type-helpers' + import VueFinalModal from './components/VueFinalModal/VueFinalModal.vue' import type CoreModal from './components/CoreModal/CoreModal.vue' import { internalVfmSymbol } from './injectionSymbols' @@ -9,7 +11,7 @@ import type { Constructor, InternalVfm, ModalSlot, ModalSlotOptions, RawProps, U import { activeVfm, getActiveVfm } from './plugin' import { isString } from '~/utils' -type ComponentProps = ComponentPublicInstance['$props'] +type _ComponentProps = ComponentPublicInstance['$props'] /** * Returns the vfm instance. Equivalent to using `$vfm` inside @@ -65,7 +67,7 @@ function withMarkRaw

(options: Partial>, DefaultComponent: /** * Create a dynamic modal. */ -export function useModal

['$props']>(_options: UseModalOptions

): UseModalReturnType

{ +export function useModal

>(_options: UseModalOptions

): UseModalReturnType

{ const options = reactive({ id: Symbol('useModal'), modelValue: !!_options?.defaultModelValue, @@ -202,7 +204,7 @@ export function pickModalProps(props: any, modalProps: any) { }, {} as Record) } -export function byPassAllModalEvents(emit?: InstanceType['$emit']) { +export function byPassAllModalEvents(emit?: ComponentEmit) { if (!emit) return {} return { @@ -219,8 +221,8 @@ export function byPassAllModalEvents(emit?: InstanceType['$emi } export function useVfmAttrs(options: { - props: ComponentProps - modalProps: ComponentProps + props: _ComponentProps + modalProps: _ComponentProps emit?: any }) { const { props, modalProps, emit } = options diff --git a/packages/vue-final-modal/src/useSwipeToClose.ts b/packages/vue-final-modal/src/useSwipeToClose.ts index 3072aaf1..8cb09fe7 100644 --- a/packages/vue-final-modal/src/useSwipeToClose.ts +++ b/packages/vue-final-modal/src/useSwipeToClose.ts @@ -1,12 +1,13 @@ import { useEventListener } from '@vueuse/core' import type { Ref } from 'vue' import { computed, ref, watch } from 'vue' +import type { ComponentProps } from 'vue-component-type-helpers' import type CoreModal from './components/CoreModal/CoreModal.vue' import { useSwipeable } from './useSwipeable' import { clamp, noop } from './utils' export function useSwipeToClose( - props: InstanceType['$props'], + props: ComponentProps, options: { vfmContentEl: Ref modelValueLocal: Ref