Line data Source code
1 : import ConfirmBody from '@comfyorg/design-system/confirm/ConfirmBody'
2 : import ConfirmFooter from '@comfyorg/design-system/confirm/ConfirmFooter'
3 : import ConfirmHeader from '@comfyorg/design-system/confirm/ConfirmHeader'
4 : import type { DialogInstance } from '@/stores/dialogStore'
5 : import { useDialogStore } from '@/stores/dialogStore'
6 : import type { ComponentAttrs, ComponentProps } from 'vue-component-type-helpers'
7 :
8 : interface ConfirmDialogOptions {
9 : key?: string
10 : headerProps?: ComponentAttrs<typeof ConfirmHeader>
11 : props?: ComponentAttrs<typeof ConfirmBody>
12 : footerProps: ComponentAttrs<typeof ConfirmFooter> &
13 : Pick<ComponentProps<typeof ConfirmFooter>, 'cancelText' | 'confirmText'>
14 : }
15 :
16 26 : export function showConfirmDialog(
17 : options: ConfirmDialogOptions
18 : ): DialogInstance {
19 26 : const dialogStore = useDialogStore()
20 26 : const { key, headerProps, props, footerProps } = options
21 26 : return dialogStore.showDialog({
22 : key,
23 : headerComponent: ConfirmHeader,
24 : component: ConfirmBody,
25 : footerComponent: ConfirmFooter,
26 : headerProps,
27 : props,
28 : footerProps,
29 : dialogComponentProps: {
30 : flush: true
31 : }
32 : })
33 : }
|