Jenesius/vue-modal

Modal Store and execute modal by name.

Jenesius opened this issue · 6 comments

Is your feature request related to a problem? Please describe.
In one of my project, I have a core of site, that use modal for default functionality. In those case it was show confirm modal when
we want execute some request. In this case we can use openModal('confirmation', { text: 'Do You want start removing data?' })

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

const store = {
  'confirmation': ModalConfirmation
  'apply': ModalApply,
  'notification': ModalNotification
}
openModal('confirmation')
pushModal('apply')
promptModal('notification')

Additional context
Add any other context or screenshots about the feature request here.

Need to chack this solution. It can create a lot of misstake in code. IDE can't detect it by name.

Does it really have some advantages?

config({
  store: {}
})

It can be usefull of some libraries. Also need add method hasModal that will check there is modal with provided name

import ModalConfirm from "./ModalConfirm.vue";
import {config, hasModal} from "jenesius-vue-modal";

config({
  store: {
    confirm: ModalConfirm
  }
})
hasModal('alert') // false
hasModal('confirm') // true

Also need update type declaration for openModal/promptModal/pushModal

hasModal - bad name. Current method can be used for check current modal(current opened modal);

Where we need to check the modal component. Inside openModal(or other public method) or inside addModal

Done