The dialog utilities allow you to manage dialogs consistently without putting the components in the template. Or even launch dialogs from a store.
Works with any dialog component. The component should have modelValue
prop that is used to open and close the dialog.
You can import all these properties from the gitart-manage-vue-dialog
module.
gitartDialogInjectionKey
- vue injection key for the dialog controllergitartDialogPlugin
- vue plugin. Usage belowGDialogSpawn
- component to use with plugin. Usage belowIGDialog
- read the codebase for more informationIGDialogItem
- read the codebase for more informationuseDialogConfirm
- read the codebase for more informationuseDialogReturnData
- read the codebase for more informationuseGDialog
- helper to use the dialog controller. Usage below
App.vue
import { GDialogSpawn } from 'gitart-manage-vue-dialog'
<GDialogSpawn />
main.ts
import { gitartDialogPlugin } from 'gitart-manage-vue-dialog'
app.use(gitartDialogPlugin)
You can receive the dialog controller by injection or by using the useGDialog
function.
import { gitartDialogInjectionKey } from 'gitart-manage-vue-dialog'
const $dialog = inject(gitartDialogInjectionKey)!
const openDialog = () => {
$dialog.addDialog({
component: MyDialog,
props: {
title: 'My dialog',
},
})
}
import { useGDialog } from 'gitart-manage-vue-dialog'
const $dialog = useGDialog()
const openDialog = () => {
$dialog.addDialog({
component: MyDialog,
props: {
title: 'My dialog',
},
})
}
$dialog
has the following methods and properties:
addDialog
- add a dialog to the queuedialogs
- list of dialogsremoveDialog
- remove a dialog from the queue