Skip to content

Commit

Permalink
feat(modal): support ractive loading when using hook
Browse files Browse the repository at this point in the history
  • Loading branch information
qmhc committed Apr 19, 2024
1 parent ad27649 commit 0a97e86
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions components/modal/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import { createApp, createVNode, getCurrentInstance, h, nextTick, ref, render } from 'vue'
import { createApp, createVNode, getCurrentInstance, h, nextTick, ref, render, unref } from 'vue'

import Component from './modal.vue'
import { isClient, noop } from '@vexip-ui/utils'

import type { App, AppContext, ComponentPublicInstance } from 'vue'
import type { App, AppContext, ComponentPublicInstance, MaybeRef } from 'vue'
import type { ModalProps } from './props'
import type { ModalCommonSLot } from './symbol'

export type ModalOptions = Omit<ModalProps, 'active' | 'transfer' | 'autoRemove'> & {
export type ModalOptions = Omit<ModalProps, 'active' | 'transfer' | 'loading' | 'autoRemove'> & {
/**
* Specify the app context, ensue the modal using same context
*/
appContext: AppContext,
/**
* Specify whether the modal is loading
*/
loading: MaybeRef<boolean>,
/**
* Another way to use default slot
*/
Expand Down Expand Up @@ -39,6 +43,7 @@ export function useModal(options: Partial<ModalOptions> = {}): () => Promise<voi

const {
appContext,
loading,
renderer,
headerRenderer,
titleRenderer,
Expand Down Expand Up @@ -80,6 +85,7 @@ export function useModal(options: Partial<ModalOptions> = {}): () => Promise<voi
active: active.value,
transfer: false,
autoRemove: false,
loading: unref(loading),
onHide: Array.isArray(onHide) ? [...onHide, destroy] : onHide ? [onHide, destroy] : destroy
},
{
Expand Down

0 comments on commit 0a97e86

Please sign in to comment.