ember-promise-modals 5.0.0 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -3
- package/dist/components/epm-modal-container.js +16 -8
- package/dist/components/epm-modal-container.js.map +1 -1
- package/dist/components/epm-modal.js +69 -61
- package/dist/components/epm-modal.js.map +1 -1
- package/dist/helpers/open-modal.js +9 -5
- package/dist/helpers/open-modal.js.map +1 -1
- package/dist/modal.js +13 -9
- package/dist/modal.js.map +1 -1
- package/dist/services/modals.js +26 -25
- package/dist/services/modals.js.map +1 -1
- package/dist/test-support/index.js.map +1 -1
- package/package.json +28 -23
package/README.md
CHANGED
|
@@ -11,8 +11,7 @@ The better way to handle modals in your Ember.js apps.
|
|
|
11
11
|
## Compatibility
|
|
12
12
|
|
|
13
13
|
- Ember.js v3.28 or above
|
|
14
|
-
-
|
|
15
|
-
- Node.js v16 or above
|
|
14
|
+
- Embroider or ember-auto-import v2
|
|
16
15
|
|
|
17
16
|
## Installation
|
|
18
17
|
|
|
@@ -31,7 +30,7 @@ To use EPM in your project, add the target for the modals to your `application.h
|
|
|
31
30
|
Then you can inject the `modals` [service](https://guides.emberjs.com/release/services/#toc_accessing-services) wherever you need and call its `open` method with a component class to render it as a modal.
|
|
32
31
|
|
|
33
32
|
```js
|
|
34
|
-
import {
|
|
33
|
+
import { service } from '@ember/service';
|
|
35
34
|
import ConfirmationModal from 'my-app/components/confirmation-modal';
|
|
36
35
|
|
|
37
36
|
export default class extends Component {
|
|
@@ -1,14 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import '
|
|
1
|
+
import "./epm-modal-container.css"
|
|
2
|
+
import * as emberService from '@ember/service';
|
|
3
|
+
import Component from '@glimmer/component';
|
|
4
4
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
5
|
+
import { g, i } from 'decorator-transforms/runtime';
|
|
6
|
+
import { setComponentTemplate } from '@ember/component';
|
|
7
|
+
|
|
8
|
+
;
|
|
5
9
|
|
|
6
10
|
var TEMPLATE = precompileTemplate("{{#each this.modals._stack as |modal index|}}\n <div\n class=\"epm-backdrop {{if modal.isClosing \"epm-out\"}}\"\n tabindex=\"-1\"\n role=\"presentation\"\n aria-hidden=\"true\"\n data-test-epm-backdrop=\"{{index}}\"\n />\n <div class=\"epm-modal-container\">\n <EpmModal @modal={{modal}} data-test-epm-modal=\"{{index}}\" />\n </div>\n{{/each}}");
|
|
7
11
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
const service = emberService.service ?? emberService.inject;
|
|
13
|
+
class EpmModalContainer extends Component {
|
|
14
|
+
static {
|
|
15
|
+
g(this.prototype, "modals", [service]);
|
|
16
|
+
}
|
|
17
|
+
#modals = (i(this, "modals"), void 0);
|
|
18
|
+
}
|
|
19
|
+
setComponentTemplate(TEMPLATE, EpmModalContainer);
|
|
12
20
|
|
|
13
|
-
export {
|
|
21
|
+
export { EpmModalContainer as default };
|
|
14
22
|
//# sourceMappingURL=epm-modal-container.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"epm-modal-container.js","sources":[
|
|
1
|
+
{"version":3,"file":"epm-modal-container.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,59 +1,67 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { action } from '@ember/object';
|
|
2
|
+
import * as emberService from '@ember/service';
|
|
3
|
+
import Component from '@glimmer/component';
|
|
4
|
+
import { tracked } from '@glimmer/tracking';
|
|
5
|
+
import { modifier } from 'ember-modifier';
|
|
6
6
|
import { createFocusTrap } from 'focus-trap';
|
|
7
7
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
8
|
+
import { g, i, n } from 'decorator-transforms/runtime';
|
|
9
|
+
import { setComponentTemplate } from '@ember/component';
|
|
8
10
|
|
|
9
|
-
var TEMPLATE = precompileTemplate("
|
|
11
|
+
var TEMPLATE = precompileTemplate("<div {{this.setup}} class=\"epm-modal {{this.optionsClassName}} {{this.animatingClass}}\">\n {{#let (component (ensure-safe-component @modal._componentClass)) as |ModalComponent|}}\n <ModalComponent @data={{@modal._data}} @close={{this.close}} />\n {{/let}}\n</div>");
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
_animationEnd
|
|
20
|
-
|
|
21
|
-
this.
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
const service = emberService.service ?? emberService.inject;
|
|
14
|
+
class EpmModal extends Component {
|
|
15
|
+
static {
|
|
16
|
+
g(this.prototype, "modals", [service]);
|
|
17
|
+
}
|
|
18
|
+
#modals = (i(this, "modals"), void 0);
|
|
19
|
+
element = null;
|
|
20
|
+
outAnimationClass = 'epm-out';
|
|
21
|
+
_animationEnd = null;
|
|
22
|
+
static {
|
|
23
|
+
g(this.prototype, "animatingClass", [tracked], function () {
|
|
24
|
+
return '';
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
#animatingClass = (i(this, "animatingClass"), void 0);
|
|
28
|
+
get optionsClassName() {
|
|
29
|
+
return this.args.modal._options.className;
|
|
30
|
+
}
|
|
31
|
+
get focusTrapOptions() {
|
|
24
32
|
let {
|
|
25
33
|
focusTrapOptions: globalFocusTrapOptions
|
|
26
34
|
} = this.modals;
|
|
27
35
|
let {
|
|
28
36
|
focusTrapOptions: localFocusTrapOptions
|
|
29
|
-
} = this.modal._options;
|
|
30
|
-
if (localFocusTrapOptions !==
|
|
31
|
-
|
|
37
|
+
} = this.args.modal._options;
|
|
38
|
+
if (localFocusTrapOptions !== undefined) {
|
|
39
|
+
return localFocusTrapOptions;
|
|
32
40
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
41
|
+
return globalFocusTrapOptions;
|
|
42
|
+
}
|
|
43
|
+
setup = modifier(element => {
|
|
44
|
+
this.element = element;
|
|
36
45
|
this._addFocusTrap();
|
|
37
46
|
this._addAnimationListeners();
|
|
38
47
|
|
|
39
48
|
// animating in starts when the element is added to the DOM. Inform the service about it.
|
|
40
49
|
this.modals._onModalAnimationStart();
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
50
|
+
return () => {
|
|
51
|
+
this.destroyModal();
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
constructor() {
|
|
55
|
+
super(...arguments);
|
|
56
|
+
this.args.modal._componentInstance = this;
|
|
57
|
+
}
|
|
49
58
|
_addFocusTrap() {
|
|
50
|
-
let element = this._getElement();
|
|
51
59
|
if (!this.focusTrapOptions) {
|
|
52
60
|
return;
|
|
53
61
|
}
|
|
54
62
|
let options = {
|
|
55
63
|
...this.focusTrapOptions,
|
|
56
|
-
fallbackFocus: element,
|
|
64
|
+
fallbackFocus: this.element,
|
|
57
65
|
onDeactivate: (...args) => {
|
|
58
66
|
this.focusTrapOptions.onDeactivate?.(...args);
|
|
59
67
|
if (this.isDestroyed || this.isDestroying) {
|
|
@@ -62,9 +70,9 @@ var epmModal = setComponentTemplate(TEMPLATE, Component.extend({
|
|
|
62
70
|
this.closeModal();
|
|
63
71
|
}
|
|
64
72
|
};
|
|
65
|
-
this.focusTrap = createFocusTrap(element, options);
|
|
73
|
+
this.focusTrap = createFocusTrap(this.element, options);
|
|
66
74
|
this.focusTrap.activate();
|
|
67
|
-
}
|
|
75
|
+
}
|
|
68
76
|
_removeFocusTrap(onDeactivate = this.focusTrapOptions?.onDeactivate) {
|
|
69
77
|
if (!this.focusTrap) {
|
|
70
78
|
return;
|
|
@@ -72,14 +80,14 @@ var epmModal = setComponentTemplate(TEMPLATE, Component.extend({
|
|
|
72
80
|
this.focusTrap.deactivate({
|
|
73
81
|
onDeactivate
|
|
74
82
|
});
|
|
75
|
-
}
|
|
83
|
+
}
|
|
76
84
|
_addAnimationListeners() {
|
|
77
85
|
this._animationEnd = ({
|
|
78
86
|
target,
|
|
79
87
|
animationName
|
|
80
88
|
}) => {
|
|
81
89
|
// ignore animations bubbling up
|
|
82
|
-
if (target !== this.
|
|
90
|
+
if (target !== this.element) {
|
|
83
91
|
return;
|
|
84
92
|
}
|
|
85
93
|
|
|
@@ -87,24 +95,22 @@ var epmModal = setComponentTemplate(TEMPLATE, Component.extend({
|
|
|
87
95
|
this.modals._onModalAnimationEnd();
|
|
88
96
|
let isOutAnimation = animationName.substring(animationName.length - 4) === '-out';
|
|
89
97
|
if (isOutAnimation) {
|
|
90
|
-
this.modal._remove();
|
|
98
|
+
this.args.modal._remove();
|
|
91
99
|
}
|
|
92
100
|
};
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
element.addEventListener('animationend', this._animationEnd);
|
|
101
|
+
if (this.element) {
|
|
102
|
+
this.element.addEventListener('animationend', this._animationEnd);
|
|
96
103
|
}
|
|
97
|
-
}
|
|
104
|
+
}
|
|
98
105
|
_removeAnimationListeners() {
|
|
99
106
|
if (!this._animationEnd) {
|
|
100
107
|
return;
|
|
101
108
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
element.removeEventListener('animationend', this._animationEnd);
|
|
109
|
+
if (this.element) {
|
|
110
|
+
this.element.removeEventListener('animationend', this._animationEnd);
|
|
105
111
|
}
|
|
106
112
|
this._animationEnd = null;
|
|
107
|
-
}
|
|
113
|
+
}
|
|
108
114
|
destroyModal() {
|
|
109
115
|
// Remove the focus trap without triggering the optional onDeactivate() hook
|
|
110
116
|
this._removeFocusTrap(null);
|
|
@@ -113,8 +119,8 @@ var epmModal = setComponentTemplate(TEMPLATE, Component.extend({
|
|
|
113
119
|
this._removeAnimationListeners();
|
|
114
120
|
|
|
115
121
|
// make sure that we remove the modal, also resolving the test waiter
|
|
116
|
-
this.modal._remove();
|
|
117
|
-
}
|
|
122
|
+
this.args.modal._remove();
|
|
123
|
+
}
|
|
118
124
|
closeModal(result) {
|
|
119
125
|
if (this.animatingClass !== '') {
|
|
120
126
|
return;
|
|
@@ -122,18 +128,20 @@ var epmModal = setComponentTemplate(TEMPLATE, Component.extend({
|
|
|
122
128
|
this.modals._onModalAnimationStart();
|
|
123
129
|
|
|
124
130
|
// This triggers the out animation, which in turn will remove the modal after it completes
|
|
125
|
-
|
|
126
|
-
this.modal._resolve(result);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
this.closeModal(result);
|
|
131
|
+
this.animatingClass = this.outAnimationClass;
|
|
132
|
+
this.args.modal._resolve(result);
|
|
133
|
+
}
|
|
134
|
+
close(result) {
|
|
135
|
+
this.closeModal(result);
|
|
131
136
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
137
|
+
// Remove the focus trap, triggering the onDeactivate() hook
|
|
138
|
+
this._removeFocusTrap();
|
|
139
|
+
}
|
|
140
|
+
static {
|
|
141
|
+
n(this.prototype, "close", [action]);
|
|
135
142
|
}
|
|
136
|
-
}
|
|
143
|
+
}
|
|
144
|
+
setComponentTemplate(TEMPLATE, EpmModal);
|
|
137
145
|
|
|
138
|
-
export {
|
|
146
|
+
export { EpmModal as default };
|
|
139
147
|
//# sourceMappingURL=epm-modal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"epm-modal.js","sources":["../../src/components/epm-modal.
|
|
1
|
+
{"version":3,"file":"epm-modal.js","sources":["../../src/components/epm-modal.js"],"sourcesContent":["import { action } from '@ember/object';\nimport * as emberService from '@ember/service';\n\nimport Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\nimport { modifier } from 'ember-modifier';\nimport { createFocusTrap } from 'focus-trap';\n\nconst service = emberService.service ?? emberService.inject;\n\nexport default class EpmModal extends Component {\n @service modals;\n\n element = null;\n outAnimationClass = 'epm-out';\n _animationEnd = null;\n\n @tracked animatingClass = '';\n\n get optionsClassName() {\n return this.args.modal._options.className;\n }\n\n get focusTrapOptions() {\n let { focusTrapOptions: globalFocusTrapOptions } = this.modals;\n let { focusTrapOptions: localFocusTrapOptions } = this.args.modal._options;\n\n if (localFocusTrapOptions !== undefined) {\n return localFocusTrapOptions;\n }\n\n return globalFocusTrapOptions;\n }\n\n setup = modifier(element => {\n this.element = element;\n this._addFocusTrap();\n this._addAnimationListeners();\n\n // animating in starts when the element is added to the DOM. Inform the service about it.\n this.modals._onModalAnimationStart();\n\n return () => {\n this.destroyModal();\n };\n });\n\n constructor() {\n super(...arguments);\n\n this.args.modal._componentInstance = this;\n }\n\n _addFocusTrap() {\n if (!this.focusTrapOptions) {\n return;\n }\n\n let options = {\n ...this.focusTrapOptions,\n fallbackFocus: this.element,\n onDeactivate: (...args) => {\n this.focusTrapOptions.onDeactivate?.(...args);\n\n if (this.isDestroyed || this.isDestroying) {\n return;\n }\n\n this.closeModal();\n },\n };\n\n this.focusTrap = createFocusTrap(this.element, options);\n this.focusTrap.activate();\n }\n\n _removeFocusTrap(onDeactivate = this.focusTrapOptions?.onDeactivate) {\n if (!this.focusTrap) {\n return;\n }\n\n this.focusTrap.deactivate({ onDeactivate });\n }\n\n _addAnimationListeners() {\n this._animationEnd = ({ target, animationName }) => {\n // ignore animations bubbling up\n if (target !== this.element) {\n return;\n }\n\n // An animation has ended, inform the modals service\n this.modals._onModalAnimationEnd();\n\n let isOutAnimation = animationName.substring(animationName.length - 4) === '-out';\n if (isOutAnimation) {\n this.args.modal._remove();\n }\n };\n\n if (this.element) {\n this.element.addEventListener('animationend', this._animationEnd);\n }\n }\n\n _removeAnimationListeners() {\n if (!this._animationEnd) {\n return;\n }\n\n if (this.element) {\n this.element.removeEventListener('animationend', this._animationEnd);\n }\n\n this._animationEnd = null;\n }\n\n destroyModal() {\n // Remove the focus trap without triggering the optional onDeactivate() hook\n this._removeFocusTrap(null);\n\n // Remove the animation listeners\n this._removeAnimationListeners();\n\n // make sure that we remove the modal, also resolving the test waiter\n this.args.modal._remove();\n }\n\n closeModal(result) {\n if (this.animatingClass !== '') {\n return;\n }\n\n this.modals._onModalAnimationStart();\n\n // This triggers the out animation, which in turn will remove the modal after it completes\n this.animatingClass = this.outAnimationClass;\n\n this.args.modal._resolve(result);\n }\n\n @action\n close(result) {\n this.closeModal(result);\n\n // Remove the focus trap, triggering the onDeactivate() hook\n this._removeFocusTrap();\n }\n}\n"],"names":["service","emberService","inject","EpmModal","Component","g","prototype","i","void 0","element","outAnimationClass","_animationEnd","tracked","optionsClassName","args","modal","_options","className","focusTrapOptions","globalFocusTrapOptions","modals","localFocusTrapOptions","undefined","setup","modifier","_addFocusTrap","_addAnimationListeners","_onModalAnimationStart","destroyModal","constructor","arguments","_componentInstance","options","fallbackFocus","onDeactivate","isDestroyed","isDestroying","closeModal","focusTrap","createFocusTrap","activate","_removeFocusTrap","deactivate","target","animationName","_onModalAnimationEnd","isOutAnimation","substring","length","_remove","addEventListener","_removeAnimationListeners","removeEventListener","result","animatingClass","_resolve","close","n","action","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;;;;;AAQA,MAAMA,OAAO,GAAGC,YAAY,CAACD,OAAO,IAAIC,YAAY,CAACC,MAAM;AAE5C,MAAMC,QAAQ,SAASC,SAAS,CAAC;AAAA,EAAA;IAAAC,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,QAAA,EAAA,CAC7CN,OAAO,CAAA,CAAA;AAAA;AAAA,EAAA,OAAA,IAAAO,CAAA,CAAA,IAAA,EAAA,QAAA,CAAA,EAAAC,MAAA;AAERC,EAAAA,OAAO,GAAG,IAAI;AACdC,EAAAA,iBAAiB,GAAG,SAAS;AAC7BC,EAAAA,aAAa,GAAG,IAAI;AAAC,EAAA;IAAAN,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,gBAAA,EAAA,CAEpBM,OAAO,CAAA,EAAA,YAAA;AAAA,MAAA,OAAkB,EAAE;AAAA,IAAA,CAAA,CAAA;AAAA;AAAA,EAAA,eAAA,IAAAL,CAAA,CAAA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AC,IAAI,CAACxC,aAAa,EAAE;AACvB,MAAA;AACF,IAAA;IAEA,IAAI,IAAI,CAACF,OAAO,EAAE;MAChB,IAAI,CAACA,OAAO,CAAC2C,mBAAmB,CAAC,cAAc,EAAE,IAAI,CAACzC,aAAa,CAAC;AACtE,IAAA;IAEA,IAAI,CAACA,aAAa,GAAG,IAAI;AAC3B,EAAA;AAEAiB,EAAAA,YAAYA,GAAG;AACb;AACA,IAAA,IAAI,CAACa,gBAAgB,CAAC,IAAI,CAAC;;AAE3B;IACA,IAAI,CAACU,yBAAyB,EAAE;;AAEhC;AACA,IAAA,IAAI,CAACrC,IAAI,CAACC,KAAK,CAACkC,OAAO,EAAE;AAC3B,EAAA;EAEAZ,UAAUA,CAACgB,MAAM,EAAE;AACjB,IAAA,IAAI,IAAI,CAACC,cAAc,KAAK,EAAE,EAAE;AAC9B,MAAA;AACF,IAAA;AAEA,IAAA,IAAI,CAAClC,MAAM,CAACO,sBAAsB,EAAE;;AAEpC;AACA,IAAA,IAAI,CAAC2B,cAAc,GAAG,IAAI,CAAC5C,iBAAiB;IAE5C,IAAI,CAACI,IAAI,CAACC,KAAK,CAACwC,QAAQ,CAACF,MAAM,CAAC;AAClC,EAAA;EAGAG,KAAKA,CAACH,MAAM,EAAE;AACZ,IAAA,IAAI,CAAChB,UAAU,CAACgB,MAAM,CAAC;;AAEvB;IACA,IAAI,CAACZ,gBAAgB,EAAE;AACzB,EAAA;AAAC,EAAA;IAAAgB,CAAA,CAAA,IAAA,CAAAnD,SAAA,EAAA,OAAA,EAAA,CANAoD,MAAM,CAAA,CAAA;AAAA;AAOT;AAACC,oBAAA,CAAAC,QAAA,EA1IoBzD,QAAQ,CAAA;;;;"}
|
|
@@ -1,25 +1,29 @@
|
|
|
1
1
|
import Helper from '@ember/component/helper';
|
|
2
|
-
import
|
|
2
|
+
import * as emberService from '@ember/service';
|
|
3
3
|
import { g, i } from 'decorator-transforms/runtime';
|
|
4
4
|
|
|
5
|
+
const service = emberService.service ?? emberService.inject;
|
|
5
6
|
class OpenModalHelper extends Helper {
|
|
6
7
|
static {
|
|
7
|
-
g(this.prototype, "modals", [
|
|
8
|
+
g(this.prototype, "modals", [service]);
|
|
8
9
|
}
|
|
9
10
|
#modals = (i(this, "modals"), void 0);
|
|
10
11
|
modal = null;
|
|
12
|
+
once = false;
|
|
11
13
|
compute([modalComponent, data, options], {
|
|
12
14
|
close
|
|
13
15
|
}) {
|
|
16
|
+
if (this.modal || this.once) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
this.once = true;
|
|
14
20
|
this.showModal(modalComponent, data, options, close);
|
|
15
21
|
}
|
|
16
22
|
async showModal(modalComponent, data, options, close) {
|
|
17
23
|
this.modal = this.modals.open(modalComponent, data, options);
|
|
18
24
|
let success = await this.modal;
|
|
19
25
|
this.modal = null;
|
|
20
|
-
|
|
21
|
-
close(success);
|
|
22
|
-
}
|
|
26
|
+
close?.(success);
|
|
23
27
|
}
|
|
24
28
|
hideModal() {
|
|
25
29
|
this.modal?.close();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"open-modal.js","sources":["../../src/helpers/open-modal.js"],"sourcesContent":["import Helper from '@ember/component/helper';\nimport
|
|
1
|
+
{"version":3,"file":"open-modal.js","sources":["../../src/helpers/open-modal.js"],"sourcesContent":["import Helper from '@ember/component/helper';\nimport * as emberService from '@ember/service';\nconst service = emberService.service ?? emberService.inject;\n\nexport default class OpenModalHelper extends Helper {\n @service modals;\n\n modal = null;\n once = false;\n\n compute([modalComponent, data, options], { close }) {\n if (this.modal || this.once) {\n return;\n }\n\n this.once = true;\n\n this.showModal(modalComponent, data, options, close);\n }\n\n async showModal(modalComponent, data, options, close) {\n this.modal = this.modals.open(modalComponent, data, options);\n\n let success = await this.modal;\n\n this.modal = null;\n\n close?.(success);\n }\n\n hideModal() {\n this.modal?.close();\n }\n\n willDestroy() {\n this.hideModal();\n super.willDestroy(...arguments);\n }\n}\n"],"names":["service","emberService","inject","OpenModalHelper","Helper","g","prototype","i","void 0","modal","once","compute","modalComponent","data","options","close","showModal","modals","open","success","hideModal","willDestroy","arguments"],"mappings":";;;;AAEA,MAAMA,OAAO,GAAGC,YAAY,CAACD,OAAO,IAAIC,YAAY,CAACC,MAAM;AAE5C,MAAMC,eAAe,SAASC,MAAM,CAAC;AAAA,EAAA;IAAAC,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,QAAA,EAAA,CACjDN,OAAO,CAAA,CAAA;AAAA;AAAA,EAAA,OAAA,IAAAO,CAAA,CAAA,IAAA,EAAA,QAAA,CAAA,EAAAC,MAAA;AAERC,EAAAA,KAAK,GAAG,IAAI;AACZC,EAAAA,IAAI,GAAG,KAAK;EAEZC,OAAOA,CAAC,CAACC,cAAc,EAAEC,IAAI,EAAEC,OAAO,CAAC,EAAE;AAAEC,IAAAA;AAAM,GAAC,EAAE;AAClD,IAAA,IAAI,IAAI,CAACN,KAAK,IAAI,IAAI,CAACC,IAAI,EAAE;AAC3B,MAAA;AACF,IAAA;IAEA,IAAI,CAACA,IAAI,GAAG,IAAI;IAEhB,IAAI,CAACM,SAAS,CAACJ,cAAc,EAAEC,IAAI,EAAEC,OAAO,EAAEC,KAAK,CAAC;AACtD,EAAA;EAEA,MAAMC,SAASA,CAACJ,cAAc,EAAEC,IAAI,EAAEC,OAAO,EAAEC,KAAK,EAAE;AACpD,IAAA,IAAI,CAACN,KAAK,GAAG,IAAI,CAACQ,MAAM,CAACC,IAAI,CAACN,cAAc,EAAEC,IAAI,EAAEC,OAAO,CAAC;AAE5D,IAAA,IAAIK,OAAO,GAAG,MAAM,IAAI,CAACV,KAAK;IAE9B,IAAI,CAACA,KAAK,GAAG,IAAI;IAEjBM,KAAK,GAAGI,OAAO,CAAC;AAClB,EAAA;AAEAC,EAAAA,SAASA,GAAG;AACV,IAAA,IAAI,CAACX,KAAK,EAAEM,KAAK,EAAE;AACrB,EAAA;AAEAM,EAAAA,WAAWA,GAAG;IACZ,IAAI,CAACD,SAAS,EAAE;AAChB,IAAA,KAAK,CAACC,WAAW,CAAC,GAAGC,SAAS,CAAC;AACjC,EAAA;AACF;;;;"}
|
package/dist/modal.js
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import { computed, set } from '@ember/object';
|
|
2
1
|
import { waitForPromise } from '@ember/test-waiters';
|
|
2
|
+
import { tracked } from '@glimmer/tracking';
|
|
3
3
|
import { defer } from 'rsvp';
|
|
4
|
-
import {
|
|
4
|
+
import { g, i } from 'decorator-transforms/runtime';
|
|
5
5
|
|
|
6
|
-
// eslint-disable-next-line ember/no-computed-properties-in-native-classes
|
|
7
6
|
class Modal {
|
|
7
|
+
static {
|
|
8
|
+
g(this.prototype, "_deferredOutAnimation", [tracked], function () {
|
|
9
|
+
return undefined;
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
#_deferredOutAnimation = (i(this, "_deferredOutAnimation"), void 0);
|
|
8
13
|
constructor(service, componentClass, data, options = {}) {
|
|
9
14
|
this._service = service;
|
|
10
15
|
this._componentClass = componentClass;
|
|
@@ -16,7 +21,6 @@ class Modal {
|
|
|
16
21
|
};
|
|
17
22
|
this._result = undefined;
|
|
18
23
|
this._deferred = defer();
|
|
19
|
-
this._deferredOutAnimation = undefined;
|
|
20
24
|
this._componentInstance = undefined;
|
|
21
25
|
}
|
|
22
26
|
get result() {
|
|
@@ -25,9 +29,6 @@ class Modal {
|
|
|
25
29
|
get isClosing() {
|
|
26
30
|
return Boolean(this._deferredOutAnimation);
|
|
27
31
|
}
|
|
28
|
-
static {
|
|
29
|
-
n(this.prototype, "isClosing", [computed('_deferredOutAnimation')]);
|
|
30
|
-
}
|
|
31
32
|
close(result) {
|
|
32
33
|
if (this._componentInstance) {
|
|
33
34
|
this._componentInstance.closeModal(result);
|
|
@@ -46,7 +47,7 @@ class Modal {
|
|
|
46
47
|
if (this._deferredOutAnimation) {
|
|
47
48
|
return;
|
|
48
49
|
}
|
|
49
|
-
|
|
50
|
+
this._deferredOutAnimation = defer();
|
|
50
51
|
if (this._options.onAnimationModalOutEnd) {
|
|
51
52
|
this._deferredOutAnimation.promise.then(() => this._options.onAnimationModalOutEnd()).catch(() => {});
|
|
52
53
|
}
|
|
@@ -55,7 +56,10 @@ class Modal {
|
|
|
55
56
|
waitForPromise(this._deferredOutAnimation.promise);
|
|
56
57
|
}
|
|
57
58
|
_remove() {
|
|
58
|
-
this._service._stack.
|
|
59
|
+
const index = this._service._stack.indexOf(this);
|
|
60
|
+
if (index !== -1) {
|
|
61
|
+
this._service._stack.splice(index, 1);
|
|
62
|
+
}
|
|
59
63
|
if (this._service._stack.length === 0) {
|
|
60
64
|
this._service._onLastModalRemoved();
|
|
61
65
|
}
|
package/dist/modal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.js","sources":["../src/modal.js"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"modal.js","sources":["../src/modal.js"],"sourcesContent":["import { waitForPromise } from '@ember/test-waiters';\n\nimport { tracked } from '@glimmer/tracking';\nimport { defer } from 'rsvp';\n\n/**\n * @typedef {Object} ModalOptions\n * @property {Function} [onAnimationModalOutEnd]\n * @property {String} [className] - CSS class name passed to the modal element\n */\n\n/**\n * @class Modal\n * @param {Service} service\n * @param {String} componentClass\n * @param {any} data\n * @param {ModalOptions} options\n * @method close - closes the modal\n * @method then - resolves when the modal is closed\n */\nexport default class Modal {\n @tracked _deferredOutAnimation = undefined;\n\n constructor(service, componentClass, data, options = {}) {\n this._service = service;\n this._componentClass = componentClass;\n this._data = data;\n this._options = {\n className: '',\n onAnimationModalOutEnd: undefined,\n ...options,\n };\n this._result = undefined;\n this._deferred = defer();\n this._componentInstance = undefined;\n }\n\n get result() {\n return this._result;\n }\n\n get isClosing() {\n return Boolean(this._deferredOutAnimation);\n }\n\n close(result) {\n if (this._componentInstance) {\n this._componentInstance.closeModal(result);\n }\n }\n\n then(onFulfilled, onRejected) {\n return this._deferred.promise.then(onFulfilled, onRejected);\n }\n\n _destroy() {\n if (!this._componentInstance) {\n return;\n }\n\n this._componentInstance.destroyModal();\n }\n\n _resolve(result) {\n if (this._deferredOutAnimation) {\n return;\n }\n\n this._deferredOutAnimation = defer();\n if (this._options.onAnimationModalOutEnd) {\n this._deferredOutAnimation.promise.then(() => this._options.onAnimationModalOutEnd()).catch(() => {});\n }\n\n this._result = result;\n this._deferred.resolve(result);\n\n waitForPromise(this._deferredOutAnimation.promise);\n }\n\n _remove() {\n const index = this._service._stack.indexOf(this);\n if (index !== -1) {\n this._service._stack.splice(index, 1);\n }\n\n if (this._service._stack.length === 0) {\n this._service._onLastModalRemoved();\n }\n\n this._componentInstance = undefined;\n\n if (this._deferredOutAnimation) {\n this._deferredOutAnimation.resolve();\n }\n }\n}\n"],"names":["Modal","g","prototype","tracked","undefined","i","void 0","constructor","service","componentClass","data","options","_service","_componentClass","_data","_options","className","onAnimationModalOutEnd","_result","_deferred","defer","_componentInstance","result","isClosing","Boolean","_deferredOutAnimation","close","closeModal","then","onFulfilled","onRejected","promise","_destroy","destroyModal","_resolve","catch","resolve","waitForPromise","_remove","index","_stack","indexOf","splice","length","_onLastModalRemoved"],"mappings":";;;;;AAoBe,MAAMA,KAAK,CAAC;AAAA,EAAA;IAAAC,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,uBAAA,EAAA,CACxBC,OAAO,CAAA,EAAA,YAAA;AAAA,MAAA,OAAyBC,SAAS;AAAA,IAAA,CAAA,CAAA;AAAA;AAAA,EAAA,sBAAA,IAAAC,CAAA,CAAA,IAAA,EAAA,uBAAA,CAAA,EAAAC,MAAA;EAE1CC,WAAWA,CAACC,OAAO,EAAEC,cAAc,EAAEC,IAAI,EAAEC,OAAO,GAAG,EAAE,EAAE;IACvD,IAAI,CAACC,QAAQ,GAAGJ,OAAO;IACvB,IAAI,CAACK,eAAe,GAAGJ,cAAc;IACrC,IAAI,CAACK,KAAK,GAAGJ,IAAI;IACjB,IAAI,CAACK,QAAQ,GAAG;AACdC,MAAAA,SAA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ACjB,OAAO,GAAGI,MAAM;AACrB,IAAA,IAAI,CAACH,SAAS,CAACiB,OAAO,CAACd,MAAM,CAAC;AAE9Be,IAAAA,cAAc,CAAC,IAAI,CAACZ,qBAAqB,CAACM,OAAO,CAAC;AACpD,EAAA;AAEAO,EAAAA,OAAOA,GAAG;IACR,MAAMC,KAAK,GAAG,IAAI,CAAC3B,QAAQ,CAAC4B,MAAM,CAACC,OAAO,CAAC,IAAI,CAAC;AAChD,IAAA,IAAIF,KAAK,KAAK,EAAE,EAAE;MAChB,IAAI,CAAC3B,QAAQ,CAAC4B,MAAM,CAACE,MAAM,CAACH,KAAK,EAAE,CAAC,CAAC;AACvC,IAAA;IAEA,IAAI,IAAI,CAAC3B,QAAQ,CAAC4B,MAAM,CAACG,MAAM,KAAK,CAAC,EAAE;AACrC,MAAA,IAAI,CAAC/B,QAAQ,CAACgC,mBAAmB,EAAE;AACrC,IAAA;IAEA,IAAI,CAACvB,kBAAkB,GAAGjB,SAAS;IAEnC,IAAI,IAAI,CAACqB,qBAAqB,EAAE;AAC9B,MAAA,IAAI,CAACA,qBAAqB,CAACW,OAAO,EAAE;AACtC,IAAA;AACF,EAAA;AACF;;;;"}
|
package/dist/services/modals.js
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { alias } from '@ember/object/computed';
|
|
4
|
-
import Service from '@ember/service';
|
|
1
|
+
import emberService__default from '@ember/service';
|
|
2
|
+
import { TrackedArray } from 'tracked-built-ins';
|
|
5
3
|
import Modal from '../modal.js';
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
class ModalsService extends emberService__default {
|
|
6
|
+
_stack = new TrackedArray([]);
|
|
7
|
+
focusTrapOptions = undefined;
|
|
8
|
+
get count() {
|
|
9
9
|
return this._stack.filter(modal => !modal.isClosing).length;
|
|
10
|
-
}
|
|
11
|
-
top
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
}
|
|
11
|
+
get top() {
|
|
12
|
+
return this._stack.at(-1);
|
|
13
|
+
}
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
16
|
if (this.focusTrapOptions !== null) {
|
|
17
17
|
this.focusTrapOptions = {
|
|
18
18
|
...(this.focusTrapOptions ?? {}),
|
|
19
19
|
clickOutsideDeactivates: this.focusTrapOptions?.clickOutsideDeactivates ?? true
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
}
|
|
22
|
+
}
|
|
23
23
|
willDestroy() {
|
|
24
24
|
this._onLastModalRemoved();
|
|
25
25
|
this._onModalAnimationEnd();
|
|
26
26
|
this._destroyModals();
|
|
27
|
-
|
|
28
|
-
}
|
|
27
|
+
super.willDestroy(...arguments);
|
|
28
|
+
}
|
|
29
|
+
|
|
29
30
|
/**
|
|
30
31
|
* @param {*} componentClass component class
|
|
31
32
|
* @param {*} data passed to the component template
|
|
@@ -34,30 +35,30 @@ var modals = Service.extend({
|
|
|
34
35
|
*/
|
|
35
36
|
open(componentClass, data, options) {
|
|
36
37
|
let modal = new Modal(this, componentClass, data, options);
|
|
37
|
-
this._stack.
|
|
38
|
+
this._stack.push(modal);
|
|
38
39
|
if (this._stack.length === 1) {
|
|
39
40
|
this._onFirstModalAdded();
|
|
40
41
|
}
|
|
41
42
|
return modal;
|
|
42
|
-
}
|
|
43
|
+
}
|
|
43
44
|
_destroyModals() {
|
|
44
|
-
this._stack
|
|
45
|
+
for (let modal of this._stack) {
|
|
45
46
|
modal._destroy();
|
|
46
|
-
}
|
|
47
|
-
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
48
49
|
_onFirstModalAdded() {
|
|
49
50
|
document.body.classList.add('epm-scrolling-disabled');
|
|
50
|
-
}
|
|
51
|
+
}
|
|
51
52
|
_onLastModalRemoved() {
|
|
52
53
|
document.body.classList.remove('epm-scrolling-disabled');
|
|
53
|
-
}
|
|
54
|
+
}
|
|
54
55
|
_onModalAnimationStart() {
|
|
55
56
|
document.body.classList.add('epm-animating');
|
|
56
|
-
}
|
|
57
|
+
}
|
|
57
58
|
_onModalAnimationEnd() {
|
|
58
59
|
document.body.classList.remove('epm-animating');
|
|
59
60
|
}
|
|
60
|
-
}
|
|
61
|
+
}
|
|
61
62
|
|
|
62
|
-
export {
|
|
63
|
+
export { ModalsService as default };
|
|
63
64
|
//# sourceMappingURL=modals.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modals.js","sources":["../../src/services/modals.js"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"modals.js","sources":["../../src/services/modals.js"],"sourcesContent":["import Service from '@ember/service';\n\nimport { TrackedArray } from 'tracked-built-ins';\n\nimport Modal from '../modal';\n\nexport default class ModalsService extends Service {\n _stack = new TrackedArray([]);\n\n focusTrapOptions = undefined;\n\n get count() {\n return this._stack.filter(modal => !modal.isClosing).length;\n }\n\n get top() {\n return this._stack.at(-1);\n }\n\n constructor() {\n super(...arguments);\n\n if (this.focusTrapOptions !== null) {\n this.focusTrapOptions = {\n ...(this.focusTrapOptions ?? {}),\n clickOutsideDeactivates: this.focusTrapOptions?.clickOutsideDeactivates ?? true,\n };\n }\n }\n\n willDestroy() {\n this._onLastModalRemoved();\n this._onModalAnimationEnd();\n this._destroyModals();\n\n super.willDestroy(...arguments);\n }\n\n /**\n * @param {*} componentClass component class\n * @param {*} data passed to the component template\n * @param {ModalOptions} options applied to the modal\n * @returns {Modal}\n */\n open(componentClass, data, options) {\n let modal = new Modal(this, componentClass, data, options);\n\n this._stack.push(modal);\n\n if (this._stack.length === 1) {\n this._onFirstModalAdded();\n }\n\n return modal;\n }\n\n _destroyModals() {\n for (let modal of this._stack) {\n modal._destroy();\n }\n }\n\n _onFirstModalAdded() {\n document.body.classList.add('epm-scrolling-disabled');\n }\n\n _onLastModalRemoved() {\n document.body.classList.remove('epm-scrolling-disabled');\n }\n\n _onModalAnimationStart() {\n document.body.classList.add('epm-animating');\n }\n\n _onModalAnimationEnd() {\n document.body.classList.remove('epm-animating');\n }\n}\n"],"names":["ModalsService","Service","_stack","TrackedArray","focusTrapOptions","undefined","count","filter","modal","isClosing","length","top","at","constructor","arguments","clickOutsideDeactivates","willDestroy","_onLastModalRemoved","_onModalAnimationEnd","_destroyModals","open","componentClass","data","options","Modal","push","_onFirstModalAdded","_destroy","document","body","classList","add","remove","_onModalAnimationStart"],"mappings":";;;;AAMe,MAAMA,aAAa,SAASC,qBAAO,CAAC;AACjDC,EAAAA,MAAM,GAAG,IAAIC,YAAY,CAAC,EAAE,CAAC;AAE7BC,EAAAA,gBAAgB,GAAGC,SAAS;EAE5B,IAAIC,KAAKA,GAAG;AACV,IAAA,OAAO,IAAI,CAACJ,MAAM,CAACK,MAAM,CAACC,KAAK,IAAI,CAACA,KAAK,CAACC,SAAS,CAAC,CAACC,MAAM;AAC7D,EAAA;EAEA,IAAIC,GAAGA,GAAG;IACR,OAAO,IAAI,CAACT,MAAM,CAACU,EAAE,CAAC,EAAE,CAAC;AAC3B,EAAA;AAEAC,EAAAA,WAAWA,GAAG;IACZ,KAAK,CAAC,GAAGC,SAAS,CAAC;AAEnB,IAAA,IAAI,IAAI,CAACV,gBAAgB,KAAK,IAAI,EAAE;MAClC,IAAI,CAACA,gBAAgB,GAAG;AACtB,QAAA,IAAI,IAAI,CAACA,gBAAgB,IAAI,EAAE,CAAC;AAChCW,QAAAA,uBAAuB,EAAE,IAAI,CAACX,gBAAgB,EAAEW,uBAAuB,IAAI;OAC5E;AACH,IAAA;AACF,EAAA;AAEAC,EAAAA,WAAWA,GAAG;IACZ,IAAI,CAACC,mBAAmB,EAAE;IAC1B,IAAI,CAACC,oBAAoB,EAAE;IAC3B,IAAI,CAACC,cAAc,EAAE;AAErB,IAAA,KAAK,CAACH,WAAW,CAAC,GAAGF,SAAS,CAAC;AACjC,EAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACEM,EAAAA,IAAIA,CAACC,cAAc,EAAEC,IAAI,EAAEC,OAAO,EAAE;AAClC,IAAA,IAAIf,KAAK,GAAG,IAAIgB,KAAK,CAAC,IAAI,EAAEH,cAAc,EAAEC,IAAI,EAAEC,OAAO,CAAC;AAE1D,IAAA,IAAI,CAACrB,MAAM,CAACuB,IAAI,CAACjB,KAAK,CAAC;AAEvB,IAAA,IAAI,IAAI,CAACN,MAAM,CAACQ,MAAM,KAAK,CAAC,EAAE;MAC5B,IAAI,CAACgB,kBAAkB,EAAE;AAC3B,IAAA;AAEA,IAAA,OAAOlB,KAAK;AACd,EAAA;AAEAW,EAAAA,cAAcA,GAAG;AACf,IAAA,KAAK,IAAIX,KAAK,IAAI,IAAI,CAACN,MAAM,EAAE;MAC7BM,KAAK,CAACmB,QAAQ,EAAE;AAClB,IAAA;AACF,EAAA;AAEAD,EAAAA,kBAAkBA,GAAG;IACnBE,QAAQ,CAACC,IAAI,CAACC,SAAS,CAACC,GAAG,CAAC,wBAAwB,CAAC;AACvD,EAAA;AAEAd,EAAAA,mBAAmBA,GAAG;IACpBW,QAAQ,CAACC,IAAI,CAACC,SAAS,CAACE,MAAM,CAAC,wBAAwB,CAAC;AAC1D,EAAA;AAEAC,EAAAA,sBAAsBA,GAAG;IACvBL,QAAQ,CAACC,IAAI,CAACC,SAAS,CAACC,GAAG,CAAC,eAAe,CAAC;AAC9C,EAAA;AAEAb,EAAAA,oBAAoBA,GAAG;IACrBU,QAAQ,CAACC,IAAI,CAACC,SAAS,CAACE,MAAM,CAAC,eAAe,CAAC;AACjD,EAAA;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/test-support/index.js"],"sourcesContent":["import { settled } from '@ember/test-helpers';\n\nfunction setMinimum(propertyName) {\n document.documentElement.style.setProperty(propertyName, '0.001s');\n}\n\nfunction unsetMinimum(propertyName) {\n document.documentElement.style.removeProperty(propertyName);\n}\n\nexport function setupPromiseModals(hooks) {\n hooks.beforeEach(function () {\n setMinimum('--epm-animation-backdrop-in-duration');\n setMinimum('--epm-animation-backdrop-out-duration');\n setMinimum('--epm-animation-backdrop-in-delay');\n setMinimum('--epm-animation-backdrop-out-delay');\n setMinimum('--epm-animation-modal-in-duration');\n setMinimum('--epm-animation-modal-out-duration');\n setMinimum('--epm-animation-modal-in-delay');\n setMinimum('--epm-animation-modal-out-delay');\n\n this.modals = this.owner.lookup('service:modals');\n });\n\n hooks.afterEach(async function () {\n // be sure to close all modals after a test\n if (this.modals) {\n this.modals._destroyModals();\n }\n\n delete this.modals;\n\n unsetMinimum('--epm-animation-backdrop-in-duration');\n unsetMinimum('--epm-animation-backdrop-out-duration');\n unsetMinimum('--epm-animation-backdrop-in-delay');\n unsetMinimum('--epm-animation-backdrop-out-delay');\n unsetMinimum('--epm-animation-modal-in-duration');\n unsetMinimum('--epm-animation-modal-out-duration');\n unsetMinimum('--epm-animation-modal-in-delay');\n unsetMinimum('--epm-animation-modal-out-delay');\n\n // wait for any registered test waiters to settle\n await settled();\n });\n}\n"],"names":["setMinimum","propertyName","document","documentElement","style","setProperty","unsetMinimum","removeProperty","setupPromiseModals","hooks","beforeEach","modals","owner","lookup","afterEach","_destroyModals","settled"],"mappings":";;AAEA,SAASA,UAAUA,CAACC,YAAY,EAAE;EAChCC,QAAQ,CAACC,eAAe,CAACC,KAAK,CAACC,WAAW,CAACJ,YAAY,EAAE,QAAQ,CAAC
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/test-support/index.js"],"sourcesContent":["import { settled } from '@ember/test-helpers';\n\nfunction setMinimum(propertyName) {\n document.documentElement.style.setProperty(propertyName, '0.001s');\n}\n\nfunction unsetMinimum(propertyName) {\n document.documentElement.style.removeProperty(propertyName);\n}\n\nexport function setupPromiseModals(hooks) {\n hooks.beforeEach(function () {\n setMinimum('--epm-animation-backdrop-in-duration');\n setMinimum('--epm-animation-backdrop-out-duration');\n setMinimum('--epm-animation-backdrop-in-delay');\n setMinimum('--epm-animation-backdrop-out-delay');\n setMinimum('--epm-animation-modal-in-duration');\n setMinimum('--epm-animation-modal-out-duration');\n setMinimum('--epm-animation-modal-in-delay');\n setMinimum('--epm-animation-modal-out-delay');\n\n this.modals = this.owner.lookup('service:modals');\n });\n\n hooks.afterEach(async function () {\n // be sure to close all modals after a test\n if (this.modals) {\n this.modals._destroyModals();\n }\n\n delete this.modals;\n\n unsetMinimum('--epm-animation-backdrop-in-duration');\n unsetMinimum('--epm-animation-backdrop-out-duration');\n unsetMinimum('--epm-animation-backdrop-in-delay');\n unsetMinimum('--epm-animation-backdrop-out-delay');\n unsetMinimum('--epm-animation-modal-in-duration');\n unsetMinimum('--epm-animation-modal-out-duration');\n unsetMinimum('--epm-animation-modal-in-delay');\n unsetMinimum('--epm-animation-modal-out-delay');\n\n // wait for any registered test waiters to settle\n await settled();\n });\n}\n"],"names":["setMinimum","propertyName","document","documentElement","style","setProperty","unsetMinimum","removeProperty","setupPromiseModals","hooks","beforeEach","modals","owner","lookup","afterEach","_destroyModals","settled"],"mappings":";;AAEA,SAASA,UAAUA,CAACC,YAAY,EAAE;EAChCC,QAAQ,CAACC,eAAe,CAACC,KAAK,CAACC,WAAW,CAACJ,YAAY,EAAE,QAAQ,CAAC;AACpE;AAEA,SAASK,YAAYA,CAACL,YAAY,EAAE;EAClCC,QAAQ,CAACC,eAAe,CAACC,KAAK,CAACG,cAAc,CAACN,YAAY,CAAC;AAC7D;AAEO,SAASO,kBAAkBA,CAACC,KAAK,EAAE;EACxCA,KAAK,CAACC,UAAU,CAAC,YAAY;IAC3BV,UAAU,CAAC,sCAAsC,CAAC;IAClDA,UAAU,CAAC,uCAAuC,CAAC;IACnDA,UAAU,CAAC,mCAAmC,CAAC;IAC/CA,UAAU,CAAC,oCAAoC,CAAC;IAChDA,UAAU,CAAC,mCAAmC,CAAC;IAC/CA,UAAU,CAAC,oCAAoC,CAAC;IAChDA,UAAU,CAAC,gCAAgC,CAAC;IAC5CA,UAAU,CAAC,iCAAiC,CAAC;IAE7C,IAAI,CAACW,MAAM,GAAG,IAAI,CAACC,KAAK,CAACC,MAAM,CAAC,gBAAgB,CAAC;AACnD,EAAA,CAAC,CAAC;EAEFJ,KAAK,CAACK,SAAS,CAAC,kBAAkB;AAChC;IACA,IAAI,IAAI,CAACH,MAAM,EAAE;AACf,MAAA,IAAI,CAACA,MAAM,CAACI,cAAc,EAAE;AAC9B,IAAA;IAEA,OAAO,IAAI,CAACJ,MAAM;IAElBL,YAAY,CAAC,sCAAsC,CAAC;IACpDA,YAAY,CAAC,uCAAuC,CAAC;IACrDA,YAAY,CAAC,mCAAmC,CAAC;IACjDA,YAAY,CAAC,oCAAoC,CAAC;IAClDA,YAAY,CAAC,mCAAmC,CAAC;IACjDA,YAAY,CAAC,oCAAoC,CAAC;IAClDA,YAAY,CAAC,gCAAgC,CAAC;IAC9CA,YAAY,CAAC,iCAAiC,CAAC;;AAE/C;IACA,MAAMU,OAAO,EAAE;AACjB,EAAA,CAAC,CAAC;AACJ;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-promise-modals",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"description": "The better way to handle modals in your Ember.js apps.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -36,37 +36,42 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@ember/test-waiters": "^3.0.2",
|
|
38
38
|
"@embroider/addon-shim": "^1.8.7",
|
|
39
|
-
"@embroider/util": "^1.
|
|
40
|
-
"
|
|
41
|
-
"
|
|
39
|
+
"@embroider/util": "^1.13.3",
|
|
40
|
+
"@glimmer/tracking": "^1.1.2",
|
|
41
|
+
"decorator-transforms": "^2.0.0",
|
|
42
|
+
"ember-modifier": "^4.2.2",
|
|
43
|
+
"focus-trap": "^7.0.0",
|
|
44
|
+
"tracked-built-ins": "^4.0.0"
|
|
42
45
|
},
|
|
43
46
|
"devDependencies": {
|
|
44
|
-
"@babel/core": "7.
|
|
45
|
-
"@babel/eslint-parser": "7.
|
|
46
|
-
"@babel/plugin-proposal-decorators": "7.
|
|
47
|
-
"@babel/plugin-transform-class-properties": "7.
|
|
48
|
-
"@
|
|
47
|
+
"@babel/core": "7.28.5",
|
|
48
|
+
"@babel/eslint-parser": "7.28.5",
|
|
49
|
+
"@babel/plugin-proposal-decorators": "7.28.0",
|
|
50
|
+
"@babel/plugin-transform-class-properties": "7.27.1",
|
|
51
|
+
"@ember/test-helpers": "5.2.2",
|
|
52
|
+
"@embroider/addon-dev": "8.1.2",
|
|
53
|
+
"@glimmer/component": "1.1.2",
|
|
49
54
|
"@rollup/plugin-babel": "6.0.4",
|
|
50
|
-
"ember-template-lint": "
|
|
51
|
-
"eslint": "8.57.
|
|
52
|
-
"eslint-config-prettier": "
|
|
53
|
-
"eslint-plugin-ember": "
|
|
54
|
-
"eslint-plugin-import-helpers": "
|
|
55
|
-
"eslint-plugin-n": "
|
|
56
|
-
"eslint-plugin-prettier": "
|
|
57
|
-
"eslint-plugin-promise": "6.
|
|
58
|
-
"eslint-plugin-qunit": "
|
|
55
|
+
"ember-template-lint": "7.9.3",
|
|
56
|
+
"eslint": "8.57.1",
|
|
57
|
+
"eslint-config-prettier": "9.1.2",
|
|
58
|
+
"eslint-plugin-ember": "12.6.0",
|
|
59
|
+
"eslint-plugin-import-helpers": "2.0.1",
|
|
60
|
+
"eslint-plugin-n": "17.21.3",
|
|
61
|
+
"eslint-plugin-prettier": "5.5.4",
|
|
62
|
+
"eslint-plugin-promise": "6.6.0",
|
|
63
|
+
"eslint-plugin-qunit": "8.2.5",
|
|
59
64
|
"npm-run-all": "4.1.5",
|
|
60
|
-
"prettier": "
|
|
61
|
-
"rollup": "4.
|
|
65
|
+
"prettier": "3.6.2",
|
|
66
|
+
"rollup": "4.45.3",
|
|
62
67
|
"rollup-plugin-copy": "3.5.0",
|
|
63
|
-
"webpack": "5.
|
|
68
|
+
"webpack": "5.100.2"
|
|
64
69
|
},
|
|
65
70
|
"peerDependencies": {
|
|
66
|
-
"@ember/test-helpers": "^3.0.0"
|
|
71
|
+
"@ember/test-helpers": "^3.0.0 || ^5.0.0"
|
|
67
72
|
},
|
|
68
73
|
"engines": {
|
|
69
|
-
"node": ">=
|
|
74
|
+
"node": ">= 18.*"
|
|
70
75
|
},
|
|
71
76
|
"ember": {
|
|
72
77
|
"edition": "octane"
|