jenesius-vue-modal
Advanced tools
Comparing version 1.7.2 to 1.8.0
@@ -10,4 +10,5 @@ import closeModal from "./methods/closeModal"; | ||
import closeById from "./methods/closeById"; | ||
import promptModal from "./methods/prompt-modal"; | ||
import WidgetModalContainer from "./components/WidgetModalContainer.vue"; | ||
import useModalRouter from "./routerIntegration"; | ||
export { closeModal, popModal, pushModal, openModal, modalQueue, config, WidgetModalContainer as container, onBeforeModalClose, useModalRouter, getCurrentModal, closeById }; | ||
export { closeModal, popModal, pushModal, openModal, promptModal, modalQueue, config, WidgetModalContainer as container, onBeforeModalClose, useModalRouter, getCurrentModal, closeById }; |
@@ -38,2 +38,6 @@ /** | ||
/** | ||
* @description Event using for promptModal. | ||
*/ | ||
static readonly EVENT_PROMPT = "jenesius-vue-modal:____P____R____O____M____P____T"; | ||
/** | ||
* Создаёт объект управления модальным окном. | ||
@@ -40,0 +44,0 @@ * Для управления идентификатором используется статическое поле modalId. |
/*! | ||
* jenesius-vue-modal v1.7.2 | ||
* jenesius-vue-modal v1.8.0 | ||
* (c) 2022 Jenesius | ||
@@ -592,2 +592,7 @@ * @license MIT | ||
Modal.modalId = 0; | ||
/** | ||
* @description Event using for promptModal. | ||
*/ | ||
Modal.EVENT_PROMPT = 'jenesius-vue-modal:____P____R____O____M____P____T'; | ||
return Modal; | ||
@@ -683,3 +688,56 @@ }(); | ||
} | ||
/** | ||
* @description Method push modalComponent with provided options and then wait until current component will trigger event | ||
* Modal.EVENT_PROMPT. After triggering will close the modal window and return provided data to event. | ||
*/ | ||
function promptModal(component, options) { | ||
if (options === void 0) { | ||
options = {}; | ||
} | ||
return __awaiter(this, void 0, void 0, function () { | ||
var modal; | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
return [4 | ||
/*yield*/ | ||
, pushModal(component, options)]; | ||
case 1: | ||
modal = _a.sent(); | ||
return [2 | ||
/*return*/ | ||
, new Promise(function (resolve) { | ||
modal.on(Modal.EVENT_PROMPT, function (data) { | ||
return __awaiter(_this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
return [4 | ||
/*yield*/ | ||
, modal.close()]; | ||
case 1: | ||
_a.sent(); | ||
resolve(data); | ||
return [2 | ||
/*return*/ | ||
]; | ||
} | ||
}); | ||
}); | ||
}); | ||
})]; | ||
} | ||
}); | ||
}); | ||
} | ||
function styleInject(css, ref) { | ||
@@ -1121,3 +1179,4 @@ if (ref === void 0) ref = {}; | ||
exports.popModal = popModal; | ||
exports.promptModal = promptModal; | ||
exports.pushModal = pushModal; | ||
exports.useModalRouter = useModalRouter; |
{ | ||
"name": "jenesius-vue-modal", | ||
"version": "1.7.2", | ||
"version": "1.8.0", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "description": "Simple modal plugin for Vue3", |
@@ -72,4 +72,5 @@ # Jenesius Vue Modal | ||
- `popModal` - close last opened modal. | ||
- `promptModal` - opening a modal window and waiting for a value to be returned. [More information](https://modal.jenesius.com/guide/guide-methods.html#prompt-modal) | ||
[More information](https://modal.jenesius.com/docs.html/methods) | ||
For detailed information about existing methods, follow the [link](https://modal.jenesius.com/docs.html/methods) | ||
@@ -76,0 +77,0 @@ ```js |
@@ -120,2 +120,5 @@ import {mount} from "@vue/test-utils"; | ||
}) | ||
/** | ||
* Sometimes on this test start throwing error. Check that before each new test you add modalQueue.value = [] | ||
* */ | ||
it("Back", async () => { | ||
@@ -122,0 +125,0 @@ const wrapper = await render(App, {global: {plugins: [router]}}) |
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
110346
54
2616
241