<template>
  <IxModal v-model:visible="dialog.visible"
      :title="dialog.title"
      :type="dialog.type">
    {{ dialog.msg }}
  </IxModal>
</template>

<script lang="ts" setup>
import { ModalType } from '@idux/components'

defineOptions({name: 'Dialog'})

const dialog = reactive<{
  msg: string,
  title: string,
  type: ModalType,
  visible: boolean,
}>({
  msg: 'string',
  title: '',
  type: 'info',
  visible: false,
})


function showDialog(msg: string, title: string, type: ModalType = 'info') {
  Object.assign(dialog, {msg, title, type, visible: true})
}

function closeDialog() {
  dialog.visible = false
}

defineExpose({
  showDialog,
  closeDialog
})
</script>
