Allow passthrough to root component when creating dialog (#2787)

This commit is contained in:
bymyself
2025-03-01 14:43:32 -07:00
committed by GitHub
parent 9b5fa95ae2
commit 9b8f9bd597
2 changed files with 14 additions and 4 deletions

View File

@@ -7,6 +7,7 @@
class="global-dialog"
v-bind="item.dialogComponentProps"
:auto-z-index="false"
:pt="item.dialogComponentProps.pt"
:pt:mask:style="{ zIndex: baseZIndex + index + 1 }"
:aria-labelledby="item.key"
>

View File

@@ -1,13 +1,22 @@
// We should consider moving to https://primevue.org/dynamicdialog/ once everything is in Vue.
// Currently we need to bridge between legacy app code and Vue app with a Pinia store.
import { merge } from 'lodash'
import { defineStore } from 'pinia'
import type { DialogPassThroughOptions } from 'primevue/dialog'
import { type Component, markRaw, ref } from 'vue'
interface DialogComponentProps {
import type GlobalDialog from '@/components/dialog/GlobalDialog.vue'
interface CustomDialogComponentProps {
maximizable?: boolean
maximized?: boolean
onClose?: () => void
pt?: DialogPassThroughOptions
}
type DialogComponentProps = InstanceType<typeof GlobalDialog>['$props'] &
CustomDialogComponentProps
interface DialogInstance {
key: string
visible: boolean
@@ -15,7 +24,7 @@ interface DialogInstance {
headerComponent?: Component
component: Component
contentProps: Record<string, any>
dialogComponentProps: Record<string, any>
dialogComponentProps: DialogComponentProps
}
export interface ShowDialogOptions {
@@ -90,13 +99,13 @@ export const useDialogStore = defineStore('dialog', () => {
onAfterHide: () => {
closeDialog(dialog)
},
pt: {
pt: merge(options.dialogComponentProps?.pt || {}, {
root: {
onMousedown: () => {
riseDialog(dialog)
}
}
}
})
}
}
dialogStack.value.push(dialog)