jenesius-vue-modal
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "jenesius-vue-modal", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "description": "Simple modal", |
@@ -8,2 +8,4 @@ # Jenesius Vue Modal | ||
For add modals in your project you need to put the modal's container in the App component: | ||
`App.vue` | ||
```vue | ||
@@ -33,3 +35,3 @@ <template> | ||
```js | ||
import useModal from "jenesius-vue-modal"; | ||
import {useModal} from "jenesius-vue-modal"; | ||
@@ -51,3 +53,3 @@ export default{ | ||
| `closeModal()` | Close all modals | | ||
| `pushModal(VuewComponent, props)` | Add on top modal component | | ||
| `pushModal(VueComponent, props)` | Add on top modal component | | ||
| `popModal()` | Close the last modal component | | ||
@@ -72,3 +74,3 @@ | ||
```js | ||
import useModal from "jenesius-vue-modal" | ||
import {useModal} from "jenesius-vue-modal" | ||
import WidgeTestModal from "WidgeTestModal.vue"; | ||
@@ -75,0 +77,0 @@ |
@@ -18,3 +18,6 @@ import {ref, watch, shallowRef} from "vue"; | ||
let _modalId = 0; | ||
const state = { | ||
modalId: 0, | ||
initialized: false | ||
} | ||
@@ -28,3 +31,2 @@ export const modalQueue = ref([]); | ||
function closeById(id){ | ||
@@ -61,12 +63,17 @@ const indexFoRemove = modalQueue.value.findIndex(item => item.id === id); | ||
_modalId++; | ||
if (!state.initialized) { | ||
throw `Modal Container not found. Put container from jenesius-vue-modal in App's template. Check documentation for more information https://www.npmjs.com/package/jenesius-vue-modal.`; | ||
} | ||
state.modalId++; | ||
modalQueue.value.push({ | ||
component : shallowRef(component), | ||
params : params, | ||
id : _modalId | ||
id : state.modalId | ||
}); | ||
return ModalObject(_modalId); | ||
return ModalObject(state.modalId); | ||
} | ||
@@ -85,13 +92,14 @@ | ||
export default () => ({ | ||
modalQueue, | ||
export function useModal(){ | ||
return { | ||
openModal, | ||
closeModal, | ||
openModal, | ||
closeModal, | ||
popModal, | ||
pushModal, | ||
} | ||
} | ||
popModal, | ||
pushModal, | ||
container: WidgetModalContainer | ||
}) | ||
export function initialize(){ | ||
state.initialized = true; | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7947
76
80